Ejemplo n.º 1
0
  /**
   * Constructs the button with the given node type and image prefix. If the node type is "Select",
   * constructs a button that allows nodes to be selected and moved. If the node type is "Edge",
   * constructs a button that allows edges to be drawn. For other node types, constructs buttons
   * that allow those type of nodes to be added to the workbench. If a non-null image prefix is
   * provided, images for <prefix>Up.gif, <prefix>Down.gif, <prefix>Off.gif and <prefix>Roll.gif are
   * loaded from the /images directory relative to this compiled class and used to provide up, down,
   * off, and rollover images for the constructed button. On construction, nodes are mapped to their
   * node types in the Map, <code>nodeTypes</code>. Listeners are added to the node.
   *
   * @param buttonInfo contains the info needed to construct the button.
   */
  private JToggleButton constructButton(ButtonInfo buttonInfo) {
    String imagePrefix = buttonInfo.getImagePrefix();

    if (imagePrefix == null) {
      throw new NullPointerException("Image prefix must not be null.");
    }

    JToggleButton button = new JToggleButton();

    button.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            setShiftDown(e.isShiftDown());
            //                setControlDown(e.isControlDown());
          }
        });

    if ("Select".equals(buttonInfo.getNodeTypeName())) {
      button.setIcon(new ImageIcon(ImageUtils.getImage(this, "move.gif")));
    } else if ("Edge".equals(buttonInfo.getNodeTypeName())) {
      button.setIcon(new ImageIcon(ImageUtils.getImage(this, "flow.gif")));
    } else {
      button.setName(buttonInfo.getNodeTypeName());
      button.setText("<html><center>" + buttonInfo.getDisplayName() + "</center></html>");
    }

    button.setMaximumSize(new Dimension(110, 40)); // For a vertical box.
    button.setToolTipText(buttonInfo.getToolTipText());
    this.nodeTypes.put(button, buttonInfo.getNodeTypeName());

    return button;
  }
  public void addColorChooserPanel(final AbstractColorChooserPanel ccp) {
    final String displayName = ccp.getDisplayName();
    if (displayName == null) {
      // Return if we haven't initialized yet
      return;
    }

    if (ccp.getClass()
        .getName()
        .equals("ch.randelshofer.quaqua.colorchooser.Quaqua15ColorPicker")) {
      northPanel.add(ccp, BorderLayout.WEST);
    } else {
      Icon displayIcon = ccp.getLargeDisplayIcon();
      JToggleButton tb = new JToggleButton(null, displayIcon);
      tb.setToolTipText(displayName);
      tb.setFocusable(false);
      tb.setHorizontalTextPosition(SwingConstants.CENTER);
      tb.setVerticalTextPosition(SwingConstants.BOTTOM);
      tb.setFont(UIManager.getFont("ColorChooser.font"));
      tb.putClientProperty("Quaqua.Button.style", "toolBarTab");
      JPanel centerView = new JPanel(new BorderLayout());
      centerView.add(ccp);
      chooserPanelHolder.add(centerView, displayName);
      toolBarButtonGroup.add(tb);
      toolBar.add(tb);

      if (toolBar.getComponentCount() == 1
          || lastSelectedChooserName != null && lastSelectedChooserName.equals(displayName)) {
        tb.setSelected(true);
        CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
        cl.show(chooserPanelHolder, displayName);
      }

      tb.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              if (evt.getStateChange() == ItemEvent.SELECTED) {
                CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
                cl.show(chooserPanelHolder, displayName);
                lastSelectedChooserName = displayName;
              }
            }
          });
    }
  }
Ejemplo n.º 3
0
  private void initToolbar() {
    JToolBar tbTraceFilters = new JToolBar();
    tbTraceFilters.setFloatable(false);
    tbTraceFilters.setRollover(true);

    tbTraceFilters.add(new JLabel("Min time:"));
    txtMinTime = new JTextField(4);
    tbTraceFilters.add(txtMinTime);

    JButton btnFilterByTime = new JButton(new FilterByTimeAction());
    btnFilterByTime.setFocusable(false);
    btnFilterByTime.setToolTipText("Filter by trace execution time");
    tbTraceFilters.add(btnFilterByTime);

    tbTraceFilters.addSeparator();

    btnFilterErrors = new JToggleButton(new FilterByErrorAction());
    btnFilterErrors.setFocusable(false);
    btnFilterErrors.setToolTipText("Show only traces with errors");
    tbTraceFilters.add(btnFilterErrors);

    tbTraceFilters.addSeparator();

    cmbTraceType = new JComboBox();
    cmbTraceType.addItem("*");

    cmbTraceType.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String item = (String) e.getItem();
              traceLabel = "*".equals(item) ? null : item;
              tbmTraces.setDataSet(dataSet, traceFilter);
            }
          }
        });

    tbTraceFilters.add(cmbTraceType);

    add(tbTraceFilters, BorderLayout.NORTH);
  }
  public JMovieControlAqua() {
    // Set the background color to the border color of the buttons.
    // This way the toolbar won't look too ugly when the buttons
    // are displayed before they have been loaded completely.
    // setBackground(new Color(118, 118, 118));
    setBackground(Color.WHITE);

    Dimension buttonSize = new Dimension(16, 16);
    GridBagLayout gridbag = new GridBagLayout();
    Insets margin = new Insets(0, 0, 0, 0);
    setLayout(gridbag);
    GridBagConstraints c;

    ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels");
    colorCyclingButton = new JToggleButton();
    colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText"));
    colorCyclingButton.addActionListener(this);
    colorCyclingButton.setPreferredSize(buttonSize);
    colorCyclingButton.setMinimumSize(buttonSize);
    colorCyclingButton.setVisible(false);
    colorCyclingButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(colorCyclingButton, c);
    add(colorCyclingButton);

    audioButton = new JToggleButton();
    audioButton.setToolTipText(labels.getString("audio.toolTipText"));
    audioButton.addActionListener(this);
    audioButton.setPreferredSize(buttonSize);
    audioButton.setMinimumSize(buttonSize);
    audioButton.setVisible(false);
    audioButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(audioButton, c);
    add(audioButton);

    startButton = new JToggleButton();
    startButton.setToolTipText(labels.getString("play.toolTipText"));
    startButton.addActionListener(this);
    startButton.setPreferredSize(buttonSize);
    startButton.setMinimumSize(buttonSize);
    startButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 1;
    // c.gridy = 0;
    gridbag.setConstraints(startButton, c);
    add(startButton);

    slider = new JMovieSliderAqua();
    c = new GridBagConstraints();
    // c.gridx = 2;
    // c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(slider, c);
    add(slider);

    rewindButton = new JButton();
    rewindButton.setToolTipText(labels.getString("previous.toolTipText"));
    rewindButton.setPreferredSize(buttonSize);
    rewindButton.setMinimumSize(buttonSize);
    rewindButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 3;
    // c.gridy = 0;

    gridbag.setConstraints(rewindButton, c);
    add(rewindButton);
    rewindButton.addActionListener(this);

    forwardButton = new JButton();
    forwardButton.setToolTipText(labels.getString("next.toolTipText"));
    buttonSize = new Dimension(17, 16);
    forwardButton.setPreferredSize(buttonSize);
    forwardButton.setMinimumSize(buttonSize);
    forwardButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 4;
    // c.gridy = 0;
    gridbag.setConstraints(forwardButton, c);
    add(forwardButton);
    forwardButton.addActionListener(this);

    // The spacer is used when the play controls are hidden
    spacer = new JPanel(new BorderLayout());
    spacer.setVisible(false);
    spacer.setPreferredSize(new Dimension(16, 16));
    spacer.setMinimumSize(new Dimension(16, 16));
    spacer.setOpaque(false);
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(spacer, c);
    add(spacer);

    Border border =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.border.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderP.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4))));

    Border westBorder =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWest.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWestP.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4))));

    startButton.setBorder(westBorder);
    colorCyclingButton.setBorder(westBorder);
    audioButton.setBorder(westBorder);
    rewindButton.setBorder(westBorder);
    forwardButton.setBorder(border);
    startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton));
    colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton));
    forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton));

    colorCyclingButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setDisabledIcon(
        new ImageIcon(
            Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png")));
    audioButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png")));
    audioButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png")));
    audioButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png")));
    startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png")));
    startButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png")));
    startButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png")));
    rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png")));
    rewindButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png")));
    forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png")));
    forwardButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png")));

    // Automatic scrolling
    scrollHandler = new ScrollHandler();
    scrollTimer = new Timer(60, scrollHandler);
    scrollTimer.setInitialDelay(300); // default InitialDelay?
    forwardButton.addMouseListener(scrollHandler);
    rewindButton.addMouseListener(scrollHandler);
  }
Ejemplo n.º 5
0
  /**
   * Конструктор
   *
   * @param mediator Посредник родитьельского окна
   */
  public ButtonToolBar(final IGuiMediator mediator) {
    this.mediator = mediator;

    try {
      locale = ((WBDrawing) mediator).getLocalizer();
    } catch (Exception e) {
      logger.debug(e.getMessage(), e);
    }

    mouseMenu = new JPopupMenu();
    imagePanel = new JPanel();
    imagePanel.setLayout(new GridLayout(4, 2));
    mouseMenu.add(imagePanel);
    imagePanel.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            System.out.println("Focus Gained");
          }

          public void focusLost(FocusEvent e) {
            mouseMenu.setVisible(false);
            System.out.println("Focus Lost");
          }
        });

    URL url = ClassLoader.getSystemResource("img/open.gif");
    Icon iconOpen = new ImageIcon(url);
    JButton btnOpen = new JButton(iconOpen);
    btnOpen.setToolTipText(locale.getString("btntoolbar.open"));
    url = ClassLoader.getSystemResource("img/save.gif");
    Icon iconSave = new ImageIcon(url);
    JButton btnSave = new JButton(iconSave);
    btnSave.setToolTipText(locale.getString("btntoolbar.save"));
    url = ClassLoader.getSystemResource("img/undo.gif");
    Icon iconUndo = new ImageIcon(url);
    btnUndo = new JButton(iconUndo);
    btnUndo.setToolTipText(locale.getString("btntoolbar.undo"));
    url = ClassLoader.getSystemResource("img/redo.gif");
    Icon iconRedo = new ImageIcon(url);
    btnRedo = new JButton(iconRedo);
    btnRedo.setToolTipText(locale.getString("btntoolbar.redo"));
    url = ClassLoader.getSystemResource("img/draw.gif");
    Icon iconDraw = new ImageIcon(url);
    btnDraw = new JToggleButton(iconDraw, true);
    btnDraw.setToolTipText(locale.getString("btntoolbar.draw"));
    url = ClassLoader.getSystemResource("img/pen.gif");
    Icon iconPen = new ImageIcon(url);
    btnPen = new JToggleButton(iconPen);
    btnPen.setToolTipText(locale.getString("btntoolbar.pen"));
    url = ClassLoader.getSystemResource("img/calibrate.gif");
    Icon iconCalibrate = new ImageIcon(url);
    btnCalibrate = new JToggleButton(iconCalibrate);
    btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration"));
    url = ClassLoader.getSystemResource("img/gridMove.gif");
    Icon iconGridMove = new ImageIcon(url);

    JToggleButton btnGrigMove = new JToggleButton(iconGridMove);
    url = ClassLoader.getSystemResource("img/hand.gif");
    Icon iconHand = new ImageIcon(url);

    JToggleButton btnHand = new JToggleButton(iconHand);
    btnHand.setToolTipText(locale.getString("btntoolbar.hand"));

    url = ClassLoader.getSystemResource("img/selTool.gif");
    Icon iconSelTool = new ImageIcon(url);
    JToggleButton btnSelTool = new JToggleButton(iconSelTool);

    url = ClassLoader.getSystemResource("img/spline.gif");
    Icon iconQuadTool = new ImageIcon(url);
    btnSpline = new JToggleButton(iconQuadTool);
    btnSpline.setToolTipText(locale.getString("btntoolbar.spline"));

    btnTools = new JToggleButton("T");

    btnTextTool = new JToggleButton("A");

    url = ClassLoader.getSystemResource("img/ruler.gif");
    Icon iconRulerTool = new ImageIcon(url);
    btnRulerTool = new JToggleButton(iconRulerTool);

    url = ClassLoader.getSystemResource("img/sendFile.gif");
    Icon iconSendFile = new ImageIcon(url);
    JToggleButton btnFileTransmit = new JToggleButton(iconSendFile);
    btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit"));
    url = ClassLoader.getSystemResource("img/nodesEdit.gif");
    Icon iconNodesEdit = new ImageIcon(url);

    JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit);
    btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit"));

    JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test"));
    btnTest.setEnabled(false);
    url = ClassLoader.getSystemResource("img/send.gif");
    Icon iconSend = new ImageIcon(url);
    JButton btnSendArq = new JButton(iconSend);
    btnSendArq.setToolTipText(locale.getString("btntoolbar.send"));
    url = ClassLoader.getSystemResource("img/clear.gif");
    Icon iconClear = new ImageIcon(url);
    JButton btnClearTab = new JButton(iconClear);
    btnClearTab.setToolTipText(locale.getString("btntoolbar.clear"));

    JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel"));
    btnRequestModel.setEnabled(false);

    JComboBox cmbTools = new JComboBox();
    cmbTools.addItem("Thick Line");

    cmbTools.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            boolean selected = btnTools.getModel().isSelected();
            if (selected) {
              mode = getToolsMode();
              guiChanged();
            }
          }
        });

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(btnDraw);
    buttonGroup.add(btnPen);
    buttonGroup.add(btnCalibrate);
    buttonGroup.add(btnGrigMove);
    buttonGroup.add(btnHand);
    buttonGroup.add(btnSelTool);
    buttonGroup.add(btnSpline);
    buttonGroup.add(btnTextTool);
    buttonGroup.add(btnRulerTool);
    buttonGroup.add(btnNodesEdit);
    // buttonGroup.add( btnTools );

    btnDraw.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_DRAWING;
            }
            guiChanged();
          }
        });

    btnPen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_PEN;
            }
            guiChanged();
          }
        });

    btnCalibrate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_CALIBRATING;
            }
            guiChanged();
          }
        });

    btnGrigMove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_GRID_MOVING;
            }
            guiChanged();
          }
        });

    btnHand.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_HAND_MAP;
            }
            guiChanged();
          }
        });

    btnSelTool.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_SELECT_TOOL;
            }
            guiChanged();
          }
        });

    btnSpline.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_QUAD_TOOL;
            }
            guiChanged();
          }
        });

    btnTextTool.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_TEXT_TOOL;
            }
            guiChanged();
          }
        });

    btnRulerTool.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_RULER_TOOL;
            }
            guiChanged();
          }
        });

    btnNodesEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_NODES_EDIT;
            }
            guiChanged();
          }
        });

    btnTools.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mode = getToolsMode();
            guiChanged();
          }
        });

    btnOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnOpenPressed();
          }
        });

    btnSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSavePressed();
          }
        });

    btnUndo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnUndoPressed();
          }
        });

    btnRedo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnRedoPressed();
          }
        });

    btnTest.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnTestPressed();
          }
        });

    btnSendArq.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSendModelPressed();
          }
        });

    btnSendArq.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSendArqModelPressed();
          }
        });

    btnClearTab.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnClearTabPressed();
          }
        });

    btnRequestModel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnFileTransmitPressed();
          }
        });

    btnFileTransmit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnFileTransmitPressed();
          }
        });

    add(btnOpen);
    add(btnSave);
    //        add( btnUndo );
    //        add( btnRedo );
    addSeparator();
    // add(lblMode);

    actionButton = new JToggleButton(btnDraw.getIcon());
    actionButton.setToolTipText(btnDraw.getToolTipText());
    actionButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            mouseMenu.show(e.getComponent(), e.getX(), e.getY());
          }
        });
    addButton(btnDraw);
    addButton(btnPen);
    addButton(btnCalibrate);
    // add( btnGrigMove );
    addButton(btnHand);
    // add(btnSelTool);
    addButton(btnSpline);
    addButton(btnNodesEdit);
    // add( btnTextTool );
    addButton(btnRulerTool);
    // addSeparator();
    // add(cmbTools);
    add(actionButton);

    cmbScale = new JComboBox();
    cmbScale.setEditable(true);
    cmbScale.addItem("1:1000");
    cmbScale.addItem("1:2000");
    cmbScale.addItem("1:5000");
    cmbScale.addItem("1:10000");
    cmbScale.addItem("1:25000");
    cmbScale.addItem("1:50000");
    cmbScale.addItem("1:100000");
    cmbScale.setSelectedIndex(3);
    cmbScale.setToolTipText(locale.getString("btntoolbar.scale"));
    cmbScale.setPreferredSize(cmbScale.getMinimumSize());
    cmbScale.setMaximumSize(cmbScale.getMinimumSize());

    cmbScale.addItemListener(new ZoomListener());
    addSeparator();

    chbVisibleGrid = new JCheckBox();
    chbVisibleGrid.setSelected(true);
    chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid"));
    // addSeparator();
    chbVisibleGrid.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            guiChanged();
          }
        });
    add(btnFileTransmit);
    add(btnSendArq);
    add(btnClearTab);
    add(chbVisibleGrid);
    add(cmbScale);
    // addSeparator();
    // add( lblControl );
    // add( btnSend );
    // add( btnRequestModel );
    // add( btnTest );
  }
Ejemplo n.º 6
0
  public PanelSpec(SmedAction dia) {
    dlg = dia;
    setLayout(null);
    add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP));
    add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP));
    add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP));
    add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP));
    add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP));
    add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP));
    add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP));
    add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT));
    add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP));
    add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP));
    add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP));
    add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP));

    categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER);
    categoryLabel.setBounds(new Rectangle(5, 125, 160, 18));
    add(categoryLabel);
    categoryBox = new JComboBox();
    categoryBox.setBounds(new Rectangle(5, 142, 160, 18));
    add(categoryBox);
    categoryBox.setVisible(true);
    categoryBox.addActionListener(alCategoryBox);
    addCatItem("", Cat.NOCAT);
    addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN);
    addCatItem(Messages.getString("Warning"), Cat.SPM_WARN);
    addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF);
    addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT);
    addCatItem(Messages.getString("Cable"), Cat.SPM_CABL);
    addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL);
    addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS);
    addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN);
    addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR);
    addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY);
    addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG);
    addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC);
    addCatItem(Messages.getString("TSS"), Cat.SPM_TSS);
    addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL);
    addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE);
    addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY);
    addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH);
    mooringBox = new JComboBox();
    mooringBox.setBounds(new Rectangle(5, 142, 160, 18));
    add(mooringBox);
    mooringBox.setVisible(false);
    mooringBox.addActionListener(alMooringBox);
    addMorItem("", Cat.NOCAT);
    addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN);
    addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN);
    addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD);
    addMorItem(Messages.getString("Wall"), Cat.MOR_WALL);
    addMorItem(Messages.getString("Post"), Cat.MOR_POST);
    addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR);
    addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE);
    addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO);
    addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY);
    addMorItem(Messages.getString("CALM"), Cat.INB_CALM);
    addMorItem(Messages.getString("SBM"), Cat.INB_SBM);

    topmarkButton.setBounds(new Rectangle(136, 0, 34, 32));
    topmarkButton.setToolTipText(Messages.getString("Topmark"));
    topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
    topmarkButton.addActionListener(alTop);
    add(topmarkButton);

    //		noticeButton.setBounds(new Rectangle(136, 32, 34, 32));
    //		noticeButton.setToolTipText(Messages.getString("Notice"));
    //		noticeButton.setBorder(BorderFactory.createLoweredBevelBorder());
    //		noticeButton.addActionListener(alNotice);
    //		add(noticeButton);

    mooringButton.setBounds(new Rectangle(136, 64, 34, 32));
    mooringButton.setToolTipText(Messages.getString("Mooring"));
    mooringButton.setBorder(BorderFactory.createLoweredBevelBorder());
    mooringButton.addActionListener(alMooring);
    add(mooringButton);
  }
Ejemplo n.º 7
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);
  }