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));
}
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));
}
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());
}
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());
}
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);
}
}
Aggregations