Search in sources :

Example 6 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class BatchLookupService method getBatchDataByText.

@Override
public List<List<ILookupRow<?>>> getBatchDataByText(BatchLookupCall batch) {
    List<ILookupCall<?>> calls = batch.getCallBatch();
    List<List<ILookupRow<?>>> result = new ArrayList<List<ILookupRow<?>>>();
    BatchLookupResultCache cache = new BatchLookupResultCache();
    for (ILookupCall<?> call : calls) {
        result.add(new ArrayList<ILookupRow<?>>(cache.getDataByText(call)));
    }
    return result;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Example 7 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class BatchLookupService method getBatchDataByAll.

@Override
public List<List<ILookupRow<?>>> getBatchDataByAll(BatchLookupCall batch) {
    List<ILookupCall<?>> calls = batch.getCallBatch();
    List<List<ILookupRow<?>>> result = new ArrayList<List<ILookupRow<?>>>();
    BatchLookupResultCache cache = new BatchLookupResultCache();
    for (ILookupCall<?> call : calls) {
        result.add(new ArrayList<ILookupRow<?>>(cache.getDataByAll(call)));
    }
    return result;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Example 8 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class AbstractSmartField2 method newByRecLookupRowProvider.

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

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

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

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

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

        @Override
        public IFuture<Void> provideAsync(ILookupCall<VALUE> lookupCall, ILookupRowFetchedCallback<VALUE> 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) ILookupRowProvider(org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ToStringBuilder(org.eclipse.scout.rt.platform.util.ToStringBuilder) List(java.util.List) ArrayList(java.util.ArrayList) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Example 9 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubteeLookup_WithPrepare.

@Test
public void testSubteeLookup_WithPrepare() {
    ISmartField<Long> field = new AbstractSmartField<Long>() {

        @Override
        protected void execPrepareLookup(ILookupCall<Long> call) {
            call.setMaster(testMasterValue);
        }
    };
    field.setLookupCall(new TestLookupCall());
    List<? extends ILookupRow<Long>> rows2 = field.callSubTreeLookup(1L);
    assertEquals(2, rows2.size());
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Test(org.junit.Test)

Example 10 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubteeLookup_WithPrepareRec.

@Test
public void testSubteeLookup_WithPrepareRec() {
    ISmartField<Long> field = new AbstractSmartField<Long>() {

        @Override
        protected void execPrepareRecLookup(ILookupCall<Long> call, Long parentKey) {
            call.setMaster(testMasterValue);
        }
    };
    field.setLookupCall(new TestLookupCall());
    List<? extends ILookupRow<Long>> rows2 = field.callSubTreeLookup(1L);
    assertEquals(2, rows2.size());
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Test(org.junit.Test)

Aggregations

ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)25 ArrayList (java.util.ArrayList)19 List (java.util.List)19 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)18 ClientRunContext (org.eclipse.scout.rt.client.context.ClientRunContext)8 ToStringBuilder (org.eclipse.scout.rt.platform.util.ToStringBuilder)8 BatchLookupResultCache (org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache)8 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)8 BatchLookupCall (org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)6 Test (org.junit.Test)5 ILookupRowProvider (org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 TestLookupCall (org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall)3 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 BatchLookupNormalizer (org.eclipse.scout.rt.shared.services.lookup.BatchLookupNormalizer)2 IBatchLookupService (org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService)2 Before (org.junit.Before)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 IMixedSmartField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField)1