* @param searchMenu the actual search menu that needs to be set up.
*/
protected void setupSearchMenu(JMenu searchMenu)
{
final SearchModel sm = new SearchModel();
searchMenu.removeAll();
ArrayList list = sm.getFilterNames(SearchModel.FULLNAMES); //TE: get the full names of the saved search filters.
Object names[] = list.toArray();
Arrays.sort(names, new SearchModel.StringComparator()); //TE: sort the list alphabetically.
ActionListener searchListener = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JMenuItem item = (JMenuItem)e.getSource();
if (item == search)
{
tree = jxplorer.getActiveTree();
tree.openSearch(); //TE: open the search window (via Smart Tree).
}
else if (item == deleteFilter)
{
if (sm.getFilterNames(SearchModel.ALLFILTERS).size()==0)
{
JOptionPane.showMessageDialog(jxplorer, CBIntText.get("There are no filters available to delete."), CBIntText.get("Nothing to Delete"), JOptionPane.INFORMATION_MESSAGE );
return;
}
else
{
DeleteFilterGUI dfg = new DeleteFilterGUI(jxplorer); //TE: open the delete filter dialog.
dfg.setVisible(true);
}
}
else if (item == attrList)
{
ReturnAttributesDialog rad = new ReturnAttributesDialog(jxplorer);
rad.setVisible(true);
}
else
{
doSearch(item.getText(), ((myJMenuItem)item).getToolTipText());
}
jxplorer.repaint();
}
};
search = setMenuItem(searchMenu, searchListener,
new String[] {CBIntText.get("Search Dialog"), "Ctrl+F", CBIntText.get("Search the directory."), "E", Theme.getInstance().getDirImages()+"find.gif"} );
deleteFilter = setMenuItem(searchMenu, searchListener,
new String[] {CBIntText.get("Delete Filter"), "", CBIntText.get("Delete an existing filter."), "E", Theme.getInstance().getDirImages()+"delete.gif"} );
attrList = setMenuItem(searchMenu, searchListener,
new String[] {CBIntText.get("Return Attribute Lists"), "", CBIntText.get("Opens a dialog that lets you manage the attributes that you wish to be returned in a search."), "E", Theme.getInstance().getDirImages()+"return_attrs.gif"} );
if(names.length > 0)
setMenuItem(searchMenu, searchListener, new String[] {"-", "", "", "", ""} );
ButtonRegister br = JXplorer.getButtonRegister();
br.registerItem(br.SEARCH, search);
String[] searchValues = new String[names.length];
String[] searchNames = new String[names.length];
for(int i=0; i<names.length;i++)
{
String key = names[i].toString();
searchNames[i] = key;
searchValues[i] = sm.getLDAPFilter(searchNames[i]);
searchNames[i] = searchNames[i].startsWith("JXFilter") ? searchNames[i].substring(9) : searchNames[i].substring(13); //TE: cut the prefix off (e.g: either 'JXFilter' or 'JXTextFilter').
}
if (names.length>15) //TE: add a scrollable list rather than a blown out menu!
{