Search in sources :

Example 26 with ILookupRow

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

the class BatchNormalizerTest method setUp.

@Before
public void setUp() throws Exception {
    Answer answer = new Answer<List<ILookupRow<Object>>>() {

        @Override
        public List<ILookupRow<Object>> answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            ILookupCall<?> call = (ILookupCall<?>) args[0];
            return createCallResult(call);
        }
    };
    Mockito.doAnswer(answer).when(m_lookupService).getDataByKey(Mockito.<ILookupCall<Object>>any());
    Mockito.doAnswer(answer).when(m_lookupService).getDataByAll(Mockito.<ILookupCall<Object>>any());
    Mockito.doAnswer(answer).when(m_lookupService).getDataByText(Mockito.<ILookupCall<Object>>any());
    Mockito.doAnswer(answer).when(m_lookupService).getDataByRec(Mockito.<ILookupCall<Object>>any());
}
Also used : Answer(org.mockito.stubbing.Answer) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Before(org.junit.Before)

Example 27 with ILookupRow

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

the class IncrementalTreeBuilderTest method testCreateParentMap_EmptyTree.

@Test
public void testCreateParentMap_EmptyTree() {
    ITree tree = createTestTree();
    Map<Long, ILookupRow<Long>> parentMap = new IncrementalTreeBuilder<Long>(null).createParentMap(tree);
    assertTrue(parentMap.isEmpty());
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 28 with ILookupRow

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

the class IncrementalTreeBuilderTest method testCreatePaths_Empty.

@Test
public void testCreatePaths_Empty() {
    ITree tree = createTestTree();
    IncrementalTreeBuilder<Long> builder = new IncrementalTreeBuilder<Long>(null);
    ArrayList<ILookupRow<Long>> rows = new ArrayList<>();
    List<List<ILookupRow<Long>>> paths = builder.createPaths(rows, tree);
    assertTrue(paths.isEmpty());
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 29 with ILookupRow

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

the class JsonTableTest method testTableEventCoalesceInUi_ReplaceRows.

@Test
public void testTableEventCoalesceInUi_ReplaceRows() throws Exception {
    ListBoxTable listbox = new ListBoxTable();
    ILookupRow<Long> row1 = new LookupRow<Long>(1L, "Row1");
    ILookupRow<Long> row2 = new LookupRow<Long>(2L, "Row2").withActive(false);
    ILookupRow<Long> row3 = new LookupRow<Long>(3L, "Row3");
    ILookupRow<Long> row4 = new LookupRow<Long>(4L, "Row4");
    ArrayList<ITableRow> rowsInitial = new ArrayList<ITableRow>();
    rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row1));
    rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row2));
    rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row3));
    ITable table = listbox.getTable();
    table.addRows(rowsInitial);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    m_uiSession.currentJsonResponse().addAdapter(jsonTable);
    JSONObject response = m_uiSession.currentJsonResponse().toJson();
    JsonTestUtility.endRequest(m_uiSession);
    JSONArray events = response.optJSONArray("events");
    ArrayList<ITableRow> rowsUpdate = new ArrayList<ITableRow>();
    rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row1));
    rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row2));
    rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row3));
    rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row4));
    table.replaceRows(rowsUpdate);
    response = m_uiSession.currentJsonResponse().toJson();
    JsonTestUtility.endRequest(m_uiSession);
    events = response.optJSONArray("events");
    JSONObject lastEvent = events.optJSONObject(events.length() - 1);
    assertEquals(lastEvent.optString("type"), "rowOrderChanged");
    JSONArray rowIds = lastEvent.optJSONArray("rowIds");
    assertTrue(rowIds.length() == 3);
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) ListBoxTable(org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable) Test(org.junit.Test)

Example 30 with ILookupRow

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

the class AbstractContentAssistField method newByKeyLookupRowProvider.

// ==== Lookup row fetching strategies ==== //
/**
 * Creates a {@link ILookupRowProvider} to fetch a row by key.
 *
 * @see LookupCall#getDataByKey()
 * @see LookupCall#getDataByAllInBackground(ILookupRowFetchedCallback)
 */
protected ILookupRowProvider<LOOKUP_KEY> newByKeyLookupRowProvider(final LOOKUP_KEY key) {
    return new ILookupRowProvider<LOOKUP_KEY>() {

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

        @Override
        public void afterProvide(ILookupCall<LOOKUP_KEY> lookupCall, List<ILookupRow<LOOKUP_KEY>> result) {
            interceptFilterLookupResult(lookupCall, result);
            interceptFilterKeyLookupResult(lookupCall, 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.getDataByKeyInBackground(clientRunContext, callback);
        }

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

        @Override
        public String toString() {
            ToStringBuilder sb = new ToStringBuilder(this).attr("Key Lookup").attr("key", key);
            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

ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)36 ArrayList (java.util.ArrayList)29 List (java.util.List)24 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)19 BatchLookupResultCache (org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache)10 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)10 ClientRunContext (org.eclipse.scout.rt.client.context.ClientRunContext)9 ToStringBuilder (org.eclipse.scout.rt.platform.util.ToStringBuilder)8 Test (org.junit.Test)7 BatchLookupCall (org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)6 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)5 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 ILookupRowProvider (org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 LookupRow (org.eclipse.scout.rt.shared.services.lookup.LookupRow)4 HashMap (java.util.HashMap)3 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)3 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)3 Pattern (java.util.regex.Pattern)2 IBatchLookupService (org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService)2