Lines 50-68
Link Here
|
50 |
import java.awt.event.ActionListener; |
50 |
import java.awt.event.ActionListener; |
51 |
import java.awt.event.ItemEvent; |
51 |
import java.awt.event.ItemEvent; |
52 |
import java.awt.event.ItemListener; |
52 |
import java.awt.event.ItemListener; |
|
|
53 |
import java.beans.PropertyChangeEvent; |
54 |
import java.lang.ref.Reference; |
55 |
import java.lang.ref.WeakReference; |
53 |
import java.util.List; |
56 |
import java.util.List; |
54 |
import javax.swing.AbstractAction; |
57 |
import javax.swing.AbstractAction; |
|
|
58 |
import javax.swing.AbstractButton; |
55 |
import javax.swing.Action; |
59 |
import javax.swing.Action; |
56 |
import javax.swing.Icon; |
60 |
import javax.swing.Icon; |
|
|
61 |
import javax.swing.ImageIcon; |
57 |
import javax.swing.JButton; |
62 |
import javax.swing.JButton; |
58 |
import javax.swing.JCheckBoxMenuItem; |
63 |
import javax.swing.JCheckBoxMenuItem; |
59 |
import javax.swing.JPopupMenu; |
64 |
import javax.swing.JPopupMenu; |
60 |
import javax.swing.JRadioButtonMenuItem; |
65 |
import javax.swing.JRadioButtonMenuItem; |
|
|
66 |
import javax.swing.JToggleButton; |
61 |
import javax.swing.SwingUtilities; |
67 |
import javax.swing.SwingUtilities; |
|
|
68 |
import javax.swing.border.EmptyBorder; |
69 |
import org.netbeans.api.debugger.ActiveBreakpoints; |
62 |
import org.netbeans.api.debugger.Breakpoint; |
70 |
import org.netbeans.api.debugger.Breakpoint; |
|
|
71 |
import org.netbeans.api.debugger.DebuggerEngine; |
63 |
import org.netbeans.api.debugger.DebuggerManager; |
72 |
import org.netbeans.api.debugger.DebuggerManager; |
64 |
import org.netbeans.api.debugger.DebuggerManagerAdapter; |
73 |
import org.netbeans.api.debugger.DebuggerManagerAdapter; |
65 |
|
|
|
66 |
import org.netbeans.api.debugger.Properties; |
74 |
import org.netbeans.api.debugger.Properties; |
67 |
import org.netbeans.api.debugger.Session; |
75 |
import org.netbeans.api.debugger.Session; |
68 |
import org.netbeans.api.project.Project; |
76 |
import org.netbeans.api.project.Project; |
Lines 84-89
Link Here
|
84 |
|
92 |
|
85 |
public static final String PREFERENCES_NAME = "variables_view"; // NOI18N |
93 |
public static final String PREFERENCES_NAME = "variables_view"; // NOI18N |
86 |
public static final String SHOW_VALUE_AS_STRING = "show_value_as_string"; // NOI18N |
94 |
public static final String SHOW_VALUE_AS_STRING = "show_value_as_string"; // NOI18N |
|
|
95 |
private static final String DEACTIVATED_LINE_BREAKPOINT = |
96 |
"org/netbeans/modules/debugger/resources/editor/Breakpoint_stroke.png"; // NOI18N |
87 |
|
97 |
|
88 |
public static JButton createNewBreakpointActionButton() { |
98 |
public static JButton createNewBreakpointActionButton() { |
89 |
JButton button = VariablesViewButtons.createButton( |
99 |
JButton button = VariablesViewButtons.createButton( |
Lines 97-102
Link Here
|
97 |
}); |
107 |
}); |
98 |
return button; |
108 |
return button; |
99 |
} |
109 |
} |
|
|
110 |
|
111 |
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session", |
112 |
"CTL_ActivateAllBreakpoints=Activate all breakpoints in current session", |
113 |
"CTL_NoDeactivation=The current session does not allow to deactivate breakpoints", |
114 |
"CTL_NoSession=No debugger session"}) |
115 |
public static AbstractButton createActivateBreakpointsActionButton() { |
116 |
ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false); |
117 |
final JToggleButton button = new JToggleButton(icon); |
118 |
// ensure small size, just for the icon |
119 |
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); |
120 |
button.setPreferredSize(size); |
121 |
button.setMargin(new Insets(1, 1, 1, 1)); |
122 |
button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button))); |
123 |
button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints()); |
124 |
button.setFocusable(false); |
125 |
final BreakpointsActivator ba = new BreakpointsActivator(button); |
126 |
button.addActionListener(ba); |
127 |
DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() { |
128 |
@Override |
129 |
public void propertyChange(PropertyChangeEvent evt) { |
130 |
DebuggerEngine de = (DebuggerEngine) evt.getNewValue(); |
131 |
ba.setCurrentEngine(de); |
132 |
} |
133 |
}); |
134 |
ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine()); |
135 |
return button; |
136 |
} |
137 |
|
138 |
private static class BreakpointsActivator implements ActionListener { |
139 |
|
140 |
private final Reference<JToggleButton> buttonRef; |
141 |
//private DebuggerEngine currentEngine; |
142 |
private volatile ActiveBreakpoints ab; |
143 |
//private String name; |
144 |
|
145 |
public BreakpointsActivator(JToggleButton button) { |
146 |
this.buttonRef = new WeakReference<JToggleButton>(button); |
147 |
} |
148 |
|
149 |
public void setCurrentEngine(DebuggerEngine currentEngine) { |
150 |
//this.currentEngine = currentEngine; |
151 |
//Session session = currentEngine.lookupFirst(null, Session.class); |
152 |
//this.name = session.getName(); |
153 |
final JToggleButton button = buttonRef.get(); |
154 |
if (button == null) { |
155 |
return ; |
156 |
} |
157 |
ActiveBreakpoints ab; |
158 |
final boolean active; |
159 |
final boolean canDeactivate; |
160 |
if (currentEngine == null) { |
161 |
ab = null; |
162 |
active = canDeactivate = false; |
163 |
} else { |
164 |
ab = ActiveBreakpoints.get(currentEngine); |
165 |
active = ab.areBreakpointsActive(); |
166 |
canDeactivate = ab.canDeactivateBreakpoints(); |
167 |
} |
168 |
SwingUtilities.invokeLater(new Runnable() { |
169 |
@Override |
170 |
public void run() { |
171 |
button.setSelected(!active); |
172 |
button.setEnabled(canDeactivate); |
173 |
setTooltip(button, active, canDeactivate); |
174 |
} |
175 |
}); |
176 |
this.ab = ab; |
177 |
} |
178 |
|
179 |
@Override |
180 |
public void actionPerformed(ActionEvent e) { |
181 |
ActiveBreakpoints ab = this.ab; |
182 |
if (ab == null || !ab.canDeactivateBreakpoints()) { |
183 |
return ; |
184 |
} |
185 |
JToggleButton button = (JToggleButton) e.getSource(); |
186 |
final boolean active = !button.isSelected(); |
187 |
ab.setBreakpointsActive(active); |
188 |
setTooltip(button, active, true); |
189 |
} |
190 |
|
191 |
private static void setTooltip(JToggleButton button, boolean active, boolean canDeactivate) { |
192 |
if (!canDeactivate) { |
193 |
if (active) { |
194 |
button.setToolTipText(Bundle.CTL_NoDeactivation()); |
195 |
} else { |
196 |
button.setToolTipText(Bundle.CTL_NoSession()); |
197 |
} |
198 |
} else { |
199 |
if (active) { |
200 |
button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints()); |
201 |
} else { |
202 |
button.setToolTipText(Bundle.CTL_ActivateAllBreakpoints()); |
203 |
} |
204 |
} |
205 |
} |
206 |
} |
100 |
|
207 |
|
101 |
public static synchronized JButton createGroupSelectionButton() { |
208 |
public static synchronized JButton createGroupSelectionButton() { |
102 |
final JButton button = VariablesViewButtons.createButton( |
209 |
final JButton button = VariablesViewButtons.createButton( |