Search in sources :

Example 16 with OrderedCollection

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

the class AbstractTree method initConfig.

protected void initConfig() {
    // default enabled
    m_enabled = NamedBitMaskHelper.ALL_BITS_SET;
    m_eventHistory = createEventHistory();
    m_eventBuffer = createEventBuffer();
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(createUIFacade(), ModelContext.copyCurrent());
    m_contributionHolder = new ContributionComposite(this);
    setEnabled(true);
    setTitle(getConfiguredTitle());
    setIconId(getConfiguredIconId());
    setDefaultIconId(getConfiguredDefaultIconId());
    setCssClass(getConfiguredCssClass());
    setAutoTitle(getConfiguredAutoTitle());
    setCheckable(getConfiguredCheckable());
    setNodeHeightHint(getConfiguredNodeHeightHint());
    setMultiCheck(getConfiguredMultiCheck());
    setMultiSelect(getConfiguredMultiSelect());
    setAutoDiscardOnDelete(getConfiguredAutoDiscardOnDelete());
    setDragEnabled(getConfiguredDragEnabled());
    setDragType(getConfiguredDragType());
    setDropType(getConfiguredDropType());
    setDropMaximumSize(getConfiguredDropMaximumSize());
    setRootNodeVisible(getConfiguredRootNodeVisible());
    setRootHandlesVisible(getConfiguredRootHandlesVisible());
    setScrollToSelection(getConfiguredScrollToSelection());
    setSaveAndRestoreScrollbars(getConfiguredSaveAndRestoreScrollbars());
    setAutoCheckChildNodes(getConfiguredAutoCheckChildNodes());
    setLazyExpandingEnabled(getConfiguredLazyExpandingEnabled());
    setDisplayStyle(getConfiguredDisplayStyle());
    setToggleBreadcrumbStyleEnabled(getConfiguredToggleBreadcrumbStyleEnabled());
    setRootNode(new AbstractTreeNode() {
    });
    // add Convenience observer for drag & drop callbacks and event history
    addTreeListener(new TreeAdapter() {

        @Override
        public void treeChanged(TreeEvent e) {
            // event history
            IEventHistory<TreeEvent> h = getEventHistory();
            if (h != null) {
                h.notifyEvent(e);
            }
            // dnd
            switch(e.getType()) {
                case TreeEvent.TYPE_NODES_DRAG_REQUEST:
                    {
                        m_lastSeenDropNode = null;
                        if (e.getDragObject() == null) {
                            try {
                                TransferObject transferObject = interceptDrag(e.getNode());
                                if (transferObject == null) {
                                    transferObject = interceptDrag(e.getNodes());
                                }
                                e.setDragObject(transferObject);
                            } catch (Exception t) {
                                LOG.error("Drag", t);
                            }
                        }
                        break;
                    }
                case TreeEvent.TYPE_NODE_DROP_ACTION:
                    {
                        m_lastSeenDropNode = null;
                        if (e.getDropObject() != null) {
                            try {
                                interceptDrop(e.getNode(), e.getDropObject());
                            } catch (Exception t) {
                                LOG.error("Drop", t);
                            }
                        }
                        break;
                    }
                case TreeEvent.TYPE_NODES_SELECTED:
                    {
                        rebuildKeyStrokesInternal();
                        break;
                    }
                case TreeEvent.TYPE_NODES_CHECKED:
                    {
                        try {
                            interceptNodesChecked(CollectionUtility.arrayList(e.getNodes()));
                        } catch (RuntimeException ex) {
                            BEANS.get(ExceptionHandler.class).handle(ex);
                        }
                        break;
                    }
                case TreeEvent.TYPE_NODE_DROP_TARGET_CHANGED:
                    {
                        try {
                            if (m_lastSeenDropNode == null || m_lastSeenDropNode != e.getNode()) {
                                m_lastSeenDropNode = e.getNode();
                                interceptDropTargetChanged(e.getNode());
                            }
                        } catch (RuntimeException ex) {
                            LOG.error("DropTargetChanged", ex);
                        }
                        break;
                    }
                case TreeEvent.TYPE_DRAG_FINISHED:
                    {
                        m_lastSeenDropNode = null;
                    }
            }
        }
    });
    // key shortcuts
    List<Class<? extends IKeyStroke>> configuredKeyStrokes = getConfiguredKeyStrokes();
    List<IKeyStroke> ksList = new ArrayList<IKeyStroke>(configuredKeyStrokes.size());
    for (Class<? extends IKeyStroke> keystrokeClazz : configuredKeyStrokes) {
        ksList.add(ConfigurationUtility.newInnerInstance(this, keystrokeClazz));
    }
    // ticket 87370: add ENTER key stroke when execNodeAction has an override
    if (ConfigurationUtility.isMethodOverwrite(AbstractTree.class, "execNodeAction", new Class[] { ITreeNode.class }, this.getClass())) {
        ksList.add(new KeyStroke("ENTER") {

            @Override
            protected void execAction() {
                fireNodeAction(getSelectedNode());
            }
        });
    }
    List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
    contributedKeyStrokes.addAll(contributedKeyStrokes);
    m_baseKeyStrokes = ksList;
    setKeyStrokesInternal(m_baseKeyStrokes);
    // 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 = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menus.addOrdered(menu);
    }
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("Error occured while dynamically contributing menus.", e);
    }
    menus.addAllOrdered(contributedMenus);
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    TreeContextMenu contextMenu = new TreeContextMenu(this, menus.getOrderedList());
    setContextMenuInternal(contextMenu);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) ArrayList(java.util.ArrayList) IEventHistory(org.eclipse.scout.rt.client.ui.IEventHistory) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) TransferObject(org.eclipse.scout.rt.client.ui.dnd.TransferObject) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) KeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.KeyStroke) TreeContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.TreeContextMenu) ITreeContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITreeContextMenu)

Example 17 with OrderedCollection

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

the class AbstractCalendar method initConfig.

protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
    m_contributionHolder = new ContributionComposite(this);
    setTitle(getConfiguredTitle());
    setSelectedDate(new Date());
    setStartHour(getConfiguredStartHour());
    setEndHour(getConfiguredEndHour());
    setUseOverflowCells(getConfiguredUseOverflowCells());
    setShowDisplayModeSelection(getConfiguredShowDisplayModeSelection());
    setMarkNoonHour(getConfiguredMarkNoonHour());
    setMarkOutOfMonthDays(getConfiguredMarkOutOfMonthDays());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menus.addOrdered(menu);
    }
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    menus.addAllOrdered(contributedMenus);
    // producers
    List<Class<? extends ICalendarItemProvider>> configuredProducers = getConfiguredProducers();
    List<ICalendarItemProvider> contributedProducers = m_contributionHolder.getContributionsByClass(ICalendarItemProvider.class);
    List<ICalendarItemProvider> producerList = new ArrayList<ICalendarItemProvider>(configuredProducers.size() + contributedProducers.size());
    for (Class<? extends ICalendarItemProvider> itemProviderClazz : configuredProducers) {
        try {
            ICalendarItemProvider provider = ConfigurationUtility.newInnerInstance(this, itemProviderClazz);
            producerList.add(provider);
            // add empty space menus to the context menu
            menus.addAllOrdered(ActionUtility.getActions(provider.getMenus(), ActionUtility.createMenuFilterMenuTypes(CollectionUtility.hashSet(CalendarMenuType.EmptySpace), false)));
        } catch (Exception e) {
            BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + itemProviderClazz.getName() + "'.", e));
        }
    }
    producerList.addAll(contributedProducers);
    m_providers = producerList;
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contributing menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    ICalendarContextMenu contextMenu = new CalendarContextMenu(this, menus.getOrderedList());
    setContextMenu(contextMenu);
    // attach change listener for item updates
    for (final ICalendarItemProvider p : m_providers) {
        p.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals(ICalendarItemProvider.PROP_ITEMS)) {
                    List<ICalendarItemProvider> modified = new ArrayList<ICalendarItemProvider>(1);
                    modified.add(p);
                    updateComponentsInternal(modified);
                } else if (e.getPropertyName().equals(ICalendarItemProvider.PROP_LOAD_IN_PROGRESS)) {
                    updateLoadInProgressInternal();
                }
            }
        });
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) PropertyChangeEvent(java.beans.PropertyChangeEvent) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider) ICalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu) Date(java.util.Date) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) CalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.CalendarContextMenu) ICalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu)

Example 18 with OrderedCollection

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

the class AbstractCalendarItemProvider method initConfig.

protected void initConfig() {
    m_contributionHolder = new ContributionComposite(this);
    setMoveItemEnabled(getConfiguredMoveItemEnabled());
    setRefreshIntervalMillis(getConfiguredRefreshIntervallMillis());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menu.initAction();
        menus.addOrdered(menu);
    }
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    menus.addAllOrdered(contributedMenus);
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contribute menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    m_menus = menus.getOrderedList();
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection)

Example 19 with OrderedCollection

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

the class AbstractDataModelEntity method initConfig.

protected void initConfig() {
    // default visible
    m_visible = NamedBitMaskHelper.ALL_BITS_SET;
    m_contributionHolder = new ContributionComposite(this);
    setText(getConfiguredText());
    setIconId(getConfiguredIconId());
    setVisible(getConfiguredVisible());
    setOneToMany(getConfiguredOneToMany());
    setOrder(calculateViewOrder());
    List<Class<IDataModelAttribute>> configuredAttributes = getConfiguredAttributes();
    List<IDataModelAttribute> contributedAttributes = m_contributionHolder.getContributionsByClass(IDataModelAttribute.class);
    OrderedCollection<IDataModelAttribute> attributes = new OrderedCollection<IDataModelAttribute>();
    for (Class<? extends IDataModelAttribute> c : configuredAttributes) {
        attributes.addOrdered(ConfigurationUtility.newInnerInstance(this, c));
    }
    attributes.addAllOrdered(contributedAttributes);
    injectAttributesInternal(attributes);
    ExtensionUtility.moveModelObjects(attributes);
    m_attributes = attributes.getOrderedList();
    for (IDataModelAttribute a : m_attributes) {
        if (a instanceof AbstractDataModelAttribute) {
            ((AbstractDataModelAttribute) a).setParentEntity(this);
        }
    }
    // lazy create entities at point when setParentEntity is set, this is necessary to avoid cyclic loops
    m_entities = new ArrayList<IDataModelEntity>();
}
Also used : ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection)

Example 20 with OrderedCollection

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

the class AbstractRadioButtonGroup method initConfig.

@Override
protected void initConfig() {
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    m_fieldPropertyChangeListener = new P_FieldPropertyChangeListenerEx();
    m_grid = createGrid();
    super.initConfig();
    // Configured CodeType
    if (getConfiguredCodeType() != null) {
        setCodeTypeClass(getConfiguredCodeType());
    }
    // Configured LookupCall
    Class<? extends ILookupCall<T>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<T> call = BEANS.get(lookupCallClass);
        setLookupCall(call);
    }
    // add fields
    List<Class<? extends IFormField>> configuredFields = getConfiguredFields();
    List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
    OrderedCollection<IFormField> fields = new OrderedCollection<IFormField>();
    for (Class<? extends IFormField> fieldClazz : configuredFields) {
        fields.addOrdered(ConfigurationUtility.newInnerInstance(this, fieldClazz));
    }
    fields.addAllOrdered(contributedFields);
    injectFieldsInternal(fields);
    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);
    }
    // extract buttons from field subtree
    List<IRadioButton<T>> buttonList = new ArrayList<IRadioButton<T>>();
    for (IFormField f : m_fields) {
        IRadioButton<T> b = findFirstButtonInFieldTree(f);
        if (b != null) {
            buttonList.add(b);
        }
    }
    m_radioButtons = buttonList;
    // decorate radio buttons
    for (IRadioButton b : m_radioButtons) {
        b.addPropertyChangeListener(new P_ButtonPropertyChangeListener());
    }
    handleFieldVisibilityChanged();
}
Also used : ArrayList(java.util.ArrayList) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) IRadioButton(org.eclipse.scout.rt.client.ui.form.fields.button.IRadioButton) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField)

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