KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > editors > searchresult > SearchResultEditorActionGroup


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult;
22
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
29 import org.apache.directory.ldapstudio.browser.ui.actions.CopyAttributeDescriptionAction;
30 import org.apache.directory.ldapstudio.browser.ui.actions.CopyDnAction;
31 import org.apache.directory.ldapstudio.browser.ui.actions.CopyEntryAsCsvAction;
32 import org.apache.directory.ldapstudio.browser.ui.actions.CopySearchFilterAction;
33 import org.apache.directory.ldapstudio.browser.ui.actions.CopyUrlAction;
34 import org.apache.directory.ldapstudio.browser.ui.actions.CopyValueAction;
35 import org.apache.directory.ldapstudio.browser.ui.actions.LocateDnInDitAction;
36 import org.apache.directory.ldapstudio.browser.ui.actions.NewBatchOperationAction;
37 import org.apache.directory.ldapstudio.browser.ui.actions.NewSearchAction;
38 import org.apache.directory.ldapstudio.browser.ui.actions.OpenSchemaBrowserAction;
39 import org.apache.directory.ldapstudio.browser.ui.actions.OpenSearchResultAction;
40 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.SearchResultEditorActionProxy;
41 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
42 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
43 import org.apache.directory.ldapstudio.browser.common.actions.CopyAction;
44 import org.apache.directory.ldapstudio.browser.common.actions.NewValueAction;
45 import org.apache.directory.ldapstudio.browser.common.actions.PropertiesAction;
46 import org.apache.directory.ldapstudio.browser.common.actions.RefreshAction;
47 import org.apache.directory.ldapstudio.browser.common.actions.ShowRawValuesAction;
48 import org.apache.directory.ldapstudio.browser.common.actions.ValueEditorPreferencesAction;
49 import org.apache.directory.ldapstudio.browser.common.actions.proxy.BrowserActionProxy;
50 import org.apache.directory.ldapstudio.valueeditors.IValueEditor;
51 import org.eclipse.jface.action.IAction;
52 import org.eclipse.jface.action.IMenuListener;
53 import org.eclipse.jface.action.IMenuManager;
54 import org.eclipse.jface.action.IToolBarManager;
55 import org.eclipse.jface.action.MenuManager;
56 import org.eclipse.jface.action.Separator;
57 import org.eclipse.jface.commands.ActionHandler;
58 import org.eclipse.jface.viewers.TableViewer;
59 import org.eclipse.ui.IActionBars;
60 import org.eclipse.ui.IWorkbenchActionConstants;
61 import org.eclipse.ui.PlatformUI;
62 import org.eclipse.ui.actions.ActionFactory;
63 import org.eclipse.ui.actions.ContributionItemFactory;
64 import org.eclipse.ui.commands.ICommandService;
65
66
67 public class SearchResultEditorActionGroup implements IMenuListener
68 {
69
70     private ShowDNAction showDNAction;
71
72     private ShowLinksAction showLinksAction;
73
74     private ShowRawValuesAction showRawValuesAction;
75
76     private OpenSearchResultEditorPreferencePage openSearchResultEditorPreferencePage;
77
78     private ShowQuickFilterAction showQuickFilterAction;
79
80     private OpenDefaultEditorAction openDefaultEditorAction;
81
82     private OpenBestEditorAction openBestEditorAction;
83
84     private OpenEditorAction[] openEditorActions;
85
86     private ValueEditorPreferencesAction openValueEditorPreferencesAction;
87
88     private static final String JavaDoc copyTableAction = "copyTableAction";
89
90     private static final String JavaDoc refreshSearchAction = "refreshSearchAction";
91
92     private final static String JavaDoc newValueAction = "newValueAction";
93
94     private final static String JavaDoc newSearchAction = "newSearchAction";
95
96     private static final String JavaDoc newBatchOperationAction = "newBatchOperationAction";
97
98     private final static String JavaDoc copyAction = "copyAction";
99
100     private final static String JavaDoc pasteAction = "pasteAction";
101
102     private final static String JavaDoc deleteAction = "deleteAction";
103
104     private static final String JavaDoc copyDnAction = "copyDnAction";
105
106     private static final String JavaDoc copyUrlAction = "copyUrlAction";
107
108     private static final String JavaDoc copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction";
109
110     private static final String JavaDoc copyValueUtf8Action = "copyValueUtf8Action";
111
112     private static final String JavaDoc copyValueBase64Action = "copyValueBase64Action";
113
114     private static final String JavaDoc copyValueHexAction = "copyValueHexAction";
115
116     private static final String JavaDoc copyValueAsLdifAction = "copyValueAsLdifAction";
117
118     private static final String JavaDoc copySearchFilterAction = "copySearchFilterAction";
119
120     private static final String JavaDoc copyNotSearchFilterAction = "copyNotSearchFilterAction";
121
122     private static final String JavaDoc copyAndSearchFilterAction = "copyAndSearchFilterAction";
123
124     private static final String JavaDoc copyOrSearchFilterAction = "copyOrSearchFilterAction";
125
126     private static final String JavaDoc openSearchResultAction = "showEntryInSearchResultsAction";
127
128     private static final String JavaDoc locateDnInDitAction = "locateDnInDitAction";
129
130     private static final String JavaDoc showOcdAction = "showOcdAction";
131
132     private static final String JavaDoc showAtdAction = "showAtdAction";
133
134     private static final String JavaDoc showEqualityMrdAction = "showEqualityMrdAction";
135
136     private static final String JavaDoc showSubstringMrdAction = "showSubstringMrdAction";
137
138     private static final String JavaDoc showOrderingMrdAction = "showOrderingMrdAction";
139
140     private static final String JavaDoc showLsdAction = "showLsdAction";
141
142     private final static String JavaDoc propertyDialogAction = "propertyDialogAction";
143
144     private Map JavaDoc searchResultEditorActionMap;
145
146     private IActionBars actionBars;
147
148     private SearchResultEditor searchResultEditor;
149
150
151     public SearchResultEditorActionGroup( SearchResultEditor searchResultEditor )
152     {
153         this.searchResultEditor = searchResultEditor;
154         this.searchResultEditorActionMap = new HashMap JavaDoc();
155
156         TableViewer viewer = searchResultEditor.getMainWidget().getViewer();
157         SearchResultEditorCursor cursor = searchResultEditor.getConfiguration().getCursor( viewer );
158
159         this.showDNAction = new ShowDNAction();
160         this.showLinksAction = new ShowLinksAction();
161         this.showRawValuesAction = new ShowRawValuesAction();
162         this.openSearchResultEditorPreferencePage = new OpenSearchResultEditorPreferencePage();
163         this.showQuickFilterAction = new ShowQuickFilterAction( searchResultEditor.getMainWidget()
164             .getQuickFilterWidget() );
165
166         this.openBestEditorAction = new OpenBestEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
167             viewer ), this, searchResultEditor.getConfiguration().getValueEditorManager( viewer ) );
168         this.openDefaultEditorAction = new OpenDefaultEditorAction( this.openBestEditorAction );
169         IValueEditor[] valueEditors = searchResultEditor.getConfiguration().getValueEditorManager( viewer )
170             .getAllValueEditors();
171         this.openEditorActions = new OpenEditorAction[valueEditors.length];
172         for ( int i = 0; i < this.openEditorActions.length; i++ )
173         {
174             this.openEditorActions[i] = new OpenEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
175                 viewer ), this, searchResultEditor.getConfiguration().getValueEditorManager( viewer ),
176                 valueEditors[i] );
177         }
178         this.openValueEditorPreferencesAction = new ValueEditorPreferencesAction();
179
180         this.searchResultEditorActionMap.put( copyTableAction, new SearchResultEditorActionProxy( cursor,
181             new CopyEntryAsCsvAction( CopyEntryAsCsvAction.MODE_TABLE ) ) );
182         this.searchResultEditorActionMap.put( refreshSearchAction, new SearchResultEditorActionProxy( cursor,
183             new RefreshAction() ) );
184
185         this.searchResultEditorActionMap.put( newValueAction, new SearchResultEditorActionProxy( cursor,
186             new NewValueAction() ) );
187         this.searchResultEditorActionMap.put( newSearchAction, new SearchResultEditorActionProxy( cursor,
188             new NewSearchAction() ) );
189         this.searchResultEditorActionMap.put( newBatchOperationAction, new SearchResultEditorActionProxy( cursor,
190             new NewBatchOperationAction() ) );
191
192         this.searchResultEditorActionMap.put( locateDnInDitAction, new SearchResultEditorActionProxy( cursor,
193             new LocateDnInDitAction() ) );
194         this.searchResultEditorActionMap.put( openSearchResultAction, new SearchResultEditorActionProxy( cursor,
195             new OpenSearchResultAction() ) );
196
197         this.searchResultEditorActionMap.put( showOcdAction, new SearchResultEditorActionProxy( cursor,
198             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) );
199         this.searchResultEditorActionMap.put( showAtdAction, new SearchResultEditorActionProxy( cursor,
200             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) );
201         this.searchResultEditorActionMap.put( showEqualityMrdAction, new SearchResultEditorActionProxy( cursor,
202             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) );
203         this.searchResultEditorActionMap.put( showSubstringMrdAction, new SearchResultEditorActionProxy( cursor,
204             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) );
205         this.searchResultEditorActionMap.put( showOrderingMrdAction, new SearchResultEditorActionProxy( cursor,
206             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) );
207         this.searchResultEditorActionMap.put( showLsdAction, new SearchResultEditorActionProxy( cursor,
208             new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SYNTAX ) ) );
209
210         this.searchResultEditorActionMap.put( pasteAction, new SearchResultEditorActionProxy( cursor,
211             new SearchResultEditorPasteAction() ) );
212         this.searchResultEditorActionMap.put( copyAction, new SearchResultEditorActionProxy( cursor, new CopyAction(
213             ( BrowserActionProxy ) this.searchResultEditorActionMap.get( pasteAction ) ) ) );
214         this.searchResultEditorActionMap.put( deleteAction, new SearchResultEditorActionProxy( cursor,
215             new SearchResultDeleteAction() ) );
216
217         this.searchResultEditorActionMap.put( copyDnAction, new SearchResultEditorActionProxy( cursor,
218             new CopyDnAction() ) );
219         this.searchResultEditorActionMap.put( copyUrlAction, new SearchResultEditorActionProxy( cursor,
220             new CopyUrlAction() ) );
221         this.searchResultEditorActionMap.put( copyAttriuteDescriptionAction, new SearchResultEditorActionProxy( cursor,
222             new CopyAttributeDescriptionAction() ) );
223         this.searchResultEditorActionMap.put( copyValueUtf8Action, new SearchResultEditorActionProxy( cursor,
224             new CopyValueAction( CopyValueAction.MODE_UTF8 ) ) );
225         this.searchResultEditorActionMap.put( copyValueBase64Action, new SearchResultEditorActionProxy( cursor,
226             new CopyValueAction( CopyValueAction.MODE_BASE64 ) ) );
227         this.searchResultEditorActionMap.put( copyValueHexAction, new SearchResultEditorActionProxy( cursor,
228             new CopyValueAction( CopyValueAction.MODE_HEX ) ) );
229         this.searchResultEditorActionMap.put( copyValueAsLdifAction, new SearchResultEditorActionProxy( cursor,
230             new CopyValueAction( CopyValueAction.MODE_LDIF ) ) );
231
232         this.searchResultEditorActionMap.put( copySearchFilterAction, new SearchResultEditorActionProxy( cursor,
233             new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) );
234         this.searchResultEditorActionMap.put( copyNotSearchFilterAction, new SearchResultEditorActionProxy( cursor,
235             new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) );
236         this.searchResultEditorActionMap.put( copyAndSearchFilterAction, new SearchResultEditorActionProxy( cursor,
237             new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) );
238         this.searchResultEditorActionMap.put( copyOrSearchFilterAction, new SearchResultEditorActionProxy( cursor,
239             new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) );
240
241         this.searchResultEditorActionMap.put( propertyDialogAction, new SearchResultEditorActionProxy( cursor,
242             new PropertiesAction() ) );
243
244     }
245
246
247     public void dispose()
248     {
249
250         if ( this.searchResultEditor != null )
251         {
252             this.showRawValuesAction = null;
253             this.showDNAction.dispose();
254             this.showDNAction = null;
255             this.showLinksAction.dispose();
256             this.showLinksAction = null;
257             this.openSearchResultEditorPreferencePage = null;
258             this.showQuickFilterAction.dispose();
259             this.showQuickFilterAction = null;
260
261             this.openDefaultEditorAction.dispose();
262             this.openDefaultEditorAction = null;
263             this.openBestEditorAction.dispose();
264             this.openBestEditorAction = null;
265             for ( int i = 0; i < this.openEditorActions.length; i++ )
266             {
267                 this.openEditorActions[i].dispose();
268                 this.openEditorActions[i] = null;
269             }
270             this.openValueEditorPreferencesAction = null;
271
272             for ( Iterator JavaDoc it = this.searchResultEditorActionMap.keySet().iterator(); it.hasNext(); )
273             {
274                 String JavaDoc key = ( String JavaDoc ) it.next();
275                 SearchResultEditorActionProxy action = ( SearchResultEditorActionProxy ) this.searchResultEditorActionMap
276                     .get( key );
277                 action.dispose();
278                 action = null;
279                 it.remove();
280             }
281             this.searchResultEditorActionMap.clear();
282             this.searchResultEditorActionMap = null;
283
284             this.actionBars = null;
285             this.searchResultEditor = null;
286         }
287     }
288
289
290     public void fillToolBar( IToolBarManager toolBarManager )
291     {
292         toolBarManager.add( new Separator() );
293         toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( newValueAction ) );
294         toolBarManager.add( new Separator() );
295         toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
296         toolBarManager.add( new Separator() );
297         toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
298         toolBarManager.add( new Separator() );
299         toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyTableAction ) );
300         toolBarManager.add( new Separator() );
301         toolBarManager.add( this.showQuickFilterAction );
302         toolBarManager.update( true );
303     }
304
305
306     public void fillMenu( IMenuManager menuManager )
307     {
308         menuManager.add( this.showDNAction );
309         menuManager.add( this.showLinksAction );
310         menuManager.add( this.showRawValuesAction );
311         menuManager.add( new Separator() );
312         menuManager.add( this.openSearchResultEditorPreferencePage );
313         menuManager.addMenuListener( new IMenuListener()
314         {
315             public void menuAboutToShow( IMenuManager manager )
316             {
317                 showRawValuesAction.setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
318                     BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
319             }
320         } );
321         menuManager.update( true );
322     }
323
324
325     public void enableGlobalActionHandlers( IActionBars actionBars )
326     {
327         this.actionBars = actionBars;
328         this.activateGlobalActionHandlers();
329     }
330
331
332     public void fillContextMenu( IMenuManager menuManager )
333     {
334         menuManager.setRemoveAllWhenShown( true );
335         menuManager.addMenuListener( this );
336     }
337
338
339     public void menuAboutToShow( IMenuManager menuManager )
340     {
341
342         // new
343
menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newValueAction ) );
344         menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newSearchAction ) );
345         menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newBatchOperationAction ) );
346         menuManager.add( new Separator() );
347
348         // navigation
349
menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction ) );
350         menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction ) );
351         MenuManager schemaMenuManager = new MenuManager( "Open Schema Browser" );
352         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showOcdAction ) );
353         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showAtdAction ) );
354         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showEqualityMrdAction ) );
355         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showSubstringMrdAction ) );
356         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showOrderingMrdAction ) );
357         schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showLsdAction ) );
358         menuManager.add( schemaMenuManager );
359         MenuManager showInSubMenu = new MenuManager( "Show In" );
360         showInSubMenu.add( ContributionItemFactory.VIEWS_SHOW_IN.create( PlatformUI.getWorkbench()
361             .getActiveWorkbenchWindow() ) );
362         menuManager.add( showInSubMenu );
363         menuManager.add( new Separator() );
364
365         // copy, paste, delete
366
menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyAction ) );
367         menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( pasteAction ) );
368         menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
369         MenuManager advancedMenuManager = new MenuManager( "Advanced" );
370         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyDnAction ) );
371         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyUrlAction ) );
372         advancedMenuManager.add( new Separator() );
373         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyAttriuteDescriptionAction ) );
374         advancedMenuManager.add( new Separator() );
375         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueUtf8Action ) );
376         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueBase64Action ) );
377         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueHexAction ) );
378         advancedMenuManager.add( new Separator() );
379         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueAsLdifAction ) );
380         advancedMenuManager.add( new Separator() );
381         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copySearchFilterAction ) );
382         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyNotSearchFilterAction ) );
383         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyAndSearchFilterAction ) );
384         advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyOrSearchFilterAction ) );
385         menuManager.add( advancedMenuManager );
386         menuManager.add( new Separator() );
387
388         // edit
389
menuManager.add( this.openDefaultEditorAction );
390         MenuManager editorMenuManager = new MenuManager( "Edit Value With" );
391         if ( this.openBestEditorAction.isEnabled() )
392         {
393             editorMenuManager.add( this.openBestEditorAction );
394             editorMenuManager.add( new Separator() );
395         }
396         for ( int i = 0; i < this.openEditorActions.length; i++ )
397         {
398             if ( this.openEditorActions[i].isEnabled()
399                 && this.openEditorActions[i].getValueEditor().getClass() != this.openBestEditorAction
400                     .getBestValueEditor().getClass() )
401             {
402                 editorMenuManager.add( this.openEditorActions[i] );
403             }
404         }
405         editorMenuManager.add( new Separator() );
406         editorMenuManager.add( this.openValueEditorPreferencesAction );
407         menuManager.add( editorMenuManager );
408         menuManager.add( new Separator() );
409
410         // refresh
411
menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
412         menuManager.add( new Separator() );
413
414         // additions
415
menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
416
417         // / properties
418
menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( propertyDialogAction ) );
419
420     }
421
422
423     public void activateGlobalActionHandlers()
424     {
425
426         if ( this.actionBars != null )
427         {
428             actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) this.searchResultEditorActionMap
429                 .get( copyAction ) );
430             actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(),
431                 ( IAction ) this.searchResultEditorActionMap.get( pasteAction ) );
432             actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(),
433                 ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
434             actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(),
435                 ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
436             actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(),
437                 ( IAction ) this.searchResultEditorActionMap.get( propertyDialogAction ) );
438             actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), this.showQuickFilterAction );
439             actionBars.updateActionBars();
440         }
441
442         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
443             ICommandService.class );
444         if ( commandService != null )
445         {
446             IAction nva = ( IAction ) this.searchResultEditorActionMap.get( newValueAction );
447             commandService.getCommand( nva.getActionDefinitionId() ).setHandler( new ActionHandler( nva ) );
448             IAction lid = ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction );
449             commandService.getCommand( lid.getActionDefinitionId() ).setHandler( new ActionHandler( lid ) );
450             IAction osr = ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction );
451             commandService.getCommand( osr.getActionDefinitionId() ).setHandler( new ActionHandler( osr ) );
452             commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler(
453                 new ActionHandler( openDefaultEditorAction ) );
454         }
455
456     }
457
458
459     public void deactivateGlobalActionHandlers()
460     {
461
462         if ( this.actionBars != null )
463         {
464             actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null );
465             actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null );
466             actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), null );
467             actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null );
468             actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), null );
469             actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), null );
470             actionBars.updateActionBars();
471         }
472
473         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
474             ICommandService.class );
475         if ( commandService != null )
476         {
477             IAction nva = ( IAction ) this.searchResultEditorActionMap.get( newValueAction );
478             commandService.getCommand( nva.getActionDefinitionId() ).setHandler( null );
479             IAction lid = ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction );
480             commandService.getCommand( lid.getActionDefinitionId() ).setHandler( null );
481             IAction osr = ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction );
482             commandService.getCommand( osr.getActionDefinitionId() ).setHandler( null );
483             commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler( null );
484         }
485
486     }
487
488
489     public OpenBestEditorAction getOpenBestEditorAction()
490     {
491         return openBestEditorAction;
492     }
493
494
495     public void setInput( ISearch search )
496     {
497         for ( Iterator JavaDoc it = this.searchResultEditorActionMap.values().iterator(); it.hasNext(); )
498         {
499             SearchResultEditorActionProxy action = ( SearchResultEditorActionProxy ) it.next();
500             action.inputChanged( search );
501         }
502     }
503
504
505     public boolean isEditorActive()
506     {
507         if ( this.openDefaultEditorAction.isActive() )
508         {
509             return true;
510         }
511         if ( this.openBestEditorAction.isActive() )
512         {
513             return true;
514         }
515         for ( int i = 0; i < this.openEditorActions.length; i++ )
516         {
517             if ( this.openEditorActions[i].isActive() )
518             {
519                 return true;
520             }
521         }
522
523         return false;
524     }
525
526 }
527
Popular Tags