Search in sources :

Example 6 with ILookupRow

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

the class AbstractSmartColumn2 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)

Example 7 with ILookupRow

use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow 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 8 with ILookupRow

use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow 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)

Example 9 with ILookupRow

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

the class AbstractListBox method getCheckedLookupRows.

@SuppressWarnings("unchecked")
@Override
public Set<ILookupRow<KEY>> getCheckedLookupRows() {
    Collection<ITableRow> checkedRows = getTable().getCheckedRows();
    Set<ILookupRow<KEY>> result = new HashSet<ILookupRow<KEY>>(checkedRows.size());
    for (ITableRow row : checkedRows) {
        ICell cell = row.getCell(1);
        result.add(new LookupRow<KEY>((KEY) row.getCellValue(0), cell.getText()).withIconId(cell.getIconId()).withTooltipText(cell.getTooltipText()).withBackgroundColor(cell.getBackgroundColor()).withForegroundColor(cell.getForegroundColor()).withFont(cell.getFont()).withEnabled(row.isEnabled()));
    }
    return result;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) HashSet(java.util.HashSet) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell)

Example 10 with ILookupRow

use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow 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)

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