damus-commit Mailing List for damus
Brought to you by:
dbrosius
You can subscribe to this list here.
2010 |
Jan
|
Feb
(12) |
Mar
(35) |
Apr
|
May
|
Jun
(33) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2011-08-03 10:31:18
|
Revision: 83 http://damus.svn.sourceforge.net/damus/?rev=83&view=rev Author: dbrosius Date: 2011-08-03 10:31:09 +0000 (Wed, 03 Aug 2011) Log Message: ----------- add proxy support Modified Paths: -------------- trunk/damus/.classpath trunk/damus/build.xml trunk/damus/damus.fb trunk/damus/etc/damus.jnlp trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java trunk/damus/src/com/mebigfatguy/damus/gui/NewModelPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/TrainingValueCellEditor.java trunk/damus/src/com/mebigfatguy/damus/gui/TrainingValueCellRenderer.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelNewModelAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/ModelAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java trunk/damus/src/com/mebigfatguy/damus/gui/model/MetricsTableModel.java trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java Removed Paths: ------------- trunk/damus/lib/commons-math-2.1-SNAPSHOT.jar Modified: trunk/damus/.classpath =================================================================== --- trunk/damus/.classpath 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/.classpath 2011-08-03 10:31:09 UTC (rev 83) @@ -2,6 +2,6 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="lib/commons-math-2.1-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="lib/commons-math-2.2.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/damus/build.xml =================================================================== --- trunk/damus/build.xml 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/build.xml 2011-08-03 10:31:09 UTC (rev 83) @@ -1,181 +1,161 @@ -<!-- -/* - * damus - a forecasting tool - * Copyright (C) 2010 Dave Brosius - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. - */ - --> +<!-- /* * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed + on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and limitations * under the License. */ --> <project name="damus" default="jar"> - - <property file="build.properties"/> - - <property name="src.dir" value="${basedir}/src"/> - <property name="classes.dir" value="${basedir}/classes"/> - <property name="lib.dir" value="${basedir}/lib"/> - <property name="etc.dir" value="${basedir}/etc"/> - <property name="htdocs.dir" value="${basedir}/htdocs"/> - <property name="jnlp.dir" value="${htdocs.dir}/jnlp"/> - <property name="javadoc.dir" value="${htdocs.dir}/javadoc"/> - <property name="javac.source" value="1.6"/> - <property name="javac.target" value="1.6"/> - <property name="javac.deprecation" value="on"/> - <property name="javac.debug" value="on"/> - - <property name="damus.version" value="0.1.0"/> - + + <property file="build.properties" /> + + <property name="src.dir" value="${basedir}/src" /> + <property name="classes.dir" value="${basedir}/classes" /> + <property name="lib.dir" value="${basedir}/lib" /> + <property name="etc.dir" value="${basedir}/etc" /> + <property name="htdocs.dir" value="${basedir}/htdocs" /> + <property name="jnlp.dir" value="${htdocs.dir}/jnlp" /> + <property name="javadoc.dir" value="${htdocs.dir}/javadoc" /> + <property name="javac.source" value="1.6" /> + <property name="javac.target" value="1.6" /> + <property name="javac.deprecation" value="on" /> + <property name="javac.debug" value="on" /> + + <property name="damus.version" value="0.1.0" /> + + <property name="commons-math.version" value="2.2" /> + <target name="clean" description="removes all generated collateral"> - <delete dir="${classes.dir}"/> - <delete dir="${javadoc.dir}"/> + <delete dir="${classes.dir}" /> + <delete dir="${javadoc.dir}" /> <delete> <fileset dir="${jnlp.dir}"> - <include name="damus*.jar"/> - <include name="*.jnlp"/> + <include name="damus*.jar" /> + <include name="*.jnlp" /> </fileset> </delete> <delete> - <fileset dir="${basedir}" includes="*.zip"/> - </delete> + <fileset dir="${basedir}" includes="*.zip" /> + </delete> </target> - + <target name="-init" description="prepares repository for a build"> - <mkdir dir="${classes.dir}"/> - <mkdir dir="${javadoc.dir}"/> + <mkdir dir="${classes.dir}" /> + <mkdir dir="${lib.dir}" /> + <mkdir dir="${javadoc.dir}" /> <path id="damus.classpath"> - <pathelement location="${lib.dir}/commons-math-2.1.SNAPSHOT.jar"/> + <pathelement location="${lib.dir}/commons-math-${commons-math.version}.jar" /> </path> </target> - - <target name="compile" depends="-init" description="compiles java files"> - <javac srcdir="${src.dir}" - destdir="${classes.dir}" - source="${javac.source}" - target="${javac.target}" - deprecation="${javac.deprecation}" - debug="${javac.debug}"> - <classpath refid="damus.classpath"/> + + <property name="commons-math_url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-math/${commons-math.version}/commons-math-${commons-math.version}.jar" /> + + <target name="commons-math_check"> + <available file="${lib.dir}/commons-math-${commons-math.version}.jar" property="commons-math.exists" /> + </target> + + <target name="install_commons-math" depends="commons-math_check" unless="commons-math.exists" description="installs commons-math.jar into lib"> + <get src="${commons-math_url}" dest="${basedir}/lib/commons-math-${commons-math.version}.jar" verbose="true" ignoreerrors="false" /> + </target> + + <target name="pull" depends="install_commons-math" description="pulls in the 3rd party jars"> + </target> + + <target name="compile" depends="-init, pull" description="compiles java files"> + <javac srcdir="${src.dir}" destdir="${classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> + <classpath refid="damus.classpath" /> </javac> </target> - + <target name="resources" depends="-init" description="copies required files"> <copy todir="${classes.dir}"> <fileset dir="${src.dir}"> - <include name="**/*.properties"/> + <include name="**/*.properties" /> </fileset> </copy> - <echo message="${damus.version}" file="${classes.dir}/com/mebigfatguy/damus/io/Version.txt"/> + <echo message="${damus.version}" file="${classes.dir}/com/mebigfatguy/damus/io/Version.txt" /> <copy todir="${jnlp.dir}"> <fileset dir="${etc.dir}"> - <include name="*.jnlp"/> + <include name="*.jnlp" /> </fileset> </copy> <replaceregexp byline="true"> - <regexp pattern="\$VERSION"/> - <substitution expression="${damus.version}"/> - <fileset dir="${jnlp.dir}"> - <include name="*.jnlp"/> - </fileset> - </replaceregexp> + <regexp pattern="\$VERSION" /> + <substitution expression="${damus.version}" /> + <fileset dir="${jnlp.dir}"> + <include name="*.jnlp" /> + </fileset> + </replaceregexp> </target> - + <target name="jar" depends="compile, resources" description="produces the damus jar file"> <jar destfile="${jnlp.dir}/damus-${damus.version}.jar"> <fileset dir="${classes.dir}"> - <include name="**/*.class"/> - <include name="**/*.properties"/> - <include name="**/*.gif"/> - <include name="**/*.xsd"/> - <include name="**/*.xsl"/> - <include name="**/*.txt"/> - <include name="**/*.jpg"/> + <include name="**/*.class" /> + <include name="**/*.properties" /> + <include name="**/*.gif" /> + <include name="**/*.xsd" /> + <include name="**/*.xsl" /> + <include name="**/*.txt" /> + <include name="**/*.jpg" /> </fileset> <fileset dir="${basedir}"> - <include name="license.txt"/> + <include name="license.txt" /> </fileset> <manifest> - <attribute name="damus-version" value="${damus.version}"/> - <attribute name="Main-Class" value="com.mebigfatguy.damus.main.PatchMain"/> - <attribute name="Class-Path" value="xml-apis.jar xalan.jar xercesImpl.jar serializer.jar"/> + <attribute name="damus-version" value="${damus.version}" /> + <attribute name="Main-Class" value="com.mebigfatguy.damus.main.PatchMain" /> + <attribute name="Class-Path" value="xml-apis.jar xalan.jar xercesImpl.jar serializer.jar" /> </manifest> - </jar> + </jar> </target> - + <target name="srczip" description="builds the source distribution zip file"> - <zip destfile="${basedir}/damus-src-${damus.version}.zip" - basedir="${basedir}" - includes="src/**/*.java, src/**/*.properties, src/**/*.gif, src/**/*.xsd, src/**/*.xsl, lib/**/*.jar, *.txt"/> + <zip destfile="${basedir}/damus-src-${damus.version}.zip" basedir="${basedir}" includes="src/**/*.java, src/**/*.properties, src/**/*.gif, src/**/*.xsd, src/**/*.xsl, lib/**/*.jar, *.txt" /> </target> - + <target name="javadoc" depends="-init" description="build the javadoc for the project"> - <javadoc packagenames="com.mebigfatguy.*" - sourcepath="${src.dir}" - classpathref="damus.classpath" - destdir="${javadoc.dir}" - windowtitle="damus api"> - <doctitle><![CDATA[<h1>damus javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2008-2010 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="damus.classpath" destdir="${javadoc.dir}" windowtitle="damus api"> + <doctitle><![CDATA[<h1>damus javadoc</h1>]]></doctitle> + <bottom><![CDATA[<i>Copyright © 2008-2010 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> - + <target name="test" depends="-init, compile, resources" description="runs unit tests"> <path id="damustest.classpath"> - <pathelement location="${classes.dir}"/> + <pathelement location="${classes.dir}" /> </path> - <junit - printsummary="true" - haltonfailure="true" - haltonerror="true" - showoutput="true" - fork="true"> + <junit printsummary="true" haltonfailure="true" haltonerror="true" showoutput="true" fork="true"> - <classpath><path refid="damustest.classpath"/></classpath> - <batchtest fork="true"> - <fileset dir="${classes.dir}" - excludes="test/*$*" - includes="test/*"/> - </batchtest> - </junit> + <classpath> + <path refid="damustest.classpath" /> + </classpath> + <batchtest fork="true"> + <fileset dir="${classes.dir}" excludes="test/*$*" includes="test/*" /> + </batchtest> + </junit> </target> - - <target name="build" depends="clean, -init, compile, resources, test, jar" description="builds the damus jar"/> - + + <target name="build" depends="clean, -init, compile, resources, test, jar" description="builds the damus jar" /> + <target name="jnlp" description="copy jars to jnlp directory"> <copy todir="${jnlp.dir}"> <fileset dir="${lib.dir}"> - <include name="*.jar"/> + <include name="*.jar" /> </fileset> <fileset dir="${basedir}"> - <include name="*.jar"/> + <include name="*.jar" /> </fileset> </copy> - <input message="Enter keystore password" addproperty="pass"/> - <signjar keystore="damus.store" - alias="damus" - keypass="${pass}" - storepass="${pass}"> - <fileset dir="${jnlp.dir}"> - <include name="*.jar"/> + <input message="Enter keystore password" addproperty="pass" /> + <signjar keystore="damus.store" alias="damus" keypass="${pass}" storepass="${pass}"> + <fileset dir="${jnlp.dir}"> + <include name="*.jar" /> </fileset> </signjar> </target> - + <target name="binzip" depends="build" description="zips up all jars"> - <zip destfile="${basedir}/damus-bin-${damus.version}.zip" - basedir="${jnlp.dir}" - includes="damus-${damus.version}.jar commons-math-2.1.SNAPSHOT"/> + <zip destfile="${basedir}/damus-bin-${damus.version}.zip" basedir="${jnlp.dir}" includes="damus-${damus.version}.jar commons-math-2.1.SNAPSHOT" /> </target> - - <target name="release" depends="build, jnlp, binzip, srczip, javadoc" description="prepares everything for a release"/> + <target name="release" depends="build, jnlp, binzip, srczip, javadoc" description="prepares everything for a release" /> + </project> \ No newline at end of file Modified: trunk/damus/damus.fb =================================================================== --- trunk/damus/damus.fb 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/damus.fb 2011-08-03 10:31:09 UTC (rev 83) @@ -3,6 +3,6 @@ [Source dirs] ./src [Aux classpath entries] -./lib/commons-math-2.1-SNAPSHOT.jar +./lib/commons-math-2.2.jar [Options] relative_paths=true Modified: trunk/damus/etc/damus.jnlp =================================================================== --- trunk/damus/etc/damus.jnlp 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/etc/damus.jnlp 2011-08-03 10:31:09 UTC (rev 83) @@ -17,7 +17,7 @@ <resources> <j2se version="1.6+" initial-heap-size="200m"/> <jar href="damus-$VERSION.jar"/> - <jar href="commons-math-2.1.SNAPSHOT.jar"/> + <jar href="commons-math-2.2.jar"/> </resources> <application-desc main-class="com.mebigfatguy.damus.main.Damus"/> </jnlp> Deleted: trunk/damus/lib/commons-math-2.1-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,94 +2,95 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.data; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; import com.mebigfatguy.damus.main.Context; public class TrainingItem implements Cloneable { - private String itemDescription; - private Map<Metric, Object> metricData = new HashMap<Metric, Object>(); - - public TrainingItem() { - PredictionModel model = Context.instance().getPredictionModel(); - if (model != null) { - int numMetrics = model.getNumMetrics(); - for (int i = 0; i < numMetrics; i++) { - Metric metric = model.getMetric(i); - switch (metric.getType()) { - case Percent: - metricData.put(metric, Integer.valueOf(50)); - break; - - case Real: - metricData.put(metric, Double.valueOf(0)); - break; - - case YesNo: - metricData.put(metric, Boolean.FALSE); - break; - } - } - int numResults = model.getNumResults(); - for (int i = 0; i < numResults; i++) { - Metric metric = model.getResult(i); - switch (metric.getType()) { - case Percent: - metricData.put(metric, Integer.valueOf(50)); - break; - - case Real: - metricData.put(metric, Double.valueOf(0)); - break; - - case YesNo: - metricData.put(metric, Boolean.FALSE); - break; - } - } - } - } - - public void setDescription(String description) { - itemDescription = description; - } - - public String getDescription() { - return itemDescription; - } - - public Object getValue(Metric metric) { - return metricData.get(metric); - } - - public void setValue(Metric metric, Object value) { - metricData.put(metric, value); - } - - @Override - public Object clone() { - try { - TrainingItem clone = (TrainingItem)super.clone(); - clone.metricData = new HashMap<Metric, Object>(metricData); - - return clone; - } catch (CloneNotSupportedException cnse) { - throw new Error("Clone Not Supported on TrainingItem"); - } - } + private String itemDescription; + private Map<Metric, Object> metricData = new HashMap<Metric, Object>(); + + public TrainingItem() { + PredictionModel model = Context.instance().getPredictionModel(); + if (model != null) { + int numMetrics = model.getNumMetrics(); + for (int i = 0; i < numMetrics; i++) { + Metric metric = model.getMetric(i); + switch (metric.getType()) { + case Percent: + metricData.put(metric, Integer.valueOf(50)); + break; + + case Real: + metricData.put(metric, new BigDecimal("0")); + break; + + case YesNo: + metricData.put(metric, Boolean.FALSE); + break; + } + } + int numResults = model.getNumResults(); + for (int i = 0; i < numResults; i++) { + Metric metric = model.getResult(i); + switch (metric.getType()) { + case Percent: + metricData.put(metric, Integer.valueOf(50)); + break; + + case Real: + metricData.put(metric, new BigDecimal(0)); + break; + + case YesNo: + metricData.put(metric, Boolean.FALSE); + break; + } + } + } + } + + public void setDescription(String description) { + itemDescription = description; + } + + public String getDescription() { + return itemDescription; + } + + public Object getValue(Metric metric) { + return metricData.get(metric); + } + + public void setValue(Metric metric, Object value) { + metricData.put(metric, value); + } + + @Override + public Object clone() { + try { + TrainingItem clone = (TrainingItem)super.clone(); + clone.metricData = new HashMap<Metric, Object>(metricData); + + return clone; + } catch (CloneNotSupportedException cnse) { + throw new Error("Clone Not Supported on TrainingItem"); + } + } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,17 +2,17 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.gui; @@ -41,140 +41,139 @@ public class DamusFrame extends JFrame implements PanelViewer { - private static final long serialVersionUID = 69030272254787759L; - - private JMenu fileMenu; - private JTabbedPane tabPane; - private JMenuItem newItem; - private JMenuItem openItem; - private JMenuItem closeItem; - private JMenuItem saveItem; - private JMenuItem saveAsItem; - private JMenuItem quitItem; - - private JMenu dataMenu; - private JCheckBoxMenuItem modelItem; - private JCheckBoxMenuItem reviewItem; - private JCheckBoxMenuItem trainItem; - private JCheckBoxMenuItem predictItem; - - private final EnumMap<PanelType, JPanel> panels = new EnumMap<PanelType, JPanel>(PanelType.class); - - public DamusFrame() { - initComponents(); - initMenus(); - setTitle(DamusBundle.getString(DamusBundle.TITLE)); - setSize(800, 600); - //TODO: For now just close - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - } + private static final long serialVersionUID = 69030272254787759L; - private final void initComponents() { - Container cp = getContentPane(); - tabPane = new JTabbedPane(); - cp.add(tabPane); - } + private JTabbedPane tabPane; + private JMenuItem newItem; + private JMenuItem openItem; + private JMenuItem closeItem; + private JMenuItem saveItem; + private JMenuItem saveAsItem; - private final void initMenus() { - JMenuBar mb = new JMenuBar(); - - fileMenu = new JMenu(DamusBundle.getString(DamusBundle.FILE)); - newItem = new JMenuItem(new NewAction(this)); - fileMenu.add(newItem); - openItem = new JMenuItem(new OpenAction(this)); - fileMenu.add(openItem); - closeItem = new JMenuItem(new CloseAction(this)); - fileMenu.add(closeItem); - fileMenu.addSeparator(); - saveItem = new JMenuItem(new SaveAction()); - fileMenu.add(saveItem); - saveAsItem = new JMenuItem(new SaveAsAction()); - fileMenu.add(saveAsItem); - fileMenu.addSeparator(); - quitItem = new JMenuItem(new QuitAction()); - fileMenu.add(quitItem); - mb.add(fileMenu); - - dataMenu = new JMenu(DamusBundle.getString(DamusBundle.DATA)); - modelItem = new JCheckBoxMenuItem(new ModelAction(this)); - dataMenu.add(modelItem); - reviewItem = new JCheckBoxMenuItem(new ReviewAction(this)); - dataMenu.add(reviewItem); - trainItem = new JCheckBoxMenuItem(new TrainNewAction(this)); - dataMenu.add(trainItem); - predictItem = new JCheckBoxMenuItem(new PredictAction(this)); - dataMenu.add(predictItem); - dataMenu.setEnabled(false); - mb.add(dataMenu); - - markModelClosed(); - - setJMenuBar(mb); + private JMenu dataMenu; + private JCheckBoxMenuItem modelItem; + private JCheckBoxMenuItem reviewItem; + private JCheckBoxMenuItem trainItem; + private JCheckBoxMenuItem predictItem; + + private final EnumMap<PanelType, JPanel> panels = new EnumMap<PanelType, JPanel>(PanelType.class); + + public DamusFrame() { + initComponents(); + initMenus(); + setTitle(DamusBundle.getString(DamusBundle.TITLE)); + setSize(800, 600); + //TODO: For now just close + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } - - @Override - public void openPanel(PanelType type, JPanel panel, boolean shared) { - if (!shared) { - tabPane.removeAll(); - } - - tabPane.add(type.toString(), panel); - panels.put(type, panel); - - if (type == PanelType.NEWMODEL) - markModelOpen(); - - selectPanelMenus(); - - tabPane.setSelectedComponent(panel); - - } - - @Override - public void closePanel(PanelType type) { - JPanel panel = panels.get(type); - if (panel != null) { - tabPane.remove(panel); - panels.remove(type); - } - - selectPanelMenus(); - } - - @Override - public void closeAllPanels() { - for (PanelType type : panels.keySet()) { - closePanel(type); - } - - selectPanelMenus(); - markModelClosed(); - } - - private void selectPanelMenus() { - newItem.setSelected(panels.containsKey(PanelType.NEWMODEL)); - reviewItem.setSelected(panels.containsKey(PanelType.REVIEW)); - trainItem.setSelected(panels.containsKey(PanelType.TRAINMODEL)); - predictItem.setSelected(panels.containsKey(PanelType.PREDICTMODEL)); - } - - public void markModelOpen() { - newItem.setEnabled(false); - openItem.setEnabled(false); - closeItem.setEnabled(true); - saveItem.setEnabled(true); - saveAsItem.setEnabled(true); - dataMenu.setEnabled(true); - modelItem.setSelected(true); - } - - public void markModelClosed() { - newItem.setEnabled(true); - openItem.setEnabled(true); - closeItem.setEnabled(false); - saveItem.setEnabled(false); - saveAsItem.setEnabled(false); - dataMenu.setEnabled(false); - modelItem.setSelected(false); - } + + private final void initComponents() { + Container cp = getContentPane(); + tabPane = new JTabbedPane(); + cp.add(tabPane); + } + + private final void initMenus() { + JMenuBar mb = new JMenuBar(); + + JMenu fileMenu = new JMenu(DamusBundle.getString(DamusBundle.FILE)); + newItem = new JMenuItem(new NewAction(this)); + fileMenu.add(newItem); + openItem = new JMenuItem(new OpenAction(this)); + fileMenu.add(openItem); + closeItem = new JMenuItem(new CloseAction(this)); + fileMenu.add(closeItem); + fileMenu.addSeparator(); + saveItem = new JMenuItem(new SaveAction()); + fileMenu.add(saveItem); + saveAsItem = new JMenuItem(new SaveAsAction()); + fileMenu.add(saveAsItem); + fileMenu.addSeparator(); + JMenuItem quitItem = new JMenuItem(new QuitAction()); + fileMenu.add(quitItem); + mb.add(fileMenu); + + dataMenu = new JMenu(DamusBundle.getString(DamusBundle.DATA)); + modelItem = new JCheckBoxMenuItem(new ModelAction(this)); + dataMenu.add(modelItem); + reviewItem = new JCheckBoxMenuItem(new ReviewAction(this)); + dataMenu.add(reviewItem); + trainItem = new JCheckBoxMenuItem(new TrainNewAction(this)); + dataMenu.add(trainItem); + predictItem = new JCheckBoxMenuItem(new PredictAction(this)); + dataMenu.add(predictItem); + dataMenu.setEnabled(false); + mb.add(dataMenu); + + markModelClosed(); + + setJMenuBar(mb); + } + + @Override + public void openPanel(PanelType type, JPanel panel, boolean shared) { + if (!shared) { + tabPane.removeAll(); + } + + tabPane.add(type.toString(), panel); + panels.put(type, panel); + + if (type == PanelType.NEWMODEL) { + markModelOpen(); + } + + selectPanelMenus(); + + tabPane.setSelectedComponent(panel); + + } + + @Override + public void closePanel(PanelType type) { + JPanel panel = panels.get(type); + if (panel != null) { + tabPane.remove(panel); + panels.remove(type); + } + + selectPanelMenus(); + } + + @Override + public void closeAllPanels() { + for (PanelType type : panels.keySet()) { + closePanel(type); + } + + selectPanelMenus(); + markModelClosed(); + } + + private void selectPanelMenus() { + newItem.setSelected(panels.containsKey(PanelType.NEWMODEL)); + reviewItem.setSelected(panels.containsKey(PanelType.REVIEW)); + trainItem.setSelected(panels.containsKey(PanelType.TRAINMODEL)); + predictItem.setSelected(panels.containsKey(PanelType.PREDICTMODEL)); + } + + public void markModelOpen() { + newItem.setEnabled(false); + openItem.setEnabled(false); + closeItem.setEnabled(true); + saveItem.setEnabled(true); + saveAsItem.setEnabled(true); + dataMenu.setEnabled(true); + modelItem.setSelected(true); + } + + public void markModelClosed() { + newItem.setEnabled(true); + openItem.setEnabled(true); + closeItem.setEnabled(false); + saveItem.setEnabled(false); + saveAsItem.setEnabled(false); + dataMenu.setEnabled(false); + modelItem.setSelected(false); + } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/NewModelPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/NewModelPanel.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/gui/NewModelPanel.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,17 +2,17 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.gui; @@ -37,121 +37,117 @@ import com.mebigfatguy.damus.gui.model.MetricsTableModel; public class NewModelPanel extends JPanel { - - private static final long serialVersionUID = 3740341073101896416L; - - private PanelViewer panelViewer; - private boolean newModel; - private JTable metricTable; - private JTable resultTable; - private JButton addMetricButton; - private JButton deleteMetricButton; - private JButton addResultButton; - private JButton deleteResultButton; - private JButton okButton; - private JButton cancelButton; - - public NewModelPanel(PanelViewer viewer, boolean showNewModel) { - panelViewer = viewer; - newModel = showNewModel; - initComponents(); - } - private void initComponents() { - setLayout(new BorderLayout(4, 4)); - - add(createModelPanel(), BorderLayout.CENTER); - - if (newModel) { - add(createCtrlPanel(), BorderLayout.SOUTH); - } - - GUIUtils.sizeUniformly(addMetricButton, deleteMetricButton, addResultButton, deleteResultButton); - } - - private JPanel createModelPanel() { - JPanel p = new JPanel(); - p.setLayout(new BorderLayout(4, 4)); - - JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - p.add(sp, BorderLayout.CENTER); - - JPanel metricsPanel = createMetricsPanel(); - JPanel resultsPanel = createResultsPanel(); - - sp.add(metricsPanel); - sp.add(resultsPanel); - sp.setDividerLocation(300); - return p; - } - - private JPanel createMetricsPanel() { - JPanel metricsPanel = new JPanel(); - metricsPanel.setLayout(new BorderLayout(4, 4)); - MetricsTableModel mtm = new MetricsTableModel(ForecastDataType.Metric); - - metricTable = new JTable(mtm); - TableColumn column = metricTable.getColumnModel().getColumn(1); - column.setCellEditor(new MetricTypeCellEditor()); - metricsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS)), BorderFactory.createEmptyBorder(10, 0, 10, 0))); - metricsPanel.add(new JScrollPane(metricTable), BorderLayout.CENTER); - - JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.Y_AXIS)); - ctrlPanel.add(Box.createVerticalGlue()); - addMetricButton = new JButton(new AddForecastDataTypeAction(metricTable, ForecastDataType.Metric)); - ctrlPanel.add(addMetricButton); - ctrlPanel.add(Box.createVerticalStrut(10)); - deleteMetricButton = new JButton(new DeleteForecastDataTypeAction(metricTable, ForecastDataType.Metric)); - ctrlPanel.add(deleteMetricButton); - ctrlPanel.add(Box.createVerticalGlue()); - ctrlPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); - metricsPanel.add(ctrlPanel, BorderLayout.EAST); - - return metricsPanel; - } - - private JPanel createResultsPanel() { - JPanel resultsPanel = new JPanel(); - resultsPanel.setLayout(new BorderLayout(4, 4)); - MetricsTableModel dtm = new MetricsTableModel(ForecastDataType.Result); - - resultTable = new JTable(dtm); - TableColumn column = resultTable.getColumnModel().getColumn(1); - column.setCellEditor(new MetricTypeCellEditor()); - resultsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.RESULTS)), BorderFactory.createEmptyBorder(10, 0, 10, 0))); - resultsPanel.add(new JScrollPane(resultTable), BorderLayout.CENTER); - - JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.Y_AXIS)); - ctrlPanel.add(Box.createVerticalGlue()); - addResultButton = new JButton(new AddForecastDataTypeAction(resultTable, ForecastDataType.Result)); - ctrlPanel.add(addResultButton); - ctrlPanel.add(Box.createVerticalStrut(10)); - deleteResultButton = new JButton(new DeleteForecastDataTypeAction(resultTable, ForecastDataType.Result)); - ctrlPanel.add(deleteResultButton); - ctrlPanel.add(Box.createVerticalGlue()); - ctrlPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); - resultsPanel.add(ctrlPanel, BorderLayout.EAST); - - return resultsPanel; - } - - private JPanel createCtrlPanel() { - JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); - - okButton = new JButton(new AcceptNewModelAction(panelViewer)); - cancelButton = new JButton(new CancelNewModelAction(panelViewer)); - - GUIUtils.sizeUniformly(okButton, cancelButton); - ctrlPanel.add(Box.createHorizontalGlue()); - ctrlPanel.add(okButton); - ctrlPanel.add(Box.createHorizontalStrut(10)); - ctrlPanel.add(cancelButton); - ctrlPanel.add(Box.createHorizontalGlue()); - - ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - return ctrlPanel; - } + private static final long serialVersionUID = 3740341073101896416L; + + private final PanelViewer panelViewer; + private final boolean newModel; + private JButton addMetricButton; + private JButton deleteMetricButton; + private JButton addResultButton; + private JButton deleteResultButton; + + public NewModelPanel(PanelViewer viewer, boolean showNewModel) { + panelViewer = viewer; + newModel = showNewModel; + initComponents(); + } + + private void initComponents() { + setLayout(new BorderLayout(4, 4)); + + add(createModelPanel(), BorderLayout.CENTER); + + if (newModel) { + add(createCtrlPanel(), BorderLayout.SOUTH); + } + + GUIUtils.sizeUniformly(addMetricButton, deleteMetricButton, addResultButton, deleteResultButton); + } + + private JPanel createModelPanel() { + JPanel p = new JPanel(); + p.setLayout(new BorderLayout(4, 4)); + + JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + p.add(sp, BorderLayout.CENTER); + + JPanel metricsPanel = createMetricsPanel(); + JPanel resultsPanel = createResultsPanel(); + + sp.add(metricsPanel); + sp.add(resultsPanel); + sp.setDividerLocation(300); + return p; + } + + private JPanel createMetricsPanel() { + JPanel metricsPanel = new JPanel(); + metricsPanel.setLayout(new BorderLayout(4, 4)); + MetricsTableModel mtm = new MetricsTableModel(ForecastDataType.Metric); + + JTable metricTable = new JTable(mtm); + TableColumn column = metricTable.getColumnModel().getColumn(1); + column.setCellEditor(new MetricTypeCellEditor()); + metricsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS)), BorderFactory.createEmptyBorder(10, 0, 10, 0))); + metricsPanel.add(new JScrollPane(metricTable), BorderLayout.CENTER); + + JPanel ctrlPanel = new JPanel(); + ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.Y_AXIS)); + ctrlPanel.add(Box.createVerticalGlue()); + addMetricButton = new JButton(new AddForecastDataTypeAction(metricTable, ForecastDataType.Metric)); + ctrlPanel.add(addMetricButton); + ctrlPanel.add(Box.createVerticalStrut(10)); + deleteMetricButton = new JButton(new DeleteForecastDataTypeAction(metricTable, ForecastDataType.Metric)); + ctrlPanel.add(deleteMetricButton); + ctrlPanel.add(Box.createVerticalGlue()); + ctrlPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + metricsPanel.add(ctrlPanel, BorderLayout.EAST); + + return metricsPanel; + } + + private JPanel createResultsPanel() { + JPanel resultsPanel = new JPanel(); + resultsPanel.setLayout(new BorderLayout(4, 4)); + MetricsTableModel dtm = new MetricsTableModel(ForecastDataType.Result); + + JTable resultTable = new JTable(dtm); + TableColumn column = resultTable.getColumnModel().getColumn(1); + column.setCellEditor(new MetricTypeCellEditor()); + resultsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.RESULTS)), BorderFactory.createEmptyBorder(10, 0, 10, 0))); + resultsPanel.add(new JScrollPane(resultTable), BorderLayout.CENTER); + + JPanel ctrlPanel = new JPanel(); + ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.Y_AXIS)); + ctrlPanel.add(Box.createVerticalGlue()); + addResultButton = new JButton(new AddForecastDataTypeAction(resultTable, ForecastDataType.Result)); + ctrlPanel.add(addResultButton); + ctrlPanel.add(Box.createVerticalStrut(10)); + deleteResultButton = new JButton(new DeleteForecastDataTypeAction(resultTable, ForecastDataType.Result)); + ctrlPanel.add(deleteResultButton); + ctrlPanel.add(Box.createVerticalGlue()); + ctrlPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + resultsPanel.add(ctrlPanel, BorderLayout.EAST); + + return resultsPanel; + } + + private JPanel createCtrlPanel() { + JPanel ctrlPanel = new JPanel(); + ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); + + JButton okButton = new JButton(new AcceptNewModelAction(panelViewer)); + JButton cancelButton = new JButton(new CancelNewModelAction(panelViewer)); + + GUIUtils.sizeUniformly(okButton, cancelButton); + ctrlPanel.add(Box.createHorizontalGlue()); + ctrlPanel.add(okButton); + ctrlPanel.add(Box.createHorizontalStrut(10)); + ctrlPanel.add(cancelButton); + ctrlPanel.add(Box.createHorizontalGlue()); + + ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + return ctrlPanel; + } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,17 +2,17 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.gui; @@ -42,112 +42,110 @@ public class PredictionPanel extends JPanel { - private static final long serialVersionUID = -5723506056156479994L; - private final PanelViewer panelViewer; - private JTextField descriptionField; - private JTable predictionTable; - private JTable resultsTable; - private JButton closeButton; - private final TrainingItem trainingItem = new TrainingItem(); - private PredictionTableModel resultsModel; - - public PredictionPanel(PanelViewer viewer) { - panelViewer = viewer; - initComponents(); - } - - private void initComponents() { - setLayout(new BorderLayout(4, 4)); - - add(createDescriptionPanel(), BorderLayout.NORTH); - add(createPredictionPanel(), BorderLayout.CENTER); - add(createCtrlPanel(), BorderLayout.SOUTH); - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - updateResults(); - descriptionField.requestFocus(); - } - }); - } - - private JPanel createDescriptionPanel() { - JPanel descPanel = new JPanel(); - - descPanel.setLayout(new BorderLayout(4, 4)); - JLabel descLabel = new JLabel(DamusBundle.getString(DamusBundle.DESCRIPTION)); - descPanel.add(descLabel, BorderLayout.WEST); - descriptionField = new JTextField(20); - descLabel.setLabelFor(descriptionField); - descPanel.add(descriptionField, BorderLayout.CENTER); - descPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - return descPanel; - } - - private JPanel createPredictionPanel() { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - - { - JPanel metricsPanel = new JPanel(); - metricsPanel.setLayout(new BorderLayout(4, 4)); - predictionTable = new JTable(new PredictionTableModel(ForecastDataType.Metric, trainingItem)); - predictionTable.setRowHeight(predictionTable.getRowHeight() + 14); - TableColumn column = predictionTable.getColumnModel().getColumn(1); - column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Metric)); - TableCellEditor editor = new TrainingValueCellEditor(ForecastDataType.Metric); - editor.addCellEditorListener(new CellEditorListener() { + private static final long serialVersionUID = -5723506056156479994L; + private final PanelViewer panelViewer; + private JTextField descriptionField; + private final TrainingItem trainingItem = new TrainingItem(); + private PredictionTableModel resultsModel; - @Override - public void editingCanceled(ChangeEvent e) { - updateResults(); - } + public PredictionPanel(PanelViewer viewer) { + panelViewer = viewer; + initComponents(); + } - @Override - public void editingStopped(ChangeEvent e) { - updateResults(); - } - }); - column.setCellEditor(editor); - metricsPanel.add(new JScrollPane(predictionTable), BorderLayout.CENTER); - metricsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS))); - panel.add(metricsPanel); - } - - { - JPanel resultsPanel = new JPanel(); - resultsPanel.setLayout(new BorderLayout(4, 4)); - resultsModel = new PredictionTableModel(ForecastDataType.Result, trainingItem); - resultsTable = new JTable(resultsModel); - resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); - TableColumn column = resultsTable.getColumnModel().getColumn(1); - column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); - column.setCellEditor(new TrainingValueCellEditor(ForecastDataType.Result)); - resultsPanel.add(new JScrollPane(resultsTable), BorderLayout.CENTER); - resultsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.RESULTS))); - panel.add(resultsPanel); - } - - return panel; - } - - private JPanel createCtrlPanel() { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - - closeButton = new JButton(new ClosePredictionAction(panelViewer)); - - panel.add(Box.createHorizontalGlue()); - panel.add(closeButton); - - panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - return panel; - } - - private void updateResults() { - DamusCalculator calc = new DamusCalculator(trainingItem); - if (calc.calc()) { - resultsModel.fireTableStructureChanged(); - } - } + private void initComponents() { + setLayout(new BorderLayout(4, 4)); + + add(createDescriptionPanel(), BorderLayout.NORTH); + add(createPredictionPanel(), BorderLayout.CENTER); + add(createCtrlPanel(), BorderLayout.SOUTH); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + updateResults(); + descriptionField.requestFocus(); + } + }); + } + + private JPanel createDescriptionPanel() { + JPanel descPanel = new JPanel(); + + descPanel.setLayout(new BorderLayout(4, 4)); + JLabel descLabel = new JLabel(DamusBundle.getString(DamusBundle.DESCRIPTION)); + descPanel.add(descLabel, BorderLayout.WEST); + descriptionField = new JTextField(20); + descLabel.setLabelFor(descriptionField); + descPanel.add(descriptionField, BorderLayout.CENTER); + descPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + return descPanel; + } + + private JPanel createPredictionPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + + { + JPanel metricsPanel = new JPanel(); + metricsPanel.setLayout(new BorderLayout(4, 4)); + JTable predictionTable = new JTable(new PredictionTableModel(ForecastDataType.Metric, trainingItem)); + predictionTable.setRowHeight(predictionTable.getRowHeight() + 14); + TableColumn column = predictionTable.getColumnModel().getColumn(1); + column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Metric)); + TableCellEditor editor = new TrainingValueCellEditor(ForecastDataType.Metric); + editor.addCellEditorListener(new CellEditorListener() { + + @Override + public void editingCanceled(ChangeEvent e) { + updateResults(); + } + + @Override + public void editingStopped(ChangeEvent e) { + updateResults(); + } + }); + column.setCellEditor(editor); + metricsPanel.add(new JScrollPane(predictionTable), BorderLayout.CENTER); + metricsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS))); + panel.add(metricsPanel); + } + + { + JPanel resultsPanel = new JPanel(); + resultsPanel.setLayout(new BorderLayout(4, 4)); + resultsModel = new PredictionTableModel(ForecastDataType.Result, trainingItem); + JTable resultsTable = new JTable(resultsModel); + resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); + TableColumn column = resultsTable.getColumnModel().getColumn(1); + column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); + column.setCellEditor(new TrainingValueCellEditor(ForecastDataType.Result)); + resultsPanel.add(new JScrollPane(resultsTable), BorderLayout.CENTER); + resultsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.RESULTS))); + panel.add(resultsPanel); + } + + return panel; + } + + private JPanel createCtrlPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + + JButton closeButton = new JButton(new ClosePredictionAction(panelViewer)); + + panel.add(Box.createHorizontalGlue()); + panel.add(closeButton); + + panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + return panel; + } + + private void updateResults() { + DamusCalculator calc = new DamusCalculator(trainingItem); + if (calc.calc()) { + resultsModel.fireTableStructureChanged(); + } + } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,17 +2,17 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.gui; @@ -33,67 +33,68 @@ import com.mebigfatguy.damus.gui.model.ReviewItemsTableModel; public class ReviewPanel extends JPanel { - - private static final long serialVersionUID = -8696144138294129488L; - private final PanelViewer panelViewer; - private JTable reviewTable; - private JButton deleteButton; - private JButton trainButton; - private JButton finishButton; - - public ReviewPanel(PanelViewer viewer) { - panelViewer = viewer; - initComponents(); - - ReviewItemsTableModel model = (ReviewItemsTableModel)reviewTable.getModel(); - if (model.getRowCount() > 0) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - reviewTable.getSelectionModel().setSelectionInterval(0, 0); - } - }); - } - } - private void initComponents() { - setLayout(new BorderLayout(4, 4)); - - add(createReviewPanel(), BorderLayout.CENTER); - add(createCtrlPanel(), BorderLayout.SOUTH); - - GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); - } - - private JPanel createReviewPanel() { - - JPanel panel = new JPanel(); - ReviewItemsTableModel rtm = new ReviewItemsTableModel(); - reviewTable = new JTable(rtm); - panel.setLayout(new BorderLayout(4, 4)); - panel.add(new JScrollPane(reviewTable), BorderLayout.CENTER); - - panel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.TRAINEDITEMS))); - return panel; - } - - private JPanel createCtrlPanel() { - JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); - - deleteButton = new JButton(DamusBundle.getString(DamusBundle.DELETE)); - trainButton = new JButton(new TrainAction(panelViewer, reviewTable)); - finishButton = new JButton(new FinishReviewAction(panelViewer)); - - GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); - - ctrlPanel.add(deleteButton); - ctrlPanel.add(Box.createHorizontalGlue()); - ctrlPanel.add(trainButton); - ctrlPanel.add(Box.createHorizontalGlue()); - ctrlPanel.add(finishButton); - - ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - return ctrlPanel; - } + private static final long serialVersionUID = -8696144138294129488L; + private final PanelViewer panelViewer; + private JTable reviewTable; + private JButton deleteButton; + private JButton trainButton; + private JButton finishButton; + + public ReviewPanel(PanelViewer viewer) { + panelViewer = viewer; + initComponents(); + + ReviewItemsTableModel model = (ReviewItemsTableModel)reviewTable.getModel(); + if (model.getRowCount() > 0) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + reviewTable.getSelectionModel().setSelectionInterval(0, 0); + } + }); + } + } + + private void initComponents() { + setLayout(new BorderLayout(4, 4)); + + add(createReviewPanel(), BorderLayout.CENTER); + add(createCtrlPanel(), BorderLayout.SOUTH); + + GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); + } + + private JPanel createReviewPanel() { + + JPanel panel = new JPanel(); + ReviewItemsTableModel rtm = new ReviewItemsTableModel(); + reviewTable = new JTable(rtm); + panel.setLayout(new BorderLayout(4, 4)); + panel.add(new JScrollPane(reviewTable), BorderLayout.CENTER); + + panel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.TRAINEDITEMS))); + return panel; + } + + private JPanel createCtrlPanel() { + JPanel ctrlPanel = new JPanel(); + ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); + + deleteButton = new JButton(DamusBundle.getString(DamusBundle.DELETE)); + trainButton = new JButton(new TrainAction(panelViewer, reviewTable)); + finishButton = new JButton(new FinishReviewAction(panelViewer)); + + GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); + + ctrlPanel.add(deleteButton); + ctrlPanel.add(Box.createHorizontalGlue()); + ctrlPanel.add(trainButton); + ctrlPanel.add(Box.createHorizontalGlue()); + ctrlPanel.add(finishButton); + + ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + return ctrlPanel; + } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-27 16:36:36 UTC (rev 82) +++ trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2011-08-03 10:31:09 UTC (rev 83) @@ -2,17 +2,17 @@ * damus - a forecasting tool * Copyright (C) 2010 Dave Brosius * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. */ package com.mebigfatguy.damus.gui; @@ -42,118 +42,114 @@ public class TrainingPanel extends JPanel { - private static final long serialVersionUID = -4289076135864687250L; - - private final PanelViewer panelViewer; - private final boolean isNew; - private JTable trainingTable; - private JTable resultsTable; - private JTextField descriptionField; - private JButton cancelButton; - private JButton addAndNextButton; - private JButton addAndFinishButton; - - public TrainingPanel(PanelViewer viewer, boolean isNewItem) { - panelViewer = viewer; - isNew = isNewItem; - initComponents(); - } - - public boolean populateTrainingItem(TrainingItem item) { - String itemDesc = descriptionField.getText().trim(); - if (itemDesc.length() > 0) { - item.setDescription(itemDesc); - return true; - } - return false; - } - - public void reset() { - descriptionField.setText(""); - } - - private void initComponents() { - setLayout(new BorderLayout(4, 4)); - - add(createDescriptionPanel(), BorderLayout.NORTH); - add(createTrainingPanel(), BorderLayout.CENTER); - add(createCtrlPanel(), BorderLayout.SOUTH); - - SwingUtilities.invokeLater(new Runnable() { - public void run() {... [truncated message content] |
From: <dbr...@us...> - 2010-06-27 16:36:42
|
Revision: 82 http://damus.svn.sourceforge.net/damus/?rev=82&view=rev Author: dbrosius Date: 2010-06-27 16:36:36 +0000 (Sun, 27 Jun 2010) Log Message: ----------- fire table changed events Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 16:24:52 UTC (rev 81) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 16:36:36 UTC (rev 82) @@ -49,6 +49,7 @@ private JTable resultsTable; private JButton closeButton; private final TrainingItem trainingItem = new TrainingItem(); + private PredictionTableModel resultsModel; public PredictionPanel(PanelViewer viewer) { panelViewer = viewer; @@ -116,7 +117,8 @@ { JPanel resultsPanel = new JPanel(); resultsPanel.setLayout(new BorderLayout(4, 4)); - resultsTable = new JTable(new PredictionTableModel(ForecastDataType.Result, trainingItem)); + resultsModel = new PredictionTableModel(ForecastDataType.Result, trainingItem); + resultsTable = new JTable(resultsModel); resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); TableColumn column = resultsTable.getColumnModel().getColumn(1); column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); @@ -144,6 +146,8 @@ private void updateResults() { DamusCalculator calc = new DamusCalculator(trainingItem); - calc.calc(); + if (calc.calc()) { + resultsModel.fireTableStructureChanged(); + } } } Modified: trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java 2010-06-27 16:24:52 UTC (rev 81) +++ trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java 2010-06-27 16:36:36 UTC (rev 82) @@ -30,9 +30,8 @@ trainingItem = item; } - public void calc() { - TrainingItem linearRegression = (TrainingItem)trainingItem.clone(); - calcLinearRegression(linearRegression); + public boolean calc() { + return calcLinearRegression(trainingItem); } private boolean calcLinearRegression(TrainingItem linearRegression) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 16:24:59
|
Revision: 81 http://damus.svn.sourceforge.net/damus/?rev=81&view=rev Author: dbrosius Date: 2010-06-27 16:24:52 +0000 (Sun, 27 Jun 2010) Log Message: ----------- flush out Multiple linear regression Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java Modified: trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java 2010-06-27 15:16:15 UTC (rev 80) +++ trunk/damus/src/com/mebigfatguy/damus/data/TrainingItem.java 2010-06-27 16:24:52 UTC (rev 81) @@ -21,9 +21,9 @@ import com.mebigfatguy.damus.main.Context; -public class TrainingItem { +public class TrainingItem implements Cloneable { private String itemDescription; - private final Map<Metric, Object> metricData = new HashMap<Metric, Object>(); + private Map<Metric, Object> metricData = new HashMap<Metric, Object>(); public TrainingItem() { PredictionModel model = Context.instance().getPredictionModel(); @@ -80,4 +80,16 @@ public void setValue(Metric metric, Object value) { metricData.put(metric, value); } + + @Override + public Object clone() { + try { + TrainingItem clone = (TrainingItem)super.clone(); + clone.metricData = new HashMap<Metric, Object>(metricData); + + return clone; + } catch (CloneNotSupportedException cnse) { + throw new Error("Clone Not Supported on TrainingItem"); + } + } } Modified: trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java 2010-06-27 15:16:15 UTC (rev 80) +++ trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java 2010-06-27 16:24:52 UTC (rev 81) @@ -16,6 +16,11 @@ */ package com.mebigfatguy.damus.main; +import org.apache.commons.math.stat.regression.OLSMultipleLinearRegression; + +import com.mebigfatguy.damus.data.Metric; +import com.mebigfatguy.damus.data.PredictionModel; +import com.mebigfatguy.damus.data.TrainingData; import com.mebigfatguy.damus.data.TrainingItem; public class DamusCalculator { @@ -26,6 +31,82 @@ } public void calc() { - + TrainingItem linearRegression = (TrainingItem)trainingItem.clone(); + calcLinearRegression(linearRegression); } + + private boolean calcLinearRegression(TrainingItem linearRegression) { + try { + Context context = Context.instance(); + PredictionModel model = context.getPredictionModel(); + TrainingData data = context.getTrainingData(); + + int numMetrics = model.getNumMetrics(); + int numResults = model.getNumResults(); + int numItems = data.getNumItems(); + + OLSMultipleLinearRegression regression = new OLSMultipleLinearRegression(); + + double [][] xx = new double[numItems][]; + for (int i = 0; i < numItems; i++) { + double[] x = new double[numMetrics]; + for (int m = 0; m < numMetrics; m++) { + Metric metric = model.getMetric(m); + double value; + switch (metric.getType()) { + case Percent: + value = ((Number)data.getItem(i).getValue(metric)).doubleValue(); + break; + + case Real: + value = ((Number)data.getItem(i).getValue(metric)).doubleValue(); + break; + + case YesNo: + value = ((Boolean)data.getItem(i).getValue(metric)).booleanValue() ? 1.0 : 0.0; + break; + + default: + value = 0.0; + break; + } + x[m] = value; + } + xx[i] = x; + } + + for (int r = 0; r < numResults; r++) { + Metric metric = model.getResult(r); + double[] y = new double[numItems]; + for (int i = 0; i < numItems; i++) { + double value; + switch (metric.getType()) { + case Percent: + value = ((Number)data.getItem(i).getValue(metric)).doubleValue(); + break; + + case Real: + value = ((Number)data.getItem(i).getValue(metric)).doubleValue(); + break; + + case YesNo: + value = ((Boolean)data.getItem(i).getValue(metric)).booleanValue() ? 1.0 : 0.0; + break; + + default: + value = 0.0; + break; + } + y[i] = value; + } + + regression.newSampleData(y, xx); + double result = regression.estimateRegressandVariance(); + trainingItem.setValue(metric, Double.valueOf(result)); + } + return true; + } catch (Exception e) { + return false; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 15:16:21
|
Revision: 80 http://damus.svn.sourceforge.net/damus/?rev=80&view=rev Author: dbrosius Date: 2010-06-27 15:16:15 +0000 (Sun, 27 Jun 2010) Log Message: ----------- stub in the calculator Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 15:03:12 UTC (rev 79) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 15:16:15 UTC (rev 80) @@ -35,18 +35,20 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.ForecastDataType; +import com.mebigfatguy.damus.data.TrainingItem; import com.mebigfatguy.damus.gui.actions.ClosePredictionAction; import com.mebigfatguy.damus.gui.model.PredictionTableModel; +import com.mebigfatguy.damus.main.DamusCalculator; public class PredictionPanel extends JPanel { - private static final long serialVersionUID = -4289076135864687250L; - + private static final long serialVersionUID = -5723506056156479994L; private final PanelViewer panelViewer; private JTextField descriptionField; private JTable predictionTable; private JTable resultsTable; private JButton closeButton; + private final TrainingItem trainingItem = new TrainingItem(); public PredictionPanel(PanelViewer viewer) { panelViewer = viewer; @@ -62,6 +64,7 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { + updateResults(); descriptionField.requestFocus(); } }); @@ -87,7 +90,7 @@ { JPanel metricsPanel = new JPanel(); metricsPanel.setLayout(new BorderLayout(4, 4)); - predictionTable = new JTable(new PredictionTableModel(ForecastDataType.Metric)); + predictionTable = new JTable(new PredictionTableModel(ForecastDataType.Metric, trainingItem)); predictionTable.setRowHeight(predictionTable.getRowHeight() + 14); TableColumn column = predictionTable.getColumnModel().getColumn(1); column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Metric)); @@ -113,7 +116,7 @@ { JPanel resultsPanel = new JPanel(); resultsPanel.setLayout(new BorderLayout(4, 4)); - resultsTable = new JTable(new PredictionTableModel(ForecastDataType.Result)); + resultsTable = new JTable(new PredictionTableModel(ForecastDataType.Result, trainingItem)); resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); TableColumn column = resultsTable.getColumnModel().getColumn(1); column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); @@ -140,5 +143,7 @@ } private void updateResults() { + DamusCalculator calc = new DamusCalculator(trainingItem); + calc.calc(); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java 2010-06-27 15:03:12 UTC (rev 79) +++ trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java 2010-06-27 15:16:15 UTC (rev 80) @@ -30,10 +30,11 @@ private static final long serialVersionUID = -8900184057917667615L; private final ForecastDataType forecastDataType; private final PredictionModel model = Context.instance().getPredictionModel(); - private final TrainingItem trainingItem = new TrainingItem(); + private final TrainingItem trainingItem; - public PredictionTableModel(ForecastDataType dataType) { + public PredictionTableModel(ForecastDataType dataType, TrainingItem item) { forecastDataType = dataType; + trainingItem = item; } @Override Added: trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java 2010-06-27 15:16:15 UTC (rev 80) @@ -0,0 +1,31 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.main; + +import com.mebigfatguy.damus.data.TrainingItem; + +public class DamusCalculator { + + private final TrainingItem trainingItem; + public DamusCalculator(TrainingItem item) { + trainingItem = item; + } + + public void calc() { + + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/main/DamusCalculator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 15:03:18
|
Revision: 79 http://damus.svn.sourceforge.net/damus/?rev=79&view=rev Author: dbrosius Date: 2010-06-27 15:03:12 +0000 (Sun, 27 Jun 2010) Log Message: ----------- stub in predictions events Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:51:07 UTC (rev 78) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 15:03:12 UTC (rev 79) @@ -28,6 +28,9 @@ import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingUtilities; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.table.TableCellEditor; import javax.swing.table.TableColumn; import com.mebigfatguy.damus.bundle.DamusBundle; @@ -88,7 +91,20 @@ predictionTable.setRowHeight(predictionTable.getRowHeight() + 14); TableColumn column = predictionTable.getColumnModel().getColumn(1); column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Metric)); - column.setCellEditor(new TrainingValueCellEditor(ForecastDataType.Metric)); + TableCellEditor editor = new TrainingValueCellEditor(ForecastDataType.Metric); + editor.addCellEditorListener(new CellEditorListener() { + + @Override + public void editingCanceled(ChangeEvent e) { + updateResults(); + } + + @Override + public void editingStopped(ChangeEvent e) { + updateResults(); + } + }); + column.setCellEditor(editor); metricsPanel.add(new JScrollPane(predictionTable), BorderLayout.CENTER); metricsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS))); panel.add(metricsPanel); @@ -122,4 +138,7 @@ panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return panel; } + + private void updateResults() { + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 14:51:13
|
Revision: 78 http://damus.svn.sourceforge.net/damus/?rev=78&view=rev Author: dbrosius Date: 2010-06-27 14:51:07 +0000 (Sun, 27 Jun 2010) Log Message: ----------- prediction panel will be hot changed on edit changes, so remove extra buttons Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/ClosePredictionAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-27 14:43:33 UTC (rev 77) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-27 14:51:07 UTC (rev 78) @@ -42,6 +42,7 @@ public static final String YESNO = "damus.yesno"; public static final String CREATE_MODEL = "damus.createmodel"; public static final String CANCEL = "damus.cancel"; + public static final String CLOSE_PANEL = "damus.closepanel"; public static final String OK = "damus.ok"; public static final String MODEL = "damus.predictionmodel"; public static final String RESULT_NAME = "damus.resultname"; Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-27 14:43:33 UTC (rev 77) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-27 14:51:07 UTC (rev 78) @@ -22,6 +22,7 @@ damus.yesno = Yes or No damus.createmodel = Create Model damus.cancel = Cancel +damus.closepanel = Close damus.ok = OK damus.predictionmodel = Prediction Model damus.resultname = Result Name Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:43:33 UTC (rev 77) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:51:07 UTC (rev 78) @@ -32,8 +32,7 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.ForecastDataType; -import com.mebigfatguy.damus.gui.actions.CancelTrainingAction; -import com.mebigfatguy.damus.gui.actions.PredictItemAction; +import com.mebigfatguy.damus.gui.actions.ClosePredictionAction; import com.mebigfatguy.damus.gui.model.PredictionTableModel; public class PredictionPanel extends JPanel { @@ -44,8 +43,7 @@ private JTextField descriptionField; private JTable predictionTable; private JTable resultsTable; - private JButton cancelButton; - private JButton predictButton; + private JButton closeButton; public PredictionPanel(PanelViewer viewer) { panelViewer = viewer; @@ -116,14 +114,10 @@ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - cancelButton = new JButton(new CancelTrainingAction(panelViewer)); - predictButton = new JButton(new PredictItemAction(panelViewer)); + closeButton = new JButton(new ClosePredictionAction(panelViewer)); - GUIUtils.sizeUniformly(cancelButton, predictButton); - - panel.add(cancelButton); panel.add(Box.createHorizontalGlue()); - panel.add(predictButton); + panel.add(closeButton); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return panel; Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java 2010-06-27 14:43:33 UTC (rev 77) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java 2010-06-27 14:51:07 UTC (rev 78) @@ -46,7 +46,5 @@ trainingData.removeItem(item); } panelViewer.closePanel(PanelType.TRAINMODEL); - } - } Added: trunk/damus/src/com/mebigfatguy/damus/gui/actions/ClosePredictionAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/ClosePredictionAction.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/ClosePredictionAction.java 2010-06-27 14:51:07 UTC (rev 78) @@ -0,0 +1,42 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.gui.actions; +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; + + +public class ClosePredictionAction extends AbstractAction { + + private static final long serialVersionUID = 3729520424496335639L; + private final PanelViewer panelViewer; + + public ClosePredictionAction(PanelViewer viewer) { + super(DamusBundle.getString(DamusBundle.CLOSE_PANEL)); + panelViewer = viewer; + } + + @Override + public void actionPerformed(ActionEvent e) { + panelViewer.closePanel(PanelType.PREDICTMODEL); + } + +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/actions/ClosePredictionAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java 2010-06-27 14:43:33 UTC (rev 77) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java 2010-06-27 14:51:07 UTC (rev 78) @@ -1,3 +1,19 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ package com.mebigfatguy.damus.gui.actions; import java.awt.event.ActionEvent; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 14:43:39
|
Revision: 77 http://damus.svn.sourceforge.net/damus/?rev=77&view=rev Author: dbrosius Date: 2010-06-27 14:43:33 +0000 (Sun, 27 Jun 2010) Log Message: ----------- prediction results aren't editable Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:42:29 UTC (rev 76) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:43:33 UTC (rev 77) @@ -35,7 +35,6 @@ import com.mebigfatguy.damus.gui.actions.CancelTrainingAction; import com.mebigfatguy.damus.gui.actions.PredictItemAction; import com.mebigfatguy.damus.gui.model.PredictionTableModel; -import com.mebigfatguy.damus.gui.model.TrainingTableModel; public class PredictionPanel extends JPanel { @@ -100,7 +99,7 @@ { JPanel resultsPanel = new JPanel(); resultsPanel.setLayout(new BorderLayout(4, 4)); - resultsTable = new JTable(new TrainingTableModel(ForecastDataType.Result)); + resultsTable = new JTable(new PredictionTableModel(ForecastDataType.Result)); resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); TableColumn column = resultsTable.getColumnModel().getColumn(1); column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 14:42:35
|
Revision: 76 http://damus.svn.sourceforge.net/damus/?rev=76&view=rev Author: dbrosius Date: 2010-06-27 14:42:29 +0000 (Sun, 27 Jun 2010) Log Message: ----------- stub in the prediction panel Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictAction.java trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-27 14:22:41 UTC (rev 75) +++ trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-27 14:42:29 UTC (rev 76) @@ -102,7 +102,7 @@ dataMenu.add(reviewItem); trainItem = new JCheckBoxMenuItem(new TrainNewAction(this)); dataMenu.add(trainItem); - predictItem = new JCheckBoxMenuItem(new PredictAction()); + predictItem = new JCheckBoxMenuItem(new PredictAction(this)); dataMenu.add(predictItem); dataMenu.setEnabled(false); mb.add(dataMenu); Added: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java 2010-06-27 14:42:29 UTC (rev 76) @@ -0,0 +1,132 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.gui; + +import java.awt.BorderLayout; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.table.TableColumn; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.ForecastDataType; +import com.mebigfatguy.damus.gui.actions.CancelTrainingAction; +import com.mebigfatguy.damus.gui.actions.PredictItemAction; +import com.mebigfatguy.damus.gui.model.PredictionTableModel; +import com.mebigfatguy.damus.gui.model.TrainingTableModel; + +public class PredictionPanel extends JPanel { + + private static final long serialVersionUID = -4289076135864687250L; + + private final PanelViewer panelViewer; + private JTextField descriptionField; + private JTable predictionTable; + private JTable resultsTable; + private JButton cancelButton; + private JButton predictButton; + + public PredictionPanel(PanelViewer viewer) { + panelViewer = viewer; + initComponents(); + } + + private void initComponents() { + setLayout(new BorderLayout(4, 4)); + + add(createDescriptionPanel(), BorderLayout.NORTH); + add(createPredictionPanel(), BorderLayout.CENTER); + add(createCtrlPanel(), BorderLayout.SOUTH); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + descriptionField.requestFocus(); + } + }); + } + + private JPanel createDescriptionPanel() { + JPanel descPanel = new JPanel(); + + descPanel.setLayout(new BorderLayout(4, 4)); + JLabel descLabel = new JLabel(DamusBundle.getString(DamusBundle.DESCRIPTION)); + descPanel.add(descLabel, BorderLayout.WEST); + descriptionField = new JTextField(20); + descLabel.setLabelFor(descriptionField); + descPanel.add(descriptionField, BorderLayout.CENTER); + descPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + return descPanel; + } + + private JPanel createPredictionPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + + { + JPanel metricsPanel = new JPanel(); + metricsPanel.setLayout(new BorderLayout(4, 4)); + predictionTable = new JTable(new PredictionTableModel(ForecastDataType.Metric)); + predictionTable.setRowHeight(predictionTable.getRowHeight() + 14); + TableColumn column = predictionTable.getColumnModel().getColumn(1); + column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Metric)); + column.setCellEditor(new TrainingValueCellEditor(ForecastDataType.Metric)); + metricsPanel.add(new JScrollPane(predictionTable), BorderLayout.CENTER); + metricsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.METRICS))); + panel.add(metricsPanel); + } + + { + JPanel resultsPanel = new JPanel(); + resultsPanel.setLayout(new BorderLayout(4, 4)); + resultsTable = new JTable(new TrainingTableModel(ForecastDataType.Result)); + resultsTable.setRowHeight(resultsTable.getRowHeight() + 14); + TableColumn column = resultsTable.getColumnModel().getColumn(1); + column.setCellRenderer(new TrainingValueCellRenderer(ForecastDataType.Result)); + column.setCellEditor(new TrainingValueCellEditor(ForecastDataType.Result)); + resultsPanel.add(new JScrollPane(resultsTable), BorderLayout.CENTER); + resultsPanel.setBorder(BorderFactory.createTitledBorder(DamusBundle.getString(DamusBundle.RESULTS))); + panel.add(resultsPanel); + } + + return panel; + } + + private JPanel createCtrlPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + + cancelButton = new JButton(new CancelTrainingAction(panelViewer)); + predictButton = new JButton(new PredictItemAction(panelViewer)); + + GUIUtils.sizeUniformly(cancelButton, predictButton); + + panel.add(cancelButton); + panel.add(Box.createHorizontalGlue()); + panel.add(predictButton); + + panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + return panel; + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/PredictionPanel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictAction.java 2010-06-27 14:22:41 UTC (rev 75) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictAction.java 2010-06-27 14:42:29 UTC (rev 76) @@ -19,21 +19,36 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractAction; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JPanel; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.gui.PredictionPanel; public class PredictAction extends AbstractAction { - private static final long serialVersionUID = -3795481817774177732L; + private static final long serialVersionUID = -9078941810787549844L; + private final PanelViewer panelViewer; - public PredictAction() { + public PredictAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.PREDICT)); + panelViewer = viewer; } @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - + JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource(); + if (item.isSelected()) { + JPanel newPanel = createNewPanel(); + panelViewer.openPanel(PanelType.PREDICTMODEL, newPanel, true); + } + else + panelViewer.closePanel(PanelType.PREDICTMODEL); } - + + private JPanel createNewPanel() { + return new PredictionPanel(panelViewer); + } } Added: trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java 2010-06-27 14:42:29 UTC (rev 76) @@ -0,0 +1,23 @@ +package com.mebigfatguy.damus.gui.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.gui.PanelViewer; + +public class PredictItemAction extends AbstractAction { + + private static final long serialVersionUID = 6749751713294743053L; + private final PanelViewer panelViewer; + + public PredictItemAction(PanelViewer viewer) { + super(DamusBundle.getString(DamusBundle.PREDICT)); + panelViewer = viewer; + } + + @Override + public void actionPerformed(ActionEvent e) { + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/actions/PredictItemAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java 2010-06-27 14:42:29 UTC (rev 76) @@ -0,0 +1,99 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.gui.model; + +import javax.swing.table.AbstractTableModel; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.ForecastDataType; +import com.mebigfatguy.damus.data.Metric; +import com.mebigfatguy.damus.data.PredictionModel; +import com.mebigfatguy.damus.data.TrainingItem; +import com.mebigfatguy.damus.main.Context; + +public class PredictionTableModel extends AbstractTableModel { + + private static final long serialVersionUID = -8900184057917667615L; + private final ForecastDataType forecastDataType; + private final PredictionModel model = Context.instance().getPredictionModel(); + private final TrainingItem trainingItem = new TrainingItem(); + + public PredictionTableModel(ForecastDataType dataType) { + forecastDataType = dataType; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public int getRowCount() { + if (forecastDataType == ForecastDataType.Metric) + return model.getNumMetrics(); + else + return model.getNumResults(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + Metric metric; + + if (forecastDataType == ForecastDataType.Metric) + metric = model.getMetric(rowIndex); + else + metric = model.getResult(rowIndex); + + if (columnIndex == 0) { + return metric.getName(); + } else { + return trainingItem.getValue(metric); + } + } + + @Override + public String getColumnName(int column) { + if (column == 0) { + if (forecastDataType == ForecastDataType.Metric) + return DamusBundle.getString(DamusBundle.METRIC_NAME); + else + return DamusBundle.getString(DamusBundle.RESULT_NAME); + } else { + if (forecastDataType == ForecastDataType.Metric) + return DamusBundle.getString(DamusBundle.METRIC_VALUE); + else + return DamusBundle.getString(DamusBundle.RESULT_VALUE); + } + } + + @Override + public Class<?> getColumnClass(int columnIndex) { + if (columnIndex == 0) + return String.class; + else + return Object.class; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return (forecastDataType == ForecastDataType.Metric) && (columnIndex == 1); + } + + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/model/PredictionTableModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java 2010-06-27 14:22:41 UTC (rev 75) +++ trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java 2010-06-27 14:42:29 UTC (rev 76) @@ -81,8 +81,6 @@ else return DamusBundle.getString(DamusBundle.RESULT_VALUE); } - - } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-27 14:22:47
|
Revision: 75 http://damus.svn.sourceforge.net/damus/?rev=75&view=rev Author: dbrosius Date: 2010-06-27 14:22:41 +0000 (Sun, 27 Jun 2010) Log Message: ----------- fix results table headers Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties trunk/damus/src/com/mebigfatguy/damus/gui/model/MetricsTableModel.java trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-21 06:17:29 UTC (rev 74) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-27 14:22:41 UTC (rev 75) @@ -46,6 +46,7 @@ public static final String MODEL = "damus.predictionmodel"; public static final String RESULT_NAME = "damus.resultname"; public static final String RESULT_TYPE = "damus.resulttype"; + public static final String RESULT_VALUE = "damus.resultvalue"; public static final String METRICS = "damus.metrics"; public static final String RESULTS = "damus.results"; public static final String DATA = "damus.data"; Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-21 06:17:29 UTC (rev 74) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-27 14:22:41 UTC (rev 75) @@ -26,6 +26,7 @@ damus.predictionmodel = Prediction Model damus.resultname = Result Name damus.resulttype = Result Type +damus.resultvalue = Result Value damus.metrics = Metrics damus.results = Results damus.data = Data Modified: trunk/damus/src/com/mebigfatguy/damus/gui/model/MetricsTableModel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/model/MetricsTableModel.java 2010-06-21 06:17:29 UTC (rev 74) +++ trunk/damus/src/com/mebigfatguy/damus/gui/model/MetricsTableModel.java 2010-06-27 14:22:41 UTC (rev 75) @@ -112,10 +112,17 @@ @Override public String getColumnName(int column) { - if (column == 0) - return DamusBundle.getString(DamusBundle.METRIC_NAME); - - return DamusBundle.getString(DamusBundle.METRIC_TYPE); + if (column == 0) { + if (dataType == ForecastDataType.Metric) + return DamusBundle.getString(DamusBundle.METRIC_NAME); + else + return DamusBundle.getString(DamusBundle.RESULT_NAME); + } else { + if (dataType == ForecastDataType.Metric) + return DamusBundle.getString(DamusBundle.METRIC_VALUE); + else + return DamusBundle.getString(DamusBundle.RESULT_VALUE); + } } @Override Modified: trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java 2010-06-21 06:17:29 UTC (rev 74) +++ trunk/damus/src/com/mebigfatguy/damus/gui/model/TrainingTableModel.java 2010-06-27 14:22:41 UTC (rev 75) @@ -30,9 +30,9 @@ private static final long serialVersionUID = -8736809366193297759L; - private ForecastDataType forecastDataType; - private PredictionModel model = Context.instance().getPredictionModel(); - private TrainingData data = Context.instance().getTrainingData(); + private final ForecastDataType forecastDataType; + private final PredictionModel model = Context.instance().getPredictionModel(); + private final TrainingData data = Context.instance().getTrainingData(); public TrainingTableModel(ForecastDataType dataType) { forecastDataType = dataType; @@ -75,9 +75,14 @@ return DamusBundle.getString(DamusBundle.METRIC_NAME); else return DamusBundle.getString(DamusBundle.RESULT_NAME); + } else { + if (forecastDataType == ForecastDataType.Metric) + return DamusBundle.getString(DamusBundle.METRIC_VALUE); + else + return DamusBundle.getString(DamusBundle.RESULT_VALUE); } - return DamusBundle.getString(DamusBundle.METRIC_VALUE); + } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 06:17:36
|
Revision: 74 http://damus.svn.sourceforge.net/damus/?rev=74&view=rev Author: dbrosius Date: 2010-06-21 06:17:29 +0000 (Mon, 21 Jun 2010) Log Message: ----------- hook up the train button from the review panel Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainNewAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-21 05:23:38 UTC (rev 73) +++ trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-21 06:17:29 UTC (rev 74) @@ -37,7 +37,7 @@ import com.mebigfatguy.damus.gui.actions.ReviewAction; import com.mebigfatguy.damus.gui.actions.SaveAction; import com.mebigfatguy.damus.gui.actions.SaveAsAction; -import com.mebigfatguy.damus.gui.actions.TrainAction; +import com.mebigfatguy.damus.gui.actions.TrainNewAction; public class DamusFrame extends JFrame implements PanelViewer { @@ -100,7 +100,7 @@ dataMenu.add(modelItem); reviewItem = new JCheckBoxMenuItem(new ReviewAction(this)); dataMenu.add(reviewItem); - trainItem = new JCheckBoxMenuItem(new TrainAction(this)); + trainItem = new JCheckBoxMenuItem(new TrainNewAction(this)); dataMenu.add(trainItem); predictItem = new JCheckBoxMenuItem(new PredictAction()); dataMenu.add(predictItem); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 05:23:38 UTC (rev 73) +++ trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 06:17:29 UTC (rev 74) @@ -29,6 +29,7 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.gui.actions.FinishReviewAction; +import com.mebigfatguy.damus.gui.actions.TrainAction; import com.mebigfatguy.damus.gui.model.ReviewItemsTableModel; public class ReviewPanel extends JPanel { @@ -80,7 +81,7 @@ ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); deleteButton = new JButton(DamusBundle.getString(DamusBundle.DELETE)); - trainButton = new JButton(DamusBundle.getString(DamusBundle.TRAINITEM)); + trainButton = new JButton(new TrainAction(panelViewer, reviewTable)); finishButton = new JButton(new FinishReviewAction(panelViewer)); GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 05:23:38 UTC (rev 73) +++ trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 06:17:29 UTC (rev 74) @@ -32,11 +32,13 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.ForecastDataType; +import com.mebigfatguy.damus.data.TrainingData; import com.mebigfatguy.damus.data.TrainingItem; import com.mebigfatguy.damus.gui.actions.AddTrainingAndFinishAction; import com.mebigfatguy.damus.gui.actions.AddTrainingAndNextAction; import com.mebigfatguy.damus.gui.actions.CancelTrainingAction; import com.mebigfatguy.damus.gui.model.TrainingTableModel; +import com.mebigfatguy.damus.main.Context; public class TrainingPanel extends JPanel { @@ -94,6 +96,11 @@ descLabel.setLabelFor(descriptionField); descPanel.add(descriptionField, BorderLayout.CENTER); descPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + Context context = Context.instance(); + TrainingData data = context.getTrainingData(); + TrainingItem item = data.getItem(data.getCurrentIndex()); + descriptionField.setText(item.getDescription()); return descPanel; } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java 2010-06-21 05:23:38 UTC (rev 73) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java 2010-06-21 06:17:29 UTC (rev 74) @@ -18,12 +18,11 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractAction; -import javax.swing.JCheckBoxMenuItem; import javax.swing.JPanel; +import javax.swing.JTable; import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.TrainingData; -import com.mebigfatguy.damus.data.TrainingItem; import com.mebigfatguy.damus.gui.PanelType; import com.mebigfatguy.damus.gui.PanelViewer; import com.mebigfatguy.damus.gui.TrainingPanel; @@ -31,31 +30,26 @@ public class TrainAction extends AbstractAction { - - private static final long serialVersionUID = -5199894453893029822L; + private static final long serialVersionUID = 3717245128955315910L; private final PanelViewer panelViewer; + private final JTable reviewTable; - public TrainAction(PanelViewer viewer) { + public TrainAction(PanelViewer viewer, JTable table) { super(DamusBundle.getString(DamusBundle.TRAIN)); panelViewer = viewer; + reviewTable = table; } @Override public void actionPerformed(ActionEvent e) { - JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource(); - if (item.isSelected()) { - JPanel newPanel = createTrainingPanel(); - panelViewer.openPanel(PanelType.TRAINMODEL, newPanel, true); - } else { - panelViewer.closePanel(PanelType.TRAINMODEL); - } + JPanel newPanel = createTrainingPanel(); + panelViewer.openPanel(PanelType.TRAINMODEL, newPanel, true); } private JPanel createTrainingPanel() { TrainingData data = Context.instance().getTrainingData(); - data.addItem(new TrainingItem()); - data.setCurrentIndex(data.getNumItems() - 1); - return new TrainingPanel(panelViewer, true); + data.setCurrentIndex(reviewTable.getSelectedRow()); + return new TrainingPanel(panelViewer, false); } } Added: trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainNewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainNewAction.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainNewAction.java 2010-06-21 06:17:29 UTC (rev 74) @@ -0,0 +1,61 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.gui.actions; +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JPanel; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.TrainingData; +import com.mebigfatguy.damus.data.TrainingItem; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.gui.TrainingPanel; +import com.mebigfatguy.damus.main.Context; + + +public class TrainNewAction extends AbstractAction { + + private static final long serialVersionUID = -5199894453893029822L; + + private final PanelViewer panelViewer; + + public TrainNewAction(PanelViewer viewer) { + super(DamusBundle.getString(DamusBundle.TRAIN)); + panelViewer = viewer; + } + + @Override + public void actionPerformed(ActionEvent e) { + JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource(); + if (item.isSelected()) { + JPanel newPanel = createTrainingPanel(); + panelViewer.openPanel(PanelType.TRAINMODEL, newPanel, true); + } else { + panelViewer.closePanel(PanelType.TRAINMODEL); + } + } + + private JPanel createTrainingPanel() { + TrainingData data = Context.instance().getTrainingData(); + data.addItem(new TrainingItem()); + data.setCurrentIndex(data.getNumItems() - 1); + return new TrainingPanel(panelViewer, true); + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainNewAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 05:23:44
|
Revision: 73 http://damus.svn.sourceforge.net/damus/?rev=73&view=rev Author: dbrosius Date: 2010-06-21 05:23:38 +0000 (Mon, 21 Jun 2010) Log Message: ----------- select first row by default in review panel Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 04:01:11 UTC (rev 72) +++ trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 05:23:38 UTC (rev 73) @@ -25,6 +25,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.SwingUtilities; import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.gui.actions.FinishReviewAction; @@ -42,6 +43,15 @@ public ReviewPanel(PanelViewer viewer) { panelViewer = viewer; initComponents(); + + ReviewItemsTableModel model = (ReviewItemsTableModel)reviewTable.getModel(); + if (model.getRowCount() > 0) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + reviewTable.getSelectionModel().setSelectionInterval(0, 0); + } + }); + } } private void initComponents() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 04:01:17
|
Revision: 72 http://damus.svn.sourceforge.net/damus/?rev=72&view=rev Author: dbrosius Date: 2010-06-21 04:01:11 +0000 (Mon, 21 Jun 2010) Log Message: ----------- impl review->finish Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/ReviewAction.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/FinishReviewAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 03:53:25 UTC (rev 71) +++ trunk/damus/src/com/mebigfatguy/damus/gui/ReviewPanel.java 2010-06-21 04:01:11 UTC (rev 72) @@ -27,18 +27,20 @@ import javax.swing.JTable; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.gui.actions.FinishReviewAction; import com.mebigfatguy.damus.gui.model.ReviewItemsTableModel; public class ReviewPanel extends JPanel { - - private static final long serialVersionUID = -1080460801186242434L; + private static final long serialVersionUID = -8696144138294129488L; + private final PanelViewer panelViewer; private JTable reviewTable; private JButton deleteButton; private JButton trainButton; private JButton finishButton; - public ReviewPanel() { + public ReviewPanel(PanelViewer viewer) { + panelViewer = viewer; initComponents(); } @@ -69,7 +71,7 @@ deleteButton = new JButton(DamusBundle.getString(DamusBundle.DELETE)); trainButton = new JButton(DamusBundle.getString(DamusBundle.TRAINITEM)); - finishButton = new JButton(DamusBundle.getString(DamusBundle.FINISH)); + finishButton = new JButton(new FinishReviewAction(panelViewer)); GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); Added: trunk/damus/src/com/mebigfatguy/damus/gui/actions/FinishReviewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/FinishReviewAction.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/FinishReviewAction.java 2010-06-21 04:01:11 UTC (rev 72) @@ -0,0 +1,40 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.gui.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; + +import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; + +public class FinishReviewAction extends AbstractAction { + + private static final long serialVersionUID = 8164084523215445923L; + private final PanelViewer panelViewer; + + public FinishReviewAction(PanelViewer viewer) { + super(DamusBundle.getString(DamusBundle.FINISH)); + panelViewer = viewer; + } + @Override + public void actionPerformed(ActionEvent e) { + panelViewer.closePanel(PanelType.REVIEW); + } +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/gui/actions/FinishReviewAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/ReviewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/ReviewAction.java 2010-06-21 03:53:25 UTC (rev 71) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/ReviewAction.java 2010-06-21 04:01:11 UTC (rev 72) @@ -31,7 +31,7 @@ private static final long serialVersionUID = 274782596886245534L; - private PanelViewer panelViewer; + private final PanelViewer panelViewer; public ReviewAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.REVIEW)); @@ -49,7 +49,7 @@ } private JPanel createReviewPanel() { - return new ReviewPanel(); + return new ReviewPanel(panelViewer); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 03:53:31
|
Revision: 71 http://damus.svn.sourceforge.net/damus/?rev=71&view=rev Author: dbrosius Date: 2010-06-21 03:53:25 +0000 (Mon, 21 Jun 2010) Log Message: ----------- impl train->cancel Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 02:41:49 UTC (rev 70) +++ trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 03:53:25 UTC (rev 71) @@ -134,15 +134,13 @@ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - cancelButton = new JButton(new CancelTrainingAction()); + cancelButton = new JButton(new CancelTrainingAction(panelViewer)); addAndNextButton = new JButton(new AddTrainingAndNextAction(panelViewer, this)); addAndFinishButton = new JButton(new AddTrainingAndFinishAction(panelViewer, this)); GUIUtils.sizeUniformly(cancelButton, addAndNextButton, addAndFinishButton); - if (!isNew) { - panel.add(cancelButton); - } + panel.add(cancelButton); panel.add(Box.createHorizontalGlue()); panel.add(addAndNextButton); panel.add(Box.createHorizontalStrut(10)); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java 2010-06-21 02:41:49 UTC (rev 70) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/CancelTrainingAction.java 2010-06-21 03:53:25 UTC (rev 71) @@ -21,18 +21,31 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.TrainingData; +import com.mebigfatguy.damus.data.TrainingItem; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.main.Context; public class CancelTrainingAction extends AbstractAction { private static final long serialVersionUID = -5254998640569746748L; + private final PanelViewer panelViewer; - public CancelTrainingAction() { + public CancelTrainingAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.CANCEL)); + panelViewer = viewer; } @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub + Context context = Context.instance(); + TrainingData trainingData = context.getTrainingData(); + TrainingItem item = trainingData.getItem(trainingData.getNumItems() - 1); + if (item.getDescription() == null) { + trainingData.removeItem(item); + } + panelViewer.closePanel(PanelType.TRAINMODEL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 02:41:55
|
Revision: 70 http://damus.svn.sourceforge.net/damus/?rev=70&view=rev Author: dbrosius Date: 2010-06-21 02:41:49 +0000 (Mon, 21 Jun 2010) Log Message: ----------- hook up add and finish and add and next Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AcceptNewModelAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 02:41:11 UTC (rev 69) +++ trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 02:41:49 UTC (rev 70) @@ -32,6 +32,7 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.ForecastDataType; +import com.mebigfatguy.damus.data.TrainingItem; import com.mebigfatguy.damus.gui.actions.AddTrainingAndFinishAction; import com.mebigfatguy.damus.gui.actions.AddTrainingAndNextAction; import com.mebigfatguy.damus.gui.actions.CancelTrainingAction; @@ -41,6 +42,7 @@ private static final long serialVersionUID = -4289076135864687250L; + private final PanelViewer panelViewer; private final boolean isNew; private JTable trainingTable; private JTable resultsTable; @@ -49,11 +51,25 @@ private JButton addAndNextButton; private JButton addAndFinishButton; - public TrainingPanel(boolean isNewItem) { + public TrainingPanel(PanelViewer viewer, boolean isNewItem) { + panelViewer = viewer; isNew = isNewItem; initComponents(); } + public boolean populateTrainingItem(TrainingItem item) { + String itemDesc = descriptionField.getText().trim(); + if (itemDesc.length() > 0) { + item.setDescription(itemDesc); + return true; + } + return false; + } + + public void reset() { + descriptionField.setText(""); + } + private void initComponents() { setLayout(new BorderLayout(4, 4)); @@ -119,8 +135,8 @@ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); cancelButton = new JButton(new CancelTrainingAction()); - addAndNextButton = new JButton(new AddTrainingAndNextAction()); - addAndFinishButton = new JButton(new AddTrainingAndFinishAction()); + addAndNextButton = new JButton(new AddTrainingAndNextAction(panelViewer, this)); + addAndFinishButton = new JButton(new AddTrainingAndFinishAction(panelViewer, this)); GUIUtils.sizeUniformly(cancelButton, addAndNextButton, addAndFinishButton); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AcceptNewModelAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AcceptNewModelAction.java 2010-06-21 02:41:11 UTC (rev 69) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AcceptNewModelAction.java 2010-06-21 02:41:49 UTC (rev 70) @@ -43,6 +43,6 @@ TrainingData data = Context.instance().getTrainingData(); data.addItem(new TrainingItem()); data.setCurrentIndex(0); - panelViewer.openPanel(PanelType.TRAINMODEL, new TrainingPanel(true), true); + panelViewer.openPanel(PanelType.TRAINMODEL, new TrainingPanel(panelViewer, true), true); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java 2010-06-21 02:41:11 UTC (rev 69) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java 2010-06-21 02:41:49 UTC (rev 70) @@ -21,20 +21,32 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.TrainingData; +import com.mebigfatguy.damus.gui.PanelType; +import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.gui.TrainingPanel; import com.mebigfatguy.damus.main.Context; public class AddTrainingAndFinishAction extends AbstractAction { - private static final long serialVersionUID = 4362214163255203402L; + private static final long serialVersionUID = -1938243185460308916L; + private final PanelViewer panelViewer; + private final TrainingPanel trainingPanel; - public AddTrainingAndFinishAction() { + public AddTrainingAndFinishAction(PanelViewer viewer, TrainingPanel panel) { super(DamusBundle.getString(DamusBundle.ADD_TRAINING_FINISH)); + panelViewer = viewer; + trainingPanel = panel; } @Override public void actionPerformed(ActionEvent e) { Context context = Context.instance(); - context.setDirty(true); + TrainingData data = Context.instance().getTrainingData(); + if (trainingPanel.populateTrainingItem(data.getItem(data.getNumItems() - 1))) { + context.setDirty(true); + panelViewer.closePanel(PanelType.TRAINMODEL); + } } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java 2010-06-21 02:41:11 UTC (rev 69) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java 2010-06-21 02:41:49 UTC (rev 70) @@ -21,20 +21,34 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.data.TrainingData; +import com.mebigfatguy.damus.data.TrainingItem; +import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.gui.TrainingPanel; import com.mebigfatguy.damus.main.Context; public class AddTrainingAndNextAction extends AbstractAction { - private static final long serialVersionUID = -7710191010092049641L; + private static final long serialVersionUID = 3880351786349958924L; + private final PanelViewer panelViewer; + private final TrainingPanel trainingPanel; - public AddTrainingAndNextAction() { + public AddTrainingAndNextAction(PanelViewer viewer, TrainingPanel panel) { super(DamusBundle.getString(DamusBundle.ADD_TRAINING_NEXT)); + panelViewer = viewer; + trainingPanel = panel; } @Override public void actionPerformed(ActionEvent e) { Context context = Context.instance(); - context.setDirty(true); + TrainingData data = Context.instance().getTrainingData(); + if (trainingPanel.populateTrainingItem(data.getItem(data.getNumItems() - 1))) { + context.setDirty(true); + data.addItem(new TrainingItem()); + data.setCurrentIndex(data.getNumItems() - 1); + trainingPanel.reset(); + } } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java 2010-06-21 02:41:11 UTC (rev 69) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/TrainAction.java 2010-06-21 02:41:49 UTC (rev 70) @@ -34,7 +34,7 @@ private static final long serialVersionUID = -5199894453893029822L; - private PanelViewer panelViewer; + private final PanelViewer panelViewer; public TrainAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.TRAIN)); @@ -56,6 +56,6 @@ TrainingData data = Context.instance().getTrainingData(); data.addItem(new TrainingItem()); data.setCurrentIndex(data.getNumItems() - 1); - return new TrainingPanel(true); + return new TrainingPanel(panelViewer, true); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 02:41:17
|
Revision: 69 http://damus.svn.sourceforge.net/damus/?rev=69&view=rev Author: dbrosius Date: 2010-06-21 02:41:11 +0000 (Mon, 21 Jun 2010) Log Message: ----------- add cr's between training items Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-21 01:14:24 UTC (rev 68) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-21 02:41:11 UTC (rev 69) @@ -364,6 +364,7 @@ pw.print(TAB); pw.print(item.getValue(model.getResult(r))); } + pw.println(); } pw.println(); } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-21 01:14:30
|
Revision: 68 http://damus.svn.sourceforge.net/damus/?rev=68&view=rev Author: dbrosius Date: 2010-06-21 01:14:24 +0000 (Mon, 21 Jun 2010) Log Message: ----------- better behaving training panel Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-13 23:05:50 UTC (rev 67) +++ trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-21 01:14:24 UTC (rev 68) @@ -125,6 +125,8 @@ markModelOpen(); selectPanelMenus(); + + tabPane.setSelectedComponent(panel); } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-13 23:05:50 UTC (rev 67) +++ trunk/damus/src/com/mebigfatguy/damus/gui/TrainingPanel.java 2010-06-21 01:14:24 UTC (rev 68) @@ -27,6 +27,7 @@ import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.table.TableColumn; import com.mebigfatguy.damus.bundle.DamusBundle; @@ -40,7 +41,7 @@ private static final long serialVersionUID = -4289076135864687250L; - private boolean isNew; + private final boolean isNew; private JTable trainingTable; private JTable resultsTable; private JTextField descriptionField; @@ -59,6 +60,12 @@ add(createDescriptionPanel(), BorderLayout.NORTH); add(createTrainingPanel(), BorderLayout.CENTER); add(createCtrlPanel(), BorderLayout.SOUTH); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + descriptionField.requestFocus(); + } + }); } private JPanel createDescriptionPanel() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 23:05:56
|
Revision: 67 http://damus.svn.sourceforge.net/damus/?rev=67&view=rev Author: dbrosius Date: 2010-06-13 23:05:50 +0000 (Sun, 13 Jun 2010) Log Message: ----------- on open, set the context file Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 23:04:42 UTC (rev 66) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 23:05:50 UTC (rev 67) @@ -76,6 +76,7 @@ panelViewer.closeAllPanels(); JPanel newPanel = createNewPanel(); panelViewer.openPanel(PanelType.NEWMODEL, newPanel, false); + context.setFile(f); context.setDirty(false); } } catch (IOException ioe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 23:04:48
|
Revision: 66 http://damus.svn.sourceforge.net/damus/?rev=66&view=rev Author: dbrosius Date: 2010-06-13 23:04:42 +0000 (Sun, 13 Jun 2010) Log Message: ----------- don't save null training items Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/data/TrainingData.java trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java Modified: trunk/damus/src/com/mebigfatguy/damus/data/TrainingData.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/data/TrainingData.java 2010-06-13 22:51:16 UTC (rev 65) +++ trunk/damus/src/com/mebigfatguy/damus/data/TrainingData.java 2010-06-13 23:04:42 UTC (rev 66) @@ -19,10 +19,27 @@ import java.util.ArrayList; import java.util.List; -public class TrainingData { +public class TrainingData implements Cloneable { private List<TrainingItem> items = new ArrayList<TrainingItem>(); private int currentIndex = 0; + @Override + public Object clone() { + try { + TrainingData data = (TrainingData)super.clone(); + data.items = new ArrayList<TrainingItem>(); + for (TrainingItem item : items) { + if (item.getDescription() != null) { + data.items.add(item); + } + } + + return data; + } catch (CloneNotSupportedException cnse) { + return new TrainingData(); + } + } + public void addItem(TrainingItem item) { items.add(item); } Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:51:16 UTC (rev 65) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 23:04:42 UTC (rev 66) @@ -347,6 +347,8 @@ } pw.println(); + data = (TrainingData)data.clone(); + int numItems = data.getNumItems(); pw.print(DamusBundle.getString(DamusBundle.TRAINITEM)); pw.print(TAB); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 22:51:22
|
Revision: 65 http://damus.svn.sourceforge.net/damus/?rev=65&view=rev Author: dbrosius Date: 2010-06-13 22:51:16 +0000 (Sun, 13 Jun 2010) Log Message: ----------- save old file before new/quit actions, etc. Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:38:37 UTC (rev 64) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:51:16 UTC (rev 65) @@ -26,7 +26,6 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.io.DamusIO; -import com.mebigfatguy.damus.main.Context; public class SaveAction extends AbstractAction { @@ -39,19 +38,9 @@ public void actionPerformed(ActionEvent e) { File f = null; try { - Context context = Context.instance(); - f = context.getFile(); - if (f == null) { - f = DamusIO.getSaveFile(null); - if (f != null) { - context.setFile(f); - } - } - if (f != null) { - DamusIO.save(f); - context.setDirty(false); - } + f = DamusIO.saveFile(); } catch (IOException ioe) { + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), f); JOptionPane.showMessageDialog(null, msg); } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:38:37 UTC (rev 64) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:51:16 UTC (rev 65) @@ -17,7 +17,6 @@ package com.mebigfatguy.damus.gui.actions; import java.awt.event.ActionEvent; -import java.io.File; import java.io.IOException; import java.text.MessageFormat; @@ -37,17 +36,11 @@ } public void actionPerformed(ActionEvent e) { - Context context = Context.instance(); - File f = null; try { - f = DamusIO.getSaveFile(context.getFile()); - if (f != null) { - DamusIO.save(f); - context.setFile(f); - context.setDirty(false); - } + DamusIO.saveFileAs(); } catch (IOException ioe) { - String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), (f != null) ? f.getPath() : "?"); + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), "?"); + Context context = Context.instance(); JOptionPane.showMessageDialog(context.getFrame(), msg); } } Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:38:37 UTC (rev 64) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:51:16 UTC (rev 65) @@ -50,22 +50,36 @@ } public static boolean checkSave() { - Context context = Context.instance(); - if (context.isDirty()) { - AskSaveType action = DamusIO.askSave(); - switch (action) { - case YES: - return true; - - case NO: - return true; - - case CANCEL: - return false; + try { + Context context = Context.instance(); + if (context.isDirty()) { + AskSaveType action = DamusIO.askSave(); + switch (action) { + case YES: + File f = context.getFile(); + if (f != null) + f = saveFile(); + else + f = saveFileAs(); + return f != null; + + case NO: + return true; + + case CANCEL: + return false; + } } + + return true; + } catch (IOException ioe) { + Context context = Context.instance(); + File f = context.getFile(); + String name = (f != null) ? f.getPath() : DamusBundle.getString(DamusBundle.UNTITLED_FILE); + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), name); + JOptionPane.showMessageDialog(context.getFrame(), msg); + return false; } - - return true; } private static AskSaveType askSave() { @@ -114,6 +128,35 @@ return null; } + public static final File saveFile() throws IOException { + Context context = Context.instance(); + File f = context.getFile(); + if (f == null) { + f = DamusIO.getSaveFile(null); + if (f != null) { + context.setFile(f); + } + } + if (f != null) { + save(f); + context.setDirty(false); + } + + return f; + } + + public static final File saveFileAs() throws IOException { + Context context = Context.instance(); + File f = DamusIO.getSaveFile(context.getFile()); + if (f != null) { + save(f); + context.setFile(f); + context.setDirty(false); + } + + return f; + } + public static File getOpenFile() { JFileChooser fc = new JFileChooser(); @@ -128,7 +171,7 @@ return null; } - public static void save(File f) throws IOException { + private static void save(File f) throws IOException { File temp = File.createTempFile("DIO_", ".csv"); Context context = Context.instance(); PredictionModel model = context.getPredictionModel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 22:38:44
|
Revision: 64 http://damus.svn.sourceforge.net/damus/?rev=64&view=rev Author: dbrosius Date: 2010-06-13 22:38:37 +0000 (Sun, 13 Jun 2010) Log Message: ----------- use static access where available Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -36,8 +36,7 @@ } public void actionPerformed(ActionEvent e) { - DamusIO dio = new DamusIO(); - if (dio.checkSave()) { + if (DamusIO.checkSave()) { panelViewer.closeAllPanels(); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -42,8 +42,7 @@ } public void actionPerformed(ActionEvent e) { - DamusIO dio = new DamusIO(); - if (dio.checkSave()) { + if (DamusIO.checkSave()) { Context context = Context.instance(); context.setPredictionModel(new PredictionModel()); context.setTrainingData(new TrainingData()); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -51,10 +51,10 @@ Context context = Context.instance(); File f = null; try { - DamusIO dio = new DamusIO(); - f = dio.getOpenFile(); + f = DamusIO.getOpenFile(); if (f != null) { + DamusIO dio = new DamusIO(); dio.read(f); PredictionModel predictModel = new PredictionModel(); @@ -79,7 +79,7 @@ context.setDirty(false); } } catch (IOException ioe) { - String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_OPEN_FAILURE), f.getPath()); + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_OPEN_FAILURE), (f != null) ? f.getPath() : "?"); JOptionPane.showMessageDialog(context.getFrame(), msg); } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -32,8 +32,7 @@ } public void actionPerformed(ActionEvent e) { - DamusIO dio = new DamusIO(); - if (dio.checkSave()) { + if (DamusIO.checkSave()) { System.exit(0); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -39,18 +39,16 @@ public void actionPerformed(ActionEvent e) { File f = null; try { - DamusIO dio = new DamusIO(); - Context context = Context.instance(); f = context.getFile(); if (f == null) { - f = dio.getSaveFile(null); + f = DamusIO.getSaveFile(null); if (f != null) { context.setFile(f); } } if (f != null) { - dio.save(f); + DamusIO.save(f); context.setDirty(false); } } catch (IOException ioe) { Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:38:37 UTC (rev 64) @@ -39,17 +39,15 @@ public void actionPerformed(ActionEvent e) { Context context = Context.instance(); File f = null; - try { - DamusIO dio = new DamusIO(); - - f = dio.getSaveFile(context.getFile()); + try { + f = DamusIO.getSaveFile(context.getFile()); if (f != null) { - dio.save(f); + DamusIO.save(f); context.setFile(f); context.setDirty(false); } } catch (IOException ioe) { - String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), f.getPath()); + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), (f != null) ? f.getPath() : "?"); JOptionPane.showMessageDialog(context.getFrame(), msg); } } Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:33:55 UTC (rev 63) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:38:37 UTC (rev 64) @@ -49,11 +49,10 @@ public DamusIO() { } - public boolean checkSave() { + public static boolean checkSave() { Context context = Context.instance(); if (context.isDirty()) { - DamusIO dio = new DamusIO(); - AskSaveType action = dio.askSave(); + AskSaveType action = DamusIO.askSave(); switch (action) { case YES: return true; @@ -69,7 +68,7 @@ return true; } - private AskSaveType askSave() { + private static AskSaveType askSave() { Context context = Context.instance(); File f = context.getFile(); @@ -93,7 +92,7 @@ } } - public File getSaveFile(File f) { + public static File getSaveFile(File f) { JFileChooser fc = new JFileChooser(); fc.setSelectedFile(f); @@ -115,7 +114,7 @@ return null; } - public File getOpenFile() { + public static File getOpenFile() { JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); @@ -129,7 +128,7 @@ return null; } - public void save(File f) throws IOException { + public static void save(File f) throws IOException { File temp = File.createTempFile("DIO_", ".csv"); Context context = Context.instance(); PredictionModel model = context.getPredictionModel(); @@ -264,7 +263,7 @@ return items; } - private boolean checkOverwrite(File f) { + private static boolean checkOverwrite(File f) { if (!f.exists()) { return true; } @@ -275,7 +274,7 @@ return option == JOptionPane.OK_OPTION; } - private void writeData(File f, PredictionModel model, TrainingData data) throws IOException { + private static void writeData(File f, PredictionModel model, TrainingData data) throws IOException { PrintWriter pw = null; try { pw = new PrintWriter(new BufferedWriter(new FileWriter(f))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 22:34:01
|
Revision: 63 http://damus.svn.sourceforge.net/damus/?rev=63&view=rev Author: dbrosius Date: 2010-06-13 22:33:55 +0000 (Sun, 13 Jun 2010) Log Message: ----------- start putting in asking to save on close etc. Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/DeleteForecastDataTypeAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java trunk/damus/src/com/mebigfatguy/damus/main/Context.java Added Paths: ----------- trunk/damus/src/com/mebigfatguy/damus/io/AskSaveType.java Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/DamusBundle.java 2010-06-13 22:33:55 UTC (rev 63) @@ -63,6 +63,8 @@ public static final String DAMUS_OVERWRITE_WARNING = "damus.overwritewarning"; public static final String DAMUS_OPEN_FAILURE = "damus.fileopenfailure"; public static final String DAMUS_SAVE_FAILURE = "damus.filesavefailure"; + public static final String UNTITLED_FILE = "damus.untitledfile"; + public static final String ASK_SAVE = "damus.asksave"; private static ResourceBundle rb = ResourceBundle.getBundle("com/mebigfatguy/damus/bundle/resources"); Modified: trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/bundle/resources.properties 2010-06-13 22:33:55 UTC (rev 63) @@ -42,4 +42,6 @@ damus.filedescription = Damus file (*.dms) damus.overwritewarning = File ''{0}''\n exists, do you want to overwrite it? damus.fileopenfailure = Failed opening damus file:\n''{0}'' -damus.filesavefailure = Failed saving damus file:\n''{0}'' \ No newline at end of file +damus.filesavefailure = Failed saving damus file:\n''{0}'' +damus.untitledfile = Untitled File +damus.asksave = Do you want to save the file\n''{0}''? \ No newline at end of file Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -26,6 +26,7 @@ import com.mebigfatguy.damus.data.ForecastDataType; import com.mebigfatguy.damus.data.MetricType; import com.mebigfatguy.damus.gui.model.MetricsTableModel; +import com.mebigfatguy.damus.main.Context; public class AddForecastDataTypeAction extends AbstractAction { @@ -48,6 +49,8 @@ name = MessageFormat.format(DamusBundle.getString(DamusBundle.METRIC), Integer.valueOf(++metricNum)); } model.addRow(name, MetricType.Percent); + Context context = Context.instance(); + context.setDirty(true); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndFinishAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -21,6 +21,7 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.main.Context; public class AddTrainingAndFinishAction extends AbstractAction { @@ -32,8 +33,8 @@ @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - + Context context = Context.instance(); + context.setDirty(true); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddTrainingAndNextAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -21,6 +21,7 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.main.Context; public class AddTrainingAndNextAction extends AbstractAction { @@ -32,8 +33,8 @@ @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - + Context context = Context.instance(); + context.setDirty(true); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -22,6 +22,7 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.io.DamusIO; public class CloseAction extends AbstractAction { @@ -35,7 +36,10 @@ } public void actionPerformed(ActionEvent e) { - panelViewer.closeAllPanels(); + DamusIO dio = new DamusIO(); + if (dio.checkSave()) { + panelViewer.closeAllPanels(); + } } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/DeleteForecastDataTypeAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/DeleteForecastDataTypeAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/DeleteForecastDataTypeAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -24,12 +24,13 @@ import com.mebigfatguy.damus.bundle.DamusBundle; import com.mebigfatguy.damus.data.ForecastDataType; import com.mebigfatguy.damus.gui.model.MetricsTableModel; +import com.mebigfatguy.damus.main.Context; public class DeleteForecastDataTypeAction extends AbstractAction { private static final long serialVersionUID = 3155375105828862712L; - private JTable metricTable; + private final JTable metricTable; public DeleteForecastDataTypeAction(JTable table, ForecastDataType type) { super(DamusBundle.getString((type == ForecastDataType.Metric) ? DamusBundle.DELETE_METRIC : DamusBundle.DELETE_RESULT)); @@ -43,5 +44,7 @@ for (int i = selectedRows.length - 1; i >= 0; i--) { model.removeMetric(selectedRows[i]); } + Context context = Context.instance(); + context.setDirty(true); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -27,6 +27,7 @@ import com.mebigfatguy.damus.gui.NewModelPanel; import com.mebigfatguy.damus.gui.PanelType; import com.mebigfatguy.damus.gui.PanelViewer; +import com.mebigfatguy.damus.io.DamusIO; import com.mebigfatguy.damus.main.Context; public class NewAction extends AbstractAction { @@ -41,11 +42,15 @@ } public void actionPerformed(ActionEvent e) { - Context context = Context.instance(); - context.setPredictionModel(new PredictionModel()); - context.setTrainingData(new TrainingData()); - JPanel newPanel = createNewPanel(); - panelViewer.openPanel(PanelType.NEWMODEL, newPanel, false); + DamusIO dio = new DamusIO(); + if (dio.checkSave()) { + Context context = Context.instance(); + context.setPredictionModel(new PredictionModel()); + context.setTrainingData(new TrainingData()); + JPanel newPanel = createNewPanel(); + panelViewer.openPanel(PanelType.NEWMODEL, newPanel, false); + context.setDirty(false); + } } private JPanel createNewPanel() { Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/OpenAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -48,7 +48,7 @@ } public void actionPerformed(ActionEvent e) { - Context con = Context.instance(); + Context context = Context.instance(); File f = null; try { DamusIO dio = new DamusIO(); @@ -64,22 +64,23 @@ for (Metric result : dio.getResults()) { predictModel.addResult(result); } - con.setPredictionModel(predictModel); + context.setPredictionModel(predictModel); TrainingData trainingData = new TrainingData(); for (TrainingItem item : dio.getTrainingItems()) { trainingData.addItem(item); } - con.setTrainingData(trainingData); + context.setTrainingData(trainingData); panelViewer.closeAllPanels(); JPanel newPanel = createNewPanel(); panelViewer.openPanel(PanelType.NEWMODEL, newPanel, false); + context.setDirty(false); } } catch (IOException ioe) { String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_OPEN_FAILURE), f.getPath()); - JOptionPane.showMessageDialog(con.getFrame(), msg); + JOptionPane.showMessageDialog(context.getFrame(), msg); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/QuitAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -21,6 +21,7 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; +import com.mebigfatguy.damus.io.DamusIO; public class QuitAction extends AbstractAction { @@ -31,7 +32,9 @@ } public void actionPerformed(ActionEvent e) { - System.exit(0); + DamusIO dio = new DamusIO(); + if (dio.checkSave()) { + System.exit(0); + } } - } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -41,16 +41,17 @@ try { DamusIO dio = new DamusIO(); - Context con = Context.instance(); - f = con.getFile(); + Context context = Context.instance(); + f = context.getFile(); if (f == null) { f = dio.getSaveFile(null); if (f != null) { - con.setFile(f); + context.setFile(f); } } if (f != null) { dio.save(f); + context.setDirty(false); } } catch (IOException ioe) { String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), f); Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/SaveAsAction.java 2010-06-13 22:33:55 UTC (rev 63) @@ -37,19 +37,20 @@ } public void actionPerformed(ActionEvent e) { - Context con = Context.instance(); + Context context = Context.instance(); File f = null; try { DamusIO dio = new DamusIO(); - f = dio.getSaveFile(con.getFile()); + f = dio.getSaveFile(context.getFile()); if (f != null) { dio.save(f); - con.setFile(f); + context.setFile(f); + context.setDirty(false); } } catch (IOException ioe) { String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_SAVE_FAILURE), f.getPath()); - JOptionPane.showMessageDialog(con.getFrame(), msg); + JOptionPane.showMessageDialog(context.getFrame(), msg); } } } Added: trunk/damus/src/com/mebigfatguy/damus/io/AskSaveType.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/AskSaveType.java (rev 0) +++ trunk/damus/src/com/mebigfatguy/damus/io/AskSaveType.java 2010-06-13 22:33:55 UTC (rev 63) @@ -0,0 +1,23 @@ +/* + * damus - a forecasting tool + * Copyright (C) 2010 Dave Brosius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations + * under the License. + */ +package com.mebigfatguy.damus.io; + +public enum AskSaveType { + YES, + NO, + CANCEL; +} Property changes on: trunk/damus/src/com/mebigfatguy/damus/io/AskSaveType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 22:33:55 UTC (rev 63) @@ -49,6 +49,50 @@ public DamusIO() { } + public boolean checkSave() { + Context context = Context.instance(); + if (context.isDirty()) { + DamusIO dio = new DamusIO(); + AskSaveType action = dio.askSave(); + switch (action) { + case YES: + return true; + + case NO: + return true; + + case CANCEL: + return false; + } + } + + return true; + } + + private AskSaveType askSave() { + Context context = Context.instance(); + + File f = context.getFile(); + String name; + + if (f == null) { + name = DamusBundle.getString(DamusBundle.UNTITLED_FILE); + } else { + name = f.getPath(); + } + + String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.ASK_SAVE), name); + int option = JOptionPane.showConfirmDialog(context.getFrame(), msg); + switch (option) { + case JOptionPane.OK_OPTION: + return AskSaveType.YES; + case JOptionPane.NO_OPTION: + return AskSaveType.NO; + default: + return AskSaveType.CANCEL; + } + } + public File getSaveFile(File f) { JFileChooser fc = new JFileChooser(); @@ -87,9 +131,9 @@ public void save(File f) throws IOException { File temp = File.createTempFile("DIO_", ".csv"); - Context con = Context.instance(); - PredictionModel model = con.getPredictionModel(); - TrainingData data = con.getTrainingData(); + Context context = Context.instance(); + PredictionModel model = context.getPredictionModel(); + TrainingData data = context.getTrainingData(); writeData(temp, model, data); if (f != null) { f.delete(); @@ -225,9 +269,9 @@ return true; } - Context con = Context.instance(); + Context context = Context.instance(); String msg = MessageFormat.format(DamusBundle.getString(DamusBundle.DAMUS_OVERWRITE_WARNING), f.getPath()); - int option = JOptionPane.showConfirmDialog(con.getFrame(), msg); + int option = JOptionPane.showConfirmDialog(context.getFrame(), msg); return option == JOptionPane.OK_OPTION; } Modified: trunk/damus/src/com/mebigfatguy/damus/main/Context.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/main/Context.java 2010-06-13 22:08:51 UTC (rev 62) +++ trunk/damus/src/com/mebigfatguy/damus/main/Context.java 2010-06-13 22:33:55 UTC (rev 63) @@ -30,6 +30,7 @@ private PredictionModel predictionModel; private TrainingData trainingData; private File file; + private boolean isDirty = false; public static final Context instance() { @@ -70,4 +71,12 @@ public File getFile() { return file; } + + public boolean isDirty() { + return isDirty; + } + + public void setDirty(boolean dirty) { + isDirty = dirty; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 22:08:57
|
Revision: 62 http://damus.svn.sourceforge.net/damus/?rev=62&view=rev Author: dbrosius Date: 2010-06-13 22:08:51 +0000 (Sun, 13 Jun 2010) Log Message: ----------- better menu handling Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-13 21:59:35 UTC (rev 61) +++ trunk/damus/src/com/mebigfatguy/damus/gui/DamusFrame.java 2010-06-13 22:08:51 UTC (rev 62) @@ -162,7 +162,8 @@ closeItem.setEnabled(true); saveItem.setEnabled(true); saveAsItem.setEnabled(true); - dataMenu.setEnabled(true); + dataMenu.setEnabled(true); + modelItem.setSelected(true); } public void markModelClosed() { @@ -172,5 +173,6 @@ saveItem.setEnabled(false); saveAsItem.setEnabled(false); dataMenu.setEnabled(false); + modelItem.setSelected(false); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 21:59:35 UTC (rev 61) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/CloseAction.java 2010-06-13 22:08:51 UTC (rev 62) @@ -21,14 +21,13 @@ import javax.swing.AbstractAction; import com.mebigfatguy.damus.bundle.DamusBundle; -import com.mebigfatguy.damus.gui.PanelType; import com.mebigfatguy.damus.gui.PanelViewer; public class CloseAction extends AbstractAction { private static final long serialVersionUID = 521821313394388535L; - private PanelViewer panelViewer; + private final PanelViewer panelViewer; public CloseAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.CLOSE)); @@ -36,7 +35,7 @@ } public void actionPerformed(ActionEvent e) { - panelViewer.closePanel(PanelType.NEWMODEL); + panelViewer.closeAllPanels(); } } Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 21:59:35 UTC (rev 61) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/NewAction.java 2010-06-13 22:08:51 UTC (rev 62) @@ -33,7 +33,7 @@ private static final long serialVersionUID = -1656403699359626055L; - private PanelViewer panelViewer; + private final PanelViewer panelViewer; public NewAction(PanelViewer viewer) { super(DamusBundle.getString(DamusBundle.NEW)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 21:59:41
|
Revision: 61 http://damus.svn.sourceforge.net/damus/?rev=61&view=rev Author: dbrosius Date: 2010-06-13 21:59:35 +0000 (Sun, 13 Jun 2010) Log Message: ----------- guard against bad file formats Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java Modified: trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 21:57:42 UTC (rev 60) +++ trunk/damus/src/com/mebigfatguy/damus/io/DamusIO.java 2010-06-13 21:59:35 UTC (rev 61) @@ -201,7 +201,8 @@ } items[i] = item; } - + } catch (Exception e) { + throw new IOException("Failed reading Damus file : " + f.getPath(), e); } finally { Closer.close(br); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 21:57:48
|
Revision: 60 http://damus.svn.sourceforge.net/damus/?rev=60&view=rev Author: dbrosius Date: 2010-06-13 21:57:42 +0000 (Sun, 13 Jun 2010) Log Message: ----------- sync access to static fields Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java Modified: trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java 2010-06-13 21:55:57 UTC (rev 59) +++ trunk/damus/src/com/mebigfatguy/damus/gui/actions/AddForecastDataTypeAction.java 2010-06-13 21:57:42 UTC (rev 60) @@ -42,7 +42,11 @@ @Override public void actionPerformed(ActionEvent e) { MetricsTableModel model = (MetricsTableModel)metricTable.getModel(); - String name = MessageFormat.format(DamusBundle.getString(DamusBundle.METRIC), Integer.valueOf(++metricNum)); + String name; + + synchronized(AddForecastDataTypeAction.class) { + name = MessageFormat.format(DamusBundle.getString(DamusBundle.METRIC), Integer.valueOf(++metricNum)); + } model.addRow(name, MetricType.Percent); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-06-13 21:56:03
|
Revision: 59 http://damus.svn.sourceforge.net/damus/?rev=59&view=rev Author: dbrosius Date: 2010-06-13 21:55:57 +0000 (Sun, 13 Jun 2010) Log Message: ----------- sync access to statics Modified Paths: -------------- trunk/damus/src/com/mebigfatguy/damus/data/ForecastDataType.java Modified: trunk/damus/src/com/mebigfatguy/damus/data/ForecastDataType.java =================================================================== --- trunk/damus/src/com/mebigfatguy/damus/data/ForecastDataType.java 2010-06-13 21:51:06 UTC (rev 58) +++ trunk/damus/src/com/mebigfatguy/damus/data/ForecastDataType.java 2010-06-13 21:55:57 UTC (rev 59) @@ -36,7 +36,9 @@ } public String getDefaultString() { - return MessageFormat.format(DamusBundle.getString(defaultKey), Integer.valueOf(++sNum)); + synchronized(ForecastDataType.class) { + return MessageFormat.format(DamusBundle.getString(defaultKey), Integer.valueOf(++sNum)); + } } public String getAddString() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |