use of org.eclipse.scout.rt.client.ui.IDisplayParent in project scout.rt by eclipse.
the class AbstractDesktop method activateForm.
@Override
public void activateForm(IForm form) {
if (form == null) {
setActiveForm(form);
return;
}
if (!m_formStore.contains(form)) {
// only dialogs or views can be activated.
return;
}
IDisplayParent displayParent = form.getDisplayParent();
if (displayParent instanceof IForm) {
activateForm((IForm) displayParent);
} else if (displayParent instanceof IOutline && !displayParent.equals(getOutline())) {
activateOutline(((IOutline) displayParent));
}
setActiveForm(form);
fireFormActivate(form);
}
use of org.eclipse.scout.rt.client.ui.IDisplayParent 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.client.ui.IDisplayParent in project scout.rt by eclipse.
the class AbstractDisplayParentViewIndex method addToIndex.
@Override
public boolean addToIndex(final IForm element) {
if (m_mapByElement.containsKey(element)) {
removeFromIndex(element);
}
final IDisplayParent index = calculateIndexFor(element);
if (index == null) {
return false;
}
List<IForm> elements = m_mapByIndex.get(index);
if (elements == null) {
elements = new ArrayList<>();
m_mapByIndex.put(index, elements);
}
int position = calculatePositionForElement(element);
elements.add(position, element);
m_mapByElement.put(element, index);
return true;
}
use of org.eclipse.scout.rt.client.ui.IDisplayParent in project scout.rt by eclipse.
the class AbstractDisplayParentViewIndex method removeFromIndex.
@Override
public boolean removeFromIndex(final IForm element) {
final IDisplayParent index = m_mapByElement.remove(element);
if (index == null) {
return false;
}
final List<IForm> elements = m_mapByIndex.get(index);
elements.remove(element);
if (elements.isEmpty()) {
m_mapByIndex.remove(index);
}
return true;
}
use of org.eclipse.scout.rt.client.ui.IDisplayParent in project scout.rt by eclipse.
the class JsonDesktop method addActionEventForEachDisplayParentAdapter.
protected List<JsonEvent> addActionEventForEachDisplayParentAdapter(String eventName, String propModelAdapterId, IJsonAdapter<?> modelAdapter, IDisplayParent displayParent, int position) {
List<JsonEvent> events = new ArrayList<>();
for (IJsonAdapter<IDisplayParent> displayParentAdapter : getUiSession().getJsonAdapters(displayParent)) {
JSONObject jsonEvent = new JSONObject();
jsonEvent.put(propModelAdapterId, modelAdapter.getId());
jsonEvent.put(PROP_DISPLAY_PARENT, displayParentAdapter.getId());
if (position >= 0) {
jsonEvent.put(PROP_POSITION, position);
}
// Add modelAdapter as "referenced adapter" to event (to remove event when
// modelAdapter is disposed but desktop is not)
events.add(addActionEvent(eventName, modelAdapter, jsonEvent));
}
return events;
}
Aggregations