Merge lp:~neos/revager/better-findings-list into lp:revager
- better-findings-list
- Merge into trunk
Proposed by
Davide Casciato
Status: | Merged |
---|---|
Merged at revision: | 41 |
Proposed branch: | lp:~neos/revager/better-findings-list |
Merge into: | lp:revager |
Diff against target: |
3667 lines (+1661/-1713) 9 files modified
src/org/revager/gui/actions/OpenProtocolFrameAction.java (+59/-33) src/org/revager/gui/models/FindExtRefTableModel.java (+2/-2) src/org/revager/gui/protocol/ColoredTableCellRenderer.java (+0/-110) src/org/revager/gui/protocol/FindingItem.java (+0/-1047) src/org/revager/gui/protocol/FindingPanel.java (+1116/-0) src/org/revager/gui/protocol/FindingsTab.java (+421/-0) src/org/revager/gui/protocol/ProtocolFrame.java (+30/-521) src/org/revager/resources/localeStrings_de.properties (+17/-0) src/org/revager/resources/localeStrings_en.properties (+16/-0) |
To merge this branch: | bzr merge lp:~neos/revager/better-findings-list |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Team NEOS | Pending | ||
Review via email: mp+26243@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/org/revager/gui/actions/OpenProtocolFrameAction.java' |
2 | --- src/org/revager/gui/actions/OpenProtocolFrameAction.java 2010-01-31 17:32:35 +0000 |
3 | +++ src/org/revager/gui/actions/OpenProtocolFrameAction.java 2010-05-27 20:33:41 +0000 |
4 | @@ -24,11 +24,13 @@ |
5 | |
6 | import javax.swing.AbstractAction; |
7 | import javax.swing.KeyStroke; |
8 | +import javax.swing.SwingWorker; |
9 | import javax.swing.tree.DefaultMutableTreeNode; |
10 | import javax.swing.tree.TreePath; |
11 | |
12 | import org.revager.app.Application; |
13 | import org.revager.app.FindingManagement; |
14 | +import org.revager.app.SeverityManagement; |
15 | import org.revager.app.model.Data; |
16 | import org.revager.app.model.schema.Finding; |
17 | import org.revager.app.model.schema.Meeting; |
18 | @@ -37,7 +39,6 @@ |
19 | import org.revager.gui.helpers.TreeMeeting; |
20 | import org.revager.gui.helpers.TreeProtocol; |
21 | |
22 | - |
23 | /** |
24 | * The Class OpenProtocolFrameAction. |
25 | */ |
26 | @@ -46,6 +47,8 @@ |
27 | |
28 | private FindingManagement findingMgmt = Application.getInstance() |
29 | .getFindingMgmt(); |
30 | + private SeverityManagement sevMgmt = Application.getInstance() |
31 | + .getSeverityMgmt(); |
32 | |
33 | /** |
34 | * Instantiates a new open protocol frame action. |
35 | @@ -66,39 +69,62 @@ |
36 | * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
37 | */ |
38 | @Override |
39 | - public void actionPerformed(ActionEvent arg0) { |
40 | - Meeting editMeet; |
41 | - Protocol currentProt; |
42 | - |
43 | - TreePath path = UI.getInstance().getMainFrame().getMeetingsTree() |
44 | - .getSelectionPath(); |
45 | - |
46 | - if (path.getPathCount() == 3) |
47 | - editMeet = ((TreeProtocol) ((DefaultMutableTreeNode) path |
48 | - .getLastPathComponent()).getUserObject()).getMeeting(); |
49 | - else |
50 | - editMeet = ((TreeMeeting) ((DefaultMutableTreeNode) path |
51 | - .getLastPathComponent()).getUserObject()).getMeeting(); |
52 | - |
53 | - currentProt = Application.getInstance().getProtocolMgmt().getProtocol( |
54 | - editMeet); |
55 | - if (currentProt == null) { |
56 | - currentProt = new Protocol(); |
57 | - currentProt.setDate(editMeet.getPlannedDate()); |
58 | - currentProt.setLocation(editMeet.getPlannedLocation()); |
59 | - currentProt.setStart(editMeet.getPlannedStart()); |
60 | - currentProt.setEnd(editMeet.getPlannedEnd()); |
61 | - currentProt.setComments(""); |
62 | - findingMgmt.addFinding(new Finding(), currentProt); |
63 | + public void actionPerformed(ActionEvent e) { |
64 | + new OpenProtocolFrameWorker().execute(); |
65 | + } |
66 | + |
67 | + private class OpenProtocolFrameWorker extends SwingWorker<Void, Void> { |
68 | + @Override |
69 | + protected Void doInBackground() throws Exception { |
70 | + try { |
71 | + UI.getInstance().getMainFrame().switchToProgressMode(); |
72 | + |
73 | + Meeting editMeet; |
74 | + Protocol currentProt; |
75 | + |
76 | + TreePath path = UI.getInstance().getMainFrame() |
77 | + .getMeetingsTree().getSelectionPath(); |
78 | + |
79 | + if (path.getPathCount() == 3) |
80 | + editMeet = ((TreeProtocol) ((DefaultMutableTreeNode) path |
81 | + .getLastPathComponent()).getUserObject()) |
82 | + .getMeeting(); |
83 | + else |
84 | + editMeet = ((TreeMeeting) ((DefaultMutableTreeNode) path |
85 | + .getLastPathComponent()).getUserObject()) |
86 | + .getMeeting(); |
87 | + |
88 | + currentProt = Application.getInstance().getProtocolMgmt() |
89 | + .getProtocol(editMeet); |
90 | + if (currentProt == null) { |
91 | + currentProt = new Protocol(); |
92 | + currentProt.setDate(editMeet.getPlannedDate()); |
93 | + currentProt.setLocation(editMeet.getPlannedLocation()); |
94 | + currentProt.setStart(editMeet.getPlannedStart()); |
95 | + currentProt.setEnd(editMeet.getPlannedEnd()); |
96 | + currentProt.setComments(""); |
97 | + |
98 | + Finding newFind = new Finding(); |
99 | + newFind.setSeverity(sevMgmt.getSeverities().get(0)); |
100 | + |
101 | + findingMgmt.addFinding(newFind, currentProt); |
102 | + } |
103 | + |
104 | + Application.getInstance().getProtocolMgmt().setProtocol( |
105 | + currentProt, editMeet); |
106 | + |
107 | + UI.getInstance().getProtocolFrame().resetClock(); |
108 | + UI.getInstance().getProtocolFrame().setMeeting(editMeet); |
109 | + UI.getInstance().getProtocolFrame().setVisible(true); |
110 | + UI.getInstance().getMainFrame().updateMeetingsTree(); |
111 | + |
112 | + UI.getInstance().getMainFrame().switchToEditMode(); |
113 | + } catch (Exception e) { |
114 | + UI.getInstance().getMainFrame().switchToEditMode(); |
115 | + } |
116 | + |
117 | + return null; |
118 | } |
119 | - Application.getInstance().getProtocolMgmt().setProtocol(currentProt, |
120 | - editMeet); |
121 | - |
122 | - UI.getInstance().getProtocolFrame().resetClock(); |
123 | - UI.getInstance().getProtocolFrame().setMeeting(editMeet); |
124 | - UI.getInstance().getProtocolFrame().setVisible(true); |
125 | - UI.getInstance().getMainFrame().updateMeetingsTree(); |
126 | - |
127 | } |
128 | |
129 | } |
130 | |
131 | === added file 'src/org/revager/gui/icons/closeFinding_25x25.png' |
132 | Binary files src/org/revager/gui/icons/closeFinding_25x25.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/closeFinding_25x25.png 2010-05-27 20:33:41 +0000 differ |
133 | === added file 'src/org/revager/gui/icons/closeFinding_25x25_0.png' |
134 | Binary files src/org/revager/gui/icons/closeFinding_25x25_0.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/closeFinding_25x25_0.png 2010-05-27 20:33:41 +0000 differ |
135 | === added file 'src/org/revager/gui/icons/delete_25x25.png' |
136 | Binary files src/org/revager/gui/icons/delete_25x25.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/delete_25x25.png 2010-05-27 20:33:41 +0000 differ |
137 | === added file 'src/org/revager/gui/icons/delete_25x25_0.png' |
138 | Binary files src/org/revager/gui/icons/delete_25x25_0.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/delete_25x25_0.png 2010-05-27 20:33:41 +0000 differ |
139 | === added file 'src/org/revager/gui/icons/paste_25x25.png' |
140 | Binary files src/org/revager/gui/icons/paste_25x25.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/paste_25x25.png 2010-05-27 20:33:41 +0000 differ |
141 | === added file 'src/org/revager/gui/icons/paste_25x25_0.png' |
142 | Binary files src/org/revager/gui/icons/paste_25x25_0.png 1970-01-01 00:00:00 +0000 and src/org/revager/gui/icons/paste_25x25_0.png 2010-05-27 20:33:41 +0000 differ |
143 | === renamed file 'src/org/revager/gui/models/FindExRefTableModel.java' => 'src/org/revager/gui/models/FindExtRefTableModel.java' |
144 | --- src/org/revager/gui/models/FindExRefTableModel.java 2010-01-31 17:32:35 +0000 |
145 | +++ src/org/revager/gui/models/FindExtRefTableModel.java 2010-05-27 20:33:41 +0000 |
146 | @@ -30,7 +30,7 @@ |
147 | * The Class FindExRefTableModel. |
148 | */ |
149 | @SuppressWarnings("serial") |
150 | -public class FindExRefTableModel extends AbstractTableModel { |
151 | +public class FindExtRefTableModel extends AbstractTableModel { |
152 | |
153 | private FindingManagement findingMgmt = Application.getInstance() |
154 | .getFindingMgmt(); |
155 | @@ -42,7 +42,7 @@ |
156 | * @param currentFinding |
157 | * the current finding |
158 | */ |
159 | - public FindExRefTableModel(Finding currentFinding) { |
160 | + public FindExtRefTableModel(Finding currentFinding) { |
161 | localFind = currentFinding; |
162 | } |
163 | |
164 | |
165 | === removed file 'src/org/revager/gui/protocol/ColoredTableCellRenderer.java' |
166 | --- src/org/revager/gui/protocol/ColoredTableCellRenderer.java 2010-01-31 17:32:35 +0000 |
167 | +++ src/org/revager/gui/protocol/ColoredTableCellRenderer.java 1970-01-01 00:00:00 +0000 |
168 | @@ -1,110 +0,0 @@ |
169 | -/* |
170 | - * Copyright 2009 Davide Casciato, Sandra Reich, Johannes Wettinger |
171 | - * |
172 | - * This file is part of Resi. |
173 | - * |
174 | - * Resi is free software: you can redistribute it and/or modify |
175 | - * it under the terms of the GNU General Public License as published by |
176 | - * the Free Software Foundation, either version 3 of the License, or |
177 | - * (at your option) any later version. |
178 | - * |
179 | - * Resi is distributed in the hope that it will be useful, |
180 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
181 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
182 | - * GNU General Public License for more details. |
183 | - * |
184 | - * You should have received a copy of the GNU General Public License |
185 | - * along with Resi. If not, see <http://www.gnu.org/licenses/>. |
186 | - */ |
187 | -package org.revager.gui.protocol; |
188 | - |
189 | -import java.awt.Component; |
190 | - |
191 | -import javax.swing.BorderFactory; |
192 | -import javax.swing.JLabel; |
193 | -import javax.swing.JPanel; |
194 | -import javax.swing.JTable; |
195 | -import javax.swing.table.DefaultTableCellRenderer; |
196 | - |
197 | -import org.revager.app.Application; |
198 | -import org.revager.app.FindingManagement; |
199 | -import org.revager.app.model.schema.Finding; |
200 | -import org.revager.app.model.schema.Protocol; |
201 | -import org.revager.gui.UI; |
202 | -import org.revager.tools.GUITools; |
203 | - |
204 | - |
205 | -/** |
206 | - * The Class ColoredTableCellRenderer. |
207 | - */ |
208 | -@SuppressWarnings("serial") |
209 | -public class ColoredTableCellRenderer extends DefaultTableCellRenderer { |
210 | - FindingManagement findMgmt = Application.getInstance().getFindingMgmt(); |
211 | - private Protocol prot; |
212 | - |
213 | - /** |
214 | - * Instantiates a new colored table cell renderer. |
215 | - * |
216 | - * @param currentProt |
217 | - * the current prot |
218 | - */ |
219 | - public ColoredTableCellRenderer(Protocol currentProt) { |
220 | - prot = currentProt; |
221 | - } |
222 | - |
223 | - /* |
224 | - * (non-Javadoc) |
225 | - * |
226 | - * @see |
227 | - * javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax |
228 | - * .swing.JTable, java.lang.Object, boolean, boolean, int, int) |
229 | - */ |
230 | - @Override |
231 | - public Component getTableCellRendererComponent(JTable table, Object value, |
232 | - boolean isSelected, boolean hasFocus, int row, int column) { |
233 | - JPanel localPnl = new JPanel(); |
234 | - |
235 | - JLabel label = new JLabel(String.valueOf(value)); |
236 | - label.setFont(UI.PROTOCOL_FONT); |
237 | - label.setForeground(UI.DARK_BLUE_COLOR); |
238 | - |
239 | - localPnl.add(label); |
240 | - |
241 | - if (findMgmt.getFindings(prot).get(row).getDescription().trim().equals( |
242 | - "")) { |
243 | - localPnl.setBorder(BorderFactory.createLineBorder(UI.MARKED_COLOR, |
244 | - 2)); |
245 | - } else { |
246 | - localPnl.setBorder(UI.STANDARD_BORDER); |
247 | - } |
248 | - |
249 | - // if (isSelected) |
250 | - // localPnl.setBackground(UI.TABLE_SELECTION_COLOR); |
251 | - // else |
252 | - // localPnl.setBackground(null); |
253 | - |
254 | - int fVF = UI.getInstance().getProtocolFrame().getFirstVisibleFinding(); |
255 | - int lVF = fVF |
256 | - + UI.getInstance().getProtocolFrame().getVisibleFindingsCount() |
257 | - - 1; |
258 | - if (row >= fVF && row <= lVF) { |
259 | - localPnl.setBackground(UI.BLUE_BACKGROUND_COLOR); |
260 | - } else { |
261 | - localPnl.setBackground(null); |
262 | - } |
263 | - |
264 | - Finding find = Application.getInstance().getFindingMgmt().getFinding( |
265 | - (Integer) value, prot); |
266 | - |
267 | - if (find != null) { |
268 | - String tip = GUITools.getTextAsHtml("<font size=\"5\"><b>(" |
269 | - + find.getId() + ") " + find.getSeverity() + "</b>" |
270 | - + "\n\n" + find.getDescription() + "</font>"); |
271 | - |
272 | - setToolTipText(tip); |
273 | - } |
274 | - |
275 | - return localPnl; |
276 | - } |
277 | - |
278 | -} |
279 | |
280 | === removed file 'src/org/revager/gui/protocol/FindingItem.java' |
281 | --- src/org/revager/gui/protocol/FindingItem.java 2010-01-31 17:32:35 +0000 |
282 | +++ src/org/revager/gui/protocol/FindingItem.java 1970-01-01 00:00:00 +0000 |
283 | @@ -1,1047 +0,0 @@ |
284 | -/* |
285 | - * Copyright 2009 Davide Casciato, Sandra Reich, Johannes Wettinger |
286 | - * |
287 | - * This file is part of Resi. |
288 | - * |
289 | - * Resi is free software: you can redistribute it and/or modify |
290 | - * it under the terms of the GNU General Public License as published by |
291 | - * the Free Software Foundation, either version 3 of the License, or |
292 | - * (at your option) any later version. |
293 | - * |
294 | - * Resi is distributed in the hope that it will be useful, |
295 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
296 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
297 | - * GNU General Public License for more details. |
298 | - * |
299 | - * You should have received a copy of the GNU General Public License |
300 | - * along with Resi. If not, see <http://www.gnu.org/licenses/>. |
301 | - */ |
302 | -package org.revager.gui.protocol; |
303 | - |
304 | -import java.awt.BorderLayout; |
305 | -import java.awt.Color; |
306 | -import java.awt.Component; |
307 | -import java.awt.Desktop; |
308 | -import java.awt.Font; |
309 | -import java.awt.GridBagConstraints; |
310 | -import java.awt.GridBagLayout; |
311 | -import java.awt.GridLayout; |
312 | -import java.awt.Image; |
313 | -import java.awt.event.ActionEvent; |
314 | -import java.awt.event.ActionListener; |
315 | -import java.awt.event.FocusEvent; |
316 | -import java.awt.event.FocusListener; |
317 | -import java.awt.event.ItemEvent; |
318 | -import java.awt.event.ItemListener; |
319 | -import java.awt.event.KeyEvent; |
320 | -import java.awt.event.KeyListener; |
321 | -import java.awt.event.MouseEvent; |
322 | -import java.awt.event.MouseListener; |
323 | -import java.io.File; |
324 | -import java.util.List; |
325 | -import java.util.Observable; |
326 | -import java.util.Observer; |
327 | - |
328 | -import javax.swing.ImageIcon; |
329 | -import javax.swing.JButton; |
330 | -import javax.swing.JComboBox; |
331 | -import javax.swing.JLabel; |
332 | -import javax.swing.JOptionPane; |
333 | -import javax.swing.JPanel; |
334 | -import javax.swing.JScrollPane; |
335 | -import javax.swing.JTable; |
336 | -import javax.swing.JTextArea; |
337 | -import javax.swing.JTextField; |
338 | -import javax.swing.SwingWorker; |
339 | -import javax.swing.border.CompoundBorder; |
340 | -import javax.swing.border.EmptyBorder; |
341 | -import javax.swing.border.MatteBorder; |
342 | -import javax.swing.table.DefaultTableCellRenderer; |
343 | - |
344 | -import org.revager.app.Application; |
345 | -import org.revager.app.FindingManagement; |
346 | -import org.revager.app.ResiFileFilter; |
347 | -import org.revager.app.SeverityManagement; |
348 | -import org.revager.app.model.Data; |
349 | -import org.revager.app.model.DataException; |
350 | -import org.revager.app.model.ResiData; |
351 | -import org.revager.app.model.appdata.AppSettingKey; |
352 | -import org.revager.app.model.appdata.AppSettingValue; |
353 | -import org.revager.app.model.schema.Aspect; |
354 | -import org.revager.app.model.schema.Finding; |
355 | -import org.revager.app.model.schema.Protocol; |
356 | -import org.revager.gui.UI; |
357 | -import org.revager.gui.helpers.DefaultTableHeaderCellRenderer; |
358 | -import org.revager.gui.helpers.FileChooser; |
359 | -import org.revager.gui.models.FindAspTableModel; |
360 | -import org.revager.gui.models.FindExRefTableModel; |
361 | -import org.revager.gui.models.FindRefTableModel; |
362 | -import org.revager.gui.protocol.AddAspToFindPopupWindow.ButtonClicked; |
363 | -import org.revager.tools.AppTools; |
364 | -import org.revager.tools.GUITools; |
365 | - |
366 | - |
367 | -/** |
368 | - * The Class FindingItem. |
369 | - */ |
370 | -@SuppressWarnings("serial") |
371 | -public class FindingItem extends JPanel implements Observer { |
372 | - |
373 | - private FindingManagement findMgmt = Application.getInstance() |
374 | - .getFindingMgmt(); |
375 | - |
376 | - private JComboBox sevBx; |
377 | - private JTextArea descTxtArea; |
378 | - |
379 | - // private JLabel sevLbl = new JLabel(Data.getInstance().getLocaleStr( |
380 | - // "editProtocol.finding.sev")); |
381 | - // private JLabel descLbl = new JLabel(Data.getInstance().getLocaleStr( |
382 | - // "editProtocol.finding.desc")); |
383 | - private JLabel idLbl; |
384 | - |
385 | - private GridBagLayout gbl = new GridBagLayout(); |
386 | - private GridLayout gl = new GridLayout(3, 1); |
387 | - |
388 | - private FindRefTableModel frtm; |
389 | - private FindExRefTableModel fertm; |
390 | - private FindAspTableModel fatm; |
391 | - |
392 | - private JTable refTbl; |
393 | - private JTable exRefTbl; |
394 | - private JTable aspTbl; |
395 | - |
396 | - private JScrollPane descScrllPn; |
397 | - private JScrollPane refScrllPn; |
398 | - private JScrollPane exRefScrllPn; |
399 | - private JScrollPane aspScrllPn; |
400 | - |
401 | - private JButton addRefBttn; |
402 | - private JButton ediRefBttn; |
403 | - private JButton remRefBttn; |
404 | - |
405 | - private JButton addExRefBttn; |
406 | - private JButton remExRefBttn; |
407 | - |
408 | - private JButton addAspBttn; |
409 | - private JButton remAspBttn; |
410 | - |
411 | - private JButton pushUpBttn; |
412 | - private JButton pushDownBttn; |
413 | - |
414 | - private JButton remFindBttn; |
415 | - |
416 | - private JButton pasteExRefBttn; |
417 | - |
418 | - private Finding currentFinding; |
419 | - private Protocol currentProtocol; |
420 | - |
421 | - private ImageIcon addIcon = Data.getInstance().getIcon("add_25x25_0.png"); |
422 | - private ImageIcon remIcon = Data.getInstance() |
423 | - .getIcon("remove_25x25_0.png"); |
424 | - private ImageIcon editIcon = Data.getInstance().getIcon("edit_25x25_0.png"); |
425 | - private ImageIcon pushUpIcon = Data.getInstance().getIcon( |
426 | - "upArrow_25x25_0.png"); |
427 | - private ImageIcon pushDownIcon = Data.getInstance().getIcon( |
428 | - "downArrow_25x25_0.png"); |
429 | - private ImageIcon remFindIcon = Data.getInstance().getIcon( |
430 | - "clear_22x22_0.png"); |
431 | - private ImageIcon showExRefIcon = Data.getInstance().getIcon( |
432 | - "show_25x25_0.png"); |
433 | - |
434 | - private ImageIcon rolloverAddIcon = Data.getInstance().getIcon( |
435 | - "add_25x25.png"); |
436 | - private ImageIcon rolloverRemIcon = Data.getInstance().getIcon( |
437 | - "remove_25x25.png"); |
438 | - private ImageIcon rolloverEditIcon = Data.getInstance().getIcon( |
439 | - "edit_25x25.png"); |
440 | - private ImageIcon rolloverPushUpIcon = Data.getInstance().getIcon( |
441 | - "upArrow_25x25.png"); |
442 | - private ImageIcon rolloverPushDownIcon = Data.getInstance().getIcon( |
443 | - "downArrow_25x25.png"); |
444 | - private ImageIcon rolloverRemFindIcon = Data.getInstance().getIcon( |
445 | - "clear_22x22.png"); |
446 | - private ImageIcon rolloverShowExRefIcon = Data.getInstance().getIcon( |
447 | - "show_25x25.png"); |
448 | - |
449 | - private FindingManagement findingMgmt = Application.getInstance() |
450 | - .getFindingMgmt(); |
451 | - private SeverityManagement sevMgmt = Application.getInstance() |
452 | - .getSeverityMgmt(); |
453 | - private ResiData resiData = Data.getInstance().getResiData(); |
454 | - |
455 | - private FocusListener focusListener = new FocusListener() { |
456 | - @Override |
457 | - public void focusGained(FocusEvent e) { |
458 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
459 | - e.getSource()); |
460 | - |
461 | - updateTableButtons(); |
462 | - } |
463 | - |
464 | - @Override |
465 | - public void focusLost(FocusEvent e) { |
466 | - updateTableButtons(); |
467 | - } |
468 | - }; |
469 | - |
470 | - /** |
471 | - * Instantiates a new finding item. |
472 | - * |
473 | - * @param find |
474 | - * the find |
475 | - * @param prot |
476 | - * the prot |
477 | - */ |
478 | - public FindingItem(Finding find, Protocol prot) { |
479 | - super(); |
480 | - |
481 | - Data.getInstance().getResiData().addObserver(this); |
482 | - |
483 | - currentFinding = find; |
484 | - |
485 | - currentProtocol = prot; |
486 | - |
487 | - setLayout(gbl); |
488 | - String nr = Data.getInstance().getLocaleStr( |
489 | - "editProtocol.finding.number") |
490 | - + " "; |
491 | - idLbl = new JLabel(nr.concat(currentFinding.getId().toString())); |
492 | - idLbl.setFont(UI.PROTOCOL_TITLE_FONT); |
493 | - idLbl.setForeground(Color.DARK_GRAY); |
494 | - |
495 | - /* |
496 | - * creating buttons and their panels |
497 | - */ |
498 | - JPanel refBttnPnl = new JPanel(gl); |
499 | - JPanel exRefBttnPnl = new JPanel(gl); |
500 | - JPanel aspBttnPnl = new JPanel(gl); |
501 | - |
502 | - refBttnPnl.setOpaque(false); |
503 | - exRefBttnPnl.setOpaque(false); |
504 | - aspBttnPnl.setOpaque(false); |
505 | - |
506 | - /* |
507 | - * creating refButtons and adding them to their panel |
508 | - */ |
509 | - |
510 | - addRefBttn = GUITools.newImageButton(addIcon, rolloverAddIcon); |
511 | - addRefBttn.addActionListener(new ActionListener() { |
512 | - @Override |
513 | - public void actionPerformed(ActionEvent e) { |
514 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
515 | - refTbl); |
516 | - |
517 | - if (refTbl.getCellEditor() != null) { |
518 | - refTbl.getCellEditor().stopCellEditing(); |
519 | - } |
520 | - |
521 | - String ref = Data.getInstance().getLocaleStr( |
522 | - "editProtocol.finding.newRef"); |
523 | - findingMgmt.addReference(ref, currentFinding); |
524 | - frtm.fireTableDataChanged(); |
525 | - |
526 | - int row = refTbl.getRowCount() - 1; |
527 | - |
528 | - refTbl.scrollRectToVisible(refTbl.getCellRect(row, 0, false)); |
529 | - refTbl.editCellAt(row, 0); |
530 | - } |
531 | - }); |
532 | - |
533 | - remRefBttn = GUITools.newImageButton(remIcon, rolloverRemIcon); |
534 | - remRefBttn.addActionListener(new ActionListener() { |
535 | - @Override |
536 | - public void actionPerformed(ActionEvent e) { |
537 | - int selRow = refTbl.getSelectedRow(); |
538 | - |
539 | - if (refTbl.getEditingRow() != -1) { |
540 | - selRow = refTbl.getEditingRow(); |
541 | - |
542 | - refTbl.getCellEditor().stopCellEditing(); |
543 | - } |
544 | - |
545 | - if (selRow != -1) { |
546 | - String ref = findingMgmt.getReferences(currentFinding).get( |
547 | - selRow); |
548 | - findingMgmt.removeReference(ref, currentFinding); |
549 | - frtm.fireTableDataChanged(); |
550 | - } |
551 | - |
552 | - updateTableButtons(); |
553 | - } |
554 | - }); |
555 | - |
556 | - ediRefBttn = GUITools.newImageButton(editIcon, rolloverEditIcon); |
557 | - ediRefBttn.addActionListener(new ActionListener() { |
558 | - @Override |
559 | - public void actionPerformed(ActionEvent e) { |
560 | - int selRow = refTbl.getSelectedRow(); |
561 | - if (selRow != -1) { |
562 | - refTbl.editCellAt(selRow, 0); |
563 | - frtm.fireTableDataChanged(); |
564 | - } |
565 | - } |
566 | - }); |
567 | - |
568 | - addRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
569 | - "findingsItem.addRef")); |
570 | - remRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
571 | - "findingsItem.remRef")); |
572 | - ediRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
573 | - "findingsItem.ediRef")); |
574 | - |
575 | - refBttnPnl.add(addRefBttn); |
576 | - refBttnPnl.add(remRefBttn); |
577 | - refBttnPnl.add(ediRefBttn); |
578 | - |
579 | - /* |
580 | - * creating exRefButton and adding them to their panels |
581 | - */ |
582 | - |
583 | - addExRefBttn = GUITools.newImageButton(addIcon, rolloverAddIcon); |
584 | - addExRefBttn.addActionListener(new ActionListener() { |
585 | - @Override |
586 | - public void actionPerformed(ActionEvent e) { |
587 | - final ProtocolFrame protFrame = UI.getInstance() |
588 | - .getProtocolFrame(); |
589 | - |
590 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
591 | - exRefTbl); |
592 | - |
593 | - SwingWorker<Void, Void> addExtRefWorker = new SwingWorker<Void, Void>() { |
594 | - @Override |
595 | - protected Void doInBackground() throws Exception { |
596 | - FileChooser fileChooser = UI.getInstance() |
597 | - .getFileChooser(); |
598 | - |
599 | - fileChooser.setFile(null); |
600 | - |
601 | - if (fileChooser.showDialog(UI.getInstance() |
602 | - .getEditProductDialog(), |
603 | - FileChooser.MODE_OPEN_FILE, |
604 | - ResiFileFilter.TYPE_ALL) == FileChooser.SELECTED_APPROVE) { |
605 | - |
606 | - protFrame.switchToProgressMode(); |
607 | - |
608 | - File file = fileChooser.getFile(); |
609 | - findingMgmt.addExtReference(file, currentFinding); |
610 | - fertm.fireTableDataChanged(); |
611 | - |
612 | - Thread.sleep(200); |
613 | - |
614 | - GUITools.scrollToBottom(exRefScrllPn); |
615 | - |
616 | - updateTableButtons(); |
617 | - } |
618 | - |
619 | - protFrame.switchToEditMode(); |
620 | - |
621 | - return null; |
622 | - } |
623 | - }; |
624 | - |
625 | - addExtRefWorker.execute(); |
626 | - } |
627 | - }); |
628 | - |
629 | - remExRefBttn = GUITools.newImageButton(remIcon, rolloverRemIcon); |
630 | - remExRefBttn.addActionListener(new ActionListener() { |
631 | - @Override |
632 | - public void actionPerformed(ActionEvent e) { |
633 | - int selRow = exRefTbl.getSelectedRow(); |
634 | - if (selRow != -1) { |
635 | - File file = findingMgmt.getExtReferences(currentFinding) |
636 | - .get(selRow); |
637 | - findingMgmt.removeExtReference(file, currentFinding); |
638 | - fertm.fireTableDataChanged(); |
639 | - updateTableButtons(); |
640 | - } |
641 | - } |
642 | - }); |
643 | - |
644 | - /* |
645 | - * |
646 | - * creating show external reference button |
647 | - */ |
648 | - pasteExRefBttn = GUITools.newImageButton(showExRefIcon, |
649 | - rolloverShowExRefIcon); |
650 | - pasteExRefBttn.addActionListener(new ActionListener() { |
651 | - @Override |
652 | - public void actionPerformed(ActionEvent e) { |
653 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
654 | - exRefTbl); |
655 | - |
656 | - SwingWorker<Void, Void> addImgFromCbWorker = new SwingWorker<Void, Void>() { |
657 | - @Override |
658 | - protected Void doInBackground() throws Exception { |
659 | - UI |
660 | - .getInstance() |
661 | - .getProtocolFrame() |
662 | - .switchToProgressMode( |
663 | - Data |
664 | - .getInstance() |
665 | - .getLocaleStr( |
666 | - "editProtocol.message.imgLoading")); |
667 | - |
668 | - Image img = AppTools.getImageFromClipboard(); |
669 | - |
670 | - if (img == null) { |
671 | - JOptionPane |
672 | - .showMessageDialog( |
673 | - UI.getInstance().getProtocolFrame(), |
674 | - GUITools |
675 | - .getMessagePane(Data |
676 | - .getInstance() |
677 | - .getLocaleStr( |
678 | - "editProtocol.message.noImgInCb")), |
679 | - Data.getInstance().getLocaleStr( |
680 | - "info"), |
681 | - JOptionPane.INFORMATION_MESSAGE); |
682 | - } else { |
683 | - Image scalImg = img.getScaledInstance(-1, 250, |
684 | - Image.SCALE_SMOOTH); |
685 | - |
686 | - JLabel labelImg = new JLabel(new ImageIcon(scalImg)); |
687 | - labelImg.setBorder(new CompoundBorder( |
688 | - new EmptyBorder(0, 0, 15, 0), |
689 | - new MatteBorder(1, 1, 1, 1, |
690 | - UI.SEPARATOR_COLOR))); |
691 | - |
692 | - JTextField inputField = new JTextField(); |
693 | - inputField.setText(Data.getInstance().getLocaleStr( |
694 | - "editProtocol.finding.stdFileName")); |
695 | - |
696 | - JPanel messagePane = new JPanel(new BorderLayout()); |
697 | - messagePane.add(labelImg, BorderLayout.NORTH); |
698 | - messagePane |
699 | - .add( |
700 | - new JLabel( |
701 | - Data |
702 | - .getInstance() |
703 | - .getLocaleStr( |
704 | - "editProtocol.message.askForFileName")), |
705 | - BorderLayout.CENTER); |
706 | - messagePane.add(inputField, BorderLayout.SOUTH); |
707 | - |
708 | - // String fileName = (String) JOptionPane |
709 | - // .showInputDialog( |
710 | - // UI.getInstance().getProtocolFrame(), |
711 | - // messagePane, |
712 | - // Data.getInstance().getLocaleStr( |
713 | - // "confirm"), |
714 | - // JOptionPane.DEFAULT_OPTION, |
715 | - // null, |
716 | - // null, |
717 | - // Data |
718 | - // .getInstance() |
719 | - // .getLocaleStr( |
720 | - // "editProtocol.finding.stdFileName")); |
721 | - |
722 | - Object[] options = { |
723 | - Data.getInstance().getLocaleStr( |
724 | - "findingsItem.save"), |
725 | - Data.getInstance().getLocaleStr( |
726 | - "findingsItem.edit"), |
727 | - Data.getInstance().getLocaleStr( |
728 | - "findingsItem.abort") }; |
729 | - |
730 | - int action = JOptionPane.showOptionDialog(UI |
731 | - .getInstance().getProtocolFrame(), |
732 | - messagePane, Data.getInstance() |
733 | - .getLocaleStr("confirm"), |
734 | - JOptionPane.YES_NO_CANCEL_OPTION, |
735 | - JOptionPane.PLAIN_MESSAGE, null, options, |
736 | - options[0]); |
737 | - |
738 | - String fileName = null; |
739 | - |
740 | - if (action != 2) { |
741 | - fileName = inputField.getText(); |
742 | - } |
743 | - |
744 | - if (fileName != null && !fileName.trim().equals("")) { |
745 | - findingMgmt.addExtReference(img, fileName, |
746 | - currentFinding); |
747 | - |
748 | - fertm.fireTableDataChanged(); |
749 | - |
750 | - updateTableButtons(); |
751 | - } |
752 | - |
753 | - if (action == 1) { |
754 | - int numberOfExtRefs = findingMgmt |
755 | - .getExtReferences(currentFinding) |
756 | - .size(); |
757 | - |
758 | - File extRef = findingMgmt.getExtReferences( |
759 | - currentFinding) |
760 | - .get(numberOfExtRefs - 1); |
761 | - |
762 | - UI.getInstance().getProtocolFrame() |
763 | - .getImageEditor(extRef) |
764 | - .setVisible(true); |
765 | - } |
766 | - } |
767 | - |
768 | - UI.getInstance().getProtocolFrame().switchToEditMode(); |
769 | - |
770 | - return null; |
771 | - } |
772 | - }; |
773 | - |
774 | - addImgFromCbWorker.execute(); |
775 | - } |
776 | - }); |
777 | - |
778 | - addExRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
779 | - "findingsItem.addExRef")); |
780 | - remExRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
781 | - "findingsItem.remExRef")); |
782 | - pasteExRefBttn.setToolTipText(Data.getInstance().getLocaleStr( |
783 | - "findingsItem.pasteExRef")); |
784 | - |
785 | - exRefBttnPnl.add(addExRefBttn); |
786 | - exRefBttnPnl.add(remExRefBttn); |
787 | - exRefBttnPnl.add(pasteExRefBttn); |
788 | - |
789 | - /* |
790 | - * creating aspButtons and adding them to their panel |
791 | - */ |
792 | - addAspBttn = GUITools.newImageButton(addIcon, rolloverAddIcon); |
793 | - addAspBttn.addActionListener(new ActionListener() { |
794 | - @Override |
795 | - public void actionPerformed(ActionEvent e) { |
796 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
797 | - aspTbl); |
798 | - |
799 | - AddAspToFindPopupWindow popup = new AddAspToFindPopupWindow(UI |
800 | - .getInstance().getProtocolFrame()); |
801 | - |
802 | - popup.setVisible(true); |
803 | - |
804 | - if (popup.getButtonClicked() == ButtonClicked.OK) { |
805 | - List<Aspect> aspList = popup.getSelAspList(); |
806 | - |
807 | - for (Aspect asp : aspList) { |
808 | - findingMgmt.addAspect(asp, currentFinding); |
809 | - } |
810 | - |
811 | - fatm.fireTableDataChanged(); |
812 | - |
813 | - GUITools.scrollToBottom(aspScrllPn); |
814 | - } |
815 | - |
816 | - updateTableButtons(); |
817 | - } |
818 | - }); |
819 | - |
820 | - remAspBttn = GUITools.newImageButton(remIcon, rolloverRemIcon); |
821 | - remAspBttn.addActionListener(new ActionListener() { |
822 | - |
823 | - @Override |
824 | - public void actionPerformed(ActionEvent e) { |
825 | - int selRow = aspTbl.getSelectedRow(); |
826 | - if (selRow != -1) { |
827 | - String asp = findingMgmt.getAspects(currentFinding).get( |
828 | - selRow); |
829 | - findingMgmt.removeAspect(asp, currentFinding); |
830 | - fatm.fireTableDataChanged(); |
831 | - } |
832 | - updateTableButtons(); |
833 | - } |
834 | - }); |
835 | - |
836 | - addAspBttn.setToolTipText(Data.getInstance().getLocaleStr( |
837 | - "findingsItem.addAsp")); |
838 | - remAspBttn.setToolTipText(Data.getInstance().getLocaleStr( |
839 | - "findingsItem.remAsp")); |
840 | - |
841 | - aspBttnPnl.add(addAspBttn); |
842 | - aspBttnPnl.add(remAspBttn); |
843 | - |
844 | - /* |
845 | - * |
846 | - * creating pushbuttons; |
847 | - */ |
848 | - pushUpBttn = GUITools.newImageButton(pushUpIcon, rolloverPushUpIcon); |
849 | - pushUpBttn.setToolTipText(Data.getInstance().getLocaleStr( |
850 | - "findingsItem.pushUp")); |
851 | - pushUpBttn.addActionListener(new ActionListener() { |
852 | - @Override |
853 | - public void actionPerformed(ActionEvent e) { |
854 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
855 | - null); |
856 | - |
857 | - findingMgmt.pushUpFinding(currentFinding, currentProtocol); |
858 | - int index = UI.getInstance().getProtocolFrame() |
859 | - .getFirstVisibleFinding(); |
860 | - UI.getInstance().getProtocolFrame().setFirstVisibleFinding( |
861 | - index - 1); |
862 | - UI.getInstance().getProtocolFrame().updatePanelFindings(); |
863 | - UI.getInstance().getProtocolFrame().getFtm() |
864 | - .fireTableDataChanged(); |
865 | - UI.getInstance().getProtocolFrame().setSelectionRow(); |
866 | - UI.getInstance().getProtocolFrame().updateTable(); |
867 | - } |
868 | - }); |
869 | - |
870 | - pushDownBttn = GUITools.newImageButton(pushDownIcon, |
871 | - rolloverPushDownIcon); |
872 | - pushDownBttn.setToolTipText(Data.getInstance().getLocaleStr( |
873 | - "findingsItem.pushDown")); |
874 | - pushDownBttn.addActionListener(new ActionListener() { |
875 | - @Override |
876 | - public void actionPerformed(ActionEvent e) { |
877 | - UI.getInstance().getProtocolFrame().updateFocus(currentFinding, |
878 | - null); |
879 | - |
880 | - findingMgmt.pushDownFinding(currentFinding, currentProtocol); |
881 | - int index = UI.getInstance().getProtocolFrame() |
882 | - .getFirstVisibleFinding(); |
883 | - UI.getInstance().getProtocolFrame().setFirstVisibleFinding( |
884 | - index + 1); |
885 | - UI.getInstance().getProtocolFrame().updatePanelFindings(); |
886 | - |
887 | - UI.getInstance().getProtocolFrame().getFtm() |
888 | - .fireTableDataChanged(); |
889 | - UI.getInstance().getProtocolFrame().setSelectionRow(); |
890 | - UI.getInstance().getProtocolFrame().updateTable(); |
891 | - } |
892 | - }); |
893 | - |
894 | - /* |
895 | - * |
896 | - * creating remove finding button |
897 | - */ |
898 | - remFindBttn = GUITools.newImageButton(remFindIcon, rolloverRemFindIcon); |
899 | - remFindBttn.setToolTipText(Data.getInstance().getLocaleStr( |
900 | - "findingsItem.delFind")); |
901 | - remFindBttn.addActionListener(new ActionListener() { |
902 | - @Override |
903 | - public void actionPerformed(ActionEvent arg0) { |
904 | - findingMgmt.removeFinding(currentFinding, currentProtocol); |
905 | - UI.getInstance().getProtocolFrame().updatePanelFindings(); |
906 | - |
907 | - UI.getInstance().getProtocolFrame().getFtm() |
908 | - .fireTableDataChanged(); |
909 | - UI.getInstance().getProtocolFrame().setSelectionRow(); |
910 | - UI.getInstance().getProtocolFrame().updateTable(); |
911 | - } |
912 | - }); |
913 | - |
914 | - updateFindBttns(); |
915 | - |
916 | - /* |
917 | - * |
918 | - * creating and setting desc,ref,exRef,asp,frtm,fertm,fatm |
919 | - */ |
920 | - |
921 | - descTxtArea = new JTextArea(currentFinding.getDescription()); |
922 | - |
923 | - descScrllPn = GUITools.setIntoScrllPn(descTxtArea); |
924 | - GUITools.scrollToTop(descScrllPn); |
925 | - |
926 | - descTxtArea.addFocusListener(focusListener); |
927 | - descTxtArea.setFont(UI.PROTOCOL_FONT); |
928 | - descTxtArea.addKeyListener(new KeyListener() { |
929 | - @Override |
930 | - public void keyPressed(KeyEvent e) { |
931 | - Object evSrc = e.getSource(); |
932 | - |
933 | - if (evSrc instanceof JTextArea |
934 | - && e.getKeyCode() == KeyEvent.VK_TAB) { |
935 | - JTextArea txtArea = (JTextArea) evSrc; |
936 | - |
937 | - if (e.getModifiers() > 0) { |
938 | - txtArea.transferFocusBackward(); |
939 | - } else { |
940 | - txtArea.transferFocus(); |
941 | - e.consume(); |
942 | - } |
943 | - } |
944 | - } |
945 | - |
946 | - @Override |
947 | - public void keyReleased(KeyEvent e) { |
948 | - boolean mark = false; |
949 | - |
950 | - try { |
951 | - if (Data.getInstance().getAppData().getSettingValue( |
952 | - AppSettingKey.APP_HIGHLIGHT_FIELDS) == AppSettingValue.TRUE) { |
953 | - mark = true; |
954 | - } |
955 | - } catch (DataException exc) { |
956 | - mark = true; |
957 | - } |
958 | - |
959 | - if (descTxtArea.getText().trim().equals("") && mark) { |
960 | - descScrllPn.setBorder(UI.MARKED_BORDER); |
961 | - } else { |
962 | - descScrllPn.setBorder(UI.STANDARD_BORDER); |
963 | - } |
964 | - |
965 | - currentFinding.setDescription(descTxtArea.getText()); |
966 | - UI.getInstance().getProtocolFrame().getFtm() |
967 | - .fireTableDataChanged(); |
968 | - resiData.fireDataChanged(); |
969 | - UI.getInstance().getProtocolFrame().setSelectionRow(); |
970 | - } |
971 | - |
972 | - @Override |
973 | - public void keyTyped(KeyEvent e) { |
974 | - } |
975 | - }); |
976 | - |
977 | - for (KeyListener kl : descTxtArea.getKeyListeners()) { |
978 | - kl.keyReleased(null); |
979 | - } |
980 | - |
981 | - /* |
982 | - * disabeling buttons |
983 | - */ |
984 | - remAspBttn.setEnabled(false); |
985 | - remExRefBttn.setEnabled(false); |
986 | - remRefBttn.setEnabled(false); |
987 | - |
988 | - ediRefBttn.setEnabled(false); |
989 | - |
990 | - /* |
991 | - * creating table models |
992 | - */ |
993 | - fatm = new FindAspTableModel(currentFinding); |
994 | - frtm = new FindRefTableModel(currentFinding); |
995 | - fertm = new FindExRefTableModel(currentFinding); |
996 | - |
997 | - DefaultTableCellRenderer cellRend = new DefaultTableCellRenderer() { |
998 | - @Override |
999 | - public Font getFont() { |
1000 | - return UI.PROTOCOL_FONT; |
1001 | - } |
1002 | - |
1003 | - @Override |
1004 | - public Component getTableCellRendererComponent(JTable table, |
1005 | - Object value, boolean isSelected, boolean hasFocus, |
1006 | - int row, int column) { |
1007 | - setToolTipText(GUITools.getTextAsHtml("<font size=\"5\">" |
1008 | - + (String) value + "</font>")); |
1009 | - |
1010 | - return super.getTableCellRendererComponent(table, value, |
1011 | - isSelected, hasFocus, row, column); |
1012 | - } |
1013 | - }; |
1014 | - |
1015 | - DefaultTableHeaderCellRenderer headRend = new DefaultTableHeaderCellRenderer() { |
1016 | - @Override |
1017 | - public Font getFont() { |
1018 | - return UI.PROTOCOL_FONT; |
1019 | - } |
1020 | - }; |
1021 | - |
1022 | - aspTbl = GUITools.newStandardTable(fatm, true); |
1023 | - refTbl = GUITools.newStandardTable(frtm, true); |
1024 | - exRefTbl = GUITools.newStandardTable(fertm, true); |
1025 | - |
1026 | - aspTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend); |
1027 | - refTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend); |
1028 | - exRefTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend); |
1029 | - |
1030 | - aspTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend); |
1031 | - refTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend); |
1032 | - exRefTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend); |
1033 | - |
1034 | - aspTbl.setRowHeight(29); |
1035 | - refTbl.setRowHeight(29); |
1036 | - exRefTbl.setRowHeight(29); |
1037 | - |
1038 | - aspTbl.addFocusListener(focusListener); |
1039 | - refTbl.addFocusListener(focusListener); |
1040 | - exRefTbl.addFocusListener(focusListener); |
1041 | - |
1042 | - aspTbl.addMouseListener(new MouseListener() { |
1043 | - @Override |
1044 | - public void mouseClicked(MouseEvent e) { |
1045 | - updateTableButtons(); |
1046 | - } |
1047 | - |
1048 | - @Override |
1049 | - public void mouseEntered(MouseEvent e) { |
1050 | - } |
1051 | - |
1052 | - @Override |
1053 | - public void mouseExited(MouseEvent e) { |
1054 | - } |
1055 | - |
1056 | - @Override |
1057 | - public void mousePressed(MouseEvent e) { |
1058 | - } |
1059 | - |
1060 | - @Override |
1061 | - public void mouseReleased(MouseEvent e) { |
1062 | - } |
1063 | - }); |
1064 | - |
1065 | - refTbl.addMouseListener(new MouseListener() { |
1066 | - @Override |
1067 | - public void mouseClicked(MouseEvent e) { |
1068 | - updateTableButtons(); |
1069 | - } |
1070 | - |
1071 | - @Override |
1072 | - public void mouseEntered(MouseEvent e) { |
1073 | - } |
1074 | - |
1075 | - @Override |
1076 | - public void mouseExited(MouseEvent e) { |
1077 | - } |
1078 | - |
1079 | - @Override |
1080 | - public void mousePressed(MouseEvent e) { |
1081 | - } |
1082 | - |
1083 | - @Override |
1084 | - public void mouseReleased(MouseEvent e) { |
1085 | - } |
1086 | - }); |
1087 | - |
1088 | - exRefTbl.addMouseListener(new MouseListener() { |
1089 | - @Override |
1090 | - public void mouseClicked(MouseEvent e) { |
1091 | - updateTableButtons(); |
1092 | - |
1093 | - if (e.getClickCount() == 2) { |
1094 | - int selRow = exRefTbl.getSelectedRow(); |
1095 | - |
1096 | - if (selRow != -1) { |
1097 | - File ref = findMgmt.getExtReferences(currentFinding) |
1098 | - .get(exRefTbl.getSelectedRow()); |
1099 | - |
1100 | - if (AppTools.isReadableWritableImageFile(ref)) { |
1101 | - UI.getInstance().getProtocolFrame().getImageEditor( |
1102 | - ref).setVisible(true); |
1103 | - } else { |
1104 | - try { |
1105 | - Desktop.getDesktop().open(ref); |
1106 | - } catch (Exception exc) { |
1107 | - JOptionPane.showMessageDialog(UI.getInstance() |
1108 | - .getProtocolFrame(), GUITools |
1109 | - .getMessagePane(exc.getMessage()), Data |
1110 | - .getInstance().getLocaleStr("error"), |
1111 | - JOptionPane.ERROR_MESSAGE); |
1112 | - } |
1113 | - } |
1114 | - } |
1115 | - } |
1116 | - } |
1117 | - |
1118 | - @Override |
1119 | - public void mouseEntered(MouseEvent e) { |
1120 | - } |
1121 | - |
1122 | - @Override |
1123 | - public void mouseExited(MouseEvent e) { |
1124 | - } |
1125 | - |
1126 | - @Override |
1127 | - public void mousePressed(MouseEvent e) { |
1128 | - } |
1129 | - |
1130 | - @Override |
1131 | - public void mouseReleased(MouseEvent e) { |
1132 | - } |
1133 | - }); |
1134 | - |
1135 | - aspScrllPn = new JScrollPane(aspTbl); |
1136 | - refScrllPn = new JScrollPane(refTbl); |
1137 | - exRefScrllPn = new JScrollPane(exRefTbl); |
1138 | - |
1139 | - aspScrllPn.getViewport().setBackground(Color.WHITE); |
1140 | - refScrllPn.getViewport().setBackground(Color.WHITE); |
1141 | - exRefScrllPn.getViewport().setBackground(Color.WHITE); |
1142 | - |
1143 | - sevBx = new JComboBox(); |
1144 | - sevBx.setFont(UI.PROTOCOL_FONT_BOLD); |
1145 | - |
1146 | - for (String sev : sevMgmt.getSeverities()) { |
1147 | - sevBx.addItem(sev); |
1148 | - } |
1149 | - |
1150 | - sevBx.addFocusListener(focusListener); |
1151 | - |
1152 | - sevBx.addItemListener(new ItemListener() { |
1153 | - @Override |
1154 | - public void itemStateChanged(ItemEvent e) { |
1155 | - if (e.getStateChange() == ItemEvent.SELECTED) { |
1156 | - currentFinding.setSeverity(sevBx.getSelectedItem() |
1157 | - .toString()); |
1158 | - resiData.fireDataChanged(); |
1159 | - } |
1160 | - } |
1161 | - }); |
1162 | - sevBx.setSelectedItem(currentFinding.getSeverity()); |
1163 | - |
1164 | - /* |
1165 | - * adding components to the content panel |
1166 | - */ |
1167 | - GUITools.addComponent(this, gbl, idLbl, 0, 0, 1, 1, 0.0, 0.0, 5, 10, 5, |
1168 | - 0, GridBagConstraints.NONE, GridBagConstraints.WEST); |
1169 | - GUITools.addComponent(this, gbl, remFindBttn, 1, 0, 1, 1, 0.0, 0.0, 5, |
1170 | - 15, 5, 3, GridBagConstraints.NONE, GridBagConstraints.WEST); |
1171 | - GUITools.addComponent(this, gbl, pushUpBttn, 2, 0, 1, 1, 0.0, 0.0, 5, |
1172 | - 5, 5, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); |
1173 | - GUITools.addComponent(this, gbl, pushDownBttn, 3, 0, 1, 1, 0.0, 0.0, 5, |
1174 | - 5, 5, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); |
1175 | - |
1176 | - // GUITools.addComponent(this, gbl, descLbl, 0, 1, 5, 1, 0, 0, 15, 10, |
1177 | - // 0, |
1178 | - // 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
1179 | - GUITools |
1180 | - .addComponent(this, gbl, descScrllPn, 0, 2, 5, 3, 1.0, 1.0, 5, |
1181 | - 10, 0, 0, GridBagConstraints.BOTH, |
1182 | - GridBagConstraints.NORTHWEST); |
1183 | - |
1184 | - GUITools.addComponent(this, gbl, refScrllPn, 0, 5, 5, 1, 1.0, 1.0, 5, |
1185 | - 10, 10, 0, GridBagConstraints.BOTH, |
1186 | - GridBagConstraints.NORTHWEST); |
1187 | - GUITools.addComponent(this, gbl, refBttnPnl, 5, 5, 1, 1, 0, 0, 5, 10, |
1188 | - 20, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
1189 | - |
1190 | - // GUITools.addComponent(this, gbl, sevLbl, 6, 1, 1, 1, 0, 0, 15, 30, 0, |
1191 | - // 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
1192 | - GUITools.addComponent(this, gbl, sevBx, 6, 2, 1, 1, 1.0, 0, 5, 30, 0, |
1193 | - 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); |
1194 | - |
1195 | - GUITools |
1196 | - .addComponent(this, gbl, aspScrllPn, 6, 3, 1, 2, 1.0, 1.0, 5, |
1197 | - 30, 0, 0, GridBagConstraints.BOTH, |
1198 | - GridBagConstraints.NORTHWEST); |
1199 | - GUITools.addComponent(this, gbl, aspBttnPnl, 7, 3, 1, 2, 0, 0, 5, 10, |
1200 | - 0, 10, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
1201 | - |
1202 | - GUITools.addComponent(this, gbl, exRefScrllPn, 6, 5, 1, 1, 1.0, 1.0, 5, |
1203 | - 30, 10, 0, GridBagConstraints.BOTH, |
1204 | - GridBagConstraints.NORTHWEST); |
1205 | - GUITools.addComponent(this, gbl, exRefBttnPnl, 7, 5, 1, 1, 0, 0, 5, 10, |
1206 | - 20, 10, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
1207 | - |
1208 | - /* |
1209 | - * change for saving |
1210 | - */ |
1211 | - if (findingMgmt.isFindingEmpty(currentFinding)) { |
1212 | - currentFinding.setDescription(""); |
1213 | - currentFinding.setSeverity(sevMgmt.getSeverities().get(0)); |
1214 | - resiData.fireDataChanged(); |
1215 | - } |
1216 | - } |
1217 | - |
1218 | - /** |
1219 | - * Updates the buttons of the tables. |
1220 | - */ |
1221 | - private void updateTableButtons() { |
1222 | - if (aspTbl.getSelectedRow() == -1) { |
1223 | - remAspBttn.setEnabled(false); |
1224 | - } else { |
1225 | - remAspBttn.setEnabled(true); |
1226 | - } |
1227 | - |
1228 | - if (refTbl.getSelectedRow() == -1) { |
1229 | - remRefBttn.setEnabled(false); |
1230 | - ediRefBttn.setEnabled(false); |
1231 | - } else { |
1232 | - remRefBttn.setEnabled(true); |
1233 | - ediRefBttn.setEnabled(true); |
1234 | - } |
1235 | - |
1236 | - if (exRefTbl.getSelectedRow() == -1) { |
1237 | - remExRefBttn.setEnabled(false); |
1238 | - } else { |
1239 | - remExRefBttn.setEnabled(true); |
1240 | - } |
1241 | - } |
1242 | - |
1243 | - /* |
1244 | - * (non-Javadoc) |
1245 | - * |
1246 | - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) |
1247 | - */ |
1248 | - @Override |
1249 | - public void update(Observable o, Object arg) { |
1250 | - updateFindBttns(); |
1251 | - } |
1252 | - |
1253 | - /** |
1254 | - * Update find bttns. |
1255 | - */ |
1256 | - public void updateFindBttns() { |
1257 | - if (findingMgmt.getNumberOfFindings(currentProtocol) == 1) { |
1258 | - remFindBttn.setEnabled(false); |
1259 | - pushUpBttn.setEnabled(false); |
1260 | - pushDownBttn.setEnabled(false); |
1261 | - |
1262 | - } else { |
1263 | - remFindBttn.setEnabled(true); |
1264 | - |
1265 | - if (findingMgmt.isTopFinding(currentFinding, currentProtocol)) { |
1266 | - pushUpBttn.setEnabled(false); |
1267 | - } else { |
1268 | - pushUpBttn.setEnabled(true); |
1269 | - } |
1270 | - |
1271 | - if (findingMgmt.isBottomFinding(currentFinding, currentProtocol)) { |
1272 | - pushDownBttn.setEnabled(false); |
1273 | - } else { |
1274 | - pushDownBttn.setEnabled(true); |
1275 | - } |
1276 | - } |
1277 | - } |
1278 | - |
1279 | - /** |
1280 | - * Updates the focus. |
1281 | - * |
1282 | - * @param evSource |
1283 | - * the event source |
1284 | - */ |
1285 | - public void updateFocus(Object evSource) { |
1286 | - if (evSource != descTxtArea) { |
1287 | - descTxtArea.select(0, 0); |
1288 | - } |
1289 | - |
1290 | - if (evSource != refTbl) { |
1291 | - if (refTbl.getCellEditor() != null) { |
1292 | - refTbl.getCellEditor().stopCellEditing(); |
1293 | - } |
1294 | - |
1295 | - if (refTbl.getRowCount() > 0) { |
1296 | - refTbl.removeRowSelectionInterval(0, refTbl.getRowCount() - 1); |
1297 | - } |
1298 | - } |
1299 | - |
1300 | - if (evSource != exRefTbl) { |
1301 | - if (exRefTbl.getRowCount() > 0) { |
1302 | - exRefTbl.removeRowSelectionInterval(0, |
1303 | - exRefTbl.getRowCount() - 1); |
1304 | - } |
1305 | - } |
1306 | - |
1307 | - if (evSource != aspTbl) { |
1308 | - if (aspTbl.getRowCount() > 0) { |
1309 | - aspTbl.removeRowSelectionInterval(0, aspTbl.getRowCount() - 1); |
1310 | - } |
1311 | - } |
1312 | - } |
1313 | - |
1314 | - /** |
1315 | - * Returns the current finding |
1316 | - * |
1317 | - * @return the current finding |
1318 | - */ |
1319 | - public Finding getCurrentFinding() { |
1320 | - return currentFinding; |
1321 | - } |
1322 | - |
1323 | - public boolean isCellEditing(){ |
1324 | - return refTbl.isEditing(); |
1325 | - } |
1326 | - |
1327 | - public void saveRef(){ |
1328 | - refTbl.getCellEditor().stopCellEditing(); |
1329 | - } |
1330 | -} |
1331 | |
1332 | === added file 'src/org/revager/gui/protocol/FindingPanel.java' |
1333 | --- src/org/revager/gui/protocol/FindingPanel.java 1970-01-01 00:00:00 +0000 |
1334 | +++ src/org/revager/gui/protocol/FindingPanel.java 2010-05-27 20:33:41 +0000 |
1335 | @@ -0,0 +1,1116 @@ |
1336 | +package org.revager.gui.protocol; |
1337 | + |
1338 | +import java.awt.BorderLayout; |
1339 | +import java.awt.Color; |
1340 | +import java.awt.Component; |
1341 | +import java.awt.Cursor; |
1342 | +import java.awt.Desktop; |
1343 | +import java.awt.Dimension; |
1344 | +import java.awt.Font; |
1345 | +import java.awt.GridBagConstraints; |
1346 | +import java.awt.GridBagLayout; |
1347 | +import java.awt.GridLayout; |
1348 | +import java.awt.Image; |
1349 | +import java.awt.event.ActionEvent; |
1350 | +import java.awt.event.ActionListener; |
1351 | +import java.awt.event.FocusEvent; |
1352 | +import java.awt.event.FocusListener; |
1353 | +import java.awt.event.ItemEvent; |
1354 | +import java.awt.event.ItemListener; |
1355 | +import java.awt.event.KeyEvent; |
1356 | +import java.awt.event.KeyListener; |
1357 | +import java.awt.event.MouseEvent; |
1358 | +import java.awt.event.MouseListener; |
1359 | +import java.io.File; |
1360 | +import java.util.List; |
1361 | + |
1362 | +import javax.swing.ImageIcon; |
1363 | +import javax.swing.JButton; |
1364 | +import javax.swing.JComboBox; |
1365 | +import javax.swing.JLabel; |
1366 | +import javax.swing.JOptionPane; |
1367 | +import javax.swing.JPanel; |
1368 | +import javax.swing.JScrollPane; |
1369 | +import javax.swing.JTable; |
1370 | +import javax.swing.JTextArea; |
1371 | +import javax.swing.JTextField; |
1372 | +import javax.swing.SwingWorker; |
1373 | +import javax.swing.border.CompoundBorder; |
1374 | +import javax.swing.border.EmptyBorder; |
1375 | +import javax.swing.border.MatteBorder; |
1376 | +import javax.swing.table.DefaultTableCellRenderer; |
1377 | + |
1378 | +import org.revager.app.Application; |
1379 | +import org.revager.app.FindingManagement; |
1380 | +import org.revager.app.ResiFileFilter; |
1381 | +import org.revager.app.SeverityManagement; |
1382 | +import org.revager.app.model.Data; |
1383 | +import org.revager.app.model.ResiData; |
1384 | +import org.revager.app.model.schema.Aspect; |
1385 | +import org.revager.app.model.schema.Finding; |
1386 | +import org.revager.app.model.schema.Protocol; |
1387 | +import org.revager.gui.UI; |
1388 | +import org.revager.gui.helpers.DefaultTableHeaderCellRenderer; |
1389 | +import org.revager.gui.helpers.FileChooser; |
1390 | +import org.revager.gui.models.FindAspTableModel; |
1391 | +import org.revager.gui.models.FindExtRefTableModel; |
1392 | +import org.revager.gui.models.FindRefTableModel; |
1393 | +import org.revager.gui.protocol.AddAspToFindPopupWindow.ButtonClicked; |
1394 | +import org.revager.tools.AppTools; |
1395 | +import org.revager.tools.GUITools; |
1396 | + |
1397 | +public class FindingPanel extends JPanel { |
1398 | + |
1399 | + private static final long serialVersionUID = 1L; |
1400 | + |
1401 | + public enum Type { |
1402 | + EDIT_VIEW, COMPACT_VIEW |
1403 | + } |
1404 | + |
1405 | + private static final int CONTROL_BUTTONS_PADDING = 2; |
1406 | + |
1407 | + public static final Dimension EDIT_VIEW_SIZE = new Dimension(100, 280); |
1408 | + public static final Dimension COMPACT_VIEW_SIZE = new Dimension(100, 45); |
1409 | + |
1410 | + private static final Color EDIT_VIEW_BG = new Color(255, 255, 204); |
1411 | + private static final Color COMPACT_VIEW_BG = new Color(229, 226, 226); |
1412 | + |
1413 | + private Type type = Type.EDIT_VIEW; |
1414 | + |
1415 | + private Finding finding = null; |
1416 | + |
1417 | + private FindingsTab findingsTab = null; |
1418 | + |
1419 | + private Protocol protocol = null; |
1420 | + |
1421 | + private GridBagLayout layout = new GridBagLayout(); |
1422 | + |
1423 | + private FindingManagement findMgmt = Application.getInstance() |
1424 | + .getFindingMgmt(); |
1425 | + private SeverityManagement sevMgmt = Application.getInstance() |
1426 | + .getSeverityMgmt(); |
1427 | + private ResiData resiData = Data.getInstance().getResiData(); |
1428 | + |
1429 | + private ImageIcon iconAdd = Data.getInstance().getIcon("add_25x25_0.png"); |
1430 | + private ImageIcon iconRemove = Data.getInstance().getIcon( |
1431 | + "remove_25x25_0.png"); |
1432 | + private ImageIcon iconEdit = Data.getInstance().getIcon("edit_25x25_0.png"); |
1433 | + private ImageIcon iconPushUp = Data.getInstance().getIcon( |
1434 | + "upArrow_25x25_0.png"); |
1435 | + private ImageIcon iconPushDown = Data.getInstance().getIcon( |
1436 | + "downArrow_25x25_0.png"); |
1437 | + private ImageIcon iconPushTop = Data.getInstance().getIcon( |
1438 | + "pushTop_25x25_0.png"); |
1439 | + private ImageIcon iconPushBottom = Data.getInstance().getIcon( |
1440 | + "pushBottom_25x25_0.png"); |
1441 | + private ImageIcon iconRemoveFinding = Data.getInstance().getIcon( |
1442 | + "delete_25x25_0.png"); |
1443 | + private ImageIcon iconCloseFinding = Data.getInstance().getIcon( |
1444 | + "closeFinding_25x25_0.png"); |
1445 | + private ImageIcon iconPaste = Data.getInstance().getIcon( |
1446 | + "paste_25x25_0.png"); |
1447 | + |
1448 | + private ImageIcon iconRolloverAdd = Data.getInstance().getIcon( |
1449 | + "add_25x25.png"); |
1450 | + private ImageIcon iconRolloverRemove = Data.getInstance().getIcon( |
1451 | + "remove_25x25.png"); |
1452 | + private ImageIcon iconRolloverEdit = Data.getInstance().getIcon( |
1453 | + "edit_25x25.png"); |
1454 | + private ImageIcon iconRolloverPushUp = Data.getInstance().getIcon( |
1455 | + "upArrow_25x25.png"); |
1456 | + private ImageIcon iconRolloverPushDown = Data.getInstance().getIcon( |
1457 | + "downArrow_25x25.png"); |
1458 | + private ImageIcon iconRolloverPushTop = Data.getInstance().getIcon( |
1459 | + "pushTop_25x25.png"); |
1460 | + private ImageIcon iconRolloverPushBottom = Data.getInstance().getIcon( |
1461 | + "pushBottom_25x25.png"); |
1462 | + private ImageIcon iconRolloverRemoveFinding = Data.getInstance().getIcon( |
1463 | + "delete_25x25.png"); |
1464 | + private ImageIcon iconRolloverCloseFinding = Data.getInstance().getIcon( |
1465 | + "closeFinding_25x25.png"); |
1466 | + private ImageIcon iconRolloverPaste = Data.getInstance().getIcon( |
1467 | + "paste_25x25.png"); |
1468 | + |
1469 | + private ImageIcon iconBlank = Data.getInstance().getIcon("blank_25x25.png"); |
1470 | + |
1471 | + private GridBagLayout layoutEditView = new GridBagLayout(); |
1472 | + private JPanel panelEditView = new JPanel(layoutEditView); |
1473 | + |
1474 | + private GridBagLayout layoutCompactView = new GridBagLayout(); |
1475 | + private JPanel panelCompactView = new JPanel(layoutCompactView); |
1476 | + |
1477 | + private JLabel labelFindingNumber = new JLabel(); |
1478 | + private JLabel labelFindingSeverity = new JLabel(); |
1479 | + private JLabel labelFindingDescription = new JLabel(); |
1480 | + |
1481 | + private JLabel labelFindingTitle = new JLabel(); |
1482 | + |
1483 | + private JComboBox comboSeverity = new JComboBox(); |
1484 | + |
1485 | + private JTextArea textDescription = new JTextArea(); |
1486 | + |
1487 | + private FindRefTableModel modelReferences; |
1488 | + private FindExtRefTableModel modelExtReferences; |
1489 | + private FindAspTableModel modelAspects; |
1490 | + |
1491 | + private JTable tableReferences; |
1492 | + private JTable tableExtReferences; |
1493 | + private JTable tableAspects; |
1494 | + |
1495 | + private JScrollPane scrollDescription; |
1496 | + private JScrollPane scrollReferences; |
1497 | + private JScrollPane scrollExtReferences; |
1498 | + private JScrollPane scrollAspects; |
1499 | + |
1500 | + private JButton buttonAddReference = GUITools.newImageButton(iconAdd, |
1501 | + iconRolloverAdd); |
1502 | + private JButton buttonEditReference = GUITools.newImageButton(iconEdit, |
1503 | + iconRolloverEdit); |
1504 | + private JButton buttonRemoveReference = GUITools.newImageButton(iconRemove, |
1505 | + iconRolloverRemove); |
1506 | + |
1507 | + private JButton buttonAddExtReference = GUITools.newImageButton(iconAdd, |
1508 | + iconRolloverAdd); |
1509 | + private JButton buttonRemoveExtReference = GUITools.newImageButton( |
1510 | + iconRemove, iconRolloverRemove); |
1511 | + private JButton buttonPasteExtReference = GUITools.newImageButton( |
1512 | + iconPaste, iconRolloverPaste); |
1513 | + |
1514 | + private JButton buttonAddAspect = GUITools.newImageButton(iconAdd, |
1515 | + iconRolloverAdd); |
1516 | + private JButton buttonRemoveAspect = GUITools.newImageButton(iconRemove, |
1517 | + iconRolloverRemove); |
1518 | + |
1519 | + private JButton buttonPushUp = GUITools.newImageButton(iconPushUp, |
1520 | + iconRolloverPushUp); |
1521 | + private JButton buttonPushDown = GUITools.newImageButton(iconPushDown, |
1522 | + iconRolloverPushDown); |
1523 | + private JButton buttonPushTop = GUITools.newImageButton(iconPushTop, |
1524 | + iconRolloverPushTop); |
1525 | + private JButton buttonPushBottom = GUITools.newImageButton(iconPushBottom, |
1526 | + iconRolloverPushBottom); |
1527 | + private JButton buttonCloseFinding = GUITools.newImageButton( |
1528 | + iconCloseFinding, iconRolloverCloseFinding); |
1529 | + private JButton buttonRemoveFinding = GUITools.newImageButton( |
1530 | + iconRemoveFinding, iconRolloverRemoveFinding); |
1531 | + |
1532 | + private JButton buttonDummy = GUITools.newImageButton(iconBlank, iconBlank); |
1533 | + |
1534 | + private FocusListener focusListener = new FocusListener() { |
1535 | + @Override |
1536 | + public void focusGained(FocusEvent e) { |
1537 | + updateFocus(e.getSource()); |
1538 | + |
1539 | + updateTableButtons(); |
1540 | + } |
1541 | + |
1542 | + @Override |
1543 | + public void focusLost(FocusEvent e) { |
1544 | + updateTableButtons(); |
1545 | + } |
1546 | + }; |
1547 | + |
1548 | + private MouseListener mouseListener = new MouseListener() { |
1549 | + @Override |
1550 | + public void mouseClicked(MouseEvent e) { |
1551 | + updateTableButtons(); |
1552 | + } |
1553 | + |
1554 | + @Override |
1555 | + public void mouseEntered(MouseEvent e) { |
1556 | + } |
1557 | + |
1558 | + @Override |
1559 | + public void mouseExited(MouseEvent e) { |
1560 | + } |
1561 | + |
1562 | + @Override |
1563 | + public void mousePressed(MouseEvent e) { |
1564 | + } |
1565 | + |
1566 | + @Override |
1567 | + public void mouseReleased(MouseEvent e) { |
1568 | + } |
1569 | + }; |
1570 | + |
1571 | + private MouseListener mouseListenerCompact = new MouseListener() { |
1572 | + @Override |
1573 | + public void mouseReleased(MouseEvent e) { |
1574 | + } |
1575 | + |
1576 | + @Override |
1577 | + public void mousePressed(MouseEvent e) { |
1578 | + } |
1579 | + |
1580 | + @Override |
1581 | + public void mouseExited(MouseEvent e) { |
1582 | + } |
1583 | + |
1584 | + @Override |
1585 | + public void mouseEntered(MouseEvent e) { |
1586 | + } |
1587 | + |
1588 | + @Override |
1589 | + public void mouseClicked(MouseEvent e) { |
1590 | + findingsTab.editFinding(finding); |
1591 | + } |
1592 | + }; |
1593 | + |
1594 | + public FindingPanel(final Finding finding, final FindingsTab findingsTab) { |
1595 | + super(); |
1596 | + |
1597 | + this.finding = finding; |
1598 | + this.findingsTab = findingsTab; |
1599 | + this.protocol = findingsTab.getProtocol(); |
1600 | + |
1601 | + this.setLayout(layout); |
1602 | + this.setBackground(Color.WHITE); |
1603 | + |
1604 | + /* |
1605 | + * Initialize tables and models |
1606 | + */ |
1607 | + modelReferences = new FindRefTableModel(finding); |
1608 | + modelExtReferences = new FindExtRefTableModel(finding); |
1609 | + modelAspects = new FindAspTableModel(finding); |
1610 | + |
1611 | + /* |
1612 | + * Prepare buttons and put them inside separate panels |
1613 | + */ |
1614 | + JPanel panelButtonsReferences = new JPanel(new GridLayout(3, 1)); |
1615 | + JPanel panelButtonsExtReferences = new JPanel(new GridLayout(3, 1)); |
1616 | + JPanel panelButtonsAspects = new JPanel(new GridLayout(2, 1)); |
1617 | + |
1618 | + panelButtonsReferences.setOpaque(false); |
1619 | + panelButtonsExtReferences.setOpaque(false); |
1620 | + panelButtonsAspects.setOpaque(false); |
1621 | + |
1622 | + /* |
1623 | + * Set tooltips for buttons |
1624 | + */ |
1625 | + buttonCloseFinding.setToolTipText(Data.getInstance().getLocaleStr( |
1626 | + "findingsList.close")); |
1627 | + buttonRemoveFinding.setToolTipText(Data.getInstance().getLocaleStr( |
1628 | + "findingsList.remove")); |
1629 | + buttonPushUp.setToolTipText(Data.getInstance().getLocaleStr( |
1630 | + "findingsList.pushUp")); |
1631 | + buttonPushDown.setToolTipText(Data.getInstance().getLocaleStr( |
1632 | + "findingsList.pushDown")); |
1633 | + buttonPushTop.setToolTipText(Data.getInstance().getLocaleStr( |
1634 | + "findingsList.pushTop")); |
1635 | + buttonPushBottom.setToolTipText(Data.getInstance().getLocaleStr( |
1636 | + "findingsList.pushBottom")); |
1637 | + |
1638 | + /* |
1639 | + * Buttons for references table |
1640 | + */ |
1641 | + buttonAddReference.addActionListener(new ActionListener() { |
1642 | + @Override |
1643 | + public void actionPerformed(ActionEvent e) { |
1644 | + // UI.getInstance().getProtocolFrame().updateFocus(finding, |
1645 | + // tableReferences); |
1646 | + |
1647 | + if (tableReferences.getCellEditor() != null) { |
1648 | + tableReferences.getCellEditor().stopCellEditing(); |
1649 | + } |
1650 | + |
1651 | + String ref = Data.getInstance().getLocaleStr( |
1652 | + "editProtocol.finding.newRef"); |
1653 | + findMgmt.addReference(ref, finding); |
1654 | + modelReferences.fireTableDataChanged(); |
1655 | + |
1656 | + int row = tableReferences.getRowCount() - 1; |
1657 | + |
1658 | + tableReferences.scrollRectToVisible(tableReferences |
1659 | + .getCellRect(row, 0, false)); |
1660 | + tableReferences.editCellAt(row, 0); |
1661 | + } |
1662 | + }); |
1663 | + |
1664 | + buttonRemoveReference.addActionListener(new ActionListener() { |
1665 | + @Override |
1666 | + public void actionPerformed(ActionEvent e) { |
1667 | + int selRow = tableReferences.getSelectedRow(); |
1668 | + |
1669 | + if (tableReferences.getEditingRow() != -1) { |
1670 | + selRow = tableReferences.getEditingRow(); |
1671 | + |
1672 | + tableReferences.getCellEditor().stopCellEditing(); |
1673 | + } |
1674 | + |
1675 | + if (selRow != -1) { |
1676 | + String ref = findMgmt.getReferences(finding).get(selRow); |
1677 | + findMgmt.removeReference(ref, finding); |
1678 | + modelReferences.fireTableDataChanged(); |
1679 | + } |
1680 | + |
1681 | + updateTableButtons(); |
1682 | + } |
1683 | + }); |
1684 | + |
1685 | + buttonEditReference.addActionListener(new ActionListener() { |
1686 | + @Override |
1687 | + public void actionPerformed(ActionEvent e) { |
1688 | + int selRow = tableReferences.getSelectedRow(); |
1689 | + |
1690 | + if (selRow != -1) { |
1691 | + tableReferences.editCellAt(selRow, 0); |
1692 | + modelReferences.fireTableDataChanged(); |
1693 | + } |
1694 | + } |
1695 | + }); |
1696 | + |
1697 | + buttonAddReference.setToolTipText(Data.getInstance().getLocaleStr( |
1698 | + "findingsItem.addRef")); |
1699 | + buttonRemoveReference.setToolTipText(Data.getInstance().getLocaleStr( |
1700 | + "findingsItem.remRef")); |
1701 | + buttonEditReference.setToolTipText(Data.getInstance().getLocaleStr( |
1702 | + "findingsItem.ediRef")); |
1703 | + |
1704 | + buttonRemoveReference.setEnabled(false); |
1705 | + buttonEditReference.setEnabled(false); |
1706 | + |
1707 | + panelButtonsReferences.add(buttonAddReference); |
1708 | + panelButtonsReferences.add(buttonRemoveReference); |
1709 | + panelButtonsReferences.add(buttonEditReference); |
1710 | + |
1711 | + /* |
1712 | + * Buttons for external references table |
1713 | + */ |
1714 | + buttonAddExtReference.addActionListener(new ActionListener() { |
1715 | + @Override |
1716 | + public void actionPerformed(ActionEvent e) { |
1717 | + updateFocus(tableExtReferences); |
1718 | + |
1719 | + new AddExternalReferenceWorker().execute(); |
1720 | + } |
1721 | + }); |
1722 | + |
1723 | + buttonRemoveExtReference.addActionListener(new ActionListener() { |
1724 | + @Override |
1725 | + public void actionPerformed(ActionEvent e) { |
1726 | + int selRow = tableExtReferences.getSelectedRow(); |
1727 | + |
1728 | + if (selRow != -1) { |
1729 | + File file = findMgmt.getExtReferences(finding).get(selRow); |
1730 | + |
1731 | + findMgmt.removeExtReference(file, finding); |
1732 | + |
1733 | + modelExtReferences.fireTableDataChanged(); |
1734 | + |
1735 | + updateTableButtons(); |
1736 | + } |
1737 | + } |
1738 | + }); |
1739 | + |
1740 | + buttonPasteExtReference.addActionListener(new ActionListener() { |
1741 | + @Override |
1742 | + public void actionPerformed(ActionEvent e) { |
1743 | + updateFocus(tableExtReferences); |
1744 | + |
1745 | + new PasteImageFromClipboardWorker().execute(); |
1746 | + } |
1747 | + }); |
1748 | + |
1749 | + buttonAddExtReference.setToolTipText(Data.getInstance().getLocaleStr( |
1750 | + "findingsItem.addExRef")); |
1751 | + buttonRemoveExtReference.setToolTipText(Data.getInstance() |
1752 | + .getLocaleStr("findingsItem.remExRef")); |
1753 | + buttonPasteExtReference.setToolTipText(Data.getInstance().getLocaleStr( |
1754 | + "findingsItem.pasteExRef")); |
1755 | + |
1756 | + buttonRemoveExtReference.setEnabled(false); |
1757 | + |
1758 | + panelButtonsExtReferences.add(buttonAddExtReference); |
1759 | + panelButtonsExtReferences.add(buttonRemoveExtReference); |
1760 | + panelButtonsExtReferences.add(buttonPasteExtReference); |
1761 | + |
1762 | + /* |
1763 | + * Buttons for aspects table |
1764 | + */ |
1765 | + buttonAddAspect.addActionListener(new ActionListener() { |
1766 | + @Override |
1767 | + public void actionPerformed(ActionEvent e) { |
1768 | + updateFocus(tableAspects); |
1769 | + |
1770 | + AddAspToFindPopupWindow popup = new AddAspToFindPopupWindow(UI |
1771 | + .getInstance().getProtocolFrame()); |
1772 | + |
1773 | + popup.setVisible(true); |
1774 | + |
1775 | + if (popup.getButtonClicked() == ButtonClicked.OK) { |
1776 | + List<Aspect> aspList = popup.getSelAspList(); |
1777 | + |
1778 | + for (Aspect asp : aspList) { |
1779 | + findMgmt.addAspect(asp, finding); |
1780 | + } |
1781 | + |
1782 | + modelAspects.fireTableDataChanged(); |
1783 | + |
1784 | + GUITools.scrollToBottom(scrollAspects); |
1785 | + } |
1786 | + |
1787 | + updateTableButtons(); |
1788 | + } |
1789 | + }); |
1790 | + |
1791 | + buttonRemoveAspect.addActionListener(new ActionListener() { |
1792 | + @Override |
1793 | + public void actionPerformed(ActionEvent e) { |
1794 | + int selRow = tableAspects.getSelectedRow(); |
1795 | + |
1796 | + if (selRow != -1) { |
1797 | + String asp = findMgmt.getAspects(finding).get(selRow); |
1798 | + findMgmt.removeAspect(asp, finding); |
1799 | + modelAspects.fireTableDataChanged(); |
1800 | + } |
1801 | + |
1802 | + updateTableButtons(); |
1803 | + } |
1804 | + }); |
1805 | + |
1806 | + buttonAddAspect.setToolTipText(Data.getInstance().getLocaleStr( |
1807 | + "findingsItem.addAsp")); |
1808 | + buttonRemoveAspect.setToolTipText(Data.getInstance().getLocaleStr( |
1809 | + "findingsItem.remAsp")); |
1810 | + |
1811 | + buttonRemoveAspect.setEnabled(false); |
1812 | + |
1813 | + panelButtonsAspects.add(buttonAddAspect); |
1814 | + panelButtonsAspects.add(buttonRemoveAspect); |
1815 | + |
1816 | + /* |
1817 | + * Prepare tables |
1818 | + */ |
1819 | + tableAspects = GUITools.newStandardTable(modelAspects, true); |
1820 | + tableReferences = GUITools.newStandardTable(modelReferences, true); |
1821 | + tableExtReferences = GUITools |
1822 | + .newStandardTable(modelExtReferences, true); |
1823 | + |
1824 | + tableAspects.getColumnModel().getColumn(0).setHeaderRenderer( |
1825 | + new FindingPanelHeadRenderer()); |
1826 | + tableReferences.getColumnModel().getColumn(0).setHeaderRenderer( |
1827 | + new FindingPanelHeadRenderer()); |
1828 | + tableExtReferences.getColumnModel().getColumn(0).setHeaderRenderer( |
1829 | + new FindingPanelHeadRenderer()); |
1830 | + |
1831 | + tableAspects.getColumnModel().getColumn(0).setCellRenderer( |
1832 | + new FindingPanelCellRenderer()); |
1833 | + tableReferences.getColumnModel().getColumn(0).setCellRenderer( |
1834 | + new FindingPanelCellRenderer()); |
1835 | + tableExtReferences.getColumnModel().getColumn(0).setCellRenderer( |
1836 | + new FindingPanelCellRenderer()); |
1837 | + |
1838 | + tableAspects.setRowHeight(29); |
1839 | + tableReferences.setRowHeight(29); |
1840 | + tableExtReferences.setRowHeight(29); |
1841 | + |
1842 | + tableAspects.addFocusListener(focusListener); |
1843 | + tableReferences.addFocusListener(focusListener); |
1844 | + tableExtReferences.addFocusListener(focusListener); |
1845 | + |
1846 | + tableAspects.addMouseListener(mouseListener); |
1847 | + tableReferences.addMouseListener(mouseListener); |
1848 | + tableExtReferences.addMouseListener(new MouseListener() { |
1849 | + @Override |
1850 | + public void mouseClicked(MouseEvent e) { |
1851 | + updateTableButtons(); |
1852 | + |
1853 | + if (e.getClickCount() == 2) { |
1854 | + int selRow = tableReferences.getSelectedRow(); |
1855 | + |
1856 | + if (selRow != -1) { |
1857 | + File ref = findMgmt.getExtReferences(finding).get( |
1858 | + tableReferences.getSelectedRow()); |
1859 | + |
1860 | + if (AppTools.isReadableWritableImageFile(ref)) { |
1861 | + UI.getInstance().getProtocolFrame().getImageEditor( |
1862 | + ref).setVisible(true); |
1863 | + } else { |
1864 | + try { |
1865 | + Desktop.getDesktop().open(ref); |
1866 | + } catch (Exception exc) { |
1867 | + JOptionPane.showMessageDialog(UI.getInstance() |
1868 | + .getProtocolFrame(), GUITools |
1869 | + .getMessagePane(exc.getMessage()), Data |
1870 | + .getInstance().getLocaleStr("error"), |
1871 | + JOptionPane.ERROR_MESSAGE); |
1872 | + } |
1873 | + } |
1874 | + } |
1875 | + } |
1876 | + } |
1877 | + |
1878 | + @Override |
1879 | + public void mouseEntered(MouseEvent e) { |
1880 | + } |
1881 | + |
1882 | + @Override |
1883 | + public void mouseExited(MouseEvent e) { |
1884 | + } |
1885 | + |
1886 | + @Override |
1887 | + public void mousePressed(MouseEvent e) { |
1888 | + } |
1889 | + |
1890 | + @Override |
1891 | + public void mouseReleased(MouseEvent e) { |
1892 | + } |
1893 | + }); |
1894 | + |
1895 | + scrollAspects = new JScrollPane(tableAspects); |
1896 | + scrollReferences = new JScrollPane(tableReferences); |
1897 | + scrollExtReferences = new JScrollPane(tableExtReferences); |
1898 | + |
1899 | + scrollAspects.getViewport().setBackground(Color.WHITE); |
1900 | + scrollReferences.getViewport().setBackground(Color.WHITE); |
1901 | + scrollExtReferences.getViewport().setBackground(Color.WHITE); |
1902 | + |
1903 | + /* |
1904 | + * Create content panel |
1905 | + */ |
1906 | + panelEditView.setBorder(UI.STANDARD_BORDER); |
1907 | + panelEditView.setBackground(EDIT_VIEW_BG); |
1908 | + |
1909 | + panelCompactView.setBorder(UI.STANDARD_BORDER); |
1910 | + panelCompactView.setBackground(COMPACT_VIEW_BG); |
1911 | + |
1912 | + labelFindingDescription.setFont(UI.PROTOCOL_FONT); |
1913 | + |
1914 | + labelFindingNumber.setFont(UI.PROTOCOL_FONT_BOLD); |
1915 | + |
1916 | + labelFindingSeverity.setFont(new Font(UI.PROTOCOL_FONT.getName(), |
1917 | + Font.ITALIC, UI.PROTOCOL_FONT.getSize())); |
1918 | + |
1919 | + labelFindingTitle.setFont(UI.PROTOCOL_FONT_BOLD); |
1920 | + labelFindingTitle.setText(Data.getInstance().getLocaleStr( |
1921 | + "editProtocol.finding.number") |
1922 | + + " " + finding.getId()); |
1923 | + |
1924 | + scrollDescription = GUITools.setIntoScrllPn(textDescription); |
1925 | + GUITools.scrollToTop(scrollDescription); |
1926 | + |
1927 | + textDescription.setText(finding.getDescription()); |
1928 | + textDescription.addFocusListener(focusListener); |
1929 | + textDescription.setFont(UI.PROTOCOL_FONT); |
1930 | + textDescription.addKeyListener(new KeyListener() { |
1931 | + @Override |
1932 | + public void keyTyped(KeyEvent e) { |
1933 | + } |
1934 | + |
1935 | + @Override |
1936 | + public void keyReleased(KeyEvent e) { |
1937 | + findingsTab.updateTab(); |
1938 | + |
1939 | + if (findMgmt.isFindingNotComplete(finding)) { |
1940 | + scrollDescription.setBorder(UI.MARKED_BORDER); |
1941 | + } else { |
1942 | + scrollDescription.setBorder(UI.STANDARD_BORDER); |
1943 | + } |
1944 | + } |
1945 | + |
1946 | + @Override |
1947 | + public void keyPressed(KeyEvent e) { |
1948 | + } |
1949 | + }); |
1950 | + |
1951 | + comboSeverity.setFont(UI.PROTOCOL_FONT_BOLD); |
1952 | + for (String sev : sevMgmt.getSeverities()) { |
1953 | + comboSeverity.addItem(sev); |
1954 | + } |
1955 | + comboSeverity.addFocusListener(focusListener); |
1956 | + |
1957 | + comboSeverity.setSelectedItem(finding.getSeverity()); |
1958 | + |
1959 | + comboSeverity.addItemListener(new ItemListener() { |
1960 | + @Override |
1961 | + public void itemStateChanged(ItemEvent e) { |
1962 | + if (e.getStateChange() == ItemEvent.SELECTED) { |
1963 | + finding.setSeverity(comboSeverity.getSelectedItem() |
1964 | + .toString()); |
1965 | + resiData.fireDataChanged(); |
1966 | + } |
1967 | + } |
1968 | + }); |
1969 | + |
1970 | + buttonCloseFinding.addActionListener(new ActionListener() { |
1971 | + @Override |
1972 | + public void actionPerformed(ActionEvent e) { |
1973 | + findingsTab.closeCurrentFinding(); |
1974 | + } |
1975 | + }); |
1976 | + buttonRemoveFinding.addActionListener(new ActionListener() { |
1977 | + @Override |
1978 | + public void actionPerformed(ActionEvent e) { |
1979 | + if (JOptionPane.showConfirmDialog(UI.getInstance() |
1980 | + .getProtocolFrame(), GUITools.getMessagePane(Data |
1981 | + .getInstance().getLocaleStr( |
1982 | + "findingsList.confirmRemoval")), Data |
1983 | + .getInstance().getLocaleStr("question"), |
1984 | + JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { |
1985 | + findingsTab.removeCurrentFinding(); |
1986 | + } |
1987 | + } |
1988 | + }); |
1989 | + buttonPushUp.addActionListener(new ActionListener() { |
1990 | + @Override |
1991 | + public void actionPerformed(ActionEvent e) { |
1992 | + findingsTab.pushUpCurrentFinding(); |
1993 | + } |
1994 | + }); |
1995 | + buttonPushDown.addActionListener(new ActionListener() { |
1996 | + @Override |
1997 | + public void actionPerformed(ActionEvent e) { |
1998 | + findingsTab.pushDownCurrentFinding(); |
1999 | + } |
2000 | + }); |
2001 | + buttonPushTop.addActionListener(new ActionListener() { |
2002 | + @Override |
2003 | + public void actionPerformed(ActionEvent e) { |
2004 | + findingsTab.pushTopCurrentFinding(); |
2005 | + } |
2006 | + }); |
2007 | + buttonPushBottom.addActionListener(new ActionListener() { |
2008 | + @Override |
2009 | + public void actionPerformed(ActionEvent e) { |
2010 | + findingsTab.pushBottomCurrentFinding(); |
2011 | + } |
2012 | + }); |
2013 | + |
2014 | + /* |
2015 | + * Register focus listener |
2016 | + */ |
2017 | + textDescription.addFocusListener(focusListener); |
2018 | + comboSeverity.addFocusListener(focusListener); |
2019 | + |
2020 | + tableAspects.addFocusListener(focusListener); |
2021 | + tableExtReferences.addFocusListener(focusListener); |
2022 | + tableReferences.addFocusListener(focusListener); |
2023 | + |
2024 | + /* |
2025 | + * Add components to compact view panel |
2026 | + */ |
2027 | + GUITools.addComponent(panelCompactView, layoutCompactView, |
2028 | + labelFindingNumber, 0, 0, 1, 1, 0.0, 0.0, 10, 10, 10, 10, |
2029 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2030 | + |
2031 | + GUITools.addComponent(panelCompactView, layoutCompactView, |
2032 | + labelFindingDescription, 1, 0, 1, 1, 1.0, 0.0, 10, 10, 10, 10, |
2033 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2034 | + |
2035 | + GUITools.addComponent(panelCompactView, layoutCompactView, |
2036 | + labelFindingSeverity, 2, 0, 1, 1, 0.0, 0.0, 10, 10, 10, 10, |
2037 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHEAST); |
2038 | + |
2039 | + /* |
2040 | + * Add components to edit view panel |
2041 | + */ |
2042 | + JPanel panelStrut = new JPanel(); |
2043 | + panelStrut.setBackground(EDIT_VIEW_BG); |
2044 | + |
2045 | + GUITools.addComponent(panelEditView, layoutEditView, labelFindingTitle, |
2046 | + 0, 0, 2, 1, 0.0, 0.0, 10, 10, 0, 10, GridBagConstraints.BOTH, |
2047 | + GridBagConstraints.NORTHWEST); |
2048 | + GUITools.addComponent(panelEditView, layoutEditView, comboSeverity, 1, |
2049 | + 0, 2, 1, 0.0, 0.0, 10, 10, 0, 10, GridBagConstraints.NONE, |
2050 | + GridBagConstraints.NORTHEAST); |
2051 | + GUITools.addComponent(panelEditView, layoutEditView, scrollDescription, |
2052 | + 0, 1, 1, 1, 1.0, 1.0, 10, 10, 0, 10, GridBagConstraints.BOTH, |
2053 | + GridBagConstraints.NORTHWEST); |
2054 | + GUITools.addComponent(panelEditView, layoutEditView, panelStrut, 1, 1, |
2055 | + 1, 1, 0.0, 0.0, 10, 0, 0, 20, GridBagConstraints.BOTH, |
2056 | + GridBagConstraints.NORTHWEST); |
2057 | + GUITools.addComponent(panelEditView, layoutEditView, scrollReferences, |
2058 | + 2, 1, 1, 1, 1.0, 0.0, 10, 10, 0, 10, GridBagConstraints.BOTH, |
2059 | + GridBagConstraints.NORTHWEST); |
2060 | + GUITools.addComponent(panelEditView, layoutEditView, |
2061 | + panelButtonsReferences, 3, 1, 1, 1, 0.0, 0.0, 10, 0, 0, 10, |
2062 | + GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
2063 | + GUITools.addComponent(panelEditView, layoutEditView, scrollAspects, 0, |
2064 | + 2, 1, 1, 1.0, 0.0, 10, 10, 10, 10, GridBagConstraints.BOTH, |
2065 | + GridBagConstraints.NORTHWEST); |
2066 | + GUITools.addComponent(panelEditView, layoutEditView, |
2067 | + panelButtonsAspects, 1, 2, 1, 1, 0.0, 0.0, 10, 0, 10, 20, |
2068 | + GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
2069 | + GUITools.addComponent(panelEditView, layoutEditView, |
2070 | + scrollExtReferences, 2, 2, 1, 1, 1.0, 0.0, 10, 10, 10, 10, |
2071 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2072 | + GUITools.addComponent(panelEditView, layoutEditView, |
2073 | + panelButtonsExtReferences, 3, 2, 1, 1, 0.0, 0.0, 10, 0, 10, 10, |
2074 | + GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); |
2075 | + |
2076 | + setEditView(); |
2077 | + |
2078 | + if (findMgmt.isFindingEmpty(finding)) { |
2079 | + finding.setDescription(""); |
2080 | + finding.setSeverity(sevMgmt.getSeverities().get(0)); |
2081 | + resiData.fireDataChanged(); |
2082 | + } |
2083 | + |
2084 | + updateTableButtons(); |
2085 | + updateFindingButtons(); |
2086 | + } |
2087 | + |
2088 | + private void setEditView() { |
2089 | + type = Type.EDIT_VIEW; |
2090 | + |
2091 | + this.setPreferredSize(EDIT_VIEW_SIZE); |
2092 | + |
2093 | + this.setToolTipText(null); |
2094 | + |
2095 | + this.removeAll(); |
2096 | + |
2097 | + this.removeMouseListener(mouseListenerCompact); |
2098 | + |
2099 | + this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
2100 | + |
2101 | + if (findMgmt.isFindingNotComplete(finding)) { |
2102 | + scrollDescription.setBorder(UI.MARKED_BORDER); |
2103 | + } else { |
2104 | + scrollDescription.setBorder(UI.STANDARD_BORDER); |
2105 | + } |
2106 | + |
2107 | + updateFindingButtons(); |
2108 | + |
2109 | + /* |
2110 | + * Create finding control buttons like push etc. |
2111 | + */ |
2112 | + GUITools.addComponent(this, layout, buttonPushTop, 0, 0, 1, 1, 0.0, |
2113 | + 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2114 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2115 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2116 | + GUITools.addComponent(this, layout, buttonPushUp, 0, 1, 1, 1, 0.0, 0.0, |
2117 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2118 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2119 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2120 | + GUITools.addComponent(this, layout, buttonCloseFinding, 0, 2, 1, 1, |
2121 | + 0.0, 1.0, CONTROL_BUTTONS_PADDING + 35, |
2122 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2123 | + CONTROL_BUTTONS_PADDING, GridBagConstraints.BOTH, |
2124 | + GridBagConstraints.NORTHWEST); |
2125 | + GUITools.addComponent(this, layout, buttonRemoveFinding, 0, 3, 1, 1, |
2126 | + 0.0, 1.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2127 | + CONTROL_BUTTONS_PADDING + 35, CONTROL_BUTTONS_PADDING, |
2128 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2129 | + GUITools.addComponent(this, layout, buttonPushDown, 0, 4, 1, 1, 0.0, |
2130 | + 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2131 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2132 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2133 | + GUITools.addComponent(this, layout, buttonPushBottom, 0, 5, 1, 1, 0.0, |
2134 | + 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2135 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2136 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2137 | + |
2138 | + /* |
2139 | + * Add content panel to root panel |
2140 | + */ |
2141 | + GUITools.addComponent(this, layout, panelEditView, 1, 0, 1, 6, 1.0, |
2142 | + 0.0, 0, 0, 0, 20, GridBagConstraints.BOTH, |
2143 | + GridBagConstraints.NORTHWEST); |
2144 | + |
2145 | + /* |
2146 | + * Get the focus |
2147 | + */ |
2148 | + textDescription.requestFocusInWindow(); |
2149 | + } |
2150 | + |
2151 | + private void setCompactView() { |
2152 | + type = Type.COMPACT_VIEW; |
2153 | + |
2154 | + this.setPreferredSize(COMPACT_VIEW_SIZE); |
2155 | + |
2156 | + this.setToolTipText(finding.getAspects().size() + " " |
2157 | + + Data.getInstance().getLocaleStr("findingsList.aspects") |
2158 | + + ", " + finding.getReferences().size() + " " |
2159 | + + Data.getInstance().getLocaleStr("findingsList.references") |
2160 | + + ", " + finding.getExternalReferences().size() |
2161 | + + Data.getInstance().getLocaleStr("findingsList.files")); |
2162 | + |
2163 | + this.removeAll(); |
2164 | + |
2165 | + this.addMouseListener(mouseListenerCompact); |
2166 | + |
2167 | + this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
2168 | + |
2169 | + if (findMgmt.isFindingNotComplete(finding)) { |
2170 | + panelCompactView.setBorder(UI.MARKED_BORDER); |
2171 | + panelCompactView.setBackground(UI.MARKED_COLOR.brighter()); |
2172 | + } else { |
2173 | + panelCompactView.setBorder(UI.STANDARD_BORDER); |
2174 | + panelCompactView.setBackground(COMPACT_VIEW_BG); |
2175 | + } |
2176 | + |
2177 | + storeFindingData(); |
2178 | + |
2179 | + /* |
2180 | + * Update labels |
2181 | + */ |
2182 | + labelFindingNumber.setText(Data.getInstance().getLocaleStr( |
2183 | + "editProtocol.finding.number") |
2184 | + + " " + finding.getId()); |
2185 | + |
2186 | + labelFindingSeverity.setText(finding.getSeverity()); |
2187 | + |
2188 | + labelFindingDescription.setText(finding.getDescription()); |
2189 | + |
2190 | + /* |
2191 | + * Add content panel to the root panel |
2192 | + */ |
2193 | + buttonDummy.setEnabled(false); |
2194 | + |
2195 | + GUITools.addComponent(this, layout, buttonDummy, 0, 0, 1, 1, 0.0, 0.0, |
2196 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2197 | + CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING, |
2198 | + GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2199 | + |
2200 | + GUITools.addComponent(this, layout, panelCompactView, 1, 0, 1, 1, 1.0, |
2201 | + 0.0, 0, 0, 0, 20, GridBagConstraints.BOTH, |
2202 | + GridBagConstraints.NORTHWEST); |
2203 | + } |
2204 | + |
2205 | + public void updateFindingButtons() { |
2206 | + if (findMgmt.getNumberOfFindings(protocol) == 1) { |
2207 | + // buttonRemoveFinding.setEnabled(false); |
2208 | + buttonPushUp.setEnabled(false); |
2209 | + buttonPushDown.setEnabled(false); |
2210 | + buttonPushTop.setEnabled(false); |
2211 | + buttonPushBottom.setEnabled(false); |
2212 | + } else { |
2213 | + // buttonRemoveFinding.setEnabled(true); |
2214 | + |
2215 | + if (findMgmt.isTopFinding(finding, protocol)) { |
2216 | + buttonPushUp.setEnabled(false); |
2217 | + buttonPushTop.setEnabled(false); |
2218 | + } else { |
2219 | + buttonPushUp.setEnabled(true); |
2220 | + buttonPushTop.setEnabled(true); |
2221 | + } |
2222 | + |
2223 | + if (findMgmt.isBottomFinding(finding, protocol)) { |
2224 | + buttonPushDown.setEnabled(false); |
2225 | + buttonPushBottom.setEnabled(false); |
2226 | + } else { |
2227 | + buttonPushDown.setEnabled(true); |
2228 | + buttonPushBottom.setEnabled(true); |
2229 | + } |
2230 | + } |
2231 | + } |
2232 | + |
2233 | + private void updateTableButtons() { |
2234 | + if (tableAspects.getSelectedRow() == -1) { |
2235 | + buttonRemoveAspect.setEnabled(false); |
2236 | + } else { |
2237 | + buttonRemoveAspect.setEnabled(true); |
2238 | + } |
2239 | + |
2240 | + if (tableReferences.getSelectedRow() == -1) { |
2241 | + buttonRemoveReference.setEnabled(false); |
2242 | + buttonEditReference.setEnabled(false); |
2243 | + } else { |
2244 | + buttonRemoveReference.setEnabled(true); |
2245 | + buttonEditReference.setEnabled(true); |
2246 | + } |
2247 | + |
2248 | + if (tableExtReferences.getSelectedRow() == -1) { |
2249 | + buttonRemoveExtReference.setEnabled(false); |
2250 | + } else { |
2251 | + buttonRemoveExtReference.setEnabled(true); |
2252 | + } |
2253 | + } |
2254 | + |
2255 | + public void updateFocus(Object evSource) { |
2256 | + if (evSource != textDescription) { |
2257 | + textDescription.select(0, 0); |
2258 | + } |
2259 | + |
2260 | + if (evSource != tableReferences) { |
2261 | + if (tableReferences.getCellEditor() != null) { |
2262 | + tableReferences.getCellEditor().stopCellEditing(); |
2263 | + } |
2264 | + |
2265 | + if (tableReferences.getRowCount() > 0) { |
2266 | + tableReferences.removeRowSelectionInterval(0, tableReferences |
2267 | + .getRowCount() - 1); |
2268 | + } |
2269 | + } |
2270 | + |
2271 | + if (evSource != tableExtReferences) { |
2272 | + if (tableExtReferences.getRowCount() > 0) { |
2273 | + tableExtReferences.removeRowSelectionInterval(0, |
2274 | + tableExtReferences.getRowCount() - 1); |
2275 | + } |
2276 | + } |
2277 | + |
2278 | + if (evSource != tableAspects) { |
2279 | + if (tableAspects.getRowCount() > 0) { |
2280 | + tableAspects.removeRowSelectionInterval(0, tableAspects |
2281 | + .getRowCount() - 1); |
2282 | + } |
2283 | + } |
2284 | + } |
2285 | + |
2286 | + public boolean isCompactView() { |
2287 | + return type == Type.COMPACT_VIEW; |
2288 | + } |
2289 | + |
2290 | + public boolean isEditView() { |
2291 | + return type == Type.EDIT_VIEW; |
2292 | + } |
2293 | + |
2294 | + public void switchView() { |
2295 | + if (isEditView()) { |
2296 | + setCompactView(); |
2297 | + } else { |
2298 | + setEditView(); |
2299 | + } |
2300 | + } |
2301 | + |
2302 | + public Finding getFinding() { |
2303 | + return finding; |
2304 | + } |
2305 | + |
2306 | + public void storeFindingData() { |
2307 | + finding.setDescription(textDescription.getText()); |
2308 | + |
2309 | + if (tableReferences.isEditing()) { |
2310 | + tableReferences.getCellEditor().stopCellEditing(); |
2311 | + } |
2312 | + } |
2313 | + |
2314 | + private class FindingPanelCellRenderer extends DefaultTableCellRenderer { |
2315 | + private static final long serialVersionUID = 1L; |
2316 | + |
2317 | + @Override |
2318 | + public Font getFont() { |
2319 | + return UI.PROTOCOL_FONT; |
2320 | + } |
2321 | + |
2322 | + @Override |
2323 | + public Component getTableCellRendererComponent(JTable table, |
2324 | + Object value, boolean isSelected, boolean hasFocus, int row, |
2325 | + int column) { |
2326 | + setToolTipText(GUITools.getTextAsHtml("<font size=\"5\">" |
2327 | + + (String) value + "</font>")); |
2328 | + |
2329 | + return super.getTableCellRendererComponent(table, value, |
2330 | + isSelected, hasFocus, row, column); |
2331 | + } |
2332 | + }; |
2333 | + |
2334 | + private class FindingPanelHeadRenderer extends |
2335 | + DefaultTableHeaderCellRenderer { |
2336 | + private static final long serialVersionUID = 1L; |
2337 | + |
2338 | + @Override |
2339 | + public Font getFont() { |
2340 | + return UI.PROTOCOL_FONT; |
2341 | + } |
2342 | + }; |
2343 | + |
2344 | + private class AddExternalReferenceWorker extends SwingWorker<Void, Void> { |
2345 | + @Override |
2346 | + protected Void doInBackground() throws Exception { |
2347 | + FileChooser fileChooser = UI.getInstance().getFileChooser(); |
2348 | + |
2349 | + fileChooser.setFile(null); |
2350 | + |
2351 | + if (fileChooser.showDialog(UI.getInstance().getEditProductDialog(), |
2352 | + FileChooser.MODE_OPEN_FILE, ResiFileFilter.TYPE_ALL) == FileChooser.SELECTED_APPROVE) { |
2353 | + |
2354 | + UI.getInstance().getProtocolFrame().switchToProgressMode(); |
2355 | + |
2356 | + File file = fileChooser.getFile(); |
2357 | + findMgmt.addExtReference(file, finding); |
2358 | + modelExtReferences.fireTableDataChanged(); |
2359 | + |
2360 | + Thread.sleep(200); |
2361 | + |
2362 | + GUITools.scrollToBottom(scrollExtReferences); |
2363 | + |
2364 | + updateTableButtons(); |
2365 | + } |
2366 | + |
2367 | + UI.getInstance().getProtocolFrame().switchToEditMode(); |
2368 | + |
2369 | + return null; |
2370 | + } |
2371 | + }; |
2372 | + |
2373 | + private class PasteImageFromClipboardWorker extends SwingWorker<Void, Void> { |
2374 | + @Override |
2375 | + protected Void doInBackground() throws Exception { |
2376 | + UI.getInstance().getProtocolFrame().switchToProgressMode( |
2377 | + Data.getInstance().getLocaleStr( |
2378 | + "editProtocol.message.imgLoading")); |
2379 | + |
2380 | + Image img = AppTools.getImageFromClipboard(); |
2381 | + |
2382 | + if (img == null) { |
2383 | + JOptionPane.showMessageDialog(UI.getInstance() |
2384 | + .getProtocolFrame(), GUITools.getMessagePane(Data |
2385 | + .getInstance().getLocaleStr( |
2386 | + "editProtocol.message.noImgInCb")), Data |
2387 | + .getInstance().getLocaleStr("info"), |
2388 | + JOptionPane.INFORMATION_MESSAGE); |
2389 | + } else { |
2390 | + Image scalImg = img.getScaledInstance(-1, 250, |
2391 | + Image.SCALE_SMOOTH); |
2392 | + |
2393 | + JLabel labelImg = new JLabel(new ImageIcon(scalImg)); |
2394 | + labelImg.setBorder(new CompoundBorder(new EmptyBorder(0, 0, 15, |
2395 | + 0), new MatteBorder(1, 1, 1, 1, UI.SEPARATOR_COLOR))); |
2396 | + |
2397 | + JTextField inputField = new JTextField(); |
2398 | + inputField.setText(Data.getInstance().getLocaleStr( |
2399 | + "editProtocol.finding.stdFileName")); |
2400 | + |
2401 | + JPanel messagePane = new JPanel(new BorderLayout()); |
2402 | + messagePane.add(labelImg, BorderLayout.NORTH); |
2403 | + messagePane.add(new JLabel(Data.getInstance().getLocaleStr( |
2404 | + "editProtocol.message.askForFileName")), |
2405 | + BorderLayout.CENTER); |
2406 | + messagePane.add(inputField, BorderLayout.SOUTH); |
2407 | + |
2408 | + Object[] options = { |
2409 | + Data.getInstance().getLocaleStr("findingsItem.save"), |
2410 | + Data.getInstance().getLocaleStr("findingsItem.edit"), |
2411 | + Data.getInstance().getLocaleStr("findingsItem.abort") }; |
2412 | + |
2413 | + int action = JOptionPane.showOptionDialog(UI.getInstance() |
2414 | + .getProtocolFrame(), messagePane, Data.getInstance() |
2415 | + .getLocaleStr("confirm"), |
2416 | + JOptionPane.YES_NO_CANCEL_OPTION, |
2417 | + JOptionPane.PLAIN_MESSAGE, null, options, options[0]); |
2418 | + |
2419 | + String fileName = null; |
2420 | + |
2421 | + if (action != 2) { |
2422 | + fileName = inputField.getText(); |
2423 | + } |
2424 | + |
2425 | + if (fileName != null && !fileName.trim().equals("")) { |
2426 | + findMgmt.addExtReference(img, fileName, finding); |
2427 | + |
2428 | + modelExtReferences.fireTableDataChanged(); |
2429 | + |
2430 | + updateTableButtons(); |
2431 | + } |
2432 | + |
2433 | + if (action == 1) { |
2434 | + int numberOfExtRefs = findMgmt.getExtReferences(finding) |
2435 | + .size(); |
2436 | + |
2437 | + File extRef = findMgmt.getExtReferences(finding).get( |
2438 | + numberOfExtRefs - 1); |
2439 | + |
2440 | + UI.getInstance().getProtocolFrame().getImageEditor(extRef) |
2441 | + .setVisible(true); |
2442 | + } |
2443 | + } |
2444 | + |
2445 | + UI.getInstance().getProtocolFrame().switchToEditMode(); |
2446 | + |
2447 | + return null; |
2448 | + } |
2449 | + } |
2450 | + |
2451 | +} |
2452 | |
2453 | === added file 'src/org/revager/gui/protocol/FindingsTab.java' |
2454 | --- src/org/revager/gui/protocol/FindingsTab.java 1970-01-01 00:00:00 +0000 |
2455 | +++ src/org/revager/gui/protocol/FindingsTab.java 2010-05-27 20:33:41 +0000 |
2456 | @@ -0,0 +1,421 @@ |
2457 | +package org.revager.gui.protocol; |
2458 | + |
2459 | +import java.awt.BorderLayout; |
2460 | +import java.awt.Color; |
2461 | +import java.awt.GridBagConstraints; |
2462 | +import java.awt.GridBagLayout; |
2463 | +import java.awt.event.ActionEvent; |
2464 | +import java.awt.event.ActionListener; |
2465 | +import java.util.HashMap; |
2466 | +import java.util.Map; |
2467 | + |
2468 | +import javax.swing.BorderFactory; |
2469 | +import javax.swing.JButton; |
2470 | +import javax.swing.JLabel; |
2471 | +import javax.swing.JPanel; |
2472 | +import javax.swing.JScrollPane; |
2473 | +import javax.swing.SwingUtilities; |
2474 | + |
2475 | +import org.revager.app.Application; |
2476 | +import org.revager.app.FindingManagement; |
2477 | +import org.revager.app.SeverityManagement; |
2478 | +import org.revager.app.model.Data; |
2479 | +import org.revager.app.model.schema.Finding; |
2480 | +import org.revager.app.model.schema.Protocol; |
2481 | +import org.revager.gui.UI; |
2482 | +import org.revager.tools.GUITools; |
2483 | + |
2484 | +public class FindingsTab extends JPanel { |
2485 | + |
2486 | + private static final long serialVersionUID = 1L; |
2487 | + |
2488 | + private FindingManagement findMgmt = Application.getInstance() |
2489 | + .getFindingMgmt(); |
2490 | + private SeverityManagement sevMgmt = Application.getInstance() |
2491 | + .getSeverityMgmt(); |
2492 | + |
2493 | + private Protocol protocol = null; |
2494 | + |
2495 | + private FindingPanel currentFindingPanel = null; |
2496 | + |
2497 | + private GridBagLayout layoutFindingsList = new GridBagLayout(); |
2498 | + private JPanel panelFindingsList = new JPanel(layoutFindingsList); |
2499 | + private JScrollPane scrollFindingsList = new JScrollPane(panelFindingsList); |
2500 | + |
2501 | + private int gblAlignment = GridBagConstraints.BOTH; |
2502 | + |
2503 | + private JPanel panelStrut = new JPanel(); |
2504 | + |
2505 | + private JButton buttonAddFinding = new JButton(Data.getInstance() |
2506 | + .getLocaleStr("editProtocol.newFinding")); |
2507 | + private JLabel labelNumOfFindings = new JLabel(); |
2508 | + |
2509 | + private Map<Finding, Integer> gridBagPositions = new HashMap<Finding, Integer>(); |
2510 | + private Map<Finding, FindingPanel> findingPanels = new HashMap<Finding, FindingPanel>(); |
2511 | + |
2512 | + private int currentGridBagPosition = 0; |
2513 | + |
2514 | + public FindingsTab(final Protocol protocol) { |
2515 | + super(); |
2516 | + |
2517 | + this.protocol = protocol; |
2518 | + |
2519 | + this.setLayout(new BorderLayout()); |
2520 | + |
2521 | + panelFindingsList.setBackground(Color.WHITE); |
2522 | + panelStrut.setBackground(Color.WHITE); |
2523 | + |
2524 | + scrollFindingsList.getVerticalScrollBar().setUnitIncrement(12); |
2525 | + scrollFindingsList.getHorizontalScrollBar().setUnitIncrement(12); |
2526 | + |
2527 | + /* |
2528 | + * Prepare footer |
2529 | + */ |
2530 | + JPanel panelFoot = new JPanel(new BorderLayout()); |
2531 | + |
2532 | + labelNumOfFindings.setFont(UI.PROTOCOL_FONT); |
2533 | + |
2534 | + buttonAddFinding.setIcon(Data.getInstance().getIcon("add_25x25.png")); |
2535 | + buttonAddFinding.addActionListener(new ActionListener() { |
2536 | + @Override |
2537 | + public void actionPerformed(ActionEvent e) { |
2538 | + if (currentFindingPanel != null) { |
2539 | + currentFindingPanel.storeFindingData(); |
2540 | + } |
2541 | + |
2542 | + // int listIdLastFinding = |
2543 | + // findMgmt.getNumberOfFindings(protocol) - 1; |
2544 | + |
2545 | + // if (!findMgmt.isFindingEmpty(findMgmt.getFindings(protocol) |
2546 | + // .get(listIdLastFinding))) { |
2547 | + Finding newFind = new Finding(); |
2548 | + newFind.setSeverity(sevMgmt.getSeverities().get(0)); |
2549 | + newFind = findMgmt.addFinding(newFind, protocol); |
2550 | + |
2551 | + addFinding(newFind); |
2552 | + // } |
2553 | + } |
2554 | + }); |
2555 | + |
2556 | + panelFoot.setBorder(BorderFactory.createMatteBorder(5, 35, 5, 35, |
2557 | + panelFoot.getBackground())); |
2558 | + |
2559 | + panelFoot.add(buttonAddFinding, BorderLayout.WEST); |
2560 | + panelFoot.add(labelNumOfFindings, BorderLayout.EAST); |
2561 | + |
2562 | + this.add(scrollFindingsList, BorderLayout.CENTER); |
2563 | + this.add(panelFoot, BorderLayout.SOUTH); |
2564 | + |
2565 | + /* |
2566 | + * Load all findings |
2567 | + */ |
2568 | + for (Finding find : findMgmt.getFindings(protocol)) { |
2569 | + addFinding(find); |
2570 | + } |
2571 | + } |
2572 | + |
2573 | + public Protocol getProtocol() { |
2574 | + return protocol; |
2575 | + } |
2576 | + |
2577 | + public void updateTab() { |
2578 | + if (currentFindingPanel != null) { |
2579 | + currentFindingPanel.storeFindingData(); |
2580 | + } |
2581 | + |
2582 | + labelNumOfFindings.setText(findMgmt.getNumberOfFindings(protocol) + " " |
2583 | + + Data.getInstance().getLocaleStr("editProtocol.findings")); |
2584 | + |
2585 | + /* |
2586 | + * Update the tooltip |
2587 | + */ |
2588 | + Map<String, Integer> findingsSev = new HashMap<String, Integer>(); |
2589 | + |
2590 | + for (Finding f : findMgmt.getFindings(protocol)) { |
2591 | + if (findingsSev.get(f.getSeverity()) == null) { |
2592 | + findingsSev.put(f.getSeverity(), 1); |
2593 | + } else { |
2594 | + findingsSev.put(f.getSeverity(), findingsSev.get(f |
2595 | + .getSeverity()) + 1); |
2596 | + } |
2597 | + } |
2598 | + |
2599 | + String sevOverview = ""; |
2600 | + String separator = ""; |
2601 | + |
2602 | + for (String s : sevMgmt.getSeverities()) { |
2603 | + if (findingsSev.get(s) != null) { |
2604 | + sevOverview = sevOverview + separator + findingsSev.get(s) |
2605 | + + " x " + s; |
2606 | + |
2607 | + separator = "; "; |
2608 | + } |
2609 | + } |
2610 | + |
2611 | + labelNumOfFindings.setToolTipText(GUITools.getTextAsHtml(sevOverview)); |
2612 | + |
2613 | + /* |
2614 | + * Update the button state |
2615 | + */ |
2616 | + boolean isComplete = true; |
2617 | + |
2618 | + for (Finding find : findMgmt.getFindings(protocol)) { |
2619 | + if (findMgmt.isFindingNotComplete(find)) { |
2620 | + isComplete = false; |
2621 | + } |
2622 | + } |
2623 | + |
2624 | + buttonAddFinding.setEnabled(isComplete); |
2625 | + |
2626 | + UI.getInstance().getProtocolFrame().update(null, null); |
2627 | + } |
2628 | + |
2629 | + public void addFinding(Finding finding) { |
2630 | + findMgmt.addFinding(finding, protocol); |
2631 | + |
2632 | + if (currentFindingPanel != null) { |
2633 | + currentFindingPanel.switchView(); |
2634 | + } |
2635 | + |
2636 | + currentFindingPanel = new FindingPanel(finding, this); |
2637 | + |
2638 | + gridBagPositions.put(finding, currentGridBagPosition); |
2639 | + findingPanels.put(finding, currentFindingPanel); |
2640 | + |
2641 | + panelFindingsList.remove(panelStrut); |
2642 | + |
2643 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2644 | + currentFindingPanel, 0, currentGridBagPosition, 1, 1, 1.0, 0.0, |
2645 | + 5, 5, 5, 5, gblAlignment, GridBagConstraints.NORTHWEST); |
2646 | + |
2647 | + /* |
2648 | + * Update position of strut panel |
2649 | + */ |
2650 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2651 | + panelStrut, 0, currentGridBagPosition + 1, 1, 1, 1.0, 1.0, 0, |
2652 | + 0, 0, 0, gblAlignment, GridBagConstraints.NORTHWEST); |
2653 | + |
2654 | + currentGridBagPosition++; |
2655 | + |
2656 | + GUITools.scrollToBottom(scrollFindingsList); |
2657 | + // panelFindingsList.scrollRectToVisible(currentFindingPanel.getBounds()); |
2658 | + |
2659 | + panelFindingsList.revalidate(); |
2660 | + |
2661 | + updateTab(); |
2662 | + } |
2663 | + |
2664 | + public void editFinding(Finding finding) { |
2665 | + if (currentFindingPanel != null |
2666 | + && currentFindingPanel.getFinding() == finding) { |
2667 | + return; |
2668 | + } |
2669 | + |
2670 | + if (currentFindingPanel != null) { |
2671 | + currentFindingPanel.switchView(); |
2672 | + } |
2673 | + |
2674 | + currentFindingPanel = findingPanels.get(finding); |
2675 | + |
2676 | + currentFindingPanel.switchView(); |
2677 | + |
2678 | + panelFindingsList.revalidate(); |
2679 | + } |
2680 | + |
2681 | + public void closeCurrentFinding() { |
2682 | + if (currentFindingPanel != null) { |
2683 | + currentFindingPanel.switchView(); |
2684 | + |
2685 | + currentFindingPanel = null; |
2686 | + |
2687 | + panelFindingsList.revalidate(); |
2688 | + } |
2689 | + } |
2690 | + |
2691 | + public void removeCurrentFinding() { |
2692 | + if (currentFindingPanel != null) { |
2693 | + Finding currentFinding = currentFindingPanel.getFinding(); |
2694 | + |
2695 | + panelFindingsList.remove(currentFindingPanel); |
2696 | + |
2697 | + currentFindingPanel = null; |
2698 | + |
2699 | + gridBagPositions.remove(currentFinding); |
2700 | + findingPanels.remove(currentFinding); |
2701 | + |
2702 | + findMgmt.removeFinding(currentFinding, protocol); |
2703 | + |
2704 | + panelFindingsList.revalidate(); |
2705 | + } |
2706 | + |
2707 | + /* |
2708 | + * Add new finding, if there are no findings present |
2709 | + */ |
2710 | + if (findMgmt.getNumberOfFindings(protocol) == 0) { |
2711 | + Finding newFind = new Finding(); |
2712 | + newFind.setSeverity(sevMgmt.getSeverities().get(0)); |
2713 | + newFind = findMgmt.addFinding(newFind, protocol); |
2714 | + |
2715 | + addFinding(newFind); |
2716 | + } |
2717 | + |
2718 | + updateTab(); |
2719 | + } |
2720 | + |
2721 | + public void pushUpCurrentFinding() { |
2722 | + if (currentFindingPanel != null) { |
2723 | + FindingPanel predecFindPanel = null; |
2724 | + |
2725 | + int predecPos = -1; |
2726 | + int currPos = gridBagPositions |
2727 | + .get(currentFindingPanel.getFinding()); |
2728 | + |
2729 | + /* |
2730 | + * Find predecessor |
2731 | + */ |
2732 | + for (Finding find : gridBagPositions.keySet()) { |
2733 | + if (gridBagPositions.get(find) < currPos |
2734 | + && gridBagPositions.get(find) > predecPos) { |
2735 | + predecPos = gridBagPositions.get(find); |
2736 | + predecFindPanel = findingPanels.get(find); |
2737 | + } |
2738 | + } |
2739 | + |
2740 | + gridBagPositions.put(currentFindingPanel.getFinding(), predecPos); |
2741 | + gridBagPositions.put(predecFindPanel.getFinding(), currPos); |
2742 | + |
2743 | + panelFindingsList.remove(currentFindingPanel); |
2744 | + panelFindingsList.remove(predecFindPanel); |
2745 | + |
2746 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2747 | + currentFindingPanel, 0, predecPos, 1, 1, 1.0, 0.0, 5, 5, 5, |
2748 | + 5, gblAlignment, GridBagConstraints.NORTHWEST); |
2749 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2750 | + predecFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
2751 | + gblAlignment, GridBagConstraints.NORTHWEST); |
2752 | + |
2753 | + findMgmt.pushUpFinding(currentFindingPanel.getFinding(), protocol); |
2754 | + |
2755 | + panelFindingsList.revalidate(); |
2756 | + |
2757 | + SwingUtilities.invokeLater(new Runnable() { |
2758 | + public void run() { |
2759 | + scrollFindingsList |
2760 | + .getVerticalScrollBar() |
2761 | + .setValue( |
2762 | + scrollFindingsList.getVerticalScrollBar() |
2763 | + .getValue() |
2764 | + - (FindingPanel.COMPACT_VIEW_SIZE.height + 10)); |
2765 | + } |
2766 | + }); |
2767 | + |
2768 | + currentFindingPanel.updateFindingButtons(); |
2769 | + } |
2770 | + } |
2771 | + |
2772 | + public void pushDownCurrentFinding() { |
2773 | + if (currentFindingPanel != null) { |
2774 | + FindingPanel succFindPanel = null; |
2775 | + |
2776 | + int succPos = currentGridBagPosition + 1; |
2777 | + int currPos = gridBagPositions |
2778 | + .get(currentFindingPanel.getFinding()); |
2779 | + |
2780 | + /* |
2781 | + * Find successor |
2782 | + */ |
2783 | + for (Finding find : gridBagPositions.keySet()) { |
2784 | + if (gridBagPositions.get(find) > currPos |
2785 | + && gridBagPositions.get(find) < succPos) { |
2786 | + succPos = gridBagPositions.get(find); |
2787 | + succFindPanel = findingPanels.get(find); |
2788 | + } |
2789 | + } |
2790 | + |
2791 | + gridBagPositions.put(currentFindingPanel.getFinding(), succPos); |
2792 | + gridBagPositions.put(succFindPanel.getFinding(), currPos); |
2793 | + |
2794 | + panelFindingsList.remove(currentFindingPanel); |
2795 | + panelFindingsList.remove(succFindPanel); |
2796 | + |
2797 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2798 | + currentFindingPanel, 0, succPos, 1, 1, 1.0, 0.0, 5, 5, 5, |
2799 | + 5, gblAlignment, GridBagConstraints.NORTHWEST); |
2800 | + GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2801 | + succFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
2802 | + gblAlignment, GridBagConstraints.NORTHWEST); |
2803 | + |
2804 | + findMgmt |
2805 | + .pushDownFinding(currentFindingPanel.getFinding(), protocol); |
2806 | + |
2807 | + panelFindingsList.revalidate(); |
2808 | + |
2809 | + SwingUtilities.invokeLater(new Runnable() { |
2810 | + public void run() { |
2811 | + scrollFindingsList |
2812 | + .getVerticalScrollBar() |
2813 | + .setValue( |
2814 | + scrollFindingsList.getVerticalScrollBar() |
2815 | + .getValue() |
2816 | + + (FindingPanel.COMPACT_VIEW_SIZE.height + 10)); |
2817 | + } |
2818 | + }); |
2819 | + |
2820 | + currentFindingPanel.updateFindingButtons(); |
2821 | + } |
2822 | + } |
2823 | + |
2824 | + public void pushTopCurrentFinding() { |
2825 | + if (currentFindingPanel != null) { |
2826 | + while (!findMgmt.isTopFinding(currentFindingPanel.getFinding(), |
2827 | + protocol)) { |
2828 | + pushUpCurrentFinding(); |
2829 | + } |
2830 | + /* |
2831 | + * FindingPanel firstFindPanel = null; |
2832 | + * |
2833 | + * int firstPos = currentGridBagPosition + 1; int currPos = |
2834 | + * gridBagPositions .get(currentFindingPanel.getFinding()); |
2835 | + * |
2836 | + * |
2837 | + * |
2838 | + * for (Finding find : gridBagPositions.keySet()) { if |
2839 | + * (gridBagPositions.get(find) < firstPos) { firstPos = |
2840 | + * gridBagPositions.get(find); firstFindPanel = |
2841 | + * findingPanels.get(find); } } |
2842 | + * |
2843 | + * gridBagPositions.put(currentFindingPanel.getFinding(), firstPos); |
2844 | + * gridBagPositions.put(firstFindPanel.getFinding(), currPos); |
2845 | + * |
2846 | + * panelFindingsList.remove(currentFindingPanel); |
2847 | + * panelFindingsList.remove(firstFindPanel); |
2848 | + * |
2849 | + * GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2850 | + * currentFindingPanel, 0, firstPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
2851 | + * GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2852 | + * GUITools.addComponent(panelFindingsList, layoutFindingsList, |
2853 | + * firstFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
2854 | + * GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); |
2855 | + * |
2856 | + * findMgmt.pushTopFinding(currentFindingPanel.getFinding(), |
2857 | + * protocol); |
2858 | + * |
2859 | + * panelFindingsList.revalidate(); |
2860 | + * |
2861 | + * GUITools.scrollToTop(scrollFindingsList); |
2862 | + * |
2863 | + * currentFindingPanel.updateFindingButtons(); |
2864 | + */ |
2865 | + } |
2866 | + } |
2867 | + |
2868 | + public void pushBottomCurrentFinding() { |
2869 | + if (currentFindingPanel != null) { |
2870 | + while (!findMgmt.isBottomFinding(currentFindingPanel.getFinding(), |
2871 | + protocol)) { |
2872 | + pushDownCurrentFinding(); |
2873 | + } |
2874 | + } |
2875 | + } |
2876 | + |
2877 | +} |
2878 | |
2879 | === modified file 'src/org/revager/gui/protocol/ProtocolFrame.java' |
2880 | --- src/org/revager/gui/protocol/ProtocolFrame.java 2010-01-31 17:32:35 +0000 |
2881 | +++ src/org/revager/gui/protocol/ProtocolFrame.java 2010-05-27 20:33:41 +0000 |
2882 | @@ -19,7 +19,6 @@ |
2883 | package org.revager.gui.protocol; |
2884 | |
2885 | import java.awt.BorderLayout; |
2886 | -import java.awt.Color; |
2887 | import java.awt.Component; |
2888 | import java.awt.Cursor; |
2889 | import java.awt.Dimension; |
2890 | @@ -32,8 +31,6 @@ |
2891 | import java.awt.Toolkit; |
2892 | import java.awt.event.ActionEvent; |
2893 | import java.awt.event.ActionListener; |
2894 | -import java.awt.event.ComponentEvent; |
2895 | -import java.awt.event.ComponentListener; |
2896 | import java.awt.event.ItemEvent; |
2897 | import java.awt.event.ItemListener; |
2898 | import java.awt.event.KeyEvent; |
2899 | @@ -71,10 +68,8 @@ |
2900 | import javax.swing.JTextArea; |
2901 | import javax.swing.JTextField; |
2902 | import javax.swing.SwingWorker; |
2903 | -import javax.swing.UIManager; |
2904 | import javax.swing.JSpinner.NumberEditor; |
2905 | import javax.swing.border.EmptyBorder; |
2906 | -import javax.swing.border.MatteBorder; |
2907 | import javax.swing.event.ChangeEvent; |
2908 | import javax.swing.event.ChangeListener; |
2909 | import javax.swing.table.TableCellRenderer; |
2910 | @@ -84,13 +79,11 @@ |
2911 | import org.revager.app.FindingManagement; |
2912 | import org.revager.app.ProtocolManagement; |
2913 | import org.revager.app.ReviewManagement; |
2914 | -import org.revager.app.SeverityManagement; |
2915 | import org.revager.app.model.Data; |
2916 | import org.revager.app.model.DataException; |
2917 | import org.revager.app.model.appdata.AppSettingKey; |
2918 | import org.revager.app.model.appdata.AppSettingValue; |
2919 | import org.revager.app.model.schema.Attendee; |
2920 | -import org.revager.app.model.schema.Finding; |
2921 | import org.revager.app.model.schema.Meeting; |
2922 | import org.revager.app.model.schema.Protocol; |
2923 | import org.revager.gui.AbstractFrame; |
2924 | @@ -103,7 +96,6 @@ |
2925 | import org.revager.gui.helpers.DatePicker; |
2926 | import org.revager.gui.helpers.HintItem; |
2927 | import org.revager.gui.helpers.ObservingTextField; |
2928 | -import org.revager.gui.models.FindingsTableModel; |
2929 | import org.revager.gui.models.PresentAttendeesTableModel; |
2930 | import org.revager.gui.models.RotateSpinnerNumberModel; |
2931 | import org.revager.gui.protocol.graphical_annotations.ImageEditorDialog; |
2932 | @@ -111,7 +103,6 @@ |
2933 | import org.revager.gui.workers.ProtocolClockWorker; |
2934 | import org.revager.tools.GUITools; |
2935 | |
2936 | - |
2937 | /** |
2938 | * The Class ProtocolFrame. |
2939 | */ |
2940 | @@ -130,9 +121,7 @@ |
2941 | private boolean fullscreen = false; |
2942 | private boolean nativeFullscrSupported = false; |
2943 | |
2944 | - private int visibleFindingsCount = 1; |
2945 | - |
2946 | - private int firstVisibleFinding = 0; |
2947 | + private boolean bodyCreated = false; |
2948 | |
2949 | private GraphicsDevice gd = GraphicsEnvironment |
2950 | .getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
2951 | @@ -140,14 +129,10 @@ |
2952 | private FindingManagement findMgmt = Application.getInstance() |
2953 | .getFindingMgmt(); |
2954 | |
2955 | - private Finding editingFinding = null; |
2956 | - |
2957 | private GridBagLayout gbl = new GridBagLayout(); |
2958 | private JTabbedPane tabbedPane = new JTabbedPane(); |
2959 | private JPanel tabPanelOrg = new JPanel(gbl); |
2960 | private JPanel bottomOrgPanel = new JPanel(gbl); |
2961 | - |
2962 | - private List<FindingItem> visibleFList=new ArrayList<FindingItem>(); |
2963 | |
2964 | private JButton tbPdfExport; |
2965 | private JButton tbCsvExport; |
2966 | @@ -180,15 +165,9 @@ |
2967 | /* |
2968 | * things for finding tab |
2969 | */ |
2970 | - private GridBagLayout gblBaseFindings = new GridBagLayout(); |
2971 | - private GridBagLayout gblFindings = new GridBagLayout(); |
2972 | - private JPanel tabPanelFindings = new JPanel(gblBaseFindings); |
2973 | - private JPanel panelFindings = new JPanel(gblFindings); |
2974 | - private JButton buttonFindScrollUp; |
2975 | - private JButton buttonFindScrollDown; |
2976 | - private JLabel labelFindTop = new JLabel(); |
2977 | - private JLabel labelFindBottom = new JLabel(); |
2978 | - private ColoredTableCellRenderer ctcr; |
2979 | + private Protocol currentProt; |
2980 | + |
2981 | + private FindingsTab tabPanelFindings; |
2982 | |
2983 | private SimpleDateFormat sdfCurrentTime = new SimpleDateFormat( |
2984 | "d. MMMM yyyy | HH:mm"); |
2985 | @@ -200,14 +179,10 @@ |
2986 | private JButton clockButtonReset; |
2987 | |
2988 | private PresentAttendeesTableModel patm; |
2989 | - private FindingsTableModel ftm; |
2990 | |
2991 | private JTable presentAttTable; |
2992 | - private JTable findTbl; |
2993 | - private JScrollPane findScrllPn; |
2994 | |
2995 | private List<Attendee> presentAttList; |
2996 | - private Protocol currentProt; |
2997 | |
2998 | private Meeting currentMeet = null; |
2999 | private JSpinner beginMSpinner; |
3000 | @@ -219,7 +194,6 @@ |
3001 | private JTextArea impTxtArea; |
3002 | private JTextArea meetCommTxtArea; |
3003 | private JTextArea protCommTxtArea; |
3004 | - private JButton buttonAddFinding; |
3005 | private JScrollPane impScrllPn; |
3006 | private JScrollPane meetCommScrllPn; |
3007 | private JScrollPane protCommScrllPn; |
3008 | @@ -236,9 +210,6 @@ |
3009 | private JButton removeAttendee; |
3010 | private JButton editAttendee; |
3011 | |
3012 | - private SeverityManagement sevMgmt = Application.getInstance() |
3013 | - .getSeverityMgmt(); |
3014 | - |
3015 | private DateFormat dateF = SimpleDateFormat |
3016 | .getDateInstance(DateFormat.LONG); |
3017 | |
3018 | @@ -253,52 +224,6 @@ |
3019 | }; |
3020 | |
3021 | /** |
3022 | - * Gets the ftm. |
3023 | - * |
3024 | - * @return the ftm |
3025 | - */ |
3026 | - public FindingsTableModel getFtm() { |
3027 | - return ftm; |
3028 | - } |
3029 | - |
3030 | - /** |
3031 | - * Gets the find tbl. |
3032 | - * |
3033 | - * @return the find tbl |
3034 | - */ |
3035 | - public JTable getFindTbl() { |
3036 | - return findTbl; |
3037 | - } |
3038 | - |
3039 | - /** |
3040 | - * Gets the first visible finding. |
3041 | - * |
3042 | - * @return the first visible finding |
3043 | - */ |
3044 | - public int getFirstVisibleFinding() { |
3045 | - return firstVisibleFinding; |
3046 | - } |
3047 | - |
3048 | - /** |
3049 | - * Gets the visible findings count. |
3050 | - * |
3051 | - * @return the visible findings count |
3052 | - */ |
3053 | - public int getVisibleFindingsCount() { |
3054 | - return visibleFindingsCount; |
3055 | - } |
3056 | - |
3057 | - /** |
3058 | - * Sets the first visible finding. |
3059 | - * |
3060 | - * @param firstVisibleFinding |
3061 | - * the new first visible finding |
3062 | - */ |
3063 | - public void setFirstVisibleFinding(int firstVisibleFinding) { |
3064 | - this.firstVisibleFinding = firstVisibleFinding; |
3065 | - } |
3066 | - |
3067 | - /** |
3068 | * Gets the patm. |
3069 | * |
3070 | * @return the patm |
3071 | @@ -396,6 +321,8 @@ |
3072 | createCommAndRatePanel(); |
3073 | tabPanelCommAndRec.validate(); |
3074 | |
3075 | + tabPanelFindings = new FindingsTab(currentProt); |
3076 | + |
3077 | tabbedPane.removeAll(); |
3078 | tabbedPane.removeChangeListener(tabChangeListener); |
3079 | |
3080 | @@ -410,42 +337,10 @@ |
3081 | "editProtocol.commAndRec"), tabPanelCommAndRec); |
3082 | |
3083 | tabbedPane.addChangeListener(tabChangeListener); |
3084 | - |
3085 | - tabbedPane.addMouseListener(new MouseListener(){ |
3086 | - |
3087 | - @Override |
3088 | - public void mouseClicked(MouseEvent e) { |
3089 | - saveEditRefs(); |
3090 | - } |
3091 | - |
3092 | - @Override |
3093 | - public void mouseEntered(MouseEvent e) { |
3094 | - |
3095 | - } |
3096 | - |
3097 | - @Override |
3098 | - public void mouseExited(MouseEvent e) { |
3099 | - // TODO Auto-generated method stub |
3100 | - |
3101 | - } |
3102 | - |
3103 | - @Override |
3104 | - public void mousePressed(MouseEvent e) { |
3105 | - |
3106 | - } |
3107 | - |
3108 | - @Override |
3109 | - public void mouseReleased(MouseEvent e) { |
3110 | - // TODO Auto-generated method stub |
3111 | - |
3112 | - }}); |
3113 | |
3114 | add(tabbedPane); |
3115 | |
3116 | - tabPanelFindings.removeAll(); |
3117 | - |
3118 | - createPanelFindings(); |
3119 | - updatePanelFindings(); |
3120 | + bodyCreated = true; |
3121 | } |
3122 | |
3123 | /* |
3124 | @@ -561,7 +456,6 @@ |
3125 | tbFullscreen.addActionListener(new ActionListener() { |
3126 | @Override |
3127 | public void actionPerformed(ActionEvent e) { |
3128 | - saveEditRefs(); |
3129 | UI.getInstance().getProtocolFrame(!isFullscreen()).setVisible( |
3130 | true); |
3131 | } |
3132 | @@ -1199,292 +1093,6 @@ |
3133 | } |
3134 | |
3135 | /** |
3136 | - * Creates the panel findings. |
3137 | - */ |
3138 | - private void createPanelFindings() { |
3139 | - buttonFindScrollUp = GUITools.newImageButton(Data.getInstance() |
3140 | - .getIcon("findingUp_32x32_0.png"), Data.getInstance().getIcon( |
3141 | - "findingUp_32x32.png")); |
3142 | - buttonFindScrollUp.setToolTipText(Data.getInstance().getLocaleStr( |
3143 | - "editProtocol.scrollUp")); |
3144 | - buttonFindScrollUp.addActionListener(new ActionListener() { |
3145 | - @Override |
3146 | - public void actionPerformed(ActionEvent e) { |
3147 | - saveEditRefs(); |
3148 | - if (firstVisibleFinding > 0) { |
3149 | - firstVisibleFinding--; |
3150 | - |
3151 | - updatePanelFindings(); |
3152 | - ftm.fireTableDataChanged(); |
3153 | - findTbl.setRowSelectionInterval(firstVisibleFinding, |
3154 | - firstVisibleFinding); |
3155 | - updateTable(); |
3156 | - } |
3157 | - } |
3158 | - }); |
3159 | - |
3160 | - buttonFindScrollDown = GUITools.newImageButton(Data.getInstance() |
3161 | - .getIcon("findingDown_32x32_0.png"), Data.getInstance() |
3162 | - .getIcon("findingDown_32x32.png")); |
3163 | - buttonFindScrollDown.setToolTipText(Data.getInstance().getLocaleStr( |
3164 | - "editProtocol.scrollDown")); |
3165 | - buttonFindScrollDown.addActionListener(new ActionListener() { |
3166 | - @Override |
3167 | - public void actionPerformed(ActionEvent e) { |
3168 | - saveEditRefs(); |
3169 | - if (firstVisibleFinding < findMgmt |
3170 | - .getNumberOfFindings(currentProt) |
3171 | - - visibleFindingsCount) { |
3172 | - firstVisibleFinding++; |
3173 | - |
3174 | - updatePanelFindings(); |
3175 | - |
3176 | - ftm.fireTableDataChanged(); |
3177 | - findTbl.setRowSelectionInterval(firstVisibleFinding, |
3178 | - firstVisibleFinding); |
3179 | - updateTable(); |
3180 | - } |
3181 | - } |
3182 | - }); |
3183 | - |
3184 | - buttonAddFinding = GUITools.newImageButton(Data.getInstance().getIcon( |
3185 | - "findingAdd_32x32_0.png"), Data.getInstance().getIcon( |
3186 | - "findingAdd_32x32.png")); |
3187 | - buttonAddFinding.setToolTipText(Data.getInstance().getLocaleStr( |
3188 | - "editProtocol.newFinding")); |
3189 | - buttonAddFinding.addActionListener(new ActionListener() { |
3190 | - @Override |
3191 | - public void actionPerformed(ActionEvent e) { |
3192 | - saveEditRefs(); |
3193 | - int listIdLastFinding = findMgmt |
3194 | - .getNumberOfFindings(currentProt) - 1; |
3195 | - |
3196 | - if (!findMgmt.isFindingEmpty(findMgmt.getFindings(currentProt) |
3197 | - .get(listIdLastFinding))) { |
3198 | - Finding newFind = new Finding(); |
3199 | - newFind.setSeverity(sevMgmt.getSeverities().get(0)); |
3200 | - editingFinding = findMgmt.addFinding(newFind, currentProt); |
3201 | - firstVisibleFinding = findMgmt |
3202 | - .getNumberOfFindings(currentProt) |
3203 | - - visibleFindingsCount; |
3204 | - |
3205 | - updatePanelFindings(); |
3206 | - ftm.fireTableDataChanged(); |
3207 | - findTbl.setRowSelectionInterval(firstVisibleFinding, |
3208 | - firstVisibleFinding); |
3209 | - updateTable(); |
3210 | - } |
3211 | - } |
3212 | - }); |
3213 | - |
3214 | - ftm = new FindingsTableModel(currentProt); |
3215 | - findTbl = GUITools.newStandardTable(ftm, false); |
3216 | - findTbl.setRowHeight(36); |
3217 | - ctcr = new ColoredTableCellRenderer(currentProt); |
3218 | - findTbl.getColumnModel().getColumn(0).setCellRenderer(ctcr); |
3219 | - findTbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
3220 | - findTbl.addMouseListener(new MouseListener() { |
3221 | - @Override |
3222 | - public void mouseClicked(MouseEvent e) { |
3223 | - saveEditRefs(); |
3224 | - firstVisibleFinding = findTbl.getSelectedRow(); |
3225 | - updatePanelFindings(); |
3226 | - |
3227 | - ftm.fireTableDataChanged(); |
3228 | - findTbl.setRowSelectionInterval(firstVisibleFinding, |
3229 | - firstVisibleFinding); |
3230 | - |
3231 | - updateTable(); |
3232 | - } |
3233 | - |
3234 | - @Override |
3235 | - public void mouseEntered(MouseEvent e) { |
3236 | - } |
3237 | - |
3238 | - @Override |
3239 | - public void mouseExited(MouseEvent e) { |
3240 | - } |
3241 | - |
3242 | - @Override |
3243 | - public void mousePressed(MouseEvent e) { |
3244 | - } |
3245 | - |
3246 | - @Override |
3247 | - public void mouseReleased(MouseEvent e) { |
3248 | - } |
3249 | - }); |
3250 | - |
3251 | - findScrllPn = new JScrollPane(findTbl); |
3252 | - findScrllPn |
3253 | - .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
3254 | - |
3255 | - labelFindTop.setFont(UI.PROTOCOL_FONT); |
3256 | - labelFindBottom.setFont(UI.PROTOCOL_FONT); |
3257 | - |
3258 | - labelFindTop.setForeground(Color.GRAY); |
3259 | - labelFindBottom.setForeground(Color.GRAY); |
3260 | - |
3261 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, labelFindTop, |
3262 | - 0, 0, 1, 1, 0.0, 0.0, 5, 10, 5, 10, GridBagConstraints.NONE, |
3263 | - GridBagConstraints.WEST); |
3264 | - |
3265 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3266 | - buttonFindScrollUp, 1, 0, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
3267 | - GridBagConstraints.NONE, GridBagConstraints.CENTER); |
3268 | - |
3269 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3270 | - new JSeparator(JSeparator.HORIZONTAL), 0, 1, 3, 1, 1.0, 0.0, 0, |
3271 | - 10, 5, 10, GridBagConstraints.HORIZONTAL, |
3272 | - GridBagConstraints.CENTER); |
3273 | - |
3274 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, panelFindings, |
3275 | - 0, 2, 3, 1, 0.9, 1.0, 5, 5, 5, 5, GridBagConstraints.BOTH, |
3276 | - GridBagConstraints.NORTHWEST); |
3277 | - |
3278 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3279 | - new JSeparator(JSeparator.HORIZONTAL), 0, 3, 3, 1, 1.0, 0.0, 5, |
3280 | - 10, 0, 10, GridBagConstraints.HORIZONTAL, |
3281 | - GridBagConstraints.CENTER); |
3282 | - |
3283 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3284 | - labelFindBottom, 0, 4, 1, 1, 0.0, 0.0, 5, 10, 5, 10, |
3285 | - GridBagConstraints.NONE, GridBagConstraints.WEST); |
3286 | - |
3287 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3288 | - buttonFindScrollDown, 1, 4, 1, 1, 1.0, 0.0, 5, 5, 5, 5, |
3289 | - GridBagConstraints.NONE, GridBagConstraints.CENTER); |
3290 | - |
3291 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, |
3292 | - buttonAddFinding, 2, 4, 1, 1, 0.0, 0.0, 5, 5, 5, 10, |
3293 | - GridBagConstraints.NONE, GridBagConstraints.EAST); |
3294 | - |
3295 | - GUITools.addComponent(tabPanelFindings, gblBaseFindings, findScrllPn, |
3296 | - 3, 0, 1, 5, 0.0, 1.0, 5, 0, 5, 5, GridBagConstraints.BOTH, |
3297 | - GridBagConstraints.NORTHWEST); |
3298 | - } |
3299 | - |
3300 | - /** |
3301 | - * Update panel findings. |
3302 | - */ |
3303 | - public void updatePanelFindings() { |
3304 | - panelFindings.removeAll(); |
3305 | - visibleFList.clear(); |
3306 | - |
3307 | - /* |
3308 | - * Calculate number of shown findings from the window size |
3309 | - */ |
3310 | - visibleFindingsCount = (int) ((panelFindings.getSize().getHeight()) / 270); |
3311 | - |
3312 | - if (visibleFindingsCount < 1) { |
3313 | - visibleFindingsCount = 1; |
3314 | - } |
3315 | - |
3316 | - /* |
3317 | - * Check validity of first visible finding |
3318 | - */ |
3319 | - if (firstVisibleFinding > findMgmt.getNumberOfFindings(currentProt) |
3320 | - - visibleFindingsCount) { |
3321 | - firstVisibleFinding = findMgmt.getNumberOfFindings(currentProt) |
3322 | - - visibleFindingsCount; |
3323 | - } |
3324 | - |
3325 | - if (firstVisibleFinding < 0) { |
3326 | - firstVisibleFinding = 0; |
3327 | - } |
3328 | - |
3329 | - /* |
3330 | - * Update labels at bottom and top |
3331 | - */ |
3332 | - labelFindTop.setText(firstVisibleFinding |
3333 | - + " " |
3334 | - + Data.getInstance() |
3335 | - .getLocaleStr("editProtocol.findingsBefore")); |
3336 | - |
3337 | - labelFindBottom |
3338 | - .setText(findMgmt.getNumberOfFindings(currentProt) |
3339 | - - firstVisibleFinding |
3340 | - - visibleFindingsCount |
3341 | - + " " |
3342 | - + Data.getInstance().getLocaleStr( |
3343 | - "editProtocol.findingsAfter")); |
3344 | - |
3345 | - /* |
3346 | - * If no finding exist |
3347 | - */ |
3348 | - while (findMgmt.getNumberOfFindings(currentProt) < visibleFindingsCount) { |
3349 | - findMgmt.addFinding(new Finding(), currentProt); |
3350 | - } |
3351 | - |
3352 | - int lastVisibleFinding = firstVisibleFinding + visibleFindingsCount; |
3353 | - |
3354 | - if (lastVisibleFinding > findMgmt.getNumberOfFindings(currentProt)) { |
3355 | - lastVisibleFinding = findMgmt.getNumberOfFindings(currentProt) - 1; |
3356 | - } |
3357 | - |
3358 | - for (int i = firstVisibleFinding; i < lastVisibleFinding; i++) { |
3359 | - Finding find = findMgmt.getFindings(currentProt).get(i); |
3360 | - |
3361 | - FindingItem fi = new FindingItem(find, currentProt); |
3362 | - |
3363 | - /* |
3364 | - * Separator |
3365 | - */ |
3366 | - if (i > firstVisibleFinding) { |
3367 | - GUITools.addComponent(panelFindings, gblFindings, |
3368 | - new JSeparator(JSeparator.HORIZONTAL), 0, |
3369 | - 2 * (i - firstVisibleFinding), 1, 1, 1.0, 0.0, 5, 5, 5, |
3370 | - 5, GridBagConstraints.HORIZONTAL, |
3371 | - GridBagConstraints.NORTHWEST); |
3372 | - } |
3373 | - |
3374 | - GUITools |
3375 | - .addComponent(panelFindings, gblFindings, fi, 0, |
3376 | - (2 * (i - firstVisibleFinding)) + 1, 1, 1, 1.0, |
3377 | - 1.0, 5, 5, 5, 5, GridBagConstraints.BOTH, |
3378 | - GridBagConstraints.NORTHWEST); |
3379 | - |
3380 | - visibleFList.add(fi); |
3381 | - } |
3382 | - |
3383 | - updateFocus(); |
3384 | - |
3385 | - /* |
3386 | - * Update buttons |
3387 | - */ |
3388 | - if (firstVisibleFinding == 0) { |
3389 | - buttonFindScrollUp.setEnabled(false); |
3390 | - } else { |
3391 | - buttonFindScrollUp.setEnabled(true); |
3392 | - } |
3393 | - |
3394 | - if (findMgmt.getNumberOfFindings(currentProt) - visibleFindingsCount == firstVisibleFinding) { |
3395 | - buttonFindScrollDown.setEnabled(false); |
3396 | - } else { |
3397 | - buttonFindScrollDown.setEnabled(true); |
3398 | - } |
3399 | - |
3400 | - updateAddFindBttn(); |
3401 | - |
3402 | - tabPanelFindings.revalidate(); |
3403 | - panelFindings.revalidate(); |
3404 | - |
3405 | - tabPanelFindings.repaint(); |
3406 | - panelFindings.repaint(); |
3407 | - |
3408 | - /* |
3409 | - * Fit the size of the scroll pane with the findings |
3410 | - */ |
3411 | - int lastIdLength = Integer.toString( |
3412 | - Application.getInstance().getFindingMgmt().getLastId()) |
3413 | - .length(); |
3414 | - |
3415 | - Dimension dim = new Dimension(34 + (lastIdLength * 12), 100); |
3416 | - |
3417 | - findScrllPn.setMinimumSize(dim); |
3418 | - findScrllPn.setPreferredSize(dim); |
3419 | - } |
3420 | - |
3421 | - /** |
3422 | * Resets the clock. |
3423 | */ |
3424 | public void resetClock() { |
3425 | @@ -1640,25 +1248,6 @@ |
3426 | |
3427 | createHints(); |
3428 | |
3429 | - panelFindings.addComponentListener(new ComponentListener() { |
3430 | - @Override |
3431 | - public void componentHidden(ComponentEvent e) { |
3432 | - } |
3433 | - |
3434 | - @Override |
3435 | - public void componentMoved(ComponentEvent e) { |
3436 | - } |
3437 | - |
3438 | - @Override |
3439 | - public void componentResized(ComponentEvent e) { |
3440 | - updatePanelFindings(); |
3441 | - } |
3442 | - |
3443 | - @Override |
3444 | - public void componentShown(ComponentEvent e) { |
3445 | - } |
3446 | - }); |
3447 | - |
3448 | addWindowListener(new WindowListener() { |
3449 | @Override |
3450 | public void windowActivated(WindowEvent e) { |
3451 | @@ -1687,7 +1276,7 @@ |
3452 | |
3453 | if (option == JOptionPane.YES_OPTION) { |
3454 | new ImageEditorWriteWorker(currentProt).execute(); |
3455 | - |
3456 | + |
3457 | UI.getInstance().getProtocolFrame().setVisible(false); |
3458 | } else if (option == JOptionPane.NO_OPTION) { |
3459 | UI.getInstance().getProtocolFrame().setVisible(false); |
3460 | @@ -1746,25 +1335,26 @@ |
3461 | */ |
3462 | @Override |
3463 | public void update(Observable o, Object arg) { |
3464 | - updateHints(); |
3465 | - updateAddFindBttn(); |
3466 | - |
3467 | - if (protMgmt.isProtocolComplete(currentProt)) { |
3468 | - tbCsvExport.setEnabled(true); |
3469 | - tbPdfExport.setEnabled(true); |
3470 | - tbConfirmProt.setVisible(true); |
3471 | - tbExitProt.setVisible(false); |
3472 | - } else { |
3473 | - tbCsvExport.setEnabled(false); |
3474 | - tbPdfExport.setEnabled(false); |
3475 | - tbConfirmProt.setVisible(false); |
3476 | - tbExitProt.setVisible(true); |
3477 | - } |
3478 | - |
3479 | - if (revMgmt.isReviewConfirmable()) { |
3480 | - recBx.setEnabled(true); |
3481 | - } else { |
3482 | - recBx.setEnabled(false); |
3483 | + if (bodyCreated) { |
3484 | + updateHints(); |
3485 | + |
3486 | + if (protMgmt.isProtocolComplete(currentProt)) { |
3487 | + tbCsvExport.setEnabled(true); |
3488 | + tbPdfExport.setEnabled(true); |
3489 | + tbConfirmProt.setVisible(true); |
3490 | + tbExitProt.setVisible(false); |
3491 | + } else { |
3492 | + tbCsvExport.setEnabled(false); |
3493 | + tbPdfExport.setEnabled(false); |
3494 | + tbConfirmProt.setVisible(false); |
3495 | + tbExitProt.setVisible(true); |
3496 | + } |
3497 | + |
3498 | + if (revMgmt.isReviewConfirmable()) { |
3499 | + recBx.setEnabled(true); |
3500 | + } else { |
3501 | + recBx.setEnabled(false); |
3502 | + } |
3503 | } |
3504 | } |
3505 | |
3506 | @@ -1842,25 +1432,6 @@ |
3507 | return false; |
3508 | } |
3509 | |
3510 | - /** |
3511 | - * Update add find bttn. |
3512 | - */ |
3513 | - public void updateAddFindBttn() { |
3514 | - |
3515 | - boolean isNotComplete = false; |
3516 | - |
3517 | - for (Finding find : findMgmt.getFindings(currentProt)) |
3518 | - if (findMgmt.isFindingNotComplete(find)) |
3519 | - isNotComplete = true; |
3520 | - |
3521 | - if (isNotComplete) { |
3522 | - buttonAddFinding.setEnabled(false); |
3523 | - } else { |
3524 | - buttonAddFinding.setEnabled(true); |
3525 | - } |
3526 | - |
3527 | - } |
3528 | - |
3529 | private long updateTime = System.currentTimeMillis(); |
3530 | private KeyListener updateListener = new KeyListener() { |
3531 | @Override |
3532 | @@ -2173,70 +1744,14 @@ |
3533 | setHints(hints); |
3534 | } |
3535 | |
3536 | - /** |
3537 | - * Update table. |
3538 | - */ |
3539 | - public void updateTable() { |
3540 | - int selRow = findTbl.getSelectedRow(); |
3541 | - |
3542 | - findTbl.scrollRectToVisible(findTbl.getCellRect(selRow, 0, false)); |
3543 | - } |
3544 | - |
3545 | - /** |
3546 | - * Sets the selection row. |
3547 | - */ |
3548 | - public void setSelectionRow() { |
3549 | - findTbl.setRowSelectionInterval(firstVisibleFinding, |
3550 | - firstVisibleFinding); |
3551 | - } |
3552 | - |
3553 | - /** |
3554 | - * Updates the focus of the findings. |
3555 | - */ |
3556 | - public void updateFocus() { |
3557 | - updateFocus(null, null); |
3558 | - } |
3559 | - |
3560 | - /** |
3561 | - * Updates the focus of the findings. |
3562 | - */ |
3563 | - public void updateFocus(Finding focusedFinding, Object eventSource) { |
3564 | - if (eventSource != null && eventSource instanceof Component) { |
3565 | - ((Component) eventSource).requestFocusInWindow(); |
3566 | - } |
3567 | - |
3568 | - if (focusedFinding != null) { |
3569 | - editingFinding = focusedFinding; |
3570 | - } |
3571 | - |
3572 | - for (Component comp : panelFindings.getComponents()) { |
3573 | - if (comp instanceof FindingItem) { |
3574 | - FindingItem fi = ((FindingItem) comp); |
3575 | - |
3576 | - fi.updateFocus(eventSource); |
3577 | - |
3578 | - if (visibleFindingsCount > 1 |
3579 | - && editingFinding != null |
3580 | - && fi.getCurrentFinding().getId() == editingFinding |
3581 | - .getId()) { |
3582 | - fi.setBorder(new MatteBorder(1, 5, 1, 5, new Color(0, 132, |
3583 | - 209))); |
3584 | - fi.setBackground(UI.TABLE_ALT_COLOR); |
3585 | - } else { |
3586 | - fi.setBorder(new EmptyBorder(1, 5, 1, 5)); |
3587 | - fi.setBackground(UIManager.getColor("JPanel.background")); |
3588 | - } |
3589 | - } |
3590 | - } |
3591 | - } |
3592 | - |
3593 | public ImageEditorDialog getImageEditor(File image) { |
3594 | String imagePath = image.getAbsolutePath(); |
3595 | |
3596 | ImageEditorDialog editor = imageEditors.get(imagePath); |
3597 | |
3598 | if (editor == null) { |
3599 | - editor = new ImageEditorDialog(UI.getInstance().getProtocolFrame(), image); |
3600 | + editor = new ImageEditorDialog(UI.getInstance().getProtocolFrame(), |
3601 | + image); |
3602 | |
3603 | imageEditors.put(imagePath, editor); |
3604 | } |
3605 | @@ -2247,11 +1762,5 @@ |
3606 | public Map<String, ImageEditorDialog> getImageEditors() { |
3607 | return imageEditors; |
3608 | } |
3609 | - |
3610 | - private void saveEditRefs(){ |
3611 | - for (FindingItem findI:visibleFList) |
3612 | - if(tabPanelFindings.isVisible()&&findI.isCellEditing()) |
3613 | - findI.saveRef(); |
3614 | - } |
3615 | |
3616 | } |
3617 | |
3618 | === modified file 'src/org/revager/resources/localeStrings_de.properties' |
3619 | --- src/org/revager/resources/localeStrings_de.properties 2010-01-31 17:32:35 +0000 |
3620 | +++ src/org/revager/resources/localeStrings_de.properties 2010-05-27 20:33:41 +0000 |
3621 | @@ -937,3 +937,20 @@ |
3622 | message.csvNoFindingsExist=Es existieren keine Befunde zum Exportieren in eine CSV-Datei. |
3623 | message.invitationZipFileWriteFailed=Das Einladungspaket konnte nicht als ZIP-Datei gespeichert werden. |
3624 | message.invitationDirWriteFailed=Das Einladungspaket konnte nicht als Verzeichnis gespeichert werden. |
3625 | + |
3626 | + |
3627 | + |
3628 | +###################################### |
3629 | +## Findings List in Protocol Window ## |
3630 | +###################################### |
3631 | + |
3632 | +findingsList.pushUp=Befund nach oben verschieben |
3633 | +findingsList.pushDown=Befund nach unten verschieben |
3634 | +findingsList.pushTop=Als ersten Befund in der Liste positionieren |
3635 | +findingsList.pushBottom=Als letzten Befund in der Liste positionieren |
3636 | +findingsList.remove=Befund entfernen |
3637 | +findingsList.close=Bearbeitungsansicht des Befundes schließen |
3638 | +findingsList.aspects=Prüfaspekt(e) |
3639 | +findingsList.references=Referenz(en) |
3640 | +findingsList.files=Datei(en) |
3641 | +findingsList.confirmRemoval=Sind Sie sicher den gewählten Befund dauerhaft zu löschen? |
3642 | \ No newline at end of file |
3643 | |
3644 | === modified file 'src/org/revager/resources/localeStrings_en.properties' |
3645 | --- src/org/revager/resources/localeStrings_en.properties 2010-01-31 17:32:35 +0000 |
3646 | +++ src/org/revager/resources/localeStrings_en.properties 2010-05-27 20:33:41 +0000 |
3647 | @@ -931,3 +931,19 @@ |
3648 | message.invitationZipFileWriteFailed=Couldn't save invitations as ZIP-file. |
3649 | message.invitationDirWriteFailed=Couldn't save invitation as directory. |
3650 | |
3651 | + |
3652 | + |
3653 | +###################################### |
3654 | +## Findings List in Protocol Window ## |
3655 | +###################################### |
3656 | + |
3657 | +findingsList.pushUp=Push up finding |
3658 | +findingsList.pushDown=Push down finding |
3659 | +findingsList.pushTop=Push finding to top |
3660 | +findingsList.pushBottom=Push finding to bottom |
3661 | +findingsList.remove=Remove this finding |
3662 | +findingsList.close=Close edit view of this finding |
3663 | +findingsList.aspects=Aspect(s) |
3664 | +findingsList.references=Reference(s) |
3665 | +findingsList.files=File(s) |
3666 | +findingsList.confirmRemoval=Are you sure you want to remove the selected finding permanently? |
3667 | \ No newline at end of file |