1 20 21 package org.apache.directory.ldapstudio.browser.common.actions; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 26 import org.apache.directory.ldapstudio.browser.common.dialogs.FilterWidgetDialog; 27 import org.apache.directory.ldapstudio.browser.core.jobs.InitializeChildrenJob; 28 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 29 30 import org.eclipse.jface.dialogs.Dialog; 31 import org.eclipse.jface.resource.ImageDescriptor; 32 33 34 42 public class FilterChildrenAction extends BrowserAction 43 { 44 45 48 public FilterChildrenAction() 49 { 50 super(); 51 } 52 53 54 57 public void run() 58 { 59 if ( getSelectedEntries().length == 1 ) 60 { 61 FilterWidgetDialog dialog = new FilterWidgetDialog( getShell(), "Filter Children", getSelectedEntries()[0] 62 .getChildrenFilter(), getSelectedEntries()[0].getConnection() ); 63 if ( dialog.open() == Dialog.OK ) 64 { 65 String newFilter = dialog.getFilter(); 66 67 if ( newFilter == null || "".equals( newFilter.trim() ) ) 68 { 69 getSelectedEntries()[0].setChildrenFilter( null ); 70 } 71 else 72 { 73 getSelectedEntries()[0].setChildrenFilter( newFilter.trim() ); 74 } 75 new InitializeChildrenJob( new IEntry[] 76 { getSelectedEntries()[0] } ).execute(); 77 78 } 79 } 80 } 81 82 83 86 public String getText() 87 { 88 return "Filter Children..."; 89 } 90 91 92 95 public ImageDescriptor getImageDescriptor() 96 { 97 return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_FILTER_DIT ); 98 } 99 100 101 104 public String getCommandId() 105 { 106 return null; 107 } 108 109 110 113 public boolean isEnabled() 114 { 115 return getSelectedSearches().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0 116 && getSelectedEntries().length == 1 117 && ( getSelectedEntries()[0].hasChildren() || getSelectedEntries()[0].getChildrenFilter() != null ); 118 } 119 } 120 | Popular Tags |