Search in sources :

Example 21 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method setPageSearchForm.

public void setPageSearchForm(IForm f, boolean force) {
    if (force || m_pageSearchForm != f) {
        IForm oldForm = m_pageSearchForm;
        m_pageSearchForm = f;
        // extensions
        for (IDesktopExtension ext : getDesktopExtensions()) {
            try {
                ContributionCommand cc = ext.pageSearchFormChangedDelegate(oldForm, m_pageSearchForm);
                if (cc == ContributionCommand.Stop) {
                    break;
                }
            } catch (Exception t) {
                LOG.error("extension {}", ext, t);
            }
        }
    }
}
Also used : IForm(org.eclipse.scout.rt.client.ui.form.IForm) DeepLinkException(org.eclipse.scout.rt.client.deeplink.DeepLinkException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException)

Example 22 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method updateActiveFormOnOutlineChanged.

protected void updateActiveFormOnOutlineChanged() {
    // If active form is not set or parent of active form is desktop
    // we must do nothing
    IForm activeForm = getActiveForm();
    if (activeForm == null || activeForm.getDisplayParent() == this) {
        return;
    }
    // Does the active form belong to the current outline?
    // if not, we must set the active form to null otherwise we do nothing
    List<IForm> formsByOutline = m_formStore.getByDisplayParent(m_outline);
    if (!formsByOutline.contains(activeForm)) {
        setActiveForm(null);
    }
}
Also used : IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 23 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractPageWithNodes method enhanceDetailFormWithPageMenus.

protected void enhanceDetailFormWithPageMenus() {
    if (getOutline() == null) {
        return;
    }
    IForm form = getDetailForm();
    IFormFieldContextMenu mainBoxContextMenu = form.getRootGroupBox().getContextMenu();
    List<IMenu> menus = mainBoxContextMenu.getChildActions();
    for (IMenu menu : getOutline().getMenusForPage(this)) {
        // TODO [6.2] hmu, bsh: menues im ui sammeln anstelle in forms injecten
        if (menu.getMenuTypes().contains(TreeMenuType.Header) && menu.getMenuTypes().size() == 1) {
            // Don't show TreeMenuType.Header. These menus should only be shown on outline title
            continue;
        }
        menus.add(OutlineMenuWrapper.wrapMenu(menu));
    }
    if (!CollectionUtility.equalsCollection(menus, mainBoxContextMenu.getChildActions())) {
        mainBoxContextMenu.setChildActions(menus);
    }
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IFormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 24 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractCompositeField method getReplacingFieldClass.

/**
 * Checks whether the form field with the given class has been replaced by another form field. If so, the replacing
 * form field's class is returned. Otherwise the given class itself.
 *
 * @param c
 * @return Returns the possibly available replacing field class for the given class.
 * @see Replace
 * @since 3.8.2
 */
private <T extends IFormField> Class<? extends T> getReplacingFieldClass(Class<T> c) {
    // 1. check local replacements
    if (m_formFieldReplacements != null) {
        @SuppressWarnings("unchecked") Class<? extends T> replacementFieldClass = (Class<? extends T>) m_formFieldReplacements.get(c);
        if (replacementFieldClass != null) {
            return replacementFieldClass;
        }
    }
    // 2. check global replacements
    IForm form = getForm();
    if (form instanceof AbstractForm) {
        Map<Class<?>, Class<? extends IFormField>> mapping = ((AbstractForm) form).getFormFieldReplacementsInternal();
        if (mapping != null) {
            @SuppressWarnings("unchecked") Class<? extends T> replacementFieldClass = (Class<? extends T>) mapping.get(c);
            if (replacementFieldClass != null) {
                return replacementFieldClass;
            }
        }
    }
    // 3. check parent field replacements (used for templates only. It is less common and therefore checked after global replacements)
    ICompositeField parentField = getParentField();
    while (parentField != null) {
        if (parentField instanceof AbstractCompositeField) {
            Map<Class<?>, Class<? extends IFormField>> parentReplacements = ((AbstractCompositeField) parentField).m_formFieldReplacements;
            if (parentReplacements != null) {
                @SuppressWarnings("unchecked") Class<? extends T> replacementFieldClass = (Class<? extends T>) parentReplacements.get(c);
                if (replacementFieldClass != null) {
                    return replacementFieldClass;
                }
            }
        }
        parentField = parentField.getParentField();
    }
    // 4. field is not replaced
    return c;
}
Also used : IForm(org.eclipse.scout.rt.client.ui.form.IForm) AbstractForm(org.eclipse.scout.rt.client.ui.form.AbstractForm)

Example 25 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractFormField method existsDuplicateClassId.

/**
 * Sanity check for class ids. Scans all fields in a form to find duplicate class ids.
 *
 * @return <code>true</code>, if another field with the same id is found. <code>false</code> otherwise.
 */
private boolean existsDuplicateClassId() {
    IForm form = getForm();
    String currentClassId = computeClassId();
    if (form != null) {
        List<String> classIds = new ArrayList<String>();
        for (IFormField f : form.getAllFields()) {
            if (f != this) {
                String fClassId = ConfigurationUtility.getAnnotatedClassIdWithFallback(f.getClass(), true);
                classIds.add(fClassId);
            }
        }
        if (classIds.contains(currentClassId)) {
            return true;
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Aggregations

IForm (org.eclipse.scout.rt.client.ui.form.IForm)38 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)5 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)4 IDisplayParent (org.eclipse.scout.rt.client.ui.IDisplayParent)3 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)3 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)3 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)3 JSONObject (org.json.JSONObject)3 List (java.util.List)2 ModelContext (org.eclipse.scout.rt.client.ModelContextProxy.ModelContext)2 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)2 IFileChooser (org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser)2 ISearchForm (org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm)2 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)2 ITabBox (org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)2 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)2 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1