1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.ericmignot.modeler.gui.historic; |
19 |
| |
20 |
| import java.awt.BorderLayout; |
21 |
| import java.awt.Color; |
22 |
| import java.awt.Dimension; |
23 |
| import java.awt.GridLayout; |
24 |
| import java.awt.event.ActionEvent; |
25 |
| import java.awt.event.ActionListener; |
26 |
| import java.net.URL; |
27 |
| |
28 |
| import javax.swing.ImageIcon; |
29 |
| import javax.swing.JButton; |
30 |
| import javax.swing.JPanel; |
31 |
| import javax.swing.border.EtchedBorder; |
32 |
| |
33 |
| import org.ericmignot.modeler.gui.Controller; |
34 |
| import org.ericmignot.modeler.gui.StaticValues; |
35 |
| import org.ericmignot.modeler.util.graphic.GraphicHelper; |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| public class HistoricPanel extends JPanel |
41 |
| { |
42 |
| private Controller controller; |
43 |
| private JPanel actionsPanel; |
44 |
| private JButton undoButton; |
45 |
| private JButton redoButton; |
46 |
| private JButton saveButton; |
47 |
| |
48 |
| private JButton zoomInButton; |
49 |
| private JButton zoomOutButton; |
50 |
| |
51 |
119
| public HistoricPanel(Controller controller)
|
52 |
| { |
53 |
119
| this.controller = controller;
|
54 |
| |
55 |
119
| this.setLayout(new BorderLayout());
|
56 |
119
| Color background = GraphicHelper.buildColor(StaticValues.getInstance().get("Design.Historic.BackgroundColor", "236, 233, 216"));
|
57 |
119
| this.setBackground(background);
|
58 |
| |
59 |
119
| this.actionsPanel = new JPanel(new GridLayout(0, 1));
|
60 |
119
| this.actionsPanel.setBackground(background);
|
61 |
| |
62 |
119
| URL undoIconURL = this.getClass().getClassLoader().getResource("org/ericmignot/modeler/gui/historic/undo.GIF");
|
63 |
119
| ImageIcon undoIcon = new ImageIcon(undoIconURL);
|
64 |
119
| undoButton = new JButton(undoIcon);
|
65 |
119
| undoButton.setToolTipText(StaticValues.getInstance().get("Design.Historic.CancelTooltip", "Cancel last action"));
|
66 |
119
| this.actionsPanel.add(undoButton);
|
67 |
119
| undoButton.addActionListener(new ActionListener()
|
68 |
| { |
69 |
0
| public void actionPerformed(ActionEvent e)
|
70 |
| { |
71 |
0
| HistoricPanel.this.controller.treatUndo();
|
72 |
| } |
73 |
| }); |
74 |
119
| int width = undoIcon.getIconWidth();
|
75 |
119
| int height = undoIcon.getIconHeight();
|
76 |
119
| undoButton.setPreferredSize(new Dimension(width, height));
|
77 |
| |
78 |
119
| URL redoIconURL = this.getClass().getClassLoader().getResource("org/ericmignot/modeler/gui/historic/redo.GIF");
|
79 |
119
| ImageIcon redoIcon = new ImageIcon(redoIconURL);
|
80 |
119
| redoButton = new JButton(redoIcon);
|
81 |
119
| redoButton.setToolTipText(StaticValues.getInstance().get("Design.Historic.RedoTooltip", "Redo last cancelled action"));
|
82 |
119
| this.actionsPanel.add(redoButton);
|
83 |
119
| redoButton.addActionListener(new ActionListener()
|
84 |
| { |
85 |
0
| public void actionPerformed(ActionEvent e)
|
86 |
| { |
87 |
0
| HistoricPanel.this.controller.treatRedo();
|
88 |
| } |
89 |
| }); |
90 |
119
| width = redoIcon.getIconWidth();
|
91 |
119
| height = redoIcon.getIconHeight();
|
92 |
119
| redoButton.setPreferredSize(new Dimension(width, height));
|
93 |
| |
94 |
| |
95 |
119
| URL zoomInIconURL = this.getClass().getClassLoader().getResource("org/ericmignot/modeler/gui/historic/zoomIn.GIF");
|
96 |
119
| ImageIcon zoomInIcon = new ImageIcon(zoomInIconURL);
|
97 |
119
| zoomInButton = new JButton(zoomInIcon);
|
98 |
119
| zoomInButton.setToolTipText(StaticValues.getInstance().get("Historic.ZoomInTooltip", "Zoom in"));
|
99 |
119
| this.actionsPanel.add(zoomInButton);
|
100 |
119
| zoomInButton.addActionListener(new ActionListener()
|
101 |
| { |
102 |
0
| public void actionPerformed(ActionEvent e)
|
103 |
| { |
104 |
0
| HistoricPanel.this.controller.treatZoomIn();
|
105 |
| } |
106 |
| }); |
107 |
119
| width = zoomInIcon.getIconWidth();
|
108 |
119
| height = zoomInIcon.getIconHeight();
|
109 |
119
| zoomInButton.setPreferredSize(new Dimension(width, height));
|
110 |
| |
111 |
119
| URL zoomOutIconURL = this.getClass().getClassLoader().getResource("org/ericmignot/modeler/gui/historic/zoomOut.GIF");
|
112 |
119
| ImageIcon zoomOutIcon = new ImageIcon(zoomOutIconURL);
|
113 |
119
| zoomOutButton = new JButton(zoomOutIcon);
|
114 |
119
| zoomOutButton.setToolTipText(StaticValues.getInstance().get("Design.Historic.ZoomOutTooltip", "Zoom out"));
|
115 |
119
| this.actionsPanel.add(zoomOutButton);
|
116 |
119
| zoomOutButton.addActionListener(new ActionListener()
|
117 |
| { |
118 |
0
| public void actionPerformed(ActionEvent e)
|
119 |
| { |
120 |
0
| HistoricPanel.this.controller.treatZoomOut();
|
121 |
| } |
122 |
| }); |
123 |
119
| width = zoomOutIcon.getIconWidth();
|
124 |
119
| height = zoomOutIcon.getIconHeight();
|
125 |
119
| zoomOutButton.setPreferredSize(new Dimension(width, height));
|
126 |
| |
127 |
119
| String saveFunction = StaticValues.getInstance().get("Interface.Save", null);
|
128 |
119
| if (saveFunction != null)
|
129 |
| { |
130 |
2
| URL saveIconURL = this.getClass().getClassLoader().getResource("org/ericmignot/modeler/gui/historic/save.GIF");
|
131 |
2
| ImageIcon saveIcon = new ImageIcon(saveIconURL);
|
132 |
2
| saveButton = new JButton(saveIcon);
|
133 |
2
| saveButton.setToolTipText(StaticValues.getInstance().get("Design.Historic.SaveTooltip", "Save workflow"));
|
134 |
2
| actionsPanel.add(saveButton);
|
135 |
2
| saveButton.addActionListener(new ActionListener()
|
136 |
| { |
137 |
0
| public void actionPerformed(ActionEvent e)
|
138 |
| { |
139 |
0
| HistoricPanel.this.controller.treatSave();
|
140 |
| } |
141 |
| }); |
142 |
2
| width = saveIcon.getIconWidth();
|
143 |
2
| height = saveIcon.getIconHeight();
|
144 |
2
| saveButton.setPreferredSize(new Dimension(width, height));
|
145 |
| } |
146 |
| |
147 |
119
| this.add(this.actionsPanel, BorderLayout.NORTH);
|
148 |
| |
149 |
119
| JPanel tmpPanel = new JPanel();
|
150 |
119
| tmpPanel.setBackground(background);
|
151 |
119
| this.add(tmpPanel, BorderLayout.CENTER);
|
152 |
| |
153 |
119
| this.setBorder(new EtchedBorder());
|
154 |
| } |
155 |
| |
156 |
0
| public void forceDoLayout()
|
157 |
| { |
158 |
0
| this.doLayout();
|
159 |
0
| this.actionsPanel.doLayout();
|
160 |
| } |
161 |
| |
162 |
1
| public JButton getRedoButton()
|
163 |
| { |
164 |
1
| return redoButton;
|
165 |
| } |
166 |
| |
167 |
3
| public JButton getSaveButton()
|
168 |
| { |
169 |
3
| return saveButton;
|
170 |
| } |
171 |
| |
172 |
1
| public JButton getUndoButton()
|
173 |
| { |
174 |
1
| return undoButton;
|
175 |
| } |
176 |
| |
177 |
1
| public JButton getZoomInButton()
|
178 |
| { |
179 |
1
| return zoomInButton;
|
180 |
| } |
181 |
| |
182 |
1
| public JButton getZoomOutButton()
|
183 |
| { |
184 |
1
| return zoomOutButton;
|
185 |
| } |
186 |
| |
187 |
| |
188 |
| |
189 |
| } |