00001 package edu.rice.cs.hpc.traceviewer.operation; 00002 00003 import org.eclipse.core.commands.operations.AbstractOperation; 00004 import org.eclipse.core.commands.operations.IOperationHistory; 00005 import org.eclipse.core.commands.operations.IUndoContext; 00006 import org.eclipse.core.commands.operations.IUndoableOperation; 00007 import org.eclipse.ui.PlatformUI; 00008 00009 import edu.rice.cs.hpc.traceviewer.spaceTimeData.Frame; 00010 00011 /******************************************** 00012 * 00013 * generic trace operation 00014 * 00015 ********************************************/ 00016 public abstract class TraceOperation extends AbstractOperation { 00017 00018 final static public IUndoContext traceContext = new TraceOperationContext(); 00019 final static public IUndoContext undoableContext = new UndoableOperationContext(); 00020 00021 protected Frame frame; 00022 00023 public TraceOperation(String label) { 00024 this(label,null); 00025 } 00026 00027 public TraceOperation(String label, Frame frame) { 00028 super(label + " " + frame); 00029 addContext(traceContext); 00030 this.frame = frame; 00031 } 00032 00033 public Frame getFrame() { 00034 return frame; 00035 } 00036 00037 static public IOperationHistory getOperationHistory() { 00038 return PlatformUI.getWorkbench().getOperationSupport() 00039 .getOperationHistory(); 00040 } 00041 00042 public static IUndoableOperation[] getUndoHistory() 00043 { 00044 return getOperationHistory().getUndoHistory(undoableContext); 00045 } 00046 00047 public static IUndoableOperation[] getRedoHistory() 00048 { 00049 return getOperationHistory().getRedoHistory(undoableContext); 00050 } 00051 00052 public static void clear() 00053 { 00054 TraceOperation.getOperationHistory(). 00055 dispose(undoableContext, true, true, true); 00056 } 00057 }