Search in sources :

Example 1 with IKeyStroke

use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.

the class AbstractTable method initConfig.

protected void initConfig() {
    m_eventHistory = createEventHistory();
    m_eventBuffer = createEventBuffer();
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(createUIFacade(), ModelContext.copyCurrent());
    m_contributionHolder = new ContributionComposite(this);
    setEnabled(true);
    setLoading(false);
    setGroupingStyle(getConfiguredGroupingStyle());
    setTitle(getConfiguredTitle());
    setAutoDiscardOnDelete(getConfiguredAutoDiscardOnDelete());
    setSortEnabled(getConfiguredSortEnabled());
    setDefaultIconId(getConfiguredDefaultIconId());
    setCssClass((getConfiguredCssClass()));
    setRowIconVisible(getConfiguredRowIconVisible());
    setHeaderVisible(getConfiguredHeaderVisible());
    setHeaderEnabled(getConfiguredHeaderEnabled());
    setAutoResizeColumns(getConfiguredAutoResizeColumns());
    setCheckable(getConfiguredCheckable());
    setMultiCheck(getConfiguredMultiCheck());
    setMultiSelect(getConfiguredMultiSelect());
    setInitialMultilineText(getConfiguredMultilineText());
    setMultilineText(getConfiguredMultilineText());
    setKeyboardNavigation(getConfiguredKeyboardNavigation());
    setDragType(getConfiguredDragType());
    setDropType(getConfiguredDropType());
    setDropMaximumSize(getConfiguredDropMaximumSize());
    setScrollToSelection(getConfiguredScrollToSelection());
    setTableStatusVisible(getConfiguredTableStatusVisible());
    if (getTableCustomizer() == null) {
        setTableCustomizer(createTableCustomizer());
    }
    // columns
    createColumnsInternal();
    // table controls
    createTableControlsInternal();
    // menus
    initMenus();
    // key strokes
    List<Class<? extends IKeyStroke>> ksClasses = getConfiguredKeyStrokes();
    List<IKeyStroke> ksList = new ArrayList<IKeyStroke>(ksClasses.size());
    for (Class<? extends IKeyStroke> clazz : ksClasses) {
        IKeyStroke ks = ConfigurationUtility.newInnerInstance(this, clazz);
        ks.initAction();
        if (ks.getKeyStroke() != null) {
            ksList.add(ks);
        }
    }
    // add ENTER key stroke when default menu is used or execRowAction has an override
    Class<? extends IMenu> defaultMenuType = getDefaultMenuInternal();
    if (defaultMenuType != null || ConfigurationUtility.isMethodOverwrite(AbstractTable.class, "execRowAction", new Class[] { ITableRow.class }, this.getClass())) {
        ksList.add(new KeyStroke("ENTER") {

            @Override
            protected void execAction() {
                fireRowAction(getSelectedRow());
            }
        });
    }
    // add keystroke contributions
    List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
    ksList.addAll(contributedKeyStrokes);
    setKeyStrokes(ksList);
    m_tableOrganizer = BEANS.get(ITableOrganizerProvider.class).createTableOrganizer(this);
    // add Convenience observer for drag & drop callbacks, event history and ui sort possible check
    addTableListener(new TableAdapter() {

        @Override
        public void tableChanged(TableEvent e) {
            // event history
            IEventHistory<TableEvent> h = getEventHistory();
            if (h != null) {
                h.notifyEvent(e);
            }
            // dnd
            switch(e.getType()) {
                case TableEvent.TYPE_ROWS_DRAG_REQUEST:
                    {
                        if (e.getDragObject() == null) {
                            try {
                                e.setDragObject(interceptDrag(e.getRows()));
                            } catch (RuntimeException ex) {
                                BEANS.get(ExceptionHandler.class).handle(ex);
                            }
                        }
                        break;
                    }
                case TableEvent.TYPE_ROW_DROP_ACTION:
                    {
                        if (e.getDropObject() != null && isEnabled()) {
                            try {
                                interceptDrop(e.getFirstRow(), e.getDropObject());
                            } catch (RuntimeException ex) {
                                BEANS.get(ExceptionHandler.class).handle(ex);
                            }
                        }
                        break;
                    }
                case TableEvent.TYPE_ROWS_COPY_REQUEST:
                    {
                        if (e.getCopyObject() == null) {
                            try {
                                e.setCopyObject(interceptCopy(e.getRows()));
                            } catch (RuntimeException ex) {
                                BEANS.get(ExceptionHandler.class).handle(ex);
                            }
                        }
                        break;
                    }
                case TableEvent.TYPE_ALL_ROWS_DELETED:
                case TableEvent.TYPE_ROWS_DELETED:
                case TableEvent.TYPE_ROWS_INSERTED:
                case TableEvent.TYPE_ROWS_UPDATED:
                    {
                        if (isValueChangeTriggerEnabled()) {
                            try {
                                interceptContentChanged();
                            } catch (RuntimeException ex) {
                                BEANS.get(ExceptionHandler.class).handle(ex);
                            }
                        }
                        break;
                    }
                case TableEvent.TYPE_ROWS_CHECKED:
                    try {
                        interceptRowsChecked(e.getRows());
                    } catch (RuntimeException ex) {
                        BEANS.get(ExceptionHandler.class).handle(ex);
                    }
                    break;
                case TableEvent.TYPE_COLUMN_HEADERS_UPDATED:
                case TableEvent.TYPE_COLUMN_STRUCTURE_CHANGED:
                    checkIfColumnPreventsUiSortForTable();
                    break;
            }
        }
    });
}
Also used : ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) ArrayList(java.util.ArrayList) IEventHistory(org.eclipse.scout.rt.client.ui.IEventHistory) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) ExceptionHandler(org.eclipse.scout.rt.platform.exception.ExceptionHandler) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) KeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.KeyStroke)

Example 2 with IKeyStroke

use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.

the class AbstractDesktop method initConfig.

protected void initConfig() {
    m_eventHistory = createEventHistory();
    // add convenience observer for event history
    addDesktopListener(new DesktopListener() {

        @Override
        public void desktopChanged(DesktopEvent e) {
            IEventHistory<DesktopEvent> h = getEventHistory();
            if (h != null) {
                h.notifyEvent(e);
            }
        }
    });
    ClientSessionProvider.currentSession().getMemoryPolicy().registerDesktop(this);
    BEANS.get(IDeviceTransformationService.class).install(this);
    initDesktopExtensions();
    setTitle(getConfiguredTitle());
    setCssClass(getConfiguredCssClass());
    setSelectViewTabsKeyStrokesEnabled(getConfiguredSelectViewTabsKeyStrokesEnabled());
    setSelectViewTabsKeyStrokeModifier(getConfiguredSelectViewTabsKeyStrokeModifier());
    setLogoId(getConfiguredLogoId());
    setDisplayStyle(getConfiguredDisplayStyle());
    initDisplayStyle(getDisplayStyle());
    setCacheSplitterPosition(getConfiguredCacheSplitterPosition());
    List<IDesktopExtension> extensions = getDesktopExtensions();
    m_contributionHolder = new ContributionComposite(this);
    // outlines
    OrderedCollection<IOutline> outlines = new OrderedCollection<IOutline>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeOutlines(outlines);
        } catch (Exception t) {
            LOG.error("contributing outlines by {}", ext, t);
        }
    }
    List<IOutline> contributedOutlines = m_contributionHolder.getContributionsByClass(IOutline.class);
    outlines.addAllOrdered(contributedOutlines);
    // move outlines
    ExtensionUtility.moveModelObjects(outlines);
    setAvailableOutlines(outlines.getOrderedList());
    // actions (keyStroke, menu, viewButton, toolButton)
    List<IAction> actionList = new ArrayList<IAction>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeActions(actionList);
        } catch (Exception t) {
            LOG.error("contributing actions by {}", ext, t);
        }
    }
    List<IAction> contributedActions = m_contributionHolder.getContributionsByClass(IAction.class);
    actionList.addAll(contributedActions);
    // build complete menu and viewButton lists
    // only top level menus
    OrderedComparator orderedComparator = new OrderedComparator();
    List<IMenu> menuList = new ActionFinder().findActions(actionList, IMenu.class, false);
    ExtensionUtility.moveModelObjects(menuList);
    Collections.sort(menuList, orderedComparator);
    m_menus = menuList;
    List<IViewButton> viewButtonList = new ActionFinder().findActions(actionList, IViewButton.class, false);
    ExtensionUtility.moveModelObjects(viewButtonList);
    Collections.sort(viewButtonList, orderedComparator);
    m_viewButtons = viewButtonList;
    // add dynamic keyStrokes
    List<IKeyStroke> ksList = new ActionFinder().findActions(actionList, IKeyStroke.class, true);
    for (IKeyStroke ks : ksList) {
        try {
            ks.initAction();
        } catch (RuntimeException | PlatformError e) {
            LOG.error("could not initialize key stroke '{}'.", ks, e);
        }
    }
    addKeyStrokes(ksList.toArray(new IKeyStroke[ksList.size()]));
    // init outlines
    for (IOutline o : m_availableOutlines) {
        try {
            o.initTree();
        } catch (Exception e) {
            LOG.error("Could not init outline {}", o, e);
        }
    }
    addPropertyChangeListener(new P_LocalPropertyChangeListener());
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) IEventHistory(org.eclipse.scout.rt.client.ui.IEventHistory) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) DeepLinkException(org.eclipse.scout.rt.client.deeplink.DeepLinkException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IViewButton(org.eclipse.scout.rt.client.ui.action.view.IViewButton) IDeviceTransformationService(org.eclipse.scout.rt.client.transformation.IDeviceTransformationService) ActionFinder(org.eclipse.scout.rt.client.ui.action.ActionFinder)

Example 3 with IKeyStroke

use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.

the class AbstractDesktop method addKeyStrokes.

@Override
public void addKeyStrokes(IKeyStroke... keyStrokes) {
    if (keyStrokes != null && keyStrokes.length > 0) {
        Map<String, IKeyStroke> map = new HashMap<String, IKeyStroke>();
        for (IKeyStroke ks : getKeyStrokes()) {
            map.put(ks.getKeyStroke(), ks);
        }
        for (IKeyStroke ks : keyStrokes) {
            map.put(ks.getKeyStroke(), ks);
        }
        setKeyStrokes(map.values());
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)

Example 4 with IKeyStroke

use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.

the class AbstractDesktop method removeKeyStrokes.

@Override
public void removeKeyStrokes(IKeyStroke... keyStrokes) {
    if (keyStrokes != null && keyStrokes.length > 0) {
        Map<String, IKeyStroke> map = new HashMap<String, IKeyStroke>();
        for (IKeyStroke ks : getKeyStrokes()) {
            map.put(ks.getKeyStroke(), ks);
        }
        for (IKeyStroke ks : keyStrokes) {
            map.remove(ks.getKeyStroke());
        }
        setKeyStrokes(map.values());
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)

Example 5 with IKeyStroke

use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.

the class AbstractFormField method initLocalKeyStrokes.

protected List<IKeyStroke> initLocalKeyStrokes() {
    List<Class<? extends IKeyStroke>> configuredKeyStrokes = getConfiguredKeyStrokes();
    List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
    Map<String, IKeyStroke> ksMap = new HashMap<String, IKeyStroke>(configuredKeyStrokes.size() + contributedKeyStrokes.size());
    for (Class<? extends IKeyStroke> keystrokeClazz : configuredKeyStrokes) {
        IKeyStroke ks = ConfigurationUtility.newInnerInstance(this, keystrokeClazz);
        ks.initAction();
        if (ks.getKeyStroke() != null) {
            ksMap.put(ks.getKeyStroke().toUpperCase(), ks);
        }
    }
    for (IKeyStroke ks : contributedKeyStrokes) {
        try {
            ks.initAction();
            if (ks.getKeyStroke() != null) {
                ksMap.put(ks.getKeyStroke().toUpperCase(), ks);
            }
        } catch (Exception e) {
            BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error initializing key stroke '" + ks.getClass().getName() + "'.", e));
        }
    }
    return CollectionUtility.arrayListWithoutNullElements(ksMap.values());
}
Also used : HashMap(java.util.HashMap) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)9 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)3 IViewButton (org.eclipse.scout.rt.client.ui.action.view.IViewButton)3 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)3 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)3 LinkedHashMap (java.util.LinkedHashMap)2 KeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.KeyStroke)2 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)2 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)2 TreeMap (java.util.TreeMap)1 IClientSession (org.eclipse.scout.rt.client.IClientSession)1 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)1 IDeviceTransformationService (org.eclipse.scout.rt.client.transformation.IDeviceTransformationService)1 ActionFinder (org.eclipse.scout.rt.client.ui.action.ActionFinder)1 IAction (org.eclipse.scout.rt.client.ui.action.IAction)1 ITreeContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.ITreeContextMenu)1 TreeContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.TreeContextMenu)1