Beispiel #1
0
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
Beispiel #2
0
  /** Creates new ForwardAction */
  public ForwardAction(Object control) {
    super(control, NAME);
    if (control instanceof JHelp) {
      JHelp help = (JHelp) control;
      historyModel = help.getHistoryModel();
      historyModel.addHelpHistoryModelListener(this);

      setEnabled(historyModel.getIndex() > 0);

      putValue("icon", UIManager.getIcon(NAME + ".icon"));

      Locale locale = null;
      try {
        locale = help.getModel().getHelpSet().getLocale();
      } catch (NullPointerException npe) {
        locale = Locale.getDefault();
      }
      putValue("tooltip", HelpUtilities.getString(locale, "tooltip." + NAME));
      putValue("access", HelpUtilities.getString(locale, "access." + NAME));
    }
  }
Beispiel #3
0
  public void installUI(JComponent c) {
    searchnav = (JHelpSearchNavigator) c;
    HelpModel helpmodel = searchnav.getModel();

    searchnav.setLayout(new BorderLayout());
    searchnav.addPropertyChangeListener(this);
    searchnav.addComponentListener(this);
    if (helpmodel != null) {
      helpmodel.addHelpModelListener(this);
    }

    JLabel search =
        new JLabel(HelpUtilities.getString(HelpUtilities.getLocale(c), "search.findLabel"));
    searchparams = new JTextField("", 20);
    search.setLabelFor(searchparams);
    searchparams.addActionListener(searchAction);

    JPanel box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(search);
    box.add(searchparams);

    searchnav.add("North", box);
    topNode = new DefaultMutableTreeNode();
    lastTOCnode = null;
    tree = new JTree(topNode);
    // public String convertValueToText(Object val
    TreeSelectionModel tsm = tree.getSelectionModel();
    tsm.addTreeSelectionListener(this);
    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);
    sp = new JScrollPane();
    sp.getViewport().add(tree);
    searchnav.add("Center", sp);
    reloadData();
  }