Search in sources :

Example 1 with MainPanel

use of com.servoy.j2db.smart.MainPanel 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 MainPanel

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

the class DataTextEditor method prepareForTextToolbarHandling.

private void prepareForTextToolbarHandling() {
    addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            setTextToolBarComponent(null);
        }

        public void focusGained(FocusEvent e) {
            if (eventExecutor.getValidationEnabled()) {
                setTextToolBarComponent(enclosedComponent);
            }
        // else find mode...
        }
    });
    addHierarchyListener(new HierarchyListener() {

        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) == HierarchyEvent.PARENT_CHANGED) {
                // get the new text toolbar to be used
                Container parent = getParent();
                while (parent != null && !(parent instanceof MainPanel)) {
                    parent = parent.getParent();
                }
                if (parent instanceof MainPanel) {
                    parentWindow = (SwingRuntimeWindow) application.getRuntimeWindowManager().getWindow(((MainPanel) parent).getContainerName());
                } else {
                    parentWindow = null;
                }
            }
        }
    });
}
Also used : Container(java.awt.Container) MainPanel(com.servoy.j2db.smart.MainPanel) HierarchyEvent(java.awt.event.HierarchyEvent) SwingRuntimeWindow(com.servoy.j2db.smart.SwingRuntimeWindow) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) HierarchyListener(java.awt.event.HierarchyListener)

Aggregations

MainPanel (com.servoy.j2db.smart.MainPanel)2 Container (java.awt.Container)2 FormController (com.servoy.j2db.FormController)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 SwingForm (com.servoy.j2db.smart.SwingForm)1 SwingFormManager (com.servoy.j2db.smart.SwingFormManager)1 SwingRuntimeWindow (com.servoy.j2db.smart.SwingRuntimeWindow)1 FormLookupPanel (com.servoy.j2db.smart.dataui.FormLookupPanel)1 FocusEvent (java.awt.event.FocusEvent)1 FocusListener (java.awt.event.FocusListener)1 HierarchyEvent (java.awt.event.HierarchyEvent)1 HierarchyListener (java.awt.event.HierarchyListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1