Search in sources :

Example 6 with OrderedCollection

use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection in project scout.rt by eclipse.

the class AbstractGroupBox method initMenus.

private void initMenus() {
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        menus.addOrdered(ConfigurationUtility.newInnerInstance(this, menuClazz));
    }
    menus.addAllOrdered(contributedMenus);
    injectMenusInternal(menus);
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    // set container on menus
    IFormFieldContextMenu contextMenu = new FormFieldContextMenu<IGroupBox>(this, menus.getOrderedList());
    contextMenu.setContainerInternal(this);
    setContextMenu(contextMenu);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) FormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.FormFieldContextMenu) IFormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) IFormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu)

Example 7 with OrderedCollection

use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection in project scout.rt by eclipse.

the class AbstractImageField method initConfig.

@Override
protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
    super.initConfig();
    setImageTransform(new AffineTransformSpec());
    setAutoFit(getConfiguredAutoFit());
    setImageId(getConfiguredImageId());
    setPanDelta(getConfiguredPanDelta());
    setRotateDelta(getConfiguredRotateDelta());
    setZoomDelta(getConfiguredZoomDelta());
    setDragType(getConfiguredDragType());
    setDropType(getConfiguredDropType());
    setDropMaximumSize(getConfiguredDropMaximumSize());
    setScrollBarEnabled(getConfiguredScrollBarEnabled());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        menus.addOrdered(ConfigurationUtility.newInnerInstance(this, menuClazz));
    }
    menus.addAllOrdered(contributedMenus);
    injectMenusInternal(menus);
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    m_contextMenu = new FormFieldContextMenu<IImageField>(this, menus.getOrderedList());
    m_contextMenu.setContainerInternal(this);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) AffineTransformSpec(org.eclipse.scout.rt.shared.data.basic.AffineTransformSpec)

Example 8 with OrderedCollection

use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection 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 9 with OrderedCollection

use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection in project scout.rt by eclipse.

the class AbstractCompositeField method initConfig.

@Override
protected void initConfig() {
    /*
     * call first super initConfig to ensure all properties are applied to the field only.
     * E.g. setEnabled(getConfiguredEnabled()) would enable/disable all children when called
     * after field creation. -> all fields would have the enabled state of the MainBox.
     */
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    m_fieldPropertyChangeListener = new P_FieldPropertyChangeListener();
    super.initConfig();
    // prepare injected fields
    DefaultFormFieldInjection injectedFields = null;
    List<Class<IFormField>> declaredFields = getConfiguredFields();
    List<Class<? extends IFormField>> configuredFields = new ArrayList<Class<? extends IFormField>>(declaredFields.size());
    for (Class<? extends IFormField> clazz : declaredFields) {
        if (ConfigurationUtility.isInjectFieldAnnotationPresent(clazz)) {
            if (injectedFields == null) {
                injectedFields = new DefaultFormFieldInjection(this);
            }
            injectedFields.addField(clazz);
        } else {
            configuredFields.add(clazz);
        }
    }
    try {
        List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
        if (injectedFields != null) {
            FormFieldInjectionThreadLocal.push(injectedFields);
        }
        FormFieldInjectionThreadLocal.pushContainerField(this);
        filterFieldsInternal(configuredFields);
        // create instances
        OrderedCollection<IFormField> fields = new OrderedCollection<IFormField>();
        for (Class<? extends IFormField> clazz : configuredFields) {
            IFormField f = ConfigurationUtility.newInnerInstance(this, clazz);
            fields.addOrdered(f);
        }
        // handle contributions
        fields.addAllOrdered(contributedFields);
        injectFieldsInternal(fields);
        // connect
        for (IFormField f : fields) {
            f.setParentFieldInternal(this);
        }
        m_fields = fields.getOrderedList();
        // attach a proxy controller to each child field in the group for: visible, saveNeeded
        for (IFormField f : m_fields) {
            f.addPropertyChangeListener(m_fieldPropertyChangeListener);
        }
    } finally {
        if (injectedFields != null) {
            m_formFieldReplacements = injectedFields.getReplacementMapping();
            FormFieldInjectionThreadLocal.pop(injectedFields);
        }
        FormFieldInjectionThreadLocal.popContainerField(this);
    }
    handleFieldVisibilityChanged();
}
Also used : DefaultFormFieldInjection(org.eclipse.scout.rt.client.ui.form.DefaultFormFieldInjection) ArrayList(java.util.ArrayList) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection)

Example 10 with OrderedCollection

use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection in project scout.rt by eclipse.

the class AbstractButton method initConfig.

@Override
protected void initConfig() {
    super.initConfig();
    setSystemType(getConfiguredSystemType());
    setDisplayStyleInternal(getConfiguredDisplayStyle());
    setProcessButton(getConfiguredProcessButton());
    setDefaultButton(getConfiguredDefaultButton());
    setIconId(getConfiguredIconId());
    setKeyStroke(getConfiguredKeyStroke());
    setKeyStrokeScopeClass(getConfiguredKeyStrokeScopeClass());
    setPreventDoubleClick(getConfiguredPreventDoubleClick());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        IMenu menu;
        menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menus.addOrdered(menu);
    }
    menus.addAllOrdered(contributedMenus);
    injectMenusInternal(menus);
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    IContextMenu contextMenu = new FormFieldContextMenu<IButton>(this, menus.getOrderedList());
    contextMenu.setContainerInternal(this);
    setContextMenu(contextMenu);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) FormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.FormFieldContextMenu) IContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IContextMenu) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection)

Aggregations

OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)23 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)12 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)8 ArrayList (java.util.ArrayList)7 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)4 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)4 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IProposalField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 Test (org.junit.Test)4 List (java.util.List)3 FormFieldContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.FormFieldContextMenu)3 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)2 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)2 IFormFieldContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu)2 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)2 IOException (java.io.IOException)1