/** Enalbe all the view history related toolbar icons. */
 public void enableHistoryButtons() {
   pbBack.setEnabled(history.canGoBack());
   pbShowBackHistory.setEnabled(history.canGoBack());
   pbForward.setEnabled(history.canGoForward());
   pbShowForwardHistory.setEnabled(history.canGoForward());
   tbrToolBar.repaint();
 }
  /** Display the forwards window history in a menu. */
  private void onShowForwardHistory() {

    UIScrollableMenu hist =
        new UIScrollableMenu(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"),
            0); //$NON-NLS-1$

    Vector views = history.getForwardHistory();
    int currentIndex = history.getCurrentPosition();

    int count = views.size();
    if (count == 0) return;

    JMenuItem item = null;
    for (int i = 0; i < count; i++) {
      View view = (View) views.elementAt(i);
      item = new JMenuItem(view.getLabel());

      final View fview = view;
      final int fi = (currentIndex + 1) + i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel());
            }
          });

      hist.add(item);
    }

    JPopupMenu pop = hist.getPopupMenu();
    pop.pack();

    Point loc = pbShowForwardHistory.getLocation();
    Dimension size = pbShowForwardHistory.getSize();
    Dimension popsize = hist.getPreferredSize();
    Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop());

    int x = 0;
    int y = 0;
    if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x + size.width;
      y = finalP.y;
    } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x - popsize.width;
      y = finalP.y;
    } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y + size.width;
    } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y - popsize.height;
    }

    hist.setPopupMenuVisible(true);
    pop.show(oParent.getDesktop(), x, y);
  }
  /**
   * Create a new instance of UIToolBarMain, with the given properties.
   *
   * @param oManager the IUIToolBarManager that is managing this toolbar.
   * @param parent the parent frame for the application.
   * @param nType the unique identifier for this toolbar.
   * @param isSimple is the user in simple interface mode. True for yes, false for advanced mode.
   */
  public UIToolBarMain(
      IUIToolBarManager oManager, ProjectCompendiumFrame parent, int nType, boolean isSimple) {

    this.oParent = parent;
    this.oManager = oManager;
    this.nType = nType;
    this.bSimpleInterface = isSimple;

    tbrToolBar =
        new UIToolBar(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.mainToolbar")); // $NON-NLS-1$
    tbrToolBar.setOrientation(DEFAULT_ORIENTATION);

    createToolBarItems();
  }
Exemplo n.º 4
0
 /**
  * Enable/disable the toolbar.
  *
  * @param enabled true to enable, false to disable.
  */
 public void setEnabled(boolean enabled) {
   tbrToolBar.setEnabled(enabled);
 }
Exemplo n.º 5
0
  /**
   * Does Nothing
   *
   * @param selected, true to enable, false to disable.
   */
  public void setNodeOrLinkSelected(boolean selected) {
    if (tbrToolBar != null) {

      UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame();
      if (selected && frame instanceof UIMapViewFrame) {
        UIMapViewFrame oMapFrame = (UIMapViewFrame) frame;
        UIViewPane pane = oMapFrame.getViewPane();

        int nLinkCount = pane.getNumberOfSelectedLinks();
        if (nLinkCount == 0) return;

        bJustSetting = true;

        int i = 0;
        UILink link = null;
        LinkProperties linkProps = null;
        boolean bDefaultLinkStyle = false;
        boolean bDefaultLinkDashed = false;
        boolean bDefaultLinkWeight = false;
        boolean bDefaultLinkColour = false;
        boolean bDefaultArrowType = false;

        LinkProperties defaultprops = UIUtilities.getLinkProperties("");
        int linkstyle = defaultprops.getLinkStyle();
        int linkdashed = defaultprops.getLinkDashed();
        int linkweight = defaultprops.getLinkWeight();
        int linkcolour = defaultprops.getLinkColour();
        int arrowtype = defaultprops.getArrowType();

        for (Enumeration e = pane.getSelectedLinks(); e.hasMoreElements(); ) {
          link = (UILink) e.nextElement();
          linkProps = link.getLinkProperties();
          if (i == 0) {
            linkstyle = linkProps.getLinkStyle();
            linkdashed = linkProps.getLinkDashed();
            linkweight = linkProps.getLinkWeight();
            linkcolour = linkProps.getLinkColour();
            arrowtype = linkProps.getArrowType();
            i++;
          } else {
            if (arrowtype != linkProps.getArrowType()) {
              bDefaultArrowType = true;
            }
            if (linkstyle != linkProps.getLinkStyle()) {
              bDefaultLinkStyle = true;
            }
            if (linkdashed != linkProps.getLinkDashed()) {
              bDefaultLinkDashed = true;
            }
            if (linkweight != linkProps.getLinkWeight()) {
              bDefaultLinkWeight = true;
            }
            if (linkcolour != linkProps.getLinkColour()) {
              bDefaultLinkColour = true;
            }
          }
        }

        tbrToolBar.setEnabled(true);

        if (bDefaultLinkColour) {
          selectedLinkColour = new Color(defaultprops.getLinkColour());
        } else {
          selectedLinkColour = new Color(linkcolour);
        }

        linkColourPanel.setEnabled(true);
        txtLinkColour.setEnabled(true);

        cbLineWeight.setEnabled(true);
        if (bDefaultLinkWeight) {
          cbLineWeight.setSelectedIndex(defaultprops.getLinkWeight() - 1);
        } else {
          cbLineWeight.setSelectedIndex(linkweight - 1);
        }

        cbArrows.setEnabled(true);
        if (bDefaultArrowType) {
          cbArrows.setSelectedIndex(defaultprops.getArrowType());
        } else {
          cbArrows.setSelectedIndex(arrowtype);
        }

        cbLinkStyle.setEnabled(true);
        if (bDefaultLinkStyle) {
          cbLinkStyle.setSelectedIndex(defaultprops.getLinkStyle());
        } else {
          cbLinkStyle.setSelectedIndex(linkstyle);
        }

        cbLinkDashed.setEnabled(true);
        if (bDefaultLinkDashed) {
          cbLinkDashed.setSelectedIndex(defaultprops.getLinkDashed());
        } else {
          cbLinkDashed.setSelectedIndex(linkdashed);
        }

        bJustSetting = false;

      } else if (!selected) {

        bJustSetting = true;

        linkColourPanel.setEnabled(false);
        txtLinkColour.setEnabled(false);
        tbrToolBar.setEnabled(false);
        cbArrows.setEnabled(false);
        cbLineWeight.setEnabled(false);
        cbLinkStyle.setEnabled(false);
        cbLinkDashed.setEnabled(false);

        bJustSetting = false;
      }
    }
  }
Exemplo n.º 6
0
 /** Updates the menu when the current database project is closed. */
 public void onDatabaseClose() {
   if (tbrToolBar != null) tbrToolBar.setEnabled(false);
 }
Exemplo n.º 7
0
  /**
   * Create and return the toolbar with the node formatting options.
   *
   * @return UIToolBar, the toolbar with all the node formatting options.
   */
  private UIToolBar createToolBar(int orientation) {

    tbrToolBar =
        new UIToolBar(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.name"),
            UIToolBar.NORTHSOUTH); // $NON-NLS-1$
    tbrToolBar.setOrientation(orientation);
    tbrToolBar.setEnabled(false);
    CSH.setHelpIDString(tbrToolBar, "toolbars.formatlink"); // $NON-NLS-1$

    GridBagLayout grid = new GridBagLayout();
    linkPanel = new JPanel(grid);
    linkColourPanel = new JPanel(new BorderLayout());
    linkColourPanel.setBackground(Color.black);

    JLabel label = new JLabel(" "); // $NON-NLS-1$
    GridBagConstraints con5 = new GridBagConstraints();
    con5.fill = GridBagConstraints.NONE;
    con5.anchor = GridBagConstraints.CENTER;
    grid.addLayoutComponent(label, con5);
    linkPanel.add(label);

    txtLinkColour = new JLabel(UIImages.get(BACKGROUND_COLOUR));
    txtLinkColour.setBorder(null);
    txtLinkColour.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE,
            "UIToolBarFormatLink.selectLinkColour")); //$NON-NLS-1$
    txtLinkColour.setEnabled(false);
    txtLinkColour.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            int clickCount = e.getClickCount();
            if (clickCount == 1 && txtLinkColour.isEnabled()) {
              onUpdateLinkColour(linkColourPanel.getBackground().getRGB());
            }
          }
        });
    linkColourPanel.add(txtLinkColour, BorderLayout.CENTER);

    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.NONE;
    con.anchor = GridBagConstraints.CENTER;
    grid.addLayoutComponent(linkColourPanel, con);
    linkPanel.add(linkColourPanel);

    btLinkColour = new UIImageButton(UIImages.get(RIGHT_ARROW_ICON));
    btLinkColour.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            int clickCount = e.getClickCount();
            if (clickCount == 1 && txtLinkColour.isEnabled()) {
              if (oColorChooserDialog != null) {
                oColorChooserDialog.setColour(selectedLinkColour);
              } else {
                oColorChooserDialog =
                    new UIColorChooserDialog(ProjectCompendium.APP, selectedLinkColour);
              }
              oColorChooserDialog.setVisible(true);
              Color oColour = oColorChooserDialog.getColour();
              oColorChooserDialog.setVisible(false);
              if (oColour != null) {
                linkColourPanel.setBackground(oColour);
                onUpdateLinkColour(oColour.getRGB());
              }
            }
          }
        });
    linkPanel.add(btLinkColour);

    label = new JLabel(" "); // $NON-NLS-1$
    GridBagConstraints con4 = new GridBagConstraints();
    con4.fill = GridBagConstraints.NONE;
    con4.anchor = GridBagConstraints.CENTER;
    grid.addLayoutComponent(label, con4);
    linkPanel.add(label);

    tbrToolBar.add(linkPanel);
    CSH.setHelpIDString(txtLinkColour, "toolbars.formatlink"); // $NON-NLS-1$

    tbrToolBar.add(createWeightChoiceBox());
    tbrToolBar.add(createArrowChoiceBox());
    tbrToolBar.add(createLinkStyleChoiceBox());
    tbrToolBar.add(createLinkDashedChoiceBox());

    return tbrToolBar;
  }
  /**
   * Creates and return the main toolbar (for example, cut/copy/paste/open/close etc.).
   *
   * @return UIToolBar, the toolbar with all the main options.
   */
  private UIToolBar createToolBarItems() {

    if (!bSimpleInterface) {
      pbOpen =
          tbrToolBar.createToolBarButton(
              LanguageProperties.getString(
                  LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.open"),
              UIImages.get(OPEN_ICON)); // $NON-NLS-1$
      pbOpen.addActionListener(this);
      pbOpen.setEnabled(false);
      tbrToolBar.add(pbOpen);
      CSH.setHelpIDString(pbOpen, "toolbars.main"); // $NON-NLS-1$

      pbClose =
          tbrToolBar.createToolBarButton(
              LanguageProperties.getString(
                  LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.close"),
              UIImages.get(CLOSE_ICON)); // $NON-NLS-1$
      pbClose.addActionListener(this);
      pbClose.setEnabled(true);
      tbrToolBar.add(pbClose);
      CSH.setHelpIDString(pbClose, "toolbars.main"); // $NON-NLS-1$

      tbrToolBar.addSeparator();
    }

    pbCut =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.cut"),
            UIImages.get(CUT_ICON)); // $NON-NLS-1$
    pbCut.addActionListener(this);
    pbCut.setEnabled(false);
    tbrToolBar.add(pbCut);
    CSH.setHelpIDString(pbCut, "toolbars.main"); // $NON-NLS-1$

    pbCopy =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.copy"),
            UIImages.get(COPY_ICON)); // $NON-NLS-1$
    pbCopy.addActionListener(this);
    pbCopy.setEnabled(false);
    tbrToolBar.add(pbCopy);
    CSH.setHelpIDString(pbCopy, "toolbars.main"); // $NON-NLS-1$

    pbPaste =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.paste"),
            UIImages.get(PASTE_ICON)); // $NON-NLS-1$
    pbPaste.addActionListener(this);
    pbPaste.setEnabled(false);
    tbrToolBar.add(pbPaste);
    CSH.setHelpIDString(pbPaste, "toolbars.main"); // $NON-NLS-1$

    pbDelete =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.delete"),
            UIImages.get(DELETE_ICON)); // $NON-NLS-1$
    pbDelete.addActionListener(this);
    pbDelete.setEnabled(false);
    tbrToolBar.add(pbDelete);
    CSH.setHelpIDString(pbDelete, "toolbars.main"); // $NON-NLS-1$

    tbrToolBar.addSeparator();

    pbUndo =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.undo"),
            UIImages.get(UNDO_ICON)); // $NON-NLS-1$
    pbUndo.addActionListener(this);
    pbUndo.setEnabled(false);
    tbrToolBar.add(pbUndo);
    CSH.setHelpIDString(pbUndo, "toolbars.main"); // $NON-NLS-1$

    pbRedo =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.redo"),
            UIImages.get(REDO_ICON)); // $NON-NLS-1$
    pbRedo.addActionListener(this);
    pbRedo.setEnabled(false);
    tbrToolBar.add(pbRedo);
    CSH.setHelpIDString(pbRedo, "toolbars.main"); // $NON-NLS-1$

    tbrToolBar.addSeparator();

    pbShowBackHistory =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.backTo"),
            UIImages.get(PREVIOUS_ICON)); // $NON-NLS-1$
    pbShowBackHistory.addActionListener(this);
    pbShowBackHistory.setEnabled(false);
    tbrToolBar.add(pbShowBackHistory);
    CSH.setHelpIDString(pbShowBackHistory, "toolbars.main"); // $NON-NLS-1$

    pbBack =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.back"),
            UIImages.get(BACK_ICON)); // $NON-NLS-1$
    pbBack.addActionListener(this);
    pbBack.setEnabled(false);
    tbrToolBar.add(pbBack);
    CSH.setHelpIDString(pbBack, "toolbars.main"); // $NON-NLS-1$

    pbForward =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forward"),
            UIImages.get(FORWARD_ICON)); // $NON-NLS-1$
    pbForward.addActionListener(this);
    pbForward.setEnabled(false);
    tbrToolBar.add(pbForward);
    CSH.setHelpIDString(pbForward, "toolbars.main"); // $NON-NLS-1$

    pbShowForwardHistory =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardTo"),
            UIImages.get(NEXT_ICON)); // $NON-NLS-1$
    pbShowForwardHistory.addActionListener(this);
    pbShowForwardHistory.setEnabled(false);
    tbrToolBar.add(pbShowForwardHistory);
    CSH.setHelpIDString(pbShowForwardHistory, "toolbars.main"); // $NON-NLS-1$

    tbrToolBar.addSeparator();

    pbImageRollover =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.imageRollover"),
            UIImages.get(IMAGE_ROLLOVER_ICON)); // $NON-NLS-1$
    pbImageRollover.addActionListener(this);
    pbImageRollover.setEnabled(true);
    tbrToolBar.add(pbImageRollover);
    CSH.setHelpIDString(pbImageRollover, "toolbars.main"); // $NON-NLS-1$

    pbSearch =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.search"),
            UIImages.get(SEARCH_ICON)); // $NON-NLS-1$
    pbSearch.addActionListener(this);
    pbSearch.setEnabled(true);
    tbrToolBar.add(pbSearch);
    CSH.setHelpIDString(pbSearch, "toolbars.main"); // $NON-NLS-1$

    pbHelp =
        tbrToolBar.createToolBarButton(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.helpOnItem"),
            UIImages.get(HELP_ICON)); // $NON-NLS-1$
    if (((UIToolBarManager) oManager).getHelpBroker() != null) {
      pbHelp.addActionListener(
          new CSH.DisplayHelpAfterTracking(((UIToolBarManager) oManager).getHelpBroker()));
    }

    pbHelp.setEnabled(true);
    tbrToolBar.add(pbHelp);

    return tbrToolBar;
  }
 /**
  * If true, redraw the simple form of this menu, else redraw the complex form.
  *
  * @param isSimple true for the simple menu, false for the advanced.
  */
 public void setIsSimple(boolean isSimple) {
   bSimpleInterface = isSimple;
   tbrToolBar.removeAll();
   createToolBarItems();
 }