* [1637757] Project - phase line tab to phase tab throw exception

* [1637763] Tab navigation should ignore disabled tab
* [1638337] Can't skip tab level even when it is valid to do so
This commit is contained in:
Heng Sin Low 2007-01-18 17:16:32 +00:00
parent 6e30c7b864
commit e9ec86056a
3 changed files with 111 additions and 22 deletions

View File

@ -516,6 +516,7 @@ public final class APanel extends CPanel
boolean included = false;
// MTab
GridTab gTab = m_mWorkbench.getMWindow(wb).getTab(tab);
Env.setContext(m_ctx, m_curWindowNo, tab, "TabLevel", Integer.toString(gTab.getTabLevel()));
// Query first tab
if (tab == 0)
{
@ -1127,8 +1128,29 @@ public final class APanel extends CPanel
int index = m_curWinTab.getSelectedIndex();
if (index == m_curWinTab.getTabCount()-1)
return;
m_curGC.getTable().removeEditor();
m_curWinTab.setSelectedIndex(index+1);
//hengsin, bug [ 1637763 ]
if (m_curWinTab instanceof VTabbedPane)
{
VTabbedPane tabPane = (VTabbedPane)m_curWinTab;
index++;
while ( index < tabPane.getTabCount() )
{
if (tabPane.isEnabledAt(index))
{
m_curGC.getTable().removeEditor();
tabPane.setSelectedIndex(index);
break;
}
else
index++;
}
}
else
{
m_curGC.getTable().removeEditor();
m_curWinTab.setSelectedIndex(index+1);
}
} // navigateDetail
/**
@ -1139,8 +1161,28 @@ public final class APanel extends CPanel
int index = m_curWinTab.getSelectedIndex();
if (index == 0)
return;
m_curGC.getTable().removeEditor();
m_curWinTab.setSelectedIndex(index-1);
//hengsin, bug [ 1637763 ]
if (m_curWinTab instanceof VTabbedPane)
{
VTabbedPane tabPane = (VTabbedPane)m_curWinTab;
index--;
while ( index >= 0 )
{
if (tabPane.isEnabledAt(index))
{
m_curGC.getTable().removeEditor();
tabPane.setSelectedIndex(index);
break;
}
else
index--;
}
}
else
{
m_curGC.getTable().removeEditor();
m_curWinTab.setSelectedIndex(index-1);
}
} // navigateParent

View File

@ -1098,5 +1098,12 @@ public class GridController extends CPanel
return Env.getContext(Env.getCtx(), m_WindowNo, variableName);
} // get_ValueAsString
/**
* Is controller data not stale
* @return boolean
*/
public boolean isCurrent()
{
return m_mTab != null ? m_mTab.isCurrent() : false;
}
} // GridController

View File

@ -146,6 +146,38 @@ public class VTabbedPane extends CTabbedPane
removeAll();
} // dispose
@Override
//hengsin, bug [ 1637763 ]
public boolean isEnabledAt(int index) {
boolean enabled = super.isEnabledAt(index);
if (!enabled) return enabled;
Component comp = getComponentAt(index);
GridController gc = null;
if (comp instanceof GridController)
gc = (GridController)comp;
// Display
if (gc != null)
{
enabled = isDisplay(gc);
}
return enabled;
}
//hengsin, bug [ 1637763 ]
private boolean isDisplay(GridController gc)
{
String logic = gc.getDisplayLogic();
if (logic != null && logic.length() > 0)
{
boolean display = Evaluator.evaluateLogic(gc, logic);
if (!display)
{
log.info("Not displayed - " + logic);
return false;
}
}
return true;
}
/**
* Set Selected Index.
@ -161,16 +193,9 @@ public class VTabbedPane extends CTabbedPane
// Display
if (newGC != null)
{
String logic = newGC.getDisplayLogic();
if (logic != null && logic.length() > 0)
{
boolean display = Evaluator.evaluateLogic(newGC, logic);
if (!display)
{
log.info("Not displayed - " + logic);
return;
}
}
//hengsin, bug [ 1637763 ]
if(isDisplay(newGC) == false)
return;
}
//
@ -183,23 +208,38 @@ public class VTabbedPane extends CTabbedPane
GridController oldGC = (GridController)oldC;
if (newGC.getTabLevel() > oldGC.getTabLevel()+1)
{
// validate
// Search for right tab
GridController rightGC = null;
boolean canJump = true;
int currentLevel = newGC.getTabLevel();
for (int i = index-1; i >=0; i--)
{
Component rightC = getComponentAt(i);
GridController rightGC = null;
if (rightC instanceof GridController)
{
rightGC = (GridController)rightC;
if (rightGC.getTabLevel() == oldGC.getTabLevel()+1)
GridController gc = (GridController)rightC;
//can only skip level if all parent data are not stale
if (gc.getTabLevel() < currentLevel)
{
ADialog.warn(0, this, "TabSwitchJumpGo", rightGC.getTitle());
return;
if (gc.getTabLevel() == oldGC.getTabLevel()+1)
{
rightGC = gc;
}
if (!gc.isCurrent())
canJump = false;
currentLevel = gc.getTabLevel();
}
}
}
ADialog.warn(0, this, "TabSwitchJump");
return;
if (canJump == false)
{
if (rightGC != null )
ADialog.warn(0, this, "TabSwitchJumpGo", rightGC.getTitle());
else
ADialog.warn(0, this, "TabSwitchJump");
return;
}
}
oldGC.setMnemonics(false);
}