Search in sources :

Example 1 with ConfigOperation

use of org.eclipse.scout.rt.platform.annotations.ConfigOperation in project scout.rt by eclipse.

the class AbstractTable method execCopy.

/**
 * Called by a <code>CTRL-C</code> event on the table to copy the given rows into the clipboard.
 * <p>
 * Subclasses can override this method. The default creates a {@link TextTransferObject} of the table content (HTML
 * table).
 *
 * @param rows
 *          The selected table rows to copy.
 * @return A transferable object representing the given rows or null to not populate the clipboard.
 */
@ConfigOperation
@Order(30)
protected TransferObject execCopy(List<? extends ITableRow> rows) {
    if (!CollectionUtility.hasElements(rows)) {
        return null;
    }
    StringBuilder plainText = new StringBuilder();
    List<IColumn<?>> columns = getColumnSet().getVisibleColumns();
    boolean firstRow = true;
    for (ITableRow row : rows) {
        appendCopyTextForRow(plainText, row, firstRow, columns);
        firstRow = false;
    }
    TextTransferObject transferObject = new TextTransferObject(plainText.toString());
    return transferObject;
}
Also used : TextTransferObject(org.eclipse.scout.rt.client.ui.dnd.TextTransferObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 2 with ConfigOperation

use of org.eclipse.scout.rt.platform.annotations.ConfigOperation in project scout.rt by eclipse.

the class AbstractColumn method execPrepareEdit.

/**
 * Prepares the editing of a cell in the table.
 * <p>
 * Cell editing is canceled (normally by typing escape) or saved (normally by clicking another cell, typing enter).
 * <p>
 * When saved, the method {@link #completeEdit(ITableRow, IFormField)} /
 * {@link #interceptCompleteEdit(ITableRow, IFormField)} is called on this column.
 * <p>
 * Subclasses can override this method. The default returns an appropriate field based on the column data type.
 * <p>
 * The mapping from the cell value to the field value is achieved using {@link #cellToEditField(Object, String,
 * IMultiStatus, IFormField))}
 *
 * @param row
 *          on which editing occurs
 * @return a field for editing.
 */
@ConfigOperation
@Order(61)
protected IFormField execPrepareEdit(ITableRow row) {
    IFormField f = prepareEditInternal(row);
    if (f != null) {
        f.setLabelVisible(false);
        cellValueToEditor(row, f);
        f.markSaved();
    }
    return f;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 3 with ConfigOperation

use of org.eclipse.scout.rt.platform.annotations.ConfigOperation in project scout.rt by eclipse.

the class AbstractPlanner method execDisplayModeChanged.

@ConfigOperation
@Order(30)
protected void execDisplayModeChanged(int displayMode) {
    Calendar from = Calendar.getInstance();
    Calendar to = Calendar.getInstance();
    if (getViewRange() != null && getViewRange().getFrom() != null) {
        from.setTime(getViewRange().getFrom());
        to.setTime(getViewRange().getFrom());
    }
    DateUtility.truncCalendar(from);
    DateUtility.truncCalendar(to);
    switch(displayMode) {
        case IPlannerDisplayMode.DAY:
            to.add(Calendar.DAY_OF_WEEK, 1);
            break;
        case IPlannerDisplayMode.WEEK:
            from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.add(Calendar.DAY_OF_WEEK, 7);
            break;
        case IPlannerDisplayMode.WORK_WEEK:
            from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.add(Calendar.DAY_OF_WEEK, 5);
            break;
        case IPlannerDisplayMode.MONTH:
            from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.add(Calendar.MONTH, 2);
            break;
        case IPlannerDisplayMode.CALENDAR_WEEK:
            from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            to.add(Calendar.MONTH, 9);
            break;
        case IPlannerDisplayMode.YEAR:
            to.add(Calendar.YEAR, 2);
            break;
    }
    setViewRange(from.getTime(), to.getTime());
}
Also used : Calendar(java.util.Calendar) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 4 with ConfigOperation

use of org.eclipse.scout.rt.platform.annotations.ConfigOperation in project scout.rt by eclipse.

the class AbstractPage method execComputeParentTablePageMenus.

/**
 * The default implementation returns the single selection menus from the parent table page's table.
 * <p>
 * If this behavior is not desired return an empty list or filter the menus for your needs instead.
 *
 * @param parentTablePage
 *          Parent table page
 * @return A list (non-null) of single selection menus.
 */
@Order(150)
@ConfigOperation
protected List<IMenu> execComputeParentTablePageMenus(IPageWithTable<?> parentTablePage) {
    ITableRow row = parentTablePage.getTableRowFor(this);
    if (row == null) {
        return CollectionUtility.emptyArrayList();
    }
    ITable table = parentTablePage.getTable();
    table.getUIFacade().setSelectedRowsFromUI(CollectionUtility.arrayList(row));
    return ActionUtility.getActions(table.getContextMenu().getChildActions(), ActionUtility.createMenuFilterMenuTypes(CollectionUtility.hashSet(TableMenuType.SingleSelection), false));
}
Also used : ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 5 with ConfigOperation

use of org.eclipse.scout.rt.platform.annotations.ConfigOperation 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)

Aggregations

ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)21 Order (org.eclipse.scout.rt.platform.Order)20 IDataModelEntity (org.eclipse.scout.rt.shared.data.model.IDataModelEntity)4 EntityNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode)3 ArrayList (java.util.ArrayList)2 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 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)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 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)1