use of org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler 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);
}
Aggregations