1 package com.ca.directory.jxplorer.search; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import java.util.*; 6 import java.util.logging.Level ; 7 import java.util.logging.Logger ; 8 import javax.swing.*; 9 import javax.swing.event.*; 10 import javax.swing.border.*; 11 12 import com.ca.directory.jxplorer.*; 13 import com.ca.commons.naming.*; 14 import com.ca.commons.cbutil.*; 15 16 27 public class SearchGUI extends CBDialog 28 { 29 final JXplorer jx; 30 protected JTabbedPane tabbedPane; 31 JCheckBox aliasSearchCheckBox, aliasFindingCheckBox; 32 JTextField baseDNTextField, filterNameTextField; 33 CBJComboBox andOrCombo, searchLevelCombo, returnAttributesCombo; 34 static final String [] andOrArray = new String [] {CBIntText.get("And"), CBIntText.get("Or")}; 35 static final String [] searchLevelArray = new String [] {CBIntText.get("Search Base Object"), CBIntText.get("Search Next Level"), CBIntText.get("Search Full Subtree"),}; 36 static final int BASEOBJECTSEARCH=0, ONELEVELSEARCH=1, FULLSUBTREESEARCH=2; 37 CBButton btnSave, btnLoad, btnMore, btnLess, btnView; 38 BuildFilterPanel build; 39 JoinFilterPanel join; 40 TextFilterPanel text; 41 SearchModel searchModel; 42 String buildName = "Untitled", joinName = "Untitled", textName = "Untitled", dirImages; 43 CBButton[] btnEdit = new CBButton[50]; 44 int buttonCounter = 0; String [] returnAttrs = null; 46 47 private static Logger log = Logger.getLogger(SearchGUI.class.getName()); 48 49 51 57 public SearchGUI(DN baseDN, JXplorer jxplorer) 58 { 59 super(jxplorer, CBIntText.get("Search"), HelpIDs.SEARCH); 60 jx = jxplorer; 61 62 dirImages = JXplorer.getProperty("dir.images"); 63 64 build = new BuildFilterPanel(jx); 65 join = new JoinFilterPanel(getEditButton()); 66 text = new TextFilterPanel(); 67 68 buttonCounter++; 69 searchModel = new SearchModel(); 70 71 CBPanel panel = getMainPanel(baseDN); 72 73 tabbedPane = new JTabbedPane(); 74 75 tabbedPane.addTab(CBIntText.get("Build Filter"), new ImageIcon(dirImages+"build.gif"), build, CBIntText.get("Build a filter from scratch.")); 76 tabbedPane.addTab(CBIntText.get("Join Filters"), new ImageIcon(dirImages+"join.gif"), join, CBIntText.get("Join filters that have been made in the Build tab.")); 77 tabbedPane.addTab(CBIntText.get("Text Filter"), new ImageIcon(dirImages+"text.gif"), text, CBIntText.get("Type or paste a filter into the field in plain text.")); 78 79 OK.setText(CBIntText.get("Search")); 80 81 display.makeHeavy(); 82 display.addln(panel); 83 display.add(tabbedPane); 84 display.makeLight(); 85 display.add(getButtonPanel()); 86 87 CBButton btnAttrs = new CBButton(CBIntText.get("Return Attrs"), CBIntText.get("Select Returning Attributes.")); 88 btnAttrs.addActionListener(new ActionListener(){ 89 public void actionPerformed(ActionEvent e){ 90 ArrayList list = CBListSelector.getSelectedValues(jx, build.getAttributes(), CBIntText.get("Select Returning Attributes"), HelpIDs.SEARCH); 91 if(list!=null) 92 returnAttrs = (String [])list.toArray(new String [list.size()]); 93 }}); 94 95 setSize(550, 400); 96 CBUtility.center(this, jx); 97 98 104 tabbedPane.addChangeListener(new ChangeListener() 105 { 106 public void stateChanged(ChangeEvent e) 107 { 108 int index = tabbedPane.getSelectedIndex(); 109 110 if (index == 0) 111 { 112 filterNameTextField.setText(buildName); 113 setButtons(true); 114 } 115 else if (index == 1) 116 { 117 filterNameTextField.setText(joinName); 118 setButtons(true); 119 } 120 else if (index ==2) 121 { 122 filterNameTextField.setText(textName); 123 setButtons(false); 124 } 125 } 126 }); 127 } 128 129 135 public CBPanel getMainPanel(DN baseDN) 136 { 137 CBPanel panel = new CBPanel(); 138 139 panel.add(new JLabel(CBIntText.get("Filter Name") + ": ")); 141 panel.makeWide(); 142 panel.add(filterNameTextField = new JTextField("Untitled")); 143 panel.makeLight(); 144 panel.newLine(); 145 146 panel.add(new JLabel(CBIntText.get("Start Searching From") + ": ")); 148 panel.makeWide(); 149 if(baseDN == null) 150 panel.add(baseDNTextField = new JTextField("")); 151 else 152 panel.add(baseDNTextField = new JTextField(baseDN.toString())); 153 panel.makeLight(); 154 panel.newLine(); 155 156 CBPanel optionsPanel = new CBPanel(); 158 CBPanel aliasPanel = new CBPanel(); 160 aliasPanel.setBorder(new TitledBorder(CBIntText.get(" Alias Options "))); 161 162 aliasPanel.makeWide(); 163 aliasPanel.addln(aliasSearchCheckBox = new JCheckBox(CBIntText.get("Resolve aliases while searching."))); 164 aliasSearchCheckBox.setToolTipText(CBIntText.get("Resolve aliases while searching.")); 165 aliasPanel.addln(aliasFindingCheckBox = new JCheckBox(CBIntText.get("Resolve aliases when finding base object."))); 166 aliasFindingCheckBox.setToolTipText(CBIntText.get("Resolve aliases when finding base object.")); 167 168 CBPanel searchLevelPanel = new CBPanel(); 170 searchLevelPanel.setBorder(new TitledBorder(CBIntText.get(" Search Level "))); 171 searchLevelPanel.addln(new JLabel(CBIntText.get("Select Search Level: "))); 172 searchLevelPanel.makeWide(); 173 searchLevelPanel.addln(searchLevelCombo = new CBJComboBox(searchLevelArray)); 174 searchLevelCombo.setSelectedIndex(FULLSUBTREESEARCH); 175 176 optionsPanel.add(aliasPanel); 178 optionsPanel.makeWide(); 179 optionsPanel.addln(searchLevelPanel); 180 181 panel.makeWide(); 182 panel.addln(optionsPanel); 183 184 CBPanel returnAttrsPanel = new CBPanel(); 186 returnAttributesCombo = new CBJComboBox(ReturnAttributesDialog.getSavedListNames()); 187 returnAttributesCombo.setSelectedItem(ReturnAttributesDialog.DEFAULT_RETURN_ATTRS); 188 189 returnAttrsPanel.makeLight(); 190 returnAttrsPanel.add(new JLabel(CBIntText.get("Information to retrieve: "))); 191 returnAttrsPanel.makeWide(); 192 returnAttrsPanel.addln(returnAttributesCombo); 193 194 panel.addln(returnAttrsPanel); 195 196 return panel; 197 } 198 199 203 public void setBaseDN(DN baseDN) 204 { 205 if(baseDN != null) 206 baseDNTextField.setText(baseDN.toString()); 207 } 208 209 214 public CBPanel getButtonPanel() 215 { 216 CBPanel panel = new CBPanel(); 217 218 btnMore = new CBButton(CBIntText.get("More"), CBIntText.get("Add a Line to the search window.")); 219 btnMore.addActionListener(new ActionListener(){ 220 public void actionPerformed(ActionEvent e){ 221 if (isFilterValid()) 222 { 223 if (tabbedPane.getSelectedIndex()==0) { 225 build.addFilterRow(); 226 } 227 else if (tabbedPane.getSelectedIndex()==1 && buttonCounter<50) 228 { 229 join.addFilterRow(getEditButton()); 230 buttonCounter++; } 232 } 233 else 234 { 235 showMessage(CBIntText.get("There is an error in the filter; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly,\nthen try to add more rows."), CBIntText.get("Missing Information")); 236 } 237 }}); 238 239 btnLess = new CBButton(CBIntText.get("Less"), CBIntText.get("Remove a Line from the search window.")); 240 btnLess.addActionListener(new ActionListener(){ 241 public void actionPerformed(ActionEvent e){ 242 if (tabbedPane.getSelectedIndex()==0) { 244 build.removeFilterRow(); 245 } 246 else if (tabbedPane.getSelectedIndex()==1 && buttonCounter>1) 247 { 248 buttonCounter--; 249 join.removeFilterRow(btnEdit[buttonCounter]); 250 } 251 }}); 252 253 btnSave = new CBButton(CBIntText.get("Save"), CBIntText.get("Save this filter.")); 254 btnSave.addActionListener(new ActionListener(){ 255 public void actionPerformed(ActionEvent e){ 256 if (isFilterValid()) 257 save(); 258 else 259 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 260 }}); 261 262 btnLoad = new CBButton(CBIntText.get("Load"), CBIntText.get("Load a previously saved filter.")); 263 btnLoad.addActionListener(new ActionListener(){ 264 public void actionPerformed(ActionEvent e){ 265 if(tabbedPane.getSelectedIndex()==0) 266 loadBuild(); 267 else if(tabbedPane.getSelectedIndex()==1) 268 loadJoin(); 269 else if(tabbedPane.getSelectedIndex()==2) 270 loadText(); 271 }}); 272 273 btnView = new CBButton(CBIntText.get("View"), CBIntText.get("View this search filter as text.")); 274 btnView.addActionListener(new ActionListener(){ 275 public void actionPerformed(ActionEvent e){ 276 if (!isFilterValid()) 277 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 278 else if(tabbedPane.getSelectedIndex()==1 && recursiveFilterCheck(null, join.getFilter(), "View")) return; 280 else 281 showDialog(CBIntText.get("Current Filter"), getLDAPFilter()); 282 }}); 283 284 panel.makeHigh(); panel.addln(new JLabel(" ")); 286 panel.makeLight(); 287 panel.addln(btnMore); 288 panel.addln(btnLess); 289 panel.addln(btnSave); 290 panel.addln(btnLoad); 291 panel.addln(btnView); 292 293 return panel; 294 } 295 296 301 protected void setButtons(boolean state) 302 { 303 btnMore.setEnabled(state); 304 btnLess.setEnabled(state); 305 btnView.setEnabled(state); 306 } 307 308 314 protected void showDialog(String title, String filter) 315 { 316 JTextArea area = new JTextArea(filter); 317 area.setLineWrap(true); 318 area.setWrapStyleWord(true); 319 JScrollPane scrollPane = new JScrollPane(area); 320 scrollPane.setPreferredSize(new Dimension(300,60)); 321 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 322 JOptionPane.showMessageDialog(this, scrollPane, title, JOptionPane.INFORMATION_MESSAGE); 323 } 324 325 330 protected CBButton getEditButton() 331 { 332 btnEdit[buttonCounter] = new CBButton(CBIntText.get("Edit"), CBIntText.get("Edit this filter.")); 333 334 btnEdit[buttonCounter].setPreferredSize(new Dimension(55,21)); 335 btnEdit[buttonCounter].addActionListener(new ActionListener() 336 { 337 public void actionPerformed(ActionEvent e) 338 { 339 CBButton item = (CBButton)e.getSource(); 340 341 for(int i=0; i<buttonCounter; i++) 342 { 343 if (item == btnEdit[i]) 344 edit(i); 345 } 346 } 347 }); 348 349 return btnEdit[buttonCounter]; 350 } 351 352 359 protected void edit(int row) 360 { 361 ArrayList list = searchModel.getFilterNames(SearchModel.BUILDFILTER); String filter = join.getFilterComboValue(row); 363 364 if (filter==null) { 366 showMessage(CBIntText.get("There are no filters available to edit"), CBIntText.get("Nothing to Edit")); 367 return; 368 } 369 else 370 { 371 try 372 { 373 if (list.contains(filter)) { 375 buildName = filter; tabbedPane.setSelectedIndex(0); 378 build.displayFilter(searchModel.getFilter(filter)); } 380 else { 382 String value = searchModel.getFilter(filter); 384 setNumberOfRows(build.getOccurrences(searchModel.getFilter(filter), "JXFilter")); 386 ArrayList aList = searchModel.getJoinFilterNames(value); 388 if (!join.displayFilter(aList, value)) 389 { 390 showMessage(CBIntText.get("Your filter cannot be edited."), CBIntText.get("Edit Unsuccessful")); 391 } 392 else 393 { 394 joinName = filter; 395 filterNameTextField.setText(joinName); } 397 } 398 } 399 catch(Exception e) { 401 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 402 return; 403 } 404 } 405 } 406 407 413 protected void setNumberOfRows(int rows) 414 { 415 if (buttonCounter > rows) { 417 while (buttonCounter > rows) { 419 buttonCounter--; join.removeFilterRow(btnEdit[buttonCounter]); 421 } 422 } 423 else if (buttonCounter < rows) { 425 while (buttonCounter < rows) { 427 join.addFilterRow(getEditButton()); 428 buttonCounter++; } 430 } 431 } 432 433 439 protected void save() 440 { 441 String name = filterNameTextField.getText(); boolean exists = false; 444 if (name == null || name.trim().length()<=0 || name.equalsIgnoreCase("Untitled")) 445 { 446 showMessage(CBIntText.get("Please enter a name in the 'Filter Name' field for the filter that you are trying to save."), CBIntText.get("Name Required")); 447 return; 448 } 449 else if (name.startsWith("JXFilter")) 450 { 451 showMessage(CBIntText.get("The name ''{0}'' is a reserved name. Please enter a different name.", new String [] {name}), CBIntText.get("Naming Error")); 452 return; 453 } 454 455 if (searchModel.exists(name)) { 457 int response = JOptionPane.showConfirmDialog(this, CBIntText.get("The name ''{0}'' already exists. Do you want to replace it?", new String [] { name }), 458 CBIntText.get("Select Filter"), JOptionPane.YES_NO_OPTION ); 459 460 if(response != JOptionPane.YES_OPTION) 461 return; 462 463 exists = true; 464 } 465 466 try 467 { 468 if (tabbedPane.getSelectedIndex()==0) 469 { 470 buildName = name; searchModel.saveFilter(name, getLDAPFilter()); 472 } 473 else if (tabbedPane.getSelectedIndex()==1) 474 { 475 String filter = join.getFilter(); 476 477 if(recursiveFilterCheck(name, filter, "Save")) return; 479 480 joinName = name; searchModel.saveFilter(name, filter); 482 } 483 else if (tabbedPane.getSelectedIndex()==2) 484 { 485 textName = name; searchModel.saveTextFilter(name, text.getFilter()); 487 } 488 } 489 catch(Exception e) { 491 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 492 return; 493 } 494 495 save(name); 497 if(!exists) join.updateFilterCombo(name); 499 500 jx.getMainMenu().updateSearchMenu(); 502 showMessage(CBIntText.get("Your filter ''{0}'' was saved successfully.", new String [] {name}), CBIntText.get("Successful Save.")); 503 } 504 505 510 protected void save(String name) 511 { 512 String baseDN = ((baseDNTextField.getText()).trim()).length()<=0 ? ((jx.getTree()).getRootDN()).toString() : baseDNTextField.getText(); 513 searchModel.saveValue(name, SearchModel.BASEDN, baseDN); 514 searchModel.saveValue(name, SearchModel.RETATTRS, (returnAttributesCombo.getSelectedItem()).toString()); 515 searchModel.saveSearchLevel(name, searchLevelCombo.getSelectedIndex()); 516 searchModel.saveAlias(name, SearchModel.FIND, aliasFindingCheckBox.isSelected()); 517 searchModel.saveAlias(name, SearchModel.SEARCH, aliasSearchCheckBox.isSelected()); 518 } 519 520 524 protected void loadBuild() 525 { 526 ArrayList list = searchModel.getFilterNames(SearchModel.BUILDFILTER); 528 if (list.size()==0) 529 { 530 showMessage(CBIntText.get("There are no filters available to load.") , CBIntText.get("Nothing to Load")); 531 return; 532 } 533 534 Object listOb[] = list.toArray(); 535 Arrays.sort(listOb, new SearchModel.StringComparator()); 537 CBJComboBox loadCombo = new CBJComboBox(listOb); 538 loadCombo.setRenderer(new CBBasicComboBoxRenderer(listOb)); 539 loadCombo.setPreferredSize(new Dimension(140, 20)); 540 int response = JOptionPane.showConfirmDialog(this, loadCombo, CBIntText.get("Select Filter"), JOptionPane.OK_CANCEL_OPTION); 541 542 if (response != JOptionPane.OK_OPTION) 543 return; 545 if (loadCombo.getSelectedItem()!=null) 546 { 547 String filter=null; 548 try 549 { 550 filter = searchModel.getFilter(loadCombo.getSelectedItem().toString()); } 552 catch(Exception e) { 554 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 555 return; 556 } 557 558 if (!build.displayFilter(filter)) { 560 showMessage(CBIntText.get("Your filter cannot be displayed."), CBIntText.get("Load Unsuccessful")); 561 } 562 else 563 { 564 buildName = loadCombo.getSelectedItem().toString(); filterNameTextField.setText(buildName); } 567 } 568 else 569 showMessage(CBIntText.get("Problem loading; there are no filters selected.") , CBIntText.get("Nothing to Load")); 570 571 load(loadCombo.getSelectedItem().toString()); 572 } 573 574 579 protected void loadJoin() 580 { 581 ArrayList list = searchModel.getFilterNames(SearchModel.JOINFILTER); 583 if (list.size()==0) 584 { 585 showMessage(CBIntText.get("There are no filters available to load.") , CBIntText.get("Nothing to Load")); 586 return; 587 } 588 589 CBJComboBox loadCombo = new CBJComboBox(list.toArray()); 590 loadCombo.setRenderer(new CBBasicComboBoxRenderer(list.toArray())); 591 loadCombo.setPreferredSize(new Dimension(140, 20)); 592 int response = JOptionPane.showConfirmDialog(this, loadCombo, 593 CBIntText.get("Select Filter"), JOptionPane.OK_CANCEL_OPTION); 594 595 if (response != JOptionPane.OK_OPTION) 596 return; 598 if (loadCombo.getSelectedItem()!=null) 599 { 600 String filter = loadCombo.getSelectedItem().toString(); 602 try 603 { 604 setNumberOfRows(build.getOccurrences(searchModel.getFilter(filter), "JXFilter")); 606 list = searchModel.getJoinFilterNames(searchModel.getFilter(filter)); 608 if(!join.displayFilter(list, searchModel.getFilter(filter))) showMessage(CBIntText.get("Your filter cannot be displayed."), CBIntText.get("Load Unsuccessful")); 610 else 611 { 612 joinName = loadCombo.getSelectedItem().toString(); filterNameTextField.setText(joinName); } 615 } 616 catch(Exception e) { 618 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 619 return; 620 } 621 } 622 else 623 showMessage(CBIntText.get("Problem loading; there are no filters selected.") , CBIntText.get("Nothing to Load")); 624 625 load(loadCombo.getSelectedItem().toString()); 626 } 627 628 633 protected void loadText() 635 { 636 ArrayList list = searchModel.getFilterNames(SearchModel.TEXTFILTER); 638 if (list.size()==0) 639 { 640 showMessage(CBIntText.get("There are no filters available to load.") , CBIntText.get("Nothing to Load")); 641 return; 642 } 643 644 CBJComboBox loadCombo = new CBJComboBox(list.toArray()); 645 loadCombo.setRenderer(new CBBasicComboBoxRenderer(list.toArray())); 646 loadCombo.setPreferredSize(new Dimension(140, 20)); 647 int response = JOptionPane.showConfirmDialog(this, loadCombo, CBIntText.get("Select Filter"), JOptionPane.OK_CANCEL_OPTION); 648 649 if (response != JOptionPane.OK_OPTION) 650 return; 651 652 if (loadCombo.getSelectedItem()!=null) 653 { 654 textName = loadCombo.getSelectedItem().toString(); text.displayFilter(searchModel.getTextFilter(textName)); 656 filterNameTextField.setText(textName); } 658 else 659 showMessage(CBIntText.get("Problem loading; there are no filters selected.") , CBIntText.get("Nothing to Load")); 660 661 load(loadCombo.getSelectedItem().toString()); 662 } 663 664 670 protected void load(String name) 671 { 672 int searchLevel = 2; 674 try 675 { 676 searchLevel = Integer.parseInt(searchModel.getValue(name + "." + SearchModel.SEARCHLEVEL)); 677 searchLevelCombo.setSelectedIndex(searchLevel); 678 } 679 catch(NumberFormatException e) 680 { 681 searchLevelCombo.setSelectedIndex(2); 682 } 683 684 685 String dn = searchModel.getValue(name + "." + SearchModel.BASEDN); 687 if(dn!=null) 688 baseDNTextField.setText(dn); 689 690 String retAttrs = searchModel.getValue(name + "." + SearchModel.RETATTRS); 693 if (retAttrs!=null) 694 { 695 Object temp[] = ReturnAttributesDialog.getSavedListNames(); 696 697 for(int i=0; i<temp.length;i++) 698 { 699 if (((String )temp[i]).equalsIgnoreCase(retAttrs)) 700 { 701 returnAttributesCombo.setSelectedItem(temp[i]); 702 break; 703 } 704 } 705 } 706 707 String find = searchModel.getValue(name + "." + SearchModel.FIND); 709 if (find!=null) 710 { 711 if(find.equalsIgnoreCase("true")) 712 aliasFindingCheckBox.setSelected(true); 713 else 714 aliasFindingCheckBox.setSelected(false); 715 } 716 717 String search = searchModel.getValue(name + "." + SearchModel.SEARCH); 719 if (search!=null) 720 { 721 if(search.equalsIgnoreCase("true")) 722 aliasSearchCheckBox.setSelected(true); 723 else 724 aliasSearchCheckBox.setSelected(false); 725 } 726 } 727 728 733 protected boolean isFilterValid() 734 { 735 if (tabbedPane.getSelectedIndex()==0) 736 return build.isFilterValid(); 737 else if (tabbedPane.getSelectedIndex()==1) 738 return join.isFilterValid(); 739 else if(tabbedPane.getSelectedIndex()==2) 740 return text.isFilterValid(); 741 742 return false; } 744 745 750 protected String getLDAPFilter() 751 { 752 if (tabbedPane.getSelectedIndex()==0) 753 return build.getFilter(); 754 else if(tabbedPane.getSelectedIndex()==1) 755 return searchModel.getJoinFilter(join.getFilter()); 756 else if(tabbedPane.getSelectedIndex()==2) 757 return text.getFilter(); 758 759 return ""; 760 } 761 762 767 protected void showMessage(String message, String title) 768 { 769 JOptionPane.showMessageDialog(this, message, title, JOptionPane.INFORMATION_MESSAGE ); 770 } 771 772 776 public void doOK() 777 { 778 if (isFilterValid()) 779 { 780 if(tabbedPane.getSelectedIndex()==1 && recursiveFilterCheck(null, join.getFilter(), "Search")) 782 return; 783 setAliasOptions(); 784 785 String returnAttrs = (returnAttributesCombo.getSelectedItem()).toString(); 786 if (!returnAttrs.equalsIgnoreCase(ReturnAttributesDialog.DEFAULT_RETURN_ATTRS)) 787 { 788 closeSearchGUI(); 789 String [] attrNames = ReturnAttributesDialog.getReturnAttributes(returnAttrs); 790 searchModel.openRetAttrDisplay(jx, attrNames, (jx.getSearchTree()).getDataSource()); 791 SearchExecute.run(jx.getSearchTree(), new DN(baseDNTextField.getText()), getLDAPFilter(), attrNames, searchLevelCombo.getSelectedIndex(), jx.getSearchBroker()); } 793 else 794 { 795 closeSearchGUI(); 796 SearchExecute.run(jx.getSearchTree(), new DN(baseDNTextField.getText()), getLDAPFilter(), 797 new String [] {"objectClass"}, searchLevelCombo.getSelectedIndex(), jx.getSearchBroker()); } 799 jx.getTreeTabPane().setSelectedComponent(jx.getResultsPanel()); 800 } 801 else 802 { 803 showMessage(CBIntText.get("The filter cannot be constructed; there appears to be missing information.\nPlease make sure you have entered all the information for the filter correctly."), CBIntText.get("Missing Information")); 804 } 805 } 806 807 810 public void doCancel() 811 { 812 closeSearchGUI(); 813 } 814 815 819 public void closeSearchGUI() 820 { 821 filterNameTextField.setText("Untitled"); setVisible(false); 823 } 824 825 836 public void setAliasOptions() 837 { 838 String aliasOption = "always"; 839 840 if (!aliasSearchCheckBox.isSelected() && !aliasFindingCheckBox.isSelected()) 841 aliasOption = "never"; 842 else if (aliasSearchCheckBox.isSelected() && !aliasFindingCheckBox.isSelected()) 843 aliasOption = "searching"; 844 else if (!aliasSearchCheckBox.isSelected() && aliasFindingCheckBox.isSelected()) 845 aliasOption = "finding"; 846 847 log.fine("Setting search alias option to: ["+aliasOption+"]"); 848 JXplorer.setProperty("option.ldap.searchAliasBehaviour", aliasOption); 849 } 850 851 860 protected boolean recursiveFilterCheck(String filterName, String filter, String type) 861 { 862 if(recursiveFilterCheck(filterName, filter)) { 864 showMessage(CBIntText.get("The filter you are trying to {0} is not valid. You may be trying to construct a filter within itself which will cause an infinite loop.", new String [] {type.toLowerCase()}), CBIntText.get(type + " Error")); 865 return true; 866 } 867 return false; 868 } 869 870 878 protected boolean recursiveFilterCheck(String filterName, String filter) 879 { 880 boolean recursive = false; 881 String temp; 882 ArrayList list = searchModel.getJoinFilterNames(filter); 883 884 for(int i=0;i<list.size();i++) 885 { 886 temp = list.get(i).toString(); 887 888 if(filterName != null && filterName.compareTo(temp) == 0) 889 { 890 recursive = true; 891 break; 892 } 893 894 String value = searchModel.getFilter(temp); 896 897 if(value != null && value.indexOf("JXFilter") != -1) 899 recursive = recursiveFilterCheck(filterName, value); 900 901 if(recursive) 902 return true; 903 } 904 905 return recursive; 906 } 907 } 908 909 910 912 920 921 922 | Popular Tags |