package org.eparapher.rcp; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.ICoolBarManager; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.ToolBarContributionItem; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ContributionItemFactory; import org.eclipse.ui.actions.NewWizardDropDownAction; import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; import org.eparapher.rcp.actions.CMSSignDocumentAction; import org.eparapher.rcp.actions.ToPDFAndSignDocumentAction; import org.eparapher.rcp.actions.XMLSignDocumentAction; import org.eparapher.rcp.statusline.OpenOfficeStatus; import org.eparapher.rcp.statusline.TokenStatus; import org.eparapher.rcp.tools.GUIIcons; public class ApplicationActionBarAdvisor extends ActionBarAdvisor { private IWorkbenchAction newAction; private IWorkbenchAction newDropDownAction; private IWorkbenchAction closeAction; private IWorkbenchAction closeAllAction; private IWorkbenchAction saveAction; private IWorkbenchAction saveAsAction; private IWorkbenchAction saveAllAction; private IWorkbenchAction printAction; private IWorkbenchAction refreshAction; private IWorkbenchAction propertiesAction; private IWorkbenchAction exitAction; //private IWorkbenchAction importAction; //private IWorkbenchAction exportAction; private IWorkbenchAction copyAction; private IWorkbenchAction cutAction; private IWorkbenchAction pasteAction; private IWorkbenchAction undoAction; private IWorkbenchAction redoAction; private IWorkbenchAction deleteAction; private IWorkbenchAction selectAllAction; private IWorkbenchAction renameAction; private IWorkbenchAction moveAction; private IWorkbenchAction preferenceAction; private IWorkbenchAction backwardHistoryAction; private IWorkbenchAction forwardHistoryAction; private IWorkbenchAction nextAction; private IWorkbenchAction previousAction; private IWorkbenchAction cmssignature; private IWorkbenchAction pdfsignature; private IWorkbenchAction xmlsignature; //private IWorkbenchAction pdfConvert_And_Sign; //private IWorkbenchAction signatureVerification; private IContributionItem viewsList; private IContributionItem perspectivesList; private IContributionItem reopenEditorsList; private IWorkbenchAction openPerspectiveAction; private IWorkbenchAction resetPerspectiveAction; private IWorkbenchAction savePerspectiveAction; private IWorkbenchAction closePerspectiveAction; //private IWorkbenchAction introAction; private IWorkbenchAction aboutAction; private IWorkbenchAction showHelpAction; private IWorkbenchAction searchHelpAction; private IWorkbenchAction dynamicHelpAction; //private static IActionBarConfigurer thisConfigurer; private TokenStatus tokenstatusline; private OpenOfficeStatus oofficestatusline; public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { super(configurer); //thisConfigurer = configurer; } /** * Generates Actions */ protected void makeActions(IWorkbenchWindow window) { newAction = ActionFactory.NEW.create( window ); newAction.setText( "New..." ); newDropDownAction = new NewWizardDropDownAction( window ); closeAction = ActionFactory.CLOSE.create( window ); closeAllAction = ActionFactory.CLOSE_ALL.create(window); saveAction = ActionFactory.SAVE.create(window); saveAsAction = ActionFactory.SAVE_AS.create( window ); saveAllAction = ActionFactory.SAVE_ALL.create( window ); printAction = ActionFactory.PRINT.create( window ); refreshAction = ActionFactory.REFRESH.create( window ); propertiesAction = ActionFactory.PROPERTIES.create( window ); exitAction = ActionFactory.QUIT.create(window); exitAction.setImageDescriptor(GUIIcons.EXIT_ICON); register( newAction ); register( closeAction ); register( closeAllAction ); register( saveAction ); register( saveAsAction ); register( saveAllAction ); register( printAction ); register( refreshAction ); register( propertiesAction ); register( exitAction ); //importAction = ActionFactory.IMPORT.create( window ); //register( importAction ); //exportAction = ActionFactory.EXPORT.create( window ); //register( exportAction ); copyAction = ActionFactory.COPY.create(window); cutAction = ActionFactory.CUT.create(window); pasteAction = ActionFactory.PASTE.create(window); undoAction = ActionFactory.UNDO.create(window); redoAction = ActionFactory.REDO.create(window); moveAction = ActionFactory.MOVE.create( window ); renameAction = ActionFactory.RENAME.create( window ); deleteAction = ActionFactory.DELETE.create( window ); selectAllAction = ActionFactory.SELECT_ALL.create( window ); preferenceAction = ActionFactory.PREFERENCES.create(window); preferenceAction.setImageDescriptor(GUIIcons.PREF_ICON); register(copyAction); register(cutAction); register(pasteAction); register(undoAction); register(redoAction); register( moveAction ); register( renameAction ); register( deleteAction ); register( selectAllAction ); register(preferenceAction); forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create( window ); register( forwardHistoryAction ); backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create( window ); register( backwardHistoryAction ); nextAction = ActionFactory.NEXT.create( window ); register( nextAction ); previousAction = ActionFactory.PREVIOUS.create( window ); register( previousAction ); //signature = new SignDocumentAction(); //pdfConvert_And_Sign = new ToPDFAndSignDocumentAction(); //signatureVerification = new SignatureVerificationAction(); //showViewAction = ActionFactory.SHOW_VIEW_MENU.create(window); viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create(window); perspectivesList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create( window ); reopenEditorsList = ContributionItemFactory.REOPEN_EDITORS.create( window ); openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window); resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window); savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window); closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create( window ); //register(showViewAction); register(resetPerspectiveAction); register(savePerspectiveAction); register( closePerspectiveAction ); //introAction = ActionFactory.INTRO.create(window); showHelpAction = ActionFactory.HELP_CONTENTS.create(window); searchHelpAction = ActionFactory.HELP_SEARCH.create(window); dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window); aboutAction = ActionFactory.ABOUT.create(window); //register(introAction); register(showHelpAction); register(searchHelpAction); register(dynamicHelpAction); register(aboutAction); cmssignature = new CMSSignDocumentAction(window) ; pdfsignature = new ToPDFAndSignDocumentAction(window); xmlsignature = new XMLSignDocumentAction(window); register(cmssignature); register(pdfsignature); register(xmlsignature); } /** * Populates the Menu Bar */ protected void fillMenuBar(IMenuManager menuBar) { //File Menu MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); menuBar.add(fileMenu); fileMenu.add(newAction); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.NEW_EXT ) ); //fileMenu.add( openFileAction ); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.OPEN_EXT ) ); fileMenu.add(new Separator()); fileMenu.add( closeAction ); fileMenu.add( closeAllAction ); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.CLOSE_EXT ) ); fileMenu.add( new Separator() ); fileMenu.add( saveAction ); fileMenu.add( saveAsAction ); fileMenu.add( saveAllAction ); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) ); fileMenu.add( new Separator() ); fileMenu.add( refreshAction ); fileMenu.add( new Separator() ); fileMenu.add( printAction ); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.PRINT_EXT ) ); fileMenu.add( new Separator() ); //fileMenu.add( importAction ); //fileMenu.add( exportAction ); //fileMenu.add( new GroupMarker( IWorkbenchActionConstants.IMPORT_EXT ) ); //fileMenu.add( new Separator() ); fileMenu.add( propertiesAction ); fileMenu.add( reopenEditorsList ); fileMenu.add( new GroupMarker( IWorkbenchActionConstants.MRU ) ); fileMenu.add( new Separator() ); fileMenu.add(exitAction); //Edit Menu MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT); menuBar.add(editMenu); editMenu.add(undoAction); editMenu.add(redoAction); editMenu.add(new Separator()); editMenu.add(copyAction); editMenu.add(cutAction); editMenu.add(pasteAction); editMenu.add(new Separator()); editMenu.add( deleteAction ); editMenu.add( selectAllAction ); editMenu.add( new Separator() ); editMenu.add( moveAction ); editMenu.add( renameAction ); editMenu.add( new Separator() ); editMenu.add(preferenceAction); //Signature Menu //MenuManager signatureMenu = new MenuManager("&Signature", ""); //menuBar.add(signatureMenu); //signatureMenu.add(signature); //signatureMenu.add(pdfConvert_And_Sign); //signatureMenu.add(new Separator()); //signatureMenu.add(signatureVerification); //Windows Menu MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW); menuBar.add(windowMenu); MenuManager viewMenu = new MenuManager("Show View"); viewMenu.add(viewsList); windowMenu.add(viewMenu); MenuManager perspectiveMenu = new MenuManager( "Open Perspective", "openPerspective" ); perspectiveMenu.add( perspectivesList ); windowMenu.add( perspectiveMenu ); windowMenu.add(new Separator()); windowMenu.add(openPerspectiveAction); windowMenu.add(savePerspectiveAction); windowMenu.add( closePerspectiveAction ); //windowMenu.add( closeAllPerspectivesAction ); windowMenu.add(resetPerspectiveAction); //Help Menu MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); menuBar.add(helpMenu); //helpMenu.add(introAction); //helpMenu.add( new Separator() ); helpMenu.add(showHelpAction); helpMenu.add(searchHelpAction); helpMenu.add(dynamicHelpAction); helpMenu.add(new Separator()); helpMenu.add(aboutAction); //http://www.eclipse.org/articles/article.php?file=Article-AddingHelpToRCP/index.html } /** * Populates the Cool Bar */ protected void fillCoolBar1( ICoolBarManager coolBar ) { // add main tool bar IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); toolbar.add( newDropDownAction ); //toolbar.add( saveAction ); //toolbar.add( printAction ); toolbar.add( preferenceAction ); coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar" ) ); //$NON-NLS-1$ IToolBarManager signtoolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); signtoolbar.add( new CMSSignDocumentAction() ); signtoolbar.add( new ToPDFAndSignDocumentAction() ); signtoolbar.add( new XMLSignDocumentAction() ); coolBar.add( new ToolBarContributionItem( signtoolbar, Application.PLUGIN_ID + ".signbar" ) ); //$NON-NLS-1$ // add marker for additions coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) ); // add navigation tool bar // some actions are added from org.eclipse.ui.editor to the HISTORY_GROUP IToolBarManager navToolBar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) ); navToolBar.add( backwardHistoryAction ); navToolBar.add( forwardHistoryAction ); coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) ); } /** * Populates the Cool Bar */ protected void fillCoolBar( ICoolBarManager coolBar ) { // add main tool bar IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); toolbar.add( newDropDownAction ); toolbar.add( saveAction ); //toolbar.add( printAction ); toolbar.add( preferenceAction ); coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar" ) ); //$NON-NLS-1$ IToolBarManager signtoolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); signtoolbar.add( cmssignature ); signtoolbar.add( pdfsignature ); signtoolbar.add( xmlsignature ); coolBar.add( new ToolBarContributionItem( signtoolbar, Application.PLUGIN_ID + ".signbar" ) ); //$NON-NLS-1$ // add marker for additions coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) ); // add navigation tool bar // some actions are added from org.eclipse.ui.editor to the HISTORY_GROUP //IToolBarManager navToolBar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); //navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) ); //navToolBar.add( backwardHistoryAction ); //navToolBar.add( forwardHistoryAction ); //coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) ); } @Override protected void fillStatusLine(IStatusLineManager statusLine) { super.fillStatusLine(statusLine); tokenstatusline = new TokenStatus(statusLine); oofficestatusline = new OpenOfficeStatus(statusLine); } }