use of org.adempiere.webui.panel.IADTabPanel in project adempiere by adempiere.
the class AbstractADTab method getPath.
/**
*
* @return full path
*/
public String getPath() {
StringBuffer path = new StringBuffer();
int s = this.getSelectedIndex();
if (s <= 0)
s = 0;
IADTabPanel p = tabPanelList.get(s);
for (int i = 0; i <= s; i++) {
String n = null;
if (i == s)
n = p.getTitle();
else {
IADTabPanel t = tabPanelList.get(i);
if (t.getTabLevel() < p.getTabLevel())
n = t.getTitle();
}
if (n != null) {
if (path.length() > 0) {
path.append(" > ");
}
path.append(n);
}
}
return path.toString();
}
use of org.adempiere.webui.panel.IADTabPanel in project adempiere by adempiere.
the class CompositeADTab method doTabSelectionChanged.
@Override
protected void doTabSelectionChanged(int oldIndex, int newIndex) {
IADTabPanel oldTabpanel = oldIndex >= 0 ? tabPanelList.get(oldIndex) : null;
IADTabPanel newTabpanel = tabPanelList.get(newIndex);
if (oldTabpanel != null) {
oldTabpanel.setVisible(false);
}
newTabpanel.createUI();
newTabpanel.setVisible(true);
if (tabList.getSelectedIndex() != newIndex)
tabList.setSelectedIndex(newIndex);
}
use of org.adempiere.webui.panel.IADTabPanel in project adempiere by adempiere.
the class AbstractADTab method updateSelectedIndex.
/**
*
* @param oldIndex
* @param newIndex
* @return
*/
public boolean updateSelectedIndex(int oldIndex, int newIndex) {
IADTabPanel newTab = tabPanelList.get(newIndex);
if (!isDisplay(newTab)) {
return false;
}
boolean canJump = true;
if (newIndex != oldIndex) {
canJump = canNavigateTo(oldIndex, newIndex);
if (canJump) {
prepareContext(newIndex, newTab);
doTabSelectionChanged(oldIndex, newIndex);
}
}
return canJump;
}
use of org.adempiere.webui.panel.IADTabPanel in project adempiere by adempiere.
the class AbstractADTab method prepareContext.
private void prepareContext(int newIndex, IADTabPanel newTab) {
//update context
if (newTab != null && (adWindowPanel == null || !adWindowPanel.isEmbedded())) {
List<Integer> parents = new ArrayList<Integer>();
//get parent list
if (newIndex > 0) {
int currentLevel = newTab.getTabLevel();
for (int i = newIndex - 1; i >= 0; i--) {
IADTabPanel adtab = tabPanelList.get(i);
if (adtab.getGridTab() == null)
continue;
if (adtab instanceof ADSortTab)
continue;
if (adtab.getTabLevel() < currentLevel || i == 0) {
parents.add(i);
}
}
Collections.reverse(parents);
} else {
parents.add(0);
}
//clear context
for (int i = 0; i < tabPanelList.size(); i++) {
IADTabPanel adtab = tabPanelList.get(i);
if (adtab.getGridTab() == null)
continue;
if (adtab instanceof ADSortTab)
continue;
GridField[] fields = adtab.getGridTab().getFields();
for (GridField gf : fields) {
Env.setContext(Env.getCtx(), gf.getWindowNo(), gf.getColumnName(), "");
}
}
//add parent value to context
if (!parents.isEmpty()) {
for (int i : parents) {
IADTabPanel adtab = tabPanelList.get(i);
GridField[] fields = adtab.getGridTab().getFields();
for (GridField gf : fields) {
if (// preserve value of tab above if null on current tab
gf.getValue() != null)
gf.updateContext();
}
}
}
}
}
use of org.adempiere.webui.panel.IADTabPanel in project adempiere by adempiere.
the class AbstractADTab method canNavigateTo.
public boolean canNavigateTo(int fromIndex, int toIndex) {
IADTabPanel newTab = tabPanelList.get(toIndex);
if (newTab instanceof ADTabPanel) {
if (!isDisplay(newTab)) {
return false;
}
}
boolean canJump = true;
if (toIndex != fromIndex) {
IADTabPanel oldTabpanel = fromIndex >= 0 ? tabPanelList.get(fromIndex) : null;
if (oldTabpanel != null) {
IADTabPanel oldTab = oldTabpanel;
if (newTab.getTabLevel() > oldTab.getTabLevel()) {
int currentLevel = newTab.getTabLevel();
for (int i = toIndex - 1; i >= 0; i--) {
IADTabPanel tabPanel = tabPanelList.get(i);
if (tabPanel.getTabLevel() < currentLevel) {
if (!tabPanel.isCurrent()) {
canJump = false;
break;
}
currentLevel = tabPanel.getTabLevel();
}
}
}
}
}
return canJump;
}
Aggregations