Search in sources :

Example 26 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class DeepLinkUriBuilder method createBrowserHistoryEntry.

public BrowserHistoryEntry createBrowserHistoryEntry() {
    if (m_path == null) {
        throw new IllegalStateException("Cannot create BrowserHistoryEntry without deep-link path");
    }
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    StringBuilder title = new StringBuilder(desktop.getTitle());
    if (StringUtility.hasText(m_info)) {
        title.append(" - ").append(m_info);
    }
    return new BrowserHistoryEntry(m_builder.createURI(), title.toString(), m_path);
}
Also used : BrowserHistoryEntry(org.eclipse.scout.rt.client.ui.desktop.BrowserHistoryEntry) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 27 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class OutlineDeepLinkHandler method handleImpl.

@Override
public void handleImpl(Matcher matcher) throws DeepLinkException {
    String outlineId = matcher.group(1);
    IOutline selectedOutline = null;
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    for (IOutline outline : desktop.getAvailableOutlines()) {
        String tmpOutlineId = outlineId(outline);
        if (tmpOutlineId.equals(outlineId)) {
            selectedOutline = outline;
            break;
        }
    }
    if (selectedOutline == null) {
        throw new DeepLinkException("No outline with ID " + outlineId + " found");
    }
    if (!selectedOutline.isVisible() || !selectedOutline.isEnabled()) {
        throw new DeepLinkException("Outline ID " + outlineId + " is not enabled or visible");
    }
    desktop.activateOutline(selectedOutline);
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 28 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class AbstractForm method startInternal.

/**
 * This method is called from the implemented handler methods in a explicit form subclass
 */
protected IForm startInternal(final IFormHandler handler) {
    ClientRunContexts.copyCurrent().withForm(this).run(new IRunnable() {

        @Override
        public void run() throws Exception {
            if (isBlockingInternal()) {
                throw new IllegalStateException("The form " + getFormId() + " has already been started");
            }
            // Ensure that boolean is set not only once by the constructor
            setFormLoading(true);
            setHandler(handler);
            m_closeType = IButton.SYSTEM_TYPE_NONE;
            m_blockingCondition.setBlocking(true);
            try {
                initForm();
                loadStateInternal();
                // if form was disposed during initForm() or loadStateInternal()
                if (!isBlockingInternal()) {
                    return;
                }
                if (getHandler().isGuiLess()) {
                    // make sure the form is storing since it is not showing
                    storeStateInternal();
                    markSaved();
                    doFinally();
                    disposeFormInternal();
                    return;
                }
            } catch (RuntimeException | PlatformError e) {
                disposeFormInternal();
                PlatformException pe = BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", AbstractForm.this.getClass().getName());
                if (pe instanceof VetoException) {
                    VetoException ve = (VetoException) pe;
                    interceptOnVetoException(ve, ve.getStatus().getCode());
                }
                throw pe;
            }
            setButtonsArmed(true);
            setCloseTimerArmed(true);
            setFormStarted(true);
            // Notify the UI to display this form.
            if (isShowOnStart()) {
                IDesktop desktop = getDesktop();
                if (desktop == null || !desktop.isOpened()) {
                    throw new ProcessingException("There is no desktop or it is not open in the UI.");
                } else {
                    desktop.showForm(AbstractForm.this);
                }
            }
        }
    });
    return this;
}
Also used : VetoException(org.eclipse.scout.rt.platform.exception.VetoException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 29 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class AbstractPage method disposeInternal.

@Override
public void disposeInternal() {
    super.disposeInternal();
    try {
        interceptDisposePage();
        disposeDetailForm();
        disposeTable();
        fireAfterPageDispose();
    } catch (RuntimeException | PlatformError e) {
        BEANS.get(ExceptionHandler.class).handle(e);
    }
    // automatically remove all data change listeners
    ITree tree = getTree();
    if (tree != null) {
        tree.removeTreeListener(m_treeListener);
    }
    if (m_internalDataChangeListener != null) {
        IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
        if (desktop != null) {
            desktop.removeDataChangeListener(m_internalDataChangeListener);
        }
    }
}
Also used : PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 30 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class AbstractPageWithTable method loadChildrenImpl.

/**
 * load tree children<br>
 * this method delegates to the table reload<br>
 * when the table is loaded and this node is not a leaf node then the table rows are mirrored in child nodes
 */
@Override
protected final void loadChildrenImpl() {
    ITree tree = getTree();
    try {
        if (tree != null) {
            tree.setTreeChanging(true);
        }
        // 
        // backup currently selected tree node and its path to root
        boolean oldSelectionOwned = false;
        int oldSelectionDirectChildIndex = -1;
        ITreeNode oldSelectedNode = null;
        if (tree != null) {
            oldSelectedNode = tree.getSelectedNode();
        }
        List<Object> oldSelectedRowKeys = null;
        if (oldSelectedNode != null) {
            ITreeNode t = oldSelectedNode;
            while (t != null && t.getParentNode() != null) {
                if (t.getParentNode() == this) {
                    oldSelectionOwned = true;
                    oldSelectedRowKeys = getTableRowFor(t).getKeyValues();
                    oldSelectionDirectChildIndex = t.getChildNodeIndex();
                    break;
                }
                t = t.getParentNode();
            }
        }
        // 
        setChildrenLoaded(false);
        fireBeforeDataLoaded();
        try {
            loadTableDataImpl();
        } catch (ThreadInterruptedError | FutureCancelledError e) {
        // NOSONAR
        // NOOP
        } finally {
            fireAfterDataLoaded();
        }
        setChildrenLoaded(true);
        setChildrenDirty(false);
        // table events will handle automatic tree changes in case table is mirrored in tree.
        // restore currently selected tree node when it was owned by our table rows.
        // in case selection was lost, try to select similar index as before
        T table = getTable();
        if (tree != null && table != null && oldSelectionOwned && tree.getSelectedNode() == null) {
            ITreeNode newSelectedNode = null;
            ITableRow row = table.getSelectedRow();
            if (row != null) {
                newSelectedNode = getTreeNodeFor(row);
            } else {
                row = table.findRowByKey(oldSelectedRowKeys);
                if (row != null) {
                    newSelectedNode = getTreeNodeFor(row);
                } else if (oldSelectedNode != null && oldSelectedNode.getTree() == tree) {
                    // NOSONAR
                    newSelectedNode = oldSelectedNode;
                } else {
                    int index = Math.max(-1, Math.min(oldSelectionDirectChildIndex, getChildNodeCount() - 1));
                    if (index >= 0 && index < getChildNodeCount()) {
                        newSelectedNode = getChildNode(index);
                    } else {
                        newSelectedNode = this;
                    }
                }
            }
            if (newSelectedNode != null) {
                tree.selectNode(newSelectedNode);
            }
        }
    } finally {
        if (tree != null) {
            tree.setTreeChanging(false);
        }
    }
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    if (desktop != null) {
        desktop.afterTablePageLoaded(this);
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) FutureCancelledError(org.eclipse.scout.rt.platform.util.concurrent.FutureCancelledError) ThreadInterruptedError(org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Aggregations

IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)61 Test (org.junit.Test)36 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)18 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)7 JsonAdapterRegistryTest (org.eclipse.scout.rt.ui.html.json.JsonAdapterRegistryTest)7 IOutlineViewButton (org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton)5 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)5 JsonForm (org.eclipse.scout.rt.ui.html.json.form.JsonForm)5 JSONObject (org.json.JSONObject)5 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)4 IClientSession (org.eclipse.scout.rt.client.IClientSession)3 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)3 IForm (org.eclipse.scout.rt.client.ui.form.IForm)3 DesktopWithOneOutline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithOneOutline)3 OutlineViewButton (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton)3 OutlineWithOneNode (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode)3 FormWithOneField (org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 Locale (java.util.Locale)2