Search in sources :

Example 1 with IFormLookupPanel

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;
}
Also used : FormController(com.servoy.j2db.FormController) BasicFormController(com.servoy.j2db.BasicFormController) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with IFormLookupPanel

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;
}
Also used : ISplitPane(com.servoy.j2db.ui.ISplitPane) Tab(com.servoy.j2db.persistence.Tab) IPersist(com.servoy.j2db.persistence.IPersist) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) RuntimeSplitPane(com.servoy.j2db.ui.scripting.RuntimeSplitPane) JSONException(org.json.JSONException) IOException(java.io.IOException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel)

Example 3 with IFormLookupPanel

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;
}
Also used : AbstractRuntimeTabPaneAlike(com.servoy.j2db.ui.scripting.AbstractRuntimeTabPaneAlike) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) Color(java.awt.Color) ITabPanel(com.servoy.j2db.ui.ITabPanel) RuntimeAccordionPanel(com.servoy.j2db.ui.scripting.RuntimeAccordionPanel) JSONException(org.json.JSONException) IOException(java.io.IOException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel) Tab(com.servoy.j2db.persistence.Tab) RuntimeTabPanel(com.servoy.j2db.ui.scripting.RuntimeTabPanel) IPersist(com.servoy.j2db.persistence.IPersist)

Example 4 with IFormLookupPanel

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;
}
Also used : FormController(com.servoy.j2db.FormController) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel)

Example 5 with IFormLookupPanel

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();
        }
    });
}
Also used : ArrayList(java.util.ArrayList) SafeArrayList(com.servoy.j2db.util.SafeArrayList) JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel)

Aggregations

IFormLookupPanel (com.servoy.j2db.ui.IFormLookupPanel)5 ArrayList (java.util.ArrayList)3 FormController (com.servoy.j2db.FormController)2 IForm (com.servoy.j2db.IForm)2 RelatedFoundSet (com.servoy.j2db.dataprocessing.RelatedFoundSet)2 Form (com.servoy.j2db.persistence.Form)2 IPersist (com.servoy.j2db.persistence.IPersist)2 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 Tab (com.servoy.j2db.persistence.Tab)2 IOException (java.io.IOException)2 List (java.util.List)2 JSONException (org.json.JSONException)2 BasicFormController (com.servoy.j2db.BasicFormController)1 IComponent (com.servoy.j2db.ui.IComponent)1 ISplitPane (com.servoy.j2db.ui.ISplitPane)1 ITabPanel (com.servoy.j2db.ui.ITabPanel)1 AbstractRuntimeTabPaneAlike (com.servoy.j2db.ui.scripting.AbstractRuntimeTabPaneAlike)1 RuntimeAccordionPanel (com.servoy.j2db.ui.scripting.RuntimeAccordionPanel)1 RuntimeSplitPane (com.servoy.j2db.ui.scripting.RuntimeSplitPane)1 RuntimeTabPanel (com.servoy.j2db.ui.scripting.RuntimeTabPanel)1