00001 /* 00002 * CalibrationPanel.java 00003 * 00004 * Copyright (C) 2005 Project SQUID, http://www.cs.helsinki.fi/group/squid/ 00005 * 00006 * This file is part of Ikayaki. 00007 * 00008 * Ikayaki is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * Ikayaki is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Ikayaki; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 package ikayaki.gui; 00024 00025 import ikayaki.Ikayaki; 00026 import ikayaki.Project; 00027 00028 import javax.swing.*; 00029 import java.awt.*; 00030 import java.io.File; 00031 00039 public class CalibrationPanel extends ProjectComponent { 00040 00041 /* -- in MeasurementControlsPanel -- 00042 * Event A: On calibrateButton click - call project.doSingleStep(); show error message if 00043 * false is returned. 00044 */ 00045 00046 /* -- in ProjectExplorerTable -- 00047 * Event B: On calibrationProjectTable click - call Project.loadProject(File) with clicked 00048 * project file (calibrationProjectTable row); call MainViewPanel.changeProject(Project) with 00049 * returned Project unless null, on which case show error message and revert calibrationProjectTable 00050 * selection to old project, if any. 00051 */ 00052 00053 /* -- in ProjectExplorerTable and MeasurementControlsPanel -- 00054 * Event C: On ProjectEvent - highlight calibration project whose measuring started, or 00055 * unhighlight one whose measuring ended; enable calibrateButton if measuring has ended, 00056 * or disable if measuring has started. 00057 */ 00058 00062 private ProjectComponent parent; 00063 00067 private File directory; 00068 00073 private ProjectExplorerTable calibrationProjectTable; 00074 00075 private JButton calibrateButton; 00076 00077 private JPanel calibratePanel; 00078 00084 public CalibrationPanel(ProjectComponent parent) { 00085 this.parent = parent; 00086 this.directory = Ikayaki.CALIBRATION_PROJECT_DIR; 00087 00088 calibrationProjectTable = new ProjectExplorerTable(this.parent, true); 00089 // done by setProject(null) 00090 // calibrationProjectTable.setDirectory(this.directory); 00091 00092 calibrateButton = new JButton(((MainViewPanel) parent).getMeasurementControlsPanel().getCalibrateAction()); 00093 00094 calibratePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2)); 00095 calibratePanel.add(calibrateButton); 00096 00097 // emulate the looks of a JScrollPane 00098 JPanel tablePanel = new JPanel(new BorderLayout()); 00099 tablePanel.add(calibrationProjectTable.getTableHeader(), BorderLayout.NORTH); 00100 tablePanel.add(calibrationProjectTable, BorderLayout.CENTER); 00101 tablePanel.setBorder(new JScrollPane().getBorder()); 00102 00103 this.setLayout(new BorderLayout()); 00104 this.add(tablePanel, BorderLayout.CENTER); 00105 this.add(calibratePanel, BorderLayout.SOUTH); 00106 00107 // initialize with no project 00108 setProject(null); 00109 } 00110 00117 public void setProject(Project project) { 00118 super.setProject(project); 00119 calibrationProjectTable.setDirectory(this.directory); 00120 00121 // add calibrationProjectTable as a ProjectListener so it can update current project's timestamps 00122 if (project != null) project.addProjectListener(calibrationProjectTable); 00123 } 00124 }