Search in sources :

Example 1 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method closeInternal.

@Override
public void closeInternal() {
    setOpenedInternal(false);
    detachGui();
    List<IForm> showedForms = new ArrayList<IForm>();
    // Remove showed forms
    for (IForm form : m_formStore.values()) {
        hideForm(form);
        showedForms.add(form);
    }
    // extensions
    for (IDesktopExtension ext : getDesktopExtensions()) {
        try {
            ContributionCommand cc = ext.desktopClosingDelegate();
            if (cc == ContributionCommand.Stop) {
                break;
            }
        } catch (RuntimeException | PlatformError t) {
            LOG.error("extension {}", ext, t);
        }
    }
    // close messageboxes
    for (IMessageBox m : getMessageBoxes()) {
        if (m != null) {
            try {
                m.getUIFacade().setResultFromUI(IMessageBox.CANCEL_OPTION);
            } catch (RuntimeException | PlatformError e) {
                LOG.error("Exception while closing messagebox", e);
            }
        }
    }
    // close filechoosers
    for (IFileChooser f : getFileChoosers()) {
        if (f != null) {
            try {
                f.getUIFacade().setResultFromUI(Collections.<BinaryResource>emptyList());
            } catch (RuntimeException | PlatformError e) {
                LOG.error("Exception while closing filechooser", e);
            }
        }
    }
    // close client callbacks
    for (ClientCallback<?> c : CollectionUtility.arrayList(m_pendingPositionResponses)) {
        if (c != null) {
            try {
                c.cancel(true);
                c.failed(new ThreadInterruptedError("desktop is closing"));
            } catch (RuntimeException | PlatformError e) {
                LOG.error("Exception while closing client callback", e);
            }
        }
    }
    // close open forms
    for (IForm form : showedForms) {
        if (form != null) {
            try {
                form.doClose();
            } catch (RuntimeException | PlatformError e) {
                LOG.error("Exception while closing form", e);
            }
        }
    }
    // dispose outlines
    for (IOutline outline : getAvailableOutlines()) {
        try {
            outline.disposeTree();
        } catch (RuntimeException | PlatformError e) {
            LOG.warn("Exception while disposing outline.", e);
        }
    }
    ActionUtility.disposeActions(getActions());
    fireDesktopClosed();
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) ThreadInterruptedError(org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError) IForm(org.eclipse.scout.rt.client.ui.form.IForm) IMessageBox(org.eclipse.scout.rt.client.ui.messagebox.IMessageBox) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IFileChooser(org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser)

Example 2 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method setPageDetailForm.

@Override
public void setPageDetailForm(IForm f) {
    if (m_pageDetailForm != f) {
        IForm oldForm = m_pageDetailForm;
        m_pageDetailForm = f;
        // extensions
        for (IDesktopExtension ext : getDesktopExtensions()) {
            try {
                ContributionCommand cc = ext.pageDetailFormChangedDelegate(oldForm, m_pageDetailForm);
                if (cc == ContributionCommand.Stop) {
                    break;
                }
            } catch (Exception e) {
                LOG.error("extension {}", ext, e);
            }
        }
    }
}
Also used : IForm(org.eclipse.scout.rt.client.ui.form.IForm) DeepLinkException(org.eclipse.scout.rt.client.deeplink.DeepLinkException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException)

Example 3 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method getUnsavedForms.

@Override
public List<IForm> getUnsavedForms() {
    List<IForm> saveNeededForms = new ArrayList<IForm>();
    List<IForm> showedForms = m_formStore.values();
    // last element on the stack is the first that needs to be saved: iterate from end to start
    for (int i = showedForms.size() - 1; i >= 0; i--) {
        IForm f = showedForms.get(i);
        if (f.isAskIfNeedSave() && f.isSaveNeeded()) {
            saveNeededForms.add(f);
        }
    }
    return saveNeededForms;
}
Also used : ArrayList(java.util.ArrayList) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Example 4 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm 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 5 with IForm

use of org.eclipse.scout.rt.client.ui.form.IForm in project scout.rt by eclipse.

the class AbstractDesktop method getSimilarViewForms.

@Override
public List<IForm> getSimilarViewForms(final IForm form) {
    if (form == null) {
        return CollectionUtility.emptyArrayList();
    }
    final Object formKey;
    try {
        formKey = form.computeExclusiveKey();
    } catch (final RuntimeException | PlatformError e) {
        BEANS.get(ExceptionHandler.class).handle(e);
        return CollectionUtility.emptyArrayList();
    }
    if (formKey == null) {
        return CollectionUtility.emptyArrayList();
    }
    final IForm currentDetailForm = getPageDetailForm();
    final IForm currentSearchForm = getPageSearchForm();
    final List<IForm> similarForms = new ArrayList<>();
    for (final IForm candidateView : m_formStore.getViewsByKey(formKey)) {
        if (candidateView == currentDetailForm) {
            continue;
        }
        if (candidateView == currentSearchForm) {
            continue;
        }
        if (candidateView.getClass().equals(form.getClass())) {
            similarForms.add(candidateView);
        }
    }
    return similarForms;
}
Also used : PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) ArrayList(java.util.ArrayList) IExtensibleObject(org.eclipse.scout.rt.shared.extension.IExtensibleObject) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Aggregations

IForm (org.eclipse.scout.rt.client.ui.form.IForm)38 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)5 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)4 IDisplayParent (org.eclipse.scout.rt.client.ui.IDisplayParent)3 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)3 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)3 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)3 JSONObject (org.json.JSONObject)3 List (java.util.List)2 ModelContext (org.eclipse.scout.rt.client.ModelContextProxy.ModelContext)2 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)2 IFileChooser (org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser)2 ISearchForm (org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm)2 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)2 ITabBox (org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)2 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)2 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1