/** 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);
  }
  /** Move forward one item in the window history, if possible, and open the view. */
  private void onForward() {

    View view = history.goForward();
    if (view != null) oParent.addViewToDesktop(view, view.getLabel());

    enableHistoryButtons();
  }
  /** Updates the menu when the current database project is closed. */
  public void onDatabaseClose() {
    if (pbUndo != null) pbUndo.setEnabled(false);
    if (pbRedo != null) pbRedo.setEnabled(false);
    if (pbOpen != null) pbOpen.setEnabled(true);
    if (pbClose != null) pbClose.setEnabled(false);
    if (pbHelp != null) pbHelp.setEnabled(false);
    if (pbSearch != null) pbSearch.setEnabled(false);
    if (pbImageRollover != null) pbImageRollover.setEnabled(false);

    history.clear();
  }
 /**
  * Try to add a View object to the history.
  *
  * @param view com.compendium.core.datamodel.View, the view to add to the history.
  */
 public void addToHistory(View view) {
   history.add(view);
 }
 /**
  * Try to remove a View object from the history.
  *
  * @param view com.compendium.core.datamodel.View, the view to add to the history.
  */
 public void removeFromHistory(View view) {
   history.remove(view);
 }
 /** Clear the view history. */
 public void clearHistory() {
   history.clear();
 }