Search in sources :

Example 1 with IDisplayParent

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);
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 2 with IDisplayParent

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);
}
Also used : ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) MoveFormFieldsHandler(org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent)

Example 3 with IDisplayParent

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;
}
Also used : IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 4 with IDisplayParent

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;
}
Also used : IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 5 with IDisplayParent

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;
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent)

Aggregations

IDisplayParent (org.eclipse.scout.rt.client.ui.IDisplayParent)5 IForm (org.eclipse.scout.rt.client.ui.form.IForm)3 ArrayList (java.util.ArrayList)1 MoveFormFieldsHandler (org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)1 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)1 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)1 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)1 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1 JSONObject (org.json.JSONObject)1