ProcedureClassMapAction.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.actions;
00002 
00003 import org.eclipse.core.commands.AbstractHandler;
00004 import org.eclipse.core.commands.ExecutionEvent;
00005 import org.eclipse.core.commands.ExecutionException;
00006 import org.eclipse.jface.dialogs.Dialog;
00007 import org.eclipse.swt.widgets.Shell;
00008 import org.eclipse.ui.IWorkbenchWindow;
00009 import org.eclipse.ui.handlers.HandlerUtil;
00010 import org.eclipse.ui.services.ISourceProviderService;
00011 
00012 import edu.rice.cs.hpc.traceviewer.services.DataService;
00013 import edu.rice.cs.hpc.traceviewer.data.graph.ColorTable;
00014 import edu.rice.cs.hpc.traceviewer.ui.ProcedureClassDialog;
00015 import edu.rice.cs.hpc.traceviewer.data.util.ProcedureClassMap;
00016 
00017 
00018 /****
00019  * 
00020  * action handler to show procedure-class map dialog
00021  *
00022  */
00023 public class ProcedureClassMapAction extends AbstractHandler {
00024 
00025     /*
00026      * (non-Javadoc)
00027      * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
00028      */
00029     public Object execute(ExecutionEvent event) throws ExecutionException {
00030 
00031         final Shell shell = HandlerUtil.getActiveShell(event);
00032         final IWorkbenchWindow win = HandlerUtil.getActiveWorkbenchWindow(event);
00033         
00034         ProcedureClassMap classMap = new ProcedureClassMap(shell.getDisplay());
00035         ProcedureClassDialog dlg = new ProcedureClassDialog(shell, classMap);
00036         if ( dlg.open() == Dialog.OK ) {
00037             classMap.save();
00038             broadcastChanges(win);
00039         }
00040         
00041         return null;
00042     }
00043 
00044     private void broadcastChanges(IWorkbenchWindow winObj) {
00045         
00046         if (winObj == null) {
00047             // impossible to get a window handle
00048             return;
00049         }
00050         ISourceProviderService sourceProviderService = (ISourceProviderService) winObj.getService(
00051                 ISourceProviderService.class);
00052         
00053         DataService dataService = (DataService) sourceProviderService.getSourceProvider(DataService.DATA_PROVIDER);
00054         // reset the color table
00055         ColorTable colorTable = dataService.getData().getColorTable(); 
00056         colorTable.dispose();
00057         colorTable.setColorTable();
00058         
00059         // broadcast to all views
00060         dataService.broadcastUpdate(null);
00061     }
00062 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1