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