neos team mailing list archive
-
neos team
-
Mailing list archive
-
Message #00532
[Merge] lp:~neos/revager/better-findings-list into lp:revager
Davide Casciato has proposed merging lp:~neos/revager/better-findings-list into lp:revager.
Requested reviews:
Team N.E.O.S. (neos)
Related bugs:
#494623 (FR) Show the last findings with all details, not just their number
https://bugs.launchpad.net/bugs/494623
--
https://code.launchpad.net/~neos/revager/better-findings-list/+merge/26243
Your team Team N.E.O.S. is requested to review the proposed merge of lp:~neos/revager/better-findings-list into lp:revager.
=== modified file 'src/org/revager/gui/actions/OpenProtocolFrameAction.java'
--- src/org/revager/gui/actions/OpenProtocolFrameAction.java 2010-01-31 17:32:35 +0000
+++ src/org/revager/gui/actions/OpenProtocolFrameAction.java 2010-05-27 20:33:41 +0000
@@ -24,11 +24,13 @@
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
+import javax.swing.SwingWorker;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import org.revager.app.Application;
import org.revager.app.FindingManagement;
+import org.revager.app.SeverityManagement;
import org.revager.app.model.Data;
import org.revager.app.model.schema.Finding;
import org.revager.app.model.schema.Meeting;
@@ -37,7 +39,6 @@
import org.revager.gui.helpers.TreeMeeting;
import org.revager.gui.helpers.TreeProtocol;
-
/**
* The Class OpenProtocolFrameAction.
*/
@@ -46,6 +47,8 @@
private FindingManagement findingMgmt = Application.getInstance()
.getFindingMgmt();
+ private SeverityManagement sevMgmt = Application.getInstance()
+ .getSeverityMgmt();
/**
* Instantiates a new open protocol frame action.
@@ -66,39 +69,62 @@
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
- public void actionPerformed(ActionEvent arg0) {
- Meeting editMeet;
- Protocol currentProt;
-
- TreePath path = UI.getInstance().getMainFrame().getMeetingsTree()
- .getSelectionPath();
-
- if (path.getPathCount() == 3)
- editMeet = ((TreeProtocol) ((DefaultMutableTreeNode) path
- .getLastPathComponent()).getUserObject()).getMeeting();
- else
- editMeet = ((TreeMeeting) ((DefaultMutableTreeNode) path
- .getLastPathComponent()).getUserObject()).getMeeting();
-
- currentProt = Application.getInstance().getProtocolMgmt().getProtocol(
- editMeet);
- if (currentProt == null) {
- currentProt = new Protocol();
- currentProt.setDate(editMeet.getPlannedDate());
- currentProt.setLocation(editMeet.getPlannedLocation());
- currentProt.setStart(editMeet.getPlannedStart());
- currentProt.setEnd(editMeet.getPlannedEnd());
- currentProt.setComments("");
- findingMgmt.addFinding(new Finding(), currentProt);
+ public void actionPerformed(ActionEvent e) {
+ new OpenProtocolFrameWorker().execute();
+ }
+
+ private class OpenProtocolFrameWorker extends SwingWorker<Void, Void> {
+ @Override
+ protected Void doInBackground() throws Exception {
+ try {
+ UI.getInstance().getMainFrame().switchToProgressMode();
+
+ Meeting editMeet;
+ Protocol currentProt;
+
+ TreePath path = UI.getInstance().getMainFrame()
+ .getMeetingsTree().getSelectionPath();
+
+ if (path.getPathCount() == 3)
+ editMeet = ((TreeProtocol) ((DefaultMutableTreeNode) path
+ .getLastPathComponent()).getUserObject())
+ .getMeeting();
+ else
+ editMeet = ((TreeMeeting) ((DefaultMutableTreeNode) path
+ .getLastPathComponent()).getUserObject())
+ .getMeeting();
+
+ currentProt = Application.getInstance().getProtocolMgmt()
+ .getProtocol(editMeet);
+ if (currentProt == null) {
+ currentProt = new Protocol();
+ currentProt.setDate(editMeet.getPlannedDate());
+ currentProt.setLocation(editMeet.getPlannedLocation());
+ currentProt.setStart(editMeet.getPlannedStart());
+ currentProt.setEnd(editMeet.getPlannedEnd());
+ currentProt.setComments("");
+
+ Finding newFind = new Finding();
+ newFind.setSeverity(sevMgmt.getSeverities().get(0));
+
+ findingMgmt.addFinding(newFind, currentProt);
+ }
+
+ Application.getInstance().getProtocolMgmt().setProtocol(
+ currentProt, editMeet);
+
+ UI.getInstance().getProtocolFrame().resetClock();
+ UI.getInstance().getProtocolFrame().setMeeting(editMeet);
+ UI.getInstance().getProtocolFrame().setVisible(true);
+ UI.getInstance().getMainFrame().updateMeetingsTree();
+
+ UI.getInstance().getMainFrame().switchToEditMode();
+ } catch (Exception e) {
+ UI.getInstance().getMainFrame().switchToEditMode();
+ }
+
+ return null;
}
- Application.getInstance().getProtocolMgmt().setProtocol(currentProt,
- editMeet);
-
- UI.getInstance().getProtocolFrame().resetClock();
- UI.getInstance().getProtocolFrame().setMeeting(editMeet);
- UI.getInstance().getProtocolFrame().setVisible(true);
- UI.getInstance().getMainFrame().updateMeetingsTree();
-
}
}
=== added file 'src/org/revager/gui/icons/closeFinding_25x25.png'
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
=== added file 'src/org/revager/gui/icons/closeFinding_25x25_0.png'
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
=== added file 'src/org/revager/gui/icons/delete_25x25.png'
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
=== added file 'src/org/revager/gui/icons/delete_25x25_0.png'
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
=== added file 'src/org/revager/gui/icons/paste_25x25.png'
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
=== added file 'src/org/revager/gui/icons/paste_25x25_0.png'
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
=== renamed file 'src/org/revager/gui/models/FindExRefTableModel.java' => 'src/org/revager/gui/models/FindExtRefTableModel.java'
--- src/org/revager/gui/models/FindExRefTableModel.java 2010-01-31 17:32:35 +0000
+++ src/org/revager/gui/models/FindExtRefTableModel.java 2010-05-27 20:33:41 +0000
@@ -30,7 +30,7 @@
* The Class FindExRefTableModel.
*/
@SuppressWarnings("serial")
-public class FindExRefTableModel extends AbstractTableModel {
+public class FindExtRefTableModel extends AbstractTableModel {
private FindingManagement findingMgmt = Application.getInstance()
.getFindingMgmt();
@@ -42,7 +42,7 @@
* @param currentFinding
* the current finding
*/
- public FindExRefTableModel(Finding currentFinding) {
+ public FindExtRefTableModel(Finding currentFinding) {
localFind = currentFinding;
}
=== removed file 'src/org/revager/gui/protocol/ColoredTableCellRenderer.java'
--- src/org/revager/gui/protocol/ColoredTableCellRenderer.java 2010-01-31 17:32:35 +0000
+++ src/org/revager/gui/protocol/ColoredTableCellRenderer.java 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright 2009 Davide Casciato, Sandra Reich, Johannes Wettinger
- *
- * This file is part of Resi.
- *
- * Resi is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Resi is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Resi. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.revager.gui.protocol;
-
-import java.awt.Component;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableCellRenderer;
-
-import org.revager.app.Application;
-import org.revager.app.FindingManagement;
-import org.revager.app.model.schema.Finding;
-import org.revager.app.model.schema.Protocol;
-import org.revager.gui.UI;
-import org.revager.tools.GUITools;
-
-
-/**
- * The Class ColoredTableCellRenderer.
- */
-@SuppressWarnings("serial")
-public class ColoredTableCellRenderer extends DefaultTableCellRenderer {
- FindingManagement findMgmt = Application.getInstance().getFindingMgmt();
- private Protocol prot;
-
- /**
- * Instantiates a new colored table cell renderer.
- *
- * @param currentProt
- * the current prot
- */
- public ColoredTableCellRenderer(Protocol currentProt) {
- prot = currentProt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax
- * .swing.JTable, java.lang.Object, boolean, boolean, int, int)
- */
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- JPanel localPnl = new JPanel();
-
- JLabel label = new JLabel(String.valueOf(value));
- label.setFont(UI.PROTOCOL_FONT);
- label.setForeground(UI.DARK_BLUE_COLOR);
-
- localPnl.add(label);
-
- if (findMgmt.getFindings(prot).get(row).getDescription().trim().equals(
- "")) {
- localPnl.setBorder(BorderFactory.createLineBorder(UI.MARKED_COLOR,
- 2));
- } else {
- localPnl.setBorder(UI.STANDARD_BORDER);
- }
-
- // if (isSelected)
- // localPnl.setBackground(UI.TABLE_SELECTION_COLOR);
- // else
- // localPnl.setBackground(null);
-
- int fVF = UI.getInstance().getProtocolFrame().getFirstVisibleFinding();
- int lVF = fVF
- + UI.getInstance().getProtocolFrame().getVisibleFindingsCount()
- - 1;
- if (row >= fVF && row <= lVF) {
- localPnl.setBackground(UI.BLUE_BACKGROUND_COLOR);
- } else {
- localPnl.setBackground(null);
- }
-
- Finding find = Application.getInstance().getFindingMgmt().getFinding(
- (Integer) value, prot);
-
- if (find != null) {
- String tip = GUITools.getTextAsHtml("<font size=\"5\"><b>("
- + find.getId() + ") " + find.getSeverity() + "</b>"
- + "\n\n" + find.getDescription() + "</font>");
-
- setToolTipText(tip);
- }
-
- return localPnl;
- }
-
-}
=== removed file 'src/org/revager/gui/protocol/FindingItem.java'
--- src/org/revager/gui/protocol/FindingItem.java 2010-01-31 17:32:35 +0000
+++ src/org/revager/gui/protocol/FindingItem.java 1970-01-01 00:00:00 +0000
@@ -1,1047 +0,0 @@
-/*
- * Copyright 2009 Davide Casciato, Sandra Reich, Johannes Wettinger
- *
- * This file is part of Resi.
- *
- * Resi is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Resi is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Resi. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.revager.gui.protocol;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Desktop;
-import java.awt.Font;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Image;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.io.File;
-import java.util.List;
-import java.util.Observable;
-import java.util.Observer;
-
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.SwingWorker;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.MatteBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-
-import org.revager.app.Application;
-import org.revager.app.FindingManagement;
-import org.revager.app.ResiFileFilter;
-import org.revager.app.SeverityManagement;
-import org.revager.app.model.Data;
-import org.revager.app.model.DataException;
-import org.revager.app.model.ResiData;
-import org.revager.app.model.appdata.AppSettingKey;
-import org.revager.app.model.appdata.AppSettingValue;
-import org.revager.app.model.schema.Aspect;
-import org.revager.app.model.schema.Finding;
-import org.revager.app.model.schema.Protocol;
-import org.revager.gui.UI;
-import org.revager.gui.helpers.DefaultTableHeaderCellRenderer;
-import org.revager.gui.helpers.FileChooser;
-import org.revager.gui.models.FindAspTableModel;
-import org.revager.gui.models.FindExRefTableModel;
-import org.revager.gui.models.FindRefTableModel;
-import org.revager.gui.protocol.AddAspToFindPopupWindow.ButtonClicked;
-import org.revager.tools.AppTools;
-import org.revager.tools.GUITools;
-
-
-/**
- * The Class FindingItem.
- */
-@SuppressWarnings("serial")
-public class FindingItem extends JPanel implements Observer {
-
- private FindingManagement findMgmt = Application.getInstance()
- .getFindingMgmt();
-
- private JComboBox sevBx;
- private JTextArea descTxtArea;
-
- // private JLabel sevLbl = new JLabel(Data.getInstance().getLocaleStr(
- // "editProtocol.finding.sev"));
- // private JLabel descLbl = new JLabel(Data.getInstance().getLocaleStr(
- // "editProtocol.finding.desc"));
- private JLabel idLbl;
-
- private GridBagLayout gbl = new GridBagLayout();
- private GridLayout gl = new GridLayout(3, 1);
-
- private FindRefTableModel frtm;
- private FindExRefTableModel fertm;
- private FindAspTableModel fatm;
-
- private JTable refTbl;
- private JTable exRefTbl;
- private JTable aspTbl;
-
- private JScrollPane descScrllPn;
- private JScrollPane refScrllPn;
- private JScrollPane exRefScrllPn;
- private JScrollPane aspScrllPn;
-
- private JButton addRefBttn;
- private JButton ediRefBttn;
- private JButton remRefBttn;
-
- private JButton addExRefBttn;
- private JButton remExRefBttn;
-
- private JButton addAspBttn;
- private JButton remAspBttn;
-
- private JButton pushUpBttn;
- private JButton pushDownBttn;
-
- private JButton remFindBttn;
-
- private JButton pasteExRefBttn;
-
- private Finding currentFinding;
- private Protocol currentProtocol;
-
- private ImageIcon addIcon = Data.getInstance().getIcon("add_25x25_0.png");
- private ImageIcon remIcon = Data.getInstance()
- .getIcon("remove_25x25_0.png");
- private ImageIcon editIcon = Data.getInstance().getIcon("edit_25x25_0.png");
- private ImageIcon pushUpIcon = Data.getInstance().getIcon(
- "upArrow_25x25_0.png");
- private ImageIcon pushDownIcon = Data.getInstance().getIcon(
- "downArrow_25x25_0.png");
- private ImageIcon remFindIcon = Data.getInstance().getIcon(
- "clear_22x22_0.png");
- private ImageIcon showExRefIcon = Data.getInstance().getIcon(
- "show_25x25_0.png");
-
- private ImageIcon rolloverAddIcon = Data.getInstance().getIcon(
- "add_25x25.png");
- private ImageIcon rolloverRemIcon = Data.getInstance().getIcon(
- "remove_25x25.png");
- private ImageIcon rolloverEditIcon = Data.getInstance().getIcon(
- "edit_25x25.png");
- private ImageIcon rolloverPushUpIcon = Data.getInstance().getIcon(
- "upArrow_25x25.png");
- private ImageIcon rolloverPushDownIcon = Data.getInstance().getIcon(
- "downArrow_25x25.png");
- private ImageIcon rolloverRemFindIcon = Data.getInstance().getIcon(
- "clear_22x22.png");
- private ImageIcon rolloverShowExRefIcon = Data.getInstance().getIcon(
- "show_25x25.png");
-
- private FindingManagement findingMgmt = Application.getInstance()
- .getFindingMgmt();
- private SeverityManagement sevMgmt = Application.getInstance()
- .getSeverityMgmt();
- private ResiData resiData = Data.getInstance().getResiData();
-
- private FocusListener focusListener = new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- e.getSource());
-
- updateTableButtons();
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- updateTableButtons();
- }
- };
-
- /**
- * Instantiates a new finding item.
- *
- * @param find
- * the find
- * @param prot
- * the prot
- */
- public FindingItem(Finding find, Protocol prot) {
- super();
-
- Data.getInstance().getResiData().addObserver(this);
-
- currentFinding = find;
-
- currentProtocol = prot;
-
- setLayout(gbl);
- String nr = Data.getInstance().getLocaleStr(
- "editProtocol.finding.number")
- + " ";
- idLbl = new JLabel(nr.concat(currentFinding.getId().toString()));
- idLbl.setFont(UI.PROTOCOL_TITLE_FONT);
- idLbl.setForeground(Color.DARK_GRAY);
-
- /*
- * creating buttons and their panels
- */
- JPanel refBttnPnl = new JPanel(gl);
- JPanel exRefBttnPnl = new JPanel(gl);
- JPanel aspBttnPnl = new JPanel(gl);
-
- refBttnPnl.setOpaque(false);
- exRefBttnPnl.setOpaque(false);
- aspBttnPnl.setOpaque(false);
-
- /*
- * creating refButtons and adding them to their panel
- */
-
- addRefBttn = GUITools.newImageButton(addIcon, rolloverAddIcon);
- addRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- refTbl);
-
- if (refTbl.getCellEditor() != null) {
- refTbl.getCellEditor().stopCellEditing();
- }
-
- String ref = Data.getInstance().getLocaleStr(
- "editProtocol.finding.newRef");
- findingMgmt.addReference(ref, currentFinding);
- frtm.fireTableDataChanged();
-
- int row = refTbl.getRowCount() - 1;
-
- refTbl.scrollRectToVisible(refTbl.getCellRect(row, 0, false));
- refTbl.editCellAt(row, 0);
- }
- });
-
- remRefBttn = GUITools.newImageButton(remIcon, rolloverRemIcon);
- remRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int selRow = refTbl.getSelectedRow();
-
- if (refTbl.getEditingRow() != -1) {
- selRow = refTbl.getEditingRow();
-
- refTbl.getCellEditor().stopCellEditing();
- }
-
- if (selRow != -1) {
- String ref = findingMgmt.getReferences(currentFinding).get(
- selRow);
- findingMgmt.removeReference(ref, currentFinding);
- frtm.fireTableDataChanged();
- }
-
- updateTableButtons();
- }
- });
-
- ediRefBttn = GUITools.newImageButton(editIcon, rolloverEditIcon);
- ediRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int selRow = refTbl.getSelectedRow();
- if (selRow != -1) {
- refTbl.editCellAt(selRow, 0);
- frtm.fireTableDataChanged();
- }
- }
- });
-
- addRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.addRef"));
- remRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.remRef"));
- ediRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.ediRef"));
-
- refBttnPnl.add(addRefBttn);
- refBttnPnl.add(remRefBttn);
- refBttnPnl.add(ediRefBttn);
-
- /*
- * creating exRefButton and adding them to their panels
- */
-
- addExRefBttn = GUITools.newImageButton(addIcon, rolloverAddIcon);
- addExRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- final ProtocolFrame protFrame = UI.getInstance()
- .getProtocolFrame();
-
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- exRefTbl);
-
- SwingWorker<Void, Void> addExtRefWorker = new SwingWorker<Void, Void>() {
- @Override
- protected Void doInBackground() throws Exception {
- FileChooser fileChooser = UI.getInstance()
- .getFileChooser();
-
- fileChooser.setFile(null);
-
- if (fileChooser.showDialog(UI.getInstance()
- .getEditProductDialog(),
- FileChooser.MODE_OPEN_FILE,
- ResiFileFilter.TYPE_ALL) == FileChooser.SELECTED_APPROVE) {
-
- protFrame.switchToProgressMode();
-
- File file = fileChooser.getFile();
- findingMgmt.addExtReference(file, currentFinding);
- fertm.fireTableDataChanged();
-
- Thread.sleep(200);
-
- GUITools.scrollToBottom(exRefScrllPn);
-
- updateTableButtons();
- }
-
- protFrame.switchToEditMode();
-
- return null;
- }
- };
-
- addExtRefWorker.execute();
- }
- });
-
- remExRefBttn = GUITools.newImageButton(remIcon, rolloverRemIcon);
- remExRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int selRow = exRefTbl.getSelectedRow();
- if (selRow != -1) {
- File file = findingMgmt.getExtReferences(currentFinding)
- .get(selRow);
- findingMgmt.removeExtReference(file, currentFinding);
- fertm.fireTableDataChanged();
- updateTableButtons();
- }
- }
- });
-
- /*
- *
- * creating show external reference button
- */
- pasteExRefBttn = GUITools.newImageButton(showExRefIcon,
- rolloverShowExRefIcon);
- pasteExRefBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- exRefTbl);
-
- SwingWorker<Void, Void> addImgFromCbWorker = new SwingWorker<Void, Void>() {
- @Override
- protected Void doInBackground() throws Exception {
- UI
- .getInstance()
- .getProtocolFrame()
- .switchToProgressMode(
- Data
- .getInstance()
- .getLocaleStr(
- "editProtocol.message.imgLoading"));
-
- Image img = AppTools.getImageFromClipboard();
-
- if (img == null) {
- JOptionPane
- .showMessageDialog(
- UI.getInstance().getProtocolFrame(),
- GUITools
- .getMessagePane(Data
- .getInstance()
- .getLocaleStr(
- "editProtocol.message.noImgInCb")),
- Data.getInstance().getLocaleStr(
- "info"),
- JOptionPane.INFORMATION_MESSAGE);
- } else {
- Image scalImg = img.getScaledInstance(-1, 250,
- Image.SCALE_SMOOTH);
-
- JLabel labelImg = new JLabel(new ImageIcon(scalImg));
- labelImg.setBorder(new CompoundBorder(
- new EmptyBorder(0, 0, 15, 0),
- new MatteBorder(1, 1, 1, 1,
- UI.SEPARATOR_COLOR)));
-
- JTextField inputField = new JTextField();
- inputField.setText(Data.getInstance().getLocaleStr(
- "editProtocol.finding.stdFileName"));
-
- JPanel messagePane = new JPanel(new BorderLayout());
- messagePane.add(labelImg, BorderLayout.NORTH);
- messagePane
- .add(
- new JLabel(
- Data
- .getInstance()
- .getLocaleStr(
- "editProtocol.message.askForFileName")),
- BorderLayout.CENTER);
- messagePane.add(inputField, BorderLayout.SOUTH);
-
- // String fileName = (String) JOptionPane
- // .showInputDialog(
- // UI.getInstance().getProtocolFrame(),
- // messagePane,
- // Data.getInstance().getLocaleStr(
- // "confirm"),
- // JOptionPane.DEFAULT_OPTION,
- // null,
- // null,
- // Data
- // .getInstance()
- // .getLocaleStr(
- // "editProtocol.finding.stdFileName"));
-
- Object[] options = {
- Data.getInstance().getLocaleStr(
- "findingsItem.save"),
- Data.getInstance().getLocaleStr(
- "findingsItem.edit"),
- Data.getInstance().getLocaleStr(
- "findingsItem.abort") };
-
- int action = JOptionPane.showOptionDialog(UI
- .getInstance().getProtocolFrame(),
- messagePane, Data.getInstance()
- .getLocaleStr("confirm"),
- JOptionPane.YES_NO_CANCEL_OPTION,
- JOptionPane.PLAIN_MESSAGE, null, options,
- options[0]);
-
- String fileName = null;
-
- if (action != 2) {
- fileName = inputField.getText();
- }
-
- if (fileName != null && !fileName.trim().equals("")) {
- findingMgmt.addExtReference(img, fileName,
- currentFinding);
-
- fertm.fireTableDataChanged();
-
- updateTableButtons();
- }
-
- if (action == 1) {
- int numberOfExtRefs = findingMgmt
- .getExtReferences(currentFinding)
- .size();
-
- File extRef = findingMgmt.getExtReferences(
- currentFinding)
- .get(numberOfExtRefs - 1);
-
- UI.getInstance().getProtocolFrame()
- .getImageEditor(extRef)
- .setVisible(true);
- }
- }
-
- UI.getInstance().getProtocolFrame().switchToEditMode();
-
- return null;
- }
- };
-
- addImgFromCbWorker.execute();
- }
- });
-
- addExRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.addExRef"));
- remExRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.remExRef"));
- pasteExRefBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.pasteExRef"));
-
- exRefBttnPnl.add(addExRefBttn);
- exRefBttnPnl.add(remExRefBttn);
- exRefBttnPnl.add(pasteExRefBttn);
-
- /*
- * creating aspButtons and adding them to their panel
- */
- addAspBttn = GUITools.newImageButton(addIcon, rolloverAddIcon);
- addAspBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- aspTbl);
-
- AddAspToFindPopupWindow popup = new AddAspToFindPopupWindow(UI
- .getInstance().getProtocolFrame());
-
- popup.setVisible(true);
-
- if (popup.getButtonClicked() == ButtonClicked.OK) {
- List<Aspect> aspList = popup.getSelAspList();
-
- for (Aspect asp : aspList) {
- findingMgmt.addAspect(asp, currentFinding);
- }
-
- fatm.fireTableDataChanged();
-
- GUITools.scrollToBottom(aspScrllPn);
- }
-
- updateTableButtons();
- }
- });
-
- remAspBttn = GUITools.newImageButton(remIcon, rolloverRemIcon);
- remAspBttn.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- int selRow = aspTbl.getSelectedRow();
- if (selRow != -1) {
- String asp = findingMgmt.getAspects(currentFinding).get(
- selRow);
- findingMgmt.removeAspect(asp, currentFinding);
- fatm.fireTableDataChanged();
- }
- updateTableButtons();
- }
- });
-
- addAspBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.addAsp"));
- remAspBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.remAsp"));
-
- aspBttnPnl.add(addAspBttn);
- aspBttnPnl.add(remAspBttn);
-
- /*
- *
- * creating pushbuttons;
- */
- pushUpBttn = GUITools.newImageButton(pushUpIcon, rolloverPushUpIcon);
- pushUpBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.pushUp"));
- pushUpBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- null);
-
- findingMgmt.pushUpFinding(currentFinding, currentProtocol);
- int index = UI.getInstance().getProtocolFrame()
- .getFirstVisibleFinding();
- UI.getInstance().getProtocolFrame().setFirstVisibleFinding(
- index - 1);
- UI.getInstance().getProtocolFrame().updatePanelFindings();
- UI.getInstance().getProtocolFrame().getFtm()
- .fireTableDataChanged();
- UI.getInstance().getProtocolFrame().setSelectionRow();
- UI.getInstance().getProtocolFrame().updateTable();
- }
- });
-
- pushDownBttn = GUITools.newImageButton(pushDownIcon,
- rolloverPushDownIcon);
- pushDownBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.pushDown"));
- pushDownBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UI.getInstance().getProtocolFrame().updateFocus(currentFinding,
- null);
-
- findingMgmt.pushDownFinding(currentFinding, currentProtocol);
- int index = UI.getInstance().getProtocolFrame()
- .getFirstVisibleFinding();
- UI.getInstance().getProtocolFrame().setFirstVisibleFinding(
- index + 1);
- UI.getInstance().getProtocolFrame().updatePanelFindings();
-
- UI.getInstance().getProtocolFrame().getFtm()
- .fireTableDataChanged();
- UI.getInstance().getProtocolFrame().setSelectionRow();
- UI.getInstance().getProtocolFrame().updateTable();
- }
- });
-
- /*
- *
- * creating remove finding button
- */
- remFindBttn = GUITools.newImageButton(remFindIcon, rolloverRemFindIcon);
- remFindBttn.setToolTipText(Data.getInstance().getLocaleStr(
- "findingsItem.delFind"));
- remFindBttn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- findingMgmt.removeFinding(currentFinding, currentProtocol);
- UI.getInstance().getProtocolFrame().updatePanelFindings();
-
- UI.getInstance().getProtocolFrame().getFtm()
- .fireTableDataChanged();
- UI.getInstance().getProtocolFrame().setSelectionRow();
- UI.getInstance().getProtocolFrame().updateTable();
- }
- });
-
- updateFindBttns();
-
- /*
- *
- * creating and setting desc,ref,exRef,asp,frtm,fertm,fatm
- */
-
- descTxtArea = new JTextArea(currentFinding.getDescription());
-
- descScrllPn = GUITools.setIntoScrllPn(descTxtArea);
- GUITools.scrollToTop(descScrllPn);
-
- descTxtArea.addFocusListener(focusListener);
- descTxtArea.setFont(UI.PROTOCOL_FONT);
- descTxtArea.addKeyListener(new KeyListener() {
- @Override
- public void keyPressed(KeyEvent e) {
- Object evSrc = e.getSource();
-
- if (evSrc instanceof JTextArea
- && e.getKeyCode() == KeyEvent.VK_TAB) {
- JTextArea txtArea = (JTextArea) evSrc;
-
- if (e.getModifiers() > 0) {
- txtArea.transferFocusBackward();
- } else {
- txtArea.transferFocus();
- e.consume();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- boolean mark = false;
-
- try {
- if (Data.getInstance().getAppData().getSettingValue(
- AppSettingKey.APP_HIGHLIGHT_FIELDS) == AppSettingValue.TRUE) {
- mark = true;
- }
- } catch (DataException exc) {
- mark = true;
- }
-
- if (descTxtArea.getText().trim().equals("") && mark) {
- descScrllPn.setBorder(UI.MARKED_BORDER);
- } else {
- descScrllPn.setBorder(UI.STANDARD_BORDER);
- }
-
- currentFinding.setDescription(descTxtArea.getText());
- UI.getInstance().getProtocolFrame().getFtm()
- .fireTableDataChanged();
- resiData.fireDataChanged();
- UI.getInstance().getProtocolFrame().setSelectionRow();
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
- });
-
- for (KeyListener kl : descTxtArea.getKeyListeners()) {
- kl.keyReleased(null);
- }
-
- /*
- * disabeling buttons
- */
- remAspBttn.setEnabled(false);
- remExRefBttn.setEnabled(false);
- remRefBttn.setEnabled(false);
-
- ediRefBttn.setEnabled(false);
-
- /*
- * creating table models
- */
- fatm = new FindAspTableModel(currentFinding);
- frtm = new FindRefTableModel(currentFinding);
- fertm = new FindExRefTableModel(currentFinding);
-
- DefaultTableCellRenderer cellRend = new DefaultTableCellRenderer() {
- @Override
- public Font getFont() {
- return UI.PROTOCOL_FONT;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
- int row, int column) {
- setToolTipText(GUITools.getTextAsHtml("<font size=\"5\">"
- + (String) value + "</font>"));
-
- return super.getTableCellRendererComponent(table, value,
- isSelected, hasFocus, row, column);
- }
- };
-
- DefaultTableHeaderCellRenderer headRend = new DefaultTableHeaderCellRenderer() {
- @Override
- public Font getFont() {
- return UI.PROTOCOL_FONT;
- }
- };
-
- aspTbl = GUITools.newStandardTable(fatm, true);
- refTbl = GUITools.newStandardTable(frtm, true);
- exRefTbl = GUITools.newStandardTable(fertm, true);
-
- aspTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend);
- refTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend);
- exRefTbl.getColumnModel().getColumn(0).setHeaderRenderer(headRend);
-
- aspTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend);
- refTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend);
- exRefTbl.getColumnModel().getColumn(0).setCellRenderer(cellRend);
-
- aspTbl.setRowHeight(29);
- refTbl.setRowHeight(29);
- exRefTbl.setRowHeight(29);
-
- aspTbl.addFocusListener(focusListener);
- refTbl.addFocusListener(focusListener);
- exRefTbl.addFocusListener(focusListener);
-
- aspTbl.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(MouseEvent e) {
- updateTableButtons();
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- });
-
- refTbl.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(MouseEvent e) {
- updateTableButtons();
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- });
-
- exRefTbl.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(MouseEvent e) {
- updateTableButtons();
-
- if (e.getClickCount() == 2) {
- int selRow = exRefTbl.getSelectedRow();
-
- if (selRow != -1) {
- File ref = findMgmt.getExtReferences(currentFinding)
- .get(exRefTbl.getSelectedRow());
-
- if (AppTools.isReadableWritableImageFile(ref)) {
- UI.getInstance().getProtocolFrame().getImageEditor(
- ref).setVisible(true);
- } else {
- try {
- Desktop.getDesktop().open(ref);
- } catch (Exception exc) {
- JOptionPane.showMessageDialog(UI.getInstance()
- .getProtocolFrame(), GUITools
- .getMessagePane(exc.getMessage()), Data
- .getInstance().getLocaleStr("error"),
- JOptionPane.ERROR_MESSAGE);
- }
- }
- }
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- });
-
- aspScrllPn = new JScrollPane(aspTbl);
- refScrllPn = new JScrollPane(refTbl);
- exRefScrllPn = new JScrollPane(exRefTbl);
-
- aspScrllPn.getViewport().setBackground(Color.WHITE);
- refScrllPn.getViewport().setBackground(Color.WHITE);
- exRefScrllPn.getViewport().setBackground(Color.WHITE);
-
- sevBx = new JComboBox();
- sevBx.setFont(UI.PROTOCOL_FONT_BOLD);
-
- for (String sev : sevMgmt.getSeverities()) {
- sevBx.addItem(sev);
- }
-
- sevBx.addFocusListener(focusListener);
-
- sevBx.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- currentFinding.setSeverity(sevBx.getSelectedItem()
- .toString());
- resiData.fireDataChanged();
- }
- }
- });
- sevBx.setSelectedItem(currentFinding.getSeverity());
-
- /*
- * adding components to the content panel
- */
- GUITools.addComponent(this, gbl, idLbl, 0, 0, 1, 1, 0.0, 0.0, 5, 10, 5,
- 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
- GUITools.addComponent(this, gbl, remFindBttn, 1, 0, 1, 1, 0.0, 0.0, 5,
- 15, 5, 3, GridBagConstraints.NONE, GridBagConstraints.WEST);
- GUITools.addComponent(this, gbl, pushUpBttn, 2, 0, 1, 1, 0.0, 0.0, 5,
- 5, 5, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
- GUITools.addComponent(this, gbl, pushDownBttn, 3, 0, 1, 1, 0.0, 0.0, 5,
- 5, 5, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
-
- // GUITools.addComponent(this, gbl, descLbl, 0, 1, 5, 1, 0, 0, 15, 10,
- // 0,
- // 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
- GUITools
- .addComponent(this, gbl, descScrllPn, 0, 2, 5, 3, 1.0, 1.0, 5,
- 10, 0, 0, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
-
- GUITools.addComponent(this, gbl, refScrllPn, 0, 5, 5, 1, 1.0, 1.0, 5,
- 10, 10, 0, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
- GUITools.addComponent(this, gbl, refBttnPnl, 5, 5, 1, 1, 0, 0, 5, 10,
- 20, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
-
- // GUITools.addComponent(this, gbl, sevLbl, 6, 1, 1, 1, 0, 0, 15, 30, 0,
- // 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
- GUITools.addComponent(this, gbl, sevBx, 6, 2, 1, 1, 1.0, 0, 5, 30, 0,
- 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
-
- GUITools
- .addComponent(this, gbl, aspScrllPn, 6, 3, 1, 2, 1.0, 1.0, 5,
- 30, 0, 0, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
- GUITools.addComponent(this, gbl, aspBttnPnl, 7, 3, 1, 2, 0, 0, 5, 10,
- 0, 10, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
-
- GUITools.addComponent(this, gbl, exRefScrllPn, 6, 5, 1, 1, 1.0, 1.0, 5,
- 30, 10, 0, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
- GUITools.addComponent(this, gbl, exRefBttnPnl, 7, 5, 1, 1, 0, 0, 5, 10,
- 20, 10, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
-
- /*
- * change for saving
- */
- if (findingMgmt.isFindingEmpty(currentFinding)) {
- currentFinding.setDescription("");
- currentFinding.setSeverity(sevMgmt.getSeverities().get(0));
- resiData.fireDataChanged();
- }
- }
-
- /**
- * Updates the buttons of the tables.
- */
- private void updateTableButtons() {
- if (aspTbl.getSelectedRow() == -1) {
- remAspBttn.setEnabled(false);
- } else {
- remAspBttn.setEnabled(true);
- }
-
- if (refTbl.getSelectedRow() == -1) {
- remRefBttn.setEnabled(false);
- ediRefBttn.setEnabled(false);
- } else {
- remRefBttn.setEnabled(true);
- ediRefBttn.setEnabled(true);
- }
-
- if (exRefTbl.getSelectedRow() == -1) {
- remExRefBttn.setEnabled(false);
- } else {
- remExRefBttn.setEnabled(true);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
- */
- @Override
- public void update(Observable o, Object arg) {
- updateFindBttns();
- }
-
- /**
- * Update find bttns.
- */
- public void updateFindBttns() {
- if (findingMgmt.getNumberOfFindings(currentProtocol) == 1) {
- remFindBttn.setEnabled(false);
- pushUpBttn.setEnabled(false);
- pushDownBttn.setEnabled(false);
-
- } else {
- remFindBttn.setEnabled(true);
-
- if (findingMgmt.isTopFinding(currentFinding, currentProtocol)) {
- pushUpBttn.setEnabled(false);
- } else {
- pushUpBttn.setEnabled(true);
- }
-
- if (findingMgmt.isBottomFinding(currentFinding, currentProtocol)) {
- pushDownBttn.setEnabled(false);
- } else {
- pushDownBttn.setEnabled(true);
- }
- }
- }
-
- /**
- * Updates the focus.
- *
- * @param evSource
- * the event source
- */
- public void updateFocus(Object evSource) {
- if (evSource != descTxtArea) {
- descTxtArea.select(0, 0);
- }
-
- if (evSource != refTbl) {
- if (refTbl.getCellEditor() != null) {
- refTbl.getCellEditor().stopCellEditing();
- }
-
- if (refTbl.getRowCount() > 0) {
- refTbl.removeRowSelectionInterval(0, refTbl.getRowCount() - 1);
- }
- }
-
- if (evSource != exRefTbl) {
- if (exRefTbl.getRowCount() > 0) {
- exRefTbl.removeRowSelectionInterval(0,
- exRefTbl.getRowCount() - 1);
- }
- }
-
- if (evSource != aspTbl) {
- if (aspTbl.getRowCount() > 0) {
- aspTbl.removeRowSelectionInterval(0, aspTbl.getRowCount() - 1);
- }
- }
- }
-
- /**
- * Returns the current finding
- *
- * @return the current finding
- */
- public Finding getCurrentFinding() {
- return currentFinding;
- }
-
- public boolean isCellEditing(){
- return refTbl.isEditing();
- }
-
- public void saveRef(){
- refTbl.getCellEditor().stopCellEditing();
- }
-}
=== added file 'src/org/revager/gui/protocol/FindingPanel.java'
--- src/org/revager/gui/protocol/FindingPanel.java 1970-01-01 00:00:00 +0000
+++ src/org/revager/gui/protocol/FindingPanel.java 2010-05-27 20:33:41 +0000
@@ -0,0 +1,1116 @@
+package org.revager.gui.protocol;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Desktop;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.File;
+import java.util.List;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.SwingWorker;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.MatteBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.revager.app.Application;
+import org.revager.app.FindingManagement;
+import org.revager.app.ResiFileFilter;
+import org.revager.app.SeverityManagement;
+import org.revager.app.model.Data;
+import org.revager.app.model.ResiData;
+import org.revager.app.model.schema.Aspect;
+import org.revager.app.model.schema.Finding;
+import org.revager.app.model.schema.Protocol;
+import org.revager.gui.UI;
+import org.revager.gui.helpers.DefaultTableHeaderCellRenderer;
+import org.revager.gui.helpers.FileChooser;
+import org.revager.gui.models.FindAspTableModel;
+import org.revager.gui.models.FindExtRefTableModel;
+import org.revager.gui.models.FindRefTableModel;
+import org.revager.gui.protocol.AddAspToFindPopupWindow.ButtonClicked;
+import org.revager.tools.AppTools;
+import org.revager.tools.GUITools;
+
+public class FindingPanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum Type {
+ EDIT_VIEW, COMPACT_VIEW
+ }
+
+ private static final int CONTROL_BUTTONS_PADDING = 2;
+
+ public static final Dimension EDIT_VIEW_SIZE = new Dimension(100, 280);
+ public static final Dimension COMPACT_VIEW_SIZE = new Dimension(100, 45);
+
+ private static final Color EDIT_VIEW_BG = new Color(255, 255, 204);
+ private static final Color COMPACT_VIEW_BG = new Color(229, 226, 226);
+
+ private Type type = Type.EDIT_VIEW;
+
+ private Finding finding = null;
+
+ private FindingsTab findingsTab = null;
+
+ private Protocol protocol = null;
+
+ private GridBagLayout layout = new GridBagLayout();
+
+ private FindingManagement findMgmt = Application.getInstance()
+ .getFindingMgmt();
+ private SeverityManagement sevMgmt = Application.getInstance()
+ .getSeverityMgmt();
+ private ResiData resiData = Data.getInstance().getResiData();
+
+ private ImageIcon iconAdd = Data.getInstance().getIcon("add_25x25_0.png");
+ private ImageIcon iconRemove = Data.getInstance().getIcon(
+ "remove_25x25_0.png");
+ private ImageIcon iconEdit = Data.getInstance().getIcon("edit_25x25_0.png");
+ private ImageIcon iconPushUp = Data.getInstance().getIcon(
+ "upArrow_25x25_0.png");
+ private ImageIcon iconPushDown = Data.getInstance().getIcon(
+ "downArrow_25x25_0.png");
+ private ImageIcon iconPushTop = Data.getInstance().getIcon(
+ "pushTop_25x25_0.png");
+ private ImageIcon iconPushBottom = Data.getInstance().getIcon(
+ "pushBottom_25x25_0.png");
+ private ImageIcon iconRemoveFinding = Data.getInstance().getIcon(
+ "delete_25x25_0.png");
+ private ImageIcon iconCloseFinding = Data.getInstance().getIcon(
+ "closeFinding_25x25_0.png");
+ private ImageIcon iconPaste = Data.getInstance().getIcon(
+ "paste_25x25_0.png");
+
+ private ImageIcon iconRolloverAdd = Data.getInstance().getIcon(
+ "add_25x25.png");
+ private ImageIcon iconRolloverRemove = Data.getInstance().getIcon(
+ "remove_25x25.png");
+ private ImageIcon iconRolloverEdit = Data.getInstance().getIcon(
+ "edit_25x25.png");
+ private ImageIcon iconRolloverPushUp = Data.getInstance().getIcon(
+ "upArrow_25x25.png");
+ private ImageIcon iconRolloverPushDown = Data.getInstance().getIcon(
+ "downArrow_25x25.png");
+ private ImageIcon iconRolloverPushTop = Data.getInstance().getIcon(
+ "pushTop_25x25.png");
+ private ImageIcon iconRolloverPushBottom = Data.getInstance().getIcon(
+ "pushBottom_25x25.png");
+ private ImageIcon iconRolloverRemoveFinding = Data.getInstance().getIcon(
+ "delete_25x25.png");
+ private ImageIcon iconRolloverCloseFinding = Data.getInstance().getIcon(
+ "closeFinding_25x25.png");
+ private ImageIcon iconRolloverPaste = Data.getInstance().getIcon(
+ "paste_25x25.png");
+
+ private ImageIcon iconBlank = Data.getInstance().getIcon("blank_25x25.png");
+
+ private GridBagLayout layoutEditView = new GridBagLayout();
+ private JPanel panelEditView = new JPanel(layoutEditView);
+
+ private GridBagLayout layoutCompactView = new GridBagLayout();
+ private JPanel panelCompactView = new JPanel(layoutCompactView);
+
+ private JLabel labelFindingNumber = new JLabel();
+ private JLabel labelFindingSeverity = new JLabel();
+ private JLabel labelFindingDescription = new JLabel();
+
+ private JLabel labelFindingTitle = new JLabel();
+
+ private JComboBox comboSeverity = new JComboBox();
+
+ private JTextArea textDescription = new JTextArea();
+
+ private FindRefTableModel modelReferences;
+ private FindExtRefTableModel modelExtReferences;
+ private FindAspTableModel modelAspects;
+
+ private JTable tableReferences;
+ private JTable tableExtReferences;
+ private JTable tableAspects;
+
+ private JScrollPane scrollDescription;
+ private JScrollPane scrollReferences;
+ private JScrollPane scrollExtReferences;
+ private JScrollPane scrollAspects;
+
+ private JButton buttonAddReference = GUITools.newImageButton(iconAdd,
+ iconRolloverAdd);
+ private JButton buttonEditReference = GUITools.newImageButton(iconEdit,
+ iconRolloverEdit);
+ private JButton buttonRemoveReference = GUITools.newImageButton(iconRemove,
+ iconRolloverRemove);
+
+ private JButton buttonAddExtReference = GUITools.newImageButton(iconAdd,
+ iconRolloverAdd);
+ private JButton buttonRemoveExtReference = GUITools.newImageButton(
+ iconRemove, iconRolloverRemove);
+ private JButton buttonPasteExtReference = GUITools.newImageButton(
+ iconPaste, iconRolloverPaste);
+
+ private JButton buttonAddAspect = GUITools.newImageButton(iconAdd,
+ iconRolloverAdd);
+ private JButton buttonRemoveAspect = GUITools.newImageButton(iconRemove,
+ iconRolloverRemove);
+
+ private JButton buttonPushUp = GUITools.newImageButton(iconPushUp,
+ iconRolloverPushUp);
+ private JButton buttonPushDown = GUITools.newImageButton(iconPushDown,
+ iconRolloverPushDown);
+ private JButton buttonPushTop = GUITools.newImageButton(iconPushTop,
+ iconRolloverPushTop);
+ private JButton buttonPushBottom = GUITools.newImageButton(iconPushBottom,
+ iconRolloverPushBottom);
+ private JButton buttonCloseFinding = GUITools.newImageButton(
+ iconCloseFinding, iconRolloverCloseFinding);
+ private JButton buttonRemoveFinding = GUITools.newImageButton(
+ iconRemoveFinding, iconRolloverRemoveFinding);
+
+ private JButton buttonDummy = GUITools.newImageButton(iconBlank, iconBlank);
+
+ private FocusListener focusListener = new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ updateFocus(e.getSource());
+
+ updateTableButtons();
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ updateTableButtons();
+ }
+ };
+
+ private MouseListener mouseListener = new MouseListener() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ updateTableButtons();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+ };
+
+ private MouseListener mouseListenerCompact = new MouseListener() {
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ findingsTab.editFinding(finding);
+ }
+ };
+
+ public FindingPanel(final Finding finding, final FindingsTab findingsTab) {
+ super();
+
+ this.finding = finding;
+ this.findingsTab = findingsTab;
+ this.protocol = findingsTab.getProtocol();
+
+ this.setLayout(layout);
+ this.setBackground(Color.WHITE);
+
+ /*
+ * Initialize tables and models
+ */
+ modelReferences = new FindRefTableModel(finding);
+ modelExtReferences = new FindExtRefTableModel(finding);
+ modelAspects = new FindAspTableModel(finding);
+
+ /*
+ * Prepare buttons and put them inside separate panels
+ */
+ JPanel panelButtonsReferences = new JPanel(new GridLayout(3, 1));
+ JPanel panelButtonsExtReferences = new JPanel(new GridLayout(3, 1));
+ JPanel panelButtonsAspects = new JPanel(new GridLayout(2, 1));
+
+ panelButtonsReferences.setOpaque(false);
+ panelButtonsExtReferences.setOpaque(false);
+ panelButtonsAspects.setOpaque(false);
+
+ /*
+ * Set tooltips for buttons
+ */
+ buttonCloseFinding.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.close"));
+ buttonRemoveFinding.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.remove"));
+ buttonPushUp.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.pushUp"));
+ buttonPushDown.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.pushDown"));
+ buttonPushTop.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.pushTop"));
+ buttonPushBottom.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsList.pushBottom"));
+
+ /*
+ * Buttons for references table
+ */
+ buttonAddReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // UI.getInstance().getProtocolFrame().updateFocus(finding,
+ // tableReferences);
+
+ if (tableReferences.getCellEditor() != null) {
+ tableReferences.getCellEditor().stopCellEditing();
+ }
+
+ String ref = Data.getInstance().getLocaleStr(
+ "editProtocol.finding.newRef");
+ findMgmt.addReference(ref, finding);
+ modelReferences.fireTableDataChanged();
+
+ int row = tableReferences.getRowCount() - 1;
+
+ tableReferences.scrollRectToVisible(tableReferences
+ .getCellRect(row, 0, false));
+ tableReferences.editCellAt(row, 0);
+ }
+ });
+
+ buttonRemoveReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int selRow = tableReferences.getSelectedRow();
+
+ if (tableReferences.getEditingRow() != -1) {
+ selRow = tableReferences.getEditingRow();
+
+ tableReferences.getCellEditor().stopCellEditing();
+ }
+
+ if (selRow != -1) {
+ String ref = findMgmt.getReferences(finding).get(selRow);
+ findMgmt.removeReference(ref, finding);
+ modelReferences.fireTableDataChanged();
+ }
+
+ updateTableButtons();
+ }
+ });
+
+ buttonEditReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int selRow = tableReferences.getSelectedRow();
+
+ if (selRow != -1) {
+ tableReferences.editCellAt(selRow, 0);
+ modelReferences.fireTableDataChanged();
+ }
+ }
+ });
+
+ buttonAddReference.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.addRef"));
+ buttonRemoveReference.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.remRef"));
+ buttonEditReference.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.ediRef"));
+
+ buttonRemoveReference.setEnabled(false);
+ buttonEditReference.setEnabled(false);
+
+ panelButtonsReferences.add(buttonAddReference);
+ panelButtonsReferences.add(buttonRemoveReference);
+ panelButtonsReferences.add(buttonEditReference);
+
+ /*
+ * Buttons for external references table
+ */
+ buttonAddExtReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateFocus(tableExtReferences);
+
+ new AddExternalReferenceWorker().execute();
+ }
+ });
+
+ buttonRemoveExtReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int selRow = tableExtReferences.getSelectedRow();
+
+ if (selRow != -1) {
+ File file = findMgmt.getExtReferences(finding).get(selRow);
+
+ findMgmt.removeExtReference(file, finding);
+
+ modelExtReferences.fireTableDataChanged();
+
+ updateTableButtons();
+ }
+ }
+ });
+
+ buttonPasteExtReference.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateFocus(tableExtReferences);
+
+ new PasteImageFromClipboardWorker().execute();
+ }
+ });
+
+ buttonAddExtReference.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.addExRef"));
+ buttonRemoveExtReference.setToolTipText(Data.getInstance()
+ .getLocaleStr("findingsItem.remExRef"));
+ buttonPasteExtReference.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.pasteExRef"));
+
+ buttonRemoveExtReference.setEnabled(false);
+
+ panelButtonsExtReferences.add(buttonAddExtReference);
+ panelButtonsExtReferences.add(buttonRemoveExtReference);
+ panelButtonsExtReferences.add(buttonPasteExtReference);
+
+ /*
+ * Buttons for aspects table
+ */
+ buttonAddAspect.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateFocus(tableAspects);
+
+ AddAspToFindPopupWindow popup = new AddAspToFindPopupWindow(UI
+ .getInstance().getProtocolFrame());
+
+ popup.setVisible(true);
+
+ if (popup.getButtonClicked() == ButtonClicked.OK) {
+ List<Aspect> aspList = popup.getSelAspList();
+
+ for (Aspect asp : aspList) {
+ findMgmt.addAspect(asp, finding);
+ }
+
+ modelAspects.fireTableDataChanged();
+
+ GUITools.scrollToBottom(scrollAspects);
+ }
+
+ updateTableButtons();
+ }
+ });
+
+ buttonRemoveAspect.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int selRow = tableAspects.getSelectedRow();
+
+ if (selRow != -1) {
+ String asp = findMgmt.getAspects(finding).get(selRow);
+ findMgmt.removeAspect(asp, finding);
+ modelAspects.fireTableDataChanged();
+ }
+
+ updateTableButtons();
+ }
+ });
+
+ buttonAddAspect.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.addAsp"));
+ buttonRemoveAspect.setToolTipText(Data.getInstance().getLocaleStr(
+ "findingsItem.remAsp"));
+
+ buttonRemoveAspect.setEnabled(false);
+
+ panelButtonsAspects.add(buttonAddAspect);
+ panelButtonsAspects.add(buttonRemoveAspect);
+
+ /*
+ * Prepare tables
+ */
+ tableAspects = GUITools.newStandardTable(modelAspects, true);
+ tableReferences = GUITools.newStandardTable(modelReferences, true);
+ tableExtReferences = GUITools
+ .newStandardTable(modelExtReferences, true);
+
+ tableAspects.getColumnModel().getColumn(0).setHeaderRenderer(
+ new FindingPanelHeadRenderer());
+ tableReferences.getColumnModel().getColumn(0).setHeaderRenderer(
+ new FindingPanelHeadRenderer());
+ tableExtReferences.getColumnModel().getColumn(0).setHeaderRenderer(
+ new FindingPanelHeadRenderer());
+
+ tableAspects.getColumnModel().getColumn(0).setCellRenderer(
+ new FindingPanelCellRenderer());
+ tableReferences.getColumnModel().getColumn(0).setCellRenderer(
+ new FindingPanelCellRenderer());
+ tableExtReferences.getColumnModel().getColumn(0).setCellRenderer(
+ new FindingPanelCellRenderer());
+
+ tableAspects.setRowHeight(29);
+ tableReferences.setRowHeight(29);
+ tableExtReferences.setRowHeight(29);
+
+ tableAspects.addFocusListener(focusListener);
+ tableReferences.addFocusListener(focusListener);
+ tableExtReferences.addFocusListener(focusListener);
+
+ tableAspects.addMouseListener(mouseListener);
+ tableReferences.addMouseListener(mouseListener);
+ tableExtReferences.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ updateTableButtons();
+
+ if (e.getClickCount() == 2) {
+ int selRow = tableReferences.getSelectedRow();
+
+ if (selRow != -1) {
+ File ref = findMgmt.getExtReferences(finding).get(
+ tableReferences.getSelectedRow());
+
+ if (AppTools.isReadableWritableImageFile(ref)) {
+ UI.getInstance().getProtocolFrame().getImageEditor(
+ ref).setVisible(true);
+ } else {
+ try {
+ Desktop.getDesktop().open(ref);
+ } catch (Exception exc) {
+ JOptionPane.showMessageDialog(UI.getInstance()
+ .getProtocolFrame(), GUITools
+ .getMessagePane(exc.getMessage()), Data
+ .getInstance().getLocaleStr("error"),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+ });
+
+ scrollAspects = new JScrollPane(tableAspects);
+ scrollReferences = new JScrollPane(tableReferences);
+ scrollExtReferences = new JScrollPane(tableExtReferences);
+
+ scrollAspects.getViewport().setBackground(Color.WHITE);
+ scrollReferences.getViewport().setBackground(Color.WHITE);
+ scrollExtReferences.getViewport().setBackground(Color.WHITE);
+
+ /*
+ * Create content panel
+ */
+ panelEditView.setBorder(UI.STANDARD_BORDER);
+ panelEditView.setBackground(EDIT_VIEW_BG);
+
+ panelCompactView.setBorder(UI.STANDARD_BORDER);
+ panelCompactView.setBackground(COMPACT_VIEW_BG);
+
+ labelFindingDescription.setFont(UI.PROTOCOL_FONT);
+
+ labelFindingNumber.setFont(UI.PROTOCOL_FONT_BOLD);
+
+ labelFindingSeverity.setFont(new Font(UI.PROTOCOL_FONT.getName(),
+ Font.ITALIC, UI.PROTOCOL_FONT.getSize()));
+
+ labelFindingTitle.setFont(UI.PROTOCOL_FONT_BOLD);
+ labelFindingTitle.setText(Data.getInstance().getLocaleStr(
+ "editProtocol.finding.number")
+ + " " + finding.getId());
+
+ scrollDescription = GUITools.setIntoScrllPn(textDescription);
+ GUITools.scrollToTop(scrollDescription);
+
+ textDescription.setText(finding.getDescription());
+ textDescription.addFocusListener(focusListener);
+ textDescription.setFont(UI.PROTOCOL_FONT);
+ textDescription.addKeyListener(new KeyListener() {
+ @Override
+ public void keyTyped(KeyEvent e) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ findingsTab.updateTab();
+
+ if (findMgmt.isFindingNotComplete(finding)) {
+ scrollDescription.setBorder(UI.MARKED_BORDER);
+ } else {
+ scrollDescription.setBorder(UI.STANDARD_BORDER);
+ }
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ }
+ });
+
+ comboSeverity.setFont(UI.PROTOCOL_FONT_BOLD);
+ for (String sev : sevMgmt.getSeverities()) {
+ comboSeverity.addItem(sev);
+ }
+ comboSeverity.addFocusListener(focusListener);
+
+ comboSeverity.setSelectedItem(finding.getSeverity());
+
+ comboSeverity.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ finding.setSeverity(comboSeverity.getSelectedItem()
+ .toString());
+ resiData.fireDataChanged();
+ }
+ }
+ });
+
+ buttonCloseFinding.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ findingsTab.closeCurrentFinding();
+ }
+ });
+ buttonRemoveFinding.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (JOptionPane.showConfirmDialog(UI.getInstance()
+ .getProtocolFrame(), GUITools.getMessagePane(Data
+ .getInstance().getLocaleStr(
+ "findingsList.confirmRemoval")), Data
+ .getInstance().getLocaleStr("question"),
+ JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
+ findingsTab.removeCurrentFinding();
+ }
+ }
+ });
+ buttonPushUp.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ findingsTab.pushUpCurrentFinding();
+ }
+ });
+ buttonPushDown.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ findingsTab.pushDownCurrentFinding();
+ }
+ });
+ buttonPushTop.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ findingsTab.pushTopCurrentFinding();
+ }
+ });
+ buttonPushBottom.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ findingsTab.pushBottomCurrentFinding();
+ }
+ });
+
+ /*
+ * Register focus listener
+ */
+ textDescription.addFocusListener(focusListener);
+ comboSeverity.addFocusListener(focusListener);
+
+ tableAspects.addFocusListener(focusListener);
+ tableExtReferences.addFocusListener(focusListener);
+ tableReferences.addFocusListener(focusListener);
+
+ /*
+ * Add components to compact view panel
+ */
+ GUITools.addComponent(panelCompactView, layoutCompactView,
+ labelFindingNumber, 0, 0, 1, 1, 0.0, 0.0, 10, 10, 10, 10,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+
+ GUITools.addComponent(panelCompactView, layoutCompactView,
+ labelFindingDescription, 1, 0, 1, 1, 1.0, 0.0, 10, 10, 10, 10,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+
+ GUITools.addComponent(panelCompactView, layoutCompactView,
+ labelFindingSeverity, 2, 0, 1, 1, 0.0, 0.0, 10, 10, 10, 10,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHEAST);
+
+ /*
+ * Add components to edit view panel
+ */
+ JPanel panelStrut = new JPanel();
+ panelStrut.setBackground(EDIT_VIEW_BG);
+
+ GUITools.addComponent(panelEditView, layoutEditView, labelFindingTitle,
+ 0, 0, 2, 1, 0.0, 0.0, 10, 10, 0, 10, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView, comboSeverity, 1,
+ 0, 2, 1, 0.0, 0.0, 10, 10, 0, 10, GridBagConstraints.NONE,
+ GridBagConstraints.NORTHEAST);
+ GUITools.addComponent(panelEditView, layoutEditView, scrollDescription,
+ 0, 1, 1, 1, 1.0, 1.0, 10, 10, 0, 10, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView, panelStrut, 1, 1,
+ 1, 1, 0.0, 0.0, 10, 0, 0, 20, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView, scrollReferences,
+ 2, 1, 1, 1, 1.0, 0.0, 10, 10, 0, 10, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView,
+ panelButtonsReferences, 3, 1, 1, 1, 0.0, 0.0, 10, 0, 0, 10,
+ GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView, scrollAspects, 0,
+ 2, 1, 1, 1.0, 0.0, 10, 10, 10, 10, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView,
+ panelButtonsAspects, 1, 2, 1, 1, 0.0, 0.0, 10, 0, 10, 20,
+ GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView,
+ scrollExtReferences, 2, 2, 1, 1, 1.0, 0.0, 10, 10, 10, 10,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelEditView, layoutEditView,
+ panelButtonsExtReferences, 3, 2, 1, 1, 0.0, 0.0, 10, 0, 10, 10,
+ GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
+
+ setEditView();
+
+ if (findMgmt.isFindingEmpty(finding)) {
+ finding.setDescription("");
+ finding.setSeverity(sevMgmt.getSeverities().get(0));
+ resiData.fireDataChanged();
+ }
+
+ updateTableButtons();
+ updateFindingButtons();
+ }
+
+ private void setEditView() {
+ type = Type.EDIT_VIEW;
+
+ this.setPreferredSize(EDIT_VIEW_SIZE);
+
+ this.setToolTipText(null);
+
+ this.removeAll();
+
+ this.removeMouseListener(mouseListenerCompact);
+
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+
+ if (findMgmt.isFindingNotComplete(finding)) {
+ scrollDescription.setBorder(UI.MARKED_BORDER);
+ } else {
+ scrollDescription.setBorder(UI.STANDARD_BORDER);
+ }
+
+ updateFindingButtons();
+
+ /*
+ * Create finding control buttons like push etc.
+ */
+ GUITools.addComponent(this, layout, buttonPushTop, 0, 0, 1, 1, 0.0,
+ 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(this, layout, buttonPushUp, 0, 1, 1, 1, 0.0, 0.0,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(this, layout, buttonCloseFinding, 0, 2, 1, 1,
+ 0.0, 1.0, CONTROL_BUTTONS_PADDING + 35,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(this, layout, buttonRemoveFinding, 0, 3, 1, 1,
+ 0.0, 1.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING + 35, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(this, layout, buttonPushDown, 0, 4, 1, 1, 0.0,
+ 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(this, layout, buttonPushBottom, 0, 5, 1, 1, 0.0,
+ 0.0, CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+
+ /*
+ * Add content panel to root panel
+ */
+ GUITools.addComponent(this, layout, panelEditView, 1, 0, 1, 6, 1.0,
+ 0.0, 0, 0, 0, 20, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+
+ /*
+ * Get the focus
+ */
+ textDescription.requestFocusInWindow();
+ }
+
+ private void setCompactView() {
+ type = Type.COMPACT_VIEW;
+
+ this.setPreferredSize(COMPACT_VIEW_SIZE);
+
+ this.setToolTipText(finding.getAspects().size() + " "
+ + Data.getInstance().getLocaleStr("findingsList.aspects")
+ + ", " + finding.getReferences().size() + " "
+ + Data.getInstance().getLocaleStr("findingsList.references")
+ + ", " + finding.getExternalReferences().size()
+ + Data.getInstance().getLocaleStr("findingsList.files"));
+
+ this.removeAll();
+
+ this.addMouseListener(mouseListenerCompact);
+
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+
+ if (findMgmt.isFindingNotComplete(finding)) {
+ panelCompactView.setBorder(UI.MARKED_BORDER);
+ panelCompactView.setBackground(UI.MARKED_COLOR.brighter());
+ } else {
+ panelCompactView.setBorder(UI.STANDARD_BORDER);
+ panelCompactView.setBackground(COMPACT_VIEW_BG);
+ }
+
+ storeFindingData();
+
+ /*
+ * Update labels
+ */
+ labelFindingNumber.setText(Data.getInstance().getLocaleStr(
+ "editProtocol.finding.number")
+ + " " + finding.getId());
+
+ labelFindingSeverity.setText(finding.getSeverity());
+
+ labelFindingDescription.setText(finding.getDescription());
+
+ /*
+ * Add content panel to the root panel
+ */
+ buttonDummy.setEnabled(false);
+
+ GUITools.addComponent(this, layout, buttonDummy, 0, 0, 1, 1, 0.0, 0.0,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ CONTROL_BUTTONS_PADDING, CONTROL_BUTTONS_PADDING,
+ GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+
+ GUITools.addComponent(this, layout, panelCompactView, 1, 0, 1, 1, 1.0,
+ 0.0, 0, 0, 0, 20, GridBagConstraints.BOTH,
+ GridBagConstraints.NORTHWEST);
+ }
+
+ public void updateFindingButtons() {
+ if (findMgmt.getNumberOfFindings(protocol) == 1) {
+ // buttonRemoveFinding.setEnabled(false);
+ buttonPushUp.setEnabled(false);
+ buttonPushDown.setEnabled(false);
+ buttonPushTop.setEnabled(false);
+ buttonPushBottom.setEnabled(false);
+ } else {
+ // buttonRemoveFinding.setEnabled(true);
+
+ if (findMgmt.isTopFinding(finding, protocol)) {
+ buttonPushUp.setEnabled(false);
+ buttonPushTop.setEnabled(false);
+ } else {
+ buttonPushUp.setEnabled(true);
+ buttonPushTop.setEnabled(true);
+ }
+
+ if (findMgmt.isBottomFinding(finding, protocol)) {
+ buttonPushDown.setEnabled(false);
+ buttonPushBottom.setEnabled(false);
+ } else {
+ buttonPushDown.setEnabled(true);
+ buttonPushBottom.setEnabled(true);
+ }
+ }
+ }
+
+ private void updateTableButtons() {
+ if (tableAspects.getSelectedRow() == -1) {
+ buttonRemoveAspect.setEnabled(false);
+ } else {
+ buttonRemoveAspect.setEnabled(true);
+ }
+
+ if (tableReferences.getSelectedRow() == -1) {
+ buttonRemoveReference.setEnabled(false);
+ buttonEditReference.setEnabled(false);
+ } else {
+ buttonRemoveReference.setEnabled(true);
+ buttonEditReference.setEnabled(true);
+ }
+
+ if (tableExtReferences.getSelectedRow() == -1) {
+ buttonRemoveExtReference.setEnabled(false);
+ } else {
+ buttonRemoveExtReference.setEnabled(true);
+ }
+ }
+
+ public void updateFocus(Object evSource) {
+ if (evSource != textDescription) {
+ textDescription.select(0, 0);
+ }
+
+ if (evSource != tableReferences) {
+ if (tableReferences.getCellEditor() != null) {
+ tableReferences.getCellEditor().stopCellEditing();
+ }
+
+ if (tableReferences.getRowCount() > 0) {
+ tableReferences.removeRowSelectionInterval(0, tableReferences
+ .getRowCount() - 1);
+ }
+ }
+
+ if (evSource != tableExtReferences) {
+ if (tableExtReferences.getRowCount() > 0) {
+ tableExtReferences.removeRowSelectionInterval(0,
+ tableExtReferences.getRowCount() - 1);
+ }
+ }
+
+ if (evSource != tableAspects) {
+ if (tableAspects.getRowCount() > 0) {
+ tableAspects.removeRowSelectionInterval(0, tableAspects
+ .getRowCount() - 1);
+ }
+ }
+ }
+
+ public boolean isCompactView() {
+ return type == Type.COMPACT_VIEW;
+ }
+
+ public boolean isEditView() {
+ return type == Type.EDIT_VIEW;
+ }
+
+ public void switchView() {
+ if (isEditView()) {
+ setCompactView();
+ } else {
+ setEditView();
+ }
+ }
+
+ public Finding getFinding() {
+ return finding;
+ }
+
+ public void storeFindingData() {
+ finding.setDescription(textDescription.getText());
+
+ if (tableReferences.isEditing()) {
+ tableReferences.getCellEditor().stopCellEditing();
+ }
+ }
+
+ private class FindingPanelCellRenderer extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Font getFont() {
+ return UI.PROTOCOL_FONT;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus, int row,
+ int column) {
+ setToolTipText(GUITools.getTextAsHtml("<font size=\"5\">"
+ + (String) value + "</font>"));
+
+ return super.getTableCellRendererComponent(table, value,
+ isSelected, hasFocus, row, column);
+ }
+ };
+
+ private class FindingPanelHeadRenderer extends
+ DefaultTableHeaderCellRenderer {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Font getFont() {
+ return UI.PROTOCOL_FONT;
+ }
+ };
+
+ private class AddExternalReferenceWorker extends SwingWorker<Void, Void> {
+ @Override
+ protected Void doInBackground() throws Exception {
+ FileChooser fileChooser = UI.getInstance().getFileChooser();
+
+ fileChooser.setFile(null);
+
+ if (fileChooser.showDialog(UI.getInstance().getEditProductDialog(),
+ FileChooser.MODE_OPEN_FILE, ResiFileFilter.TYPE_ALL) == FileChooser.SELECTED_APPROVE) {
+
+ UI.getInstance().getProtocolFrame().switchToProgressMode();
+
+ File file = fileChooser.getFile();
+ findMgmt.addExtReference(file, finding);
+ modelExtReferences.fireTableDataChanged();
+
+ Thread.sleep(200);
+
+ GUITools.scrollToBottom(scrollExtReferences);
+
+ updateTableButtons();
+ }
+
+ UI.getInstance().getProtocolFrame().switchToEditMode();
+
+ return null;
+ }
+ };
+
+ private class PasteImageFromClipboardWorker extends SwingWorker<Void, Void> {
+ @Override
+ protected Void doInBackground() throws Exception {
+ UI.getInstance().getProtocolFrame().switchToProgressMode(
+ Data.getInstance().getLocaleStr(
+ "editProtocol.message.imgLoading"));
+
+ Image img = AppTools.getImageFromClipboard();
+
+ if (img == null) {
+ JOptionPane.showMessageDialog(UI.getInstance()
+ .getProtocolFrame(), GUITools.getMessagePane(Data
+ .getInstance().getLocaleStr(
+ "editProtocol.message.noImgInCb")), Data
+ .getInstance().getLocaleStr("info"),
+ JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ Image scalImg = img.getScaledInstance(-1, 250,
+ Image.SCALE_SMOOTH);
+
+ JLabel labelImg = new JLabel(new ImageIcon(scalImg));
+ labelImg.setBorder(new CompoundBorder(new EmptyBorder(0, 0, 15,
+ 0), new MatteBorder(1, 1, 1, 1, UI.SEPARATOR_COLOR)));
+
+ JTextField inputField = new JTextField();
+ inputField.setText(Data.getInstance().getLocaleStr(
+ "editProtocol.finding.stdFileName"));
+
+ JPanel messagePane = new JPanel(new BorderLayout());
+ messagePane.add(labelImg, BorderLayout.NORTH);
+ messagePane.add(new JLabel(Data.getInstance().getLocaleStr(
+ "editProtocol.message.askForFileName")),
+ BorderLayout.CENTER);
+ messagePane.add(inputField, BorderLayout.SOUTH);
+
+ Object[] options = {
+ Data.getInstance().getLocaleStr("findingsItem.save"),
+ Data.getInstance().getLocaleStr("findingsItem.edit"),
+ Data.getInstance().getLocaleStr("findingsItem.abort") };
+
+ int action = JOptionPane.showOptionDialog(UI.getInstance()
+ .getProtocolFrame(), messagePane, Data.getInstance()
+ .getLocaleStr("confirm"),
+ JOptionPane.YES_NO_CANCEL_OPTION,
+ JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
+
+ String fileName = null;
+
+ if (action != 2) {
+ fileName = inputField.getText();
+ }
+
+ if (fileName != null && !fileName.trim().equals("")) {
+ findMgmt.addExtReference(img, fileName, finding);
+
+ modelExtReferences.fireTableDataChanged();
+
+ updateTableButtons();
+ }
+
+ if (action == 1) {
+ int numberOfExtRefs = findMgmt.getExtReferences(finding)
+ .size();
+
+ File extRef = findMgmt.getExtReferences(finding).get(
+ numberOfExtRefs - 1);
+
+ UI.getInstance().getProtocolFrame().getImageEditor(extRef)
+ .setVisible(true);
+ }
+ }
+
+ UI.getInstance().getProtocolFrame().switchToEditMode();
+
+ return null;
+ }
+ }
+
+}
=== added file 'src/org/revager/gui/protocol/FindingsTab.java'
--- src/org/revager/gui/protocol/FindingsTab.java 1970-01-01 00:00:00 +0000
+++ src/org/revager/gui/protocol/FindingsTab.java 2010-05-27 20:33:41 +0000
@@ -0,0 +1,421 @@
+package org.revager.gui.protocol;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
+import org.revager.app.Application;
+import org.revager.app.FindingManagement;
+import org.revager.app.SeverityManagement;
+import org.revager.app.model.Data;
+import org.revager.app.model.schema.Finding;
+import org.revager.app.model.schema.Protocol;
+import org.revager.gui.UI;
+import org.revager.tools.GUITools;
+
+public class FindingsTab extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private FindingManagement findMgmt = Application.getInstance()
+ .getFindingMgmt();
+ private SeverityManagement sevMgmt = Application.getInstance()
+ .getSeverityMgmt();
+
+ private Protocol protocol = null;
+
+ private FindingPanel currentFindingPanel = null;
+
+ private GridBagLayout layoutFindingsList = new GridBagLayout();
+ private JPanel panelFindingsList = new JPanel(layoutFindingsList);
+ private JScrollPane scrollFindingsList = new JScrollPane(panelFindingsList);
+
+ private int gblAlignment = GridBagConstraints.BOTH;
+
+ private JPanel panelStrut = new JPanel();
+
+ private JButton buttonAddFinding = new JButton(Data.getInstance()
+ .getLocaleStr("editProtocol.newFinding"));
+ private JLabel labelNumOfFindings = new JLabel();
+
+ private Map<Finding, Integer> gridBagPositions = new HashMap<Finding, Integer>();
+ private Map<Finding, FindingPanel> findingPanels = new HashMap<Finding, FindingPanel>();
+
+ private int currentGridBagPosition = 0;
+
+ public FindingsTab(final Protocol protocol) {
+ super();
+
+ this.protocol = protocol;
+
+ this.setLayout(new BorderLayout());
+
+ panelFindingsList.setBackground(Color.WHITE);
+ panelStrut.setBackground(Color.WHITE);
+
+ scrollFindingsList.getVerticalScrollBar().setUnitIncrement(12);
+ scrollFindingsList.getHorizontalScrollBar().setUnitIncrement(12);
+
+ /*
+ * Prepare footer
+ */
+ JPanel panelFoot = new JPanel(new BorderLayout());
+
+ labelNumOfFindings.setFont(UI.PROTOCOL_FONT);
+
+ buttonAddFinding.setIcon(Data.getInstance().getIcon("add_25x25.png"));
+ buttonAddFinding.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (currentFindingPanel != null) {
+ currentFindingPanel.storeFindingData();
+ }
+
+ // int listIdLastFinding =
+ // findMgmt.getNumberOfFindings(protocol) - 1;
+
+ // if (!findMgmt.isFindingEmpty(findMgmt.getFindings(protocol)
+ // .get(listIdLastFinding))) {
+ Finding newFind = new Finding();
+ newFind.setSeverity(sevMgmt.getSeverities().get(0));
+ newFind = findMgmt.addFinding(newFind, protocol);
+
+ addFinding(newFind);
+ // }
+ }
+ });
+
+ panelFoot.setBorder(BorderFactory.createMatteBorder(5, 35, 5, 35,
+ panelFoot.getBackground()));
+
+ panelFoot.add(buttonAddFinding, BorderLayout.WEST);
+ panelFoot.add(labelNumOfFindings, BorderLayout.EAST);
+
+ this.add(scrollFindingsList, BorderLayout.CENTER);
+ this.add(panelFoot, BorderLayout.SOUTH);
+
+ /*
+ * Load all findings
+ */
+ for (Finding find : findMgmt.getFindings(protocol)) {
+ addFinding(find);
+ }
+ }
+
+ public Protocol getProtocol() {
+ return protocol;
+ }
+
+ public void updateTab() {
+ if (currentFindingPanel != null) {
+ currentFindingPanel.storeFindingData();
+ }
+
+ labelNumOfFindings.setText(findMgmt.getNumberOfFindings(protocol) + " "
+ + Data.getInstance().getLocaleStr("editProtocol.findings"));
+
+ /*
+ * Update the tooltip
+ */
+ Map<String, Integer> findingsSev = new HashMap<String, Integer>();
+
+ for (Finding f : findMgmt.getFindings(protocol)) {
+ if (findingsSev.get(f.getSeverity()) == null) {
+ findingsSev.put(f.getSeverity(), 1);
+ } else {
+ findingsSev.put(f.getSeverity(), findingsSev.get(f
+ .getSeverity()) + 1);
+ }
+ }
+
+ String sevOverview = "";
+ String separator = "";
+
+ for (String s : sevMgmt.getSeverities()) {
+ if (findingsSev.get(s) != null) {
+ sevOverview = sevOverview + separator + findingsSev.get(s)
+ + " x " + s;
+
+ separator = "; ";
+ }
+ }
+
+ labelNumOfFindings.setToolTipText(GUITools.getTextAsHtml(sevOverview));
+
+ /*
+ * Update the button state
+ */
+ boolean isComplete = true;
+
+ for (Finding find : findMgmt.getFindings(protocol)) {
+ if (findMgmt.isFindingNotComplete(find)) {
+ isComplete = false;
+ }
+ }
+
+ buttonAddFinding.setEnabled(isComplete);
+
+ UI.getInstance().getProtocolFrame().update(null, null);
+ }
+
+ public void addFinding(Finding finding) {
+ findMgmt.addFinding(finding, protocol);
+
+ if (currentFindingPanel != null) {
+ currentFindingPanel.switchView();
+ }
+
+ currentFindingPanel = new FindingPanel(finding, this);
+
+ gridBagPositions.put(finding, currentGridBagPosition);
+ findingPanels.put(finding, currentFindingPanel);
+
+ panelFindingsList.remove(panelStrut);
+
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ currentFindingPanel, 0, currentGridBagPosition, 1, 1, 1.0, 0.0,
+ 5, 5, 5, 5, gblAlignment, GridBagConstraints.NORTHWEST);
+
+ /*
+ * Update position of strut panel
+ */
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ panelStrut, 0, currentGridBagPosition + 1, 1, 1, 1.0, 1.0, 0,
+ 0, 0, 0, gblAlignment, GridBagConstraints.NORTHWEST);
+
+ currentGridBagPosition++;
+
+ GUITools.scrollToBottom(scrollFindingsList);
+ // panelFindingsList.scrollRectToVisible(currentFindingPanel.getBounds());
+
+ panelFindingsList.revalidate();
+
+ updateTab();
+ }
+
+ public void editFinding(Finding finding) {
+ if (currentFindingPanel != null
+ && currentFindingPanel.getFinding() == finding) {
+ return;
+ }
+
+ if (currentFindingPanel != null) {
+ currentFindingPanel.switchView();
+ }
+
+ currentFindingPanel = findingPanels.get(finding);
+
+ currentFindingPanel.switchView();
+
+ panelFindingsList.revalidate();
+ }
+
+ public void closeCurrentFinding() {
+ if (currentFindingPanel != null) {
+ currentFindingPanel.switchView();
+
+ currentFindingPanel = null;
+
+ panelFindingsList.revalidate();
+ }
+ }
+
+ public void removeCurrentFinding() {
+ if (currentFindingPanel != null) {
+ Finding currentFinding = currentFindingPanel.getFinding();
+
+ panelFindingsList.remove(currentFindingPanel);
+
+ currentFindingPanel = null;
+
+ gridBagPositions.remove(currentFinding);
+ findingPanels.remove(currentFinding);
+
+ findMgmt.removeFinding(currentFinding, protocol);
+
+ panelFindingsList.revalidate();
+ }
+
+ /*
+ * Add new finding, if there are no findings present
+ */
+ if (findMgmt.getNumberOfFindings(protocol) == 0) {
+ Finding newFind = new Finding();
+ newFind.setSeverity(sevMgmt.getSeverities().get(0));
+ newFind = findMgmt.addFinding(newFind, protocol);
+
+ addFinding(newFind);
+ }
+
+ updateTab();
+ }
+
+ public void pushUpCurrentFinding() {
+ if (currentFindingPanel != null) {
+ FindingPanel predecFindPanel = null;
+
+ int predecPos = -1;
+ int currPos = gridBagPositions
+ .get(currentFindingPanel.getFinding());
+
+ /*
+ * Find predecessor
+ */
+ for (Finding find : gridBagPositions.keySet()) {
+ if (gridBagPositions.get(find) < currPos
+ && gridBagPositions.get(find) > predecPos) {
+ predecPos = gridBagPositions.get(find);
+ predecFindPanel = findingPanels.get(find);
+ }
+ }
+
+ gridBagPositions.put(currentFindingPanel.getFinding(), predecPos);
+ gridBagPositions.put(predecFindPanel.getFinding(), currPos);
+
+ panelFindingsList.remove(currentFindingPanel);
+ panelFindingsList.remove(predecFindPanel);
+
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ currentFindingPanel, 0, predecPos, 1, 1, 1.0, 0.0, 5, 5, 5,
+ 5, gblAlignment, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ predecFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
+ gblAlignment, GridBagConstraints.NORTHWEST);
+
+ findMgmt.pushUpFinding(currentFindingPanel.getFinding(), protocol);
+
+ panelFindingsList.revalidate();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ scrollFindingsList
+ .getVerticalScrollBar()
+ .setValue(
+ scrollFindingsList.getVerticalScrollBar()
+ .getValue()
+ - (FindingPanel.COMPACT_VIEW_SIZE.height + 10));
+ }
+ });
+
+ currentFindingPanel.updateFindingButtons();
+ }
+ }
+
+ public void pushDownCurrentFinding() {
+ if (currentFindingPanel != null) {
+ FindingPanel succFindPanel = null;
+
+ int succPos = currentGridBagPosition + 1;
+ int currPos = gridBagPositions
+ .get(currentFindingPanel.getFinding());
+
+ /*
+ * Find successor
+ */
+ for (Finding find : gridBagPositions.keySet()) {
+ if (gridBagPositions.get(find) > currPos
+ && gridBagPositions.get(find) < succPos) {
+ succPos = gridBagPositions.get(find);
+ succFindPanel = findingPanels.get(find);
+ }
+ }
+
+ gridBagPositions.put(currentFindingPanel.getFinding(), succPos);
+ gridBagPositions.put(succFindPanel.getFinding(), currPos);
+
+ panelFindingsList.remove(currentFindingPanel);
+ panelFindingsList.remove(succFindPanel);
+
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ currentFindingPanel, 0, succPos, 1, 1, 1.0, 0.0, 5, 5, 5,
+ 5, gblAlignment, GridBagConstraints.NORTHWEST);
+ GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ succFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
+ gblAlignment, GridBagConstraints.NORTHWEST);
+
+ findMgmt
+ .pushDownFinding(currentFindingPanel.getFinding(), protocol);
+
+ panelFindingsList.revalidate();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ scrollFindingsList
+ .getVerticalScrollBar()
+ .setValue(
+ scrollFindingsList.getVerticalScrollBar()
+ .getValue()
+ + (FindingPanel.COMPACT_VIEW_SIZE.height + 10));
+ }
+ });
+
+ currentFindingPanel.updateFindingButtons();
+ }
+ }
+
+ public void pushTopCurrentFinding() {
+ if (currentFindingPanel != null) {
+ while (!findMgmt.isTopFinding(currentFindingPanel.getFinding(),
+ protocol)) {
+ pushUpCurrentFinding();
+ }
+ /*
+ * FindingPanel firstFindPanel = null;
+ *
+ * int firstPos = currentGridBagPosition + 1; int currPos =
+ * gridBagPositions .get(currentFindingPanel.getFinding());
+ *
+ *
+ *
+ * for (Finding find : gridBagPositions.keySet()) { if
+ * (gridBagPositions.get(find) < firstPos) { firstPos =
+ * gridBagPositions.get(find); firstFindPanel =
+ * findingPanels.get(find); } }
+ *
+ * gridBagPositions.put(currentFindingPanel.getFinding(), firstPos);
+ * gridBagPositions.put(firstFindPanel.getFinding(), currPos);
+ *
+ * panelFindingsList.remove(currentFindingPanel);
+ * panelFindingsList.remove(firstFindPanel);
+ *
+ * GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ * currentFindingPanel, 0, firstPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
+ * GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ * GUITools.addComponent(panelFindingsList, layoutFindingsList,
+ * firstFindPanel, 0, currPos, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
+ * GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
+ *
+ * findMgmt.pushTopFinding(currentFindingPanel.getFinding(),
+ * protocol);
+ *
+ * panelFindingsList.revalidate();
+ *
+ * GUITools.scrollToTop(scrollFindingsList);
+ *
+ * currentFindingPanel.updateFindingButtons();
+ */
+ }
+ }
+
+ public void pushBottomCurrentFinding() {
+ if (currentFindingPanel != null) {
+ while (!findMgmt.isBottomFinding(currentFindingPanel.getFinding(),
+ protocol)) {
+ pushDownCurrentFinding();
+ }
+ }
+ }
+
+}
=== modified file 'src/org/revager/gui/protocol/ProtocolFrame.java'
--- src/org/revager/gui/protocol/ProtocolFrame.java 2010-01-31 17:32:35 +0000
+++ src/org/revager/gui/protocol/ProtocolFrame.java 2010-05-27 20:33:41 +0000
@@ -19,7 +19,6 @@
package org.revager.gui.protocol;
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
@@ -32,8 +31,6 @@
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
@@ -71,10 +68,8 @@
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
-import javax.swing.UIManager;
import javax.swing.JSpinner.NumberEditor;
import javax.swing.border.EmptyBorder;
-import javax.swing.border.MatteBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.TableCellRenderer;
@@ -84,13 +79,11 @@
import org.revager.app.FindingManagement;
import org.revager.app.ProtocolManagement;
import org.revager.app.ReviewManagement;
-import org.revager.app.SeverityManagement;
import org.revager.app.model.Data;
import org.revager.app.model.DataException;
import org.revager.app.model.appdata.AppSettingKey;
import org.revager.app.model.appdata.AppSettingValue;
import org.revager.app.model.schema.Attendee;
-import org.revager.app.model.schema.Finding;
import org.revager.app.model.schema.Meeting;
import org.revager.app.model.schema.Protocol;
import org.revager.gui.AbstractFrame;
@@ -103,7 +96,6 @@
import org.revager.gui.helpers.DatePicker;
import org.revager.gui.helpers.HintItem;
import org.revager.gui.helpers.ObservingTextField;
-import org.revager.gui.models.FindingsTableModel;
import org.revager.gui.models.PresentAttendeesTableModel;
import org.revager.gui.models.RotateSpinnerNumberModel;
import org.revager.gui.protocol.graphical_annotations.ImageEditorDialog;
@@ -111,7 +103,6 @@
import org.revager.gui.workers.ProtocolClockWorker;
import org.revager.tools.GUITools;
-
/**
* The Class ProtocolFrame.
*/
@@ -130,9 +121,7 @@
private boolean fullscreen = false;
private boolean nativeFullscrSupported = false;
- private int visibleFindingsCount = 1;
-
- private int firstVisibleFinding = 0;
+ private boolean bodyCreated = false;
private GraphicsDevice gd = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
@@ -140,14 +129,10 @@
private FindingManagement findMgmt = Application.getInstance()
.getFindingMgmt();
- private Finding editingFinding = null;
-
private GridBagLayout gbl = new GridBagLayout();
private JTabbedPane tabbedPane = new JTabbedPane();
private JPanel tabPanelOrg = new JPanel(gbl);
private JPanel bottomOrgPanel = new JPanel(gbl);
-
- private List<FindingItem> visibleFList=new ArrayList<FindingItem>();
private JButton tbPdfExport;
private JButton tbCsvExport;
@@ -180,15 +165,9 @@
/*
* things for finding tab
*/
- private GridBagLayout gblBaseFindings = new GridBagLayout();
- private GridBagLayout gblFindings = new GridBagLayout();
- private JPanel tabPanelFindings = new JPanel(gblBaseFindings);
- private JPanel panelFindings = new JPanel(gblFindings);
- private JButton buttonFindScrollUp;
- private JButton buttonFindScrollDown;
- private JLabel labelFindTop = new JLabel();
- private JLabel labelFindBottom = new JLabel();
- private ColoredTableCellRenderer ctcr;
+ private Protocol currentProt;
+
+ private FindingsTab tabPanelFindings;
private SimpleDateFormat sdfCurrentTime = new SimpleDateFormat(
"d. MMMM yyyy | HH:mm");
@@ -200,14 +179,10 @@
private JButton clockButtonReset;
private PresentAttendeesTableModel patm;
- private FindingsTableModel ftm;
private JTable presentAttTable;
- private JTable findTbl;
- private JScrollPane findScrllPn;
private List<Attendee> presentAttList;
- private Protocol currentProt;
private Meeting currentMeet = null;
private JSpinner beginMSpinner;
@@ -219,7 +194,6 @@
private JTextArea impTxtArea;
private JTextArea meetCommTxtArea;
private JTextArea protCommTxtArea;
- private JButton buttonAddFinding;
private JScrollPane impScrllPn;
private JScrollPane meetCommScrllPn;
private JScrollPane protCommScrllPn;
@@ -236,9 +210,6 @@
private JButton removeAttendee;
private JButton editAttendee;
- private SeverityManagement sevMgmt = Application.getInstance()
- .getSeverityMgmt();
-
private DateFormat dateF = SimpleDateFormat
.getDateInstance(DateFormat.LONG);
@@ -253,52 +224,6 @@
};
/**
- * Gets the ftm.
- *
- * @return the ftm
- */
- public FindingsTableModel getFtm() {
- return ftm;
- }
-
- /**
- * Gets the find tbl.
- *
- * @return the find tbl
- */
- public JTable getFindTbl() {
- return findTbl;
- }
-
- /**
- * Gets the first visible finding.
- *
- * @return the first visible finding
- */
- public int getFirstVisibleFinding() {
- return firstVisibleFinding;
- }
-
- /**
- * Gets the visible findings count.
- *
- * @return the visible findings count
- */
- public int getVisibleFindingsCount() {
- return visibleFindingsCount;
- }
-
- /**
- * Sets the first visible finding.
- *
- * @param firstVisibleFinding
- * the new first visible finding
- */
- public void setFirstVisibleFinding(int firstVisibleFinding) {
- this.firstVisibleFinding = firstVisibleFinding;
- }
-
- /**
* Gets the patm.
*
* @return the patm
@@ -396,6 +321,8 @@
createCommAndRatePanel();
tabPanelCommAndRec.validate();
+ tabPanelFindings = new FindingsTab(currentProt);
+
tabbedPane.removeAll();
tabbedPane.removeChangeListener(tabChangeListener);
@@ -410,42 +337,10 @@
"editProtocol.commAndRec"), tabPanelCommAndRec);
tabbedPane.addChangeListener(tabChangeListener);
-
- tabbedPane.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseClicked(MouseEvent e) {
- saveEditRefs();
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
-
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
-
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
-
- }});
add(tabbedPane);
- tabPanelFindings.removeAll();
-
- createPanelFindings();
- updatePanelFindings();
+ bodyCreated = true;
}
/*
@@ -561,7 +456,6 @@
tbFullscreen.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- saveEditRefs();
UI.getInstance().getProtocolFrame(!isFullscreen()).setVisible(
true);
}
@@ -1199,292 +1093,6 @@
}
/**
- * Creates the panel findings.
- */
- private void createPanelFindings() {
- buttonFindScrollUp = GUITools.newImageButton(Data.getInstance()
- .getIcon("findingUp_32x32_0.png"), Data.getInstance().getIcon(
- "findingUp_32x32.png"));
- buttonFindScrollUp.setToolTipText(Data.getInstance().getLocaleStr(
- "editProtocol.scrollUp"));
- buttonFindScrollUp.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveEditRefs();
- if (firstVisibleFinding > 0) {
- firstVisibleFinding--;
-
- updatePanelFindings();
- ftm.fireTableDataChanged();
- findTbl.setRowSelectionInterval(firstVisibleFinding,
- firstVisibleFinding);
- updateTable();
- }
- }
- });
-
- buttonFindScrollDown = GUITools.newImageButton(Data.getInstance()
- .getIcon("findingDown_32x32_0.png"), Data.getInstance()
- .getIcon("findingDown_32x32.png"));
- buttonFindScrollDown.setToolTipText(Data.getInstance().getLocaleStr(
- "editProtocol.scrollDown"));
- buttonFindScrollDown.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveEditRefs();
- if (firstVisibleFinding < findMgmt
- .getNumberOfFindings(currentProt)
- - visibleFindingsCount) {
- firstVisibleFinding++;
-
- updatePanelFindings();
-
- ftm.fireTableDataChanged();
- findTbl.setRowSelectionInterval(firstVisibleFinding,
- firstVisibleFinding);
- updateTable();
- }
- }
- });
-
- buttonAddFinding = GUITools.newImageButton(Data.getInstance().getIcon(
- "findingAdd_32x32_0.png"), Data.getInstance().getIcon(
- "findingAdd_32x32.png"));
- buttonAddFinding.setToolTipText(Data.getInstance().getLocaleStr(
- "editProtocol.newFinding"));
- buttonAddFinding.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveEditRefs();
- int listIdLastFinding = findMgmt
- .getNumberOfFindings(currentProt) - 1;
-
- if (!findMgmt.isFindingEmpty(findMgmt.getFindings(currentProt)
- .get(listIdLastFinding))) {
- Finding newFind = new Finding();
- newFind.setSeverity(sevMgmt.getSeverities().get(0));
- editingFinding = findMgmt.addFinding(newFind, currentProt);
- firstVisibleFinding = findMgmt
- .getNumberOfFindings(currentProt)
- - visibleFindingsCount;
-
- updatePanelFindings();
- ftm.fireTableDataChanged();
- findTbl.setRowSelectionInterval(firstVisibleFinding,
- firstVisibleFinding);
- updateTable();
- }
- }
- });
-
- ftm = new FindingsTableModel(currentProt);
- findTbl = GUITools.newStandardTable(ftm, false);
- findTbl.setRowHeight(36);
- ctcr = new ColoredTableCellRenderer(currentProt);
- findTbl.getColumnModel().getColumn(0).setCellRenderer(ctcr);
- findTbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- findTbl.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(MouseEvent e) {
- saveEditRefs();
- firstVisibleFinding = findTbl.getSelectedRow();
- updatePanelFindings();
-
- ftm.fireTableDataChanged();
- findTbl.setRowSelectionInterval(firstVisibleFinding,
- firstVisibleFinding);
-
- updateTable();
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- });
-
- findScrllPn = new JScrollPane(findTbl);
- findScrllPn
- .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-
- labelFindTop.setFont(UI.PROTOCOL_FONT);
- labelFindBottom.setFont(UI.PROTOCOL_FONT);
-
- labelFindTop.setForeground(Color.GRAY);
- labelFindBottom.setForeground(Color.GRAY);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings, labelFindTop,
- 0, 0, 1, 1, 0.0, 0.0, 5, 10, 5, 10, GridBagConstraints.NONE,
- GridBagConstraints.WEST);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- buttonFindScrollUp, 1, 0, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
- GridBagConstraints.NONE, GridBagConstraints.CENTER);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- new JSeparator(JSeparator.HORIZONTAL), 0, 1, 3, 1, 1.0, 0.0, 0,
- 10, 5, 10, GridBagConstraints.HORIZONTAL,
- GridBagConstraints.CENTER);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings, panelFindings,
- 0, 2, 3, 1, 0.9, 1.0, 5, 5, 5, 5, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- new JSeparator(JSeparator.HORIZONTAL), 0, 3, 3, 1, 1.0, 0.0, 5,
- 10, 0, 10, GridBagConstraints.HORIZONTAL,
- GridBagConstraints.CENTER);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- labelFindBottom, 0, 4, 1, 1, 0.0, 0.0, 5, 10, 5, 10,
- GridBagConstraints.NONE, GridBagConstraints.WEST);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- buttonFindScrollDown, 1, 4, 1, 1, 1.0, 0.0, 5, 5, 5, 5,
- GridBagConstraints.NONE, GridBagConstraints.CENTER);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings,
- buttonAddFinding, 2, 4, 1, 1, 0.0, 0.0, 5, 5, 5, 10,
- GridBagConstraints.NONE, GridBagConstraints.EAST);
-
- GUITools.addComponent(tabPanelFindings, gblBaseFindings, findScrllPn,
- 3, 0, 1, 5, 0.0, 1.0, 5, 0, 5, 5, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
- }
-
- /**
- * Update panel findings.
- */
- public void updatePanelFindings() {
- panelFindings.removeAll();
- visibleFList.clear();
-
- /*
- * Calculate number of shown findings from the window size
- */
- visibleFindingsCount = (int) ((panelFindings.getSize().getHeight()) / 270);
-
- if (visibleFindingsCount < 1) {
- visibleFindingsCount = 1;
- }
-
- /*
- * Check validity of first visible finding
- */
- if (firstVisibleFinding > findMgmt.getNumberOfFindings(currentProt)
- - visibleFindingsCount) {
- firstVisibleFinding = findMgmt.getNumberOfFindings(currentProt)
- - visibleFindingsCount;
- }
-
- if (firstVisibleFinding < 0) {
- firstVisibleFinding = 0;
- }
-
- /*
- * Update labels at bottom and top
- */
- labelFindTop.setText(firstVisibleFinding
- + " "
- + Data.getInstance()
- .getLocaleStr("editProtocol.findingsBefore"));
-
- labelFindBottom
- .setText(findMgmt.getNumberOfFindings(currentProt)
- - firstVisibleFinding
- - visibleFindingsCount
- + " "
- + Data.getInstance().getLocaleStr(
- "editProtocol.findingsAfter"));
-
- /*
- * If no finding exist
- */
- while (findMgmt.getNumberOfFindings(currentProt) < visibleFindingsCount) {
- findMgmt.addFinding(new Finding(), currentProt);
- }
-
- int lastVisibleFinding = firstVisibleFinding + visibleFindingsCount;
-
- if (lastVisibleFinding > findMgmt.getNumberOfFindings(currentProt)) {
- lastVisibleFinding = findMgmt.getNumberOfFindings(currentProt) - 1;
- }
-
- for (int i = firstVisibleFinding; i < lastVisibleFinding; i++) {
- Finding find = findMgmt.getFindings(currentProt).get(i);
-
- FindingItem fi = new FindingItem(find, currentProt);
-
- /*
- * Separator
- */
- if (i > firstVisibleFinding) {
- GUITools.addComponent(panelFindings, gblFindings,
- new JSeparator(JSeparator.HORIZONTAL), 0,
- 2 * (i - firstVisibleFinding), 1, 1, 1.0, 0.0, 5, 5, 5,
- 5, GridBagConstraints.HORIZONTAL,
- GridBagConstraints.NORTHWEST);
- }
-
- GUITools
- .addComponent(panelFindings, gblFindings, fi, 0,
- (2 * (i - firstVisibleFinding)) + 1, 1, 1, 1.0,
- 1.0, 5, 5, 5, 5, GridBagConstraints.BOTH,
- GridBagConstraints.NORTHWEST);
-
- visibleFList.add(fi);
- }
-
- updateFocus();
-
- /*
- * Update buttons
- */
- if (firstVisibleFinding == 0) {
- buttonFindScrollUp.setEnabled(false);
- } else {
- buttonFindScrollUp.setEnabled(true);
- }
-
- if (findMgmt.getNumberOfFindings(currentProt) - visibleFindingsCount == firstVisibleFinding) {
- buttonFindScrollDown.setEnabled(false);
- } else {
- buttonFindScrollDown.setEnabled(true);
- }
-
- updateAddFindBttn();
-
- tabPanelFindings.revalidate();
- panelFindings.revalidate();
-
- tabPanelFindings.repaint();
- panelFindings.repaint();
-
- /*
- * Fit the size of the scroll pane with the findings
- */
- int lastIdLength = Integer.toString(
- Application.getInstance().getFindingMgmt().getLastId())
- .length();
-
- Dimension dim = new Dimension(34 + (lastIdLength * 12), 100);
-
- findScrllPn.setMinimumSize(dim);
- findScrllPn.setPreferredSize(dim);
- }
-
- /**
* Resets the clock.
*/
public void resetClock() {
@@ -1640,25 +1248,6 @@
createHints();
- panelFindings.addComponentListener(new ComponentListener() {
- @Override
- public void componentHidden(ComponentEvent e) {
- }
-
- @Override
- public void componentMoved(ComponentEvent e) {
- }
-
- @Override
- public void componentResized(ComponentEvent e) {
- updatePanelFindings();
- }
-
- @Override
- public void componentShown(ComponentEvent e) {
- }
- });
-
addWindowListener(new WindowListener() {
@Override
public void windowActivated(WindowEvent e) {
@@ -1687,7 +1276,7 @@
if (option == JOptionPane.YES_OPTION) {
new ImageEditorWriteWorker(currentProt).execute();
-
+
UI.getInstance().getProtocolFrame().setVisible(false);
} else if (option == JOptionPane.NO_OPTION) {
UI.getInstance().getProtocolFrame().setVisible(false);
@@ -1746,25 +1335,26 @@
*/
@Override
public void update(Observable o, Object arg) {
- updateHints();
- updateAddFindBttn();
-
- if (protMgmt.isProtocolComplete(currentProt)) {
- tbCsvExport.setEnabled(true);
- tbPdfExport.setEnabled(true);
- tbConfirmProt.setVisible(true);
- tbExitProt.setVisible(false);
- } else {
- tbCsvExport.setEnabled(false);
- tbPdfExport.setEnabled(false);
- tbConfirmProt.setVisible(false);
- tbExitProt.setVisible(true);
- }
-
- if (revMgmt.isReviewConfirmable()) {
- recBx.setEnabled(true);
- } else {
- recBx.setEnabled(false);
+ if (bodyCreated) {
+ updateHints();
+
+ if (protMgmt.isProtocolComplete(currentProt)) {
+ tbCsvExport.setEnabled(true);
+ tbPdfExport.setEnabled(true);
+ tbConfirmProt.setVisible(true);
+ tbExitProt.setVisible(false);
+ } else {
+ tbCsvExport.setEnabled(false);
+ tbPdfExport.setEnabled(false);
+ tbConfirmProt.setVisible(false);
+ tbExitProt.setVisible(true);
+ }
+
+ if (revMgmt.isReviewConfirmable()) {
+ recBx.setEnabled(true);
+ } else {
+ recBx.setEnabled(false);
+ }
}
}
@@ -1842,25 +1432,6 @@
return false;
}
- /**
- * Update add find bttn.
- */
- public void updateAddFindBttn() {
-
- boolean isNotComplete = false;
-
- for (Finding find : findMgmt.getFindings(currentProt))
- if (findMgmt.isFindingNotComplete(find))
- isNotComplete = true;
-
- if (isNotComplete) {
- buttonAddFinding.setEnabled(false);
- } else {
- buttonAddFinding.setEnabled(true);
- }
-
- }
-
private long updateTime = System.currentTimeMillis();
private KeyListener updateListener = new KeyListener() {
@Override
@@ -2173,70 +1744,14 @@
setHints(hints);
}
- /**
- * Update table.
- */
- public void updateTable() {
- int selRow = findTbl.getSelectedRow();
-
- findTbl.scrollRectToVisible(findTbl.getCellRect(selRow, 0, false));
- }
-
- /**
- * Sets the selection row.
- */
- public void setSelectionRow() {
- findTbl.setRowSelectionInterval(firstVisibleFinding,
- firstVisibleFinding);
- }
-
- /**
- * Updates the focus of the findings.
- */
- public void updateFocus() {
- updateFocus(null, null);
- }
-
- /**
- * Updates the focus of the findings.
- */
- public void updateFocus(Finding focusedFinding, Object eventSource) {
- if (eventSource != null && eventSource instanceof Component) {
- ((Component) eventSource).requestFocusInWindow();
- }
-
- if (focusedFinding != null) {
- editingFinding = focusedFinding;
- }
-
- for (Component comp : panelFindings.getComponents()) {
- if (comp instanceof FindingItem) {
- FindingItem fi = ((FindingItem) comp);
-
- fi.updateFocus(eventSource);
-
- if (visibleFindingsCount > 1
- && editingFinding != null
- && fi.getCurrentFinding().getId() == editingFinding
- .getId()) {
- fi.setBorder(new MatteBorder(1, 5, 1, 5, new Color(0, 132,
- 209)));
- fi.setBackground(UI.TABLE_ALT_COLOR);
- } else {
- fi.setBorder(new EmptyBorder(1, 5, 1, 5));
- fi.setBackground(UIManager.getColor("JPanel.background"));
- }
- }
- }
- }
-
public ImageEditorDialog getImageEditor(File image) {
String imagePath = image.getAbsolutePath();
ImageEditorDialog editor = imageEditors.get(imagePath);
if (editor == null) {
- editor = new ImageEditorDialog(UI.getInstance().getProtocolFrame(), image);
+ editor = new ImageEditorDialog(UI.getInstance().getProtocolFrame(),
+ image);
imageEditors.put(imagePath, editor);
}
@@ -2247,11 +1762,5 @@
public Map<String, ImageEditorDialog> getImageEditors() {
return imageEditors;
}
-
- private void saveEditRefs(){
- for (FindingItem findI:visibleFList)
- if(tabPanelFindings.isVisible()&&findI.isCellEditing())
- findI.saveRef();
- }
}
=== modified file 'src/org/revager/resources/localeStrings_de.properties'
--- src/org/revager/resources/localeStrings_de.properties 2010-01-31 17:32:35 +0000
+++ src/org/revager/resources/localeStrings_de.properties 2010-05-27 20:33:41 +0000
@@ -937,3 +937,20 @@
message.csvNoFindingsExist=Es existieren keine Befunde zum Exportieren in eine CSV-Datei.
message.invitationZipFileWriteFailed=Das Einladungspaket konnte nicht als ZIP-Datei gespeichert werden.
message.invitationDirWriteFailed=Das Einladungspaket konnte nicht als Verzeichnis gespeichert werden.
+
+
+
+######################################
+## Findings List in Protocol Window ##
+######################################
+
+findingsList.pushUp=Befund nach oben verschieben
+findingsList.pushDown=Befund nach unten verschieben
+findingsList.pushTop=Als ersten Befund in der Liste positionieren
+findingsList.pushBottom=Als letzten Befund in der Liste positionieren
+findingsList.remove=Befund entfernen
+findingsList.close=Bearbeitungsansicht des Befundes schließen
+findingsList.aspects=Prüfaspekt(e)
+findingsList.references=Referenz(en)
+findingsList.files=Datei(en)
+findingsList.confirmRemoval=Sind Sie sicher den gewählten Befund dauerhaft zu löschen?
\ No newline at end of file
=== modified file 'src/org/revager/resources/localeStrings_en.properties'
--- src/org/revager/resources/localeStrings_en.properties 2010-01-31 17:32:35 +0000
+++ src/org/revager/resources/localeStrings_en.properties 2010-05-27 20:33:41 +0000
@@ -931,3 +931,19 @@
message.invitationZipFileWriteFailed=Couldn't save invitations as ZIP-file.
message.invitationDirWriteFailed=Couldn't save invitation as directory.
+
+
+######################################
+## Findings List in Protocol Window ##
+######################################
+
+findingsList.pushUp=Push up finding
+findingsList.pushDown=Push down finding
+findingsList.pushTop=Push finding to top
+findingsList.pushBottom=Push finding to bottom
+findingsList.remove=Remove this finding
+findingsList.close=Close edit view of this finding
+findingsList.aspects=Aspect(s)
+findingsList.references=Reference(s)
+findingsList.files=File(s)
+findingsList.confirmRemoval=Are you sure you want to remove the selected finding permanently?
\ No newline at end of file
Follow ups