1 package debugger.gui.debugging;
2
3 import debugger.gui.actions.debugging.ExecuteRHSAction;
4 import debugger.gui.actions.debugging.GoNextBreakpointAction;
5
6 import javax.swing.*;
7 import java.awt.*;
8
9
15 public class PhasePanel extends JComponent {
16 private JToolBar toolBar;
17 private JButton exeRHSButton;
18 private JButton goToNextBreakButton;
19
21 public PhasePanel() {
22 initGui();
23 }
24
25 private void initGui() {
26 toolBar = new JToolBar(JToolBar.HORIZONTAL);
27 toolBar.setLayout(new GridBagLayout());
28 GridBagConstraints c = new GridBagConstraints();
29
30 c.gridx = 0;
31 c.gridy = 0;
32 c.weightx = 0;
33 c.weighty = 0;
34 c.insets = new Insets(1, 0, 1, 1);
35 this.exeRHSButton = createActionButton(ExecuteRHSAction.getInstance(), null, null, false);
36 toolBar.add(this.exeRHSButton, c);
37
38 c.gridx = 1;
39 c.insets = new Insets(1, 1, 1, 1);
40 this.goToNextBreakButton = createActionButton(GoNextBreakpointAction.getInstance(), null, null, false);
41 toolBar.add(goToNextBreakButton, c);
42
43
47 c.gridx = 3;
48 c.weightx = 1;
49 toolBar.add(new JPanel(), c);
50
51 this.setLayout(new BorderLayout());
52 this.add(toolBar, BorderLayout.CENTER);
53 }
54
55
56
64 private JButton createActionButton(Action action, Icon overrideIcon, String overrideToolTip, boolean isFocusPainted) {
65 JButton button = new JButton(action);
66 Icon icon = (Icon) ((null != overrideIcon) ? overrideIcon : action.getValue(Action.SMALL_ICON));
67 if (icon instanceof ImageIcon) {
68 Image iconImage = ((ImageIcon) icon).getImage();
69 Image scaledImage = iconImage.getScaledInstance(16, 16, Image.SCALE_SMOOTH);
70 ImageIcon newIcon = new ImageIcon(scaledImage);
71 button.setIcon(newIcon);
72 } else {
73 button.setIcon(icon);
74 }
75 if (null != overrideToolTip) button.setToolTipText(overrideToolTip);
76 button.setFocusPainted(isFocusPainted);
77 return button;
78 }
79 }
80