use of org.eclipse.scout.rt.shared.extension.ContributionComposite in project scout.rt by eclipse.
the class AbstractPlanner method initConfig.
protected void initConfig() {
m_listenerList = new EventListenerList();
m_activityMapUIFacade = createUIFacade();
//
setLabel(getConfiguredLabel());
setAvailableDisplayModes(getConfiguredAvailableDisplayModes());
setDisplayMode(getConfiguredDisplayMode());
setDisplayModeOptions(new HashMap<Integer, DisplayModeOptions>());
initDisplayModeOptions();
setHeaderVisible(getConfiguredHeaderVisible());
setSelectionMode(getConfiguredSelectionMode());
setActivitySelectable(getConfiguredActivitySelectable());
setMinimumActivityDuration(getConfiguredMinimumActivityDuration());
// 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);
}
m_contributionHolder = new ContributionComposite(this);
List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
menus.addAllOrdered(contributedMenus);
try {
injectMenusInternal(menus);
} catch (Exception e) {
LOG.error("error occured while dynamically contributing menus.", e);
}
new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
IPlannerContextMenu contextMenu = new PlannerContextMenu(this, menus.getOrderedList());
setContextMenu(contextMenu);
// local property observer
addPlannerListener(new PlannerAdapter() {
@Override
@SuppressWarnings("unchecked")
public void plannerChanged(PlannerEvent e) {
if (e.getType() == PlannerEvent.TYPE_RESOURCES_SELECTED) {
List<Resource<RI>> resources = (List<Resource<RI>>) e.getResources();
try {
interceptResourcesSelected(resources);
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(t);
}
}
}
});
addPropertyChangeListener(new PropertyChangeListener() {
@Override
@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals(PROP_DISPLAY_MODE)) {
try {
interceptDisplayModeChanged((int) e.getNewValue());
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(t);
}
} else if (e.getPropertyName().equals(PROP_VIEW_RANGE)) {
try {
interceptViewRangeChanged((Range) e.getNewValue());
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(t);
}
} else if (e.getPropertyName().equals(PROP_SELECTION_RANGE)) {
try {
interceptSelectionRangeChanged((Range) e.getNewValue());
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(t);
}
} else if (e.getPropertyName().equals(PROP_SELECTED_ACTIVITY)) {
Activity<RI, AI> cell = (Activity<RI, AI>) e.getNewValue();
if (cell != null) {
try {
interceptActivitySelected(cell);
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(t);
}
}
}
}
});
}
use of org.eclipse.scout.rt.shared.extension.ContributionComposite in project scout.rt by eclipse.
the class AbstractWizard method initConfig.
@SuppressWarnings({ "boxing", "unchecked" })
protected void initConfig() {
setTitle(getConfiguredTitle());
setSubTitle(getConfiguredSubTitle());
// initially the wizard is in state "closed"
setClosedInternal(true);
setCloseTypeInternal(CloseType.Unknown);
m_contributionHolder = new ContributionComposite(AbstractWizard.this);
m_containerForm = createContainerForm();
Assertions.assertNotNull(m_containerForm, "Missing container form");
interceptDecorateContainerForm();
// Run the initialization on behalf of the container form.
runWithinContainerForm(new IRunnable() {
@Override
public void run() throws Exception {
// steps
List<Class<? extends IWizardStep<? extends IForm>>> configuredAvailableSteps = getConfiguredAvailableSteps();
List<IWizardStep> contributedSteps = m_contributionHolder.getContributionsByClass(IWizardStep.class);
OrderedCollection<IWizardStep<? extends IForm>> steps = new OrderedCollection<IWizardStep<? extends IForm>>();
for (Class<? extends IWizardStep<? extends IForm>> element : configuredAvailableSteps) {
IWizardStep<? extends IForm> step = ConfigurationUtility.newInnerInstance(AbstractWizard.this, element);
steps.addOrdered(step);
}
for (IWizardStep step : contributedSteps) {
steps.addOrdered(step);
}
injectStepsInternal(steps);
ExtensionUtility.moveModelObjects(steps);
setAvailableSteps(steps.getOrderedList());
// add listener to listen on any field in active form
m_anyFieldChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
try {
interceptAnyFieldChanged((IFormField) e.getSource());
} catch (RuntimeException | PlatformError t) {
LOG.error("{} {}={}", e.getSource(), e.getPropertyName(), e.getNewValue(), t);
}
}
};
propertySupport.addPropertyChangeListener(PROP_WIZARD_FORM, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
IForm oldForm = (IForm) e.getOldValue();
IForm newForm = (IForm) e.getNewValue();
if (oldForm != null) {
oldForm.getRootGroupBox().removeSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
}
if (newForm != null) {
newForm.getRootGroupBox().addSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
}
}
});
}
});
}
use of org.eclipse.scout.rt.shared.extension.ContributionComposite in project scout.rt by eclipse.
the class AbstractForm method initConfig.
protected void initConfig() {
m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent().withForm(this));
m_timerFutureMap = new HashMap<>();
setShowOnStart(getConfiguredShowOnStart());
m_contributionHolder = new ContributionComposite(this);
// prepare injected fields
List<Class<IFormField>> fieldArray = getConfiguredInjectedFields();
DefaultFormFieldInjection injectedFields = null;
IGroupBox rootBox = getRootGroupBox();
try {
if (fieldArray.size() > 0) {
injectedFields = new DefaultFormFieldInjection(this);
injectedFields.addFields(fieldArray);
FormFieldInjectionThreadLocal.push(injectedFields);
}
// add mainbox if getter returns null
if (rootBox == null) {
List<IGroupBox> contributedFields = m_contributionHolder.getContributionsByClass(IGroupBox.class);
rootBox = CollectionUtility.firstElement(contributedFields);
if (rootBox == null) {
Class<? extends IGroupBox> mainBoxClass = getConfiguredMainBox();
if (mainBoxClass != null) {
rootBox = ConfigurationUtility.newInnerInstance(this, mainBoxClass);
}
}
m_mainBox = rootBox;
}
} finally {
if (injectedFields != null) {
m_fieldReplacements = injectedFields.getReplacementMapping();
FormFieldInjectionThreadLocal.pop(injectedFields);
}
}
if (rootBox != null) {
rootBox.setFormInternal(this);
rootBox.setMainBox(true);
rootBox.updateKeyStrokes();
if (rootBox.isScrollable().isUndefined()) {
rootBox.setScrollable(true);
}
}
// move form fields
new MoveFormFieldsHandler(this).moveFields();
//
if (getConfiguredCloseTimer() > 0) {
setCloseTimer(getConfiguredCloseTimer());
}
if (getConfiguredCustomTimer() > 0) {
setTimer("custom", getConfiguredCustomTimer());
}
if (getConfiguredCancelVerificationText() != null) {
setCancelVerificationText(getConfiguredCancelVerificationText());
}
if (getConfiguredTitle() != null) {
setTitle(getConfiguredTitle());
}
if (getConfiguredSubTitle() != null) {
setSubTitle(getConfiguredSubTitle());
}
setMinimizeEnabled(getConfiguredMinimizeEnabled());
setMaximizeEnabled(getConfiguredMaximizeEnabled());
setMinimized(getConfiguredMinimized());
setMaximized(getConfiguredMaximized());
setCacheBounds(getConfiguredCacheBounds());
setAskIfNeedSave(getConfiguredAskIfNeedSave());
setIconId(getConfiguredIconId());
setCssClass((getConfiguredCssClass()));
// Set 'modality' as preferred value if not 'auto'.
int modalityHint = getConfiguredModalityHint();
if (modalityHint != MODALITY_HINT_AUTO) {
m_modal.set(modalityHint == MODALITY_HINT_MODAL, true);
}
// Set 'displayParent' as preferred value if not null; must precede setting of the 'displayHint'.
IDisplayParent displayParent = getConfiguredDisplayParent();
if (displayParent != null) {
m_displayParent.set(displayParent, true);
} else {
m_displayParent.set(getDesktop(), false);
}
setDisplayHint(getConfiguredDisplayHint());
setDisplayViewId(getConfiguredDisplayViewId());
setClosable(getConfiguredClosable());
setSaveNeededVisible(getConfiguredSaveNeededVisible());
// visit all system buttons and attach observer
// is auto-detaching
m_systemButtonListener = new P_SystemButtonListener();
IFormFieldVisitor v2 = new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof IButton) {
final IButton button = (IButton) field;
if (button.getSystemType() != IButton.SYSTEM_TYPE_NONE) {
button.addButtonListener(m_systemButtonListener);
}
}
return true;
}
};
visitFields(v2);
getRootGroupBox().addPropertyChangeListener(new P_MainBoxPropertyChangeProxy());
setButtonsArmed(true);
}
use of org.eclipse.scout.rt.shared.extension.ContributionComposite in project scout.rt by eclipse.
the class AbstractDataModel method initConfig.
protected void initConfig() {
m_contributionHolder = new ContributionComposite(this);
// attributes
m_attributes = createAttributes();
for (IDataModelAttribute a : m_attributes) {
if (a instanceof AbstractDataModelAttribute) {
((AbstractDataModelAttribute) a).setParentEntity(null);
}
}
// entities
m_entities = createEntities();
Map<Class<? extends IDataModelEntity>, IDataModelEntity> instanceMap = new HashMap<Class<? extends IDataModelEntity>, IDataModelEntity>(m_entities.size());
for (IDataModelEntity e : m_entities) {
if (e instanceof AbstractDataModelEntity) {
((AbstractDataModelEntity) e).setParentEntity(null);
}
instanceMap.put(e.getClass(), e);
}
for (IDataModelEntity e : m_entities) {
e.initializeChildEntities(instanceMap);
}
}
use of org.eclipse.scout.rt.shared.extension.ContributionComposite 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());
}
Aggregations