use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection 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);
}
use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection 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();
}
}
});
}
}
use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection 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();
}
use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection 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>();
}
use of org.eclipse.scout.rt.platform.util.collection.OrderedCollection in project scout.rt by eclipse.
the class AbstractRadioButtonGroup method initConfig.
@Override
protected void initConfig() {
m_fields = CollectionUtility.emptyArrayList();
m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
m_fieldPropertyChangeListener = new P_FieldPropertyChangeListenerEx();
m_grid = createGrid();
super.initConfig();
// Configured CodeType
if (getConfiguredCodeType() != null) {
setCodeTypeClass(getConfiguredCodeType());
}
// Configured LookupCall
Class<? extends ILookupCall<T>> lookupCallClass = getConfiguredLookupCall();
if (lookupCallClass != null) {
ILookupCall<T> call = BEANS.get(lookupCallClass);
setLookupCall(call);
}
// add fields
List<Class<? extends IFormField>> configuredFields = getConfiguredFields();
List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
OrderedCollection<IFormField> fields = new OrderedCollection<IFormField>();
for (Class<? extends IFormField> fieldClazz : configuredFields) {
fields.addOrdered(ConfigurationUtility.newInnerInstance(this, fieldClazz));
}
fields.addAllOrdered(contributedFields);
injectFieldsInternal(fields);
for (IFormField f : fields) {
f.setParentFieldInternal(this);
}
m_fields = fields.getOrderedList();
// attach a proxy controller to each child field in the group for: visible, saveNeeded
for (IFormField f : m_fields) {
f.addPropertyChangeListener(m_fieldPropertyChangeListener);
}
// extract buttons from field subtree
List<IRadioButton<T>> buttonList = new ArrayList<IRadioButton<T>>();
for (IFormField f : m_fields) {
IRadioButton<T> b = findFirstButtonInFieldTree(f);
if (b != null) {
buttonList.add(b);
}
}
m_radioButtons = buttonList;
// decorate radio buttons
for (IRadioButton b : m_radioButtons) {
b.addPropertyChangeListener(new P_ButtonPropertyChangeListener());
}
handleFieldVisibilityChanged();
}
Aggregations