예제 #1
0
  /**
   * Reloads data from new model, creates new search engine to search in new model if model contains
   * view with the same name
   */
  private void reloadData(HelpModel model) {
    debug("reloadData using new model");
    helpsearch = null;
    SearchView view = null;

    newHelpSet = model.getHelpSet();
    SearchView oldView = (SearchView) searchnav.getNavigatorView();
    String oldName = oldView.getName();
    NavigatorView[] navViews = newHelpSet.getNavigatorViews();
    for (int i = 0; i < navViews.length; i++) {
      if ((navViews[i].getName()).equals(oldName)) {
        NavigatorView tempView = navViews[i];
        if (tempView instanceof SearchView) {
          view = (SearchView) tempView;
          break;
        }
      }
    }

    if (view == null) return;

    topNode.removeAllChildren();
    searchnav.setSearchEngine(new MergingSearchEngine(view));

    setCellRenderer(view, tree);
    // add all subhelpsets
    addSubHelpSets(newHelpSet);
  }
예제 #2
0
 /** Indicates that there is new search data to use. */
 private void reloadData() {
   helpsearch = null;
   setCellRenderer(searchnav.getNavigatorView(), tree);
   // add all subhelpsets
   HelpModel model = searchnav.getModel();
   if (model != null) {
     addSubHelpSets(model.getHelpSet());
   }
 }
예제 #3
0
 /**
  * Adds subhelpsets
  *
  * @param hs The HelpSet which subhelpsets will be added
  */
 protected void addSubHelpSets(HelpSet hs) {
   for (Enumeration e = hs.getHelpSets(); e.hasMoreElements(); ) {
     HelpSet ehs = (HelpSet) e.nextElement();
     // merge views
     NavigatorView[] views = ehs.getNavigatorViews();
     for (int i = 0; i < views.length; i++) {
       if (searchnav.canMerge(views[i])) searchnav.merge(views[i]);
     }
     addSubHelpSets(ehs);
   }
 }
예제 #4
0
  public void uninstallUI(JComponent c) {
    HelpModel helpmodel = searchnav.getModel();

    searchnav.removeComponentListener(this);
    searchnav.removePropertyChangeListener(this);
    TreeSelectionModel tsm = tree.getSelectionModel();
    tsm.removeTreeSelectionListener(this);
    searchnav.setLayout(null);
    searchnav.removeAll();

    if (helpmodel != null) {
      helpmodel.removeHelpModelListener(this);
    }
    searchnav = null;
  }
예제 #5
0
 public BasicSearchNavigatorUI(JHelpSearchNavigator b) {
   ImageIcon icon = getImageIcon(b.getNavigatorView());
   if (icon != null) {
     setIcon(icon);
   } else {
     setIcon(UIManager.getIcon("SearchNav.icon"));
   }
 }
예제 #6
0
  /**
   * Processes an idChanged event. Search is different from all other navigators in that you while
   * search tree is synchronized the highlighting doesn't occur unless selected from the search
   * navigator.
   */
  public void idChanged(HelpModelEvent e) {
    ID id = e.getID();
    URL url = e.getURL();
    HelpModel helpModel = searchnav.getModel();
    debug("idChanged(" + e + ")");

    if (e.getSource() != helpModel) {
      debug("Internal inconsistency!");
      debug("  " + e.getSource() + " != " + helpModel);
      throw new Error("Internal error");
    }

    TreePath s = tree.getSelectionPath();
    if (s != null) {
      Object o = s.getLastPathComponent();
      // should require only a TreeNode
      if (o instanceof DefaultMutableTreeNode) {
        DefaultMutableTreeNode tn = (DefaultMutableTreeNode) o;
        SearchTOCItem item = (SearchTOCItem) tn.getUserObject();
        if (item != null) {
          ID nId = item.getID();
          if (nId != null && nId.equals(id)) {
            return;
          }
        }
      }
    }

    DefaultMutableTreeNode node = findIDorURL(topNode, id, url);
    if (node == null) {
      // node doesn't exist. Need to clear the selection.
      debug("node didn't exist");
      tree.clearSelection();
      return;
    }
    TreePath path = new TreePath(node.getPath());
    tree.expandPath(path);
    tree.setSelectionPath(path);
    tree.scrollPathToVisible(path);
  }
예제 #7
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();
  }