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;
}
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());
}
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);
}
}
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));
}
}
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();
}
Aggregations