TraceCoolBar.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.main;
00002
00003 import org.eclipse.jface.action.Action;
00004 import org.eclipse.jface.action.IToolBarManager;
00005 import org.eclipse.jface.action.Separator;
00006 import org.eclipse.jface.resource.ImageDescriptor;
00007
00008 import edu.rice.cs.hpc.traceviewer.icon.IconManager;
00009 import edu.rice.cs.hpc.traceviewer.operation.RedoOperationAction;
00010 import edu.rice.cs.hpc.traceviewer.operation.UndoOperationAction;
00011
00012 public class TraceCoolBar {
00013
00014 final Action home;
00015 final Action tZoomIn;
00016 final Action tZoomOut;
00017 final Action pZoomIn;
00018 final Action pZoomOut;
00019 final Action save;
00020 final Action open;
00021 final Action goEast;
00022 final Action goWest;
00023 final Action goNorth;
00024 final Action goSouth;
00025
00026
00027 public TraceCoolBar(final IToolBarManager toolbar, final ITraceViewAction action, int style)
00028 {
00029 IconManager iconManager = new IconManager();
00030
00031
00032
00033
00034
00035 final ImageDescriptor homeSamp = iconManager.getObjectDescriptor(IconManager.HOME);
00036 home = new Action(null, homeSamp) {
00037 public void run() {
00038 action.home();
00039 }
00040 };
00041 this.createAction(toolbar, home, "Reset the view to display the whole trace");
00042
00043 toolbar.add(new Separator());
00044
00045 final ImageDescriptor zoomInTim = iconManager.getObjectDescriptor(IconManager.ZOOM_IN_H);
00046 tZoomIn = new Action(null, zoomInTim) {
00047 public void run() {
00048 action.timeZoomIn();
00049 }
00050 };
00051 this.createAction(toolbar, tZoomIn, "Zoom in along the time axis");
00052
00053 final ImageDescriptor zoomOutTim = iconManager.getObjectDescriptor(IconManager.ZOOM_OUT_H);
00054 tZoomOut = new Action(null, zoomOutTim) {
00055 public void run() {
00056 action.timeZoomOut();
00057 }
00058 };
00059 this.createAction(toolbar, tZoomOut, "Zoom out along the time axis");
00060
00061 ImageDescriptor zoomInProc = iconManager.getObjectDescriptor(IconManager.ZOOM_IN_V);
00062 pZoomIn = new Action(null, zoomInProc) {
00063 public void run() {
00064 action.processZoomIn();
00065 }
00066 };
00067 this.createAction(toolbar, pZoomIn, "Zoom in along the process axis");
00068
00069 ImageDescriptor zoomOutProc = iconManager.getObjectDescriptor(IconManager.ZOOM_OUT_V);
00070 pZoomOut = new Action(null, zoomOutProc) {
00071 public void run() {
00072 action.processZoomOut();
00073 }
00074 };
00075 this.createAction(toolbar, pZoomOut, "Zoom out along the process axis");
00076
00077
00078 toolbar.add(new Separator());
00079
00080
00081 final ImageDescriptor eastDesc = iconManager.getObjectDescriptor(IconManager.GO_EAST);
00082 goEast = new Action(null, eastDesc) {
00083 public void run() {
00084 action.goEast();
00085 }
00086 };
00087 this.createAction(toolbar, goEast, "Scroll left one step along the time axis");
00088
00089 final ImageDescriptor westDesc = iconManager.getObjectDescriptor(IconManager.GO_WEST);
00090 goWest = new Action(null, westDesc) {
00091 public void run() {
00092 action.goWest();
00093 }
00094 };
00095 this.createAction(toolbar, goWest, "Scroll right one step along the time axis");
00096
00097
00098 final ImageDescriptor northDesc = iconManager.getObjectDescriptor(IconManager.GO_NORTH);
00099 goNorth = new Action(null, northDesc) {
00100 public void run() {
00101 action.goNorth();
00102 }
00103 };
00104 this.createAction(toolbar, goNorth, "Scroll up one step along the process axis");
00105
00106
00107 final ImageDescriptor southDesc = iconManager.getObjectDescriptor(IconManager.GO_SOUTH);
00108 goSouth = new Action(null, southDesc) {
00109 public void run() {
00110 action.goSouth();
00111 }
00112 };
00113 this.createAction(toolbar, goSouth, "Scroll down one step along the process axis");
00114
00115 toolbar.add(new Separator());
00116
00117 ImageDescriptor undoSamp = iconManager.getObjectDescriptor(IconManager.UNDO);
00118 UndoOperationAction undo = new UndoOperationAction(undoSamp);
00119 this.createAction(toolbar, undo, "Undo the last action");
00120
00121 ImageDescriptor redoSamp = iconManager.getObjectDescriptor(IconManager.REDO);
00122 RedoOperationAction redo = new RedoOperationAction(redoSamp);
00123 this.createAction(toolbar, redo, "Redo the last undo");
00124
00125 toolbar.add(new Separator());
00126
00127 ImageDescriptor saveSamp = iconManager.getObjectDescriptor(IconManager.SAVE);
00128 save = new Action(null, saveSamp) {
00129 public void run() {
00130 action.save();
00131 }
00132 };
00133 this.createAction(toolbar, save, "Save the current view configuration to a file");
00134
00135 ImageDescriptor openSamp = iconManager.getObjectDescriptor(IconManager.OPEN);
00136 open = new Action(null, openSamp) {
00137 public void run() {
00138 action.open();
00139 }
00140 };
00141 this.createAction(toolbar, open, "Open a saved view configuration");
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151 private void createAction(IToolBarManager toolbar, Action action, String sDesc) {
00152 action.setToolTipText(sDesc);
00153 action.setEnabled(false);
00154 toolbar.add(action);
00155 }
00156 }