Search in sources :

Example 36 with FormManager

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

the class SwingRuntimeWindow method doOldShowInDialog.

private void doOldShowInDialog(String formName, boolean closeAll, boolean legacyV3Behavior) {
    FormManager fm = ((FormManager) getApplication().getFormManager());
    IMainContainer currentModalDialogContainer = fm.getModalDialogContainer();
    JSWindow parentJSWindow = getParent();
    RuntimeWindow parentRuntimeWindow = null;
    if (parentJSWindow != null && parentJSWindow.getImpl().isVisible())
        parentRuntimeWindow = parentJSWindow.getImpl();
    else {
        Window dialogWindowOwner = getWindowFromMainContainer(currentModalDialogContainer);
        if (dialogWindowOwner != null) {
            IMainContainer currentContainer = fm.getCurrentContainer();
            Window currentContainerWindow = getWindowFromMainContainer(currentContainer);
            while (currentContainerWindow != null) {
                if (dialogWindowOwner == currentContainerWindow) {
                    break;
                }
                currentContainerWindow = currentContainerWindow.getOwner();
            }
            if (currentContainerWindow == null) {
                // if it never really was the owner (in the own chain of the dialog) then do just use the currentContainer.
                currentModalDialogContainer = currentContainer;
            }
        }
        parentRuntimeWindow = getApplication().getRuntimeWindowManager().getWindow(currentModalDialogContainer.getContainerName());
    }
    boolean windowModal = ((legacyV3Behavior && wrappedWindow == null) || getType() == JSWindow.MODAL_DIALOG);
    Pair<Boolean, IMainContainer> p = createAndReparentDialogIfNeeded(fm, parentRuntimeWindow, windowModal);
    boolean bringToFrontNeeded = p.getLeft().booleanValue();
    IMainContainer previousModalContainer = p.getRight();
    FormDialog sfd = (FormDialog) wrappedWindow;
    IMainContainer container = sfd.getMainContainer();
    // For none legacy the dialog must always be really closed
    sfd.setCloseAll(closeAll || !legacyV3Behavior);
    if (sfd.isVisible()) {
        sfd.storeBounds();
    }
    final FormController fp = fm.showFormInMainPanel(formName, container, title, closeAll && legacyV3Behavior, windowName);
    if (fp != null && fp.getName().equals(formName)) {
        sfd.setModal(windowModal);
        if (!sfd.isDisplayable() && isUndecorated()) {
            sfd.setUndecorated(true);
            sfd.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
            // $NON-NLS-1$
            if (Utils.isAppleMacOS())
                sfd.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
        }
        applyOpacityAndTransparency(sfd, container, sfd.getContentPane(), sfd.isUndecorated());
        if (windowModal) {
            testAndSetJava6Modality(sfd);
            // When a modal window is closed, the old modal window state will have to be restored...
            // For example, when inside JS for an event you close a modal window and open another one,
            // the new modal window must have as owner not the closed window, but the last opened modal window
            // before the window just closed.
            // This has to happen when setVisible(false) is called on the modal dialog. We cannot simply rely
            // on executing this after sfd.setVisible(true) is unblocked, because then it will be executed
            // after the new dialog is opened by java script. (because that execution continues as the next event on the EventThread)
            sfd.setPreviousMainContainer(previousModalContainer, currentModalDialogContainer);
        } else {
            // If it is a none modal dialog, make sure the current container is reset to the currentMainContainer (== previous his parent)
            // else it is switched a bit to early (if a developer shows 2 dialogs at once from a main container)
            // the focus event of the FormDialog will set it correctly.
            fm.setCurrentContainer(currentModalDialogContainer, currentModalDialogContainer.getName());
        }
    }
    finalizeShowWindow(fp, formName, container, true, legacyV3Behavior, bringToFrontNeeded);
}
Also used : ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) Window(java.awt.Window) JSWindow(com.servoy.j2db.scripting.JSWindow) FormWindow(com.servoy.j2db.FormWindow) FormController(com.servoy.j2db.FormController) FormDialog(com.servoy.j2db.gui.FormDialog) ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) FormManager(com.servoy.j2db.FormManager) JSWindow(com.servoy.j2db.scripting.JSWindow) IMainContainer(com.servoy.j2db.IMainContainer)

Example 37 with FormManager

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

the class DataProviderEditor method setValue.

public void setValue(Object v) {
    value = (String) v;
    FormManager fm = (FormManager) application.getFormManager();
    FormController fc = fm.getCurrentMainShowingFormController();
    if (fc != null) {
        Form form = fc.getForm();
        if (form != null) {
            try {
                IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(null, form).getDataProvider(value);
                showDataEx(dp);
            } catch (Exception ex) {
                Debug.error(ex);
            }
        }
    }
}
Also used : FormController(com.servoy.j2db.FormController) FormManager(com.servoy.j2db.FormManager) Form(com.servoy.j2db.persistence.Form) IDataProvider(com.servoy.j2db.persistence.IDataProvider)

Example 38 with FormManager

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

the class CmdManager method ableFormRelatedFindActions.

public void ableFormRelatedFindActions(boolean enable) {
    FormManager fm = (FormManager) application.getFormManager();
    IForm[] visibleRootFormsInFind = (fm != null) ? fm.getVisibleRootFormsInFind() : null;
    boolean thereAreUsableVisibleFormsInFind = ((visibleRootFormsInFind != null) && (visibleRootFormsInFind.length > 0));
    // if there are visible forms that are still in find mode, even though enabled = false (for example
    // when another form exits find mode - see unrelated tab panels) the actions must still remain enabled (although it is a strange case)
    boolean shouldPerform = false;
    if (thereAreUsableVisibleFormsInFind) {
        for (IForm f : visibleRootFormsInFind) {
            if (!(f instanceof FormController) || ((FormController) f).getForm() == null || ((FormController) f).getForm().getOnSearchCmdMethodID() >= 0) {
                shouldPerform = true;
                break;
            }
        }
    } else {
        shouldPerform = true;
    }
    // if we want to enable find actions we check for onsearchcmd of the form; if set to none, actions are not enabled
    if (shouldPerform) {
        // $NON-NLS-1$
        Action cmdperformfind = actions.get("cmdperformfind");
        if (cmdperformfind != null)
            cmdperformfind.setEnabled(enable || thereAreUsableVisibleFormsInFind);
        // $NON-NLS-1$
        Action cmdreducefind = actions.get("cmdreducefind");
        if (cmdreducefind != null)
            cmdreducefind.setEnabled(enable || thereAreUsableVisibleFormsInFind);
        // $NON-NLS-1$
        Action cmdextendfind = actions.get("cmdextendfind");
        if (cmdextendfind != null)
            cmdextendfind.setEnabled(enable || thereAreUsableVisibleFormsInFind);
    }
    // this action must be enabled even if onsearchcmd is set to none...
    // $NON-NLS-1$
    Action cmdstopsearchfindall = actions.get("cmdstopsearchfindall");
    if (cmdstopsearchfindall != null)
        cmdstopsearchfindall.setEnabled(enable);
}
Also used : FormController(com.servoy.j2db.FormController) Action(javax.swing.Action) SwingFormManager(com.servoy.j2db.smart.SwingFormManager) FormManager(com.servoy.j2db.FormManager) IForm(com.servoy.j2db.IForm)

Example 39 with FormManager

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

the class CmdPerformFind method doIt.

/*
 * _____________________________________________________________ The methods below override methods from superclass AbstractCmd
 */
@Override
public UndoableEdit doIt(java.util.EventObject ae) {
    FormManager fm = (FormManager) application.getFormManager();
    IForm[] rootFindModeForms = fm.getVisibleRootFormsInFind();
    if (rootFindModeForms.length > 0) {
        // if you have 2 visible forms in find that use the same foundset (paren + child tab on the same table)
        HashSet<IFoundSet> processedFounsets = new HashSet<IFoundSet>();
        // if you call performFind() on both of them you might get the "no results, modify last find" dialog twice...
        for (IForm f : rootFindModeForms) {
            // check for each form if it is still in find mode (as onSearchCmd on one form might stop find mode on others as well and we do not want to trigger onSearchCmd on the others
            IFoundSet foundSet = f.getFoundSet();
            boolean shouldPerform = f.isInFindMode() && (foundSet == null || !processedFounsets.contains(foundSet));
            if (shouldPerform && f instanceof FormController && ((FormController) f).getForm() != null && ((FormController) f).getForm().getOnSearchCmdMethodID() < 0)
                shouldPerform = false;
            if (shouldPerform) {
                processedFounsets.add(foundSet);
                f.performFind(true, true, true);
                // wants to continue find) then don't try to perform search any more find mode forms
                if (f.isInFindMode())
                    break;
            }
        }
    }
    return null;
}
Also used : FormController(com.servoy.j2db.FormController) IFoundSet(com.servoy.j2db.dataprocessing.IFoundSet) FormManager(com.servoy.j2db.FormManager) IForm(com.servoy.j2db.IForm) HashSet(java.util.HashSet)

Example 40 with FormManager

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

the class WebBaseSelectBox method fireOnRender.

public void fireOnRender(boolean force) {
    if (scriptable != null) {
        boolean isFocused = false;
        IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
        if (currentContainer instanceof MainPage) {
            isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
        }
        if (force)
            scriptable.getRenderEventExecutor().setRenderStateChanged();
        scriptable.getRenderEventExecutor().fireOnRender(isFocused);
    }
}
Also used : FormManager(com.servoy.j2db.FormManager) IMainContainer(com.servoy.j2db.IMainContainer) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Aggregations

FormManager (com.servoy.j2db.FormManager)49 IMainContainer (com.servoy.j2db.IMainContainer)21 FormController (com.servoy.j2db.FormController)15 MainPage (com.servoy.j2db.server.headlessclient.MainPage)13 IForm (com.servoy.j2db.IForm)7 Form (com.servoy.j2db.persistence.Form)5 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)4 RepositoryException (com.servoy.j2db.persistence.RepositoryException)4 IComponent (com.servoy.j2db.ui.IComponent)4 Component (java.awt.Component)4 ArrayList (java.util.ArrayList)4 FlattenedSolution (com.servoy.j2db.FlattenedSolution)3 FormWindow (com.servoy.j2db.FormWindow)3 IBasicFormManager (com.servoy.j2db.IBasicFormManager)3 IFormController (com.servoy.j2db.IFormController)3 IFormManager (com.servoy.j2db.IFormManager)3 ITable (com.servoy.j2db.persistence.ITable)3 SwingFormManager (com.servoy.j2db.smart.SwingFormManager)3 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)3 ServoyException (com.servoy.j2db.util.ServoyException)3