Search in sources :

Example 26 with FormController

use of com.servoy.j2db.FormController in project servoy-client by Servoy.

the class FormLookupPanel method createFormPanel.

private FormController createFormPanel() {
    FormManager fm = (FormManager) application.getFormManager();
    FormController fp = fm.getFormController(formName, this);
    if (fp != null) {
        IFormUIInternal ui = fp.getFormUI();
        if (ui instanceof Component) {
            add((Component) ui, BorderLayout.CENTER);
            // just to be sure the cardlayout of main panel does return them as not visible
            ui.setComponentVisible(true);
            // delegate readOnly, really set it once from the form manager state
            fp.setReadOnly(fm.isFormReadOnly(formName));
            Container con = getParent();
            if (con != null && (con instanceof ITabPaneAlike) && !con.isEnabled()) {
                // reaply the isEnabled state of the tabpanel to its child tabs (tabs are added after enabled state is set); only if the tabpanel is disabled
                this.setEnabled(con.isEnabled());
            }
            while (con != null) {
                if (con instanceof IFormUIInternal) {
                    fp.getUndoManager().setFormUndoManager(((IFormUIInternal) con).getUndoManager());
                    break;
                }
                con = con.getParent();
            }
            // invalidate later so that everything is first visible (like the datamodel of a tableview)
            application.invokeLater(new Runnable() {

                public void run() {
                    validate();
                }
            });
        }
    }
    return fp;
}
Also used : FormController(com.servoy.j2db.FormController) Container(java.awt.Container) FormManager(com.servoy.j2db.FormManager) ITabPaneAlike(com.servoy.j2db.util.ITabPaneAlike) IFormUIInternal(com.servoy.j2db.IFormUIInternal) Component(java.awt.Component)

Example 27 with FormController

use of com.servoy.j2db.FormController in project servoy-client by Servoy.

the class FormLookupPanel method notifyVisible.

/**
 * This method must be called on the event thread
 */
public boolean notifyVisible(boolean visible, List invokeLaterRunnables) {
    Component[] childs = getComponents();
    if (childs.length == 1) {
        IFormUIInternal ui = (IFormUIInternal) childs[0];
        FormController child = ui.getController();
        return child.notifyVisible(visible, invokeLaterRunnables);
    }
    return true;
}
Also used : FormController(com.servoy.j2db.FormController) Component(java.awt.Component) IFormUIInternal(com.servoy.j2db.IFormUIInternal)

Example 28 with FormController

use of com.servoy.j2db.FormController in project servoy-client by Servoy.

the class SpecialSplitPane method showFoundSet.

private void showFoundSet(FormLookupPanel flp, IRecordInternal parentState, List<SortColumn> sort) {
    deregisterSelectionListeners();
    if (!flp.isReady())
        return;
    try {
        FormController fp = flp.getFormPanel();
        if (fp != null && flp.getRelationName() != null) {
            IFoundSetInternal relatedFoundSet = parentState == null ? null : parentState.getRelatedFoundSet(flp.getRelationName(), sort);
            registerSelectionListeners(parentState, flp.getRelationName());
            fp.loadData(relatedFoundSet, null);
        }
    } catch (RuntimeException re) {
        application.handleException("Error setting the foundset of the relation " + flp.getRelationName() + " on the tab with form " + flp.getFormName(), re);
        throw re;
    }
}
Also used : FormController(com.servoy.j2db.FormController) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal)

Example 29 with FormController

use of com.servoy.j2db.FormController in project servoy-client by Servoy.

the class SpecialTabPanel method addTab.

public boolean addTab(IForm formController, String formName, String tabname, String tabText, String tooltip, String iconURL, String fg, String bg, String relationName, RelatedFoundSet relatedFs, int idx) {
    // on the form that the tabpanel is placed on
    if (formController != null) {
        Container parent = getParent();
        while (!(parent instanceof SwingForm) && parent != null) {
            parent = parent.getParent();
        }
        if (parent != null) {
            FormController parentFormController = ((SwingForm) parent).getController();
            if (parentFormController != null && parentFormController.equals(formController)) {
                return false;
            }
        }
    }
    FormLookupPanel flp = (FormLookupPanel) createFormLookupPanel(tabname, relationName, formName);
    if (formController != null)
        flp.setReadOnly(formController.isReadOnly());
    Icon icon = null;
    if (// $NON-NLS-1$
    iconURL != null && !"".equals(iconURL)) {
        try {
            URL url = new URL(iconURL);
            icon = new ImageIcon(url);
        } catch (Exception e) {
            Debug.error(e);
        }
    }
    int tabIndex = idx;
    if (tabIndex == -1 || tabIndex >= enclosingComponent.getTabCount()) {
        tabIndex = enclosingComponent.getTabCount();
        addTab(application.getI18NMessageIfPrefixed(tabText), icon, flp, application.getI18NMessageIfPrefixed(tooltip));
    } else {
        insertTab(application.getI18NMessageIfPrefixed(tabText), icon, flp, application.getI18NMessageIfPrefixed(tooltip), tabIndex);
    }
    if (fg != null)
        setTabForegroundAt(tabIndex, PersistHelper.createColor(fg));
    if (bg != null)
        setTabBackgroundAt(tabIndex, PersistHelper.createColor(bg));
    if (relatedFs != null && enclosingComponent.getSelectedComponent() == flp) {
        FormController fp = flp.getFormPanel();
        if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
            fp.loadData(relatedFs, null);
        }
    }
    return true;
}
Also used : FormController(com.servoy.j2db.FormController) ImageIcon(javax.swing.ImageIcon) Container(java.awt.Container) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon) SwingForm(com.servoy.j2db.smart.SwingForm) URL(java.net.URL) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel)

Example 30 with FormController

use of com.servoy.j2db.FormController in project servoy-client by Servoy.

the class WebTabPanel method addTab.

public boolean addTab(IForm formController, String formName, String tabname, String tabText, String tabtooltip, String iconURL, String fg, String bg, String relationName, RelatedFoundSet relatedFs, int idx) {
    if (formController != null) {
        // to make sure we don't have recursion on adding a tab, to a tabpanel, that is based
        // on the form that the tabpanel is placed on
        WebForm webForm = findParent(WebForm.class);
        if (webForm != null) {
            FormController parentFormController = webForm.getController();
            if (parentFormController != null && parentFormController.equals(formController)) {
                return false;
            }
        }
    }
    WebTabFormLookup flp = (WebTabFormLookup) createFormLookupPanel(tabname, relationName, formName);
    if (formController != null)
        flp.setReadOnly(formController.isReadOnly());
    FlattenedSolution fl = application.getFlattenedSolution();
    int mediaId = -1;
    if (iconURL != null && !"".equals(iconURL)) {
        Media media = fl.getMedia(iconURL.replaceAll("media:///", ""));
        if (media != null)
            mediaId = media.getID();
        if (mediaId == -1) {
            Debug.warn("Form '" + formController.getName() + "' with tabpanel  '" + this.name + "' has tabicon  for tab '" + tabname + "'in with icon media url : " + iconURL + " not found");
        }
    }
    byte[] iconData = (mediaId == -1 ? null : ComponentFactory.loadIcon(fl, new Integer(mediaId)));
    int count = allTabs.size();
    int tabIndex = idx;
    if (tabIndex == -1 || tabIndex >= count) {
        tabIndex = count;
    }
    insertTab(application.getI18NMessageIfPrefixed(tabText), iconData, flp, application.getI18NMessageIfPrefixed(tabtooltip), tabIndex, true);
    if (fg != null)
        setTabForegroundAt(tabIndex, PersistHelper.createColor(fg));
    if (bg != null)
        setTabBackgroundAt(tabIndex, PersistHelper.createColor(bg));
    // from the relatedFs - which is already in the relationName param
    if (relatedFs != null && currentForm == flp) {
        FormController fp = flp.getWebForm().getController();
        if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
            fp.loadData(relatedFs, null);
        }
    }
    return true;
}
Also used : FormController(com.servoy.j2db.FormController) WebForm(com.servoy.j2db.server.headlessclient.WebForm) Media(com.servoy.j2db.persistence.Media) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Point(java.awt.Point)

Aggregations

FormController (com.servoy.j2db.FormController)70 FormManager (com.servoy.j2db.FormManager)15 Form (com.servoy.j2db.persistence.Form)13 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)12 RepositoryException (com.servoy.j2db.persistence.RepositoryException)10 Point (java.awt.Point)10 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)9 ArrayList (java.util.ArrayList)9 IFormController (com.servoy.j2db.IFormController)8 BasicFormController (com.servoy.j2db.BasicFormController)7 IForm (com.servoy.j2db.IForm)7 WebForm (com.servoy.j2db.server.headlessclient.WebForm)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)6 IFormUIInternal (com.servoy.j2db.IFormUIInternal)5 IDataProvider (com.servoy.j2db.persistence.IDataProvider)5 List (java.util.List)5 ApplicationException (com.servoy.j2db.ApplicationException)4 IMainContainer (com.servoy.j2db.IMainContainer)4 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)4 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)4