/** Update the tree to display only a specific root. */ public void update(EntityLibrary root) throws IllegalActionException { if (isDebugging) { log.debug("update(" + root.getName() + " " + root.getClass().getName() + ")"); } this.removeAll(); trimmedLibrary = new VisibleTreeModel(root); AnnotatedPTree rTree = new AnnotatedPTree(trimmedLibrary, this); MouseListener mListener = new LibraryPopupListener(rTree); rTree.setMouseListener(mListener); if (treeSingleSelectionlistener != null) { rTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); rTree.addTreeSelectionListener(treeSingleSelectionlistener); } rTree.initAnotatedPTree(); resultsTree = rTree; JScrollPane newpane = new JScrollPane(resultsTree); newpane.setPreferredSize(new Dimension(200, 200)); this.add(newpane, BorderLayout.CENTER); // add the search results counter stuff resultCounterPane = new JPanel(); resultCounterPane.setBackground(TabManager.BGCOLOR); resultCounterPane.setLayout(new BorderLayout()); resultCounterLabel = new JLabel(""); resultCounterPane.removeAll(); resultCounterPane.add(resultCounterLabel, BorderLayout.CENTER); this.add(resultCounterPane, BorderLayout.SOUTH); this.repaint(); this.validate(); }
/** * this method allows the search results to be updated in the panel * * @param results the results to update to * @exception IllegalActionException Description of the Exception */ public void update(LibrarySearchResults results) throws IllegalActionException { if (isDebugging) { log.debug("update(" + results + ")"); } this.results = results; int resultcount; if (results == null || results.size() == 0) { resultcount = 0; } else { resultcount = results.size(); } this.removeAll(); // add the results if there are any if (resultcount > 0) { // add the results tree. EntityLibrary newRoot = new SearchEntityLibrary(workspace); try { newRoot.setName( StaticResources.getDisplayString("components.searchResults", "Search Results")); } catch (IllegalActionException iae) { throw iae; } catch (NameDuplicationException nde) { throw new IllegalActionException("name duplication exception: " + nde); } buildResultTree(newRoot); trimmedLibrary = new VisibleTreeModel(newRoot); AnnotatedPTree rTree = new AnnotatedPTree(trimmedLibrary, this); MouseListener mListener = new LibraryPopupListener(rTree); rTree.setMouseListener(mListener); if (treeSingleSelectionlistener != null) { rTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); rTree.addTreeSelectionListener(treeSingleSelectionlistener); } rTree.initAnotatedPTree(); resultsTree = rTree; rTree.setShowsRootHandles(false); JScrollPane newpane = new JScrollPane(resultsTree); newpane.setPreferredSize(new Dimension(200, 200)); this.add(newpane, BorderLayout.CENTER); expandAll(resultsTree); } else { // if there are no results, just add the library back if (library.getModel() != null) { library.setModel(new NoRemoteComponentsTreeModel(library.getModel())); } this.add(new JScrollPane(library), BorderLayout.CENTER); } // add the search results counter stuff resultCounterPane = new JPanel(); resultCounterPane.setBackground(TabManager.BGCOLOR); resultCounterPane.setLayout(new BorderLayout()); resultCounterLabel = new JLabel( resultcount + " " + StaticResources.getDisplayString("components.resultsFound", "results found.")); resultCounterPane.removeAll(); resultCounterPane.add(resultCounterLabel, BorderLayout.CENTER); this.add(resultCounterPane, BorderLayout.SOUTH); this.repaint(); this.validate(); }