diff --git a/.gitignore b/.gitignore
index bbfe8d2..658fd81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,23 @@
-.idea/
-.gradle/
-.settings
-.classpath
+# OS generated files
+################################################################################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db
+
+# Others
+################################################################################
+.gradle
build/
-src/main/java/net/rptools/dicetool/dicetool/
+/bin/
+target/
+out/
+/releases/
+*.log
+*~
+\${sys:appHome}/
+/.idea
diff --git a/build.gradle b/build.gradle
index d0afeb3..2a2cc71 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,27 +1,66 @@
+buildscript {
+ dependencies {
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:3.26.1"
+ }
+ repositories {
+ mavenCentral()
+ }
+}
+
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
//apply plugin: 'findbugs' -- findbugs does not work with java version 9
-
+apply plugin: 'com.diffplug.gradle.spotless'
repositories {
- mavenCentral()
+ // Use 'jcenter' for resolving your dependencies.
+ // You can declare any Maven/Ivy/file repository here.
mavenLocal()
- maven {
- url = 'http://maptool.craigs-stuff.net/repo/'
- }
+ mavenCentral()
+ jcenter()
+ maven { url = 'http://maptool.craigs-stuff.net/repo/' }
+ maven { url = 'http://www.nerps.net/repo/' }
+ maven { url = 'https://jitpack.io' }
}
dependencies {
- compile 'net.rptools.rplib:rplib:1.4.1.4'
- compile 'net.rptools.dicelib:dicelib:1.4.0.1'
- compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.3.1'
testCompile 'rhino:js:1.6R2'
testCompile group: 'junit', name: 'junit', version: '4.11'
+ implementation 'com.thoughtworks.xstream:xstream:1.4.11.1'
+ implementation 'net.rptools.rplib:rplib:1.4.1.7'
+ implementation 'com.github.RPTools:parser:1.8.2'
+ implementation 'com.github.RPTools:dicelib:1.6.6'
}
-version='1.4.0'
+spotless {
+ java {
+ licenseHeaderFile 'spotless.license.java'
+ // Now using the Google Java style guide
+ //eclipse().configFile('build-resources/eclipse.prefs.formatter.xml')
+ googleJavaFormat()
+ // If you get exceptions thrown by spotlessApply, this might
+ // help. Enable it here if the problem is with a Java file, and
+ // below if it is not. Don't leave it enabled, as nothing will
+ // actually be updated if you do.
+ // https://github.com/diffplug/spotless/blob/master/PADDEDCELL.md
+ //paddedCell()
+ }
+
+ format 'misc', {
+ target '**/*.gradle', '**/.gitignore'
+
+ // spotless has built-in rules for most basic formatting tasks
+ trimTrailingWhitespace()
+ // or spaces. Takes an integer argument if you don't like 4
+ indentWithSpaces(4)
+ //paddedCell()
+ }
+}
+
+
+version='1.4.1'
project.version = version
install {
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 48bdcba..758de96 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index bc164f5..a4f0001 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Sat Mar 04 13:37:30 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip
diff --git a/gradlew b/gradlew
index 4453cce..cccdd3d 100755
--- a/gradlew
+++ b/gradlew
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
-save ( ) {
+save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
diff --git a/spotless.license.java b/spotless.license.java
new file mode 100644
index 0000000..722d029
--- /dev/null
+++ b/spotless.license.java
@@ -0,0 +1,24 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
diff --git a/src/main/java/net/rptools/dicetool/DiceTool.java b/src/main/java/net/rptools/dicetool/DiceTool.java
index 56f4cae..e046579 100644
--- a/src/main/java/net/rptools/dicetool/DiceTool.java
+++ b/src/main/java/net/rptools/dicetool/DiceTool.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool;
@@ -27,36 +27,28 @@
import java.awt.Toolkit;
import java.security.SecureRandom;
import java.util.Random;
-
import javax.swing.UIManager;
-
-import net.rptools.dicetool.ui.MainFrame;
import net.rptools.dicetool.ui.MainFrame;
-
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
+ *
To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class DiceTool {
- public static Random RANDOM = new SecureRandom();
+ public static Random RANDOM = new SecureRandom();
+
+ /** @param args the command line arguments */
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
+ } catch (Exception e) {
+ System.err.println("Exception during look and feel setup: " + e);
+ }
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- try {
- UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
- } catch (Exception e) {
- System.err.println("Exception during look and feel setup: " + e);
- }
+ // Draw frame contents on resize
+ Toolkit.getDefaultToolkit().setDynamicLayout(true);
-// Draw frame contents on resize
- Toolkit.getDefaultToolkit().setDynamicLayout(true);
-
- MainFrame tool = new MainFrame();
- }
+ MainFrame tool = new MainFrame();
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/Test02.java b/src/main/java/net/rptools/dicetool/Test02.java
index 0de01df..c124837 100644
--- a/src/main/java/net/rptools/dicetool/Test02.java
+++ b/src/main/java/net/rptools/dicetool/Test02.java
@@ -1,29 +1,51 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package net.rptools.dicetool;
+import com.jeta.forms.components.panel.FormPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-
import javax.swing.AbstractButton;
import javax.swing.JFrame;
-import com.jeta.forms.components.panel.FormPanel;
-
public class Test02 {
- public static void main(String... args) throws Exception {
- FormPanel panel = new FormPanel("java/net.rptools.dicetool.dicetool/ui/forms/QuickRollPanel.xml");
- AbstractButton addbtn = panel.getButton( "rollD2" );
- addbtn.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- System.out.println("Action done");
- }
- });
-
- JFrame frame = new JFrame();
- frame.add(panel);
-
- frame.setVisible(true);
- }
+ public static void main(String... args) throws Exception {
+ FormPanel panel =
+ new FormPanel("java/net.rptools.dicetool.dicetool/ui/forms/QuickRollPanel.xml");
+ AbstractButton addbtn = panel.getButton("rollD2");
+ addbtn.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ System.out.println("Action done");
+ }
+ });
+
+ JFrame frame = new JFrame();
+ frame.add(panel);
+
+ frame.setVisible(true);
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/AbstractData.java b/src/main/java/net/rptools/dicetool/model/AbstractData.java
index 282d3b9..abc7762 100644
--- a/src/main/java/net/rptools/dicetool/model/AbstractData.java
+++ b/src/main/java/net/rptools/dicetool/model/AbstractData.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
@@ -28,25 +28,25 @@
import java.util.List;
public class AbstractData {
- private List variables = new ArrayList();
+ private List variables = new ArrayList();
- private List functions = new ArrayList();
+ private List functions = new ArrayList();
- private String javascript;
+ private String javascript;
- public List getFunctions() {
- return functions;
- }
+ public List getFunctions() {
+ return functions;
+ }
- public String getJavascript() {
- return javascript;
- }
+ public String getJavascript() {
+ return javascript;
+ }
- public void setJavascript(String javascript) {
- this.javascript = javascript;
- }
+ public void setJavascript(String javascript) {
+ this.javascript = javascript;
+ }
- public List getVariables() {
- return variables;
- }
+ public List getVariables() {
+ return variables;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/Button.java b/src/main/java/net/rptools/dicetool/model/Button.java
index 438fd9c..2204bb0 100644
--- a/src/main/java/net/rptools/dicetool/model/Button.java
+++ b/src/main/java/net/rptools/dicetool/model/Button.java
@@ -1,65 +1,62 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
-import net.rptools.dicetool.model.xstream.ButtonConverter;
-import java.util.ArrayList;
-import java.util.List;
-
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
+import java.util.ArrayList;
+import java.util.List;
+import net.rptools.dicetool.model.xstream.ButtonConverter;
@XStreamAlias("button")
@XStreamConverter(ButtonConverter.class)
public class Button {
- private String name;
+ private String name;
- private List expressions = new ArrayList();
+ private List expressions = new ArrayList();
- public Button() {
- }
+ public Button() {}
- public Button(String name) {
- this.name = name;
- }
+ public Button(String name) {
+ this.name = name;
+ }
- public Button(String name, String... expressions) {
- this.name = name;
- for (String x : expressions)
- this.expressions.add(x);
- }
+ public Button(String name, String... expressions) {
+ this.name = name;
+ for (String x : expressions) this.expressions.add(x);
+ }
- public List getExpressions() {
- return expressions;
- }
+ public List getExpressions() {
+ return expressions;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/ButtonGroup.java b/src/main/java/net/rptools/dicetool/model/ButtonGroup.java
index 3135294..d069a85 100644
--- a/src/main/java/net/rptools/dicetool/model/ButtonGroup.java
+++ b/src/main/java/net/rptools/dicetool/model/ButtonGroup.java
@@ -1,67 +1,64 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
-import java.util.ArrayList;
-import java.util.List;
-
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicitCollection;
+import java.util.ArrayList;
+import java.util.List;
@XStreamAlias("button-group")
-@XStreamImplicitCollection(value="buttons")
+@XStreamImplicitCollection(value = "buttons")
public class ButtonGroup extends AbstractData {
- private String name;
-
- private List buttons = new ArrayList();
+ private String name;
- public ButtonGroup() {
+ private List buttons = new ArrayList();
- }
+ public ButtonGroup() {}
- public ButtonGroup(String name) {
- this.name = name;
- }
+ public ButtonGroup(String name) {
+ this.name = name;
+ }
- public List getButtons() {
- return buttons;
- }
+ public List getButtons() {
+ return buttons;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- public static String toXml(ButtonGroup buttonGroup) {
- return Data.getXStream().toXML(buttonGroup);
- }
+ public static String toXml(ButtonGroup buttonGroup) {
+ return Data.getXStream().toXML(buttonGroup);
+ }
- public static ButtonGroup fromXml(String xml) {
- return (ButtonGroup) Data.getXStream().fromXML(xml);
- }
+ public static ButtonGroup fromXml(String xml) {
+ return (ButtonGroup) Data.getXStream().fromXML(xml);
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/Data.java b/src/main/java/net/rptools/dicetool/model/Data.java
index f288665..46b5f18 100644
--- a/src/main/java/net/rptools/dicetool/model/Data.java
+++ b/src/main/java/net/rptools/dicetool/model/Data.java
@@ -1,63 +1,62 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
-import java.util.ArrayList;
-import java.util.List;
-
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.Annotations;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicitCollection;
+import java.util.ArrayList;
+import java.util.List;
@XStreamAlias("net.rptools.dicetool.dicetool")
-@XStreamImplicitCollection(value="buttonGroups")
+@XStreamImplicitCollection(value = "buttonGroups")
public class Data extends AbstractData {
- private List buttonGroups = new ArrayList();
-
- public List getButtonGroups() {
- return buttonGroups;
- }
-
- public static String toXml(Data data) {
- return getXStream().toXML(data);
- }
-
- public static Data fromXml(String xml) {
- return (Data) getXStream().fromXML(xml);
- }
-
- static XStream getXStream() {
- XStream xstream = new XStream();
-
- Annotations.configureAliases(xstream, Button.class);
- Annotations.configureAliases(xstream, ButtonGroup.class);
- Annotations.configureAliases(xstream, Data.class);
- Annotations.configureAliases(xstream, Function.class);
- Annotations.configureAliases(xstream, Variable.class);
-
- return xstream;
- }
+ private List buttonGroups = new ArrayList();
+
+ public List getButtonGroups() {
+ return buttonGroups;
+ }
+
+ public static String toXml(Data data) {
+ return getXStream().toXML(data);
+ }
+
+ public static Data fromXml(String xml) {
+ return (Data) getXStream().fromXML(xml);
+ }
+
+ static XStream getXStream() {
+ XStream xstream = new XStream();
+
+ Annotations.configureAliases(xstream, Button.class);
+ Annotations.configureAliases(xstream, ButtonGroup.class);
+ Annotations.configureAliases(xstream, Data.class);
+ Annotations.configureAliases(xstream, Function.class);
+ Annotations.configureAliases(xstream, Variable.class);
+
+ return xstream;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/Function.java b/src/main/java/net/rptools/dicetool/model/Function.java
index fe076ca..6103aba 100644
--- a/src/main/java/net/rptools/dicetool/model/Function.java
+++ b/src/main/java/net/rptools/dicetool/model/Function.java
@@ -1,96 +1,94 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
-import java.util.ArrayList;
-import java.util.List;
-
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicitCollection;
+import java.util.ArrayList;
+import java.util.List;
@XStreamAlias("function")
-@XStreamImplicitCollection(value="aliases", item="alias")
+@XStreamImplicitCollection(value = "aliases", item = "alias")
public class Function {
- private String name;
-
- private Class returnType;
+ private String name;
- private int minParameters;
+ private Class returnType;
- private int maxParameters;
+ private int minParameters;
- private boolean deterministic;
+ private int maxParameters;
- private List aliases = new ArrayList();
+ private boolean deterministic;
- public List getAliases() {
- return aliases;
- }
+ private List aliases = new ArrayList();
- public void setAliases(List aliases) {
- this.aliases = aliases;
- }
+ public List getAliases() {
+ return aliases;
+ }
- public boolean isDeterministic() {
- return deterministic;
- }
+ public void setAliases(List aliases) {
+ this.aliases = aliases;
+ }
- public void setDeterministic(boolean deterministic) {
- this.deterministic = deterministic;
- }
+ public boolean isDeterministic() {
+ return deterministic;
+ }
- public String getFunctionName() {
- return name;
- }
+ public void setDeterministic(boolean deterministic) {
+ this.deterministic = deterministic;
+ }
- public void setFunctionName(String functionName) {
- this.name = functionName;
- }
+ public String getFunctionName() {
+ return name;
+ }
- public int getMaxParameters() {
- return maxParameters;
- }
+ public void setFunctionName(String functionName) {
+ this.name = functionName;
+ }
- public void setMaxParameters(int maxParameters) {
- this.maxParameters = maxParameters;
- }
+ public int getMaxParameters() {
+ return maxParameters;
+ }
- public int getMinParameters() {
- return minParameters;
- }
+ public void setMaxParameters(int maxParameters) {
+ this.maxParameters = maxParameters;
+ }
- public void setMinParameters(int minParameters) {
- this.minParameters = minParameters;
- }
+ public int getMinParameters() {
+ return minParameters;
+ }
- public Class getReturnType() {
- return returnType;
- }
+ public void setMinParameters(int minParameters) {
+ this.minParameters = minParameters;
+ }
- public void setReturnType(Class returnType) {
- this.returnType = returnType;
- }
+ public Class getReturnType() {
+ return returnType;
+ }
+ public void setReturnType(Class returnType) {
+ this.returnType = returnType;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/Variable.java b/src/main/java/net/rptools/dicetool/model/Variable.java
index 18c8919..6da693c 100644
--- a/src/main/java/net/rptools/dicetool/model/Variable.java
+++ b/src/main/java/net/rptools/dicetool/model/Variable.java
@@ -1,31 +1,29 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model;
-import net.rptools.dicetool.model.xstream.VariableConverter;
-
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import net.rptools.dicetool.model.xstream.VariableConverter;
@@ -33,31 +31,30 @@
@XStreamAlias("variable")
@XStreamConverter(VariableConverter.class)
public class Variable {
- private String name;
+ private String name;
- private String value;
+ private String value;
- public Variable() {
- }
+ public Variable() {}
- public Variable(String name, String value) {
- this.name = name;
- this.value = value;
- }
+ public Variable(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- public String getValue() {
- return value;
- }
+ public String getValue() {
+ return value;
+ }
- public void setValue(String value) {
- this.value = value;
- }
+ public void setValue(String value) {
+ this.value = value;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/xstream/ButtonConverter.java b/src/main/java/net/rptools/dicetool/model/xstream/ButtonConverter.java
index 2591d08..b094e14 100644
--- a/src/main/java/net/rptools/dicetool/model/xstream/ButtonConverter.java
+++ b/src/main/java/net/rptools/dicetool/model/xstream/ButtonConverter.java
@@ -1,31 +1,29 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model.xstream;
-import net.rptools.dicetool.model.Button;
-
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
@@ -35,32 +33,31 @@
public class ButtonConverter implements Converter {
- public boolean canConvert(Class type) {
- return type.equals(Button.class);
- }
+ public boolean canConvert(Class type) {
+ return type.equals(Button.class);
+ }
+
+ public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
+ Button o = (Button) source;
+
+ writer.addAttribute("name", o.getName());
+
+ for (String x : o.getExpressions()) {
+ writer.startNode("expression");
+ writer.setValue(x);
+ writer.endNode();
+ }
+ }
- public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
- Button o = (Button) source;
-
- writer.addAttribute("name", o.getName());
-
- for (String x : o.getExpressions()) {
- writer.startNode("expression");
- writer.setValue(x);
- writer.endNode();
- }
- }
+ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ Button o = new Button(reader.getAttribute("name"));
- public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
- Button o = new Button(reader.getAttribute("name"));
-
- while (reader.hasMoreChildren()) {
- reader.moveDown();
- o.getExpressions().add(reader.getValue());
- reader.moveUp();
- }
-
- return o;
- }
+ while (reader.hasMoreChildren()) {
+ reader.moveDown();
+ o.getExpressions().add(reader.getValue());
+ reader.moveUp();
+ }
+ return o;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/model/xstream/VariableConverter.java b/src/main/java/net/rptools/dicetool/model/xstream/VariableConverter.java
index afa86db..757dccd 100644
--- a/src/main/java/net/rptools/dicetool/model/xstream/VariableConverter.java
+++ b/src/main/java/net/rptools/dicetool/model/xstream/VariableConverter.java
@@ -1,52 +1,50 @@
/* The MIT License
- *
- * Copyright (c) 2006 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.model.xstream;
-import net.rptools.dicetool.model.Variable;
-
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import net.rptools.dicetool.model.Variable;
public class VariableConverter implements Converter {
- public boolean canConvert(Class type) {
- return type.equals(Variable.class);
- }
+ public boolean canConvert(Class type) {
+ return type.equals(Variable.class);
+ }
- public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
- Variable var = (Variable) source;
-
- writer.addAttribute("name", var.getName());
- writer.setValue(var.getValue());
- }
+ public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
+ Variable var = (Variable) source;
- public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
- return new Variable(reader.getAttribute("name"), reader.getValue());
- }
+ writer.addAttribute("name", var.getName());
+ writer.setValue(var.getValue());
+ }
+ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ return new Variable(reader.getAttribute("name"), reader.getValue());
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/resultset/Row.java b/src/main/java/net/rptools/dicetool/resultset/Row.java
index 5ee5270..c29473e 100644
--- a/src/main/java/net/rptools/dicetool/resultset/Row.java
+++ b/src/main/java/net/rptools/dicetool/resultset/Row.java
@@ -1,47 +1,45 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.resultset;
public class Row {
- private String value;
+ private String value;
- public Row(String value) {
- this.value = value;
- }
+ public Row(String value) {
+ this.value = value;
+ }
- public String getValue() {
- return value;
- }
+ public String getValue() {
+ return value;
+ }
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- return "" + value + " ";
- }
+ public void setValue(String value) {
+ this.value = value;
+ }
-
-}
\ No newline at end of file
+ public String toString() {
+ return "" + value + " ";
+ }
+}
diff --git a/src/main/java/net/rptools/dicetool/ui/CellColorWrapper.java b/src/main/java/net/rptools/dicetool/ui/CellColorWrapper.java
index 873c8a6..46ff39a 100644
--- a/src/main/java/net/rptools/dicetool/ui/CellColorWrapper.java
+++ b/src/main/java/net/rptools/dicetool/ui/CellColorWrapper.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
@@ -28,52 +28,51 @@
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class CellColorWrapper {
- private Object wrappedObject;
- private Color background;
- private Color foreground;
-
- public CellColorWrapper(Object o) {
- this(o, Color.WHITE, Color.BLACK);
- }
-
- public CellColorWrapper(Object o, Color foreground, Color background) {
- this.wrappedObject = o;
- this.background = background;
- this.foreground = foreground;
- }
+ private Object wrappedObject;
+ private Color background;
+ private Color foreground;
+
+ public CellColorWrapper(Object o) {
+ this(o, Color.WHITE, Color.BLACK);
+ }
+
+ public CellColorWrapper(Object o, Color foreground, Color background) {
+ this.wrappedObject = o;
+ this.background = background;
+ this.foreground = foreground;
+ }
- public String toString() {
- if (wrappedObject == null) return null;
+ public String toString() {
+ if (wrappedObject == null) return null;
- return wrappedObject.toString();
- }
+ return wrappedObject.toString();
+ }
- public Color getBackground() {
- return background;
- }
+ public Color getBackground() {
+ return background;
+ }
- public Color getForeground() {
- return foreground;
- }
+ public Color getForeground() {
+ return foreground;
+ }
- public Object getWrappedObject() {
- return wrappedObject;
- }
+ public Object getWrappedObject() {
+ return wrappedObject;
+ }
- public void setBackground(Color color) {
- background = color;
- }
+ public void setBackground(Color color) {
+ background = color;
+ }
- public void setForeground(Color color) {
- foreground = color;
- }
+ public void setForeground(Color color) {
+ foreground = color;
+ }
- public void setWrappedObject(Object object) {
- wrappedObject = object;
- }
+ public void setWrappedObject(Object object) {
+ wrappedObject = object;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/ContextMenu.java b/src/main/java/net/rptools/dicetool/ui/ContextMenu.java
index 8e08cac..b20d9c2 100644
--- a/src/main/java/net/rptools/dicetool/ui/ContextMenu.java
+++ b/src/main/java/net/rptools/dicetool/ui/ContextMenu.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
@@ -27,130 +27,133 @@
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.Iterator;
-
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
-
-/**
- *
- * @author drice
- */
+/** @author drice */
public class ContextMenu extends JMenu {
- private static final long serialVersionUID = -8983330745044681975L;
- private MainFrame mainFrame;
-
- /** Creates a new instance of ContentMenu */
- public ContextMenu(MainFrame tool, String name) {
- super(name);
-
- this.mainFrame = tool;
-
- this.addSeparator();
-
- this.add(new AbstractAction("New") {
- private static final long serialVersionUID = -5599644198250553600L;
-
- public void actionPerformed(ActionEvent e) {
-
- String name = JOptionPane.showInputDialog(mainFrame, "Tab name", String.valueOf(mainFrame.getRollPanels().size()));
-
- // Create a new Tab
- CustomRollPanel rollPanel = new CustomRollPanel(mainFrame);
- rollPanel.setName(name);
-
- mainFrame.getRollPanels().add(rollPanel);
-
- mainFrame.getCustomRollTab().removeAll();
- for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
- rollPanel = (CustomRollPanel) i.next();
- mainFrame.getCustomRollTab().add(rollPanel);
- }
- }
- });
-
- this.add(new AbstractAction("Delete") {
- private static final long serialVersionUID = -6862072617245621294L;
-
- public void actionPerformed(ActionEvent e) {
- int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
-
- CustomRollPanel rollPanel = (CustomRollPanel) mainFrame.getRollPanels().remove(selectedIndex);
- mainFrame.getCustomRollTab().remove(rollPanel);
- }
- });
-
- this.add(new AbstractAction("Rename") {
- private static final long serialVersionUID = -5890580966305343270L;
-
- public void actionPerformed(ActionEvent e) {
- int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
-
- CustomRollPanel rollPanel = (CustomRollPanel) mainFrame.getRollPanels().get(selectedIndex);
-
- String name = JOptionPane.showInputDialog(mainFrame, "Tab name", rollPanel.getName());
-
- rollPanel.setName(name);
- mainFrame.getCustomRollTab().removeAll();
- for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
- rollPanel = (CustomRollPanel) i.next();
- mainFrame.getCustomRollTab().add(rollPanel);
- }
-
- mainFrame.getCustomRollTab().setSelectedIndex(selectedIndex);
- }
- });
-
- this.addSeparator();
-
- this.add(new AbstractAction("Move ->") {
- private static final long serialVersionUID = -4248301524310372222L;
-
- public void actionPerformed(ActionEvent e) {
- int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
-
- if (selectedIndex < mainFrame.getRollPanels().size() - 1) {
- CustomRollPanel rollPanel = (CustomRollPanel) mainFrame.getRollPanels().remove(selectedIndex);
-
- mainFrame.getRollPanels().add(selectedIndex + 1, rollPanel);
-
- mainFrame.getCustomRollTab().removeAll();
- for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
- rollPanel = (CustomRollPanel) i.next();
- mainFrame.getCustomRollTab().add(rollPanel);
- }
-
- mainFrame.getCustomRollTab().setSelectedIndex(selectedIndex + 1);
- }
- }
- });
-
- this.addSeparator();
-
- this.add(new AbstractAction("Export") {
- private static final long serialVersionUID = -6958791608623693284L;
-
- public void actionPerformed(ActionEvent e) {
- int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
-
- JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Export tab");
- fc.setCurrentDirectory(new File("."));
-
- int result = fc.showOpenDialog(mainFrame);
-
- if (result == JFileChooser.CANCEL_OPTION) {
-
- } else if (result == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
-
- mainFrame.exportPreferences(file, selectedIndex);
- }
-
- }
- });
- }
-
+ private static final long serialVersionUID = -8983330745044681975L;
+ private MainFrame mainFrame;
+
+ /** Creates a new instance of ContentMenu */
+ public ContextMenu(MainFrame tool, String name) {
+ super(name);
+
+ this.mainFrame = tool;
+
+ this.addSeparator();
+
+ this.add(
+ new AbstractAction("New") {
+ private static final long serialVersionUID = -5599644198250553600L;
+
+ public void actionPerformed(ActionEvent e) {
+
+ String name =
+ JOptionPane.showInputDialog(
+ mainFrame, "Tab name", String.valueOf(mainFrame.getRollPanels().size()));
+
+ // Create a new Tab
+ CustomRollPanel rollPanel = new CustomRollPanel(mainFrame);
+ rollPanel.setName(name);
+
+ mainFrame.getRollPanels().add(rollPanel);
+
+ mainFrame.getCustomRollTab().removeAll();
+ for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
+ rollPanel = (CustomRollPanel) i.next();
+ mainFrame.getCustomRollTab().add(rollPanel);
+ }
+ }
+ });
+
+ this.add(
+ new AbstractAction("Delete") {
+ private static final long serialVersionUID = -6862072617245621294L;
+
+ public void actionPerformed(ActionEvent e) {
+ int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
+
+ CustomRollPanel rollPanel =
+ (CustomRollPanel) mainFrame.getRollPanels().remove(selectedIndex);
+ mainFrame.getCustomRollTab().remove(rollPanel);
+ }
+ });
+
+ this.add(
+ new AbstractAction("Rename") {
+ private static final long serialVersionUID = -5890580966305343270L;
+
+ public void actionPerformed(ActionEvent e) {
+ int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
+
+ CustomRollPanel rollPanel =
+ (CustomRollPanel) mainFrame.getRollPanels().get(selectedIndex);
+
+ String name = JOptionPane.showInputDialog(mainFrame, "Tab name", rollPanel.getName());
+
+ rollPanel.setName(name);
+ mainFrame.getCustomRollTab().removeAll();
+ for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
+ rollPanel = (CustomRollPanel) i.next();
+ mainFrame.getCustomRollTab().add(rollPanel);
+ }
+
+ mainFrame.getCustomRollTab().setSelectedIndex(selectedIndex);
+ }
+ });
+
+ this.addSeparator();
+
+ this.add(
+ new AbstractAction("Move ->") {
+ private static final long serialVersionUID = -4248301524310372222L;
+
+ public void actionPerformed(ActionEvent e) {
+ int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
+
+ if (selectedIndex < mainFrame.getRollPanels().size() - 1) {
+ CustomRollPanel rollPanel =
+ (CustomRollPanel) mainFrame.getRollPanels().remove(selectedIndex);
+
+ mainFrame.getRollPanels().add(selectedIndex + 1, rollPanel);
+
+ mainFrame.getCustomRollTab().removeAll();
+ for (Iterator i = mainFrame.getRollPanels().iterator(); i.hasNext(); ) {
+ rollPanel = (CustomRollPanel) i.next();
+ mainFrame.getCustomRollTab().add(rollPanel);
+ }
+
+ mainFrame.getCustomRollTab().setSelectedIndex(selectedIndex + 1);
+ }
+ }
+ });
+
+ this.addSeparator();
+
+ this.add(
+ new AbstractAction("Export") {
+ private static final long serialVersionUID = -6958791608623693284L;
+
+ public void actionPerformed(ActionEvent e) {
+ int selectedIndex = mainFrame.getCustomRollTab().getSelectedIndex();
+
+ JFileChooser fc = new JFileChooser();
+ fc.setDialogTitle("Export tab");
+ fc.setCurrentDirectory(new File("."));
+
+ int result = fc.showOpenDialog(mainFrame);
+
+ if (result == JFileChooser.CANCEL_OPTION) {
+
+ } else if (result == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+
+ mainFrame.exportPreferences(file, selectedIndex);
+ }
+ }
+ });
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/ContextSwitchAction.java b/src/main/java/net/rptools/dicetool/ui/ContextSwitchAction.java
index e20bd87..5ed6a9d 100644
--- a/src/main/java/net/rptools/dicetool/ui/ContextSwitchAction.java
+++ b/src/main/java/net/rptools/dicetool/ui/ContextSwitchAction.java
@@ -1,48 +1,39 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.awt.event.ActionEvent;
-
import javax.swing.AbstractAction;
-/**
- *
- * @author drice
- */
+/** @author drice */
public class ContextSwitchAction extends AbstractAction {
- private static final long serialVersionUID = 3615200384792310293L;
+ private static final long serialVersionUID = 3615200384792310293L;
+
+ /** Creates a new instance of ContextSwitchAction */
+ public ContextSwitchAction() {}
- /** Creates a new instance of ContextSwitchAction */
- public ContextSwitchAction() {
- }
-
- /** Invoked when an action occurs.
- *
- */
- public void actionPerformed(ActionEvent e) {
- }
-
+ /** Invoked when an action occurs. */
+ public void actionPerformed(ActionEvent e) {}
}
diff --git a/src/main/java/net/rptools/dicetool/ui/CustomRollPanel.java b/src/main/java/net/rptools/dicetool/ui/CustomRollPanel.java
index 70457cb..e4335b4 100644
--- a/src/main/java/net/rptools/dicetool/ui/CustomRollPanel.java
+++ b/src/main/java/net/rptools/dicetool/ui/CustomRollPanel.java
@@ -1,141 +1,137 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import javax.swing.JOptionPane;
-/**
- *
- * @author drice
- */
+/** @author drice */
public class CustomRollPanel extends javax.swing.JPanel {
- private static final long serialVersionUID = 341091181935322593L;
-
- private static final int NUM_CUSTOM_ROLLS = 20;
-
- private MainFrame dmTool;
-
- private javax.swing.JTextField rollDefinition[];
- private javax.swing.JButton rollButton[];
-
- private javax.swing.JPanel inputPanel;
-
-
- /** Creates new form CustomRollPanel */
- public CustomRollPanel(MainFrame dmTool) {
- initComponents();
-
- this.dmTool = dmTool;
- }
-
- private void initComponents() {
- inputPanel = new javax.swing.JPanel();
- setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
- inputPanel.setLayout(new java.awt.GridLayout(NUM_CUSTOM_ROLLS, 2));
-
- rollDefinition = new javax.swing.JTextField[NUM_CUSTOM_ROLLS];
- rollButton = new javax.swing.JButton[NUM_CUSTOM_ROLLS];
-
- for (int i = 0; i < NUM_CUSTOM_ROLLS; i++) {
- rollDefinition[i] = new javax.swing.JTextField();
- inputPanel.add(rollDefinition[i]);
-
- rollButton[i] = new javax.swing.JButton();
- rollButton[i].setFont(new java.awt.Font("Dialog", 0, 10));
- rollButton[i].setText("Roll");
- rollButton[i].setActionCommand(String.valueOf(i));
- rollButton[i].setMaximumSize(new java.awt.Dimension(30, 20));
- rollButton[i].setMinimumSize(new java.awt.Dimension(30, 20));
- rollButton[i].setPreferredSize(new java.awt.Dimension(30, 20));
- rollButton[i].addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- saveActionPerformed(evt);
- }
- });
-
- rollButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- CustomRollPanel.this.mousePressed(evt);
- }
- });
-
- inputPanel.add(rollButton[i]);
- }
-
- add(inputPanel);
- }
+ private static final long serialVersionUID = 341091181935322593L;
- private void mousePressed(java.awt.event.MouseEvent evt) {
- //javax.swing.JDialog dialog = new RenameCustomRollDialog(this.getParent(), true);
-
- //dialog.setVisible(true);
+ private static final int NUM_CUSTOM_ROLLS = 20;
- if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
- javax.swing.JButton button = (javax.swing.JButton) evt.getComponent();
+ private MainFrame dmTool;
- button.setText(JOptionPane.showInputDialog(dmTool, "Roll name", button.getText()));
- }
- }
-
- public int getCount() {
- return NUM_CUSTOM_ROLLS;
- }
-
- public String getDefinition(int index) {
- return rollDefinition[index].getText();
- }
-
- public String getButtonLabel(int index) {
- return rollButton[index].getText();
- }
-
- public void setDefinition(int index, String definition) {
- rollDefinition[index].setText(definition);
- }
+ private javax.swing.JTextField rollDefinition[];
+ private javax.swing.JButton rollButton[];
+
+ private javax.swing.JPanel inputPanel;
+
+ /** Creates new form CustomRollPanel */
+ public CustomRollPanel(MainFrame dmTool) {
+ initComponents();
+
+ this.dmTool = dmTool;
+ }
+
+ private void initComponents() {
+ inputPanel = new javax.swing.JPanel();
+ setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
+ inputPanel.setLayout(new java.awt.GridLayout(NUM_CUSTOM_ROLLS, 2));
- public void setButtonLabel(int index, String label) {
- rollButton[index].setText(label);
+ rollDefinition = new javax.swing.JTextField[NUM_CUSTOM_ROLLS];
+ rollButton = new javax.swing.JButton[NUM_CUSTOM_ROLLS];
+
+ for (int i = 0; i < NUM_CUSTOM_ROLLS; i++) {
+ rollDefinition[i] = new javax.swing.JTextField();
+ inputPanel.add(rollDefinition[i]);
+
+ rollButton[i] = new javax.swing.JButton();
+ rollButton[i].setFont(new java.awt.Font("Dialog", 0, 10));
+ rollButton[i].setText("Roll");
+ rollButton[i].setActionCommand(String.valueOf(i));
+ rollButton[i].setMaximumSize(new java.awt.Dimension(30, 20));
+ rollButton[i].setMinimumSize(new java.awt.Dimension(30, 20));
+ rollButton[i].setPreferredSize(new java.awt.Dimension(30, 20));
+ rollButton[i].addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ saveActionPerformed(evt);
+ }
+ });
+
+ rollButton[i].addMouseListener(
+ new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ CustomRollPanel.this.mousePressed(evt);
+ }
+ });
+
+ inputPanel.add(rollButton[i]);
}
-
- private void saveActionPerformed(java.awt.event.ActionEvent evt) {
-// javax.swing.JTextField field = new javax.swing.JTextField();
-// field.setEditable(false);
-//
-// javax.swing.JButton button = new javax.swing.JButton();
-//
-// customPanel.add(field);
-// customPanel.add(button);
-//
-// customPanel.revalidate();
-
-// dmTool.roll(rollDefinition.getText());
-
- int which = Integer.parseInt(evt.getActionCommand());
- dmTool.roll(rollDefinition[which].getText());
-// System.out.println("Save action pressed.");
+
+ add(inputPanel);
+ }
+
+ private void mousePressed(java.awt.event.MouseEvent evt) {
+ // javax.swing.JDialog dialog = new RenameCustomRollDialog(this.getParent(), true);
+
+ // dialog.setVisible(true);
+
+ if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
+ javax.swing.JButton button = (javax.swing.JButton) evt.getComponent();
+
+ button.setText(JOptionPane.showInputDialog(dmTool, "Roll name", button.getText()));
}
-
-
+ }
+
+ public int getCount() {
+ return NUM_CUSTOM_ROLLS;
+ }
+
+ public String getDefinition(int index) {
+ return rollDefinition[index].getText();
+ }
+
+ public String getButtonLabel(int index) {
+ return rollButton[index].getText();
+ }
+
+ public void setDefinition(int index, String definition) {
+ rollDefinition[index].setText(definition);
+ }
+
+ public void setButtonLabel(int index, String label) {
+ rollButton[index].setText(label);
+ }
+
+ private void saveActionPerformed(java.awt.event.ActionEvent evt) {
+ // javax.swing.JTextField field = new javax.swing.JTextField();
+ // field.setEditable(false);
+ //
+ // javax.swing.JButton button = new javax.swing.JButton();
+ //
+ // customPanel.add(field);
+ // customPanel.add(button);
+ //
+ // customPanel.revalidate();
+
+ // dmTool.roll(rollDefinition.getText());
+
+ int which = Integer.parseInt(evt.getActionCommand());
+ dmTool.roll(rollDefinition[which].getText());
+ // System.out.println("Save action pressed.");
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/CustomTableCellRenderer.java b/src/main/java/net/rptools/dicetool/ui/CustomTableCellRenderer.java
index 05e2fa9..62936a3 100644
--- a/src/main/java/net/rptools/dicetool/ui/CustomTableCellRenderer.java
+++ b/src/main/java/net/rptools/dicetool/ui/CustomTableCellRenderer.java
@@ -1,72 +1,58 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.awt.Component;
-
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ *
To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class CustomTableCellRenderer extends DefaultTableCellRenderer {
- private static final long serialVersionUID = -5290414950367515769L;
-
- public Component getTableCellRendererComponent(
- JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
- CellColorWrapper wrapper = null;
+ private static final long serialVersionUID = -5290414950367515769L;
- if (value instanceof CellColorWrapper) {
- wrapper = (CellColorWrapper) value;
- value = wrapper.getWrappedObject();
- }
+ public Component getTableCellRendererComponent(
+ JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ CellColorWrapper wrapper = null;
- Component cell =
- super.getTableCellRendererComponent(
- table,
- value,
- isSelected,
- hasFocus,
- row,
- column);
+ if (value instanceof CellColorWrapper) {
+ wrapper = (CellColorWrapper) value;
+ value = wrapper.getWrappedObject();
+ }
- if (wrapper != null && !isSelected) {
- cell.setBackground(wrapper.getBackground());
- cell.setForeground(wrapper.getForeground());
- }
+ Component cell =
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- return cell;
+ if (wrapper != null && !isSelected) {
+ cell.setBackground(wrapper.getBackground());
+ cell.setForeground(wrapper.getForeground());
+ }
- }
+ return cell;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/DicePanel.java b/src/main/java/net/rptools/dicetool/ui/DicePanel.java
index abbad28..a4f06f7 100644
--- a/src/main/java/net/rptools/dicetool/ui/DicePanel.java
+++ b/src/main/java/net/rptools/dicetool/ui/DicePanel.java
@@ -1,201 +1,207 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
-/**
- *
- * @author drice
- */
+/** @author drice */
public class DicePanel extends javax.swing.JPanel {
- private static final long serialVersionUID = -8627668679690782352L;
-
- private static final String[] NUMBER_SELECTIONS = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "15", "20", "50", "100"};
-
- private MainFrame dmTool;
-
- /** Creates new form DicePanel2 */
- public DicePanel(MainFrame dmTool) {
- this.dmTool = dmTool;
-
- initComponents();
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- */
- private void initComponents() {
- numberSelect = new javax.swing.JComboBox(NUMBER_SELECTIONS);
- numberSelect.setSelectedItem(NUMBER_SELECTIONS[4]);
- jPanel2 = new javax.swing.JPanel();
- d2 = new javax.swing.JButton();
- d3 = new javax.swing.JButton();
- d4 = new javax.swing.JButton();
- d6 = new javax.swing.JButton();
- d8 = new javax.swing.JButton();
- d10 = new javax.swing.JButton();
- d12 = new javax.swing.JButton();
- d20 = new javax.swing.JButton();
- d100 = new javax.swing.JButton();
-
- setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
-
- numberSelect.setMaximumSize(new java.awt.Dimension(32767, 35));
- add(numberSelect);
-
- jPanel2.setLayout(new java.awt.GridLayout(3, 3));
-
- jPanel2.setMaximumSize(new java.awt.Dimension(200, 200));
- d2.setFont(new java.awt.Font("Dialog", 0, 10));
- d2.setText("d2");
- d2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ private static final long serialVersionUID = -8627668679690782352L;
+
+ private static final String[] NUMBER_SELECTIONS = {
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "15", "20", "50", "100"
+ };
+
+ private MainFrame dmTool;
+
+ /** Creates new form DicePanel2 */
+ public DicePanel(MainFrame dmTool) {
+ this.dmTool = dmTool;
+
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to initialize the form. */
+ private void initComponents() {
+ numberSelect = new javax.swing.JComboBox(NUMBER_SELECTIONS);
+ numberSelect.setSelectedItem(NUMBER_SELECTIONS[4]);
+ jPanel2 = new javax.swing.JPanel();
+ d2 = new javax.swing.JButton();
+ d3 = new javax.swing.JButton();
+ d4 = new javax.swing.JButton();
+ d6 = new javax.swing.JButton();
+ d8 = new javax.swing.JButton();
+ d10 = new javax.swing.JButton();
+ d12 = new javax.swing.JButton();
+ d20 = new javax.swing.JButton();
+ d100 = new javax.swing.JButton();
+
+ setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
+
+ numberSelect.setMaximumSize(new java.awt.Dimension(32767, 35));
+ add(numberSelect);
+
+ jPanel2.setLayout(new java.awt.GridLayout(3, 3));
+
+ jPanel2.setMaximumSize(new java.awt.Dimension(200, 200));
+ d2.setFont(new java.awt.Font("Dialog", 0, 10));
+ d2.setText("d2");
+ d2.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d2);
+ jPanel2.add(d2);
- d3.setFont(new java.awt.Font("Dialog", 0, 10));
- d3.setText("d3");
- d3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d3.setFont(new java.awt.Font("Dialog", 0, 10));
+ d3.setText("d3");
+ d3.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d3);
+ jPanel2.add(d3);
- d4.setFont(new java.awt.Font("Dialog", 0, 10));
- d4.setText("d4");
- d4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d4.setFont(new java.awt.Font("Dialog", 0, 10));
+ d4.setText("d4");
+ d4.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d4);
+ jPanel2.add(d4);
- d6.setFont(new java.awt.Font("Dialog", 0, 10));
- d6.setText("d6");
- d6.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d6.setFont(new java.awt.Font("Dialog", 0, 10));
+ d6.setText("d6");
+ d6.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d6);
+ jPanel2.add(d6);
- d8.setFont(new java.awt.Font("Dialog", 0, 10));
- d8.setText("d8");
- d8.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d8.setFont(new java.awt.Font("Dialog", 0, 10));
+ d8.setText("d8");
+ d8.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d8);
+ jPanel2.add(d8);
- d10.setFont(new java.awt.Font("Dialog", 0, 10));
- d10.setText("d10");
- d10.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d10.setFont(new java.awt.Font("Dialog", 0, 10));
+ d10.setText("d10");
+ d10.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d10);
+ jPanel2.add(d10);
- d12.setFont(new java.awt.Font("Dialog", 0, 10));
- d12.setText("d12");
- d12.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d12.setFont(new java.awt.Font("Dialog", 0, 10));
+ d12.setText("d12");
+ d12.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d12);
+ jPanel2.add(d12);
- d20.setFont(new java.awt.Font("Dialog", 0, 10));
- d20.setText("d20");
- d20.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d20.setFont(new java.awt.Font("Dialog", 0, 10));
+ d20.setText("d20");
+ d20.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d20);
+ jPanel2.add(d20);
- d100.setFont(new java.awt.Font("Dialog", 0, 10));
- d100.setText("d100");
- d100.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- dieActionPerformed(evt);
- }
+ d100.setFont(new java.awt.Font("Dialog", 0, 10));
+ d100.setText("d100");
+ d100.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ dieActionPerformed(evt);
+ }
});
- jPanel2.add(d100);
+ jPanel2.add(d100);
- add(jPanel2);
+ add(jPanel2);
+ }
+ private void dieActionPerformed(
+ java.awt.event.ActionEvent evt) { // GEN-FIRST:event_dieActionPerformed
+ String cmd = evt.getActionCommand();
+
+ try {
+ int num = Integer.parseInt((String) numberSelect.getSelectedItem());
+
+ StringBuffer sb = new StringBuffer(256);
+ sb.append(num).append(cmd);
+
+ dmTool.roll(sb.toString());
+ } catch (NumberFormatException ex) {
+ throw new IllegalStateException("Number format exception occurred... data must be bad.");
}
-
- private void dieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dieActionPerformed
- String cmd = evt.getActionCommand();
-
- try {
- int num = Integer.parseInt((String) numberSelect.getSelectedItem());
-
- StringBuffer sb = new StringBuffer(256);
- sb.append(num).append(cmd);
-
- dmTool.roll(sb.toString());
- } catch (NumberFormatException ex) {
- throw new IllegalStateException("Number format exception occurred... data must be bad.");
- }
- }//GEN-LAST:event_dieActionPerformed
-
- public int getSelectedItem() {
- return Integer.parseInt((String) numberSelect.getSelectedItem());
- }
-
- public void setSelectedItem(int selectedItem) {
- numberSelect.setSelectedItem(String.valueOf(selectedItem));
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton d8;
- private javax.swing.JButton d2;
- private javax.swing.JButton d12;
- private javax.swing.JButton d3;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JButton d10;
- private javax.swing.JButton d20;
- private javax.swing.JButton d100;
- private javax.swing.JButton d6;
- private javax.swing.JButton d4;
- private javax.swing.JComboBox numberSelect;
- // End of variables declaration//GEN-END:variables
-
+ } // GEN-LAST:event_dieActionPerformed
+
+ public int getSelectedItem() {
+ return Integer.parseInt((String) numberSelect.getSelectedItem());
+ }
+
+ public void setSelectedItem(int selectedItem) {
+ numberSelect.setSelectedItem(String.valueOf(selectedItem));
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton d8;
+ private javax.swing.JButton d2;
+ private javax.swing.JButton d12;
+ private javax.swing.JButton d3;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JButton d10;
+ private javax.swing.JButton d20;
+ private javax.swing.JButton d100;
+ private javax.swing.JButton d6;
+ private javax.swing.JButton d4;
+ private javax.swing.JComboBox numberSelect;
+ // End of variables declaration//GEN-END:variables
+
}
diff --git a/src/main/java/net/rptools/dicetool/ui/ListSelectionModel.java b/src/main/java/net/rptools/dicetool/ui/ListSelectionModel.java
index 5916fbe..31394b7 100644
--- a/src/main/java/net/rptools/dicetool/ui/ListSelectionModel.java
+++ b/src/main/java/net/rptools/dicetool/ui/ListSelectionModel.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
@@ -31,37 +31,35 @@
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
+ *
To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class ListSelectionModel extends DefaultListSelectionModel implements ListSelectionListener {
- private static final long serialVersionUID = 4246765137332270003L;
- private MainFrame tool;
- private JTable table;
-
- public ListSelectionModel(JTable table, MainFrame tool) {
- super();
- addListSelectionListener(this);
- this.table = table;
- this.tool = tool;
- }
- /* (non-Javadoc)
- * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
- */
- public void valueChanged(ListSelectionEvent e) {
- double sum = 0;
- for (int i = 0; i < table.getRowCount(); i++) {
- if (table.isRowSelected(i)) {
- Object o = table.getModel().getValueAt(i, 1);
- if (o instanceof CellColorWrapper) {
- CellColorWrapper ccw = (CellColorWrapper) o;
- Number v = (Number) ccw.getWrappedObject();
- if (v != null)
- sum += v.doubleValue();
- }
- }
- }
- tool.resultSelectionChanged(sum);
- }
+ private static final long serialVersionUID = 4246765137332270003L;
+ private MainFrame tool;
+ private JTable table;
+
+ public ListSelectionModel(JTable table, MainFrame tool) {
+ super();
+ addListSelectionListener(this);
+ this.table = table;
+ this.tool = tool;
+ }
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+ */
+ public void valueChanged(ListSelectionEvent e) {
+ double sum = 0;
+ for (int i = 0; i < table.getRowCount(); i++) {
+ if (table.isRowSelected(i)) {
+ Object o = table.getModel().getValueAt(i, 1);
+ if (o instanceof CellColorWrapper) {
+ CellColorWrapper ccw = (CellColorWrapper) o;
+ Number v = (Number) ccw.getWrappedObject();
+ if (v != null) sum += v.doubleValue();
+ }
+ }
+ }
+ tool.resultSelectionChanged(sum);
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/MainFrame.java b/src/main/java/net/rptools/dicetool/ui/MainFrame.java
index f192f97..2f0195a 100644
--- a/src/main/java/net/rptools/dicetool/ui/MainFrame.java
+++ b/src/main/java/net/rptools/dicetool/ui/MainFrame.java
@@ -1,530 +1,512 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.awt.*;
import java.awt.event.ActionEvent;
-import net.rptools.dicetool.DiceTool;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
-
import javax.swing.*;
import javax.swing.border.BevelBorder;
-
import net.rptools.common.expression.ExpressionParser;
-import net.rptools.parser.MapVariableResolver;
-import net.rptools.parser.ParserException;
+import net.rptools.common.expression.Result;
+import net.rptools.dicetool.DiceTool;
import net.rptools.lib.FileUtil;
import net.rptools.lib.image.ImageUtil;
import net.rptools.lib.swing.AboutDialog;
+import net.rptools.parser.MapVariableResolver;
+import net.rptools.parser.ParserException;
import net.rptools.parser.VariableResolver;
-
-/**
- * @author drice
- */
+/** @author drice */
public class MainFrame extends JFrame {
- private static final long serialVersionUID = -5149326446698624828L;
-
- private static String version;
-
- private final JMenuBar menuBar;
- private final JTabbedPane customRollTab;
- private final JLabel statusBar;
-
- private final DicePanel dicePanel;
- private final ResultPanel resultPanel;
- private final VariablePanel variablePanel;
-
- private final AboutDialog aboutDialog;
-
- private List rollPanels = new ArrayList();
-
- private List rollListeners = new ArrayList();
-
- private static final String EXPRESSION_SYNTAX =
- "bags (non cumulative rolls):\n"
- + " \\d+{ } - repeater translated into [; ]*.\n"
- + " [; ]* - Roll each expression group in order\n\n"
- + "expression groups (cumulative rolls):\n"
- + " \\d+[ ] - repeater translated into [: ]*.\n"
- + " [: ]* - Roll each expression and keep a running total\n\n"
- + "expression :\n"
- + " | [<+> | <-> | <*> | ]* = \n"
- + " \\d*[dD]\\d+ = \n"
- + " \\d+ = ";
-
- VariableResolver resolver;
-
- /** Creates a new instance of DMTool */
- public MainFrame() {
- super("Dice Tool");
-
- resolver = new MapVariableResolver();
-
- int numCustomRollPanels = getNumRollPanels();
-
- dicePanel = new DicePanel(this);
- resultPanel = new ResultPanel(this);
-
- for (int i = 0; i < numCustomRollPanels; i++) {
- CustomRollPanel rollPanel = new CustomRollPanel(this);
- rollPanels.add(rollPanel);
-
- loadRollPanelPreferences(i, rollPanel);
- }
-
- String credits = "";
- String version = "";
- Image logo = null;
+ private static final long serialVersionUID = -5149326446698624828L;
+
+ private static String version;
+
+ private final JTabbedPane customRollTab;
+ private final JLabel statusBar;
+
+ private final DicePanel dicePanel;
+ private final ResultPanel resultPanel;
+ private final VariablePanel variablePanel;
+
+ private final AboutDialog aboutDialog;
+
+ private List rollPanels = new ArrayList<>();
+
+ private final List rollListeners = new ArrayList<>();
+
+ private static final String EXPRESSION_SYNTAX =
+ "bags (non cumulative rolls):\n"
+ + " \\d+{ } - repeater translated into [; ]*.\n"
+ + " [; ]* - Roll each expression group in order\n\n"
+ + "expression groups (cumulative rolls):\n"
+ + " \\d+[ ] - repeater translated into [: ]*.\n"
+ + " [: ]* - Roll each expression and keep a running total\n\n"
+ + "expression :\n"
+ + " | [<+> | <-> | <*> | ]* = \n"
+ + " \\d*[dD]\\d+ = \n"
+ + " \\d+ = ";
+
+ /** Creates a new instance of DMTool */
+ public MainFrame() {
+ super("Dice Tool");
+
+ int numCustomRollPanels = getNumRollPanels();
+
+ dicePanel = new DicePanel(this);
+ resultPanel = new ResultPanel(this);
+
+ for (int i = 0; i < numCustomRollPanels; i++) {
+ CustomRollPanel rollPanel = new CustomRollPanel(this);
+ rollPanels.add(rollPanel);
+
+ loadRollPanelPreferences(i, rollPanel);
+ }
+
+ String credits = "";
+ String version;
+ Image logo = null;
+ try {
+ credits =
+ new String(FileUtil.loadResource("java/net.rptools.dicetool.dicetool/credits.html"));
+ version = MainFrame.getVersion();
+ credits = credits.replace("%VERSION%", version);
+ logo = ImageUtil.getImage("net/rptools/lib/image/rptools-logo.png");
+
+ } catch (Exception ioe) {
+ ioe.printStackTrace();
+ }
+ aboutDialog = new AboutDialog(this, logo, credits);
+
+ JMenuBar menuBar = new JMenuBar();
+ JMenu menu = new JMenu("File");
+ menu.setMnemonic('F');
+ menuBar.add(menu);
+
+ menu.add(
+ new AbstractAction("Load") {
+ private static final long serialVersionUID = 5894464716901662587L;
+
+ public void actionPerformed(ActionEvent e) {
+ loadPreferences();
+ }
+ });
+
+ menu.add(
+ new AbstractAction("Save") {
+ private static final long serialVersionUID = 2069214913432460961L;
+
+ public void actionPerformed(ActionEvent e) {
+ savePreferences();
+ }
+ });
+
+ menu.add(
+ new AbstractAction("Exit") {
+ private static final long serialVersionUID = 1934074661129316121L;
+
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }
+ });
+
+ JMenu contextMenu = new ContextMenu(this, "Tab");
+ contextMenu.setMnemonic('T');
+ menuBar.add(contextMenu);
+
+ menu = new JMenu("Data");
+ menu.setMnemonic('D');
+ menuBar.add(menu);
+
+ menu.add(
+ new AbstractAction("Clear") {
+ private static final long serialVersionUID = -1423278621970926792L;
+
+ public void actionPerformed(ActionEvent e) {
+ resultPanel.clearList();
+ }
+ });
+
+ menu.add(
+ new AbstractAction("Statistics") {
+ private static final long serialVersionUID = -7511992886537497232L;
+
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(MainFrame.this, "Random: " + "\nAverage: ");
+ }
+ });
+
+ menu = new JMenu("Help");
+ menu.setMnemonic('H');
+ menuBar.add(menu);
+
+ menu.add(
+ new AbstractAction("Syntax") {
+ private static final long serialVersionUID = -3156673526417487961L;
+
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(MainFrame.this, EXPRESSION_SYNTAX);
+ }
+ });
+
+ menu.add(
+ new AbstractAction("About") {
+ private static final long serialVersionUID = 7099281595551261802L;
+
+ public void actionPerformed(ActionEvent e) {
+ aboutDialog.setVisible(true);
+ }
+ });
+
+ variablePanel = new VariablePanel(this);
+ loadVariablePreferences();
+
+ this.setJMenuBar(menuBar);
+
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.X_AXIS));
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ panel.add(dicePanel);
+
+ customRollTab = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
+ for (CustomRollPanel rollPanel : rollPanels) {
+ customRollTab.add(rollPanel);
+ }
+
+ panel.add(customRollTab);
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, resultPanel);
+ splitPane.setResizeWeight(0);
+ splitPane.setOneTouchExpandable(true);
+ splitPane.setContinuousLayout(true);
+
+ statusBar = new JLabel("");
+ resultSelectionChanged(0);
+
+ JPanel vertPanel = new JPanel();
+ this.getContentPane().add(vertPanel);
+
+ GridBagConstraints con = new GridBagConstraints();
+ GridBagLayout layout = new GridBagLayout();
+ vertPanel.setLayout(layout);
+
+ // ---------------------------------------------------------------------
+ // Add the split pane to the main window
+ // ---------------------------------------------------------------------
+ con.gridx = 0;
+ con.gridy = 0;
+ con.fill = GridBagConstraints.BOTH;
+
+ con.gridwidth = GridBagConstraints.RELATIVE;
+ con.gridheight = 1;
+
+ con.anchor = GridBagConstraints.FIRST_LINE_START;
+
+ con.weightx = 1.0;
+ con.weighty = 1.0;
+
+ vertPanel.add(splitPane, con);
+
+ // ---------------------------------------------------------------------
+ // Add the variable panel to the main window
+ // ---------------------------------------------------------------------
+
+ con.gridy = 1;
+ con.weighty = 0.0;
+
+ vertPanel.add(variablePanel, con);
+
+ // ---------------------------------------------------------------------
+ // Add the status panel to the main window
+ // ---------------------------------------------------------------------
+ JPanel statusPanel = new JPanel();
+ statusPanel.add(statusBar);
+ statusPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
+ statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
+
+ con.gridy = 2;
+
+ vertPanel.add(statusPanel, con);
+
+ this.setSize(400, 645);
+
+ loadPreferences();
+ this.setVisible(true);
+
+ new WindowListener(this);
+ }
+
+ private String format(Result result) {
+
+ Object value = result.getValue();
+
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(result.getExpression()).append(" = ");
+
+ String detailExpression = result.getDetailExpression();
+ if (!detailExpression.equals(value.toString())) {
+ sb.append("(").append(detailExpression).append(") = ");
+ }
+
+ sb.append(value);
+ if (result.getDescription() != null) {
+ sb.append(" // ").append(result.getDescription());
+ }
+ return sb.toString();
+ }
+
+ public void roll(String definition) {
+ ExpressionParser parser = new ExpressionParser();
+
+ VariableResolver resolver = new MapVariableResolver();
+ try {
+
+ for (int i = 0; i < variablePanel.getCount(); i++) {
try {
- credits = new String(FileUtil.loadResource("java/net.rptools.dicetool.dicetool/credits.html"));
- version = MainFrame.getVersion();
- credits = credits.replace("%VERSION%", version);
- logo = ImageUtil.getImage("net/rptools/lib/image/rptools-logo.png");
-
- } catch (Exception ioe) {
- ioe.printStackTrace();
+ resolver.setVariable(
+ variablePanel.getName(i),
+ BigDecimal.valueOf(Integer.parseInt(variablePanel.getValue(i))));
+ } catch (ParserException e) {
+ e.printStackTrace();
}
- aboutDialog = new AboutDialog(this, logo, credits);
-
-
- menuBar = new JMenuBar();
- JMenu menu = new JMenu("File");
- menu.setMnemonic('F');
- menuBar.add(menu);
-
- menu.add(new AbstractAction("Load") {
- private static final long serialVersionUID = 5894464716901662587L;
-
- public void actionPerformed(ActionEvent e) {
- loadPreferences();
- }
- });
-
- menu.add(new AbstractAction("Save") {
- private static final long serialVersionUID = 2069214913432460961L;
-
- public void actionPerformed(ActionEvent e) {
- savePreferences();
- }
- });
-
- menu.add(new AbstractAction("Exit") {
- private static final long serialVersionUID = 1934074661129316121L;
-
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
-
- JMenu contextMenu = new ContextMenu(this, "Tab");
- contextMenu.setMnemonic('T');
- menuBar.add(contextMenu);
-
- menu = new JMenu("Data");
- menu.setMnemonic('D');
- menuBar.add(menu);
-
- menu.add(new AbstractAction("Clear") {
- private static final long serialVersionUID = -1423278621970926792L;
-
- public void actionPerformed(ActionEvent e) {
- resultPanel.clearList();
- }
- });
-
- menu.add(new AbstractAction("Statistics") {
- private static final long serialVersionUID = -7511992886537497232L;
-
- public void actionPerformed(ActionEvent e) {
- RowListModel tm = resultPanel.getTableModel();
-
- JOptionPane.showMessageDialog(
- MainFrame.this,
- "Random: "
- + "\nAverage: ");
- }
- });
-
- menu = new JMenu("Help");
- menu.setMnemonic('H');
- menuBar.add(menu);
-
- menu.add(new AbstractAction("Syntax") {
- private static final long serialVersionUID = -3156673526417487961L;
-
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(MainFrame.this, EXPRESSION_SYNTAX);
- }
- });
-
- menu.add(new AbstractAction("About") {
- private static final long serialVersionUID = 7099281595551261802L;
-
- public void actionPerformed(ActionEvent e) {
- aboutDialog.setVisible(true);
- }
- });
-
- variablePanel = new VariablePanel(this, resolver);
- loadVariablePreferences();
-
- this.setJMenuBar(menuBar);
-
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- this.getContentPane().setLayout(
- new BoxLayout(this.getContentPane(), BoxLayout.X_AXIS));
-
- JPanel panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-
- panel.add(dicePanel);
-
- customRollTab = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
- for (Iterator i = rollPanels.iterator(); i.hasNext(); ) {
- CustomRollPanel rollPanel = (CustomRollPanel) i.next();
- customRollTab.add(rollPanel);
- }
-
- panel.add(customRollTab);
-
- JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, resultPanel);
- splitPane.setResizeWeight(0);
- splitPane.setOneTouchExpandable(true);
- splitPane.setContinuousLayout(true);
-
- statusBar = new JLabel("");
- resultSelectionChanged(0);
-
- JPanel vertPanel = new JPanel();
- this.getContentPane().add(vertPanel);
-
- GridBagConstraints con = new GridBagConstraints();
- GridBagLayout layout = new GridBagLayout();
- vertPanel.setLayout(layout);
-
- //---------------------------------------------------------------------
- // Add the split pane to the main window
- //---------------------------------------------------------------------
- con.gridx = 0;
- con.gridy = 0;
- con.fill = GridBagConstraints.BOTH;
-
- con.gridwidth = GridBagConstraints.RELATIVE;
- con.gridheight = 1;
-
- con.anchor = GridBagConstraints.FIRST_LINE_START;
-
- con.weightx = 1.0;
- con.weighty = 1.0;
-
- vertPanel.add(splitPane, con);
-
- //---------------------------------------------------------------------
- // Add the variable panel to the main window
- //---------------------------------------------------------------------
-
- con.gridy = 1;
- con.weighty = 0.0;
-
- vertPanel.add(variablePanel, con);
-
- //---------------------------------------------------------------------
- // Add the status panel to the main window
- //---------------------------------------------------------------------
- JPanel statusPanel = new JPanel();
- statusPanel.add(statusBar);
- statusPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
- statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
-
- con.gridy = 2;
-
- vertPanel.add(statusPanel, con);
-
- this.setSize(400, 645);
-
- loadPreferences();
- this.setVisible(true);
-
- new WindowListener(this);
- }
-
- public void roll(String definition) {
- ExpressionParser parser = new ExpressionParser(resolver);
-
-
- try {
- //List xps = ExpressionFactory.getExpressions(definition, variablePanel.getVariables());
-
- for (Iterator i = rollListeners.iterator(); i.hasNext();) {
- RollListener l = (RollListener) i.next();
-
- l.rolled(Collections.singletonList(parser.evaluate(definition).format()));
- }
- } catch (ParserException e) {
- JOptionPane.showMessageDialog(this, e.getMessage());
- }
- }
-
- public static String getVersion() {
- if (version == null) {
- version = "DEVELOPMENT";
- try {
- if (MainFrame.class.getClassLoader().getResource("net/rptools/dicetool/version.txt") != null) {
- version = new String(FileUtil.loadResource("net/rptools/dicetool/version.txt"));
- }
- } catch (IOException ioe) {
- version = "CAN'T FIND VERSION FILE";
- }
- }
-
- return version;
- }
-
-
- public void registerRollListener(RollListener l) {
- rollListeners.add(l);
- }
-
- public int getNumRollPanels() {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
- Preferences prefs = pkg_prefs.node("customRolls");
-
- try {
- return prefs.childrenNames().length;
- } catch (BackingStoreException e) {
- return 1;
- }
- }
-
- public void loadRollPanelPreferences(
- int index,
- CustomRollPanel rollPanel) {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
-
- Preferences prefs = pkg_prefs.node("customRolls");
- String name = prefs.get("TabName" + index, String.valueOf(index));
-
- rollPanel.setName(name);
-
- prefs = pkg_prefs.node("customRolls/Tab" + index);
-
- for (int i = 0; i < rollPanel.getCount(); i++) {
- String buttonLabel = prefs.get("button" + i, "Roll");
- String definition = prefs.get("definition" + i, "");
-
- rollPanel.setButtonLabel(i, buttonLabel);
- rollPanel.setDefinition(i, definition);
- }
- }
-
- public void loadVariablePreferences() {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
-
- Preferences prefs = pkg_prefs.node("customVariables");
-
- for (int i = 0; i < variablePanel.getCount(); i++) {
- String name = prefs.get("name" + i, "var" + i);
- String value = prefs.get("value" + i, "0");
-
- variablePanel.setVariable(i, name, value);
- try {
- resolver.setVariable(name, BigDecimal.valueOf(Integer.parseInt(value)));
- } catch (ParserException e) {
- e.printStackTrace();
- }
- }
-
- }
-
- public void loadPreferences() {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
-
- int diceSelection = pkg_prefs.getInt("diceSelection", 5);
- dicePanel.setSelectedItem(diceSelection);
- }
-
- public void savePreferences() {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
-
- pkg_prefs.putInt("diceSelection", dicePanel.getSelectedItem());
-
- saveRollPanelPreferences(pkg_prefs);
- saveVariablePreferences(pkg_prefs);
- }
-
- public void saveRollPanelPreferences(Preferences rootPrefs) {
- Preferences prefs = rootPrefs.node("customRolls");
- try {
- prefs.removeNode();
- } catch (BackingStoreException e) {
- // dump it, this is bad.
- }
- prefs = rootPrefs.node("customRolls");
-
- prefs.putBoolean("tabbed", true);
-
- int index = 0;
- for (Iterator i = rollPanels.iterator(); i.hasNext(); index++) {
- CustomRollPanel rollPanel = (CustomRollPanel) i.next();
-
- String name = rollPanel.getName();
- prefs.put("TabName" + index, name);
-
- Preferences tabPrefs = prefs.node("Tab" + index);
-
- for (int j = 0; j < rollPanel.getCount(); j++) {
- String buttonLabel = rollPanel.getButtonLabel(j);
- String definition = rollPanel.getDefinition(j);
-
- tabPrefs.put("button" + j, buttonLabel);
- tabPrefs.put("definition" + j, definition);
- }
- }
- }
-
- public void saveVariablePreferences(Preferences rootPrefs) {
- Preferences prefs = rootPrefs.node("customVariables");
-
- for (int i = 0; i < variablePanel.getCount(); i++) {
-
- String name = variablePanel.getName(i);
- String value = variablePanel.getValue(i);
-
- prefs.put("name" + i, name);
- prefs.put("value" + i, value);
- }
- }
-
- public void exportPreferences(File file, int tabIndex) {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
- Preferences prefs = pkg_prefs.node("customRolls");
- Preferences tabPrefs = prefs.node("Tab" + tabIndex);
-
- try {
- tabPrefs.exportSubtree(new FileOutputStream(file));
- } catch (IOException e) {
- e.printStackTrace(System.err);
- } catch (BackingStoreException e) {
- e.printStackTrace(System.err);
- }
-
- }
-
-/* public void convertPreferences() {
- Preferences pkg_prefs = Preferences.userNodeForPackage(DMTool.class);
- Preferences prefs = pkg_prefs.node("customRolls");
-
- boolean tabbed = prefs.getBoolean("tabbed", false);
-
- if (!tabbed) {
- String[] labels = new String[20];
- String[] definitions = new String[20];
- for (int i = 0; i < 20; i++) {
- labels[i] = prefs.get("button" + i, "Roll");
- definitions[i] = prefs.get("definition" + i, "");
- }
-
- try {
- prefs.removeNode();
- } catch (BackingStoreException e) {
- // dump it, this is bad.
- }
- prefs = pkg_prefs.node("customRolls");
-
- prefs.putBoolean("tabbed", true);
- prefs.put("TabName0", "*");
-
- prefs = prefs.node("Tab0");
-
- for (int i = 0; i < 20; i++) {
- prefs.put("button" + i, labels[i]);
- prefs.put("definition" + i, definitions[i]);
- }
- }
- }
-*/
- public void resultSelectionChanged(double sum) {
- if (sum == 0) {
- statusBar.setText("total: ");
- } else {
- statusBar.setText("total: " + sum);
- }
- }
-
- /**
- * @return Returns the customRollTab.
- */
- public JTabbedPane getCustomRollTab() {
- return customRollTab;
- }
- /**
- * @return Returns the dicePanel.
- */
- public DicePanel getDicePanel() {
- return dicePanel;
- }
-
- /**
- * @return Returns the resultPanel.
- */
- public ResultPanel getResultPanel() {
- return resultPanel;
- }
- /**
- * @return Returns the rollPanels.
- */
- public List getRollPanels() {
- return rollPanels;
- }
- /**
- * @param rollPanels The rollPanels to set.
- */
- public void setRollPanels(List rollPanels) {
- this.rollPanels = rollPanels;
- }
- /**
- * @return Returns the statusBar.
- */
- public JLabel getStatusBar() {
- return statusBar;
- }
- /**
- * @return Returns the variablePanel.
- */
- public VariablePanel getVariablePanel() {
- return variablePanel;
- }
+ }
+
+ for (RollListener l : rollListeners) {
+ l.rolled(Collections.singletonList(format(parser.evaluate(definition, resolver))));
+ }
+ } catch (ParserException e) {
+ JOptionPane.showMessageDialog(this, e.getMessage());
+ }
+
+ for (int i = 0; i < variablePanel.getCount(); i++) {
+ try {
+ String var = variablePanel.getName(i);
+ Object val = resolver.getVariable(var);
+ if (val != null) variablePanel.setVariable(i, var, val.toString());
+ resolver.setVariable(
+ variablePanel.getName(i),
+ BigDecimal.valueOf(Integer.parseInt(variablePanel.getValue(i))));
+ } catch (ParserException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static String getVersion() {
+ if (version == null) {
+ version = "DEVELOPMENT";
+ try {
+ if (MainFrame.class.getClassLoader().getResource("net/rptools/dicetool/version.txt")
+ != null) {
+ version = new String(FileUtil.loadResource("net/rptools/dicetool/version.txt"));
+ }
+ } catch (IOException ioe) {
+ version = "CAN'T FIND VERSION FILE";
+ }
+ }
+
+ return version;
+ }
+
+ public void registerRollListener(RollListener l) {
+ rollListeners.add(l);
+ }
+
+ public int getNumRollPanels() {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+ Preferences prefs = pkg_prefs.node("customRolls");
+
+ try {
+ return prefs.childrenNames().length;
+ } catch (BackingStoreException e) {
+ return 1;
+ }
+ }
+
+ public void loadRollPanelPreferences(int index, CustomRollPanel rollPanel) {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+
+ Preferences prefs = pkg_prefs.node("customRolls");
+ String name = prefs.get("TabName" + index, String.valueOf(index));
+
+ rollPanel.setName(name);
+
+ prefs = pkg_prefs.node("customRolls/Tab" + index);
+
+ for (int i = 0; i < rollPanel.getCount(); i++) {
+ String buttonLabel = prefs.get("button" + i, "Roll");
+ String definition = prefs.get("definition" + i, "");
+
+ rollPanel.setButtonLabel(i, buttonLabel);
+ rollPanel.setDefinition(i, definition);
+ }
+ }
+
+ public void loadVariablePreferences() {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+
+ Preferences prefs = pkg_prefs.node("customVariables");
+
+ for (int i = 0; i < variablePanel.getCount(); i++) {
+ String name = prefs.get("name" + i, "var" + i);
+ String value = prefs.get("value" + i, "0");
+
+ variablePanel.setVariable(i, name, value);
+ }
+ }
+
+ public void loadPreferences() {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+
+ int diceSelection = pkg_prefs.getInt("diceSelection", 5);
+ dicePanel.setSelectedItem(diceSelection);
+ }
+
+ public void savePreferences() {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+
+ pkg_prefs.putInt("diceSelection", dicePanel.getSelectedItem());
+
+ saveRollPanelPreferences(pkg_prefs);
+ saveVariablePreferences(pkg_prefs);
+ }
+
+ public void saveRollPanelPreferences(Preferences rootPrefs) {
+ Preferences prefs = rootPrefs.node("customRolls");
+ try {
+ prefs.removeNode();
+ } catch (BackingStoreException e) {
+ // dump it, this is bad.
+ }
+ prefs = rootPrefs.node("customRolls");
+
+ prefs.putBoolean("tabbed", true);
+
+ int index = 0;
+ for (CustomRollPanel rollPanel : rollPanels) {
+
+ String name = rollPanel.getName();
+ prefs.put("TabName" + index, name);
+
+ Preferences tabPrefs = prefs.node("Tab" + index);
+
+ for (int j = 0; j < rollPanel.getCount(); j++) {
+ String buttonLabel = rollPanel.getButtonLabel(j);
+ String definition = rollPanel.getDefinition(j);
+
+ tabPrefs.put("button" + j, buttonLabel);
+ tabPrefs.put("definition" + j, definition);
+ }
+ }
+ }
+
+ public void saveVariablePreferences(Preferences rootPrefs) {
+ Preferences prefs = rootPrefs.node("customVariables");
+
+ for (int i = 0; i < variablePanel.getCount(); i++) {
+
+ String name = variablePanel.getName(i);
+ String value = variablePanel.getValue(i);
+
+ prefs.put("name" + i, name);
+ prefs.put("value" + i, value);
+ }
+ }
+
+ public void exportPreferences(File file, int tabIndex) {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DiceTool.class);
+ Preferences prefs = pkg_prefs.node("customRolls");
+ Preferences tabPrefs = prefs.node("Tab" + tabIndex);
+
+ try {
+ tabPrefs.exportSubtree(new FileOutputStream(file));
+ } catch (IOException | BackingStoreException e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ /* public void convertPreferences() {
+ Preferences pkg_prefs = Preferences.userNodeForPackage(DMTool.class);
+ Preferences prefs = pkg_prefs.node("customRolls");
+
+ boolean tabbed = prefs.getBoolean("tabbed", false);
+
+ if (!tabbed) {
+ String[] labels = new String[20];
+ String[] definitions = new String[20];
+ for (int i = 0; i < 20; i++) {
+ labels[i] = prefs.get("button" + i, "Roll");
+ definitions[i] = prefs.get("definition" + i, "");
+ }
+
+ try {
+ prefs.removeNode();
+ } catch (BackingStoreException e) {
+ // dump it, this is bad.
+ }
+ prefs = pkg_prefs.node("customRolls");
+
+ prefs.putBoolean("tabbed", true);
+ prefs.put("TabName0", "*");
+
+ prefs = prefs.node("Tab0");
+
+ for (int i = 0; i < 20; i++) {
+ prefs.put("button" + i, labels[i]);
+ prefs.put("definition" + i, definitions[i]);
+ }
+ }
+ }
+ */
+ public void resultSelectionChanged(double sum) {
+ if (sum == 0) {
+ statusBar.setText("total: ");
+ } else {
+ statusBar.setText("total: " + sum);
+ }
+ }
+
+ /** @return Returns the customRollTab. */
+ public JTabbedPane getCustomRollTab() {
+ return customRollTab;
+ }
+ /** @return Returns the rollPanels. */
+ public List getRollPanels() {
+ return rollPanels;
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/RenameCustomRollDialog.java b/src/main/java/net/rptools/dicetool/ui/RenameCustomRollDialog.java
index 6ffcb0f..2d924ed 100644
--- a/src/main/java/net/rptools/dicetool/ui/RenameCustomRollDialog.java
+++ b/src/main/java/net/rptools/dicetool/ui/RenameCustomRollDialog.java
@@ -1,92 +1,89 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
-/**
- *
- * @author drice
- */
+/** @author drice */
public class RenameCustomRollDialog extends javax.swing.JDialog {
- private static final long serialVersionUID = -3526982430714498553L;
- /** Creates new form RenameCustomRollDialog */
- public RenameCustomRollDialog(java.awt.Frame parent, boolean modal) {
- super(parent, modal);
- initComponents();
-
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- private void initComponents() {//GEN-BEGIN:initComponents
- buttonLabel = new javax.swing.JTextField();
- okButton = new javax.swing.JButton();
+ private static final long serialVersionUID = -3526982430714498553L;
+ /** Creates new form RenameCustomRollDialog */
+ public RenameCustomRollDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ }
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- closeDialog(evt);
- }
+ /**
+ * This method is called from within the constructor to initialize the form. WARNING: Do NOT
+ * modify this code. The content of this method is always regenerated by the Form Editor.
+ */
+ private void initComponents() { // GEN-BEGIN:initComponents
+ buttonLabel = new javax.swing.JTextField();
+ okButton = new javax.swing.JButton();
+
+ addWindowListener(
+ new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ closeDialog(evt);
+ }
});
- getContentPane().add(buttonLabel, java.awt.BorderLayout.CENTER);
+ getContentPane().add(buttonLabel, java.awt.BorderLayout.CENTER);
- okButton.setText("Ok");
- okButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- okButtonPressed(evt);
- }
+ okButton.setText("Ok");
+ okButton.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ okButtonPressed(evt);
+ }
});
- getContentPane().add(okButton, java.awt.BorderLayout.EAST);
+ getContentPane().add(okButton, java.awt.BorderLayout.EAST);
+
+ pack();
+ } // GEN-END:initComponents
+
+ private void okButtonPressed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okButtonPressed
+ setVisible(false);
+ } // GEN-LAST:event_okButtonPressed
+
+ /** Closes the dialog */
+ private void closeDialog(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_closeDialog
+ setVisible(false);
+ dispose();
+ } // GEN-LAST:event_closeDialog
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField buttonLabel;
+ private javax.swing.JButton okButton;
+ // End of variables declaration//GEN-END:variables
- pack();
- }//GEN-END:initComponents
+ public String getText() {
+ return buttonLabel.getText();
+ }
- private void okButtonPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonPressed
- setVisible(false);
- }//GEN-LAST:event_okButtonPressed
-
- /** Closes the dialog */
- private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
- setVisible(false);
- dispose();
- }//GEN-LAST:event_closeDialog
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JTextField buttonLabel;
- private javax.swing.JButton okButton;
- // End of variables declaration//GEN-END:variables
-
- public String getText() {
- return buttonLabel.getText();
- }
-
- public void setText(String text) {
- buttonLabel.setText(text);
- buttonLabel.selectAll();
- }
+ public void setText(String text) {
+ buttonLabel.setText(text);
+ buttonLabel.selectAll();
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/ResultPanel.java b/src/main/java/net/rptools/dicetool/ui/ResultPanel.java
index 013dd90..f83c943 100644
--- a/src/main/java/net/rptools/dicetool/ui/ResultPanel.java
+++ b/src/main/java/net/rptools/dicetool/ui/ResultPanel.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
@@ -27,133 +27,115 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;
-
-import net.rptools.dicetool.resultset.Row;
import net.rptools.dicetool.resultset.Row;
-
-/**
- *
- * @author drice
- */
+/** @author drice */
public class ResultPanel extends javax.swing.JPanel implements RollListener, MouseListener {
- private static final long serialVersionUID = -6416009322085819601L;
-
- private final MainFrame tool;
-
- private RowListModel tableModel;
-
- /** Creates new form ResultPanel */
- public ResultPanel(MainFrame tool) {
- this.tool = tool;
- initComponents();
-
- tool.registerRollListener(this);
- }
-
- public void clearList() {
- tableModel.clear();
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- private void initComponents() {//GEN-BEGIN:initComponents
- scrollPane = new javax.swing.JScrollPane();
- tableModel = new RowListModel();
- resultTable = new ResultTable(tool);
-
- //resultTable.setRowSelectionAllowed(false);
- //resultTable.setCellSelectionEnabled(false);
- //resultTable.setColumnSelectionAllowed(false);
-
- //resultTable.addRowSelectionInterval(1, 15);
-
- resultTable.addMouseListener(this);
-
- setLayout(new java.awt.BorderLayout());
-
- scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- resultTable.setModel(tableModel);
-
-/*
- resultTable.getColumnModel().getColumn(0).setPreferredWidth(100);
- resultTable.getColumnModel().getColumn(1).setPreferredWidth(5);
- resultTable.getColumnModel().getColumn(2).setPreferredWidth(5);
-*/
-
- scrollPane.setViewportView(resultTable);
-
- add(scrollPane, java.awt.BorderLayout.CENTER);
-
- }//GEN-END:initComponents
-
- public void add(String... expressions) {
- for (String x : expressions) {
- tableModel.addRow(new Row(x));
- }
+ private static final long serialVersionUID = -6416009322085819601L;
+
+ private final MainFrame tool;
+
+ private RowListModel tableModel;
+
+ /** Creates new form ResultPanel */
+ public ResultPanel(MainFrame tool) {
+ this.tool = tool;
+ initComponents();
+
+ tool.registerRollListener(this);
+ }
+
+ public void clearList() {
+ tableModel.clear();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form. WARNING: Do NOT
+ * modify this code. The content of this method is always regenerated by the Form Editor.
+ */
+ private void initComponents() { // GEN-BEGIN:initComponents
+ scrollPane = new javax.swing.JScrollPane();
+ tableModel = new RowListModel();
+ resultTable = new ResultTable(tool);
+
+ // resultTable.setRowSelectionAllowed(false);
+ // resultTable.setCellSelectionEnabled(false);
+ // resultTable.setColumnSelectionAllowed(false);
+
+ // resultTable.addRowSelectionInterval(1, 15);
+
+ resultTable.addMouseListener(this);
+
+ setLayout(new java.awt.BorderLayout());
+
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ resultTable.setModel(tableModel);
+
+ /*
+ resultTable.getColumnModel().getColumn(0).setPreferredWidth(100);
+ resultTable.getColumnModel().getColumn(1).setPreferredWidth(5);
+ resultTable.getColumnModel().getColumn(2).setPreferredWidth(5);
+ */
+
+ scrollPane.setViewportView(resultTable);
+
+ add(scrollPane, java.awt.BorderLayout.CENTER);
+ } // GEN-END:initComponents
+
+ public void add(String... expressions) {
+ for (String x : expressions) {
+ tableModel.addRow(new Row(x));
}
-
- public void add(List expressions) {
- for (String x : expressions) {
- tableModel.addRow(new Row(x));
- }
+ }
+
+ public void add(List expressions) {
+ for (String x : expressions) {
+ tableModel.addRow(new Row(x));
}
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JList resultTable;
- private javax.swing.JScrollPane scrollPane;
- // End of variables declaration//GEN-END:variables
-
- /**
- * @return
- */
- public RowListModel getTableModel() {
- return tableModel;
- }
-
- /**
- * @return Returns the resultTable.
- */
- public javax.swing.JList getResultTable() {
- return resultTable;
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
- */
- public void mouseClicked(MouseEvent e) {
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
- */
- public void mouseEntered(MouseEvent e) {
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
- */
- public void mouseExited(MouseEvent e) {
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
- */
- public void mousePressed(MouseEvent e) {
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
- */
- public void mouseReleased(MouseEvent e) {
- }
-
- public void rolled(List expressions) {
- add(expressions);
- }
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JList resultTable;
+ private javax.swing.JScrollPane scrollPane;
+ // End of variables declaration//GEN-END:variables
+
+ /** @return */
+ public RowListModel getTableModel() {
+ return tableModel;
+ }
+
+ /** @return Returns the resultTable. */
+ public javax.swing.JList getResultTable() {
+ return resultTable;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ */
+ public void mouseClicked(MouseEvent e) {}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent e) {}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+ */
+ public void mouseExited(MouseEvent e) {}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+ */
+ public void mousePressed(MouseEvent e) {}
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+ */
+ public void mouseReleased(MouseEvent e) {}
+
+ public void rolled(List expressions) {
+ add(expressions);
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/ResultTable.java b/src/main/java/net/rptools/dicetool/ui/ResultTable.java
index df9d52c..c5c1ebb 100644
--- a/src/main/java/net/rptools/dicetool/ui/ResultTable.java
+++ b/src/main/java/net/rptools/dicetool/ui/ResultTable.java
@@ -1,42 +1,42 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
+
import javax.swing.JList;
/**
* @author drice
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
+ * To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class ResultTable extends JList {
- private static final long serialVersionUID = 2156919317369449594L;
- private final MainFrame tool;
+ private static final long serialVersionUID = 2156919317369449594L;
+ private final MainFrame tool;
- public ResultTable(MainFrame tool) {
- super();
- this.tool = tool;
- }
-}
\ No newline at end of file
+ public ResultTable(MainFrame tool) {
+ super();
+ this.tool = tool;
+ }
+}
diff --git a/src/main/java/net/rptools/dicetool/ui/RollListener.java b/src/main/java/net/rptools/dicetool/ui/RollListener.java
index 866e243..719f166 100644
--- a/src/main/java/net/rptools/dicetool/ui/RollListener.java
+++ b/src/main/java/net/rptools/dicetool/ui/RollListener.java
@@ -1,35 +1,32 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.util.List;
-/**
- *
- * @author drice
- */
+/** @author drice */
public interface RollListener {
- public void rolled(List expressions);
+ public void rolled(List expressions);
}
diff --git a/src/main/java/net/rptools/dicetool/ui/RowListModel.java b/src/main/java/net/rptools/dicetool/ui/RowListModel.java
index 453872e..3961df6 100644
--- a/src/main/java/net/rptools/dicetool/ui/RowListModel.java
+++ b/src/main/java/net/rptools/dicetool/ui/RowListModel.java
@@ -1,108 +1,97 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.util.LinkedList;
import java.util.List;
-
import javax.swing.AbstractListModel;
-
import net.rptools.dicetool.resultset.Row;
-import net.rptools.dicetool.resultset.Row;
-
-/**
- *
- * @author drice
- */
+/** @author drice */
public class RowListModel extends AbstractListModel {
- private static final long serialVersionUID = -4240626548954778007L;
+ private static final long serialVersionUID = -4240626548954778007L;
- private static final int MAX_ROWS = 1000;
+ private static final int MAX_ROWS = 1000;
- private List rows = new LinkedList();
+ private List rows = new LinkedList();
- /** Creates a new instance of DieGroupTableModel */
- public RowListModel() {
- }
+ /** Creates a new instance of DieGroupTableModel */
+ public RowListModel() {}
- public Row getRow(int rowIndex) {
- Object o = rows.get(rowIndex);
+ public Row getRow(int rowIndex) {
+ Object o = rows.get(rowIndex);
- if (o == null)
- return null;
+ if (o == null) return null;
- Row row = (Row) o;
+ Row row = (Row) o;
- return row;
- }
-
- public void addRow(Row row) {
- rows.add(row);
- if (trimRows()) {
- fireContentsChanged(this, -1, -1);
- } else {
- fireContentsChanged(this, rows.size() - 1, rows.size() - 1);
- }
- }
-
- public void addRows(Row... rs) {
- for (Row r : rs)
- this.rows.add(r);
-
- if (trimRows()) {
- fireContentsChanged(this, -1, -1);
- } else {
- fireContentsChanged(this, rows.size() - rs.length, rows.size() - 1);
- }
+ return row;
+ }
+
+ public void addRow(Row row) {
+ rows.add(row);
+ if (trimRows()) {
+ fireContentsChanged(this, -1, -1);
+ } else {
+ fireContentsChanged(this, rows.size() - 1, rows.size() - 1);
}
-
- private boolean trimRows() {
- if (rows.size() > MAX_ROWS) {
- int trimCount = rows.size() - MAX_ROWS;
-
- for (int i = 0; i < trimCount; i++)
- rows.remove(0);
-
- return true;
- }
-
- return false;
+ }
+
+ public void addRows(Row... rs) {
+ for (Row r : rs) this.rows.add(r);
+
+ if (trimRows()) {
+ fireContentsChanged(this, -1, -1);
+ } else {
+ fireContentsChanged(this, rows.size() - rs.length, rows.size() - 1);
}
+ }
+
+ private boolean trimRows() {
+ if (rows.size() > MAX_ROWS) {
+ int trimCount = rows.size() - MAX_ROWS;
- public void clear() {
- rows.clear();
+ for (int i = 0; i < trimCount; i++) rows.remove(0);
- fireContentsChanged(this, -1, -1);
+ return true;
}
- public int getSize() {
- return rows.size();
- }
+ return false;
+ }
+
+ public void clear() {
+ rows.clear();
+
+ fireContentsChanged(this, -1, -1);
+ }
+
+ public int getSize() {
+ return rows.size();
+ }
- public Object getElementAt(int index) {
- return rows.get(index);
- }
+ public Object getElementAt(int index) {
+ return rows.get(index);
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/SettingsWindow.java b/src/main/java/net/rptools/dicetool/ui/SettingsWindow.java
index f619169..3c93b86 100644
--- a/src/main/java/net/rptools/dicetool/ui/SettingsWindow.java
+++ b/src/main/java/net/rptools/dicetool/ui/SettingsWindow.java
@@ -1,9 +1,30 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package net.rptools.dicetool.ui;
import javax.swing.*;
-/**
- * Created by smaudet on 3/4/17.
- */
-public class SettingsWindow extends JWindow {
-}
+/** Created by smaudet on 3/4/17. */
+public class SettingsWindow extends JWindow {}
diff --git a/src/main/java/net/rptools/dicetool/ui/VariablePanel.java b/src/main/java/net/rptools/dicetool/ui/VariablePanel.java
index 26d4c16..2791860 100644
--- a/src/main/java/net/rptools/dicetool/ui/VariablePanel.java
+++ b/src/main/java/net/rptools/dicetool/ui/VariablePanel.java
@@ -1,143 +1,91 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
-import net.rptools.parser.ParserException;
-import net.rptools.parser.VariableResolver;
-
import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
-
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
+ * To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
-public class VariablePanel extends JPanel implements ActionListener {
- private static final long serialVersionUID = -6160835923220655321L;
- private final int NUM_VARIABLES = 10;
- private final VariableResolver resolver;
- private MainFrame dmTool;
+public class VariablePanel extends JPanel {
+ private static final long serialVersionUID = -6160835923220655321L;
+ private final int NUM_VARIABLES = 10;
+ private MainFrame dmTool;
+
+ private Map variableToNames = new HashMap();
+ private Map variableToValues = new HashMap();
+ private JTextField[] variableNames;
+ private JTextField[] variableValues;
+
+ public VariablePanel(MainFrame dmTool) {
+ this.dmTool = dmTool;
+
+ initComponents();
+ }
- private Map variableToNames = new HashMap();
- private Map variableToValues = new HashMap();
- private JTextField[] variableNames;
- private JTextField[] variableValues;
+ private void initComponents() {
+ setLayout(new GridLayout(2, 5));
+ variableNames = new JTextField[NUM_VARIABLES];
+ for (int j = 0; j < NUM_VARIABLES; j++) {
+ JTextField jtf = new JTextField();
+ variableNames[j] = jtf;
+ add(jtf);
+ }
- public VariablePanel(MainFrame dmTool, VariableResolver resolver) {
- this.dmTool = dmTool;
- this.resolver = resolver;
+ variableValues = new JTextField[NUM_VARIABLES];
+ for (int j = 0; j < NUM_VARIABLES; j++) {
+ JTextField jtf = new JTextField();
+ variableValues[j] = jtf;
+ add(jtf);
+ }
+ for (int j = 0; j < NUM_VARIABLES; j++) {
+ variableToNames.put(variableNames[j], variableValues[j]);
+ variableToValues.put(variableValues[j], variableNames[j]);
+ }
+ }
- initComponents();
- }
+ public int getCount() {
+ return NUM_VARIABLES;
+ }
- private void initComponents() {
- setLayout(new GridLayout(2, 5));
- variableNames = new JTextField[NUM_VARIABLES];
- for (int j = 0; j < NUM_VARIABLES; j++) {
- JTextField jtf = new JTextField();
- jtf.addActionListener(this);
- variableNames[j] = jtf;
- add(jtf);
- }
+ public void setVariable(int index, String name, String value) {
+ variableNames[index].setText(name);
+ variableValues[index].setText(value);
+ }
- variableValues = new JTextField[NUM_VARIABLES];
- for (int j = 0; j < NUM_VARIABLES; j++) {
- JTextField jtf = new JTextField();
- jtf.addActionListener(this);
- variableValues[j] = jtf;
- add(jtf);
- }
- for (int j = 0; j < NUM_VARIABLES; j++) {
- variableToNames.put(variableNames[j],variableValues[j]);
- variableToValues.put(variableValues[j],variableNames[j]);
- }
- }
-
- public int getCount() {
- return NUM_VARIABLES;
- }
-
- public void setVariable(int index, String name, String value) {
- variableNames[index].setText(name);
- variableValues[index].setText(value);
- }
-
- public String getName(int index) {
- return variableNames[index].getText();
- }
-
- public String getValue(int index) {
- return variableValues[index].getText();
- }
-
- public Map getVariables() {
- Map ret = new HashMap();
-
- for (int i = 0; i < NUM_VARIABLES; i++) {
- String name = variableNames[i].getText();
-
- if (name != null && name.length() > 0 && !ret.containsKey(name)) {
- Double value = Double.valueOf(variableValues[i].getText());
-
- ret.put(name, value);
- }
- }
-
- return ret;
- }
+ public String getName(int index) {
+ return variableNames[index].getText();
+ }
- @Override
- public void actionPerformed(ActionEvent e) {
- Object source = e.getSource();
- if(source instanceof JTextField) {
- JTextField tf = (JTextField) source;
- String value = tf.getText();
- if(variableToNames.containsKey(tf)){
- JTextField valF = variableToNames.get(tf);
- try {
- resolver.setVariable(value, BigDecimal.valueOf(Integer.parseInt(valF.getText())));
- } catch (ParserException e1) {
- e1.printStackTrace();
- }
- } else if(variableToValues.containsKey(tf)) {
- JTextField namF = variableToValues.get(tf);
- try {
- resolver.setVariable(namF.getText(), BigDecimal.valueOf(Integer.valueOf(value)));
- } catch (ParserException e1) {
- e1.printStackTrace();
- }
- }
- }
- }
+ public String getValue(int index) {
+ return variableValues[index].getText();
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/WindowListener.java b/src/main/java/net/rptools/dicetool/ui/WindowListener.java
index aae7ea3..5b92dfd 100644
--- a/src/main/java/net/rptools/dicetool/ui/WindowListener.java
+++ b/src/main/java/net/rptools/dicetool/ui/WindowListener.java
@@ -1,104 +1,104 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.ui;
import java.awt.event.WindowEvent;
-
import javax.swing.JOptionPane;
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
+ * To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class WindowListener implements java.awt.event.WindowListener {
- private final MainFrame tool;
- public WindowListener(MainFrame tool) {
- this.tool = tool;
-
- this.tool.addWindowListener(this);
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
- */
- public void windowActivated(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
- */
- public void windowClosed(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
- */
- public void windowClosing(WindowEvent e) {
-
- int save = JOptionPane.showConfirmDialog(tool, "Would you like to save your settings?", "Save", JOptionPane.YES_NO_OPTION);
- if (save == JOptionPane.YES_OPTION) {
- tool.savePreferences();
- }
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
- */
- public void windowDeactivated(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
- */
- public void windowDeiconified(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
- */
- public void windowIconified(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
- */
- public void windowOpened(WindowEvent e) {
- // TODO Auto-generated method stub
-
- }
-
+ private final MainFrame tool;
+
+ public WindowListener(MainFrame tool) {
+ this.tool = tool;
+
+ this.tool.addWindowListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
+ */
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ */
+ public void windowClosed(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ */
+ public void windowClosing(WindowEvent e) {
+
+ int save =
+ JOptionPane.showConfirmDialog(
+ tool, "Would you like to save your settings?", "Save", JOptionPane.YES_NO_OPTION);
+ if (save == JOptionPane.YES_OPTION) {
+ tool.savePreferences();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
+ */
+ public void windowDeactivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
+ */
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
+ */
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
+ */
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/editor/EditorPanel.java b/src/main/java/net/rptools/dicetool/ui/editor/EditorPanel.java
index 2320017..0ecd73e 100644
--- a/src/main/java/net/rptools/dicetool/ui/editor/EditorPanel.java
+++ b/src/main/java/net/rptools/dicetool/ui/editor/EditorPanel.java
@@ -1,3 +1,27 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package net.rptools.dicetool.ui.editor;
import javax.swing.JPanel;
@@ -6,21 +30,17 @@
public class EditorPanel extends JPanel {
- private static final long serialVersionUID = 7541467864777200652L;
-
- public EditorPanel() {
- initializeComponents();
- }
-
- private void initializeComponents() {
- JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
-
- JTree tree = new JTree();
-
-
-// TreeModel
- }
-
-
+ private static final long serialVersionUID = 7541467864777200652L;
+ public EditorPanel() {
+ initializeComponents();
+ }
+
+ private void initializeComponents() {
+ JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
+
+ JTree tree = new JTree();
+
+ // TreeModel
+ }
}
diff --git a/src/main/java/net/rptools/dicetool/ui/editor/EditorTreeModel.java b/src/main/java/net/rptools/dicetool/ui/editor/EditorTreeModel.java
index 352349c..19485ff 100644
--- a/src/main/java/net/rptools/dicetool/ui/editor/EditorTreeModel.java
+++ b/src/main/java/net/rptools/dicetool/ui/editor/EditorTreeModel.java
@@ -1,3 +1,27 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package net.rptools.dicetool.ui.editor;
import javax.swing.event.TreeModelListener;
@@ -6,57 +30,56 @@
import javax.swing.tree.TreePath;
public class EditorTreeModel extends DefaultTreeModel {
-
-// private final Data data;
-
- public EditorTreeModel(TreeNode root) {
- super(root);
- }
-
-// public EditorTreeModel(Data data) {
-// super(TreeNode);
-//// TreeNode node = new TreeNode();
-// this.data = data;
-// }
-
- public Object getRoot() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getChild(Object parent, int index) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getChildCount(Object parent) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public boolean isLeaf(Object node) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void valueForPathChanged(TreePath path, Object newValue) {
- // TODO Auto-generated method stub
-
- }
-
- public int getIndexOfChild(Object parent, Object child) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public void addTreeModelListener(TreeModelListener l) {
- // TODO Auto-generated method stub
-
- }
-
- public void removeTreeModelListener(TreeModelListener l) {
- // TODO Auto-generated method stub
-
- }
+ // private final Data data;
+
+ public EditorTreeModel(TreeNode root) {
+ super(root);
+ }
+
+ // public EditorTreeModel(Data data) {
+ // super(TreeNode);
+ //// TreeNode node = new TreeNode();
+ // this.data = data;
+ // }
+
+ public Object getRoot() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getChild(Object parent, int index) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getChildCount(Object parent) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean isLeaf(Object node) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int getIndexOfChild(Object parent, Object child) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void addTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeTreeModelListener(TreeModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/src/test/java/net/rptools/dicetool/Test01.java b/src/test/java/net/rptools/dicetool/Test01.java
index dc6ce3b..89c3d0c 100644
--- a/src/test/java/net/rptools/dicetool/Test01.java
+++ b/src/test/java/net/rptools/dicetool/Test01.java
@@ -1,78 +1,76 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool;
+
import java.io.FileInputStream;
import java.io.InputStreamReader;
-import java.io.StringReader;
import java.util.Map;
-
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
-import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
/**
* @author drice
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
+ *
To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class Test01 {
- public static void main(String[] args) throws Exception {
- Context cx = Context.enter();
- try {
- Scriptable scope = cx.initStandardObjects();
- cx.evaluateReader(scope, new InputStreamReader(new FileInputStream("src/functions.js")), "", 1, null);
-
- Object[] ids = scope.getIds();
- for (int i = 0; i < ids.length; i++) {
- System.out.println("ID: " + ids[i]);
- }
-
- Object fObj = scope.get("registerFunctions", scope);
- if (!(fObj instanceof Function)) {
- System.out.println("f is undefined or not a function.");
- } else {
- Object functionArgs[] = {};
- Function f = (Function) fObj;
- Object result = f.call(cx, scope, scope, functionArgs);
-
- System.out.println(result.getClass().getName());
-
- Map m = (Map) Context.toType(result, Map.class);
-
- Function f2 = (Function) m.get("foo");
-
- //Function f2 = (Function) result;
- System.out.println(f2.call(cx, scope, scope, functionArgs));
- }
- // Object result = func.call(cx, scope, func, new Object[] { new
- // Integer(10) });
- // System.err.println(cx.toString(result));
- } finally {
- Context.exit();
- }
- }
+ public static void main(String[] args) throws Exception {
+ Context cx = Context.enter();
+ try {
+ Scriptable scope = cx.initStandardObjects();
+ cx.evaluateReader(
+ scope, new InputStreamReader(new FileInputStream("src/functions.js")), "", 1, null);
+
+ Object[] ids = scope.getIds();
+ for (int i = 0; i < ids.length; i++) {
+ System.out.println("ID: " + ids[i]);
+ }
+
+ Object fObj = scope.get("registerFunctions", scope);
+ if (!(fObj instanceof Function)) {
+ System.out.println("f is undefined or not a function.");
+ } else {
+ Object functionArgs[] = {};
+ Function f = (Function) fObj;
+ Object result = f.call(cx, scope, scope, functionArgs);
+
+ System.out.println(result.getClass().getName());
+
+ Map m = (Map) Context.toType(result, Map.class);
+
+ Function f2 = (Function) m.get("foo");
+
+ // Function f2 = (Function) result;
+ System.out.println(f2.call(cx, scope, scope, functionArgs));
+ }
+ // Object result = func.call(cx, scope, func, new Object[] { new
+ // Integer(10) });
+ // System.err.println(cx.toString(result));
+ } finally {
+ Context.exit();
+ }
+ }
}
diff --git a/src/test/java/net/rptools/dicetool/dice/ExpressionFactoryTest.java b/src/test/java/net/rptools/dicetool/dice/ExpressionFactoryTest.java
index 8a09124..dc495eb 100644
--- a/src/test/java/net/rptools/dicetool/dice/ExpressionFactoryTest.java
+++ b/src/test/java/net/rptools/dicetool/dice/ExpressionFactoryTest.java
@@ -1,61 +1,58 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.dice;
-import java.util.List;
-import java.util.ListIterator;
-
import junit.framework.TestCase;
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
+ * To change the template for this generated type comment go to Window - Preferences - Java -
+ * Code Generation - Code and Comments
*/
public class ExpressionFactoryTest extends TestCase {
- private static String[] RESULTS = new String[] {
- "roll(1, 20)+17",
- "total(1, roll(2, 6)+1)",
- "total(1, roll(2, 6)+1)",
- "total(1, roll(2, 6)+1)",
- "total(1, roll(2, 6)+1)",
- "total(1, roll(2, 6)+1)",
- "total(2, roll(1, 6))",
- "total(2, roll(1, 8))",
- "total(2, roll(1, 10))",
- "roll(1, 4)",
- };
-
- public void testGetExpressionStrings() {
- /*
- List l = ExpressionFactory.getExpressions("d20+17;5[2d6+1];d6|d8|d10;d4");
- assertEquals(RESULTS.length, l.size());
- for (ListIterator i = l.listIterator(); i.hasNext(); ) {
- assertEquals(RESULTS[i.nextIndex()], ((Expression) i.next()).getDefinition());
- }
- */
- }
+ private static String[] RESULTS =
+ new String[] {
+ "roll(1, 20)+17",
+ "total(1, roll(2, 6)+1)",
+ "total(1, roll(2, 6)+1)",
+ "total(1, roll(2, 6)+1)",
+ "total(1, roll(2, 6)+1)",
+ "total(1, roll(2, 6)+1)",
+ "total(2, roll(1, 6))",
+ "total(2, roll(1, 8))",
+ "total(2, roll(1, 10))",
+ "roll(1, 4)",
+ };
+
+ public void testGetExpressionStrings() {
+ /*
+ List l = ExpressionFactory.getExpressions("d20+17;5[2d6+1];d6|d8|d10;d4");
+ assertEquals(RESULTS.length, l.size());
+ for (ListIterator i = l.listIterator(); i.hasNext(); ) {
+ assertEquals(RESULTS[i.nextIndex()], ((Expression) i.next()).getDefinition());
+ }
+ */
+ }
}
diff --git a/src/test/java/net/rptools/dicetool/dice/ExpressionTest.java b/src/test/java/net/rptools/dicetool/dice/ExpressionTest.java
index 23a5cc4..288683d 100644
--- a/src/test/java/net/rptools/dicetool/dice/ExpressionTest.java
+++ b/src/test/java/net/rptools/dicetool/dice/ExpressionTest.java
@@ -1,25 +1,25 @@
/* The MIT License
- *
- * Copyright (c) 2004,2005 David Rice
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
+ *
+ * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.rptools.dicetool.dice;
@@ -28,50 +28,49 @@
/**
* @author drice
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ *
To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ExpressionTest extends TestCase {
- /**
- * Constructor for ExpressionTest.
- * @param arg0
- */
- public ExpressionTest(String arg0) {
- super(arg0);
- }
+ /**
+ * Constructor for ExpressionTest.
+ *
+ * @param arg0
+ */
+ public ExpressionTest(String arg0) {
+ super(arg0);
+ }
- public void testExpression() {
- }
+ public void testExpression() {}
-// public void testFixFunctions() {
-// assertEquals("add<2+10,17*22>",
-// Expression.fixFunctions("add(2+10,17*22)"));
-// assertEquals("add<10,2+17*(2+multiply<20,(2*8)+7>)>",
-// Expression.fixFunctions("add(10,2+17*(2+multiply(20,(2*8)+7)))"));
-// }
-//
-// public void testDetectParameter() {
-// assertEquals("1",
-// Expression.detectParameter("foo<1+2,12+(17*3)>", 5, Expression.DETECT_BACKWARD));
-// assertEquals("17",
-// Expression.detectParameter("foo<1+2,12+(17*3)>", 14, Expression.DETECT_BACKWARD));
-// assertEquals("(2+3)",
-// Expression.detectParameter("foo<(2+3)+2>", 9, Expression.DETECT_BACKWARD));
-// assertEquals("2",
-// Expression.detectParameter("2+3", 1, Expression.DETECT_BACKWARD));
-//
-// assertEquals("(17*3)",
-// Expression.detectParameter("foo<1+2,12+(17*3)>", 10, Expression.DETECT_FOREWARD));
-// assertEquals("3",
-// Expression.detectParameter("2+3", 1, Expression.DETECT_FOREWARD));
-// }
-//
-// public void testConvertInfixToFunctionNotation() {
-// //System.out.println(Expression.convertInfixToFunctionNotation("2+3"));
-// System.out.println(Expression.convertInfixToFunctionNotation("1+2*3"));
-// //System.out.println(Expression.convertInfixToFunctionNotation("(1+2)*3"));
-// //System.out.println(Expression.convertInfixToFunctionNotation("foo<1+2,12+(17*3)>"));
-// }
+ // public void testFixFunctions() {
+ // assertEquals("add<2+10,17*22>",
+ // Expression.fixFunctions("add(2+10,17*22)"));
+ // assertEquals("add<10,2+17*(2+multiply<20,(2*8)+7>)>",
+ // Expression.fixFunctions("add(10,2+17*(2+multiply(20,(2*8)+7)))"));
+ // }
+ //
+ // public void testDetectParameter() {
+ // assertEquals("1",
+ // Expression.detectParameter("foo<1+2,12+(17*3)>", 5, Expression.DETECT_BACKWARD));
+ // assertEquals("17",
+ // Expression.detectParameter("foo<1+2,12+(17*3)>", 14, Expression.DETECT_BACKWARD));
+ // assertEquals("(2+3)",
+ // Expression.detectParameter("foo<(2+3)+2>", 9, Expression.DETECT_BACKWARD));
+ // assertEquals("2",
+ // Expression.detectParameter("2+3", 1, Expression.DETECT_BACKWARD));
+ //
+ // assertEquals("(17*3)",
+ // Expression.detectParameter("foo<1+2,12+(17*3)>", 10, Expression.DETECT_FOREWARD));
+ // assertEquals("3",
+ // Expression.detectParameter("2+3", 1, Expression.DETECT_FOREWARD));
+ // }
+ //
+ // public void testConvertInfixToFunctionNotation() {
+ // //System.out.println(Expression.convertInfixToFunctionNotation("2+3"));
+ // System.out.println(Expression.convertInfixToFunctionNotation("1+2*3"));
+ // //System.out.println(Expression.convertInfixToFunctionNotation("(1+2)*3"));
+ // //System.out.println(Expression.convertInfixToFunctionNotation("foo<1+2,12+(17*3)>"));
+ // }
}
diff --git a/src/test/java/net/rptools/dicetool/model/DataTest.java b/src/test/java/net/rptools/dicetool/model/DataTest.java
index a766bc8..571be18 100644
--- a/src/test/java/net/rptools/dicetool/model/DataTest.java
+++ b/src/test/java/net/rptools/dicetool/model/DataTest.java
@@ -1,35 +1,53 @@
+/* The MIT License
+ *
+ * Copyright (c) 2004,2005,2006 David Rice
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package net.rptools.dicetool.model;
import junit.framework.TestCase;
-import net.rptools.dicetool.model.Button;
-import net.rptools.dicetool.model.ButtonGroup;
-import net.rptools.dicetool.model.Data;
-import net.rptools.dicetool.model.Variable;
-
public class DataTest extends TestCase {
- public void testToFromXml() {
- Data d = new Data();
- d.getVariables().add(new Variable("var1", "value1"));
- d.getVariables().add(new Variable("var2", "value2"));
- d.setJavascript("\nfunction f(a, b) {\n return a > b;\n}\n");
-
- ButtonGroup bg1 = new ButtonGroup("bg1");
- bg1.getButtons().add(new Button("b1", "d20+7", "d2+4"));
- d.getButtonGroups().add(bg1);
+ public void testToFromXml() {
+ Data d = new Data();
+ d.getVariables().add(new Variable("var1", "value1"));
+ d.getVariables().add(new Variable("var2", "value2"));
+ d.setJavascript("\nfunction f(a, b) {\n return a > b;\n}\n");
+
+ ButtonGroup bg1 = new ButtonGroup("bg1");
+ bg1.getButtons().add(new Button("b1", "d20+7", "d2+4"));
+ d.getButtonGroups().add(bg1);
+
+ ButtonGroup bg2 = new ButtonGroup("bg2");
+ bg2.getButtons().add(new Button("b2a", "d20+7", "d2+4"));
+ bg2.getButtons().add(new Button("b2b", "d20+7", "d2+4"));
+ bg2.getButtons().add(new Button("b2c", "d20+7", "d2+4"));
+ d.getButtonGroups().add(bg2);
+
+ String s = Data.toXml(d);
+ System.out.println(s);
- ButtonGroup bg2 = new ButtonGroup("bg2");
- bg2.getButtons().add(new Button("b2a", "d20+7", "d2+4"));
- bg2.getButtons().add(new Button("b2b", "d20+7", "d2+4"));
- bg2.getButtons().add(new Button("b2c", "d20+7", "d2+4"));
- d.getButtonGroups().add(bg2);
-
- String s = Data.toXml(d);
- System.out.println(s);
-
- Data d2 = Data.fromXml(s);
- assertEquals(s, Data.toXml(d2));
- }
-
+ Data d2 = Data.fromXml(s);
+ assertEquals(s, Data.toXml(d2));
+ }
}