Search in sources :

Example 1 with SwingForm

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

the class DebugJ2DBClient method destroyForm.

/**
 * @param formController
 * @return
 */
private void destroyForm(IFormController formController) {
    refreshI18NMessages(true);
    if (formController.isFormVisible()) {
        IFoundSetInternal foundSet = formController.getFormModel();
        if (foundSet instanceof FoundSet) {
            ((FoundSet) foundSet).refresh();
        }
        String name = null;
        if (formController.getForm() != null)
            name = formController.getForm().getName();
        if (name == null)
            name = formController.getName();
        if (getFormManager().getCurrentForm() == formController) {
            formController.destroy();
            getFormManager().showFormInCurrentContainer(name);
        } else {
            SwingForm swingForm = (SwingForm) formController.getFormUI();
            Container container = swingForm.getParent();
            boolean isNavigator = false;
            boolean isWindow = false;
            boolean isLookupPanel = false;
            if (container instanceof MainPanel) {
                isNavigator = ((MainPanel) container).getNavigator() == formController;
            } else if (container instanceof FormLookupPanel) {
                isLookupPanel = true;
            } else {
                while (container != null && !(container instanceof FormWindow)) {
                    container = container.getParent();
                }
                if (container instanceof FormWindow) {
                    isWindow = true;
                }
            }
            formController.destroy();
            if (isLookupPanel) {
                FormLookupPanel flp = (FormLookupPanel) container;
                FormController newFormController = flp.getFormPanel();
                if (newFormController != null) {
                    // deleted in developer ?
                    newFormController.loadData(foundSet, null);
                    List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                    newFormController.notifyVisible(true, invokeLaterRunnables);
                    Utils.invokeLater(this, invokeLaterRunnables);
                }
            } else if (isNavigator) {
                // TODO isNavigator check will always be false for NGClient?
                FormController navigator = ((FormManager) getFormManager()).getFormController(name, container);
                if (navigator != null) {
                    navigator.loadData(foundSet, null);
                    List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                    navigator.notifyVisible(true, invokeLaterRunnables);
                    Utils.invokeLater(this, invokeLaterRunnables);
                }
                mainPanel.setNavigator(navigator);
            } else if (isWindow) {
                // TODO isWindow check will always be false for NGClient?
                FormWindow w = (FormWindow) container;
                ((FormManager) getFormManager()).showFormInMainPanel(name, w.getMainContainer(), w.getTitle(), false, w.getName());
            }
        }
    } else {
        formController.destroy();
    }
    return;
}
Also used : IFormController(com.servoy.j2db.IFormController) FormController(com.servoy.j2db.FormController) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ArrayList(java.util.ArrayList) FoundSet(com.servoy.j2db.dataprocessing.FoundSet) FormWindow(com.servoy.j2db.FormWindow) SwingForm(com.servoy.j2db.smart.SwingForm) IMainContainer(com.servoy.j2db.IMainContainer) Container(java.awt.Container) MainPanel(com.servoy.j2db.smart.MainPanel) FormManager(com.servoy.j2db.FormManager) SwingFormManager(com.servoy.j2db.smart.SwingFormManager) ArrayList(java.util.ArrayList) List(java.util.List) FormLookupPanel(com.servoy.j2db.smart.dataui.FormLookupPanel)

Example 2 with SwingForm

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

the class DataRendererFactory method extendTabSequence.

public void extendTabSequence(List<Component> tabSequence, IFormUIInternal containerImpl) {
    SwingForm sf = (SwingForm) containerImpl;
    JComponent west = sf.getWest();
    if (west != null) {
        if (west instanceof ISupplyFocusChildren) {
            ISupplyFocusChildren<Component> s = (ISupplyFocusChildren<Component>) west;
            Component[] fchilds = s.getFocusChildren();
            for (Component element : fchilds) {
                tabSequence.add(element);
            }
        }
    }
}
Also used : JComponent(javax.swing.JComponent) ISupplyFocusChildren(com.servoy.j2db.util.ISupplyFocusChildren) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) SwingForm(com.servoy.j2db.smart.SwingForm)

Example 3 with SwingForm

use of com.servoy.j2db.smart.SwingForm 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 4 with SwingForm

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

the class DataRendererFactory method applyTabSequence.

public void applyTabSequence(List<Component> tabSequence, IFormUIInternal containerImpl) {
    SwingForm sf = (SwingForm) containerImpl;
    sf.setTabSeqComponents(tabSequence);
    if (tabSequence != null)
        sf.setFocusTraversalPolicy(ServoyFocusTraversalPolicy.datarenderPolicy);
    else
        sf.setFocusTraversalPolicy(ServoyFocusTraversalPolicy.defaultPolicy);
}
Also used : SwingForm(com.servoy.j2db.smart.SwingForm)

Example 5 with SwingForm

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

the class SpecialTabPanel method getTagResolver.

/**
 * @param parentState
 * @return
 */
private ITagResolver getTagResolver(IRecordInternal parentState) {
    ITagResolver resolver;
    Container parent = getParent();
    while (!(parent instanceof SwingForm) && parent != null) {
        parent = parent.getParent();
    }
    if (parent instanceof SwingForm) {
        resolver = ((SwingForm) parent).getController().getTagResolver();
    } else {
        resolver = TagResolver.createResolver(parentState);
    }
    return resolver;
}
Also used : Container(java.awt.Container) ITagResolver(com.servoy.base.util.ITagResolver) SwingForm(com.servoy.j2db.smart.SwingForm)

Aggregations

SwingForm (com.servoy.j2db.smart.SwingForm)5 Container (java.awt.Container)3 FormController (com.servoy.j2db.FormController)2 ITagResolver (com.servoy.base.util.ITagResolver)1 FormManager (com.servoy.j2db.FormManager)1 FormWindow (com.servoy.j2db.FormWindow)1 IFormController (com.servoy.j2db.IFormController)1 IMainContainer (com.servoy.j2db.IMainContainer)1 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)1 MainPanel (com.servoy.j2db.smart.MainPanel)1 SwingFormManager (com.servoy.j2db.smart.SwingFormManager)1 FormLookupPanel (com.servoy.j2db.smart.dataui.FormLookupPanel)1 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)1 IFormLookupPanel (com.servoy.j2db.ui.IFormLookupPanel)1 ISupplyFocusChildren (com.servoy.j2db.util.ISupplyFocusChildren)1 Component (java.awt.Component)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1