Search in sources :

Example 66 with FormController

use of com.servoy.j2db.FormController 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 67 with FormController

use of com.servoy.j2db.FormController 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 68 with FormController

use of com.servoy.j2db.FormController 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 69 with FormController

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

the class CmdNextRecord method doIt.

@Override
public UndoableEdit doIt(java.util.EventObject ae) {
    IFormManager fm = application.getFormManager();
    final FormController fp = (FormController) fm.getCurrentForm();
    fp.selectNextRecord();
    return null;
}
Also used : FormController(com.servoy.j2db.FormController) IFormManager(com.servoy.j2db.IFormManager)

Example 70 with FormController

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

the class TabSequenceHelper method fromAbstractToNamed.

public void fromAbstractToNamed() {
    T tableViewToInsert = null;
    int largestIndexBeforeBody = -1;
    T lastComponentBeforeBody = null;
    LinkedHashMap<T, String> componentGroupsByTabIndex = new LinkedHashMap<T, String>();
    FormController fc = runtimeContainer.getController();
    Form f = fc.getForm();
    Iterator<Part> parts = f.getParts();
    while (parts.hasNext()) {
        Part p = parts.next();
        IDataRenderer dataRenderer = fc.getDataRenderers()[p.getPartType()];
        if (dataRenderer != null) {
            // Later we will insert it in the tab sequence.
            if ((fc.getViewComponent() instanceof IProvideTabSequence) && (p.getPartType() == Part.BODY)) {
                tableViewToInsert = (T) dataRenderer;
            } else {
                SortedMap<ISupportTabSeq, T> dataRendererComponents = abstractTabSequence.get(dataRenderer);
                if (dataRendererComponents != null) {
                    for (ISupportTabSeq supportTabSeq : dataRendererComponents.keySet()) {
                        if (supportTabSeq.getTabSeq() >= 0) {
                            T next = dataRendererComponents.get(supportTabSeq);
                            String name = null;
                            if (supportTabSeq instanceof ISupportName)
                                name = ((ISupportName) supportTabSeq).getName();
                            componentGroupsByTabIndex.put(next, name);
                            if ((p.getPartType() == Part.HEADER) || (p.getPartType() == Part.TITLE_HEADER) || (p.getPartType() == Part.LEADING_GRAND_SUMMARY)) {
                                if (supportTabSeq.getTabSeq() >= largestIndexBeforeBody) {
                                    lastComponentBeforeBody = next;
                                    largestIndexBeforeBody = supportTabSeq.getTabSeq();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    componentsToNames.clear();
    if ((lastComponentBeforeBody == null) && (tableViewToInsert != null))
        componentsToNames.put(tableViewToInsert, null);
    for (T o : componentGroupsByTabIndex.keySet()) {
        componentsToNames.put(o, componentGroupsByTabIndex.get(o));
        if ((tableViewToInsert != null) && (lastComponentBeforeBody != null) && (o.equals(lastComponentBeforeBody)))
            componentsToNames.put(tableViewToInsert, null);
    }
    revertComponentsToNames();
    fromNamedToRuntime();
}
Also used : FormController(com.servoy.j2db.FormController) Form(com.servoy.j2db.persistence.Form) ISupportName(com.servoy.j2db.persistence.ISupportName) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) LinkedHashMap(java.util.LinkedHashMap) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IProvideTabSequence(com.servoy.j2db.IProvideTabSequence) Part(com.servoy.j2db.persistence.Part)

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