use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.
the class AbstractOutline method ensureDefaultDetailFormCreated.
public void ensureDefaultDetailFormCreated() {
if (getDefaultDetailForm() != null) {
return;
}
IForm form = createDefaultDetailForm();
if (form != null) {
setDefaultDetailForm(form);
interceptInitDefaultDetailForm();
}
}
use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.
the class DefaultPageChangeStrategy method pageChanged.
@Override
public void pageChanged(final IOutline outline, final IPage<?> deselectedPage, final IPage<?> selectedPage) {
if (outline == null) {
return;
}
outline.clearContextPage();
IForm detailForm = null;
ITable detailTable = null;
ISearchForm searchForm = null;
// new active page
outline.makeActivePageToContextPage();
IPage<?> activePage = outline.getActivePage();
if (activePage != null) {
try {
activePage.ensureChildrenLoaded();
} catch (RuntimeException | PlatformError e1) {
BEANS.get(ExceptionHandler.class).handle(e1);
}
if (activePage instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) activePage;
detailForm = activePage.getDetailForm();
if (activePage.isTableVisible()) {
detailTable = tablePage.getTable(false);
}
if (tablePage.isSearchActive()) {
searchForm = tablePage.getSearchFormInternal();
}
} else if (activePage instanceof IPageWithNodes) {
IPageWithNodes nodePage = (IPageWithNodes) activePage;
if (activePage.isDetailFormVisible()) {
detailForm = activePage.getDetailForm();
}
if (activePage.isTableVisible()) {
detailTable = nodePage.getTable(false);
}
}
}
// remove first
if (detailForm == null) {
outline.setDetailForm(null);
}
if (detailTable == null) {
outline.setDetailTable(null);
}
if (searchForm == null) {
outline.setSearchForm(null);
}
// add new
if (detailForm != null) {
outline.setDetailForm(detailForm);
}
if (detailTable != null) {
outline.setDetailTable(detailTable);
}
if (searchForm != null) {
outline.setSearchForm(searchForm);
}
}
use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.
the class JsonWizardProgressField method initJsonProperties.
@Override
protected void initJsonProperties(WIZARD_PROGRESS_FIELD model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<WIZARD_PROGRESS_FIELD>(IWizardProgressField.PROP_STEPS, model) {
@Override
protected List<IWizardStep<? extends IForm>> modelValue() {
return getModel().getSteps();
}
@Override
public Object prepareValueForToJson(Object value) {
@SuppressWarnings("unchecked") List<IWizardStep<? extends IForm>> wizardSteps = (List<IWizardStep<? extends IForm>>) value;
JSONArray jsonSteps = new JSONArray();
if (wizardSteps != null) {
for (IWizardStep<? extends IForm> wizardStep : wizardSteps) {
if (wizardStep.isVisible()) {
jsonSteps.put(wizardStepToJson(wizardStep));
}
}
}
return jsonSteps;
}
});
putJsonProperty(new JsonProperty<WIZARD_PROGRESS_FIELD>(IWizardProgressField.PROP_ACTIVE_STEP, model) {
@Override
protected IWizardStep<? extends IForm> modelValue() {
return getModel().getActiveStep();
}
@Override
public Object prepareValueForToJson(Object value) {
@SuppressWarnings("unchecked") IWizardStep<? extends IForm> activeWizardStep = (IWizardStep<? extends IForm>) value;
return getStepIndex(activeWizardStep);
}
@Override
public String jsonPropertyName() {
return PROP_ACTIVE_STEP_INDEX;
}
});
}
use of org.eclipse.scout.rt.client.ui.form.IForm 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.client.ui.form.IForm in project scout.rt by eclipse.
the class FindFieldByFormDataIdVisitor method visitField.
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (m_searchContextRootForm == null) {
// auto-initialize search context
// we assume the form field tree is traversed pre-order (i.e. first node itself, then its children)
m_searchContextRootForm = field.getForm();
}
if (matchesAllParts(field)) {
int fieldTypeRank = 0;
if (m_searchContextRootForm != null) {
IForm form = field.getForm();
while (form != null && form != m_searchContextRootForm) {
fieldTypeRank += 10;
form = form.getOuterForm();
}
}
if (field instanceof IValueField) {
// fieldTypeRank is fine
} else if (field instanceof ITableField) {
fieldTypeRank += 1;
} else if (!(field instanceof ICompositeField)) {
fieldTypeRank += 2;
} else {
fieldTypeRank += 3;
}
// Compute the enclosing field path rank that is used as additional hint for determining the
// best matching form field for the requested formId. Note: for compatibility reasons, the enclosing
// field path is not enforced.
int enclosingFieldPathRank = getEnclosingFieldPathRank(field);
m_prioMap.put(new CompositeObject(fieldTypeRank, enclosingFieldPathRank), field);
}
return !m_prioMap.containsKey(PERFECT_VALUE_FIELD_MATCH_KEY);
}
Aggregations