use of org.eclipse.scout.rt.platform.OrderedComparator 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.OrderedComparator in project scout.rt by eclipse.
the class CompositeFieldUtility method addField.
public static void addField(IFormField f, ICompositeField compositeField, List<IFormField> fields) {
checkFieldStateForMove(f);
checkFieldStateForMove(compositeField);
if (f.getParentField() != null) {
throw new IllegalArgumentException("field is already contained in '" + f.getParentField() + "'");
}
if (f.getForm() != null && f.getForm() != compositeField.getForm()) {
throw new IllegalArgumentException("field is part of a different form, '" + f.getForm() + "' instead of '" + compositeField.getForm() + "'");
}
fields.add(f);
Collections.sort(fields, new OrderedComparator());
f.setParentFieldInternal(compositeField);
f.setFormInternal(compositeField.getForm());
}
use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.
the class AbstractTable method addTableControlInternal.
private void addTableControlInternal(ITableControl control) {
((AbstractTableControl) control).setTable(this);
Collections.sort(m_tableControls, new OrderedComparator());
propertySupport.firePropertyChange(PROP_TABLE_CONTROLS, null, getTableControls());
}
use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.
the class AbstractActionNode method addChildActions.
@Override
public void addChildActions(Collection<? extends T> actionList) {
List<T> normalizedList = CollectionUtility.arrayListWithoutNullElements(actionList);
if (!normalizedList.isEmpty()) {
setContainerOnActions(normalizedList);
List<T> childList = getChildActionsInternal();
if (childList == null) {
childList = new ArrayList<T>(normalizedList.size());
}
childList.addAll(normalizedList);
Collections.sort(childList, new OrderedComparator());
propertySupport.setPropertyAlwaysFire(PROP_CHILD_ACTIONS, childList);
}
}
use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.
the class OrderedComparatorTest method testCompare.
@Test
public void testCompare() {
OrderedComparator comparator = new OrderedComparator();
IFormField f1 = Mockito.mock(IFormField.class);
IFormField f2 = Mockito.mock(IFormField.class);
Mockito.when(f1.getOrder()).thenReturn(10d);
Mockito.when(f2.getOrder()).thenReturn(20d);
Assert.assertEquals(0, comparator.compare(null, null));
Assert.assertEquals(-1, comparator.compare(null, f1));
Assert.assertEquals(1, comparator.compare(f1, null));
Assert.assertEquals(-1, comparator.compare(f1, f2));
Assert.assertEquals(1, comparator.compare(f2, f1));
Assert.assertEquals(0, comparator.compare(f1, f1));
}
Aggregations