Search in sources :

Example 6 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ColumnSet method applySortingAndGroupingInternal.

private void applySortingAndGroupingInternal(Map<IColumn, P_SortingAndGroupingConfig> columnConfigs) {
    TreeMap<CompositeObject, IColumn> sortMap = new TreeMap<CompositeObject, IColumn>();
    int index = 0;
    for (IColumn col : getColumns()) {
        int sortIndex = -1;
        if (col.isInitialAlwaysIncludeSortAtBegin()) {
            sortIndex = col.getInitialSortIndex();
            if (sortIndex < 0) {
                LOG.warn("AlwaysIncludeSortAtBegin is set but no sort index configured. Table: {}", m_table.getClass().getName());
            }
        } else if (col.isInitialAlwaysIncludeSortAtEnd()) {
            sortIndex = col.getInitialSortIndex();
            if (sortIndex < 0) {
                LOG.warn("AlwaysIncludeSortAtEnd is set but no sort index configured. Table: {}", m_table.getClass().getName());
            }
        } else {
            sortIndex = columnConfigs.get(col).getSortIndex();
        }
        if (sortIndex >= 0) {
            sortMap.put(new CompositeObject(sortIndex, index), col);
        }
        // aggregation function:
        if (col instanceof INumberColumn) {
            ((INumberColumn) col).setAggregationFunction(columnConfigs.get(col).getAggregationFunction());
        }
        index++;
    }
    clearSortColumns();
    clearPermanentHeadSortColumns();
    clearPermanentTailSortColumns();
    boolean asc;
    for (IColumn col : sortMap.values()) {
        if (col.isInitialAlwaysIncludeSortAtBegin()) {
            asc = col.isInitialSortAscending();
            addPermanentHeadSortColumn(col, asc);
        } else if (col.isInitialAlwaysIncludeSortAtEnd()) {
            asc = col.isInitialSortAscending();
            addPermanentTailSortColumn(col, asc);
        } else {
            asc = columnConfigs.get(col).isAscending();
            addSortColumn(col, asc);
        }
    }
    applyGrouping(columnConfigs);
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) INumberColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeMap(java.util.TreeMap)

Example 7 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class CallsView method renderCallTable.

private void renderCallTable(HtmlComponent p, SessionInspector session) {
    TreeMap<CompositeObject, CallInspector> timeToCalls = new TreeMap<CompositeObject, CallInspector>();
    CallInspector[] callInspectors = session.getCallInspectors();
    for (int i = 0; i < callInspectors.length; i++) {
        long startTime = callInspectors[i].getInfo().getStartTime();
        timeToCalls.put(new CompositeObject(startTime, i), callInspectors[i]);
    }
    CallInspector[] sorted = timeToCalls.values().toArray(new CallInspector[timeToCalls.size()]);
    p.bold("Calls");
    p.startTable(1, 0, 3);
    p.startTableRow();
    p.tableHeaderCell("#");
    p.tableHeaderCell("Operation");
    p.tableHeaderCell("Started");
    p.tableHeaderCell("Duration");
    p.tableHeaderCell("Status");
    p.endTableRow();
    CallInspector validSelection = null;
    for (int i = sorted.length - 1; i >= 0; i--) {
        if (sorted[i] == m_selectedCall) {
            validSelection = m_selectedCall;
        }
        renderCallRow(p, i + 1, sorted[i]);
    }
    m_selectedCall = validSelection;
    p.endTable();
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) CallInspector(org.eclipse.scout.rt.server.admin.inspector.CallInspector) TreeMap(java.util.TreeMap)

Example 8 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ServicesView method renderServiceTables.

private void renderServiceTables(HtmlComponent p) {
    // categorize services
    TreeMap<CompositeObject, Collection<ServiceInspector>> servicesMap = new TreeMap<CompositeObject, Collection<ServiceInspector>>();
    if (m_serviceInspectors != null) {
        for (ServiceInspector inspector : m_serviceInspectors) {
            String serviceName = inspector.getService().getClass().getSimpleName();
            String sectionName = null;
            int sectionOrder;
            try {
                if (serviceName.matches(".*ProcessService")) {
                    sectionOrder = 1;
                    sectionName = "Process Services";
                } else if (serviceName.matches(".*OutlineService")) {
                    sectionOrder = 2;
                    sectionName = "Outline Services";
                } else if (serviceName.matches(".*LookupService")) {
                    sectionOrder = 3;
                    sectionName = "Lookup Services";
                } else {
                    List<Class<?>> serviceInterfaces = BeanUtility.getInterfacesHierarchy(inspector.getService().getClass(), Object.class);
                    Class topInterface = (serviceInterfaces.size() > 0 ? serviceInterfaces.get(serviceInterfaces.size() - 1) : null);
                    if (topInterface != null && topInterface.getPackage() != null && topInterface.getPackage().getName().indexOf(".common.") >= 0) {
                        sectionOrder = 4;
                        sectionName = "Common Services";
                    } else {
                        sectionOrder = 5;
                        sectionName = "Other Services";
                    }
                }
                CompositeObject key = new CompositeObject(sectionOrder, sectionName);
                Collection<ServiceInspector> list = servicesMap.get(key);
                if (list == null) {
                    list = new ArrayList<ServiceInspector>();
                    servicesMap.put(key, list);
                }
                list.add(inspector);
            } catch (RuntimeException e) {
                LOG.warn("Failed inspecting service {}", inspector.getService().getClass(), e);
            }
        }
    }
    // tables per section
    for (Map.Entry<CompositeObject, Collection<ServiceInspector>> e : servicesMap.entrySet()) {
        String sectionName = (String) e.getKey().getComponent(1);
        Collection<ServiceInspector> list = e.getValue();
        renderServiceTable(p, sectionName, list);
        p.p();
    }
}
Also used : TreeMap(java.util.TreeMap) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) ServiceInspector(org.eclipse.scout.rt.server.admin.inspector.ServiceInspector) Collection(java.util.Collection) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 9 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ServerSessionProviderWithCache method provide.

/**
 * Returns the cached server session for the given <em>sessionId</em>, or the context's {@link Subject} if
 * <em>sessionId</em> is not specified. On cache miss, a new session is created via {@link ServerSessionProvider}.
 *
 * @param sessionId
 *          unique session ID to identify the cached session. If <code>null</code>, the context's {@link Subject} is
 *          used for identification. On cache miss, this <em>sessionId</em> is used to create a new session, or a
 *          random UUID if <code>null</code>.
 * @param serverRunContext
 *          applied during session start, and to get the session's {@link Subject}.
 * @return session found in cache, or a new session on cache miss.
 * @throws RuntimeException
 *           if session creation failed.
 */
@Override
public <SESSION extends IServerSession> SESSION provide(final String sessionId, final ServerRunContext serverRunContext) {
    // 1. Create session lookup key.
    final CompositeObject sessionCacheKey = newSessionCacheKey(sessionId, serverRunContext.getSubject());
    if (sessionCacheKey == null) {
        LOG.warn("Cannot identify cached server session because the cache key is undefined  [sessionId={}, subject={}]", sessionId, serverRunContext.getSubject());
        return super.provide(sessionId, serverRunContext);
    }
    // 2. Lookup session in the cache.
    @SuppressWarnings("unchecked") SESSION serverSession = (SESSION) m_cache.get(sessionCacheKey);
    if (serverSession != null) {
        return serverSession;
    }
    // 3. Cache miss (optimistic locking because session creation might be a long running operation)
    serverSession = super.provide(sessionId, serverRunContext);
    // 4. Cache the new server session, or return present session if created by another thread in the meantime (optimistic locking).
    @SuppressWarnings("unchecked") final SESSION cachedServerSession = (SESSION) m_cache.putIfAbsent(sessionCacheKey, serverSession);
    if (cachedServerSession != null) {
        serverSession = cachedServerSession;
    }
    return serverSession;
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject)

Example 10 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ReflectServiceInventory method getProperties.

public PropertyDescriptor[] getProperties() {
    TreeMap<CompositeObject, PropertyDescriptor> sortMap = new TreeMap<CompositeObject, PropertyDescriptor>();
    int index = 0;
    for (PropertyDescriptor p : m_properties) {
        if ("class".equals(p.getName())) {
        // ignore
        } else {
            if (p.getName().startsWith("configured")) {
                sortMap.put(new CompositeObject(1, p.getName(), index), p);
            } else {
                sortMap.put(new CompositeObject(2, p.getName(), index), p);
            }
        }
        index++;
    }
    return sortMap.values().toArray(new PropertyDescriptor[0]);
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) PropertyDescriptor(java.beans.PropertyDescriptor) TreeMap(java.util.TreeMap)

Aggregations

CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)29 TreeMap (java.util.TreeMap)16 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IBookmarkAdapter (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 INumberColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn)2 IForm (org.eclipse.scout.rt.client.ui.form.IForm)2 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 Test (org.junit.Test)2 PropertyDescriptor (java.beans.PropertyDescriptor)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1