FilterAdd.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.filter.action;
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.InputDialog;
00007 import org.eclipse.jface.window.Window;
00008 import org.eclipse.swt.widgets.Shell;
00009 import org.eclipse.ui.IWorkbenchWindow;
00010 import org.eclipse.ui.handlers.HandlerUtil;
00011 import org.eclipse.ui.services.ISourceProviderService;
00012
00013 import edu.rice.cs.hpc.data.filter.FilterAttribute;
00014 import edu.rice.cs.hpc.filter.pattern.PatternValidator;
00015 import edu.rice.cs.hpc.filter.service.FilterMap;
00016 import edu.rice.cs.hpc.filter.service.FilterStateProvider;
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 public class FilterAdd extends AbstractHandler
00027 {
00028
00029 @Override
00030 public Object execute(ExecutionEvent event) throws ExecutionException
00031 {
00032
00033
00034
00035 IWorkbenchWindow winObj = HandlerUtil.getActiveWorkbenchWindow(event);
00036
00037
00038
00039 final Shell shell = HandlerUtil.getActiveShell(event);
00040 final InputDialog dialog = new InputDialog(shell, "Add a pattern",
00041 "Use a glob pattern to define a filter. For instance, a MPI* will filter all MPI routines",
00042 "", new PatternValidator());
00043
00044 if (dialog.open() == Window.OK)
00045 {
00046
00047 FilterAttribute attribute = new FilterAttribute();
00048 final FilterMap filterMap = FilterMap.getInstance();
00049 filterMap.put(dialog.getValue(), attribute);
00050
00051
00052 ISourceProviderService sourceProviderService = (ISourceProviderService) winObj.getService(
00053 ISourceProviderService.class);
00054
00055 final FilterStateProvider provider = (FilterStateProvider) sourceProviderService.getSourceProvider(
00056 FilterStateProvider.FILTER_REFRESH_PROVIDER);
00057
00058 provider.refresh();
00059 }
00060 return null;
00061 }
00062 }