use of com.servoy.j2db.ui.scripting.RuntimeAccordionPanel in project servoy-client by Servoy.
the class ComponentFactory method createTabPanel.
private static IComponent createTabPanel(IApplication application, Form form, TabPanel meta, IScriptExecuter el) {
// HACK:To set the selected color on a tabpanel
Color oldColor = null;
if (meta.getSelectedTabColor() != null) {
oldColor = UIManager.getColor("TabbedPane.selected");
UIManager.put("TabbedPane.selected", meta.getSelectedTabColor());
}
int orient = meta.getTabOrientation();
AbstractRuntimeTabPaneAlike scriptable = null;
ITabPanel tabs;
if (meta.getTabOrientation() == TabPanel.ACCORDION_PANEL) {
scriptable = new RuntimeAccordionPanel(application.getItemFactory().createChangesRecorder(), application);
tabs = application.getItemFactory().createAccordionPanel((RuntimeAccordionPanel) scriptable, getWebID(form, meta));
} else {
scriptable = new RuntimeTabPanel(application.getItemFactory().createChangesRecorder(), application);
tabs = application.getItemFactory().createTabPanel((RuntimeTabPanel) scriptable, getWebID(form, meta), orient, meta.hasOneTab());
}
scriptable.setComponent(tabs, meta);
if (meta.getScrollTabs()) {
tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
} else {
tabs.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
}
if (el != null && meta.getOnTabChangeMethodID() > 0) {
tabs.setOnTabChangeMethodCmd(Integer.toString(meta.getOnTabChangeMethodID()), Utils.parseJSExpressions(meta.getFlattenedMethodArguments("onTabChangeMethodID")));
tabs.addScriptExecuter(el);
}
applyBasicComponentProperties(application, tabs, meta, getStyleForBasicComponent(application, meta, form));
if (meta.getHorizontalAlignment() >= 0) {
tabs.setHorizontalAlignment(meta.getHorizontalAlignment());
}
// HACK:restore so not all tabpanel get that color!
if (meta.getSelectedTabColor() != null)
UIManager.put("TabbedPane.selected", oldColor);
try {
int index = 0;
Iterator<IPersist> it = meta.getTabs();
while (it.hasNext()) {
Tab tab = (Tab) it.next();
Form f = application.getFlattenedSolution().getForm(tab.getContainsFormID());
if (f != null) {
IFormLookupPanel flp = tabs.createFormLookupPanel(tab.getName(), tab.getRelationName(), f.getName());
tabs.addTab(application.getI18NMessageIfPrefixed(tab.getText()), tab.getImageMediaID(), flp, application.getI18NMessageIfPrefixed(tab.getToolTipText()));
Color fg = tab.getForeground();
Color bg = tab.getBackground();
if (fg != null)
tabs.setTabForegroundAt(index, fg);
if (bg != null)
tabs.setTabBackgroundAt(index, bg);
String mnemonic = application.getI18NMessageIfPrefixed(tab.getMnemonic());
if (mnemonic != null && mnemonic.length() > 0) {
tabs.setMnemonicAt(index, mnemonic.charAt(0));
}
index++;
}
}
} catch (Exception ex) {
Debug.error(ex);
}
return tabs;
}
Aggregations