Search in sources :

Example 6 with IForm

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

the class AbstractOutline method ensureDefaultDetailFormCreated.

public void ensureDefaultDetailFormCreated() {
    if (getDefaultDetailForm() != null) {
        return;
    }
    IForm form = createDefaultDetailForm();
    if (form != null) {
        setDefaultDetailForm(form);
        interceptInitDefaultDetailForm();
    }
}
Also used : IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 7 with IForm

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

the class DefaultPageChangeStrategy method pageChanged.

@Override
public void pageChanged(final IOutline outline, final IPage<?> deselectedPage, final IPage<?> selectedPage) {
    if (outline == null) {
        return;
    }
    outline.clearContextPage();
    IForm detailForm = null;
    ITable detailTable = null;
    ISearchForm searchForm = null;
    // new active page
    outline.makeActivePageToContextPage();
    IPage<?> activePage = outline.getActivePage();
    if (activePage != null) {
        try {
            activePage.ensureChildrenLoaded();
        } catch (RuntimeException | PlatformError e1) {
            BEANS.get(ExceptionHandler.class).handle(e1);
        }
        if (activePage instanceof IPageWithTable) {
            IPageWithTable tablePage = (IPageWithTable) activePage;
            detailForm = activePage.getDetailForm();
            if (activePage.isTableVisible()) {
                detailTable = tablePage.getTable(false);
            }
            if (tablePage.isSearchActive()) {
                searchForm = tablePage.getSearchFormInternal();
            }
        } else if (activePage instanceof IPageWithNodes) {
            IPageWithNodes nodePage = (IPageWithNodes) activePage;
            if (activePage.isDetailFormVisible()) {
                detailForm = activePage.getDetailForm();
            }
            if (activePage.isTableVisible()) {
                detailTable = nodePage.getTable(false);
            }
        }
    }
    // remove first
    if (detailForm == null) {
        outline.setDetailForm(null);
    }
    if (detailTable == null) {
        outline.setDetailTable(null);
    }
    if (searchForm == null) {
        outline.setSearchForm(null);
    }
    // add new
    if (detailForm != null) {
        outline.setDetailForm(detailForm);
    }
    if (detailTable != null) {
        outline.setDetailTable(detailTable);
    }
    if (searchForm != null) {
        outline.setSearchForm(searchForm);
    }
}
Also used : IPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IPageWithNodes(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithNodes) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) IForm(org.eclipse.scout.rt.client.ui.form.IForm) ISearchForm(org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm)

Example 8 with IForm

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

the class JsonWizardProgressField method initJsonProperties.

@Override
protected void initJsonProperties(WIZARD_PROGRESS_FIELD model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<WIZARD_PROGRESS_FIELD>(IWizardProgressField.PROP_STEPS, model) {

        @Override
        protected List<IWizardStep<? extends IForm>> modelValue() {
            return getModel().getSteps();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            @SuppressWarnings("unchecked") List<IWizardStep<? extends IForm>> wizardSteps = (List<IWizardStep<? extends IForm>>) value;
            JSONArray jsonSteps = new JSONArray();
            if (wizardSteps != null) {
                for (IWizardStep<? extends IForm> wizardStep : wizardSteps) {
                    if (wizardStep.isVisible()) {
                        jsonSteps.put(wizardStepToJson(wizardStep));
                    }
                }
            }
            return jsonSteps;
        }
    });
    putJsonProperty(new JsonProperty<WIZARD_PROGRESS_FIELD>(IWizardProgressField.PROP_ACTIVE_STEP, model) {

        @Override
        protected IWizardStep<? extends IForm> modelValue() {
            return getModel().getActiveStep();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            @SuppressWarnings("unchecked") IWizardStep<? extends IForm> activeWizardStep = (IWizardStep<? extends IForm>) value;
            return getStepIndex(activeWizardStep);
        }

        @Override
        public String jsonPropertyName() {
            return PROP_ACTIVE_STEP_INDEX;
        }
    });
}
Also used : JSONArray(org.json.JSONArray) List(java.util.List) JSONObject(org.json.JSONObject) IWizardStep(org.eclipse.scout.rt.client.ui.wizard.IWizardStep) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 9 with IForm

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

the class AbstractWizard method initConfig.

@SuppressWarnings({ "boxing", "unchecked" })
protected void initConfig() {
    setTitle(getConfiguredTitle());
    setSubTitle(getConfiguredSubTitle());
    // initially the wizard is in state "closed"
    setClosedInternal(true);
    setCloseTypeInternal(CloseType.Unknown);
    m_contributionHolder = new ContributionComposite(AbstractWizard.this);
    m_containerForm = createContainerForm();
    Assertions.assertNotNull(m_containerForm, "Missing container form");
    interceptDecorateContainerForm();
    // Run the initialization on behalf of the container form.
    runWithinContainerForm(new IRunnable() {

        @Override
        public void run() throws Exception {
            // steps
            List<Class<? extends IWizardStep<? extends IForm>>> configuredAvailableSteps = getConfiguredAvailableSteps();
            List<IWizardStep> contributedSteps = m_contributionHolder.getContributionsByClass(IWizardStep.class);
            OrderedCollection<IWizardStep<? extends IForm>> steps = new OrderedCollection<IWizardStep<? extends IForm>>();
            for (Class<? extends IWizardStep<? extends IForm>> element : configuredAvailableSteps) {
                IWizardStep<? extends IForm> step = ConfigurationUtility.newInnerInstance(AbstractWizard.this, element);
                steps.addOrdered(step);
            }
            for (IWizardStep step : contributedSteps) {
                steps.addOrdered(step);
            }
            injectStepsInternal(steps);
            ExtensionUtility.moveModelObjects(steps);
            setAvailableSteps(steps.getOrderedList());
            // add listener to listen on any field in active form
            m_anyFieldChangeListener = new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent e) {
                    try {
                        interceptAnyFieldChanged((IFormField) e.getSource());
                    } catch (RuntimeException | PlatformError t) {
                        LOG.error("{} {}={}", e.getSource(), e.getPropertyName(), e.getNewValue(), t);
                    }
                }
            };
            propertySupport.addPropertyChangeListener(PROP_WIZARD_FORM, new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent e) {
                    IForm oldForm = (IForm) e.getOldValue();
                    IForm newForm = (IForm) e.getNewValue();
                    if (oldForm != null) {
                        oldForm.getRootGroupBox().removeSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
                    }
                    if (newForm != null) {
                        newForm.getRootGroupBox().addSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
                    }
                }
            });
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IForm(org.eclipse.scout.rt.client.ui.form.IForm) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with IForm

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

the class FindFieldByFormDataIdVisitor method visitField.

@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
    if (m_searchContextRootForm == null) {
        // auto-initialize search context
        // we assume the form field tree is traversed pre-order (i.e. first node itself, then its children)
        m_searchContextRootForm = field.getForm();
    }
    if (matchesAllParts(field)) {
        int fieldTypeRank = 0;
        if (m_searchContextRootForm != null) {
            IForm form = field.getForm();
            while (form != null && form != m_searchContextRootForm) {
                fieldTypeRank += 10;
                form = form.getOuterForm();
            }
        }
        if (field instanceof IValueField) {
        // fieldTypeRank is fine
        } else if (field instanceof ITableField) {
            fieldTypeRank += 1;
        } else if (!(field instanceof ICompositeField)) {
            fieldTypeRank += 2;
        } else {
            fieldTypeRank += 3;
        }
        // Compute the enclosing field path rank that is used as additional hint for determining the
        // best matching form field for the requested formId. Note: for compatibility reasons, the enclosing
        // field path is not enforced.
        int enclosingFieldPathRank = getEnclosingFieldPathRank(field);
        m_prioMap.put(new CompositeObject(fieldTypeRank, enclosingFieldPathRank), field);
    }
    return !m_prioMap.containsKey(PERFECT_VALUE_FIELD_MATCH_KEY);
}
Also used : ITableField(org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) IForm(org.eclipse.scout.rt.client.ui.form.IForm) ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField)

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