Search in sources :

Example 11 with OrderedCollection

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

the class AbstractProposalColumnTest method testLookupRowWithUntrimmedText2.

@Test
public void testLookupRowWithUntrimmedText2() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected boolean getConfiguredTrimText() {
            return true;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI(" a ", false, false);
    column.completeEdit(row, field);
    assertEquals("a", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 12 with OrderedCollection

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

the class AbstractProposalColumnTest method testLookupRowWithUntrimmedText1.

@Test
public void testLookupRowWithUntrimmedText1() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected boolean getConfiguredTrimText() {
            return false;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI(" a ", false, true);
    column.completeEdit(row, field);
    assertEquals(" a ", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 13 with OrderedCollection

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

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

the class AbstractValueField method initConfig.

@Override
protected void initConfig() {
    super.initConfig();
    m_listeningSlaves = new EventListenerList();
    setAutoAddDefaultMenus(getConfiguredAutoAddDefaultMenus());
    // 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);
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contributing menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    // set container on menus
    IValueFieldContextMenu contextMenu = createContextMenu(menus);
    contextMenu.setContainerInternal(this);
    setContextMenu(contextMenu);
    setStatusMenuMappings(createStatusMenuMappings());
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IValueFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IValueFieldContextMenu) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) IOException(java.io.IOException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException)

Example 15 with OrderedCollection

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

the class AbstractTable method createColumnsInternal.

private void createColumnsInternal() {
    List<Class<? extends IColumn>> ca = getConfiguredColumns();
    OrderedCollection<IColumn<?>> columns = new OrderedCollection<IColumn<?>>();
    // configured columns
    for (Class<? extends IColumn> clazz : ca) {
        IColumn<?> column = ConfigurationUtility.newInnerInstance(this, clazz);
        columns.addOrdered(column);
    }
    // contributed columns
    List<IColumn> contributedColumns = m_contributionHolder.getContributionsByClass(IColumn.class);
    for (IColumn c : contributedColumns) {
        columns.addOrdered(c);
    }
    // dynamically injected columns
    injectColumnsInternal(columns);
    // move columns
    ExtensionUtility.moveModelObjects(columns);
    m_columnSet = new ColumnSet(this, columns.getOrderedList());
    if (getConfiguredCheckableColumn() != null) {
        AbstractBooleanColumn checkableColumn = getColumnSet().getColumnByClass(getConfiguredCheckableColumn());
        setCheckableColumn(checkableColumn);
    }
    PropertyChangeListener columnVisibleListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            // disable ui sort possible property if needed
            checkIfColumnPreventsUiSortForTable();
            // prevent invisible context column (because the UI does not know of invisible columns)
            checkIfContextColumnIsVisible();
        }
    };
    for (IColumn column : m_columnSet.getColumns()) {
        column.addPropertyChangeListener(IColumn.PROP_VISIBLE, columnVisibleListener);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractBooleanColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractBooleanColumn) PropertyChangeListener(java.beans.PropertyChangeListener) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) 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