Search in sources :

Example 1 with ActionChangeEvent

use of com.ramussoft.gui.common.event.ActionChangeEvent in project ramus by Vitaliy-Yakovchuk.

the class GUIPluginFactory method initActions.

private void initActions(final String id, final View view, final DefaultCDockable dockable) {
    Action[] actions = view.getActions();
    addActions(id, view, dockable, actions);
    dockable.addSeparator();
    view.addViewTitleListener(new ViewTitleListener() {

        @Override
        public void titleChanged(ViewTitleEvent event) {
            dockable.setTitleText(event.getNewTitle());
        }
    });
    view.addActionChangeListener(new ActionChangeAdapter() {

        @Override
        public void actionsAdded(ActionChangeEvent event) {
            Action[] actions = event.getActions();
            List<Action> list = new ArrayList<Action>();
            for (Action a : actions) {
                if (a != null)
                    list.add(a);
            }
            addActions(id, view, dockable, list.toArray(new Action[list.size()]));
        }

        @Override
        public void actionsRemoved(ActionChangeEvent event) {
            for (Action a : event.getActions()) if (a != null) {
                CDecorateableAction button = actionButtons.remove(a);
                if (button != null)
                    dockable.removeAction(button);
            }
        }
    });
}
Also used : AbstractAction(javax.swing.AbstractAction) CDecorateableAction(bibliothek.gui.dock.common.intern.action.CDecorateableAction) Action(javax.swing.Action) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionChangeAdapter(com.ramussoft.gui.common.event.ActionChangeAdapter) ActionChangeEvent(com.ramussoft.gui.common.event.ActionChangeEvent) CDecorateableAction(bibliothek.gui.dock.common.intern.action.CDecorateableAction) List(java.util.List) ArrayList(java.util.ArrayList) ViewTitleListener(com.ramussoft.gui.common.event.ViewTitleListener)

Example 2 with ActionChangeEvent

use of com.ramussoft.gui.common.event.ActionChangeEvent in project ramus by Vitaliy-Yakovchuk.

the class SimleGUIPluginFactory method initActions.

private void initActions(final String id, final View view, final DFrame dockable) {
    Action[] actions = view.getActions();
    addActions(id, view, dockable, actions);
    dockable.addSeparator();
    view.addViewTitleListener(new ViewTitleListener() {

        @Override
        public void titleChanged(ViewTitleEvent event) {
            dockable.setTitleText(event.getNewTitle());
        }
    });
    view.addActionChangeListener(new ActionChangeAdapter() {

        @Override
        public void actionsAdded(ActionChangeEvent event) {
            Action[] actions = event.getActions();
            List<Action> list = new ArrayList<Action>();
            for (Action a : actions) {
                if (a != null)
                    list.add(a);
            }
            addActions(id, view, dockable, list.toArray(new Action[list.size()]));
        }

        @Override
        public void actionsRemoved(ActionChangeEvent event) {
            for (Action a : event.getActions()) if (a != null) {
                dockable.removeAction(a);
            }
        }
    });
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionChangeAdapter(com.ramussoft.gui.common.event.ActionChangeAdapter) ActionChangeEvent(com.ramussoft.gui.common.event.ActionChangeEvent) List(java.util.List) ArrayList(java.util.ArrayList) ViewTitleListener(com.ramussoft.gui.common.event.ViewTitleListener)

Example 3 with ActionChangeEvent

use of com.ramussoft.gui.common.event.ActionChangeEvent in project ramus by Vitaliy-Yakovchuk.

the class BranchView method createComponent.

@Override
public JComponent createComponent() {
    this.branchModel = new BranchModel(createRoot(engine.getRootBranch()));
    this.table = new BranchTreeTable(branchModel, this);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean b = table.getSelectedRow() >= 0;
            Node node = null;
            if (b) {
                node = (Node) table.getPathForRow(table.getSelectedRow()).getLastPathComponent();
                if (node.branch.getChildren().size() > 0)
                    addChildBranch.setEnabled(false);
                else
                    // addChildBranch.putValue(Action.SMALL_ICON,
                    // branchTree);
                    addChildBranch.setEnabled(true);
                // addChildBranch.putValue(Action.SMALL_ICON,
                // branch);
                ActionChangeEvent event = new ActionChangeEvent(new Action[] { addChildBranch, editCommment });
                for (ActionChangeListener l : getActionChangeListeners()) l.actionsRemoved(event);
                for (ActionChangeListener l : getActionChangeListeners()) l.actionsAdded(event);
            } else
                addChildBranch.setEnabled(false);
            activateBranch.setEnabled(b && node.branch.getBranchId() != actualBranch);
            editCommment.setEnabled(b && node.parent != null);
        }
    });
    table.setRootVisible(true);
    branchListener = new BranchAdapter() {

        @Override
        public void branchDeleted(BranchEvent event) {
            branchModel.setRoot(createRoot(engine.getRootBranch()));
        }

        @Override
        public void branchCreated(final BranchEvent event) {
            branchModel.setRoot(createRoot(engine.getRootBranch()));
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    table.expandAll();
                    for (int i = 0; i < table.getRowCount(); i++) {
                        Node n = (Node) table.getPathForRow(i).getLastPathComponent();
                        if (n.branch.getBranchId() == event.getBranchId()) {
                            table.getSelectionModel().addSelectionInterval(i, i);
                            break;
                        }
                    }
                }
            });
        }

        @Override
        public void branchActivated(BranchEvent event) {
            framework.propertyChanged(Commands.FULL_REFRESH);
            actualBranch = event.getBranchId();
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    table.repaint();
                }
            });
        }
    };
    engine.addBranchListener(branchListener);
    table.expandAll();
    actualBranch = engine.getActiveBranch();
    return new JScrollPane(table);
}
Also used : JScrollPane(javax.swing.JScrollPane) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionChangeEvent(com.ramussoft.gui.common.event.ActionChangeEvent) BranchEvent(com.ramussoft.common.event.BranchEvent) TreeNode(javax.swing.tree.TreeNode) TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionChangeListener(com.ramussoft.gui.common.event.ActionChangeListener) BranchAdapter(com.ramussoft.common.event.BranchAdapter)

Aggregations

ActionChangeEvent (com.ramussoft.gui.common.event.ActionChangeEvent)3 AbstractAction (javax.swing.AbstractAction)3 Action (javax.swing.Action)3 ActionChangeAdapter (com.ramussoft.gui.common.event.ActionChangeAdapter)2 ViewTitleEvent (com.ramussoft.gui.common.event.ViewTitleEvent)2 ViewTitleListener (com.ramussoft.gui.common.event.ViewTitleListener)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CDecorateableAction (bibliothek.gui.dock.common.intern.action.CDecorateableAction)1 BranchAdapter (com.ramussoft.common.event.BranchAdapter)1 BranchEvent (com.ramussoft.common.event.BranchEvent)1 ActionChangeListener (com.ramussoft.gui.common.event.ActionChangeListener)1 JScrollPane (javax.swing.JScrollPane)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 TreeNode (javax.swing.tree.TreeNode)1 TreeTableNode (org.jdesktop.swingx.treetable.TreeTableNode)1