Search in sources :

Example 1 with ILookupRow

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

the class BatchLookupServiceClientProxy method getBatchDataByText.

@Override
public List<List<ILookupRow<?>>> getBatchDataByText(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByText(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByText(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
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) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 2 with ILookupRow

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

the class BatchLookupServiceClientProxy method getBatchDataByRec.

@Override
public List<List<ILookupRow<?>>> getBatchDataByRec(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByRec(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByRec(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
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) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 3 with ILookupRow

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

the class BatchLookupServiceClientProxy method getBatchDataByAll.

@Override
public List<List<ILookupRow<?>>> getBatchDataByAll(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByAll(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByAll(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
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) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 4 with ILookupRow

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

the class KeyStrokeLookupCall method execCreateLookupRows.

@Override
protected List<ILookupRow<String>> execCreateLookupRows() {
    final HashMap<String, Integer> keyStrokesUpper = new HashMap<String, Integer>();
    // build possible keyStrokes
    for (int i = 1; i <= 12; i++) {
        keyStrokesUpper.put("SHIFT-F" + i, Integer.valueOf(i));
    }
    // remove used keyStrokes
    IBookmarkService service = BEANS.get(IBookmarkService.class);
    IBookmarkVisitor v = new IBookmarkVisitor() {

        @Override
        public boolean visitFolder(List<BookmarkFolder> path) {
            return true;
        }

        @Override
        public boolean visitBookmark(List<BookmarkFolder> path, Bookmark b) {
            String keyStroke = b.getKeyStroke();
            if (keyStroke != null) {
                if (m_currentKeyStroke != null && m_currentKeyStroke.equalsIgnoreCase(keyStroke)) {
                // keep it
                } else {
                    keyStrokesUpper.remove(keyStroke.toUpperCase(Locale.ENGLISH));
                }
            }
            return true;
        }
    };
    service.getBookmarkData().getGlobalBookmarks().visit(v);
    service.getBookmarkData().getUserBookmarks().visit(v);
    // 
    TreeSet<Integer> availableNumbers = new TreeSet<Integer>(keyStrokesUpper.values());
    ArrayList<ILookupRow<String>> resultList = new ArrayList<ILookupRow<String>>();
    for (Integer i : availableNumbers) {
        String key = "Shift-F" + i;
        String text = "Shift-F" + i;
        ILookupRow<String> row = new LookupRow<String>(key, text);
        resultList.add(row);
    }
    return resultList;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) IBookmarkVisitor(org.eclipse.scout.rt.shared.services.common.bookmark.IBookmarkVisitor) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) List(java.util.List) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)

Example 5 with ILookupRow

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

the class AbstractContentAssistColumn method updateDisplayTexts.

@Override
public void updateDisplayTexts(List<ITableRow> rows) {
    try {
        if (rows.size() > 0) {
            BatchLookupCall batchCall = new BatchLookupCall();
            ArrayList<ITableRow> batchRowList = new ArrayList<ITableRow>();
            BatchLookupResultCache lookupResultCache = new BatchLookupResultCache();
            for (ITableRow row : rows) {
                ILookupCall<?> call = prepareLookupCall(row);
                if (call != null && call.getKey() != null) {
                    // split: local vs remote
                    if (call instanceof LocalLookupCall) {
                        applyLookupResult(row, lookupResultCache.getDataByKey(call));
                    } else {
                        batchRowList.add(row);
                        batchCall.addLookupCall(call);
                    }
                } else {
                    applyLookupResult(row, new ArrayList<ILookupRow<?>>(0));
                }
            }
            // 
            if (!batchCall.isEmpty()) {
                ITableRow[] tableRows = batchRowList.toArray(new ITableRow[batchRowList.size()]);
                IBatchLookupService service = BEANS.get(IBatchLookupService.class);
                List<List<ILookupRow<?>>> resultArray = service.getBatchDataByKey(batchCall);
                for (int i = 0; i < tableRows.length; i++) {
                    applyLookupResult(tableRows[i], resultArray.get(i));
                }
            }
        }
    } catch (RuntimeException e) {
        BEANS.get(ExceptionHandler.class).handle(e);
    }
}
Also used : IBatchLookupService(org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall) LocalLookupCall(org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall) ArrayList(java.util.ArrayList) List(java.util.List)

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