Search in sources :

Example 11 with Order

use of org.eclipse.scout.rt.platform.Order in project scout.rt by eclipse.

the class AbstractDataModelEntity method calculateViewOrder.

/**
 * Calculates the column's view order, e.g. if the @Order annotation is set to 30.0, the method will return 30.0. If
 * no {@link Order} annotation is set, the method checks its super classes for an @Order annotation.
 *
 * @since 3.10.0-M4
 */
@SuppressWarnings("squid:S1244")
protected double calculateViewOrder() {
    double viewOrder = getConfiguredViewOrder();
    Class<?> cls = getClass();
    if (viewOrder == IOrdered.DEFAULT_ORDER) {
        while (cls != null && IDataModelEntity.class.isAssignableFrom(cls)) {
            if (cls.isAnnotationPresent(Order.class)) {
                Order order = (Order) cls.getAnnotation(Order.class);
                return order.value();
            }
            cls = cls.getSuperclass();
        }
    }
    return viewOrder;
}
Also used : Order(org.eclipse.scout.rt.platform.Order)

Example 12 with Order

use of org.eclipse.scout.rt.platform.Order in project scout.rt by eclipse.

the class ConfigurationUtility method sortFilteredClassesByOrderAnnotation.

/**
 * Filters the given class array and sorts the remaining elements according to their {@link Order} annotation.
 *
 * @param classes
 * @param filter
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> List<Class<? extends T>> sortFilteredClassesByOrderAnnotation(List<? extends Class> classes, Class<T> filter) {
    TreeMap<CompositeObject, Class<? extends T>> orderedClassesMap = new TreeMap<CompositeObject, Class<? extends T>>();
    int i = 0;
    for (Class candidate : classes) {
        if (filter.isAssignableFrom(candidate)) {
            if (candidate.isAnnotationPresent(Order.class)) {
                Order order = (Order) candidate.getAnnotation(Order.class);
                orderedClassesMap.put(new CompositeObject(order.value(), i), (Class<T>) candidate);
            } else {
                if (!candidate.isAnnotationPresent(Replace.class)) {
                    LOG.error("missing @Order annotation: {}", candidate.getName());
                }
                orderedClassesMap.put(new CompositeObject(Double.MAX_VALUE, i), (Class<T>) candidate);
            }
            i++;
        }
    }
    return CollectionUtility.arrayList(orderedClassesMap.values());
}
Also used : Order(org.eclipse.scout.rt.platform.Order) Replace(org.eclipse.scout.rt.platform.Replace) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) TreeMap(java.util.TreeMap)

Example 13 with Order

use of org.eclipse.scout.rt.platform.Order in project scout.rt by eclipse.

the class AbstractForm method execResetSearchFilter.

/**
 * Called when saving the form via {@link #resetSearchFilter()}.
 * <p>
 * This operation fills up the search filter and subclass override sets the formData property of the
 * {@link SearchFilter#setFormData(AbstractFormData)} and adds verbose texts with
 * {@link SearchFilter#addDisplayText(String)}
 * <p>
 * May call {@link #setSearchFilter(SearchFilter)}
 * <p>
 * Attaches a filled form data to the search filter if {@link #execCreateFormData()} returns a value.
 *
 * @param searchFilter
 *          is never null
 */
@ConfigOperation
@Order(10)
protected void execResetSearchFilter(final SearchFilter searchFilter) {
    searchFilter.clear();
    // add verbose field texts
    // do not use visitor, so children can block traversal on whole subtrees
    getRootGroupBox().applySearch(searchFilter);
    // add verbose form texts
    interceptAddSearchTerms(searchFilter);
    // override may add form data
    AbstractFormData data = createFormData();
    if (data != null) {
        exportFormData(data);
        getSearchFilter().setFormData(data);
    }
}
Also used : AbstractFormData(org.eclipse.scout.rt.shared.data.form.AbstractFormData) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 14 with Order

use of org.eclipse.scout.rt.platform.Order in project scout.rt by eclipse.

the class AbstractPageWithTable method execPopulateTable.

/**
 * Populates this page's table.
 * <p>
 * It is good practice to populate table using {@code ITable.replaceRows} instead of {@code ITable.removeAllRows();
 * ITable.addRows} because in the former case the outline tree structure below the changing rows is not discarded but
 * only marked as dirty. The subtree is lazily reloaded when the user clicks next time on a child node.
 * <p>
 * Subclasses can override this method. In most cases it is sufficient to override
 * {@link #interceptLoadData(SearchFilter)} or {@link #interceptLoadTableData(SearchFilter)} instead.<br/>
 * This default implementation does the following: It queries methods {@link #isSearchActive()} and
 * {@link #isSearchRequired()} and then calls {@link #interceptLoadData(SearchFilter)} if appropriate.
 */
@ConfigOperation
@Order(100)
protected void execPopulateTable() {
    if (isSearchActive()) {
        SearchFilter filter = getSearchFilter();
        if (filter.isCompleted() || !isSearchRequired()) {
            // create a copy of the filter, just in case the subprocess is modifying
            // or extending the filter
            filter = filter.copy();
            interceptLoadData(filter);
        }
    } else {
        // searchFilter should never be null
        interceptLoadData(new SearchFilter());
    }
    // update table data status
    if (isSearchActive() && getSearchFilter() != null && (!getSearchFilter().isCompleted()) && isSearchRequired()) {
        setTableStatus(new Status(TEXTS.get("TooManyRows"), IStatus.WARNING));
    } else {
        setTableStatus(null);
    }
    T table = getTable();
    if (isLimitedResult() && table != null) {
        String maxOutlineWarningKey = "MaxOutlineRowWarning";
        if (UserAgentUtility.isTouchDevice()) {
            maxOutlineWarningKey = "MaxOutlineRowWarningMobile";
        }
        setTableStatus(new Status(TEXTS.get(maxOutlineWarningKey, "" + table.getRowCount()), IStatus.WARNING));
    }
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 15 with Order

use of org.eclipse.scout.rt.platform.Order in project scout.rt by eclipse.

the class AbstractBookmarkMenu method execInitAction.

@Override
@ConfigOperation
@Order(10)
protected void execInitAction() {
    BEANS.get(IBookmarkService.class).addBookmarkServiceListener(new BookmarkServiceListener() {

        @Override
        public void bookmarksChanged(BookmarkServiceEvent e) {
            handleBookmarksChanged();
        }
    });
    handleBookmarksChanged();
}
Also used : BookmarkServiceListener(org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceListener) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) BookmarkServiceEvent(org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceEvent) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Aggregations

Order (org.eclipse.scout.rt.platform.Order)26 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)20 IDataModelEntity (org.eclipse.scout.rt.shared.data.model.IDataModelEntity)4 EntityNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode)3 LinkedList (java.util.LinkedList)2 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 BookmarkServiceEvent (org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceEvent)1 BookmarkServiceListener (org.eclipse.scout.rt.client.services.common.bookmark.BookmarkServiceListener)1 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)1 FormFieldProvisioningContext (org.eclipse.scout.rt.client.services.lookup.FormFieldProvisioningContext)1 ILookupCallProvisioningService (org.eclipse.scout.rt.client.services.lookup.ILookupCallProvisioningService)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)1