phib 2008-10-20 23:43:16 +00:00
parent db9ea70885
commit 68b2444b1d
1 changed files with 46 additions and 9 deletions

View File

@ -53,6 +53,10 @@ public class VTabbedPane extends CTabbedPane
/** Disabled Icon */ /** Disabled Icon */
private static Icon s_disabledIcon = null; private static Icon s_disabledIcon = null;
private ArrayList<Component> components = new ArrayList<Component>();
private ArrayList<GridTab> gTabs = new ArrayList<GridTab>();
private ArrayList<String> tabNames = new ArrayList<String>();
/** /**
* toString * toString
* @return info * @return info
@ -72,8 +76,13 @@ public class VTabbedPane extends CTabbedPane
public void addTab(String tabName, GridTab gTab, Component tabElement) public void addTab(String tabName, GridTab gTab, Component tabElement)
{ {
int index = getTabCount(); int index = getTabCount();
tabNames.add(tabName);
gTabs.add(gTab);
components.add(tabElement);
super.addTab (tabName, gTab.getIcon(), super.addTab (tabName, gTab.getIcon(),
tabElement, gTab.getDescription()); tabElement, gTab.getDescription());
ArrayList<String> dependents = gTab.getDependentOn(); ArrayList<String> dependents = gTab.getDependentOn();
for (int i = 0; i < dependents.size(); i++) for (int i = 0; i < dependents.size(); i++)
{ {
@ -86,7 +95,35 @@ public class VTabbedPane extends CTabbedPane
setDisabledIconAt(index, s_disabledIcon); setDisabledIconAt(index, s_disabledIcon);
} // addTab } // addTab
private void hideTab(String tabName) {
int tabIndex = indexOfTab(tabName);
if ( tabIndex != -1 )
removeTabAt(tabIndex);
}
private void showTab(String tabName) {
int insertAt = 0;
if ( indexOfTab(tabName) != -1 ) // already visible
return;
for ( int i = 0; i < tabNames.size(); i++ )
{
String name = tabNames.get(i);
if ( name.equals(tabName))
{
insertTab (tabName, gTabs.get(i).getIcon(),
components.get(i), gTabs.get(i).getDescription(), insertAt);
break;
}
if ( indexOfTab(name) != -1 ) // tab is visible, insert after
insertAt ++;
}
}
/** /**
* Set Workbench - or Window * Set Workbench - or Window
* @param isWorkbench * @param isWorkbench
@ -269,17 +306,17 @@ public class VTabbedPane extends CTabbedPane
if (process) if (process)
{ {
log.config(columnName == null ? "" : columnName); log.config(columnName == null ? "" : columnName);
for (int i = 0; i < getTabCount(); i++) for (int i = 0; i < components.size(); i++)
{ {
Component c = getComponentAt(i); Component c = components.get(i);
if (c instanceof GridController) if (c instanceof GridController)
{ {
GridController gc = (GridController)c; GridController gc = (GridController)c;
String logic = gc.getDisplayLogic(); boolean display = isDisplay(gc);
boolean display = true; if ( display )
if (logic != null && logic.length() > 0) showTab(tabNames.get(i));
display = Evaluator.evaluateLogic(gc, logic); else
setEnabledAt(i, display); hideTab(tabNames.get(i));
} }
} }
} }