Search in sources :

Example 11 with ContributionComposite

use of org.eclipse.scout.rt.shared.extension.ContributionComposite in project scout.rt by eclipse.

the class AbstractFormField method initConfig.

protected void initConfig() {
    setGridDataInternal(new GridData(-1, -1, 1, 1, -1, -1));
    setGridDataHints(new GridData(-1, -1, 1, 1, -1, -1));
    propertySupport.setPropertyBool(PROP_EMPTY, true);
    m_contributionHolder = new ContributionComposite(this);
    setEnabled(getConfiguredEnabled());
    setDisabledStyle(getConfiguredDisabledStyle());
    setVisible(getConfiguredVisible());
    setMandatory(getConfiguredMandatory());
    setOrder(calculateViewOrder());
    setTooltipText(getConfiguredTooltipText());
    setInitialLabel(getConfiguredLabel());
    setLabel(getConfiguredLabel());
    setLabelPosition(getConfiguredLabelPosition());
    setLabelWidthInPixel(getConfiguredLabelWidthInPixel());
    setLabelHorizontalAlignment(getConfiguredLabelHorizontalAlignment());
    setLabelVisible(getConfiguredLabelVisible());
    setStatusVisible(getConfiguredStatusVisible());
    setStatusPosition(getConfiguredStatusPosition());
    setCssClass((getConfiguredCssClass()));
    if (getConfiguredBackgroundColor() != null) {
        setBackgroundColor((getConfiguredBackgroundColor()));
    }
    if (getConfiguredForegroundColor() != null) {
        setForegroundColor((getConfiguredForegroundColor()));
    }
    if (getConfiguredFont() != null) {
        setFont(FontSpec.parse(getConfiguredFont()));
    }
    if (getConfiguredLabelBackgroundColor() != null) {
        setLabelBackgroundColor((getConfiguredLabelBackgroundColor()));
    }
    if (getConfiguredLabelForegroundColor() != null) {
        setLabelForegroundColor((getConfiguredLabelForegroundColor()));
    }
    if (getConfiguredLabelFont() != null) {
        setLabelFont(FontSpec.parse(getConfiguredLabelFont()));
    }
    setFocusable(getConfiguredFocusable());
    setPreventInitialFocus(getConfiguredPreventInitialFocus());
    setGridDataHints(new GridData(getConfiguredGridX(), getConfiguredGridY(), getConfiguredGridW(), getConfiguredGridH(), getConfiguredGridWeightX(), getConfiguredGridWeightY(), getConfiguredGridUseUiWidth(), getConfiguredGridUseUiHeight(), getConfiguredHorizontalAlignment(), getConfiguredVerticalAlignment(), getConfiguredFillHorizontal(), getConfiguredFillVertical(), getConfiguredWidthInPixel(), getConfiguredHeightInPixel()));
    setMasterRequired(getConfiguredMasterRequired());
    // private listener for subtree property change events
    addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            fireSubtreePropertyChange(e);
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite)

Example 12 with ContributionComposite

use of org.eclipse.scout.rt.shared.extension.ContributionComposite 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 13 with ContributionComposite

use of org.eclipse.scout.rt.shared.extension.ContributionComposite 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 14 with ContributionComposite

use of org.eclipse.scout.rt.shared.extension.ContributionComposite 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 15 with ContributionComposite

use of org.eclipse.scout.rt.shared.extension.ContributionComposite 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)

Aggregations

ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)16 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)8 ArrayList (java.util.ArrayList)6 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)4 List (java.util.List)3 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)3 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)3 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)3 KeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.KeyStroke)2 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)2 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)1 MoveFormFieldsHandler (org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler)1 IDeviceTransformationService (org.eclipse.scout.rt.client.transformation.IDeviceTransformationService)1