Search in sources :

Example 6 with Order

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

the class AbstractPage method execDataChanged.

/**
 * Called by the data change listener registered with this page (and the current desktop) through
 * {@link #registerDataChangeListener(Object...)}. Use this callback method to react to data change events by
 * reloading current data, or throwing away cached data etc.
 * <p>
 * Subclasses can override this method.<br/>
 * This default implementation does the following:
 * <ol>
 * <li>if this page is an ancestor of the selected page (or is selected itself) and this page is in the active
 * outline, a full re-load of the page is performed
 * <li>else the children of this page are marked dirty and the page itself is unloaded
 * </ol>
 *
 * @see IDesktop#dataChanged(Object...)
 */
@ConfigOperation
@Order(55)
protected void execDataChanged(Object... dataTypes) {
    if (getTree() == null) {
        return;
    }
    // 
    HashSet<ITreeNode> pathsToSelections = new HashSet<ITreeNode>();
    for (ITreeNode node : getTree().getSelectedNodes()) {
        ITreeNode tmp = node;
        while (tmp != null) {
            pathsToSelections.add(tmp);
            tmp = tmp.getParentNode();
        }
    }
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    final boolean isActiveOutline = (desktop != null ? desktop.getOutline() == this.getOutline() : false);
    final boolean isRootNode = pathsToSelections.isEmpty() && getTree() != null && getTree().getRootNode() == this;
    if (isActiveOutline && (pathsToSelections.contains(this) || isRootNode)) {
        try {
            // TODO [7.0] fko: maybe remove when bookmarks can be done on outline level? (currently only pages)
            if (isRootNode) {
                this.reloadPage();
            } else /*
         * Ticket 77332 (deleting a node in the tree) also requires a reload So
         * the selected and its ancestor nodes require same processing
         */
            if (desktop != null) {
                // NOSONAR
                Bookmark bm = desktop.createBookmark();
                setChildrenDirty(true);
                // activate bookmark without activating the outline, since this would hide active tabs.
                desktop.activateBookmark(bm, false);
            }
        } catch (RuntimeException | PlatformError e) {
            BEANS.get(ExceptionHandler.class).handle(e);
        }
    } else {
        // not active outline OR not on selection path
        setChildrenDirty(true);
        if (isExpanded()) {
            setExpanded(false);
        }
        try {
            if (isChildrenLoaded()) {
                getTree().unloadNode(this);
            }
        } catch (RuntimeException | PlatformError e) {
            BEANS.get(ExceptionHandler.class).handle(e);
        }
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) HashSet(java.util.HashSet) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 7 with Order

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

the class AbstractComposerField method execCreateEntityNode.

/**
 * Override this method to decorate or enhance new nodes whenever they are created
 *
 * @return the new node or null to ignore the add of a new node of this type
 *         <p>
 *         Normally overrides call super. {@link #execCreateEntityNode(ITreeNode, IDataModelEntity, boolean, Object[],
 *         List<String>)}
 */
@ConfigOperation
@Order(110)
protected EntityNode execCreateEntityNode(ITreeNode parentNode, IDataModelEntity e, boolean negated, List<? extends Object> values, List<String> texts) {
    EntityNode node = new EntityNode(this, e);
    node.setValues(values);
    node.setTexts(texts);
    node.setNegative(negated);
    node.setStatus(ITreeNode.STATUS_INSERTED);
    return node;
}
Also used : EntityNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 8 with Order

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

the class AbstractComposerField method execCreateAttributeNode.

/**
 * Override this method to decorate or enhance new nodes whenever they are created
 *
 * @return the new node or null to ignore the add of a new node of this type
 *         <p>
 *         Normally overrides call super. {@link #execCreateAttributeNode(ITreeNode, IDataModelAttribute, Integer,
 *         IComposerOp, Object[], List<String>)}
 */
@ConfigOperation
@Order(120)
protected AttributeNode execCreateAttributeNode(ITreeNode parentNode, IDataModelAttribute a, Integer aggregationType, IDataModelAttributeOp op, List<? extends Object> values, List<String> texts) {
    if (aggregationType != null && aggregationType == DataModelConstants.AGGREGATION_NONE) {
        aggregationType = null;
    }
    AttributeNode node = new AttributeNode(this, a);
    node.setAggregationType(aggregationType);
    node.setOp(op);
    node.setValues(values);
    node.setTexts(texts);
    node.setStatus(ITreeNode.STATUS_INSERTED);
    return node;
}
Also used : AttributeNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.AttributeNode) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 9 with Order

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

the class AbstractComposerField method execResolveEntityPath.

/**
 * For {@link #exportFormFieldData(AbstractFormFieldData)}, {@link AbstractTree#exportTreeData(AbstractTreeFieldData)}
 * and {@link #storeToXml(Element)} it is necessary to export {@link IDataModelEntity} and {@link IDataModelAttribute}
 * as external strings. see {@link EntityPath}
 * <p>
 * This callback completes an entity path to its root. The parameter path contains the entity path represented in the
 * composer tree of {@link EntityNode}s, the last element is the deepest tree node.
 * <p>
 * The default traverses the tree up to the root and collects all non-null {@link EntityNode#getEntity()}
 * <p>
 * This is prefixed with {@link #interceptResolveRootPathForTopLevelEntity(IDataModelEntity, List)}
 */
@ConfigOperation
@Order(99)
protected EntityPath execResolveEntityPath(EntityNode node) {
    LinkedList<IDataModelEntity> list = new LinkedList<IDataModelEntity>();
    EntityNode tmp = node;
    while (tmp != null) {
        if (tmp.getEntity() != null) {
            list.add(0, tmp.getEntity());
        }
        // next
        tmp = tmp.getAncestorNode(EntityNode.class);
    }
    if (list.size() > 0) {
        interceptResolveRootPathForTopLevelEntity(list.get(0), list);
    }
    return new EntityPath(list);
}
Also used : EntityPath(org.eclipse.scout.rt.shared.data.model.EntityPath) IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity) LinkedList(java.util.LinkedList) EntityNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 10 with Order

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

the class AbstractSqlService method execCustomBindFunction.

/**
 * Custom functions that can be used in sql statements as binds or sql style independent functions
 * <p>
 * Default functions are<br>
 * ::level(permissionClass) --> int //to resolve a permissin level by executing a permission<br>
 * ::level(permissionLevel) --> int //to resolve a permissin level by its id<br>
 * ::code(codeClass or codeTypeClass) --> the ID of the code or code type<br>
 * ::text(textId) --> the text in the user sessions language
 * <p>
 * Examples:<br>
 * ::level(UpdatePersonPermission)<br>
 * ::level(UpdatePersonPermission.LEVEL_OWN)<br>
 * <br>
 * ::code(CompanyAddressCodeType.MainAddressCode)<br>
 * ::code(MainAddressCode)<br>
 * <br>
 * ::text(SalutationMr)
 * <p>
 *
 * @return a plain object value or in case of a null value preferrably a {@link IHolder} of the correct value type
 */
@ConfigOperation
@Order(40)
protected Object execCustomBindFunction(String functionName, String[] args, Object[] bindBases) {
    if ("level".equals(functionName)) {
        if (args.length != 1) {
            throw new IllegalArgumentException("expected 1 argument for function '" + functionName + "'");
        }
        String permissionClassName = args[0];
        String levelField = null;
        // eventually a level id?
        int levelDot = permissionClassName.indexOf(".LEVEL_");
        if (levelDot >= 0) {
            levelField = permissionClassName.substring(levelDot + 1);
            permissionClassName = permissionClassName.substring(0, levelDot);
        }
        Class permissionClass = loadBundleClassLenient(m_permissionNameToDescriptor, permissionClassName);
        IAccessControlService accessControlService = BEANS.get(IAccessControlService.class);
        Object ret = tryGetPermissionLevel(permissionClass, levelField, accessControlService);
        return ret != null ? ret : new LongHolder();
    } else if ("code".equals(functionName)) {
        if (args.length != 1) {
            throw new IllegalArgumentException("expected 1 argument for function '" + functionName + "'");
        }
        String codeClassName = args[0];
        Class codeClass = loadBundleClassLenient(m_codeNameToDescriptor, codeClassName);
        if (codeClass == null) {
            throw new ProcessingException("Cannot find class for code '{}", new Object[] { args[0] });
        }
        try {
            Object ret = codeClass.getField("ID").get(null);
            return ret != null ? ret : new LongHolder();
        } catch (Exception t) {
            throw new ProcessingException("ID of code '{}'", new Object[] { args[0], t });
        }
    } else if ("text".equals(functionName)) {
        if (args.length < 1) {
            throw new IllegalArgumentException("expected at least 1 argument for function '" + functionName + "'");
        }
        String ret = TEXTS.get(args[0]);
        return ret != null ? ret : new StringHolder();
    } else {
        throw new IllegalArgumentException("undefined function '" + functionName + "'");
    }
}
Also used : LongHolder(org.eclipse.scout.rt.platform.holders.LongHolder) StringHolder(org.eclipse.scout.rt.platform.holders.StringHolder) IAccessControlService(org.eclipse.scout.rt.shared.services.common.security.IAccessControlService) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) SQLException(java.sql.SQLException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) 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