use of com.servoy.j2db.ui.IFormLookupPanel in project servoy-client by Servoy.
the class WebSplitPane method setForm.
public boolean setForm(boolean bLeftForm, Object form, Object relation) {
FormController f = null;
String fName = null;
boolean readOnly = false;
if (form instanceof FormController) {
f = (FormController) form;
readOnly = f.isReadOnly();
}
if (form instanceof BasicFormController.JSForm) {
f = (FormController) ((BasicFormController.JSForm) form).getFormPanel();
readOnly = f.isReadOnly();
}
if (f != null)
fName = f.getName();
if (form instanceof String)
fName = (String) form;
if (fName != null) {
String tabname = fName;
RelatedFoundSet relatedFs = null;
String relationName = null;
if (relation instanceof RelatedFoundSet) {
relatedFs = (RelatedFoundSet) relation;
} else if (relation instanceof String) {
relationName = (String) relation;
}
if (relatedFs != null) {
relationName = relatedFs.getRelationName();
if (f != null && !relatedFs.getDataSource().equals(f.getDataSource())) {
return false;
}
// TODO do this check to check if the parent table has this relation? How to get the parent table
// Table parentTable = null;
// application.getSolution().getRelations(Solution.SOLUTION+Solution.MODULES, parentTable, true, false);
}
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
WebTabFormLookup flp = (WebTabFormLookup) createFormLookupPanel(tabname, relationName, fName);
if (f != null)
flp.setReadOnly(readOnly);
if (bLeftForm)
setLeftForm(flp);
else
setRightForm(flp);
if (relatedFs != null) {
FormController fp = flp.getWebForm().getController();
if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
fp.loadData(relatedFs, null);
}
}
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(true, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (bNotifyVisibleForm) {
paneChanged[bLeftForm ? 0 : 1] = true;
}
return bNotifyVisibleForm;
} else if (form == null) {
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
splitComponents[bLeftForm ? 0 : 1].replace(new Label("webform", new Model<String>("")));
webTabs[bLeftForm ? 0 : 1] = null;
paneChanged[bLeftForm ? 0 : 1] = true;
return true;
}
return false;
}
use of com.servoy.j2db.ui.IFormLookupPanel in project servoy-client by Servoy.
the class ComponentFactory method createSplitPane.
private static IComponent createSplitPane(IApplication application, Form form, TabPanel meta, IScriptExecuter el) {
RuntimeSplitPane scriptable = new RuntimeSplitPane(application.getItemFactory().createChangesRecorder(), application);
ISplitPane splitPane = application.getItemFactory().createSplitPane(scriptable, getWebID(form, meta), meta.getTabOrientation());
scriptable.setComponent(splitPane, meta);
applyBasicComponentProperties(application, splitPane, meta, getStyleForBasicComponent(application, meta, form));
try {
int index = 0;
Iterator<IPersist> it = meta.getTabs();
while (it.hasNext() && index < 2) {
Tab tab = (Tab) it.next();
Form f = application.getFlattenedSolution().getForm(tab.getContainsFormID());
if (f != null) {
IFormLookupPanel flp = splitPane.createFormLookupPanel(tab.getName(), tab.getRelationName(), f.getName());
if (index < 1)
splitPane.setLeftForm(flp);
else
splitPane.setRightForm(flp);
index++;
}
}
} catch (Exception ex) {
Debug.error(ex);
}
splitPane.setDividerLocation(meta.getTabOrientation() == TabPanel.SPLIT_HORIZONTAL ? splitPane.getSize().width / 2 : splitPane.getSize().height / 2);
if (el != null && meta.getOnChangeMethodID() > 0) {
splitPane.setOnDividerChangeMethodCmd((Integer.toString(meta.getOnChangeMethodID())));
splitPane.addScriptExecuter(el);
}
return splitPane;
}
use of com.servoy.j2db.ui.IFormLookupPanel 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;
}
use of com.servoy.j2db.ui.IFormLookupPanel in project servoy-client by Servoy.
the class SpecialSplitPane method setForm.
public boolean setForm(boolean bLeftForm, Object form, Object relation) {
FormController f = null;
String fName = null;
boolean readOnly = false;
if (form instanceof FormController) {
f = (FormController) form;
readOnly = f.isReadOnly();
}
if (form instanceof FormController.JSForm) {
f = (FormController) ((FormController.JSForm) form).getFormPanel();
readOnly = f.isReadOnly();
}
if (f != null)
fName = f.getName();
if (form instanceof String)
fName = (String) form;
if (fName != null) {
String name = fName;
RelatedFoundSet relatedFs = null;
String relationName = null;
if (relation instanceof RelatedFoundSet) {
relatedFs = (RelatedFoundSet) relation;
} else if (relation instanceof String) {
relationName = (String) relation;
}
if (relatedFs != null) {
relationName = relatedFs.getRelationName();
if (f != null && !relatedFs.getDataSource().equals(f.getDataSource())) {
return false;
}
// TODO do this check to check if the parent table has this relation? How to get the parent table
// Table parentTable = null;
// application.getSolution().getRelations(Solution.SOLUTION+Solution.MODULES, parentTable, true, false);
}
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, (FormLookupPanel) replacedForm, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
FormLookupPanel flp = createFormLookupPanel(name, relationName, fName);
if (f != null)
flp.setReadOnly(readOnly);
if (bLeftForm)
setLeftForm(flp);
else
setRightForm(flp);
if (relatedFs != null) {
FormController fp = flp.getFormPanel();
if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
fp.loadData(relatedFs, null);
}
}
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(true, flp, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
return bNotifyVisibleForm;
} else if (form == null) {
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, (FormLookupPanel) replacedForm, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
if (bLeftForm)
setLeftForm(null);
else
setRightForm(null);
return true;
}
return false;
}
use of com.servoy.j2db.ui.IFormLookupPanel in project servoy-client by Servoy.
the class TablessPanel method insertTab.
/**
* @see com.servoy.j2db.util.ITabPaneAlike#insertTab(java.lang.String, java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String, int)
*/
public void insertTab(String name, String text, Icon icon, Component flp, String tooltip, int index) {
setTitleAt(index, text);
// because we use FixedCardLayout, we need to first remove the forms from the right,
// so the layout manager will have the forms in the right order
ArrayList<Component> nextComponents = new ArrayList<Component>();
nextComponents.add(flp);
int componentCount = getComponentCount();
for (int i = index; i < componentCount; i++) {
nextComponents.add(getComponent(index));
remove(index);
}
for (Component c : nextComponents) add(c, ((IFormLookupPanel) c).getFormName() + "_" + checkCounter());
// So just make sure its propagated to the new tab.
if (flp instanceof JComponent) {
JComponent jFLP = (JComponent) flp;
jFLP.setOpaque(isOpaque());
}
if (selectedTab == -1) {
setSelectedIndex(0);
}
if (tooltip != null) {
((JComponent) flp).setToolTipText(tooltip);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getParent().validate();
}
});
}
Aggregations