Search in sources :

Example 1 with IToolBarModel

use of org.jowidgets.api.model.item.IToolBarModel in project jo-client-platform by jo-source.

the class BeanRelationGraphImpl method initToolBar.

private IToolBarModel initToolBar() {
    final IActionBuilderFactory actionBF = Toolkit.getActionBuilderFactory();
    final ToolBarModel model = new ToolBarModel();
    model.addTextLabel(Messages.getString("BeanRelationGraphImpl.max.nodecount") + " ");
    final IInputFieldBluePrint<Integer> textFieldBP = BPF.inputFieldIntegerNumber().setMaxLength(3).setValue(maxNodeCount);
    maxNodeTextField = new InputControlItemModel<Integer>(textFieldBP, 30);
    maxNodeTextField.addInputListener(new IInputListener() {

        @Override
        public void inputChanged() {
            if (maxNodeTextField.getValue() != null) {
                maxNodeCount = maxNodeTextField.getValue();
                relationTreeModel.load();
            }
        }
    });
    model.addItem(maxNodeTextField);
    model.addSeparator();
    model.addTextLabel("Expand Level ");
    final IComboBoxSelectionBluePrint<Integer> comboBoxExpandLevelBp = BPF.comboBoxSelectionIntegerNumber().setElements(0, 1, 2, 3, 4, 5).autoCompletionOff();
    comboBoxExpandLevel = new InputControlItemModel<Integer>(comboBoxExpandLevelBp, 35);
    comboBoxExpandLevel.setValue(autoExpandLevel);
    comboBoxExpandLevel.addInputListener(new IInputListener() {

        @Override
        public void inputChanged() {
            if (comboBoxExpandLevel.getValue() != null) {
                autoExpandLevel = comboBoxExpandLevel.getValue();
                runLayout(true);
                vis.run("expand");
            }
        }
    });
    model.addItem(comboBoxExpandLevel);
    model.addSeparator();
    final IActionBuilder settingsDialogActionBuilder = actionBF.create();
    settingsDialogActionBuilder.setIcon(CapIcons.GRAPH_SETTINGS);
    settingsDialogActionBuilder.setCommand(new ICommandExecutor() {

        @Override
        public void execute(final IExecutionContext executionContext) throws Exception {
            openUpdateLayoutSettingsDialog();
        }
    });
    final ICommandAction settingsDialogAction = settingsDialogActionBuilder.build();
    final IComboBoxSelectionBluePrint<GraphLayout> comboBoxBp = BPF.comboBoxSelection(GraphLayout.values());
    comboBoxBp.setAutoCompletion(false);
    final InputControlItemModel<GraphLayout> comboBox = new InputControlItemModel<GraphLayout>(comboBoxBp, 130);
    comboBox.addInputListener(new IInputListener() {

        @Override
        public void inputChanged() {
            layoutManager.resetNodePositions();
            settingsDialogAction.setEnabled(true);
            setLayout(comboBox.getValue());
            if (layoutManager.getLabelEdgeLayout() != null) {
                layoutManager.getLabelEdgeLayout().run();
            }
            layoutManager.assignAnchorPoint(display, activeLayout);
            runLayout(true);
            if (layoutSettingsDialog != null) {
                layoutSettingsDialog.setVisible(false);
                layoutSettingsDialog.dispose();
                layoutSettingsDialog = null;
            }
        }
    });
    comboBox.setValue(GraphLayout.FORCE_DIRECTED_LAYOUT);
    model.addItem(comboBox);
    final ICheckedItemModel checkItemModel = model.addCheckedItem(CapIcons.GRAPH_ANIMATION, Messages.getMessage("BeanRelationGraphImpl.animation.on").get());
    checkItemModel.setSelected(true);
    checkItemModel.addItemListener(new IItemStateListener() {

        private boolean on = true;

        @Override
        public void itemStateChanged() {
            if (on) {
                checkItemModel.setText(Messages.getMessage("BeanRelationGraphImpl.animation.on").get());
                switchNodeAnimation(true);
            } else {
                checkItemModel.setText(Messages.getMessage("BeanRelationGraphImpl.animation.off").get());
                switchNodeAnimation(false);
            }
            on = !on;
        }
    });
    final IActionBuilder groupFilterActionBuilder = actionBF.create();
    groupFilterActionBuilder.setIcon(IconsSmall.SETTINGS);
    groupFilterActionBuilder.setCommand(new ICommandExecutor() {

        @Override
        public void execute(final IExecutionContext executionContext) throws Exception {
            openUpdateEdgeVisibilityDialog(0);
        }
    });
    final ICommandAction groupFilterAction = groupFilterActionBuilder.build();
    model.addSeparator();
    model.addAction(settingsDialogAction);
    model.addAction(groupFilterAction);
    model.addSeparator();
    final ICheckedItemModel edgeCheckedItem = model.addCheckedItem("Edge Label");
    edgeCheckedItem.setIcon(CapIcons.GRAPH_LETTERING);
    edgeCheckedItem.setSelected(false);
    edgeCheckedItem.addItemListener(new IItemStateListener() {

        @Override
        public void itemStateChanged() {
            layoutManager.getLabelEdgeLayout().setEdgesVisible(edgeCheckedItem.isSelected());
            runLayout(true);
        }
    });
    final IActionBuilder screenShotActionBuilder = actionBF.create();
    screenShotActionBuilder.setText(Messages.getMessage("BeanRelationGraphImpl.screenshot").get());
    screenShotActionBuilder.setIcon(CapIcons.GRAPH_SNAPSHOT);
    screenShotActionBuilder.setToolTipText(Messages.getMessage("BeanRelationGraphImpl.copy.in.clipboard").get());
    screenShotActionBuilder.setCommand(new ICommandExecutor() {

        @Override
        public void execute(final IExecutionContext executionContext) throws Exception {
            final BufferedImage bufImage = new BufferedImage(display.getSize().width, display.getSize().height, BufferedImage.TYPE_INT_RGB);
            display.paint(bufImage.createGraphics());
            java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new ImageSelection(bufImage), null);
        }
    });
    final ICommandAction screenShotAction = screenShotActionBuilder.build();
    model.addAction(screenShotAction);
    return model;
}
Also used : ToolBarModel(org.jowidgets.tools.model.item.ToolBarModel) IToolBarModel(org.jowidgets.api.model.item.IToolBarModel) InputControlItemModel(org.jowidgets.tools.model.item.InputControlItemModel) IActionBuilderFactory(org.jowidgets.api.command.IActionBuilderFactory) IItemStateListener(org.jowidgets.common.widgets.controller.IItemStateListener) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) BufferedImage(java.awt.image.BufferedImage) ICommandAction(org.jowidgets.api.command.ICommandAction) ICheckedItemModel(org.jowidgets.api.model.item.ICheckedItemModel) IExecutionContext(org.jowidgets.api.command.IExecutionContext) ICommandExecutor(org.jowidgets.api.command.ICommandExecutor) IActionBuilder(org.jowidgets.api.command.IActionBuilder) IInputListener(org.jowidgets.common.widgets.controller.IInputListener)

Example 2 with IToolBarModel

use of org.jowidgets.api.model.item.IToolBarModel 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 3 with IToolBarModel

use of org.jowidgets.api.model.item.IToolBarModel 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)

Example 4 with IToolBarModel

use of org.jowidgets.api.model.item.IToolBarModel in project jo-client-platform by jo-source.

the class EntityComponentMasterTableToolBarPlugin method onInitialize.

@Override
public void onInitialize(final IPluginProperties properties, final IViewContext context, final IBeanTable<?> table, final Collection<IAction> linkCreatorActions) {
    final IToolBarModel toolBar = context.getToolBar();
    if (table.getDefaultCreatorAction() != null) {
        toolBar.addAction(table.getDefaultCreatorAction());
    }
    final IMenuModel toolBarMenu = context.getToolBarMenu();
    for (final IAction action : linkCreatorActions) {
        toolBarMenu.addAction(action);
    }
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IAction(org.jowidgets.api.command.IAction) IToolBarModel(org.jowidgets.api.model.item.IToolBarModel)

Example 5 with IToolBarModel

use of org.jowidgets.api.model.item.IToolBarModel in project jo-client-platform by jo-source.

the class EntityComponentRelationTreeToolBarPlugin method onInitialize.

@Override
public void onInitialize(final IPluginProperties properties, final IViewContext context, final IBeanTable<?> rootTable, final IBeanRelationTree<?> relationTree, final Collection<IAction> linkCreatorActions) {
    final IToolBarModel toolBar = context.getToolBar();
    if (relationTree.getAddAction() != null) {
        toolBar.addAction(relationTree.getAddAction());
    }
    final IMenuModel toolBarMenu = context.getToolBarMenu();
    for (final IAction action : linkCreatorActions) {
        toolBarMenu.addAction(action);
    }
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IAction(org.jowidgets.api.command.IAction) IToolBarModel(org.jowidgets.api.model.item.IToolBarModel)

Aggregations

IToolBarModel (org.jowidgets.api.model.item.IToolBarModel)5 IAction (org.jowidgets.api.command.IAction)3 IMenuModel (org.jowidgets.api.model.item.IMenuModel)2 IToolBarItemModel (org.jowidgets.api.model.item.IToolBarItemModel)2 IDataModelAction (org.jowidgets.cap.ui.api.command.IDataModelAction)2 ToolBarModel (org.jowidgets.tools.model.item.ToolBarModel)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 IActionBuilder (org.jowidgets.api.command.IActionBuilder)1 IActionBuilderFactory (org.jowidgets.api.command.IActionBuilderFactory)1 ICommandAction (org.jowidgets.api.command.ICommandAction)1 ICommandExecutor (org.jowidgets.api.command.ICommandExecutor)1 IExecutionContext (org.jowidgets.api.command.IExecutionContext)1 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 ICheckedItemModel (org.jowidgets.api.model.item.ICheckedItemModel)1 ISeparatorItemModel (org.jowidgets.api.model.item.ISeparatorItemModel)1 IWorkbenchMenuInterceptorPlugin (org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin)1 IInputListener (org.jowidgets.common.widgets.controller.IInputListener)1