Пример #1
0
  /**
   * Constructor
   *
   * @param mainKFPerspective the main knowledge flow perspective
   */
  public MainKFPerspectiveToolBar(MainKFPerspective mainKFPerspective) {
    super();

    JMenu fileMenu = new JMenu();
    fileMenu.setText("File");
    m_menuMap.put("File", fileMenu);
    JMenu editMenu = new JMenu();
    editMenu.setText("Edit");
    m_menuMap.put("Edit", editMenu);
    JMenu insertMenu = new JMenu();
    insertMenu.setText("Insert");
    m_menuMap.put("Insert", insertMenu);
    JMenu viewMenu = new JMenu();
    viewMenu.setText("View");
    m_menuMap.put("View", viewMenu);

    m_mainPerspective = mainKFPerspective;
    setLayout(new BorderLayout());

    // set up an action for closing the current tab
    final Action closeAction =
        new AbstractAction("Close") {

          private static final long serialVersionUID = 4762166880144590384L;

          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentTabIndex() >= 0) {
              m_mainPerspective.removeTab(m_mainPerspective.getCurrentTabIndex());
            }
          }
        };
    KeyStroke closeKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Close", closeAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(closeKey, "Close");

    setupLeftSideToolBar();
    setupRightSideToolBar();
  }
Пример #2
0
  private void setupRightSideToolBar() {
    JToolBar fixedTools = new JToolBar();
    fixedTools.setOrientation(JToolBar.HORIZONTAL);

    JButton cutB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "cut.png").getImage()));
    cutB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    cutB.setToolTipText("Cut selected (Ctrl+X)");
    JButton copyB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "page_copy.png").getImage()));
    copyB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    copyB.setToolTipText("Copy selected (Ctrl+C)");
    JButton pasteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "paste_plain.png").getImage()));
    pasteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    pasteB.setToolTipText("Paste from clipboard (Ctrl+V)");
    JButton deleteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "delete.png").getImage()));
    deleteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    deleteB.setToolTipText("Delete selected (DEL)");
    final JToggleButton snapToGridB =
        new JToggleButton(new ImageIcon(loadIcon(ICON_PATH + "shape_handles.png").getImage()));
    // m_snapToGridB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    snapToGridB.setToolTipText("Snap to grid (Ctrl+G)");
    JButton saveB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "disk.png").getImage()));
    saveB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    saveB.setToolTipText("Save layout (Ctrl+S)");
    JButton saveBB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "disk_multiple.png").getImage()));
    saveBB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    saveBB.setToolTipText("Save layout with new name");
    JButton loadB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "folder_add.png").getImage()));
    loadB.setToolTipText("Open (Ctrl+O)");
    loadB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    JButton newB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "page_add.png").getImage()));
    newB.setToolTipText("New layout (Ctrl+N)");
    newB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    newB.setEnabled(m_mainPerspective.getAllowMultipleTabs());
    final JButton helpB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "help.png").getImage()));
    helpB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    helpB.setToolTipText("Display help (Ctrl+H)");
    JButton togglePerspectivesB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "cog_go.png").getImage()));
    togglePerspectivesB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    togglePerspectivesB.setToolTipText("Show/hide perspectives toolbar (Ctrl+P)");
    final JButton templatesB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "application_view_tile.png").getImage()));
    templatesB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    templatesB.setToolTipText("Load a template layout");
    JButton noteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "note_add.png").getImage()));
    noteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    noteB.setToolTipText("Add a note to the layout (Ctrl+I)");
    JButton selectAllB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "shape_group.png").getImage()));
    selectAllB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    selectAllB.setToolTipText("Select all (Ctrl+A)");
    final JButton zoomInB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "zoom_in.png").getImage()));
    zoomInB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    zoomInB.setToolTipText("Zoom in (Ctrl++)");
    final JButton zoomOutB =
        new JButton(new ImageIcon(loadIcon(ICON_PATH + "zoom_out.png").getImage()));
    zoomOutB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    zoomOutB.setToolTipText("Zoom out (Ctrl+-)");
    JButton undoB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "arrow_undo.png").getImage()));
    undoB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    undoB.setToolTipText("Undo (Ctrl+U)");

    // actions
    final Action saveAction =
        new AbstractAction("Save") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentTabIndex() >= 0) {
              m_mainPerspective.saveLayout(m_mainPerspective.getCurrentTabIndex(), false);
            }
          }
        };
    KeyStroke saveKey = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Save", saveAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(saveKey, "Save");
    saveB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            saveAction.actionPerformed(e);
          }
        });

    KeyStroke saveAsKey = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK);
    final Action saveAsAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            m_mainPerspective.saveLayout(m_mainPerspective.getCurrentTabIndex(), true);
          }
        };
    m_mainPerspective.getActionMap().put("SaveAS", saveAsAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(saveAsKey, "SaveAS");

    saveBB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            saveAsAction.actionPerformed(e);
          }
        });

    final Action openAction =
        new AbstractAction("Open") {
          @Override
          public void actionPerformed(ActionEvent e) {
            m_mainPerspective.loadLayout();
          }
        };
    KeyStroke openKey = KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Open", openAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(openKey, "Open");
    loadB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            openAction.actionPerformed(e);
          }
        });

    final Action newAction =
        new AbstractAction("New") {
          @Override
          public void actionPerformed(ActionEvent e) {
            m_mainPerspective.addUntitledTab();
          }
        };
    KeyStroke newKey = KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("New", newAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(newKey, "New");
    newB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            newAction.actionPerformed(ae);
          }
        });

    final Action selectAllAction =
        new AbstractAction("SelectAll") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null
                && m_mainPerspective.getCurrentLayout().numSteps() > 0) {
              List<StepVisual> newSelected = newSelected = new ArrayList<StepVisual>();
              newSelected.addAll(m_mainPerspective.getCurrentLayout().getRenderGraph());

              // toggle
              if (newSelected.size()
                  == m_mainPerspective.getCurrentLayout().getSelectedSteps().size()) {
                // unselect all
                m_mainPerspective.getCurrentLayout().setSelectedSteps(new ArrayList<StepVisual>());
              } else {
                // select all
                m_mainPerspective.getCurrentLayout().setSelectedSteps(newSelected);
              }
              m_mainPerspective.revalidate();
              m_mainPerspective.repaint();
              m_mainPerspective.notifyIsDirty();
            }
          }
        };
    KeyStroke selectAllKey = KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("SelectAll", selectAllAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(selectAllKey, "SelectAll");
    selectAllB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            selectAllAction.actionPerformed(e);
          }
        });

    final Action zoomInAction =
        new AbstractAction("ZoomIn") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null) {
              int z = m_mainPerspective.getCurrentLayout().getZoomSetting();
              z += 25;
              zoomOutB.setEnabled(true);
              if (z >= 200) {
                z = 200;
                zoomInB.setEnabled(false);
              }
              m_mainPerspective.getCurrentLayout().setZoomSetting(z);
              m_mainPerspective.revalidate();
              m_mainPerspective.repaint();
              m_mainPerspective.notifyIsDirty();
            }
          }
        };
    KeyStroke zoomInKey = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("ZoomIn", zoomInAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(zoomInKey, "ZoomIn");
    zoomInB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            zoomInAction.actionPerformed(e);
          }
        });

    final Action zoomOutAction =
        new AbstractAction("ZoomOut") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null) {
              int z = m_mainPerspective.getCurrentLayout().getZoomSetting();
              z -= 25;
              zoomInB.setEnabled(true);
              if (z <= 50) {
                z = 50;
                zoomOutB.setEnabled(false);
              }
              m_mainPerspective.getCurrentLayout().setZoomSetting(z);
              m_mainPerspective.revalidate();
              m_mainPerspective.repaint();
              m_mainPerspective.notifyIsDirty();
            }
          }
        };
    KeyStroke zoomOutKey = KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("ZoomOut", zoomOutAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(zoomOutKey, "ZoomOut");
    zoomOutB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            zoomOutAction.actionPerformed(e);
          }
        });

    final Action cutAction =
        new AbstractAction("Cut") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null
                && m_mainPerspective.getCurrentLayout().getSelectedSteps().size() > 0) {
              try {
                m_mainPerspective.getCurrentLayout().copySelectedStepsToClipboard();
                m_mainPerspective.getCurrentLayout().removeSelectedSteps();
              } catch (WekaException e1) {
                m_mainPerspective.showErrorDialog(e1);
              }
            }
          }
        };
    KeyStroke cutKey = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Cut", cutAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(cutKey, "Cut");
    cutB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            cutAction.actionPerformed(e);
          }
        });

    final Action deleteAction =
        new AbstractAction("Delete") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null) {
              try {
                m_mainPerspective.getCurrentLayout().removeSelectedSteps();
              } catch (WekaException e1) {
                m_mainPerspective.showErrorDialog(e1);
              }
            }
          }
        };
    KeyStroke deleteKey = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
    m_mainPerspective.getActionMap().put("Delete", deleteAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(deleteKey, "Delete");
    deleteB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            deleteAction.actionPerformed(e);
          }
        });

    final Action copyAction =
        new AbstractAction("Copy") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null
                && m_mainPerspective.getCurrentLayout().getSelectedSteps().size() > 0) {
              try {
                m_mainPerspective.getCurrentLayout().copySelectedStepsToClipboard();
                m_mainPerspective.getCurrentLayout().setSelectedSteps(new ArrayList<StepVisual>());
              } catch (WekaException e1) {
                m_mainPerspective.showErrorDialog(e1);
              }
            }
          }
        };
    KeyStroke copyKey = KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Copy", copyAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(copyKey, "Copy");
    copyB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            copyAction.actionPerformed(e);
          }
        });

    final Action pasteAction =
        new AbstractAction("Paste") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null
                && m_mainPerspective.getPasteBuffer().length() > 0) {
              m_mainPerspective.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
              m_mainPerspective
                  .getCurrentLayout()
                  .setFlowLayoutOperation(VisibleLayout.LayoutOperation.PASTING);
            }
          }
        };
    KeyStroke pasteKey = KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Paste", pasteAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(pasteKey, "Paste");
    pasteB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            pasteAction.actionPerformed(e);
          }
        });

    final Action snapAction =
        new AbstractAction("Snap") {
          @Override
          public void actionPerformed(ActionEvent e) {
            // toggle first
            // snapToGridB.setSelected(!snapToGridB.isSelected());
            if (snapToGridB.isSelected()) {
              if (m_mainPerspective.getCurrentLayout() != null) {
                m_mainPerspective.getCurrentLayout().snapSelectedToGrid();
              }
            }
          }
        };
    KeyStroke snapKey = KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Snap", snapAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(snapKey, "Snap");
    snapToGridB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (snapToGridB.isSelected()) {
              snapAction.actionPerformed(e);
            }
          }
        });

    final Action noteAction =
        new AbstractAction("Note") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null) {
              m_mainPerspective.getCurrentLayout().initiateAddNote();
            }
          }
        };
    KeyStroke noteKey = KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Note", noteAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(noteKey, "Note");
    noteB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            noteAction.actionPerformed(e);
          }
        });

    final Action undoAction =
        new AbstractAction("Undo") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (m_mainPerspective.getCurrentLayout() != null) {
              m_mainPerspective.getCurrentLayout().popAndLoadUndo();
            }
          }
        };
    KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Undo", undoAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(undoKey, "Undo");
    undoB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            undoAction.actionPerformed(e);
          }
        });

    final Action helpAction =
        new AbstractAction("Help") {
          @Override
          public void actionPerformed(ActionEvent e) {
            popupHelp(helpB);
          }
        };
    KeyStroke helpKey = KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Help", helpAction);
    m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(helpKey, "Help");
    helpB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            helpAction.actionPerformed(ae);
          }
        });

    templatesB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // createTemplateMenuPopup();
            PopupMenu popupMenu = new PopupMenu();
            List<String> builtinTemplates =
                m_mainPerspective.getTemplateManager().getBuiltinTemplateDescriptions();
            List<String> pluginTemplates =
                m_mainPerspective.getTemplateManager().getPluginTemplateDescriptions();

            for (final String desc : builtinTemplates) {
              MenuItem menuItem = new MenuItem(desc);
              menuItem.addActionListener(
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      try {
                        Flow templateFlow =
                            m_mainPerspective.getTemplateManager().getTemplateFlow(desc);
                        m_mainPerspective.addTab(desc);
                        m_mainPerspective.getCurrentLayout().setFlow(templateFlow);
                      } catch (WekaException ex) {
                        m_mainPerspective.showErrorDialog(ex);
                      }
                    }
                  });
              popupMenu.add(menuItem);
            }
            if (builtinTemplates.size() > 0 && pluginTemplates.size() > 0) {
              popupMenu.addSeparator();
            }
            for (final String desc : pluginTemplates) {
              MenuItem menuItem = new MenuItem(desc);
              menuItem.addActionListener(
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      try {
                        Flow templateFlow =
                            m_mainPerspective.getTemplateManager().getTemplateFlow(desc);
                        m_mainPerspective.addTab(desc);
                        m_mainPerspective.getCurrentLayout().setFlow(templateFlow);
                      } catch (WekaException ex) {
                        m_mainPerspective.showErrorDialog(ex);
                      }
                    }
                  });
              popupMenu.add(menuItem);
            }
            templatesB.add(popupMenu);
            popupMenu.show(templatesB, 0, 0);
          }
        });
    templatesB.setEnabled(m_mainPerspective.getTemplateManager().numTemplates() > 0);

    final Action togglePerspectivesAction =
        new AbstractAction("Toggle perspectives") {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (!Utils.getDontShowDialog("weka.gui.knowledgeflow.PerspectiveInfo")) {
              JCheckBox dontShow = new JCheckBox("Do not show this message again");
              Object[] stuff = new Object[2];
              stuff[0] =
                  "Perspectives are environments that take over the\n"
                      + "Knowledge Flow UI and provide major additional functionality.\n"
                      + "Many perspectives will operate on a set of instances. Instances\n"
                      + "Can be sent to a perspective by placing a DataSource on the\n"
                      + "layout canvas, configuring it and then selecting \"Send to perspective\"\n"
                      + "from the contextual popup menu that appears when you right-click on\n"
                      + "it. Several perspectives are built in to the Knowledge Flow, others\n"
                      + "can be installed via the package manager.\n";
              stuff[1] = dontShow;

              JOptionPane.showMessageDialog(
                  m_mainPerspective, stuff, "Perspective information", JOptionPane.OK_OPTION);

              if (dontShow.isSelected()) {
                try {
                  Utils.setDontShowDialog("weka.gui.Knowledgeflow.PerspectiveInfo");
                } catch (Exception ex) {
                  // quietly ignore
                }
              }
            }
            if (m_mainPerspective.getMainApplication().isPerspectivesToolBarVisible()) {
              m_mainPerspective.getMainApplication().hidePerspectivesToolBar();
            } else {
              m_mainPerspective.getMainApplication().showPerspectivesToolBar();
            }
            m_mainPerspective.revalidate();
            m_mainPerspective.notifyIsDirty();
          }
        };
    KeyStroke togglePerspectivesKey =
        KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK);
    m_mainPerspective.getActionMap().put("Toggle perspectives", togglePerspectivesAction);
    m_mainPerspective
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(togglePerspectivesKey, "Toggle perspectives");
    togglePerspectivesB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            togglePerspectivesAction.actionPerformed(e);
          }
        });

    addWidgetToToolBar(fixedTools, Widgets.ZOOM_IN_BUTTON.toString(), zoomInB);
    addMenuItemToMenu("View", Widgets.ZOOM_IN_BUTTON.toString(), zoomInAction, zoomInKey);
    addWidgetToToolBar(fixedTools, Widgets.ZOOM_OUT_BUTTON.toString(), zoomOutB);
    addMenuItemToMenu("View", Widgets.ZOOM_OUT_BUTTON.toString(), zoomOutAction, zoomOutKey);
    fixedTools.addSeparator();
    addWidgetToToolBar(fixedTools, Widgets.SELECT_ALL_BUTTON.toString(), selectAllB);
    addWidgetToToolBar(fixedTools, Widgets.CUT_BUTTON.toString(), cutB);
    addMenuItemToMenu("Edit", Widgets.CUT_BUTTON.toString(), cutAction, cutKey);
    addWidgetToToolBar(fixedTools, Widgets.COPY_BUTTON.toString(), copyB);
    addMenuItemToMenu("Edit", Widgets.COPY_BUTTON.toString(), copyAction, copyKey);
    addMenuItemToMenu("Edit", Widgets.PASTE_BUTTON.toString(), pasteAction, pasteKey);
    addWidgetToToolBar(fixedTools, Widgets.DELETE_BUTTON.toString(), deleteB);
    addMenuItemToMenu("Edit", Widgets.DELETE_BUTTON.toString(), deleteAction, deleteKey);
    addWidgetToToolBar(fixedTools, Widgets.PASTE_BUTTON.toString(), pasteB);
    addWidgetToToolBar(fixedTools, Widgets.UNDO_BUTTON.toString(), undoB);
    addMenuItemToMenu("Edit", Widgets.UNDO_BUTTON.toString(), undoAction, undoKey);
    addWidgetToToolBar(fixedTools, Widgets.NOTE_BUTTON.toString(), noteB);
    addMenuItemToMenu("Insert", Widgets.NOTE_BUTTON.toString(), noteAction, noteKey);
    fixedTools.addSeparator();
    addWidgetToToolBar(fixedTools, Widgets.SNAP_TO_GRID_BUTTON.toString(), snapToGridB);
    fixedTools.addSeparator();
    addWidgetToToolBar(fixedTools, Widgets.NEW_FLOW_BUTTON.toString(), newB);
    addMenuItemToMenu("File", Widgets.NEW_FLOW_BUTTON.toString(), newAction, newKey);
    addWidgetToToolBar(fixedTools, Widgets.SAVE_FLOW_BUTTON.toString(), saveB);
    addMenuItemToMenu("File", Widgets.LOAD_FLOW_BUTTON.toString(), openAction, openKey);
    addMenuItemToMenu("File", Widgets.SAVE_FLOW_BUTTON.toString(), saveAction, saveKey);
    addWidgetToToolBar(fixedTools, Widgets.SAVE_FLOW_AS_BUTTON.toString(), saveBB);
    addMenuItemToMenu("File", Widgets.SAVE_FLOW_AS_BUTTON.toString(), saveAction, saveAsKey);
    addWidgetToToolBar(fixedTools, Widgets.LOAD_FLOW_BUTTON.toString(), loadB);
    addWidgetToToolBar(fixedTools, Widgets.TEMPLATES_BUTTON.toString(), templatesB);
    fixedTools.addSeparator();
    addWidgetToToolBar(
        fixedTools, Widgets.TOGGLE_PERSPECTIVES_BUTTON.toString(), togglePerspectivesB);
    addWidgetToToolBar(fixedTools, Widgets.HELP_BUTTON.toString(), helpB);
    Dimension d = undoB.getPreferredSize();
    Dimension d2 = fixedTools.getMinimumSize();
    Dimension d3 = new Dimension(d2.width, d.height + 4);
    fixedTools.setPreferredSize(d3);
    fixedTools.setMaximumSize(d3);
    fixedTools.setFloatable(false);
    add(fixedTools, BorderLayout.EAST);
  }