Search in sources :

Example 1 with ClientRunContext

use of org.eclipse.scout.rt.client.context.ClientRunContext in project scout.rt by eclipse.

the class AbstractDesktop method setOutlineInternal.

protected void setOutlineInternal(IOutline newOutline) {
    final IOutline oldOutline = m_outline;
    if (oldOutline != null) {
        if (m_activeOutlineListener != null) {
            oldOutline.removePropertyChangeListener(m_activeOutlineListener);
            m_activeOutlineListener = null;
        }
        m_outline.deactivate();
    }
    // set new outline to set facts
    m_outline = newOutline;
    // deactivate old page
    if (oldOutline != null) {
        oldOutline.clearContextPage();
    }
    final ClientRunContext ctx;
    if (m_outline == null) {
        ctx = ClientRunContexts.copyCurrent().withOutline(null, true);
    } else {
        ctx = m_outline.createDisplayParentRunContext();
    }
    ctx.run(new IRunnable() {

        @Override
        public void run() throws Exception {
            if (m_outline != null) {
                m_activeOutlineListener = new P_ActiveOutlineListener();
                m_outline.addPropertyChangeListener(m_activeOutlineListener);
                setBrowserHistoryEntry(BEANS.get(OutlineDeepLinkHandler.class).createBrowserHistoryEntry(m_outline));
            }
            // This change is needed for the "on/off semantics" of the tool tab buttons to work correctly.
            if (m_outline == null) {
                setPageDetailForm(null);
                setPageDetailTable(null);
                setPageSearchForm(null, true);
            }
            // </bsh>
            updateActiveFormOnOutlineChanged();
            fireOutlineChanged(oldOutline, m_outline);
            onOutlineChangedInternal();
            fireOutlineContentActivate();
        }
    });
}
Also used : OutlineDeepLinkHandler(org.eclipse.scout.rt.client.deeplink.OutlineDeepLinkHandler) ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) 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 2 with ClientRunContext

use of org.eclipse.scout.rt.client.context.ClientRunContext in project scout.rt by eclipse.

the class ModelJobTest method testThreadName.

@Test
public void testThreadName() throws InterruptedException {
    ClientRunContext clientRunContext = ClientRunContexts.empty().withSession(m_clientSession1, true);
    assertEquals("scout-model-thread", ModelJobs.newInput(clientRunContext).getThreadName());
}
Also used : ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) Test(org.junit.Test)

Example 3 with ClientRunContext

use of org.eclipse.scout.rt.client.context.ClientRunContext in project scout.rt by eclipse.

the class ModelJobsTest method testNewInput.

@Test
public void testNewInput() {
    ClientRunContext runContext = ClientRunContexts.empty().withSession(m_clientSession, true);
    assertSame(runContext, ModelJobs.newInput(runContext).getRunContext());
    assertEquals("scout-model-thread", ModelJobs.newInput(runContext).getThreadName());
    assertSame(m_clientSession.getModelJobSemaphore(), ModelJobs.newInput(runContext).getExecutionSemaphore());
}
Also used : ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) Test(org.junit.Test)

Example 4 with ClientRunContext

use of org.eclipse.scout.rt.client.context.ClientRunContext in project scout.rt by eclipse.

the class AbstractContentAssistField method newByRecLookupRowProvider.

/**
 * @see LookupCall#getDataByRec()
 */
protected ILookupRowProvider<LOOKUP_KEY> newByRecLookupRowProvider(final LOOKUP_KEY parentKey, final TriState activeState) {
    return new ILookupRowProvider<LOOKUP_KEY>() {

        @SuppressWarnings("unchecked")
        @Override
        public List<ILookupRow<LOOKUP_KEY>> provide(ILookupCall<LOOKUP_KEY> lookupCall) {
            return (List<ILookupRow<LOOKUP_KEY>>) lookupCall.getDataByRec();
        }

        @Override
        public void beforeProvide(ILookupCall<LOOKUP_KEY> lookupCall) {
            prepareRecLookup(lookupCall, parentKey, activeState);
        }

        @Override
        public void afterProvide(ILookupCall<LOOKUP_KEY> lookupCall, List<ILookupRow<LOOKUP_KEY>> result) {
            interceptFilterLookupResult(lookupCall, result);
            interceptFilterRecLookupResult(lookupCall, result);
            cleanupResultList(result);
        }

        @Override
        public void provideSync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback) {
            throw new UnsupportedOperationException("Legacy calls not supported");
        }

        @Override
        public IFuture<Void> provideAsync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback, ClientRunContext clientRunContext) {
            throw new UnsupportedOperationException("Legacy calls not supported");
        }

        @Override
        public String toString() {
            ToStringBuilder sb = new ToStringBuilder(this).attr("Rec Lookup").attr("parentKey", parentKey).attr("activeState", activeState);
            return sb.toString();
        }
    };
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ToStringBuilder(org.eclipse.scout.rt.platform.util.ToStringBuilder) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Example 5 with ClientRunContext

use of org.eclipse.scout.rt.client.context.ClientRunContext in project scout.rt by eclipse.

the class AbstractContentAssistField method newByTextLookupRowProvider.

/**
 * Creates a {@link ILookupRowProvider} to fetch rows matching the given text.
 *
 * @see LookupCall#getDataByText()
 * @see LookupCall#getDataByTextInBackground(ILookupRowFetchedCallback)
 */
protected ILookupRowProvider<LOOKUP_KEY> newByTextLookupRowProvider(final String text) {
    return new ILookupRowProvider<LOOKUP_KEY>() {

        @Override
        public void beforeProvide(ILookupCall<LOOKUP_KEY> lookupCall) {
            prepareTextLookup(lookupCall, text);
        }

        @Override
        public void afterProvide(ILookupCall<LOOKUP_KEY> call, List<ILookupRow<LOOKUP_KEY>> result) {
            interceptFilterLookupResult(call, result);
            interceptFilterTextLookupResult(call, result);
            cleanupResultList(result);
        }

        @Override
        public void provideSync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback) {
            callback.onSuccess(provide(lookupCall));
        }

        @Override
        public IFuture<Void> provideAsync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback, ClientRunContext clientRunContext) {
            return lookupCall.getDataByTextInBackground(clientRunContext, callback);
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<ILookupRow<LOOKUP_KEY>> provide(ILookupCall<LOOKUP_KEY> lookupCall) {
            return (List<ILookupRow<LOOKUP_KEY>>) lookupCall.getDataByText();
        }

        @Override
        public String toString() {
            ToStringBuilder sb = new ToStringBuilder(this).attr("Text Lookup").attr("text", text);
            return sb.toString();
        }
    };
}
Also used : ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ToStringBuilder(org.eclipse.scout.rt.platform.util.ToStringBuilder) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Aggregations

ClientRunContext (org.eclipse.scout.rt.client.context.ClientRunContext)19 ArrayList (java.util.ArrayList)10 List (java.util.List)9 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)9 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)9 ToStringBuilder (org.eclipse.scout.rt.platform.util.ToStringBuilder)8 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)8 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)7 ILookupRowProvider (org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 FutureCancelledError (org.eclipse.scout.rt.platform.util.concurrent.FutureCancelledError)3 ThreadInterruptedError (org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError)3 Test (org.junit.Test)3 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)2 RunMonitor (org.eclipse.scout.rt.platform.context.RunMonitor)2 BlockingCountDownLatch (org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch)2 JSONObject (org.json.JSONObject)2 HashSet (java.util.HashSet)1 Callable (java.util.concurrent.Callable)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1