View Javadoc

1   package org.eparapher.rcp;
2   
3   import org.eclipse.jface.action.GroupMarker;
4   import org.eclipse.jface.action.IContributionItem;
5   import org.eclipse.jface.action.ICoolBarManager;
6   import org.eclipse.jface.action.IMenuManager;
7   import org.eclipse.jface.action.IStatusLineManager;
8   import org.eclipse.jface.action.IToolBarManager;
9   import org.eclipse.jface.action.MenuManager;
10  import org.eclipse.jface.action.Separator;
11  import org.eclipse.jface.action.ToolBarContributionItem;
12  import org.eclipse.jface.action.ToolBarManager;
13  import org.eclipse.swt.SWT;
14  import org.eclipse.ui.IWorkbenchActionConstants;
15  import org.eclipse.ui.IWorkbenchWindow;
16  import org.eclipse.ui.actions.ActionFactory;
17  import org.eclipse.ui.actions.ContributionItemFactory;
18  import org.eclipse.ui.actions.NewWizardDropDownAction;
19  import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
20  import org.eclipse.ui.application.ActionBarAdvisor;
21  import org.eclipse.ui.application.IActionBarConfigurer;
22  import org.eparapher.rcp.actions.CMSSignDocumentAction;
23  import org.eparapher.rcp.actions.ToPDFAndSignDocumentAction;
24  import org.eparapher.rcp.actions.XMLSignDocumentAction;
25  import org.eparapher.rcp.statusline.OpenOfficeStatus;
26  import org.eparapher.rcp.statusline.TokenStatus;
27  import org.eparapher.rcp.tools.GUIIcons;
28  
29  
30  
31  public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
32  
33      private IWorkbenchAction newAction;
34      private IWorkbenchAction newDropDownAction;
35      private IWorkbenchAction closeAction;
36  	private IWorkbenchAction closeAllAction;
37  	private IWorkbenchAction saveAction;
38      private IWorkbenchAction saveAsAction;
39      private IWorkbenchAction saveAllAction;
40      private IWorkbenchAction printAction;
41      private IWorkbenchAction refreshAction;
42      private IWorkbenchAction propertiesAction;
43  	private IWorkbenchAction exitAction;
44  
45      //private IWorkbenchAction importAction;
46      //private IWorkbenchAction exportAction;
47      
48  	private IWorkbenchAction copyAction;
49  	private IWorkbenchAction cutAction;
50  	private IWorkbenchAction pasteAction;
51  	private IWorkbenchAction undoAction;
52  	private IWorkbenchAction redoAction;
53      private IWorkbenchAction deleteAction;
54      private IWorkbenchAction selectAllAction;
55      private IWorkbenchAction renameAction;
56      private IWorkbenchAction moveAction;
57      private IWorkbenchAction preferenceAction;
58  
59      private IWorkbenchAction backwardHistoryAction;
60      private IWorkbenchAction forwardHistoryAction;
61      private IWorkbenchAction nextAction;
62      private IWorkbenchAction previousAction;
63  
64      private IWorkbenchAction cmssignature;
65      private IWorkbenchAction pdfsignature;
66      private IWorkbenchAction xmlsignature;
67      //private IWorkbenchAction pdfConvert_And_Sign;
68      //private IWorkbenchAction signatureVerification;
69  
70  	private IContributionItem viewsList;
71      private IContributionItem perspectivesList;
72      private IContributionItem reopenEditorsList;
73      
74  	private IWorkbenchAction openPerspectiveAction;
75  	private IWorkbenchAction resetPerspectiveAction;
76  	private IWorkbenchAction savePerspectiveAction;
77      private IWorkbenchAction closePerspectiveAction;
78  
79      //private IWorkbenchAction introAction;
80  	private IWorkbenchAction aboutAction;
81  	private IWorkbenchAction showHelpAction;
82      private IWorkbenchAction searchHelpAction;
83      private IWorkbenchAction dynamicHelpAction;
84  
85      
86  	//private static IActionBarConfigurer thisConfigurer;
87  	private TokenStatus      tokenstatusline;
88  	private OpenOfficeStatus oofficestatusline;
89  	
90  	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
91  		super(configurer);
92  		//thisConfigurer = configurer;
93  	}
94  
95  	protected void makeActions(IWorkbenchWindow window) {
96  		
97  		newAction = ActionFactory.NEW.create( window );
98          newAction.setText( "New..." );
99          newDropDownAction = new NewWizardDropDownAction( window );
100         closeAction = ActionFactory.CLOSE.create( window );
101 		closeAllAction = ActionFactory.CLOSE_ALL.create(window);
102 		saveAction = ActionFactory.SAVE.create(window);
103         saveAsAction = ActionFactory.SAVE_AS.create( window );
104         saveAllAction = ActionFactory.SAVE_ALL.create( window );
105         printAction = ActionFactory.PRINT.create( window );
106         refreshAction = ActionFactory.REFRESH.create( window );
107         propertiesAction = ActionFactory.PROPERTIES.create( window );
108 		exitAction = ActionFactory.QUIT.create(window);
109 		exitAction.setImageDescriptor(GUIIcons.EXIT_ICON);
110         register( newAction );
111         register( closeAction );
112 		register( closeAllAction );
113 		register( saveAction );
114         register( saveAsAction );
115         register( saveAllAction );
116         register( printAction );
117         register( refreshAction );
118         register( propertiesAction );
119 		register( exitAction );
120         //importAction = ActionFactory.IMPORT.create( window );
121         //register( importAction );
122 
123         //exportAction = ActionFactory.EXPORT.create( window );
124         //register( exportAction );
125         
126 		copyAction  = ActionFactory.COPY.create(window);
127 		cutAction   = ActionFactory.CUT.create(window);
128 		pasteAction = ActionFactory.PASTE.create(window);
129 		undoAction  = ActionFactory.UNDO.create(window);
130 		redoAction  = ActionFactory.REDO.create(window);
131         moveAction = ActionFactory.MOVE.create( window );
132         renameAction = ActionFactory.RENAME.create( window );
133         deleteAction = ActionFactory.DELETE.create( window );
134         selectAllAction = ActionFactory.SELECT_ALL.create( window );
135 		preferenceAction = ActionFactory.PREFERENCES.create(window);
136 		preferenceAction.setImageDescriptor(GUIIcons.PREF_ICON);
137 		register(copyAction);
138 		register(cutAction);
139 		register(pasteAction);
140 		register(undoAction);
141 		register(redoAction);
142         register( moveAction );
143         register( renameAction );
144         register( deleteAction );
145         register( selectAllAction );
146 		register(preferenceAction);
147 		
148         forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create( window );
149         register( forwardHistoryAction );
150         backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create( window );
151         register( backwardHistoryAction );
152         nextAction = ActionFactory.NEXT.create( window );
153         register( nextAction );
154         previousAction = ActionFactory.PREVIOUS.create( window );
155         register( previousAction );
156         
157 	    //signature             = new SignDocumentAction();
158 	    //pdfConvert_And_Sign   = new ToPDFAndSignDocumentAction();
159 	    //signatureVerification = new SignatureVerificationAction();
160 
161 		//showViewAction   = ActionFactory.SHOW_VIEW_MENU.create(window);
162 		viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
163         perspectivesList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create( window );
164         reopenEditorsList = ContributionItemFactory.REOPEN_EDITORS.create( window );
165         
166 		openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);
167 		resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window);
168 		savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window);
169 		closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create( window );
170 		
171 		//register(showViewAction);
172 		register(resetPerspectiveAction);
173 		register(savePerspectiveAction);
174         register( closePerspectiveAction );
175 
176 		//introAction = ActionFactory.INTRO.create(window);
177 		showHelpAction = ActionFactory.HELP_CONTENTS.create(window); 
178 	    searchHelpAction = ActionFactory.HELP_SEARCH.create(window);
179 	    dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window); 
180 		aboutAction = ActionFactory.ABOUT.create(window);
181 		//register(introAction);
182 	    register(showHelpAction); 
183 	    register(searchHelpAction);
184 	    register(dynamicHelpAction);
185 		register(aboutAction);
186 		
187 		cmssignature = new CMSSignDocumentAction(window) ;
188 		pdfsignature = new ToPDFAndSignDocumentAction(window);
189 		xmlsignature = new XMLSignDocumentAction(window);
190 		register(cmssignature);
191 		register(pdfsignature);
192 		register(xmlsignature);
193 
194 	}
195 
196 	protected void fillMenuBar(IMenuManager menuBar) {
197 		//File Menu
198 		MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
199 		menuBar.add(fileMenu);
200 		fileMenu.add(newAction);
201         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.NEW_EXT ) );
202         //fileMenu.add( openFileAction );
203         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.OPEN_EXT ) );
204 		fileMenu.add(new Separator());
205         fileMenu.add( closeAction );
206 		fileMenu.add( closeAllAction );
207         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.CLOSE_EXT ) );
208         fileMenu.add( new Separator() );
209         fileMenu.add( saveAction );
210         fileMenu.add( saveAsAction );
211         fileMenu.add( saveAllAction );
212         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) );
213         fileMenu.add( new Separator() );
214         fileMenu.add( refreshAction );
215         fileMenu.add( new Separator() );
216         fileMenu.add( printAction );
217         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.PRINT_EXT ) );
218         fileMenu.add( new Separator() );
219         //fileMenu.add( importAction );
220         //fileMenu.add( exportAction );
221         //fileMenu.add( new GroupMarker( IWorkbenchActionConstants.IMPORT_EXT ) );
222         //fileMenu.add( new Separator() );
223         fileMenu.add( propertiesAction );
224         fileMenu.add( reopenEditorsList );
225         fileMenu.add( new GroupMarker( IWorkbenchActionConstants.MRU ) );
226         fileMenu.add( new Separator() );
227 		fileMenu.add(exitAction);
228 		
229 		//Edit Menu
230 		MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
231 		menuBar.add(editMenu);
232 		
233 		editMenu.add(undoAction);
234 		editMenu.add(redoAction);
235 		editMenu.add(new Separator());
236 		editMenu.add(copyAction);
237 		editMenu.add(cutAction);
238 		editMenu.add(pasteAction);
239 		editMenu.add(new Separator());
240         editMenu.add( deleteAction );
241         editMenu.add( selectAllAction );
242         editMenu.add( new Separator() );
243         editMenu.add( moveAction );
244         editMenu.add( renameAction );
245         editMenu.add( new Separator() );
246 		editMenu.add(preferenceAction);
247 
248 		//Signature Menu
249 		//MenuManager signatureMenu = new MenuManager("&Signature", "");
250 		//menuBar.add(signatureMenu);
251 		//signatureMenu.add(signature);
252 		//signatureMenu.add(pdfConvert_And_Sign);
253 		//signatureMenu.add(new Separator());
254 		//signatureMenu.add(signatureVerification);
255 
256 		//Windows Menu
257 		MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW);
258 		menuBar.add(windowMenu);
259 		
260 		MenuManager viewMenu = new MenuManager("Show View");
261 		viewMenu.add(viewsList);
262 		windowMenu.add(viewMenu);
263 		
264         MenuManager perspectiveMenu = new MenuManager( "Open Perspective", "openPerspective" );
265         perspectiveMenu.add( perspectivesList );
266         windowMenu.add( perspectiveMenu );
267         
268 		windowMenu.add(new Separator());
269 		windowMenu.add(openPerspectiveAction);
270 		windowMenu.add(savePerspectiveAction);
271         windowMenu.add( closePerspectiveAction );
272         //windowMenu.add( closeAllPerspectivesAction );
273 		windowMenu.add(resetPerspectiveAction);
274 
275 		//Help Menu
276 		MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
277 		menuBar.add(helpMenu);
278 		
279 		//helpMenu.add(introAction);
280         //helpMenu.add( new Separator() );
281 		helpMenu.add(showHelpAction);
282 		helpMenu.add(searchHelpAction);
283 		helpMenu.add(dynamicHelpAction);
284 		helpMenu.add(new Separator());
285 		helpMenu.add(aboutAction);
286 		//http://www.eclipse.org/articles/article.php?file=Article-AddingHelpToRCP/index.html
287 
288 	}
289 	
290     /**
291      * Populates the Cool Bar
292      */
293     protected void fillCoolBar1( ICoolBarManager coolBar )
294     {
295         // add main tool bar
296         IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
297         toolbar.add( newDropDownAction );
298         //toolbar.add( saveAction );
299         //toolbar.add( printAction );
300         toolbar.add( preferenceAction );
301         coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar" ) ); //$NON-NLS-1$
302 
303         IToolBarManager signtoolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
304         signtoolbar.add( new CMSSignDocumentAction() );
305         signtoolbar.add( new ToPDFAndSignDocumentAction() );
306         signtoolbar.add( new XMLSignDocumentAction() );
307         coolBar.add( new ToolBarContributionItem( signtoolbar, Application.PLUGIN_ID + ".signbar" ) ); //$NON-NLS-1$
308 
309         // add marker for additions
310         coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) );
311 
312         // add navigation tool bar
313         // some actions are added from org.eclipse.ui.editor to the HISTORY_GROUP
314         IToolBarManager navToolBar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
315         navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) );
316         navToolBar.add( backwardHistoryAction );
317         navToolBar.add( forwardHistoryAction );
318         coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) );
319     }
320 
321     /**
322      * Populates the Cool Bar
323      */
324     protected void fillCoolBar( ICoolBarManager coolBar ) {
325         // add main tool bar
326         IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
327         toolbar.add( newDropDownAction );
328         toolbar.add( saveAction );
329         //toolbar.add( printAction );
330         toolbar.add( preferenceAction );
331         coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar" ) ); //$NON-NLS-1$
332 
333         IToolBarManager signtoolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
334         signtoolbar.add( cmssignature );
335         signtoolbar.add( pdfsignature );
336         signtoolbar.add( xmlsignature );
337         coolBar.add( new ToolBarContributionItem( signtoolbar, Application.PLUGIN_ID + ".signbar" ) ); //$NON-NLS-1$
338 
339         // add marker for additions
340         coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) );
341 
342         // add navigation tool bar
343         // some actions are added from org.eclipse.ui.editor to the HISTORY_GROUP
344         //IToolBarManager navToolBar = new ToolBarManager( SWT.FLAT | SWT.RIGHT );
345         //navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) );
346         //navToolBar.add( backwardHistoryAction );
347         //navToolBar.add( forwardHistoryAction );
348         //coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) );
349     }
350 	@Override
351 	 protected void fillStatusLine(IStatusLineManager statusLine) {
352 		
353 		super.fillStatusLine(statusLine);
354 	  
355 		tokenstatusline   = new TokenStatus(statusLine);
356 		oofficestatusline = new OpenOfficeStatus(statusLine);
357 
358 	 }
359 
360 }