1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.entryeditor; 22 23 24 import org.apache.directory.ldapstudio.browser.common.actions.DeleteAllValuesAction; 25 import org.apache.directory.ldapstudio.browser.common.actions.NewAttributeAction; 26 import org.apache.directory.ldapstudio.browser.common.actions.proxy.EntryEditorActionProxy; 27 import org.eclipse.jface.action.IAction; 28 import org.eclipse.jface.action.IMenuManager; 29 import org.eclipse.jface.action.IToolBarManager; 30 import org.eclipse.jface.action.MenuManager; 31 import org.eclipse.jface.action.Separator; 32 import org.eclipse.jface.commands.ActionHandler; 33 import org.eclipse.jface.viewers.TreeViewer; 34 import org.eclipse.ui.PlatformUI; 35 import org.eclipse.ui.commands.ICommandService; 36 37 38 44 public class EntryEditorWidgetActionGroupWithAttribute extends EntryEditorWidgetActionGroup 45 { 46 47 48 private static final String editAttributeDescriptionAction = "editAttributeDescriptionAction"; 49 50 51 private static final String newAttributeAction = "newAttributeAction"; 52 53 54 private static final String deleteAllValuesAction = "deleteAllValuesAction"; 55 56 57 64 public EntryEditorWidgetActionGroupWithAttribute( EntryEditorWidget mainWidget, 65 EntryEditorWidgetConfiguration configuration ) 66 { 67 super( mainWidget, configuration ); 68 TreeViewer viewer = mainWidget.getViewer(); 69 70 entryEditorActionMap.put( editAttributeDescriptionAction, new EntryEditorActionProxy( viewer, 71 new EditAttributeDescriptionAction( viewer ) ) ); 72 entryEditorActionMap.put( newAttributeAction, new EntryEditorActionProxy( viewer, new NewAttributeAction() ) ); 73 entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer, 74 new DeleteAllValuesAction() ) ); 75 76 } 77 78 79 82 public void fillToolBar( IToolBarManager toolBarManager ) 83 { 84 toolBarManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) ); 85 toolBarManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) ); 86 toolBarManager.add( new Separator() ); 87 toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) ); 88 toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) ); 89 toolBarManager.add( new Separator() ); 90 toolBarManager.add( this.showQuickFilterAction ); 91 toolBarManager.update( true ); 92 } 93 94 95 98 protected void contextMenuAboutToShow( IMenuManager menuManager ) 99 { 100 menuManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) ); 102 menuManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) ); 103 menuManager.add( new Separator() ); 104 105 menuManager.add( ( IAction ) entryEditorActionMap.get( copyAction ) ); 107 menuManager.add( ( IAction ) entryEditorActionMap.get( pasteAction ) ); 108 menuManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) ); 109 menuManager.add( ( IAction ) entryEditorActionMap.get( selectAllAction ) ); 110 MenuManager copyMenuManager = new MenuManager( "Advanced" ); 111 copyMenuManager.add( ( IAction ) entryEditorActionMap.get( deleteAllValuesAction ) ); 112 menuManager.add( copyMenuManager ); 113 menuManager.add( new Separator() ); 114 115 menuManager.add( ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction ) ); 117 super.addEditMenu( menuManager ); 118 menuManager.add( new Separator() ); 119 120 menuManager.add( ( IAction ) entryEditorActionMap.get( propertyDialogAction ) ); 122 } 123 124 125 128 public void activateGlobalActionHandlers() 129 { 130 super.activateGlobalActionHandlers(); 131 132 ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter( 133 ICommandService.class ); 134 if ( commandService != null ) 135 { 136 IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction ); 137 commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) ); 138 IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction ); 139 commandService.getCommand( eada.getActionDefinitionId() ).setHandler( new ActionHandler( eada ) ); 140 } 141 } 142 143 144 147 public void deactivateGlobalActionHandlers() 148 { 149 super.deactivateGlobalActionHandlers(); 150 151 ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter( 152 ICommandService.class ); 153 if ( commandService != null ) 154 { 155 IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction ); 156 commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null ); 157 IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction ); 158 commandService.getCommand( eada.getActionDefinitionId() ).setHandler( null ); 159 } 160 } 161 162 } 163 | Popular Tags |