Search in sources :

Example 1 with LocalLookupCall

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

Example 2 with LocalLookupCall

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

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

the class AbstractContentAssistField method prepareTextLookup.

@Override
public void prepareTextLookup(ILookupCall<LOOKUP_KEY> call, String text) {
    String textPattern = text;
    if (textPattern == null) {
        textPattern = "";
    }
    textPattern = textPattern.toLowerCase();
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    if (desktop != null && desktop.isAutoPrefixWildcardForTextSearch()) {
        textPattern = getWildcard() + textPattern;
    }
    if (!textPattern.endsWith(getWildcard())) {
        textPattern = textPattern + getWildcard();
    }
    // localLookupCalls should return hierarchical matches as well (children of exact matches), if field is configured accordingly
    if (call instanceof LocalLookupCall) {
        ((LocalLookupCall) call).setHierarchicalLookup(isBrowseHierarchy());
    }
    call.setKey(null);
    call.setText(textPattern);
    call.setAll(null);
    call.setRec(null);
    call.setActive(isActiveFilterEnabled() ? getActiveFilter() : TriState.TRUE);
    // when there is a master value defined in the original call, don't set it to null when no master value is available
    if (getMasterValue() != null || getLookupCall() == null || getLookupCall().getMaster() == null) {
        call.setMaster(getMasterValue());
    }
    interceptPrepareLookup(call);
    interceptPrepareTextLookup(call, text);
}
Also used : IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) LocalLookupCall(org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall)

Example 4 with LocalLookupCall

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

the class AbstractSmartField2 method prepareTextLookup.

@Override
public void prepareTextLookup(ILookupCall<VALUE> call, String text) {
    String textPattern = text;
    if (textPattern == null) {
        textPattern = "";
    }
    textPattern = textPattern.toLowerCase();
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    if (desktop != null && desktop.isAutoPrefixWildcardForTextSearch()) {
        textPattern = getWildcard() + textPattern;
    }
    if (!textPattern.endsWith(getWildcard())) {
        textPattern = textPattern + getWildcard();
    }
    // localLookupCalls should return hierarchical matches as well (children of exact matches), if field is configured accordingly
    if (call instanceof LocalLookupCall) {
        ((LocalLookupCall) call).setHierarchicalLookup(isBrowseHierarchy());
    }
    call.setKey(null);
    call.setText(textPattern);
    call.setAll(null);
    call.setRec(null);
    call.setActive(isActiveFilterEnabled() ? getActiveFilter() : TriState.TRUE);
    // when there is a master value defined in the original call, don't set it to null when no master value is available
    if (getMasterValue() != null || getLookupCall() == null || getLookupCall().getMaster() == null) {
        call.setMaster(getMasterValue());
    }
    interceptPrepareLookup(call);
    interceptPrepareTextLookup(call, text);
}
Also used : IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) LocalLookupCall(org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall)

Aggregations

LocalLookupCall (org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)2 BatchLookupCall (org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)2 BatchLookupResultCache (org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache)2 IBatchLookupService (org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService)2 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)2