1 19 20 21 package org.netbeans.modules.debugger.ui.actions; 22 23 import java.awt.event.ActionEvent ; 24 import java.util.Iterator ; 25 import javax.swing.Action ; 26 import javax.swing.AbstractAction ; 27 28 import org.netbeans.modules.debugger.ui.Utils; 29 import org.netbeans.modules.debugger.ui.views.View; 30 31 import org.openide.util.NbBundle; 32 import org.openide.windows.Mode; 33 import org.openide.windows.TopComponent; 34 import org.openide.windows.WindowManager; 35 36 37 42 public class ViewActions extends AbstractAction { 43 44 private String viewName; 45 46 private ViewActions (String viewName) { 47 this.viewName = viewName; 48 } 49 50 public Object getValue(String key) { 51 if (key == Action.NAME) { 52 return NbBundle.getMessage (ViewActions.class, (String ) super.getValue(key)); 53 } 54 Object value = super.getValue(key); 55 if (key == Action.SMALL_ICON) { 56 if (value instanceof String ) { 57 value = Utils.getIcon ((String ) value); 58 } 59 } 60 return value; 61 } 62 63 public void actionPerformed (ActionEvent evt) { 64 openComponent (viewName, true); 65 } 66 67 static TopComponent openComponent (String viewName, boolean activate) { 68 TopComponent view = WindowManager.getDefault().findTopComponent(viewName); 69 if (view == null) { 70 throw new IllegalArgumentException (viewName); 71 } 72 view.open(); 73 if (activate) { 74 view.requestActive(); 75 } 76 return view; 77 } 78 79 80 83 public static Action createBreakpointsViewAction () { 84 ViewActions action = new ViewActions("breakpointsView"); 85 action.putValue (Action.NAME, "CTL_BreakpointsAction"); 86 action.putValue (Action.SMALL_ICON, 87 "org/netbeans/modules/debugger/resources/breakpointsView/Breakpoint" ); 89 return action; 90 } 91 92 95 public static Action createCallStackViewAction () { 96 ViewActions action = new ViewActions("callstackView"); 97 action.putValue (Action.NAME, "CTL_CallStackAction"); 98 action.putValue (Action.SMALL_ICON, 99 "org/netbeans/modules/debugger/resources/callStackView/NonCurrentFrame" ); 101 return action; 102 } 103 104 107 public static Action createLocalsViewAction() { 108 ViewActions action = new ViewActions("localsView"); 109 action.putValue (Action.NAME, "CTL_LocalVariablesAction"); 110 action.putValue (Action.SMALL_ICON, 111 "org/netbeans/modules/debugger/resources/localsView/LocalVariable" ); 113 return action; 114 } 115 116 119 public static Action createSessionsViewAction () { 120 ViewActions action = new ViewActions("sessionsView"); 121 action.putValue (Action.NAME, "CTL_SessionsAction"); 122 action.putValue (Action.SMALL_ICON, 123 "org/netbeans/modules/debugger/resources/sessionsView/Session" ); 125 return action; 126 } 127 128 131 public static Action createThreadsViewAction () { 132 ViewActions action = new ViewActions("threadsView"); 133 action.putValue (Action.NAME, "CTL_ThreadsAction"); 134 action.putValue (Action.SMALL_ICON, 135 "org/netbeans/modules/debugger/resources/threadsView/ThreadGroup" ); 137 return action; 138 } 139 140 141 144 public static Action createWatchesViewAction() { 145 ViewActions action = new ViewActions("watchesView"); 146 action.putValue (Action.NAME, "CTL_WatchesAction"); 147 action.putValue (Action.SMALL_ICON, 148 "org/netbeans/modules/debugger/resources/watchesView/Watch" ); 150 return action; 151 } 152 153 } 154 155 | Popular Tags |