Search in sources :

Example 6 with IDataModelAction

use of org.jowidgets.cap.ui.api.command.IDataModelAction in project jo-client-platform by jo-source.

the class CapWorkbenchActionsProviderImpl method undoAction.

@Override
public IDataModelAction undoAction() {
    IDataModelAction result = Toolkit.getValue(UNDO_ACTION_KEY);
    if (result == null) {
        IDataModelActionBuilder builder = actionFactory.dataModelUndoActionBuilder();
        for (final IWorkbenchMenuInterceptorPlugin plugin : PluginProvider.getPlugins(IWorkbenchMenuInterceptorPlugin.ID)) {
            builder = plugin.getMenuInterceptor().undoAction(builder);
            if (builder == null) {
                break;
            }
        }
        if (builder != null) {
            result = builder.build();
        } else {
            result = null;
        }
        Toolkit.setValue(UNDO_ACTION_KEY, result);
    }
    return result;
}
Also used : IDataModelActionBuilder(org.jowidgets.cap.ui.api.command.IDataModelActionBuilder) IWorkbenchMenuInterceptorPlugin(org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin) IDataModelAction(org.jowidgets.cap.ui.api.command.IDataModelAction)

Example 7 with IDataModelAction

use of org.jowidgets.cap.ui.api.command.IDataModelAction in project jo-client-platform by jo-source.

the class CapWorkbenchMenuFactoryImpl method toolBar.

@Override
public IToolBarModel toolBar() {
    IToolBarModel result = new ToolBarModel();
    final IDataModelAction loadAction = CapWorkbenchActionsProvider.loadAction();
    boolean separator = false;
    if (loadAction != null) {
        result.addAction(loadAction);
        separator = true;
    }
    final IDataModelAction cancelAction = CapWorkbenchActionsProvider.cancelAction();
    if (cancelAction != null) {
        result.addAction(cancelAction);
        separator = true;
    }
    if (separator) {
        result.addSeparator();
        separator = false;
    }
    final IDataModelAction undoAction = CapWorkbenchActionsProvider.undoAction();
    if (undoAction != null) {
        result.addAction(undoAction);
    }
    final IDataModelAction saveAction = CapWorkbenchActionsProvider.saveAction();
    if (saveAction != null) {
        result.addAction(saveAction);
    }
    final int size = result.getItems().size();
    if (size > 0) {
        final IToolBarItemModel itemModel = result.getItems().get(size - 1);
        if (itemModel instanceof ISeparatorItemModel) {
            result.removeItem(itemModel);
        }
    }
    // Modify with plugins
    for (final IWorkbenchMenuInterceptorPlugin plugin : PluginProvider.getPlugins(IWorkbenchMenuInterceptorPlugin.ID)) {
        result = plugin.getMenuInterceptor().toolBarModel(result);
        if (result == null) {
            break;
        }
    }
    if (result != null) {
        return result;
    } else {
        return new ToolBarModel();
    }
}
Also used : IToolBarModel(org.jowidgets.api.model.item.IToolBarModel) ToolBarModel(org.jowidgets.tools.model.item.ToolBarModel) IToolBarItemModel(org.jowidgets.api.model.item.IToolBarItemModel) ISeparatorItemModel(org.jowidgets.api.model.item.ISeparatorItemModel) IToolBarModel(org.jowidgets.api.model.item.IToolBarModel) IWorkbenchMenuInterceptorPlugin(org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin) IDataModelAction(org.jowidgets.cap.ui.api.command.IDataModelAction)

Example 8 with IDataModelAction

use of org.jowidgets.cap.ui.api.command.IDataModelAction in project jo-client-platform by jo-source.

the class EntityComponent method getDataModelActions.

private List<IDataModelAction> getDataModelActions(final IComponentNodeModel componentNodeModel) {
    final IToolBarModel toolBar = componentNodeModel.getApplication().getWorkbench().getToolBar();
    final List<IDataModelAction> result = new LinkedList<IDataModelAction>();
    for (final IToolBarItemModel item : toolBar.getItems()) {
        if (item instanceof IActionItemModel) {
            final IAction action = ((IActionItemModel) item).getAction();
            if (action instanceof IDataModelAction) {
                result.add((IDataModelAction) action);
            }
        }
    }
    return result;
}
Also used : IAction(org.jowidgets.api.command.IAction) IToolBarItemModel(org.jowidgets.api.model.item.IToolBarItemModel) IToolBarModel(org.jowidgets.api.model.item.IToolBarModel) IDataModelAction(org.jowidgets.cap.ui.api.command.IDataModelAction) LinkedList(java.util.LinkedList) IActionItemModel(org.jowidgets.api.model.item.IActionItemModel)

Aggregations

IDataModelAction (org.jowidgets.cap.ui.api.command.IDataModelAction)8 IWorkbenchMenuInterceptorPlugin (org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin)6 IDataModelActionBuilder (org.jowidgets.cap.ui.api.command.IDataModelActionBuilder)4 IAction (org.jowidgets.api.command.IAction)3 ISeparatorItemModel (org.jowidgets.api.model.item.ISeparatorItemModel)2 IToolBarItemModel (org.jowidgets.api.model.item.IToolBarItemModel)2 IToolBarModel (org.jowidgets.api.model.item.IToolBarModel)2 LinkedList (java.util.LinkedList)1 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)1 IMenuModel (org.jowidgets.api.model.item.IMenuModel)1 MenuModel (org.jowidgets.tools.model.item.MenuModel)1 ToolBarModel (org.jowidgets.tools.model.item.ToolBarModel)1