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 */
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
* @return info
@ -72,8 +76,13 @@ public class VTabbedPane extends CTabbedPane
public void addTab(String tabName, GridTab gTab, Component tabElement)
{
int index = getTabCount();
tabNames.add(tabName);
gTabs.add(gTab);
components.add(tabElement);
super.addTab (tabName, gTab.getIcon(),
tabElement, gTab.getDescription());
tabElement, gTab.getDescription());
ArrayList<String> dependents = gTab.getDependentOn();
for (int i = 0; i < dependents.size(); i++)
{
@ -86,7 +95,35 @@ public class VTabbedPane extends CTabbedPane
setDisabledIconAt(index, s_disabledIcon);
} // 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
* @param isWorkbench
@ -269,17 +306,17 @@ public class VTabbedPane extends CTabbedPane
if (process)
{
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)
{
GridController gc = (GridController)c;
String logic = gc.getDisplayLogic();
boolean display = true;
if (logic != null && logic.length() > 0)
display = Evaluator.evaluateLogic(gc, logic);
setEnabledAt(i, display);
boolean display = isDisplay(gc);
if ( display )
showTab(tabNames.get(i));
else
hideTab(tabNames.get(i));
}
}
}