diff --git a/.gitignore b/.gitignore index 888bb1c..314a215 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,136 @@ -.project -.classpath -.settings/ +HELP.md +!**/src/main/**/target/ +!**/src/test/**/target/ + +## Java.gitignore +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +## Maven.gitignore +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +#!.mvn/wrapper/maven-wrapper.jar +.mvn/wrapper/maven-wrapper.jar + +## Eclipse.gitignore +.metadata +#bin/ target/ -.idea/ -atdl4j.iml -atdl4j-ui.iml -atdl4j.iws \ No newline at end of file +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans +.sts4-cache + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated +.apt_generated_test + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +.project + +## VisualStudioCode.gitignore +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +.sonatype diff --git a/README.md b/README.md index e4d8c3a..ec6eba9 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ #### The Open Source Java Solution for FIXatdl -atdl4j is an open source and not-for-profit Java implementation of [FIXatdl](http://www.fixprotocol.org/FIXatdl), the FIX Protocol Algorithmic Trading Definition Language standard developed by FIX Protocol Limited (FPL). - -Please see [the atdl4j Homepage](http://atdl4j.org) for an overview. +atdl4j is an open source and not-for-profit Java implementation of [FIXatdl](https://www.fixtrading.org/standards/fixatdl/), the FIX Protocol Algorithmic Trading Definition Language standard developed by [FIX Protocol Limited (FPL)](https://www.fixtrading.org/). ## Features -* Compatible with Java 6 and upper versions +* Compatible with Java 8 and upper versions * Displays algo input screens based on the latest industry-standard FIXatdl 1.1 XML schema * Reads and generates algorithm-specific FIX message content * Can be integrated into a trading system, or run as a standalone testing/validation tool. @@ -49,15 +47,15 @@ If you are intending to implement a full-stack trading system with FIX order cap ## Key Contributors -* Scott Atwell, American Century +* [Scott Atwell](https://github.com/scottatwell), American Century Investments * [John Shields](https://github.com/johnnyshields) * Danilo Tuler, Investtools * Renato Gallart, Investtools ## License -atdlj is licensed under the MIT license. Refer to LICENSE file for details +atdl4j is licensed under the MIT license. Refer to LICENSE file for details FIX Protocol and FIXatdl are trademarks or service marks of FIX Protocol Limited -[Looking for a .NET implementation of FIXatdl? Check out atdl4net](http://atdl4net.org) +[Looking for a .NET implementation of FIXatdl? Check out atdl4net](https://github.com/atdl4net/atdl4net) diff --git a/dist/atdl4j-swing-launcher-3.0.3.jnlp b/dist/atdl4j-swing-launcher-3.0.3.jnlp deleted file mode 100644 index a06cccd..0000000 --- a/dist/atdl4j-swing-launcher-3.0.3.jnlp +++ /dev/null @@ -1,17 +0,0 @@ - - - - atdl4j - Swing - atdl4j - - The Open Source Java solution for FIXatdl - - - - - - - - - - diff --git a/dist/atdl4j-swt-launcher-3.0.3.jnlp b/dist/atdl4j-swt-launcher-3.0.3.jnlp deleted file mode 100644 index 327ac69..0000000 --- a/dist/atdl4j-swt-launcher-3.0.3.jnlp +++ /dev/null @@ -1,17 +0,0 @@ - - - - atdl4j - SWT - atdl4j - - The Open Source Java solution for FIXatdl - - - - - - - - - - diff --git a/dist/atdl4j-ui-3.0.3.jar b/dist/atdl4j-ui-3.0.3.jar deleted file mode 100644 index 7705dc2..0000000 Binary files a/dist/atdl4j-ui-3.0.3.jar and /dev/null differ diff --git a/docs/SWTAtdl4jTesterApp overhaul_layering 20100304.txt b/docs/SWTAtdl4jTesterApp overhaul_layering 20100304.txt new file mode 100644 index 0000000..81abf61 --- /dev/null +++ b/docs/SWTAtdl4jTesterApp overhaul_layering 20100304.txt @@ -0,0 +1,75 @@ +"SWTApplication" refactoring - rename to "SWTAtdl4jTesterApp", overhaul, and layered + +Interfaces: +----------- +- org.atdl4j.ui.app.Atdl4jTesterPanel + - org.atdl4j.ui.app.Atdl4jInputAndFilterDataSelectionPanel + - org.atdl4j.ui.app.Atdl4jInputAndFilterDataPanel + - org.atdl4j.ui.app.FixMsgLoadPanel + - org.atdl4j.ui.app.Atdl4jCompositePanel + - org.atdl4j.ui.app.FixatdlFileSelectionPanel + - org.atdl4j.ui.app.StrategySelectionPanel + - org.atdl4j.ui.app.StrategyDescriptionPanel + - org.atdl4j.ui.app.StrategiesPanel + +Non-UI-specific abstract base implementation: +--------------------------------------------- +org.atdl4j.ui.app.AbstractAtdl4jTesterApp +- org.atdl4j.ui.app.AbstractAtdl4jTesterPanel + - org.atdl4j.ui.app.AbstractAtdl4jInputAndFilterDataSelectionPanel + - org.atdl4j.ui.app.AbstractAtdl4jInputAndFilterDataPanel + - org.atdl4j.ui.app.AbstractFixMsgLoadPanel + - org.atdl4j.ui.app.AbstractAtdl4jCompositePanel + - org.atdl4j.ui.app.AbstractFixatdlFileSelectionPanel + - org.atdl4j.ui.app.AbstractStrategySelectionPanel + - org.atdl4j.ui.app.AbstractStrategyDescriptionPanel + - org.atdl4j.ui.app.AbstractStrategiesPanel + +SWT-specific implementation: +---------------------------- +org.atdl4j.ui.swt.app.SWTAtdl4jTesterApp +- org.atdl4j.ui.swt.app.SWTAtdl4jTesterPanel + - org.atdl4j.ui.swt.app.SWTAtdl4jInputAndFilterDataSelectionPanel + - org.atdl4j.ui.swt.app.SWTAtdl4jInputAndFilterDataPanel + - org.atdl4j.ui.swt.app.SWTFixMsgLoadPanel + - org.atdl4j.ui.swt.app.SWTAtdl4jCompositePanel + - org.atdl4j.ui.swt.app.SWTFixatdlFileSelectionPanel + - org.atdl4j.ui.swt.app.SWTStrategySelectionPanel + - org.atdl4j.ui.swt.app.SWTStrategyDescriptionPanel + - org.atdl4j.ui.swt.app.SWTStrategiesPanel + +Listeners: +---------- +- org.atdl4j.ui.app.Atdl4jInputAndFilterDataPanelListener +- org.atdl4j.ui.app.FixMsgLoadPanelListener +- org.atdl4j.ui.app.FixatdlFileSelectionPanelListener +- org.atdl4j.ui.app.StrategySelectionPanelListener +- org.atdl4j.ui.app.StrategiesPanelListener + +Pop-up message handler: +----------------------- +- org.atdl4j.ui.app.Atdl4jUserMessageHandler +- org.atdl4j.ui.app.AbstractAtdl4jUserMessageHandler +- org.atdl4j.ui.swt.app.SWTAtdl4jUserMessageHandler + +Config: +------- +- org.atdl4j.config.Atdl4jConfig +- org.atdl4j.config.AbstractAtdl4jConfig +- org.atdl4j.ui.swt.config.SWTAtdl4jConfig +- org.atdl4j.config.InputAndFilterData + + +Tweaks: +- InputAndFilterData - Added INPUT_FIELD_NAME_STRATEGY_FILTER_FIX_MSG_TYPE, getInputStrategyFilterFixMsgType(), setInputStrategyFilterFixMsgType(), and isFixMsgTypeSupportedForStrategy() +- org.atdl4j.ui.ControlHelper +- org.atdl4j.ui.impl.AbstractControlUI +- org.atdl4j.ui.impl.AbstractStrategyUI +- org.atdl4j.ui.impl.BaseControlUIFactory +- org.atdl4j.ui.impl.BaseStrategiesUIFactory +- org.atdl4j.ui.swt.impl.SWTFactory +- org.atdl4j.ui.swt.impl.SWTStrategiesUI + + + + diff --git a/docs/atdl4j Design Overview.pdf b/docs/atdl4j Design Overview.pdf new file mode 100644 index 0000000..f2a9282 Binary files /dev/null and b/docs/atdl4j Design Overview.pdf differ diff --git a/examples.md b/examples.md index d98744c..9b0b97b 100644 --- a/examples.md +++ b/examples.md @@ -2,6 +2,9 @@ ## Swing + +See SwingAtdl4jTesterApp.java + ```java // Embed the strategy panel in your own JFrame/JDialog JFrame frame = new JFrame(); @@ -17,7 +20,7 @@ Atdl4jOptions options = new Atdl4jOptions(); SwingAtdl4jCompositePanel atdlPanel = new SwingAtdl4jCompositePanel(); JPanel strategyPanel = (JPanel) atdlPanel.buildAtdl4jCompositePanel(frame, options); -String file = "path_to_atdl_file.xml"; +String file = "path_to_atdl_file.xml"; // (see src/test/resources for example FIXatdl files) atdlPanel.parseFixatdlFile(file); atdlPanel.loadScreenWithFilteredStrategies(); @@ -28,3 +31,5 @@ frame.setVisible(true); ## SWT +See SWTAtdl4jTesterApp.java + diff --git a/pom.xml b/pom.xml index d2def3d..dc9896f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,12 @@ 4.0.0 + org.atdl4j - 3.0.2 + 4.0.0 atdl4j-ui jar atdl4j-ui + danilo.tuler @@ -24,117 +26,161 @@ Developer + + johnnyshields + Johnny Shields + + Developer + + + + scottatwell + Scott Atwell + American Century Investments + + Developer + + + - - - 3.0.4 - - - - - maven2-repository.dev.java.net - Java.net Repository for Maven - https://download.java.net/maven/2 - - - swt-repo - SWT Maven Repository - https://swt-repo.googlecode.com/svn/repo/ - - - - - scm:git:git://github.com/atdl4j/atdl4j.git - scm:git:git@github.com:atdl4j/atdl4j.git - http://github.com/atdl4j/atdl4j - - - - - googlecode - atdl4j googlecode - svn:https://atdl4j.googlecode.com/svn/repo - - - googlecode-snapshots - atdl4j googlecode Snapshots - svn:https://atdl4j.googlecode.com/svn/repo - - - + - 1.6 - 1.7.5 + 1.8 + 3.1.0 + 2.3.7 + 2.3.3 + 2.3.1 + 3.6.18 + 2.17.2 + 3.10.1 + 3.2.2 + 3.0.0 + 3.2.1 + 1.7.36 org.eclipse.swt org.eclipse.swt.win32.win32.x86_64 4.3 + 1.8 - + org.slf4j slf4j-api - ${slf4jVersion} - - - org.slf4j - slf4j-log4j12 - ${slf4jVersion} + ${slf4j.version} ${swt.native.groupId} ${swt.native.artifactId} ${swt.native.version} - - joda-time - joda-time - 1.6 - com.jidesoft jide-oss - 3.5.15 + ${jide-oss.version} + + + jakarta.xml.bind + jakarta.xml.bind-api + ${jakarta-xml-bind.version} + + + org.glassfish.jaxb + jaxb-runtime + ${glassfish-jaxb.version} + true + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2.version} + true - + true org.apache.maven.plugins maven-compiler-plugin - 3.1 - - ${jdkVersion} - ${jdkVersion} - + ${maven-compiler-plugin.version} + + ${jdkVersion} + ${jdkVersion} + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + false + + true + true + + + + ${maven.version} + ${project.artifactId} + + + - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - - java - - - + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + false + + + + + attach-sources + verify + + jar-no-fork + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + + exec + + + - ${main.class} + ${JAVA_HOME}/bin/java + + -Dlog4j.configurationFile=log4j2-atdl4j-ui.xml + -classpath + + ${main.class} + + true + ${project.build.outputDirectory} - + org.jvnet.wagon-svn wagon-svn - 1.8 + ${wagon-svn.version} - + macos @@ -162,5 +208,30 @@ org.atdl4j.ui.swt.app.impl.SWTAtdl4jTesterApp + + sign-jar + + + + org.apache.maven.plugins + maven-jarsigner-plugin + ${maven-jarsigner-plugin.version} + + + sign + + sign + + + + + atdl4j + ${project.build.directory}\${project.build.finalName}.${project.packaging} + ${storepass} + + + + + diff --git a/src/main/java/org/atdl4j/config/AbstractAtdl4jConfiguration.java b/src/main/java/org/atdl4j/config/AbstractAtdl4jConfiguration.java index e2db359..4fa7cc9 100644 --- a/src/main/java/org/atdl4j/config/AbstractAtdl4jConfiguration.java +++ b/src/main/java/org/atdl4j/config/AbstractAtdl4jConfiguration.java @@ -1,7 +1,5 @@ package org.atdl4j.config; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; import org.atdl4j.data.TypeConverterFactory; import org.atdl4j.data.exception.Atdl4jClassLoadException; import org.atdl4j.ui.Atdl4jWidget; @@ -18,13 +16,15 @@ import org.atdl4j.ui.app.FixatdlFileSelectionPanel; import org.atdl4j.ui.app.StrategyDescriptionPanel; import org.atdl4j.ui.app.StrategySelectionPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Typical setup (for class named XXX): * private String classNameXXX; * public void setClassNameXXX(String); * public String getClassNameXXX(); - * abstract protected String getDefaultClassNameXXX(); + * protected abstract String getDefaultClassNameXXX(); * public XXX getXXX() throws ; * add to constructor: setClassNameXXX( getDefaultClassNameXXX() ); * NOTE: add public XXX getXXX() to Atdl4jOptions @@ -42,12 +42,11 @@ public abstract class AbstractAtdl4jConfiguration implements Atdl4jConfiguration { - private final Logger logger = Logger.getLogger(AbstractAtdl4jConfiguration.class); + private final Logger logger = LoggerFactory.getLogger(AbstractAtdl4jConfiguration.class); - public static String ATDL4J_PACKAGE_NAME_PATH_FOR_DEBUG_LOGGING = "org.atdl4j"; -//TODO 9/26/2010 Scott Atwell public static String DEFAULT_CLASS_NAME_STRATEGIES_UI_FACTORY = "org.atdl4j.ui.impl.BaseStrategiesUIFactory"; - public static String DEFAULT_CLASS_NAME_ATDL4j_WIDGET_FACTORY = "org.atdl4j.ui.impl.BaseAtdl4jWidgetFactory"; - public static String DEFAULT_CLASS_NAME_TYPE_CONVERTER_FACTORY = "org.atdl4j.data.TypeConverterFactory"; + public static final String ATDL4J_PACKAGE_NAME_PATH_FOR_DEBUG_LOGGING = "org.atdl4j"; + public static final String DEFAULT_CLASS_NAME_ATDL4J_WIDGET_FACTORY = "org.atdl4j.ui.impl.BaseAtdl4jWidgetFactory"; + public static final String DEFAULT_CLASS_NAME_TYPE_CONVERTER_FACTORY = "org.atdl4j.data.TypeConverterFactory"; private String classNameStrategiesUI; @@ -99,12 +98,12 @@ public abstract class AbstractAtdl4jConfiguration private boolean showValidateOutputSection = true; private boolean showCompositePanelOkCancelButtonSection = true; private boolean showTesterPanelOkCancelButtonSection = true; - private Integer strategyDropDownItemDepth = new Integer( 15 ); // ComboBox drop down 'depth' (aka VisibleItemCount) + private Integer strategyDropDownItemDepth = Integer.valueOf( 15 ); // ComboBox drop down 'depth' (aka VisibleItemCount) protected String getDefaultClassNameAtdl4jWidgetFactory() { - return DEFAULT_CLASS_NAME_ATDL4j_WIDGET_FACTORY; + return DEFAULT_CLASS_NAME_ATDL4J_WIDGET_FACTORY; } protected String getDefaultClassNameTypeConverterFactory() @@ -112,43 +111,43 @@ protected String getDefaultClassNameTypeConverterFactory() return DEFAULT_CLASS_NAME_TYPE_CONVERTER_FACTORY; } - // -- UI Infrastructure -- - abstract protected String getDefaultClassNameStrategiesUI(); - abstract protected String getDefaultClassNameStrategyUI(); - abstract protected String getDefaultClassNameStrategyPanelHelper(); + // -- UI Infrastructure -- + protected abstract String getDefaultClassNameStrategiesUI(); + protected abstract String getDefaultClassNameStrategyUI(); + protected abstract String getDefaultClassNameStrategyPanelHelper(); // -- Controls/Widgets -- - abstract protected String getDefaultClassNameAtdl4jWidgetForCheckBoxT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForDropDownListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForEditableDropDownListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForRadioButtonListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForTextFieldT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForSliderT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForCheckBoxListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForClockT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForSingleSpinnerT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForDoubleSpinnerT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForSingleSelectListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForMultiSelectListT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForHiddenFieldT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForLabelT(); - abstract protected String getDefaultClassNameAtdl4jWidgetForRadioButtonT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForCheckBoxT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForDropDownListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForEditableDropDownListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForRadioButtonListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForTextFieldT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForSliderT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForCheckBoxListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForClockT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForSingleSpinnerT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForDoubleSpinnerT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForSingleSelectListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForMultiSelectListT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForHiddenFieldT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForLabelT(); + protected abstract String getDefaultClassNameAtdl4jWidgetForRadioButtonT(); // -- App Components -- - abstract protected String getDefaultClassNameAtdl4jTesterPanel(); - abstract protected String getDefaultClassNameAtdl4jInputAndFilterDataSelectionPanel(); - abstract protected String getDefaultClassNameAtdl4jInputAndFilterDataPanel(); - abstract protected String getDefaultClassNameAtdl4jCompositePanel(); - abstract protected String getDefaultClassNameAtdl4jUserMessageHandler(); - abstract protected String getDefaultClassNameFixatdlFileSelectionPanel(); - abstract protected String getDefaultClassNameFixMsgLoadPanel(); - abstract protected String getDefaultClassNameStrategySelectionPanel(); - abstract protected String getDefaultClassNameStrategyDescriptionPanel(); + protected abstract String getDefaultClassNameAtdl4jTesterPanel(); + protected abstract String getDefaultClassNameAtdl4jInputAndFilterDataSelectionPanel(); + protected abstract String getDefaultClassNameAtdl4jInputAndFilterDataPanel(); + protected abstract String getDefaultClassNameAtdl4jCompositePanel(); + protected abstract String getDefaultClassNameAtdl4jUserMessageHandler(); + protected abstract String getDefaultClassNameFixatdlFileSelectionPanel(); + protected abstract String getDefaultClassNameFixMsgLoadPanel(); + protected abstract String getDefaultClassNameStrategySelectionPanel(); + protected abstract String getDefaultClassNameStrategyDescriptionPanel(); /** * */ - public AbstractAtdl4jConfiguration() + protected AbstractAtdl4jConfiguration() { // -- UI Infrastructure setClassNameStrategiesUI( getDefaultClassNameStrategiesUI() ); @@ -639,42 +638,6 @@ public String getClassNameAtdl4jCompositePanel() return classNameAtdl4jCompositePanel; } - /* - * Sets Logger's logging level to Level.DEBUG if aDebugLevelFlag is true, otherwise to Level.INFO. - * Sets the logging level for ATDL4J_PACKAGE_NAME_PATH_FOR_DEBUG_LOGGING package/path. - */ - public void setDebugLoggingLevel( boolean aDebugLevelFlag ) - { - Level tempLevel = Level.INFO; - if ( aDebugLevelFlag ) - { - tempLevel = Level.DEBUG; - } - - logger.info( "setDebugLoggingLevel( " + aDebugLevelFlag + " ) invoking org.apache.log4j.Logger.getLogger( " + ATDL4J_PACKAGE_NAME_PATH_FOR_DEBUG_LOGGING + " ).setLevel( " + tempLevel + " )" ); - Logger.getLogger( ATDL4J_PACKAGE_NAME_PATH_FOR_DEBUG_LOGGING ).setLevel( tempLevel ); - // -- explicitly set ourself, too -- - logger.setLevel( tempLevel ); - } - - /* - * Returns true if this class' Logger's logging level is Level.DEBUG or higher, otherwise returns false. - */ - public boolean isDebugLoggingLevel() - { - // -- Use this class' own logger's level as guide -- - Level tempLevel = logger.getLevel(); - - if ( ( tempLevel != null ) && ( Level.DEBUG.isGreaterOrEqual( tempLevel ) ) ) - { - return true; - } - else - { - return false; - } - } - /** * @return the classNameStrategyPanelHelper */ @@ -762,7 +725,7 @@ public void setCatchAllStrategyLoadExceptions(boolean aCatchAllStrategyLoadExcep } /** - * @param aCatchAllStrategyLoadExceptions the catchAllStrategyLoadExceptions to set + * @param aCatchAllValidationExceptions the catchAllStrategyLoadExceptions to set */ public void setCatchAllValidationExceptions(boolean aCatchAllValidationExceptions) { @@ -902,15 +865,14 @@ public Integer getStrategyDropDownItemDepth() private E createClass(String aClassName) { if (aClassName==null) throw new Atdl4jClassLoadException(aClassName); - logger.debug( "Loading class: " + aClassName ); - try { - return ((Class) Class.forName( aClassName ) ).newInstance(); - } catch (InstantiationException e) { + logger.debug( "Loading class: {}", aClassName ); + try + { + return ((Class) Class.forName( aClassName ) ).newInstance(); + } + catch (ClassNotFoundException|IllegalAccessException|InstantiationException e) + { throw new Atdl4jClassLoadException(aClassName, e); - } catch (IllegalAccessException e) { - throw new Atdl4jClassLoadException(aClassName, e); - } catch (ClassNotFoundException e) { - throw new Atdl4jClassLoadException(aClassName, e); } } diff --git a/src/main/java/org/atdl4j/config/Atdl4jConfiguration.java b/src/main/java/org/atdl4j/config/Atdl4jConfiguration.java index e4ad847..fbc5de2 100644 --- a/src/main/java/org/atdl4j/config/Atdl4jConfiguration.java +++ b/src/main/java/org/atdl4j/config/Atdl4jConfiguration.java @@ -29,9 +29,6 @@ */ public interface Atdl4jConfiguration { - public void setDebugLoggingLevel( boolean aDebugLevelFlag ); - public boolean isDebugLoggingLevel(); - public String getClassNameAtdl4jWidgetForCheckBoxListT(); public String getClassNameAtdl4jWidgetForCheckBoxT(); public String getClassNameAtdl4jWidgetForClockT(); @@ -63,7 +60,7 @@ public interface Atdl4jConfiguration public String getClassNameTypeConverterFactory(); public boolean isCatchAllMainlineExceptions(); - public boolean isCatchAllRuntimeExceptions();; + public boolean isCatchAllRuntimeExceptions(); public boolean isCatchAllStrategyLoadExceptions(); public boolean isCatchAllValidationExceptions(); public boolean isThrowEventRuntimeExceptions(); diff --git a/src/main/java/org/atdl4j/config/Atdl4jOptions.java b/src/main/java/org/atdl4j/config/Atdl4jOptions.java index b7a7057..4f52a88 100644 --- a/src/main/java/org/atdl4j/config/Atdl4jOptions.java +++ b/src/main/java/org/atdl4j/config/Atdl4jOptions.java @@ -8,13 +8,14 @@ import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.core.PercentageT; import org.atdl4j.fixatdl.core.QtyT; import org.atdl4j.fixatdl.core.StrategyT; import org.atdl4j.fixatdl.layout.ClockT; import org.atdl4j.fixatdl.layout.ControlT; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class contains the data associated with the Atdl4jOptions. @@ -25,7 +26,7 @@ */ public class Atdl4jOptions { - private final Logger logger = Logger.getLogger(Atdl4jOptions.class); + private final Logger logger = LoggerFactory.getLogger(Atdl4jOptions.class); private InputAndFilterData inputAndFilterData; @@ -41,14 +42,17 @@ public class Atdl4jOptions private int defaultDigitsForSpinnerControlForQty = 0; private int defaultDigitsForSpinnerControl = 2; + public static final BigDecimal SYSTEM_DEFAULT_LOT_SIZE_INCREMENT_VALUE = new BigDecimal( "1.0" ); + public static final BigDecimal SYSTEM_DEFAULT_TICK_INCREMENT_VALUE = new BigDecimal( "0.0001" ); + private BigDecimal defaultIncrementValue = null; - private BigDecimal defaultLotSizeIncrementValue = new BigDecimal( "1.0" ); - private BigDecimal defaultTickIncrementValue = new BigDecimal( "0.0001" ); + private BigDecimal defaultLotSizeIncrementValue = SYSTEM_DEFAULT_LOT_SIZE_INCREMENT_VALUE; + private BigDecimal defaultTickIncrementValue = SYSTEM_DEFAULT_TICK_INCREMENT_VALUE; // -- Controls Clock control's behavior when FIX message timestamp (eg "StartTime" or "EffectiveTime") is older than current time -- - public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS = new Integer( 0 ); - public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT = new Integer( 1 ); - public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL = new Integer( 2 ); + public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS = Integer.valueOf( 0 ); + public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT = Integer.valueOf( 1 ); + public static final Integer CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL = Integer.valueOf( 2 ); // -- Controls Clock control's behavior when FIX message timestamp (eg "StartTime" or "EffectiveTime") is older than current time -- @@ -238,9 +242,9 @@ public List getStrategyListUsingInputStrategyNameListFilter( List 0 ) ) + ( !getInputAndFilterData().getInputStrategyNameList().isEmpty() ) ) { - List tempAvailableStrategyList = new ArrayList(); + List tempAvailableStrategyList = new ArrayList<>(); // -- Add the strategies according to their order in the specified InputStrategyNameList -- for ( String tempStrategyName : getInputAndFilterData().getInputStrategyNameList() ) @@ -267,7 +271,7 @@ public List getStrategyListUsingInputStrategyNameListFilter( List strategyFilterInputDataList = null; // -- Use more than one when multiple individual orders are associated with a single algo panel display -- - public static String INPUT_FIELD_NAME_INCREMENT_POLICY_LotSize = "FIX_FIXatdl_LotSize"; - public static String INPUT_FIELD_NAME_INCREMENT_POLICY_Tick = "FIX_FIXatdl_Tick"; + public static final String INPUT_FIELD_NAME_INCREMENT_POLICY_LOT_SIZE = "FIX_FIXatdl_LotSize"; + public static final String INPUT_FIELD_NAME_INCREMENT_POLICY_TICK = "FIX_FIXatdl_Tick"; private boolean inputCxlReplaceMode = false; @@ -135,7 +135,7 @@ public void addMapToInputHiddenFieldNameValueMap( Map aMap ) { if ( getInputHiddenFieldNameValueMap() == null ) { - setInputHiddenFieldNameValueMap( new HashMap() ); + setInputHiddenFieldNameValueMap( new HashMap<>() ); } getInputHiddenFieldNameValueMap().putAll( aMap ); @@ -146,7 +146,7 @@ public void addMapToInputHiddenFieldNameValueMap( Map aMap ) * Checks applicability of aStrategy against each StrategyFilterInputData within getStrategyFilterInputDataList(). * Returns true only if aStrategy meets criteria for all (least common denominator). * - * @param strategy + * @param aStrategy * @return */ public boolean isStrategySupported(StrategyT aStrategy) @@ -160,7 +160,7 @@ public boolean isStrategySupported(StrategyT aStrategy) { for ( StrategyFilterInputData tempStrategyFilterInputData : getStrategyFilterInputDataList() ) { - if ( tempStrategyFilterInputData.isStrategySupported( aStrategy ) == false ) + if (!tempStrategyFilterInputData.isStrategySupported(aStrategy)) { return false; } @@ -179,7 +179,7 @@ public void setInputHiddenFieldNameValuePair( String aFieldName, String aFieldVa { if ( getInputHiddenFieldNameValueMap() == null ) { - setInputHiddenFieldNameValueMap( new HashMap() ); + setInputHiddenFieldNameValueMap( new HashMap<>() ); } if ( aFieldValue != null ) @@ -202,7 +202,7 @@ public void setInputStandardFixFieldNameValuePair( String aFieldName, String aFi { if ( getInputHiddenFieldNameValueMap() == null ) { - setInputHiddenFieldNameValueMap( new HashMap() ); + setInputHiddenFieldNameValueMap( new HashMap<>() ); } getInputHiddenFieldNameValueMap().put( (FIX_DEFINED_FIELD_PREFIX + aFieldName), aFieldValue ); @@ -210,9 +210,9 @@ public void setInputStandardFixFieldNameValuePair( String aFieldName, String aFi /** */ - public BigDecimal getInputIncrementPolicy_LotSize() + public BigDecimal getInputIncrementPolicyLotSize() { - String tempValue = getInputHiddenFieldValue( INPUT_FIELD_NAME_INCREMENT_POLICY_LotSize ); + String tempValue = getInputHiddenFieldValue( INPUT_FIELD_NAME_INCREMENT_POLICY_LOT_SIZE ); if ( tempValue != null ) { return new BigDecimal( tempValue ); @@ -225,9 +225,9 @@ public BigDecimal getInputIncrementPolicy_LotSize() /** */ - public BigDecimal getInputIncrementPolicy_Tick() + public BigDecimal getInputIncrementPolicyTick() { - String tempValue = getInputHiddenFieldValue( INPUT_FIELD_NAME_INCREMENT_POLICY_Tick ); + String tempValue = getInputHiddenFieldValue( INPUT_FIELD_NAME_INCREMENT_POLICY_TICK ); if ( tempValue != null ) { return new BigDecimal( tempValue ); @@ -240,29 +240,29 @@ public BigDecimal getInputIncrementPolicy_Tick() /** */ - public void setInputIncrementPolicy_LotSize( BigDecimal aLotSize ) + public void setInputIncrementPolicyLotSize( BigDecimal aLotSize ) { if ( aLotSize != null ) { - setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_LotSize, aLotSize.toString() ); + setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_LOT_SIZE, aLotSize.toString() ); } else { - setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_LotSize, null); + setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_LOT_SIZE, null); } } /** */ - public void setInputIncrementPolicy_Tick( BigDecimal aTick ) + public void setInputIncrementPolicyTick( BigDecimal aTick ) { if ( aTick != null ) { - setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_Tick, aTick.toString() ); + setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_TICK, aTick.toString() ); } else { - setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_Tick, null ); + setInputHiddenFieldNameValuePair( INPUT_FIELD_NAME_INCREMENT_POLICY_TICK, null ); } } @@ -329,7 +329,7 @@ public void setStrategyFilterInputData(StrategyFilterInputData aStrategyFilterIn { if ( aStrategyFilterInputData != null ) { - List tempList = new ArrayList(); + List tempList = new ArrayList<>(); tempList.add( aStrategyFilterInputData ); setStrategyFilterInputDataList( tempList ); } diff --git a/src/main/java/org/atdl4j/config/StrategyFilterInputData.java b/src/main/java/org/atdl4j/config/StrategyFilterInputData.java index 7f0b694..b7af907 100644 --- a/src/main/java/org/atdl4j/config/StrategyFilterInputData.java +++ b/src/main/java/org/atdl4j/config/StrategyFilterInputData.java @@ -1,10 +1,11 @@ package org.atdl4j.config; -import org.apache.log4j.Logger; import org.atdl4j.fixatdl.core.InclusionT; import org.atdl4j.fixatdl.core.MarketT; import org.atdl4j.fixatdl.core.RegionT; import org.atdl4j.fixatdl.core.StrategyT; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.fixatdl.core.SecurityTypesT.SecurityType; /** @@ -16,7 +17,7 @@ */ public class StrategyFilterInputData { - private static final Logger logger = Logger.getLogger(StrategyFilterInputData.class); + private static final Logger logger = LoggerFactory.getLogger(StrategyFilterInputData.class); private String fixMsgType; // @see Strategy/@fixMsgType private String region_name; // @see Strategy/Regions/Region/@name @@ -56,13 +57,13 @@ public boolean isFixMsgTypeSupportedForStrategy(String aFixMsgType, StrategyT aS } } /** - * @param aMarket_MICCode Market's MICCode attribute + * @param aMarketMICCode Market's MICCode attribute * @param aStrategy * @return */ - public boolean isMarketSupportedForStrategy(String aMarket_MICCode, StrategyT aStrategy) + public boolean isMarketSupportedForStrategy(String aMarketMICCode, StrategyT aStrategy) { - if ( ( aMarket_MICCode != null ) && + if ( ( aMarketMICCode != null ) && ( aStrategy.getMarkets() != null ) && ( aStrategy.getMarkets().getMarket() != null ) ) { @@ -74,9 +75,9 @@ public boolean isMarketSupportedForStrategy(String aMarket_MICCode, StrategyT aS if ( InclusionT.EXCLUDE.equals( tempMarket.getInclusion() ) ) { tempExcludesExist = true; - if ( aMarket_MICCode.equals( tempMarket.getMICCode() ) ) + if ( aMarketMICCode.equals( tempMarket.getMICCode() ) ) { - logger.info("isMarketSupportedForStrategy(): strategy: " + aStrategy.getName() + " named exclusion for Market_CFICode: " + aMarket_MICCode ); + logger.info("isMarketSupportedForStrategy(): strategy: {} named exclusion for Market_MICCode: {}", aStrategy.getName(), aMarketMICCode ); return false; // -- named exclusion -- } } @@ -90,15 +91,15 @@ public boolean isMarketSupportedForStrategy(String aMarket_MICCode, StrategyT aS { tempIncludesExist = true; - if ( aMarket_MICCode.equals( tempMarket.getMICCode() ) ) + if ( aMarketMICCode.equals( tempMarket.getMICCode() ) ) { - logger.info("isMarketSupportedForStrategy(): strategy: " + aStrategy.getName() + " named inclusion for Market_MICCode: " + aMarket_MICCode ); + logger.info("isMarketSupportedForStrategy(): strategy: {} named inclusion for Market_MICCode: {}", aStrategy.getName(), aMarketMICCode ); return true; // -- named inclusion -- } } } - if ( ( tempExcludesExist == false ) && + if ( (!tempExcludesExist) && ( tempIncludesExist ) ) { return false; // -- only inclusions exist and matching inclusion was not found above -- @@ -112,20 +113,20 @@ public boolean isMarketSupportedForStrategy(String aMarket_MICCode, StrategyT aS return true; } /** - * @param aRegion_name Region's name attribute - * @param aCountry_CountryCode Country's countryCode attribute + * @param aRegionName Region's name attribute + * @param aCountryCountryCode Country's countryCode attribute * @param aStrategy * @return */ - public boolean isRegionCountrySupportedForStrategy(String aRegion_name, String aCountry_CountryCode, StrategyT aStrategy) + public boolean isRegionCountrySupportedForStrategy(String aRegionName, String aCountryCountryCode, StrategyT aStrategy) { - if ( ( aCountry_CountryCode != null ) && ( aRegion_name == null ) ) + if ( ( aCountryCountryCode != null ) && ( aRegionName == null ) ) { - logger.warn( "ERROR: isRegionCountrySupportedForStrategy() received CountryCode: " + aCountry_CountryCode + ", however, Region was not specified." ); + logger.warn( "ERROR: isRegionCountrySupportedForStrategy() received CountryCode: {}, however, Region was not specified.", aCountryCountryCode ); return true; } - if ( ( aRegion_name != null ) && + if ( ( aRegionName != null ) && ( aStrategy.getRegions() != null ) && ( aStrategy.getRegions().getRegion() != null ) ) { @@ -137,24 +138,24 @@ public boolean isRegionCountrySupportedForStrategy(String aRegion_name, String a if ( InclusionT.EXCLUDE.equals( tempRegion.getInclusion() ) ) { tempExcludesExist = true; - if ( aRegion_name.equals( tempRegion.getName() ) ) + if ( aRegionName.equals( tempRegion.getName() ) ) { // -- Verify that the Country is not in the named Inclusion list for this Region -- - if ( ( aCountry_CountryCode != null ) && + if ( ( aCountryCountryCode != null ) && ( tempRegion.getCountry() != null ) ) { for ( RegionT.Country tempCountry : tempRegion.getCountry() ) { if ( ( InclusionT.INCLUDE.equals( tempCountry.getInclusion() ) ) && - ( aCountry_CountryCode.equals( tempCountry.getCountryCode() ) ) ) + ( aCountryCountryCode.equals( tempCountry.getCountryCode() ) ) ) { - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " named inclusion for Country_CountryCode: " + aCountry_CountryCode + " despite Region_name: " + aRegion_name + " being excluded" ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} named inclusion for Country_CountryCode: {} despite Region_name: {} being excluded", aStrategy.getName(), aCountryCountryCode, aRegionName ); return true; // Country Inclusion Exists } } } - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " named exclusion for Region_name: " + aRegion_name ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} named exclusion for Region_name: {}", aStrategy.getName(), aRegionName ); return false; // -- named exclusion for Region -- } } @@ -167,28 +168,28 @@ public boolean isRegionCountrySupportedForStrategy(String aRegion_name, String a if ( InclusionT.INCLUDE.equals( tempRegion.getInclusion() ) ) { tempIncludesExist = true; - if ( aRegion_name.equals( tempRegion.getName() ) ) + if ( aRegionName.equals( tempRegion.getName() ) ) { boolean tempCountryInclusionsForARegionInclusionExist = false; // -- Verify that the Country is not in the named Exclusion list for this Region -- - if ( ( aCountry_CountryCode != null ) && + if ( ( aCountryCountryCode != null ) && ( tempRegion.getCountry() != null ) ) { for ( RegionT.Country tempCountry : tempRegion.getCountry() ) { if ( ( InclusionT.EXCLUDE.equals( tempCountry.getInclusion() ) ) && - ( aCountry_CountryCode.equals( tempCountry.getCountryCode() ) ) ) + ( aCountryCountryCode.equals( tempCountry.getCountryCode() ) ) ) { - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " named exclusion for Country_CountryCode: " + aCountry_CountryCode + " despite Region_name: " + aRegion_name + " being included" ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} named exclusion for Country_CountryCode: {} despite Region_name: {} being included", aStrategy.getName(), aCountryCountryCode, aRegionName ); return false; // Country Exclusion Exists } else if ( InclusionT.INCLUDE.equals( tempCountry.getInclusion() ) ) { tempCountryInclusionsForARegionInclusionExist = true; - if ( aCountry_CountryCode.equals( tempCountry.getCountryCode() ) ) + if ( aCountryCountryCode.equals( tempCountry.getCountryCode() ) ) { - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " named inclusion for Country_CountryCode: " + aCountry_CountryCode + " for included Region_name: " + aRegion_name ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} named inclusion for Country_CountryCode: {} for included Region_name: {}", aStrategy.getName(), aCountryCountryCode, aRegionName ); return true; // Country named as Inclusion } } @@ -197,19 +198,19 @@ else if ( InclusionT.INCLUDE.equals( tempCountry.getInclusion() ) ) if ( tempCountryInclusionsForARegionInclusionExist ) { - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " Country_CountryCode: " + aCountry_CountryCode + " was not part of included Countries for named inclusion for Region_name: " + aRegion_name ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} Country_CountryCode: {} was not part of included Countries for named inclusion for Region_name: {}", aStrategy.getName(), aCountryCountryCode, aRegionName ); return false; // -- Country not named as inclusion for included Region -- } else { - logger.info("isRegionCountrySupportedForStrategy(): strategy: " + aStrategy.getName() + " named inclusion for Region_name: " + aRegion_name ); + logger.info("isRegionCountrySupportedForStrategy(): strategy: {} named inclusion for Region_name: {}", aStrategy.getName(), aRegionName ); return true; // -- named inclusion for Region -- } } } } - if ( ( tempExcludesExist == false ) && + if ( (!tempExcludesExist) && ( tempIncludesExist ) ) { return false; // -- only inclusions exist and matching inclusion was not found above -- @@ -223,13 +224,13 @@ else if ( InclusionT.INCLUDE.equals( tempCountry.getInclusion() ) ) return true; } /** - * @param aSecurityType_name SecurityType's name attribute + * @param aSecurityTypeName SecurityType's name attribute * @param aStrategy * @return */ - public boolean isSecurityTypeSupportedForStrategy(String aSecurityType_name, StrategyT aStrategy) + public boolean isSecurityTypeSupportedForStrategy(String aSecurityTypeName, StrategyT aStrategy) { - if ( ( aSecurityType_name != null ) && + if ( ( aSecurityTypeName != null ) && ( aStrategy.getSecurityTypes() != null ) && ( aStrategy.getSecurityTypes().getSecurityType() != null ) ) { @@ -241,9 +242,9 @@ public boolean isSecurityTypeSupportedForStrategy(String aSecurityType_name, Str if ( InclusionT.EXCLUDE.equals( tempSecurityType.getInclusion() ) ) { tempExcludesExist = true; - if ( aSecurityType_name.equals( tempSecurityType.getName() ) ) + if ( aSecurityTypeName.equals( tempSecurityType.getName() ) ) { - logger.info("isSecurityTypeSupportedForStrategy(): strategy: " + aStrategy.getName() + " named exclusion for SecurityType_name: " + aSecurityType_name ); + logger.info("isSecurityTypeSupportedForStrategy(): strategy: {} named exclusion for SecurityType_name: {}", aStrategy.getName(), aSecurityTypeName ); return false; // -- named exclusion -- } } @@ -257,15 +258,15 @@ public boolean isSecurityTypeSupportedForStrategy(String aSecurityType_name, Str { tempIncludesExist = true; - if ( aSecurityType_name.equals( tempSecurityType.getName() ) ) + if ( aSecurityTypeName.equals( tempSecurityType.getName() ) ) { - logger.info("isSecurityTypeSupportedForStrategy(): strategy: " + aStrategy.getName() + " named inclusion for SecurityType_name: " + aSecurityType_name ); + logger.info("isSecurityTypeSupportedForStrategy(): strategy: {} named inclusion for SecurityType_name: {}", aStrategy.getName(), aSecurityTypeName ); return true; // -- named inclusion -- } } } - if ( ( tempExcludesExist == false ) && + if ( (!tempExcludesExist) && ( tempIncludesExist ) ) { return false; // -- only inclusions exist and matching inclusion was not found above -- @@ -281,7 +282,7 @@ public boolean isSecurityTypeSupportedForStrategy(String aSecurityType_name, Str /** - * @param strategy + * @param aStrategy * @return */ public boolean isStrategySupported(StrategyT aStrategy) @@ -292,32 +293,32 @@ public boolean isStrategySupported(StrategyT aStrategy) } String tempFixMsgType = getFixMsgType(); - String tempSecurityType_name = getSecurityType_name(); - String tempMarket_MICCode = getMarket_MICCode(); - String tempRegion_name = getRegion_name(); - String tempCountry_CountryCode = getCountry_CountryCode(); + String tmpSecurityTypeName = getSecurityType_name(); + String tmpMarketMicCode = getMarket_MICCode(); + String tmpRegionName = getRegion_name(); + String tmpCountryCode = getCountry_CountryCode(); - if ( isFixMsgTypeSupportedForStrategy( tempFixMsgType, aStrategy ) == false ) + if (!isFixMsgTypeSupportedForStrategy(tempFixMsgType, aStrategy)) { - logger.info("Excluding strategy: " + aStrategy.getName() + " as isFixMsgTypeSupportedForStrategy() returned false for tempFixMsgType: " + tempFixMsgType ); + logger.info("Excluding strategy: {} as isFixMsgTypeSupportedForStrategy() returned false for tempFixMsgType: {}", aStrategy.getName(), tempFixMsgType ); return false; } - if ( isSecurityTypeSupportedForStrategy( tempSecurityType_name, aStrategy ) == false ) + if (!isSecurityTypeSupportedForStrategy(tmpSecurityTypeName, aStrategy)) { - logger.info("Excluding strategy: " + aStrategy.getName() + " as isSecurityTypeSupportedForStrategy() returned false for tempSecurityType_name: " + tempSecurityType_name ); + logger.info("Excluding strategy: {} as isSecurityTypeSupportedForStrategy() returned false for tempSecurityType_name: {}", aStrategy.getName(), tmpSecurityTypeName ); return false; } - if ( isMarketSupportedForStrategy( tempMarket_MICCode, aStrategy ) == false ) + if (!isMarketSupportedForStrategy(tmpMarketMicCode, aStrategy)) { - logger.info("Excluding strategy: " + aStrategy.getName() + " as isMarketSupportedForStrategy() returned false for tempMarket_MICCode: " + tempMarket_MICCode ); + logger.info("Excluding strategy: {} as isMarketSupportedForStrategy() returned false for tempMarket_MICCode: {}", aStrategy.getName(), tmpMarketMicCode ); return false; } - if ( isRegionCountrySupportedForStrategy( tempRegion_name, tempCountry_CountryCode, aStrategy ) == false ) + if (!isRegionCountrySupportedForStrategy(tmpRegionName, tmpCountryCode, aStrategy)) { - logger.info("Excluding strategy: " + aStrategy.getName() + " as isRegionCountrySupportedForStrategy() returned false for tempRegion: " + tempRegion_name + " tempCountry_CountryCode: " + tempCountry_CountryCode ); + logger.info("Excluding strategy: {} as isRegionCountrySupportedForStrategy() returned false for tempRegion: {} tempCountry_CountryCode: {}", aStrategy.getName(), tmpRegionName, tmpCountryCode ); return false; } diff --git a/src/main/java/org/atdl4j/data/Atdl4jConstants.java b/src/main/java/org/atdl4j/data/Atdl4jConstants.java index 6797e5a..a5247df 100644 --- a/src/main/java/org/atdl4j/data/Atdl4jConstants.java +++ b/src/main/java/org/atdl4j/data/Atdl4jConstants.java @@ -61,5 +61,5 @@ public class Atdl4jConstants STRATEGY_FILTER_SECURITY_TYPE_ForexSpot, STRATEGY_FILTER_SECURITY_TYPE_ForexForward }; // @see Strategy/@securityType - public static String PATTERN_STRATEGY_NAME = "[A-Za-z][A-za-z0-9_]{0,255}"; + public static String PATTERN_STRATEGY_NAME = "[A-Za-z][A-Za-z0-9_]{0,255}"; } diff --git a/src/main/java/org/atdl4j/data/ControlTypeConverter.java b/src/main/java/org/atdl4j/data/ControlTypeConverter.java index a2d628b..a4de0a9 100644 --- a/src/main/java/org/atdl4j/data/ControlTypeConverter.java +++ b/src/main/java/org/atdl4j/data/ControlTypeConverter.java @@ -13,13 +13,13 @@ public interface ControlTypeConverter> { /** * Converts Control's value to Parameter value. - * -Used by: - - SWTClockWidget.getParameterValue() - - AbstractHiddenFieldWidget.getParameterValue() - - SWTSpinnerWidget.getParameterValue() - - SWTTextFieldWidget.getParameterValue() - + * + * Used by: + * - SWTClockWidget.getParameterValue() + * - AbstractHiddenFieldWidget.getParameterValue() + * - SWTSpinnerWidget.getParameterValue() + * - SWTTextFieldWidget.getParameterValue() + * * @param value * @return */ @@ -28,29 +28,28 @@ public interface ControlTypeConverter> /** * Converts Parameter value to Control value - * -Used by: - - AbstractAtdl4jWidget.applyConstValue() - - AbstractAtdl4jWidget.setFIXValue() - - AbstractStrategyUI.setFIXMessage() - + * + * Used by: + * - AbstractAtdl4jWidget.applyConstValue() + * - AbstractAtdl4jWidget.setFIXValue() + * - AbstractStrategyUI.setFIXMessage() + * * @param value * @param aControl * @return */ -// 7/11/2010 Scott Atwell need to handle CheckBox control checkedEnumRef and uncheckedEnumRef (eg "100" -> true, "0" -> false) public E convertParameterValueToControlValue(Object value); public E convertParameterValueToControlValue(Object value, ControlT aControl); /** * Converts Control's value to Comparable for Control - * -Used by: - - AbstractAtdl4jWidget.convertStringToControlComparable() - - ValueOperatorValidationRule.validate() - - AbstractAtdl4jWidget.getControlValueAsComparable() - - ValueOperatorValidationRule.validate() - + * + * Used by: + * - AbstractAtdl4jWidget.convertStringToControlComparable() + * - ValueOperatorValidationRule.validate() + * - AbstractAtdl4jWidget.getControlValueAsComparable() + * - ValueOperatorValidationRule.validate() + * * @param value * @return */ @@ -59,13 +58,13 @@ public interface ControlTypeConverter> /** * Converts aString (eg Control/@initValue or StateRule/@value) to Control value - * -Used by: - - AbstractAtdl4jWidget.convertStringToControlComparable() - - ValueOperatorValidationRule.validate() - - AbstractAtdl4jWidget.setValueAsString(String) - - SWTStateListener.setBehaviorAsStateRule() - + * + * Used by: + * - AbstractAtdl4jWidget.convertStringToControlComparable() + * - ValueOperatorValidationRule.validate() + * - AbstractAtdl4jWidget.setValueAsString(String) + * - SWTStateListener.setBehaviorAsStateRule() + * * @param aString * @return */ @@ -79,7 +78,7 @@ public interface ControlTypeConverter> /** * Returns an Object that is an instanceof the Parameter's base data type (eg String, BigDecimal, DateTime, etc) * Returns aDatatypeIfNull if Parameter is null - * @param aDatatypeIfNull + * @param aClassIfNull * @return */ public Class getParameterDatatype( Class aClassIfNull ); diff --git a/src/main/java/org/atdl4j/data/ParameterHelper.java b/src/main/java/org/atdl4j/data/ParameterHelper.java index cd8b373..7227768 100644 --- a/src/main/java/org/atdl4j/data/ParameterHelper.java +++ b/src/main/java/org/atdl4j/data/ParameterHelper.java @@ -114,10 +114,7 @@ else if ( parameter instanceof MonthYearT ) } else if ( parameter instanceof UTCTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getConstValue(), getLocalMktTz( parameter) ); - } + return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getConstValue(), getLocalMktTz( parameter) ); } else if ( parameter instanceof UTCTimeOnlyT ) { @@ -153,10 +150,7 @@ else if ( parameter instanceof TZTimeOnlyT ) } else if ( parameter instanceof TZTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getConstValue(), null ); - } + return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getConstValue(), null ); } else if ( parameter instanceof TenorT ) { @@ -242,10 +236,7 @@ else if ( parameter instanceof MonthYearT ) } else if ( parameter instanceof UTCTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getMaxValue(), getLocalMktTz( parameter) ); - } + return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getMaxValue(), getLocalMktTz( parameter) ); } else if ( parameter instanceof UTCTimeOnlyT ) { @@ -281,10 +272,7 @@ else if ( parameter instanceof TZTimeOnlyT ) } else if ( parameter instanceof TZTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getMaxValue(), null ); - } + return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getMaxValue(), null ); } else if ( parameter instanceof TenorT ) { @@ -371,10 +359,7 @@ else if ( parameter instanceof MonthYearT ) } else if ( parameter instanceof UTCTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getMinValue(), getLocalMktTz( parameter) ); - } + return DateTimeConverter.convertDailyValueToValue( ( (UTCTimestampT) parameter ).getMinValue(), getLocalMktTz( parameter) ); } else if ( parameter instanceof UTCTimeOnlyT ) { @@ -410,10 +395,7 @@ else if ( parameter instanceof TZTimeOnlyT ) } else if ( parameter instanceof TZTimestampT ) { - if ( parameter != null ) - { - return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getMinValue(), null ); - } + return DateTimeConverter.convertDailyValueToValue( ( (TZTimestampT) parameter ).getMinValue(), null ); } else if ( parameter instanceof TenorT ) { diff --git a/src/main/java/org/atdl4j/data/ParameterTypeConverter.java b/src/main/java/org/atdl4j/data/ParameterTypeConverter.java index 02a942c..64befbd 100644 --- a/src/main/java/org/atdl4j/data/ParameterTypeConverter.java +++ b/src/main/java/org/atdl4j/data/ParameterTypeConverter.java @@ -27,7 +27,7 @@ public interface ParameterTypeConverter> * Used by: AbstractAtdl4jWidget.setFIXValue() - * @param aFixValue + * @param aFixWireValue * @return */ public Object convertFixWireValueToParameterValue(String aFixWireValue); diff --git a/src/main/java/org/atdl4j/data/StrategyRuleset.java b/src/main/java/org/atdl4j/data/StrategyRuleset.java index 36b6cd2..157f7b0 100644 --- a/src/main/java/org/atdl4j/data/StrategyRuleset.java +++ b/src/main/java/org/atdl4j/data/StrategyRuleset.java @@ -50,12 +50,12 @@ public void addPatternRule(ValidationRule editUI) public StrategyRuleset() { - this.refRules = new HashMap(); - this.requiredFieldRules = new ArrayList(); - this.constFieldRules = new ArrayList(); - this.rangeFieldRules = new ArrayList(); - this.lengthFieldRules = new ArrayList(); - this.patternRules = new ArrayList(); + this.refRules = new HashMap<>(); + this.requiredFieldRules = new ArrayList<>(); + this.constFieldRules = new ArrayList<>(); + this.rangeFieldRules = new ArrayList<>(); + this.lengthFieldRules = new ArrayList<>(); + this.patternRules = new ArrayList<>(); } public void putRefRule(StrategyEditT strategyEdit, ValidationRule rule) @@ -159,17 +159,17 @@ protected ValidationException buildValidationException( ValidationException aOri protected String buildValidationExceptionText( ValidationException aOriginalValidationException, String aMsgText, Atdl4jWidget aAtdl4jWidget ) { - StringBuffer tempStringBuffer = new StringBuffer(); - - tempStringBuffer.append( "Parameter \"" + aAtdl4jWidget.getParameter().getName() + "\"" ); - tempStringBuffer.append( " (\"" + ControlHelper.getLabelOrID( aAtdl4jWidget.getControl() ) + "\") " ); - tempStringBuffer.append( aMsgText ); + StringBuilder tmpStringBuilder = new StringBuilder(); + + tmpStringBuilder.append("Parameter \"").append(aAtdl4jWidget.getParameter().getName()).append("\""); + tmpStringBuilder.append(" (\"").append(ControlHelper.getLabelOrID(aAtdl4jWidget.getControl())).append("\") "); + tmpStringBuilder.append( aMsgText ); if ( aOriginalValidationException.getMessage() != null ) - { - tempStringBuffer.append( " " + aOriginalValidationException.getMessage() ); + { + tmpStringBuilder.append(" ").append(aOriginalValidationException.getMessage()); } - return tempStringBuffer.toString(); + return tmpStringBuilder.toString(); } } diff --git a/src/main/java/org/atdl4j/data/TypeConverterFactory.java b/src/main/java/org/atdl4j/data/TypeConverterFactory.java index d37e90f..d8717c2 100644 --- a/src/main/java/org/atdl4j/data/TypeConverterFactory.java +++ b/src/main/java/org/atdl4j/data/TypeConverterFactory.java @@ -47,16 +47,6 @@ import org.atdl4j.fixatdl.layout.SliderT; import org.atdl4j.fixatdl.layout.TextFieldT; -/* - * NumericT subclasses - import org.atdl4j.fixatdl.core.AmtT; - import org.atdl4j.fixatdl.core.FloatT; - import org.atdl4j.fixatdl.core.PercentageT; - import org.atdl4j.fixatdl.core.PriceT; - import org.atdl4j.fixatdl.core.PriceOffsetT; - import org.atdl4j.fixatdl.core.QtyT; - */ - /** * Factory that creates the appropriate ParameterTypeConveter depending on the parameter * or creates the appropriate ControlTypeConveter depending upon the control type. diff --git a/src/main/java/org/atdl4j/data/TypeConverterFactoryConfig.java b/src/main/java/org/atdl4j/data/TypeConverterFactoryConfig.java index 4b6d094..fefc388 100644 --- a/src/main/java/org/atdl4j/data/TypeConverterFactoryConfig.java +++ b/src/main/java/org/atdl4j/data/TypeConverterFactoryConfig.java @@ -1,7 +1,8 @@ package org.atdl4j.data; -import org.apache.log4j.Logger; import org.atdl4j.config.Atdl4jConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -12,12 +13,11 @@ */ public class TypeConverterFactoryConfig { - protected static final Logger logger = Logger.getLogger( TypeConverterFactoryConfig.class ); + protected static final Logger logger = LoggerFactory.getLogger( TypeConverterFactoryConfig.class ); private static TypeConverterFactory typeConverterFactory; /** * @return - * @throws Atdl4jClassLoadException */ public static TypeConverterFactory getTypeConverterFactory() { diff --git a/src/main/java/org/atdl4j/data/ValidationRule.java b/src/main/java/org/atdl4j/data/ValidationRule.java index 58dd5f1..3714c9f 100644 --- a/src/main/java/org/atdl4j/data/ValidationRule.java +++ b/src/main/java/org/atdl4j/data/ValidationRule.java @@ -17,7 +17,8 @@ public interface ValidationRule { * Called by the application to validate the user input. Throws a * ValidationException if input is not valid according to the rules. * - * @param rules + * @param refRules + * @param targets * @throws ValidationException */ public void validate(Map refRules, Map> targets) diff --git a/src/main/java/org/atdl4j/data/converter/AbstractTypeConverter.java b/src/main/java/org/atdl4j/data/converter/AbstractTypeConverter.java index d4995df..de3422d 100644 --- a/src/main/java/org/atdl4j/data/converter/AbstractTypeConverter.java +++ b/src/main/java/org/atdl4j/data/converter/AbstractTypeConverter.java @@ -1,16 +1,16 @@ package org.atdl4j.data.converter; -import org.apache.log4j.Logger; import org.atdl4j.data.ControlTypeConverter; import org.atdl4j.data.ParameterHelper; import org.atdl4j.data.ParameterTypeConverter; -import org.atdl4j.data.TypeConverterFactory; import org.atdl4j.data.TypeConverterFactoryConfig; import org.atdl4j.fixatdl.core.EnumPairT; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.core.PercentageT; import org.atdl4j.fixatdl.layout.CheckBoxT; import org.atdl4j.fixatdl.layout.ControlT; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base class for ParameterTypeConverter and ControlTypeConverter interfaces @@ -22,7 +22,7 @@ public abstract class AbstractTypeConverter> { private ParameterT parameter; // used by ParameterTypeConverter private ParameterTypeConverter parameterTypeConverter; // used by ControlTypeConverter - private static final Logger logger = Logger.getLogger(ParameterTypeConverter.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractTypeConverter.class); /** @@ -175,7 +175,7 @@ public Class getParameterDatatype() if ( ( tempParameter == null ) && ( getParameterTypeConverter() != null ) ) { - tempParameter = getParameterTypeConverter().getParameter();; + tempParameter = getParameterTypeConverter().getParameter(); } if ( tempParameter != null ) @@ -200,34 +200,30 @@ public E convertParameterValueToControlValue(Object aValue, ControlT aControl) } public abstract E convertParameterValueToControlValue(Object aValue); - - public Object adjustParameterValueForEnumRefValue( Object aParameterValue, ParameterT aParameter, ControlT aControl ) { - logger.debug("aParameterValue: " + aParameterValue + " aParameter: " + aParameter + " aControl: " + aControl ); - if ( ( aParameterValue != null ) && ( aParameter != null ) && ( aControl != null ) ) + logger.debug("aParameterValue: {} aParameter: {} aControl: {}", aParameterValue, aParameter, aControl ); + if ( ( ( aParameterValue != null ) && ( aParameter != null ) && ( aControl != null ) ) + && ( aControl instanceof CheckBoxT ) ) { - if ( aControl instanceof CheckBoxT ) + CheckBoxT tempCheckBox = (CheckBoxT) aControl; + + EnumPairT tempCheckedEnumPair = ParameterHelper.getEnumPairForEnumID( aParameter, tempCheckBox.getCheckedEnumRef() ); + EnumPairT tempUncheckedEnumPair = ParameterHelper.getEnumPairForEnumID( aParameter, tempCheckBox.getUncheckedEnumRef() ); + String tempParameterValueString = aParameterValue.toString(); + logger.debug("tempParameterValueString: {} tempCheckedEnumPair: {} tempUncheckedEnumPair: {}", tempParameterValueString, tempCheckedEnumPair, tempUncheckedEnumPair ); + + if ( ( tempCheckedEnumPair != null ) && ( tempParameterValueString.equals( tempCheckedEnumPair.getWireValue() ) ) ) { - CheckBoxT tempCheckBox = (CheckBoxT) aControl; - - EnumPairT tempCheckedEnumPair = ParameterHelper.getEnumPairForEnumID( aParameter, tempCheckBox.getCheckedEnumRef() ); - EnumPairT tempUncheckedEnumPair = ParameterHelper.getEnumPairForEnumID( aParameter, tempCheckBox.getUncheckedEnumRef() ); - String tempParameterValueString = aParameterValue.toString(); - logger.debug("tempParameterValueString: " + tempParameterValueString + " tempCheckedEnumPair: " + tempCheckedEnumPair + " tempUncheckedEnumPair: " + tempUncheckedEnumPair ); - - if ( ( tempCheckedEnumPair != null ) && ( tempParameterValueString.equals( tempCheckedEnumPair.getWireValue() ) ) ) - { - return Boolean.TRUE.toString(); - } - else if ( ( tempUncheckedEnumPair != null ) && ( tempParameterValueString.equals( tempUncheckedEnumPair.getWireValue() ) ) ) - { - return Boolean.FALSE.toString(); - } + return Boolean.TRUE.toString(); + } + else if ( ( tempUncheckedEnumPair != null ) && ( tempParameterValueString.equals( tempUncheckedEnumPair.getWireValue() ) ) ) + { + return Boolean.FALSE.toString(); } } - + return aParameterValue; } diff --git a/src/main/java/org/atdl4j/data/converter/BooleanConverter.java b/src/main/java/org/atdl4j/data/converter/BooleanConverter.java index 1063c0e..c98b458 100644 --- a/src/main/java/org/atdl4j/data/converter/BooleanConverter.java +++ b/src/main/java/org/atdl4j/data/converter/BooleanConverter.java @@ -40,11 +40,11 @@ else if ( aValue instanceof String ) String str = (String) aValue; if ( str.equalsIgnoreCase( "true" ) || str.equals( "1" ) || str.equals( BooleanConverter.BOOLEAN_TRUE ) ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( str.equalsIgnoreCase( "false" ) || str.equals( "0" ) || str.equals( BooleanConverter.BOOLEAN_FALSE ) ) { - return new Boolean( false ); + return Boolean.FALSE; } else if ( str.equals( "" ) ) { @@ -52,23 +52,23 @@ else if ( str.equals( "" ) ) } else { - return new Boolean( false ); + return Boolean.FALSE; } } else if ( aValue instanceof BigDecimal || aValue instanceof BigInteger ) { - BigDecimal num = (BigDecimal) aValue; + Number num = (Number) aValue; if ( num.intValue() == 1 ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( num.intValue() == 0 ) { - return new Boolean( false ); + return Boolean.FALSE; } else { - return new Boolean( false ); + return Boolean.FALSE; } } else @@ -122,14 +122,14 @@ protected Boolean convertStringToParameterValue(String aValue) { if ( aValue != null ) { - String str = (String) aValue; + String str = aValue; if ( str.equalsIgnoreCase( "true" ) || str.equals( "1" ) || str.equals( BOOLEAN_TRUE ) ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( str.equalsIgnoreCase( "false" ) || str.equals( "0" ) || str.equals( BOOLEAN_FALSE ) ) { - return new Boolean( false ); + return Boolean.FALSE; } else if ( str.equals( "" ) ) { @@ -137,7 +137,7 @@ else if ( str.equals( "" ) ) } else { - return new Boolean( false ); + return Boolean.FALSE; } } else @@ -167,17 +167,6 @@ public String convertParameterValueToFixWireValue(Object aParameterValue) return bool.booleanValue() ? BOOLEAN_TRUE : BOOLEAN_FALSE; } else return null; - -// 2/1/2010 John Shields deleted -// trueWireValue and falseWireValue are deprecated - /* - * if (bool != null) { if (bool.booleanValue()) { if (booleanT != null && - * booleanT.getTrueWireValue() != null) return - * booleanT.getTrueWireValue(); else return BOOLEAN_TRUE; } else { if - * (booleanT != null && booleanT.getFalseWireValue() != null) return - * booleanT.getFalseWireValue(); else return BOOLEAN_FALSE; } } else { - * return null; } - */ } /* (non-Javadoc) @@ -198,11 +187,11 @@ else if ( aParameterValue instanceof String ) String str = (String) aParameterValue; if ( str.equalsIgnoreCase( "true" ) || str.equals( "1" ) || str.equals( BooleanConverter.BOOLEAN_TRUE ) ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( str.equalsIgnoreCase( "false" ) || str.equals( "0" ) || str.equals( BooleanConverter.BOOLEAN_FALSE ) ) { - return new Boolean( false ); + return Boolean.FALSE; } else if ( str.equals( "" ) ) { @@ -210,7 +199,7 @@ else if ( str.equals( "" ) ) } else { - return new Boolean( false ); + return Boolean.FALSE; } } else if ( aParameterValue instanceof BigDecimal || aParameterValue instanceof BigInteger ) @@ -218,15 +207,15 @@ else if ( aParameterValue instanceof BigDecimal || aParameterValue instanceof Bi BigDecimal num = (BigDecimal) aParameterValue; if ( num.intValue() == 1 ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( num.intValue() == 0 ) { - return new Boolean( false ); + return Boolean.FALSE; } else { - return new Boolean( false ); + return Boolean.FALSE; } } else diff --git a/src/main/java/org/atdl4j/data/converter/DatatypeConverter.java b/src/main/java/org/atdl4j/data/converter/DatatypeConverter.java index 2686f70..45c6d98 100644 --- a/src/main/java/org/atdl4j/data/converter/DatatypeConverter.java +++ b/src/main/java/org/atdl4j/data/converter/DatatypeConverter.java @@ -6,10 +6,11 @@ import java.math.BigDecimal; import java.math.BigInteger; +import java.time.Instant; +import java.time.ZonedDateTime; import javax.xml.datatype.XMLGregorianCalendar; -import org.joda.time.DateTime; /** * @@ -21,15 +22,6 @@ */ public class DatatypeConverter { - // -- Object that is an instanceof the Parameter's base data type (eg String, BigDecimal, DateTime, etc) -- - // -- @see ParameterTypeConverter.getParameterDatatype() and DatatypeConverter -// public static String DATATYPE_STRING = new String(); -// public static Boolean DATATYPE_BOOLEAN = new Boolean( false ); -// public static DateTime DATATYPE_DATE_TIME = new DateTime(); -// public static XMLGregorianCalendar DATATYPE_XML_GREGORIAN_CALENDAR = DateTimeConverter.constructNewXmlGregorianCalendar(); -// public static BigDecimal DATATYPE_BIG_DECIMAL = new BigDecimal( "0" ); -// public static BigInteger DATATYPE_BIG_INTEGER = new BigInteger( "0" ); - /** * Convert from one datatype to another (eg ParameterConverter's type to ControlConverter's type and vice-versa) * @param aValue @@ -53,22 +45,33 @@ else if ( klass == Boolean.class ) { return convertValueToBooleanDatatype( aValue ); } - else if ( klass == DateTime.class ) + else if ( klass == ZonedDateTime.class ) + { + if ( aValue == null ) + { + return null; + } + else + { + throw new IllegalArgumentException( "ZonedDateTime datatype conversion is not supported (due to timezone offests). [aValue: " + aValue + "]" ); + } + } + else if ( klass == Instant.class ) { if ( aValue == null ) { - return (DateTime) null; + return null; } else { - throw new IllegalArgumentException( "DateTime datatype conversion is not supported (due to timezone offests). [aValue: " + aValue + "]" ); + throw new IllegalArgumentException( "Instant datatype conversion is not supported (due to timezone offests). [aValue: " + aValue + "]" ); } } else if ( klass == XMLGregorianCalendar.class ) { if ( aValue == null ) { - return (XMLGregorianCalendar) null; + return null; } else { @@ -85,7 +88,7 @@ else if ( klass == BigInteger.class ) } else { - throw new IllegalArgumentException( "Unsupported aToDatatypeObject type: " + klass.getClass() + " [aValue: " + aValue + "]" ); + throw new IllegalArgumentException( "Unsupported aToDatatypeObject type: " + klass + " [aValue: " + aValue + "]" ); } } @@ -128,11 +131,11 @@ else if ( aValue instanceof String ) String str = (String) aValue; if ( str.equalsIgnoreCase( "true" ) || str.equals( "1" ) || str.equals( BooleanConverter.BOOLEAN_TRUE ) ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( str.equalsIgnoreCase( "false" ) || str.equals( "0" ) || str.equals( BooleanConverter.BOOLEAN_FALSE ) ) { - return new Boolean( false ); + return Boolean.FALSE; } else if ( str.equals( "" ) ) { @@ -148,11 +151,11 @@ else if ( aValue instanceof Number ) Number num = (Number) aValue; if ( num.intValue() == 1 ) { - return new Boolean( true ); + return Boolean.TRUE; } else if ( num.intValue() == 0 ) { - return new Boolean( false ); + return Boolean.FALSE; } else { @@ -247,9 +250,9 @@ else if ( aValue instanceof Boolean ) { Boolean bool = (Boolean) aValue; if ( Boolean.TRUE.equals( bool ) ) - return new BigInteger( "1" ); + return BigInteger.ONE; else - return new BigInteger( "0" ); + return BigInteger.ZERO; } else { diff --git a/src/main/java/org/atdl4j/data/converter/DateTimeConverter.java b/src/main/java/org/atdl4j/data/converter/DateTimeConverter.java index b1351b3..5a46486 100644 --- a/src/main/java/org/atdl4j/data/converter/DateTimeConverter.java +++ b/src/main/java/org/atdl4j/data/converter/DateTimeConverter.java @@ -1,5 +1,9 @@ package org.atdl4j.data.converter; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; @@ -15,13 +19,9 @@ import org.atdl4j.fixatdl.core.UTCTimeOnlyT; import org.atdl4j.fixatdl.core.UTCTimestampT; import org.atdl4j.fixatdl.timezones.Timezone; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; public class DateTimeConverter - extends AbstractTypeConverter> + extends AbstractTypeConverter> { Timezone timezone = null; public static DatatypeFactory javaxDatatypeFactory; @@ -78,41 +78,41 @@ else if ( getParameter() instanceof UTCTimestampT ) return "yyyyMMdd-HH:mm:ss"; } - public static DateTimeZone convertTimezoneToDateTimeZone( Timezone aTimezone ) + public static ZoneId convertTimezoneToZoneId( Timezone aTimezone ) { if ( aTimezone != null ) { - return DateTimeZone.forID( aTimezone.value() ); + return ZoneId.of( aTimezone.value() ); } else { return null; } + } - public static DateTime convertXMLGregorianCalendarToDateTime( XMLGregorianCalendar aXMLGregorianCalendar, Timezone aTimezone ) + public static ZonedDateTime convertXMLGregorianCalendarToZonedDateTime( XMLGregorianCalendar aXMLGregorianCalendar, Timezone aTimezone ) { - // -- DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) -- int tempSubsecond = 0; if ( aXMLGregorianCalendar.getFractionalSecond() != null ) { tempSubsecond = aXMLGregorianCalendar.getFractionalSecond().intValue(); } - DateTimeZone tempDateTimeZone = convertTimezoneToDateTimeZone( aTimezone ); - if ( tempDateTimeZone == null ) + ZoneId tempZoneId = convertTimezoneToZoneId( aTimezone ); + if ( tempZoneId == null ) { - tempDateTimeZone = DateTimeZone.getDefault(); - } + tempZoneId = ZoneId.systemDefault(); + } - return new DateTime( aXMLGregorianCalendar.getYear(), + return ZonedDateTime.of( aXMLGregorianCalendar.getYear(), aXMLGregorianCalendar.getMonth(), aXMLGregorianCalendar.getDay(), aXMLGregorianCalendar.getHour(), aXMLGregorianCalendar.getMinute(), aXMLGregorianCalendar.getSecond(), tempSubsecond, - tempDateTimeZone ); + tempZoneId ); } public static XMLGregorianCalendar convertDailyValueToValue( XMLGregorianCalendar aDailyValue, Timezone aTimezone ) @@ -121,27 +121,27 @@ public static XMLGregorianCalendar convertDailyValueToValue( XMLGregorianCalenda if ( aDailyValue != null ) { // -- Init calendar date portion equal to "current date" local/default -- - DateTime tempDateTime = new DateTime(); + ZonedDateTime tempZonedDateTime = ZonedDateTime.now(); if ( aTimezone != null ) { - DateTimeZone tempDateTimeZone = DateTimeZone.forID( aTimezone.value() ); - if ( tempDateTimeZone != null ) + ZoneId tempZoneId = ZoneId.of( aTimezone.value() ); + if ( tempZoneId != null ) { - int tempOffsetMillis = tempDateTimeZone.getOffset( System.currentTimeMillis() ); - // -- convert milliseconds to minutes -- - aDailyValue.setTimezone( tempOffsetMillis / 60000 ); + int tempOffsetSeconds = tempZoneId.getRules().getOffset( Instant.now() ).getTotalSeconds(); + // -- convert seconds to minutes -- + aDailyValue.setTimezone( tempOffsetSeconds / 60 ); // -- Set calendar date portion equal to "current date" of the Timezone -- // -- (eg Asian security trading in Japan during the morning of Feb 15 might be local of 9pm ET Feb 14. // -- Want to ensure we use Feb 15, not Feb 14 if localMktTz is for Japan) -- - tempDateTime = new DateTime( tempDateTimeZone ); + tempZonedDateTime = ZonedDateTime.now( tempZoneId ); } } - aDailyValue.setMonth( tempDateTime.getMonthOfYear() ); - aDailyValue.setDay( tempDateTime.getDayOfMonth() ); - aDailyValue.setYear( tempDateTime.getYear() ); + aDailyValue.setMonth( tempZonedDateTime.getMonthValue() ); + aDailyValue.setDay( tempZonedDateTime.getDayOfMonth() ); + aDailyValue.setYear( tempZonedDateTime.getYear() ); } return aDailyValue; @@ -187,46 +187,33 @@ public static XMLGregorianCalendar constructNewXmlGregorianCalendar() return getJavaxDatatypeFactory().newXMLGregorianCalendar( new GregorianCalendar() ); } - /* (non-Javadoc) + /** * @see org.atdl4j.data.ControlTypeConverter#convertControlValueToControlComparable(java.lang.Object) */ @Override - public DateTime convertControlValueToControlComparable(Object aValue) + public Instant convertControlValueToControlComparable(Object aValue) { - if ( aValue instanceof DateTime ) + if ( aValue instanceof Instant ) { - return (DateTime) aValue; + return (Instant) aValue; + } + else if ( aValue instanceof ZonedDateTime ) + { + return ((ZonedDateTime) aValue).toInstant(); } else if ( aValue instanceof XMLGregorianCalendar ) { - return convertXMLGregorianCalendarToDateTime( (XMLGregorianCalendar) aValue, getTimezone() ); + return convertXMLGregorianCalendarToZonedDateTime( (XMLGregorianCalendar) aValue, getTimezone() ).toInstant(); } else if ( aValue instanceof String ) { String str = (String) aValue; String format = getFormatString(); - DateTimeFormatter fmt = DateTimeFormat.forPattern( format ); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern( format ); try - { - if ( ( getParameterTypeConverter() == null ) || - ( getParameterTypeConverter().getParameter() == null ) || - ( getParameterTypeConverter().getParameter() instanceof UTCTimeOnlyT ) || - ( getParameterTypeConverter().getParameter() instanceof UTCTimestampT ) ) - { - DateTime tempDateTime = fmt.parseDateTime( str ); - return tempDateTime.withZone( DateTimeZone.UTC ); - } - - /* - * else if (getParameter() instanceof TZTimestamp || getParameter() instanceof - * TZTimeOnlyT) { return fmt.withOffsetParsed().parseDateTime(str); - * } - */ - else - { - return fmt.parseDateTime( str ); - } + { + return ZonedDateTime.parse(str, fmt).toInstant(); } catch (IllegalArgumentException e) { @@ -247,11 +234,15 @@ public Object convertControlValueToParameterValue(Object aValue) { if ( aValue instanceof XMLGregorianCalendar ) { - return convertXMLGregorianCalendarToDateTime( (XMLGregorianCalendar) aValue, getTimezone() ); + return convertXMLGregorianCalendarToZonedDateTime( (XMLGregorianCalendar) aValue, getTimezone() ).toInstant(); + } + else if ( aValue instanceof ZonedDateTime ) + { + return ((ZonedDateTime) aValue).toInstant(); } else { - return (DateTime) aValue; + return aValue; } } @@ -259,15 +250,19 @@ public Object convertControlValueToParameterValue(Object aValue) * @see org.atdl4j.data.ControlTypeConverter#convertParameterValueToControlValue(java.lang.Object) */ @Override - public DateTime convertParameterValueToControlValue(Object aValue) + public Instant convertParameterValueToControlValue(Object aValue) { - if ( aValue instanceof DateTime ) + if ( aValue instanceof Instant ) + { + return (Instant) aValue; + } + else if ( aValue instanceof ZonedDateTime ) { - return (DateTime) aValue; + return ((ZonedDateTime) aValue).toInstant(); } else if ( aValue instanceof XMLGregorianCalendar ) { - return convertXMLGregorianCalendarToDateTime( (XMLGregorianCalendar) aValue, getTimezone() ); + return convertXMLGregorianCalendarToZonedDateTime( (XMLGregorianCalendar) aValue, getTimezone() ).toInstant(); } else { @@ -279,7 +274,7 @@ else if ( aValue instanceof XMLGregorianCalendar ) * @see org.atdl4j.data.ControlTypeConverter#convertStringToControlValue(java.lang.String) */ @Override - public DateTime convertStringToControlValue(String aString) + public Instant convertStringToControlValue(String aString) { return convertControlValueToControlComparable( aString ); } @@ -292,9 +287,9 @@ public Object convertFixWireValueToParameterValue(String aFixWireValue) { if ( aFixWireValue != null ) { - String str = (String) aFixWireValue; + String str = aFixWireValue; String format = getFormatString(); - DateTimeFormatter fmt = DateTimeFormat.forPattern( format ); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern( format ); try { @@ -302,12 +297,11 @@ public Object convertFixWireValueToParameterValue(String aFixWireValue) getParameter() instanceof UTCTimeOnlyT || getParameter() instanceof UTCTimestampT ) { - DateTime tempDateTime = fmt.withZone( DateTimeZone.UTC ).parseDateTime( str ); - return tempDateTime; + return ZonedDateTime.parse(str, fmt.withZone( ZoneId.of("UTC"))).toInstant(); } else { - return fmt.parseDateTime( str ); + return ZonedDateTime.parse(str, fmt).toInstant(); } } catch (IllegalArgumentException e) @@ -329,9 +323,9 @@ public Object convertParameterStringToParameterValue(String aParameterString) { if ( aParameterString != null ) { - String str = (String) aParameterString; + String str = aParameterString; String format = getFormatString(); - DateTimeFormatter fmt = DateTimeFormat.forPattern( format ); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern( format ); try { @@ -339,11 +333,11 @@ public Object convertParameterStringToParameterValue(String aParameterString) getParameter() instanceof UTCTimeOnlyT || getParameter() instanceof UTCTimestampT ) { - return fmt.withZone( DateTimeZone.UTC ).parseDateTime( str ); + return ZonedDateTime.parse(str, fmt.withZone( ZoneId.of("UTC"))).toInstant(); } else { - return fmt.parseDateTime( str ); + return ZonedDateTime.parse(str, fmt).toInstant(); } } catch (IllegalArgumentException e) @@ -364,12 +358,17 @@ public Object convertParameterStringToParameterValue(String aParameterString) @Override public String convertParameterValueToFixWireValue(Object aParameterValue) { - DateTime date = convertParameterValueToParameterComparable( aParameterValue ); + if ( aParameterValue == null ) + { + return null; + } - if ( date != null ) + ZonedDateTime tempZonedDateTime = ZonedDateTime.ofInstant(convertParameterValueToParameterComparable( aParameterValue ), ZoneId.of("UTC" ) ); + + if ( tempZonedDateTime != null ) { - DateTimeFormatter fmt = DateTimeFormat.forPattern( getFormatString() ); - return fmt.withZone( DateTimeZone.UTC ).print( date ); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern( getFormatString() ); + return tempZonedDateTime.format( fmt ); } else { @@ -381,26 +380,30 @@ public String convertParameterValueToFixWireValue(Object aParameterValue) * @see org.atdl4j.data.ParameterTypeConverter#convertParameterValueToParameterComparable(java.lang.Object) */ @Override - public DateTime convertParameterValueToParameterComparable(Object aParameterValue) + public Instant convertParameterValueToParameterComparable(Object aParameterValue) { - if ( aParameterValue instanceof DateTime ) + if ( aParameterValue instanceof Instant ) + { + return (Instant) aParameterValue; + } + else if ( aParameterValue instanceof ZonedDateTime ) { - DateTime tempDateTime = (DateTime) aParameterValue; + ZonedDateTime tempZonedDateTime = (ZonedDateTime) aParameterValue; if ( getParameter() == null || getParameter() instanceof UTCTimeOnlyT || getParameter() instanceof UTCTimestampT ) { - return tempDateTime.withZone( DateTimeZone.UTC ); + return tempZonedDateTime.withZoneSameInstant( ZoneId.of( "UTC" ) ).toInstant(); } else { - return tempDateTime; + return tempZonedDateTime.toInstant(); } } else if ( aParameterValue instanceof XMLGregorianCalendar ) { - return convertXMLGregorianCalendarToDateTime( (XMLGregorianCalendar) aParameterValue, getTimezone() ); + return convertXMLGregorianCalendarToZonedDateTime( (XMLGregorianCalendar) aParameterValue, getTimezone() ).toInstant(); } else { @@ -414,20 +417,25 @@ else if ( aParameterValue instanceof XMLGregorianCalendar ) @Override public String convertParameterValueToComparisonString(Object aParameterValue) { - DateTime tempDateTime = convertParameterValueToParameterComparable( aParameterValue ); + if ( aParameterValue == null ) + { + return null; + } + + ZonedDateTime tempDateTime = ZonedDateTime.ofInstant( convertParameterValueToParameterComparable( aParameterValue ), ZoneId.systemDefault() ); if ( tempDateTime != null ) { String format = getFormatString(); - DateTimeFormatter fmt = DateTimeFormat.forPattern( format ); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern( format ); if ( getParameter() == null || getParameter() instanceof UTCTimeOnlyT || getParameter() instanceof UTCTimestampT ) { - tempDateTime = tempDateTime.withZone( DateTimeZone.UTC ); + tempDateTime = tempDateTime.withZoneSameInstant( ZoneId.of ("UTC" ) ); } - return fmt.print( tempDateTime ); + return tempDateTime.format(fmt); } else { diff --git a/src/main/java/org/atdl4j/data/converter/DecimalConverter.java b/src/main/java/org/atdl4j/data/converter/DecimalConverter.java index c6908e4..1ae1d5e 100644 --- a/src/main/java/org/atdl4j/data/converter/DecimalConverter.java +++ b/src/main/java/org/atdl4j/data/converter/DecimalConverter.java @@ -182,17 +182,6 @@ else if ( getParameter() instanceof QtyT ) { return ( (QtyT) getParameter() ).getMinValue(); } -// else if ( getParameter() instanceof IntT ) -// { -// -// IntT intT = (IntT) getParameter(); -// -// if ( intT.getMinValue() != null ) -// { -// return intT.getMinValue(); -// } -// -// } else { return null; @@ -232,17 +221,6 @@ else if ( getParameter() instanceof QtyT ) { return ( (QtyT) getParameter() ).getMaxValue(); } -// else if ( getParameter() instanceof IntT ) -// { -// -// IntT intT = (IntT) getParameter(); -// -// if ( intT.getMaxValue() != null ) -// { -// return intT.getMinValue(); -// } -// -// } else { return null; @@ -297,13 +275,12 @@ public BigDecimal convertControlValueToControlComparable(Object aValue) if ( aValue instanceof BigDecimal ) { - // 2/12/2010 return (BigDecimal) aValue; tempBigDecimal = (BigDecimal) aValue; } else if ( aValue instanceof String ) { String str = (String) aValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + if ( str.trim().length() == 0 ) { return null; } @@ -397,8 +374,8 @@ public Object convertFixWireValueToParameterValue(String aFixWireValue) if ( aFixWireValue != null ) { - String str = (String) aFixWireValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + String str = aFixWireValue; + if ( str.trim().length() == 0 ) { return null; } @@ -439,8 +416,8 @@ public Object convertParameterStringToParameterValue(String aParameterString) if ( aParameterString != null ) { - String str = (String) aParameterString; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + String str = aParameterString; + if ( str.trim().length() == 0 ) { return null; } @@ -495,7 +472,7 @@ public BigDecimal convertParameterValueToParameterComparable(Object aParameterVa else if ( aParameterValue instanceof String ) { String str = (String) aParameterValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + if ( str.trim().length() == 0 ) { return null; } diff --git a/src/main/java/org/atdl4j/data/converter/IntegerConverter.java b/src/main/java/org/atdl4j/data/converter/IntegerConverter.java index 0c49a64..aa7cf8a 100644 --- a/src/main/java/org/atdl4j/data/converter/IntegerConverter.java +++ b/src/main/java/org/atdl4j/data/converter/IntegerConverter.java @@ -155,8 +155,8 @@ protected BigInteger convertStringToParameterValue(String aValue) { if ( aValue != null ) { - String str = (String) aValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + String str = aValue; + if ( str.trim().length() == 0 ) { return null; } @@ -214,7 +214,7 @@ else if ( aParameterValue instanceof Integer ) else if ( aParameterValue instanceof String ) { String str = (String) aParameterValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + if ( str.trim().length() == 0 ) { return null; } @@ -256,7 +256,7 @@ else if ( aValue instanceof Integer ) else if ( aValue instanceof String ) { String str = (String) aValue; - if ( ( str == null ) || ( str.trim().length() == 0 ) ) + if ( str.trim().length() == 0 ) { return null; } @@ -278,7 +278,7 @@ else if ( aValue instanceof String ) else if ( aValue instanceof Boolean ) { Boolean bool = (Boolean) aValue; - return new BigInteger( bool ? "1" : "0" ); + return new BigInteger( Boolean.TRUE.equals( bool ) ? "1" : "0" ); } else { diff --git a/src/main/java/org/atdl4j/data/converter/StringConverter.java b/src/main/java/org/atdl4j/data/converter/StringConverter.java index d8c5eff..57ad3ed 100644 --- a/src/main/java/org/atdl4j/data/converter/StringConverter.java +++ b/src/main/java/org/atdl4j/data/converter/StringConverter.java @@ -22,7 +22,7 @@ public StringConverter(ParameterTypeConverter aParameterTypeConverter) private static String invertOnWire(String text) { - StringBuffer invertedString = new StringBuffer(); + StringBuilder invertedString = new StringBuilder(); int startIndex = text.lastIndexOf( " " ); int endIndex = text.length(); @@ -59,11 +59,8 @@ public Object convertFixWireValueToParameterValue(String aFixWireValue) { String str = convertStringToParameterValue( aFixWireValue ); - if ( getParameter() instanceof MultipleCharValueT && ( (MultipleCharValueT) getParameter() ).isInvertOnWire() ) - { - return invertOnWire( str ); - } - else if ( getParameter() instanceof MultipleStringValueT && ( (MultipleStringValueT) getParameter() ).isInvertOnWire() ) + if ( ( getParameter() instanceof MultipleCharValueT && ( (MultipleCharValueT) getParameter() ).isInvertOnWire() ) + || ( getParameter() instanceof MultipleStringValueT && ( (MultipleStringValueT) getParameter() ).isInvertOnWire() ) ) { return invertOnWire( str ); } @@ -89,7 +86,7 @@ protected String convertStringToParameterValue(String aValue) { if ( ( aValue != null ) && ( ! "".equals( aValue ) ) ) { - return aValue.toString(); + return aValue; } else { @@ -187,7 +184,7 @@ public String convertParameterValueToControlValue(Object aValue) return null; } // -- handle PercentageT getParameter() coming through with BigDecial (eg from Load FIX Message) -- - else if ( ( aValue != null ) && ( isControlMultiplyBy100() ) ) + else if ( isControlMultiplyBy100() ) { BigDecimal tempBigDecimal; try diff --git a/src/main/java/org/atdl4j/data/exception/ValidationException.java b/src/main/java/org/atdl4j/data/exception/ValidationException.java index e13c946..623e172 100644 --- a/src/main/java/org/atdl4j/data/exception/ValidationException.java +++ b/src/main/java/org/atdl4j/data/exception/ValidationException.java @@ -7,8 +7,9 @@ * fails during a user-initiated validation event (e.g. when * outputting a FIX message from the screen.) */ -public class ValidationException extends Exception { - private static final long serialVersionUID = -156407004102010541L; +public class ValidationException extends Exception +{ + private static final long serialVersionUID = -156407004102010541L; private Atdl4jWidget target; public ValidationException(Atdl4jWidget target) { diff --git a/src/main/java/org/atdl4j/data/fix/StringFIXMessageBuilder.java b/src/main/java/org/atdl4j/data/fix/StringFIXMessageBuilder.java index fdff74f..9013e71 100644 --- a/src/main/java/org/atdl4j/data/fix/StringFIXMessageBuilder.java +++ b/src/main/java/org/atdl4j/data/fix/StringFIXMessageBuilder.java @@ -1,21 +1,15 @@ package org.atdl4j.data.fix; -/*import java.util.HashMap; - import java.util.List; - import java.util.Map;*/ - import org.atdl4j.data.Atdl4jConstants; // TODO: Change to handle generic repeating groups public class StringFIXMessageBuilder implements FIXMessageBuilder { - private static char delimiter = '\001'; private StringBuffer sb; private StringBuffer repeating; - // private Map>> repeating; private int repeatingCount; @@ -32,8 +26,7 @@ public void onField(int field, String value) if ( field == Atdl4jConstants.TAG_STRATEGY_PARAMETER_NAME || field == Atdl4jConstants.TAG_STRATEGY_PARAMETER_TYPE || field == Atdl4jConstants.TAG_STRATEGY_PARAMETER_VALUE ) { - // if (repeating.get(Atdl4jConstants.TAG_NO_STRATEGY_PARAMETERS) == - // null) + // if (repeating.get(Atdl4jConstants.TAG_NO_STRATEGY_PARAMETERS) == null) repeating.append( field ).append( '=' ).append( value ).append( delimiter ); if ( field == Atdl4jConstants.TAG_STRATEGY_PARAMETER_NAME ) { diff --git a/src/main/java/org/atdl4j/data/validation/AbstractOperatorValidationRule.java b/src/main/java/org/atdl4j/data/validation/AbstractOperatorValidationRule.java index 458ebc6..f6d9522 100644 --- a/src/main/java/org/atdl4j/data/validation/AbstractOperatorValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/AbstractOperatorValidationRule.java @@ -1,24 +1,24 @@ package org.atdl4j.data.validation; -import org.apache.log4j.Logger; +import java.time.ZoneId; +import java.time.ZonedDateTime; + import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.fixatdl.validation.OperatorT; import org.atdl4j.ui.Atdl4jWidget; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base class for ValidationRule. * - * @param - * * @author renato.gallart */ public abstract class AbstractOperatorValidationRule implements ValidationRule { - private static final Logger logger = Logger.getLogger( AbstractOperatorValidationRule.class ); + private static final Logger logger = LoggerFactory.getLogger( AbstractOperatorValidationRule.class ); @SuppressWarnings("unchecked") protected void validateValues(Atdl4jWidget target, Object value1, OperatorT operator, Object value2) throws ValidationException @@ -27,18 +27,16 @@ protected void validateValues(Atdl4jWidget target, Object value1, OperatorT o // -- Work-around to 'handle' joda's DateTime.equals() failing if timezones are expressed differently // -- for same underlying time in millis. DateTime.isEqual() behaves as expected // -- using DateTimeZone.getDefault() will result in any values displayed in error messages to be in local zone (with "-0600" suffix if US CST) - if ( ( value1 != null ) && ( value1 instanceof DateTime ) ) + if ( value1 instanceof ZonedDateTime ) { - value1 = ((DateTime) value1).withZone( DateTimeZone.getDefault() ); + value1 = ((ZonedDateTime) value1).withZoneSameInstant( ZoneId.systemDefault() ); } - if ( ( value2 != null ) && ( value2 instanceof DateTime ) ) + if ( value2 instanceof ZonedDateTime ) { - value2 = ((DateTime) value2).withZone( DateTimeZone.getDefault() ); + value2 = ((ZonedDateTime) value2).withZoneSameInstant( ZoneId.systemDefault() ); } - - - + switch ( operator ) { case NE : @@ -132,7 +130,7 @@ protected void validateValues(Atdl4jWidget target, Object value1, OperatorT o default: // Supposed to never happen, since the schema enforces an enumerated // base restriction. - logger.error( "Invalid operator: " + operator ); + logger.error( "Invalid operator: {}", operator ); break; } } diff --git a/src/main/java/org/atdl4j/data/validation/Field2OperatorValidationRule.java b/src/main/java/org/atdl4j/data/validation/Field2OperatorValidationRule.java index 1a71fec..05bf04e 100644 --- a/src/main/java/org/atdl4j/data/validation/Field2OperatorValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/Field2OperatorValidationRule.java @@ -4,7 +4,6 @@ import java.math.BigInteger; import java.util.Map; -import org.apache.log4j.Logger; import org.atdl4j.config.InputAndFilterData; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.ValidationException; @@ -12,6 +11,8 @@ import org.atdl4j.fixatdl.validation.OperatorT; import org.atdl4j.ui.Atdl4jWidget; import org.atdl4j.ui.impl.AbstractHiddenFieldWidget; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Validator that validates input against another existing field. @@ -22,7 +23,7 @@ public class Field2OperatorValidationRule extends AbstractOperatorValidationRule { - private static final Logger logger = Logger.getLogger(Field2OperatorValidationRule.class); + private static final Logger logger = LoggerFactory.getLogger(Field2OperatorValidationRule.class); private String field; @@ -85,11 +86,11 @@ else if ( field2.startsWith( InputAndFilterData.FIX_DEFINED_FIELD_PREFIX ) ) { fieldValue2 = convertFieldValueToDesiredType( fieldValue, fieldValue2 ); } - else if ( ( target != null ) && ( target instanceof AbstractHiddenFieldWidget ) ) + else if ( target instanceof AbstractHiddenFieldWidget ) { fieldValue = convertFieldValueToDesiredType( fieldValue2, fieldValue ); } - else if ( ( target2 != null ) && ( target2 instanceof AbstractHiddenFieldWidget ) ) + else if ( target2 instanceof AbstractHiddenFieldWidget ) { fieldValue2 = convertFieldValueToDesiredType( fieldValue, fieldValue2 ); } @@ -123,15 +124,15 @@ else if( aFieldWithDesiredType instanceof BigInteger ) } else if( aFieldWithDesiredType instanceof Double ) { - return new Double( aFieldValue.toString() ); + return Double.valueOf( aFieldValue.toString() ); } else if( aFieldWithDesiredType instanceof Integer ) { - return new Integer( aFieldValue.toString() ); + return Integer.valueOf( aFieldValue.toString() ); } else { - logger.warn( "convertFieldValueToDesiredType() unhandled Class type: " + aFieldWithDesiredType.getClass().getName() ); + logger.warn( "convertFieldValueToDesiredType() unhandled Class type: {}", aFieldWithDesiredType.getClass().getName() ); return aFieldValue; } } diff --git a/src/main/java/org/atdl4j/data/validation/LengthValidationRule.java b/src/main/java/org/atdl4j/data/validation/LengthValidationRule.java index d52af3d..ccb9039 100644 --- a/src/main/java/org/atdl4j/data/validation/LengthValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/LengthValidationRule.java @@ -3,7 +3,8 @@ import java.math.BigInteger; import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.fixatdl.validation.OperatorT; @@ -17,7 +18,7 @@ public class LengthValidationRule implements ValidationRule { - private static final Logger logger = Logger.getLogger( LengthValidationRule.class ); + private static final Logger logger = LoggerFactory.getLogger( LengthValidationRule.class ); private String field; diff --git a/src/main/java/org/atdl4j/data/validation/LogicalOperatorValidationRule.java b/src/main/java/org/atdl4j/data/validation/LogicalOperatorValidationRule.java index ffeaea0..1e4cda5 100644 --- a/src/main/java/org/atdl4j/data/validation/LogicalOperatorValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/LogicalOperatorValidationRule.java @@ -27,7 +27,7 @@ public class LogicalOperatorValidationRule public LogicalOperatorValidationRule(LogicOperatorT operator, Object parent) { this.operator = operator; - this.rules = new ArrayList(); + this.rules = new ArrayList<>(); } public List getRules() diff --git a/src/main/java/org/atdl4j/data/validation/PatternValidationRule.java b/src/main/java/org/atdl4j/data/validation/PatternValidationRule.java index 3340d2f..084cd55 100644 --- a/src/main/java/org/atdl4j/data/validation/PatternValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/PatternValidationRule.java @@ -3,7 +3,8 @@ import java.util.Map; import java.util.regex.Pattern; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.ui.Atdl4jWidget; @@ -17,7 +18,7 @@ public class PatternValidationRule implements ValidationRule { - private static final Logger logger = Logger.getLogger( PatternValidationRule.class ); + private static final Logger logger = LoggerFactory.getLogger( PatternValidationRule.class ); private String field; diff --git a/src/main/java/org/atdl4j/data/validation/ValueOperatorValidationRule.java b/src/main/java/org/atdl4j/data/validation/ValueOperatorValidationRule.java index dee10d0..ba9261b 100644 --- a/src/main/java/org/atdl4j/data/validation/ValueOperatorValidationRule.java +++ b/src/main/java/org/atdl4j/data/validation/ValueOperatorValidationRule.java @@ -2,7 +2,8 @@ import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.InputAndFilterData; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.ValidationException; @@ -19,7 +20,7 @@ public class ValueOperatorValidationRule extends AbstractOperatorValidationRule { - private static final Logger logger = Logger.getLogger( ValueOperatorValidationRule.class ); + private static final Logger logger = LoggerFactory.getLogger( ValueOperatorValidationRule.class ); private String field; @@ -55,7 +56,7 @@ public void validate(Map refRules, Map refRules, Map convertStringToComparable(String string) - * throws JAXBException { if (parameterConverter != null) return - * parameterConverter.convertValueToComparable(string); else return - * controlConverter.convertValueToComparable(string); } - **/ Object fieldValue; Object v; if ( parent instanceof StateRuleT ) // Uses Control "display" values diff --git a/src/main/java/org/atdl4j/fixatdl/core/MarketsT.java b/src/main/java/org/atdl4j/fixatdl/core/MarketsT.java index ac5ccb6..9ea7ee3 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/MarketsT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/MarketsT.java @@ -70,7 +70,7 @@ public class MarketsT { */ public List getMarket() { if (market == null) { - market = new ArrayList(); + market = new ArrayList<>(); } return this.market; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/MultipleCharValueT.java b/src/main/java/org/atdl4j/fixatdl/core/MultipleCharValueT.java index d3b8ec0..82848a9 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/MultipleCharValueT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/MultipleCharValueT.java @@ -60,10 +60,14 @@ public class MultipleCharValueT * {@link BigInteger } * */ - public BigInteger getMinLength() { - if (minLength == null) { - return new BigInteger("0"); - } else { + public BigInteger getMinLength() + { + if (minLength == null) + { + return BigInteger.ZERO; + } + else + { return minLength; } } diff --git a/src/main/java/org/atdl4j/fixatdl/core/ObjectFactory.java b/src/main/java/org/atdl4j/fixatdl/core/ObjectFactory.java index 187cb18..aafcd2f 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/ObjectFactory.java +++ b/src/main/java/org/atdl4j/fixatdl/core/ObjectFactory.java @@ -31,8 +31,8 @@ @XmlRegistry public class ObjectFactory { - private final static QName _Strategies_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Core", "Strategies"); - private final static QName _Description_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Core", "Description"); + private static final QName _Strategies_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Core", "Strategies"); + private static final QName _Description_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Core", "Description"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.atdl4j.fixatdl.core @@ -375,7 +375,7 @@ public TagNumT createTagNumT() { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Core", name = "Strategies") public JAXBElement createStrategies(StrategiesT value) { - return new JAXBElement(_Strategies_QNAME, StrategiesT.class, null, value); + return new JAXBElement<>(_Strategies_QNAME, StrategiesT.class, null, value); } /** @@ -384,7 +384,7 @@ public JAXBElement createStrategies(StrategiesT value) { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Core", name = "Description") public JAXBElement createDescription(String value) { - return new JAXBElement(_Description_QNAME, String.class, null, value); + return new JAXBElement<>(_Description_QNAME, String.class, null, value); } } diff --git a/src/main/java/org/atdl4j/fixatdl/core/ParameterT.java b/src/main/java/org/atdl4j/fixatdl/core/ParameterT.java index b1c7b39..d3ac1b1 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/ParameterT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/ParameterT.java @@ -151,7 +151,7 @@ public void setDescription(String value) { */ public List getEnumPair() { if (enumPair == null) { - enumPair = new ArrayList(); + enumPair = new ArrayList<>(); } return this.enumPair; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/RegionT.java b/src/main/java/org/atdl4j/fixatdl/core/RegionT.java index b1fde0a..f966241 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/RegionT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/RegionT.java @@ -98,7 +98,7 @@ public class RegionT { */ public List getCountry() { if (country == null) { - country = new ArrayList(); + country = new ArrayList<>(); } return this.country; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/RegionsT.java b/src/main/java/org/atdl4j/fixatdl/core/RegionsT.java index 1135329..5273db0 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/RegionsT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/RegionsT.java @@ -70,7 +70,7 @@ public class RegionsT { */ public List getRegion() { if (region == null) { - region = new ArrayList(); + region = new ArrayList<>(); } return this.region; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/RepeatingGroupT.java b/src/main/java/org/atdl4j/fixatdl/core/RepeatingGroupT.java index 26b7cb1..ac28222 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/RepeatingGroupT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/RepeatingGroupT.java @@ -114,7 +114,7 @@ public void setDescription(String value) { */ public List getParameter() { if (parameter == null) { - parameter = new ArrayList(); + parameter = new ArrayList<>(); } return this.parameter; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/SecurityTypesT.java b/src/main/java/org/atdl4j/fixatdl/core/SecurityTypesT.java index b1540e6..f0383ff 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/SecurityTypesT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/SecurityTypesT.java @@ -203,7 +203,7 @@ public class SecurityTypesT { */ public List getSecurityType() { if (securityType == null) { - securityType = new ArrayList(); + securityType = new ArrayList<>(); } return this.securityType; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/StrategiesT.java b/src/main/java/org/atdl4j/fixatdl/core/StrategiesT.java index ef031ce..93f9d54 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/StrategiesT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/StrategiesT.java @@ -127,7 +127,7 @@ public void setDescription(String value) { */ public List getEdit() { if (edit == null) { - edit = new ArrayList(); + edit = new ArrayList<>(); } return this.edit; } @@ -156,7 +156,7 @@ public List getEdit() { */ public List getStrategy() { if (strategy == null) { - strategy = new ArrayList(); + strategy = new ArrayList<>(); } return this.strategy; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/StrategyT.java b/src/main/java/org/atdl4j/fixatdl/core/StrategyT.java index 49e1995..c4baa5e 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/StrategyT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/StrategyT.java @@ -260,7 +260,7 @@ public void setSecurityTypes(SecurityTypesT value) { */ public List getParameter() { if (parameter == null) { - parameter = new ArrayList(); + parameter = new ArrayList<>(); } return this.parameter; } @@ -289,7 +289,7 @@ public List getParameter() { */ public List getEdit() { if (edit == null) { - edit = new ArrayList(); + edit = new ArrayList<>(); } return this.edit; } @@ -366,7 +366,7 @@ public void setRepeatingGroup(RepeatingGroupT value) { */ public List getStrategyEdit() { if (strategyEdit == null) { - strategyEdit = new ArrayList(); + strategyEdit = new ArrayList<>(); } return this.strategyEdit; } diff --git a/src/main/java/org/atdl4j/fixatdl/core/StringT.java b/src/main/java/org/atdl4j/fixatdl/core/StringT.java index d107c0d..141ec0f 100644 --- a/src/main/java/org/atdl4j/fixatdl/core/StringT.java +++ b/src/main/java/org/atdl4j/fixatdl/core/StringT.java @@ -59,7 +59,7 @@ public class StringT */ public BigInteger getMinLength() { if (minLength == null) { - return new BigInteger("0"); + return BigInteger.ZERO; } else { return minLength; } diff --git a/src/main/java/org/atdl4j/fixatdl/flow/ObjectFactory.java b/src/main/java/org/atdl4j/fixatdl/flow/ObjectFactory.java index c78e5a4..4c9669f 100644 --- a/src/main/java/org/atdl4j/fixatdl/flow/ObjectFactory.java +++ b/src/main/java/org/atdl4j/fixatdl/flow/ObjectFactory.java @@ -31,7 +31,7 @@ @XmlRegistry public class ObjectFactory { - private final static QName _StateRule_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Flow", "StateRule"); + private static final QName _StateRule_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Flow", "StateRule"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.atdl4j.fixatdl.flow @@ -54,7 +54,7 @@ public StateRuleT createStateRuleT() { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Flow", name = "StateRule") public JAXBElement createStateRule(StateRuleT value) { - return new JAXBElement(_StateRule_QNAME, StateRuleT.class, null, value); + return new JAXBElement<>(_StateRule_QNAME, StateRuleT.class, null, value); } } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/CheckBoxListT.java b/src/main/java/org/atdl4j/fixatdl/layout/CheckBoxListT.java index 9ade8ad..015aad8 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/CheckBoxListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/CheckBoxListT.java @@ -77,7 +77,7 @@ public class CheckBoxListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/ControlT.java b/src/main/java/org/atdl4j/fixatdl/layout/ControlT.java index 96503b0..c6a1e0d 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/ControlT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/ControlT.java @@ -130,9 +130,11 @@ public abstract class ControlT { * * */ - public List getStateRule() { - if (stateRule == null) { - stateRule = new ArrayList(); + public List getStateRule() + { + if (stateRule == null) + { + stateRule = new ArrayList<>(); } return this.stateRule; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/DropDownListT.java b/src/main/java/org/atdl4j/fixatdl/layout/DropDownListT.java index 6fae314..b5080e9 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/DropDownListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/DropDownListT.java @@ -74,7 +74,7 @@ public class DropDownListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/EditableDropDownListT.java b/src/main/java/org/atdl4j/fixatdl/layout/EditableDropDownListT.java index e66c4f8..a1e7426 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/EditableDropDownListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/EditableDropDownListT.java @@ -74,7 +74,7 @@ public class EditableDropDownListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/ListItemT.java b/src/main/java/org/atdl4j/fixatdl/layout/ListItemT.java index cf41170..72c5bc5 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/ListItemT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/ListItemT.java @@ -82,7 +82,7 @@ public class ListItemT { */ public List getStateRule() { if (stateRule == null) { - stateRule = new ArrayList(); + stateRule = new ArrayList<>(); } return this.stateRule; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/MultiSelectListT.java b/src/main/java/org/atdl4j/fixatdl/layout/MultiSelectListT.java index a47c5a4..fbfcd2d 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/MultiSelectListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/MultiSelectListT.java @@ -74,7 +74,7 @@ public class MultiSelectListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/ObjectFactory.java b/src/main/java/org/atdl4j/fixatdl/layout/ObjectFactory.java index de486ec..b6fc6d8 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/ObjectFactory.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/ObjectFactory.java @@ -31,7 +31,7 @@ @XmlRegistry public class ObjectFactory { - private final static QName _StrategyLayout_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Layout", "StrategyLayout"); + private static final QName _StrategyLayout_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Layout", "StrategyLayout"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.atdl4j.fixatdl.layout @@ -190,7 +190,7 @@ public LabelT createLabelT() { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Layout", name = "StrategyLayout") public JAXBElement createStrategyLayout(StrategyLayoutT value) { - return new JAXBElement(_StrategyLayout_QNAME, StrategyLayoutT.class, null, value); + return new JAXBElement<>(_StrategyLayout_QNAME, StrategyLayoutT.class, null, value); } } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/RadioButtonListT.java b/src/main/java/org/atdl4j/fixatdl/layout/RadioButtonListT.java index f7385f5..1d11ea0 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/RadioButtonListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/RadioButtonListT.java @@ -77,7 +77,7 @@ public class RadioButtonListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/SingleSelectListT.java b/src/main/java/org/atdl4j/fixatdl/layout/SingleSelectListT.java index 4a63d7e..1b8636c 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/SingleSelectListT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/SingleSelectListT.java @@ -74,7 +74,7 @@ public class SingleSelectListT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/SliderT.java b/src/main/java/org/atdl4j/fixatdl/layout/SliderT.java index c1ba9b5..ef691ad 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/SliderT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/SliderT.java @@ -74,7 +74,7 @@ public class SliderT */ public List getListItem() { if (listItem == null) { - listItem = new ArrayList(); + listItem = new ArrayList<>(); } return this.listItem; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/StrategyLayoutT.java b/src/main/java/org/atdl4j/fixatdl/layout/StrategyLayoutT.java index b055cd1..dcf369f 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/StrategyLayoutT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/StrategyLayoutT.java @@ -68,7 +68,7 @@ public class StrategyLayoutT { */ public List getStrategyPanel() { if (strategyPanel == null) { - strategyPanel = new ArrayList(); + strategyPanel = new ArrayList<>(); } return this.strategyPanel; } diff --git a/src/main/java/org/atdl4j/fixatdl/layout/StrategyPanelT.java b/src/main/java/org/atdl4j/fixatdl/layout/StrategyPanelT.java index a24489d..3f4928e 100644 --- a/src/main/java/org/atdl4j/fixatdl/layout/StrategyPanelT.java +++ b/src/main/java/org/atdl4j/fixatdl/layout/StrategyPanelT.java @@ -91,7 +91,7 @@ public class StrategyPanelT { */ public List getStrategyPanel() { if (strategyPanel == null) { - strategyPanel = new ArrayList(); + strategyPanel = new ArrayList<>(); } return this.strategyPanel; } @@ -120,7 +120,7 @@ public List getStrategyPanel() { */ public List getControl() { if (control == null) { - control = new ArrayList(); + control = new ArrayList<>(); } return this.control; } diff --git a/src/main/java/org/atdl4j/fixatdl/regions/ObjectFactory.java b/src/main/java/org/atdl4j/fixatdl/regions/ObjectFactory.java index e2dccd5..dd2afbe 100644 --- a/src/main/java/org/atdl4j/fixatdl/regions/ObjectFactory.java +++ b/src/main/java/org/atdl4j/fixatdl/regions/ObjectFactory.java @@ -31,9 +31,9 @@ @XmlRegistry public class ObjectFactory { - private final static QName _TheAmericas_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "TheAmericas"); - private final static QName _AsiaPacificJapan_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "AsiaPacificJapan"); - private final static QName _EuropeMiddleEastAfrica_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "EuropeMiddleEastAfrica"); + private static final QName _TheAmericas_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "TheAmericas"); + private static final QName _AsiaPacificJapan_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "AsiaPacificJapan"); + private static final QName _EuropeMiddleEastAfrica_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Regions", "EuropeMiddleEastAfrica"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.atdl4j.fixatdl.regions @@ -48,7 +48,7 @@ public ObjectFactory() { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Regions", name = "TheAmericas") public JAXBElement createTheAmericas(TheAmericas value) { - return new JAXBElement(_TheAmericas_QNAME, TheAmericas.class, null, value); + return new JAXBElement<>(_TheAmericas_QNAME, TheAmericas.class, null, value); } /** @@ -57,7 +57,7 @@ public JAXBElement createTheAmericas(TheAmericas value) { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Regions", name = "AsiaPacificJapan") public JAXBElement createAsiaPacificJapan(AsiaPacificJapan value) { - return new JAXBElement(_AsiaPacificJapan_QNAME, AsiaPacificJapan.class, null, value); + return new JAXBElement<>(_AsiaPacificJapan_QNAME, AsiaPacificJapan.class, null, value); } /** @@ -66,7 +66,7 @@ public JAXBElement createAsiaPacificJapan(AsiaPacificJapan val */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Regions", name = "EuropeMiddleEastAfrica") public JAXBElement createEuropeMiddleEastAfrica(EuropeMiddleEastAfrica value) { - return new JAXBElement(_EuropeMiddleEastAfrica_QNAME, EuropeMiddleEastAfrica.class, null, value); + return new JAXBElement<>(_EuropeMiddleEastAfrica_QNAME, EuropeMiddleEastAfrica.class, null, value); } } diff --git a/src/main/java/org/atdl4j/fixatdl/validation/EditT.java b/src/main/java/org/atdl4j/fixatdl/validation/EditT.java index 9643f29..9373f78 100644 --- a/src/main/java/org/atdl4j/fixatdl/validation/EditT.java +++ b/src/main/java/org/atdl4j/fixatdl/validation/EditT.java @@ -121,7 +121,7 @@ public void setDescription(String value) { */ public List getEdit() { if (edit == null) { - edit = new ArrayList(); + edit = new ArrayList<>(); } return this.edit; } @@ -150,7 +150,7 @@ public List getEdit() { */ public List getEditRef() { if (editRef == null) { - editRef = new ArrayList(); + editRef = new ArrayList<>(); } return this.editRef; } diff --git a/src/main/java/org/atdl4j/fixatdl/validation/ObjectFactory.java b/src/main/java/org/atdl4j/fixatdl/validation/ObjectFactory.java index aca76d5..d958eb7 100644 --- a/src/main/java/org/atdl4j/fixatdl/validation/ObjectFactory.java +++ b/src/main/java/org/atdl4j/fixatdl/validation/ObjectFactory.java @@ -31,9 +31,9 @@ @XmlRegistry public class ObjectFactory { - private final static QName _StrategyEdit_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "StrategyEdit"); - private final static QName _EditRef_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "EditRef"); - private final static QName _Edit_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "Edit"); + private static final QName _StrategyEdit_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "StrategyEdit"); + private static final QName _EditRef_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "EditRef"); + private static final QName _Edit_QNAME = new QName("http://www.fixprotocol.org/FIXatdl-1-1/Validation", "Edit"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.atdl4j.fixatdl.validation @@ -72,7 +72,7 @@ public StrategyEditT createStrategyEditT() { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Validation", name = "StrategyEdit") public JAXBElement createStrategyEdit(StrategyEditT value) { - return new JAXBElement(_StrategyEdit_QNAME, StrategyEditT.class, null, value); + return new JAXBElement<>(_StrategyEdit_QNAME, StrategyEditT.class, null, value); } /** @@ -81,7 +81,7 @@ public JAXBElement createStrategyEdit(StrategyEditT value) { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Validation", name = "EditRef") public JAXBElement createEditRef(EditRefT value) { - return new JAXBElement(_EditRef_QNAME, EditRefT.class, null, value); + return new JAXBElement<>(_EditRef_QNAME, EditRefT.class, null, value); } /** @@ -90,7 +90,7 @@ public JAXBElement createEditRef(EditRefT value) { */ @XmlElementDecl(namespace = "http://www.fixprotocol.org/FIXatdl-1-1/Validation", name = "Edit") public JAXBElement createEdit(EditT value) { - return new JAXBElement(_Edit_QNAME, EditT.class, null, value); + return new JAXBElement<>(_Edit_QNAME, EditT.class, null, value); } } diff --git a/src/main/java/org/atdl4j/ui/StrategiesUI.java b/src/main/java/org/atdl4j/ui/StrategiesUI.java index 168fef1..7814506 100644 --- a/src/main/java/org/atdl4j/ui/StrategiesUI.java +++ b/src/main/java/org/atdl4j/ui/StrategiesUI.java @@ -18,7 +18,7 @@ public interface StrategiesUI { public Object buildStrategiesPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions, Atdl4jUserMessageHandler aAtdl4jUserMessageHandler); - public void createStrategyPanels(StrategiesT strategies, List aFilteredStrategyList) throws FIXatdlFormatException; // throws Exception; + public void createStrategyPanels(StrategiesT strategies, List aFilteredStrategyList) throws FIXatdlFormatException; public void removeAllStrategyPanels(); @@ -37,10 +37,9 @@ public interface StrategiesUI { public void removeWidgetListener(AtdlWidgetListener listener); public void setVisible( boolean aVisible ); - -// 12/15/2010 Scott Atwell public StrategyUI getStrategyUI( StrategyT aStrategy ); + public StrategyUI getStrategyUI( StrategyT aStrategy, boolean aReinitPanelFlag ); - + public StrategyUI getCurrentlyDisplayedStrategyUI(); public StrategyT getCurrentlyDisplayedStrategy(); } diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jCompositePanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jCompositePanel.java index cdc13a5..5bb852d 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jCompositePanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jCompositePanel.java @@ -5,20 +5,19 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; -import java.util.Vector; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.InputAndFilterData; import org.atdl4j.data.Atdl4jConstants; import org.atdl4j.data.Atdl4jHelper; -import org.atdl4j.data.exception.Atdl4jClassLoadException; import org.atdl4j.data.exception.FIXatdlFormatException; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.data.fix.FIXMessageParser; @@ -47,12 +46,12 @@ public abstract class AbstractAtdl4jCompositePanel implements Atdl4jCompositePanel, StrategySelectionPanelListener { - public final Logger logger = Logger.getLogger(AbstractAtdl4jCompositePanel.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractAtdl4jCompositePanel.class); Atdl4jOptions atdl4jOptions; Object parentOrShell; // SWT: Shell, Swing: JFrame, JDialog etc - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); private String lastFixatdlFilename; @@ -68,8 +67,8 @@ public abstract class AbstractAtdl4jCompositePanel private StrategyEventListener strategyEventListener; - abstract public void setVisibleOkCancelButtonSection( boolean aVisible ); - abstract protected void packLayout(); + public abstract void setVisibleOkCancelButtonSection( boolean aVisible ); + protected abstract void packLayout(); // 12/8/2010 Scott Atwell added List lastFilteredStrategyList = null; @@ -221,13 +220,13 @@ public StrategyT validateStrategyWithoutCatchingAllExceptions() throws Validatio setSelectedStrategyValidated( false ); - logger.debug("Validating strategy " + tempSelectedStrategy.getName()); + logger.debug("Validating strategy {}", tempSelectedStrategy.getName()); // -- (aPerformValidationFlag = true) -- SelectedStrategyDetails tempSelectedStrategyDetails = getSelectedStrategyDetails( true ); String tempUiFixMsg = tempSelectedStrategyDetails.getFixMsgFragment(); setSelectedStrategyValidated( true ); - logger.debug("Successfully Validated strategy " + tempSelectedStrategy.getName() + " FIXMessage: " + tempUiFixMsg ); + logger.debug("Successfully Validated strategy {} FIXMessage: {}", tempSelectedStrategy.getName(), tempUiFixMsg ); // -- Notify StrategyEventListener (eg Atdl4jTesterPanel) -- fireStrategyEventListenerStrategyValidated( tempSelectedStrategy, tempSelectedStrategyDetails ); @@ -308,7 +307,7 @@ public void parseFixatdlFile( String aFilename ) throws FIXatdlFormatException public void validateParsedFixatdlFileContents( StrategiesT aStrategies ) throws FIXatdlFormatException { - List tempStrategyNameList = new ArrayList(); + List tempStrategyNameList = new ArrayList<>(); for ( StrategyT tempStrategy : aStrategies.getStrategy() ) { @@ -333,8 +332,6 @@ public void validateParsedFixatdlFileContents( StrategiesT aStrategies ) /** * Can be invoked/re-invoked at anytime provided that parseFixatdlFile() has successfully parsed the * FIXatdl file contents into Atdl4jOptions().setStrategies(). Re-generates the display. - * @throws Atdl4jClassLoadException - * @throws FIXatdlFormatException */ public void loadScreenWithFilteredStrategies() { @@ -344,9 +341,7 @@ public void loadScreenWithFilteredStrategies() /** * Can be invoked/re-invoked at anytime provided that parseFixatdlFile() has successfully parsed the * FIXatdl file contents into Atdl4jOptions().setStrategies(). Re-generates the display. - * @throws Atdl4jClassLoadException - * @throws FIXatdlFormatException - * @parm aSelectStrategyName + * @param aSelectStrategyName */ public void loadScreenWithFilteredStrategies( String aSelectStrategyName ) { @@ -441,13 +436,13 @@ public void loadScreenWithFilteredStrategies( String aSelectStrategyName ) public boolean loadFixMessage( String aFixMessage ) { - logger.debug("Loading FIX string " + aFixMessage); + logger.debug("Loading FIX string {}", aFixMessage); if ( ( getAtdl4jOptions().getInputAndFilterData() != null ) && ( getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName() != null ) ) { - logger.debug("getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName(): " + getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName()); - logger.debug("Invoking selectDropDownStrategy: " + getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName() ); + logger.debug("getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName(): {}", getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName()); + logger.debug("Invoking selectDropDownStrategy: {}", getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName() ); getStrategySelectionPanel().selectDropDownStrategyByStrategyName( getAtdl4jOptions().getInputAndFilterData().getInputSelectStrategyName() ); } else // Match getWireValue() and then use getUiRep() if avail, otherwise getName() @@ -456,10 +451,10 @@ public boolean loadFixMessage( String aFixMessage ) { String strategyWireValue = FIXMessageParser.extractFieldValueFromFIXMessage( aFixMessage, getStrategies().getStrategyIdentifierTag().intValue() ); - logger.debug("strategyWireValue: " + strategyWireValue); + logger.debug("strategyWireValue: {}", strategyWireValue); if ( strategyWireValue != null ) { - logger.debug("Invoking selectDropDownStrategy for strategyWireValue: " + strategyWireValue ); + logger.debug("Invoking selectDropDownStrategy for strategyWireValue: {}", strategyWireValue ); getStrategySelectionPanel().selectDropDownStrategyByStrategyWireValue( strategyWireValue ); } @@ -479,7 +474,7 @@ public boolean loadFixMessage( String aFixMessage ) // -- Note available getStrategies() may be filtered due to SecurityTypes, Markets, or Region/Country rules -- if ( ui != null ) { - logger.debug( "Invoking ui.setFIXMessage() for: " + ui.getStrategy().getName() + " with FIX Message: " + aFixMessage ); + logger.debug( "Invoking ui.setFIXMessage() for: {} with FIX Message: {}", ui.getStrategy().getName(), aFixMessage ); ui.setFIXMessage(aFixMessage); logger.debug( "FIX string loaded successfully!" ); @@ -493,25 +488,6 @@ public boolean loadFixMessage( String aFixMessage ) fireStrategyEventListenerStrategyNotValidated( getSelectedStrategy(), getSelectedStrategy().getName() + " is not available." ); return false; } -// catch (ValidationException ex) -// { -// getAtdl4jUserMessageHandler().displayException( "Validation Exception", "", ex ); -// logger.debug( "Validation Exception:", ex ); -// -// // -- Notify StrategyEventListener (eg Atdl4jTesterPanel) -- -// fireStrategyEventListenerStrategyValidationFailed( getSelectedStrategy(), ex ); -// return false; -// } -// catch (Exception ex) -// { -// getAtdl4jUserMessageHandler().displayException( "Exception", "", ex ); -// logger.warn( "Generic Exception", ex ); -// -// // -- Notify StrategyEventListener (eg Atdl4jTesterPanel) -- -// fireStrategyEventListenerStrategyNotValidated( getSelectedStrategy(), "" ); -// return false; -// } - } /** * @param lastFixatdlFilename the lastFixatdlFilename to set @@ -591,13 +567,13 @@ public List getStrategiesFilteredStrategyList() return getStrategies().getStrategy(); } - List tempFilteredList = new ArrayList(); + List tempFilteredList = new ArrayList<>(); for ( StrategyT strategy : getStrategies().getStrategy() ) { if ( ! getAtdl4jOptions().getInputAndFilterData().isStrategySupported( strategy ) ) { - logger.debug("Excluding strategy: " + strategy.getName() + " as inputAndFilterData.isStrategySupported() returned false." ); + logger.debug("Excluding strategy: {} as inputAndFilterData.isStrategySupported() returned false.", strategy.getName() ); continue; // skip it } @@ -639,7 +615,6 @@ public boolean isSelectedStrategyValidated() /** * @return the StrategyDescriptionPanel - * @throws Atdl4jClassLoadException */ public StrategyDescriptionPanel getStrategyDescriptionPanel() { @@ -652,7 +627,6 @@ public StrategyDescriptionPanel getStrategyDescriptionPanel() /** * @return the StrategySelectionPanel - * @throws Atdl4jClassLoadException */ public StrategySelectionPanel getStrategySelectionPanel() { @@ -665,7 +639,6 @@ public StrategySelectionPanel getStrategySelectionPanel() /** * @return - * @throws Atdl4jClassLoadException */ public StrategiesUI getStrategiesUI() { @@ -679,7 +652,6 @@ public StrategiesUI getStrategiesUI() /** * @return the Atdl4jUserMessageHandler - * @throws Atdl4jClassLoadException */ public Atdl4jUserMessageHandler getAtdl4jUserMessageHandler() { @@ -699,7 +671,6 @@ public void setAtdl4jUserMessageHandler(Atdl4jUserMessageHandler atdl4jUserMessa /** * @param parentOrShell - * @throws Atdl4jClassLoadException */ public void initAtdl4jUserMessageHandler( Object parentOrShell ) { @@ -826,7 +797,7 @@ protected boolean isMatchingStrategyList( List aStrategyList1, List aStrategyList1, List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); protected void init( Object aParentOrShell, Atdl4jOptions aAtdl4jOptions ) { diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jInputAndFilterDataSelectionPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jInputAndFilterDataSelectionPanel.java index ff0eb78..bec9142 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jInputAndFilterDataSelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jInputAndFilterDataSelectionPanel.java @@ -4,13 +4,12 @@ */ package org.atdl4j.ui.app.impl; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.InputAndFilterData; -import org.atdl4j.data.exception.Atdl4jClassLoadException; import org.atdl4j.ui.app.Atdl4jInputAndFilterDataPanel; import org.atdl4j.ui.app.Atdl4jInputAndFilterDataPanelListener; import org.atdl4j.ui.app.Atdl4jInputAndFilterDataSelectionPanel; @@ -31,7 +30,7 @@ public abstract class AbstractAtdl4jInputAndFilterDataSelectionPanel private Atdl4jInputAndFilterDataPanel atdl4jInputAndFilterDataPanel; - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); private Atdl4jUserMessageHandler atdl4jUserMessageHandler; @@ -117,7 +116,6 @@ public void inputAndFilterDataSpecified(InputAndFilterData aInputAndFilterData) /** * @return the Atdl4jInputAndFilterDataPanel - * @throws Atdl4jClassLoadException */ public Atdl4jInputAndFilterDataPanel getAtdl4jInputAndFilterDataPanel() { diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterApp.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterApp.java index 2004f68..084648b 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterApp.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterApp.java @@ -3,7 +3,6 @@ import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jConfiguration; import org.atdl4j.config.Atdl4jOptions; -import org.atdl4j.data.exception.Atdl4jClassLoadException; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.ui.app.Atdl4jTesterPanel; import org.atdl4j.ui.app.Atdl4jTesterPanelListener; @@ -25,51 +24,6 @@ public abstract class AbstractAtdl4jTesterApp Atdl4jTesterPanel atdl4jTesterPanel; - private void parseMainLineArgs( String[] args ) - { -//TODO -/*** - // Load in a file if passed into the app arguments - if (args.length > 0) { - try { -//TODO 1/18/2010 Scott Atwell added BELOW -// getAtdl4jOptions().getInputAndFilterData().init(); - - if (args.length >= 2) - { - // -- InputCxlReplaceMode = args[1] (eg "true" or "false") - logger.info("args[1]: " + args[1] + " Boolean.parseBoolean() as inputCxlReplaceMode"); - getAtdl4jOptions().getInputAndFilterData().setInputCxlReplaceMode( Boolean.parseBoolean( args[1] ) ); - } - - if ( args.length >= 3) - { - // -- InputHiddenFieldNameValueMap = args[2] (eg "FIX_OrderQty=10000|FIX_Side=1|FIX_OrdType=1") - String tempStringToParse = args[2]; - logger.info("args[2]: " + tempStringToParse + " parse as InputHiddenFieldNameValueMap (eg \"FIX_OrderQty=10000|FIX_Side=1|FIX_OrdType=1\")"); - String[] tempFieldAndValuesArray = tempStringToParse.split( "\\|" ); - if ( tempFieldAndValuesArray != null ) - { - Map tempInputHiddenFieldNameValueMap = new HashMap(); - for (String tempFieldAndValue : tempFieldAndValuesArray ) - { - String[] tempCombo = tempFieldAndValue.split( "=" ); - if ( ( tempCombo != null ) && ( tempCombo.length == 2 ) ) - { - tempInputHiddenFieldNameValueMap.put( tempCombo[0], tempCombo[1] ); - } - } - - logger.info("InputHiddenFieldNameValueMap: " + tempInputHiddenFieldNameValueMap); - getAtdl4jOptions().getInputAndFilterData().addMapToInputHiddenFieldNameValueMap( tempInputHiddenFieldNameValueMap ); - } - } -//TODO 1/18/2010 Scott Atwell added ABOVE - -****/ - } - - protected void init( String[] args, Atdl4jConfiguration aAtdl4jConfiguration, Atdl4jOptions aAtdl4jOptions, Object aParentOrShell ) { Atdl4jConfig.setConfig( aAtdl4jConfiguration ); @@ -77,8 +31,6 @@ protected void init( String[] args, Atdl4jConfiguration aAtdl4jConfiguration, At setAtdl4jOptions( aAtdl4jOptions ); setParentOrShell( aParentOrShell ); - parseMainLineArgs( args ); - // -- ** Construct the core GUI component ** -- setAtdl4jTesterPanel( getAtdl4jTesterPanel() ); } @@ -94,7 +46,7 @@ public static Atdl4jOptions getAtdl4jOptions() /** * @param aAtdl4jOptions the atdl4jOptions to set */ - private void setAtdl4jOptions(Atdl4jOptions aAtdl4jOptions) + private static void setAtdl4jOptions(Atdl4jOptions aAtdl4jOptions) { atdl4jOptions = aAtdl4jOptions; } @@ -126,7 +78,6 @@ private void setAtdl4jTesterPanel(Atdl4jTesterPanel aAtdl4jTesterPanel) /** * @return the Atdl4jTesterPanel - * @throws Atdl4jClassLoadException */ public Atdl4jTesterPanel getAtdl4jTesterPanel() { diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterPanel.java index ef8964c..459bcc1 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jTesterPanel.java @@ -1,13 +1,13 @@ package org.atdl4j.ui.app.impl; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.InputAndFilterData; -import org.atdl4j.data.exception.Atdl4jClassLoadException; import org.atdl4j.data.exception.FIXatdlFormatException; import org.atdl4j.data.exception.ValidationException; import org.atdl4j.fixatdl.core.StrategyT; @@ -41,7 +41,7 @@ public abstract class AbstractAtdl4jTesterPanel FixatdlFileSelectionPanelListener, StrategyEventListener { - private final Logger logger = Logger.getLogger(AbstractAtdl4jTesterPanel.class); + private final Logger logger = LoggerFactory.getLogger(AbstractAtdl4jTesterPanel.class); Atdl4jOptions atdl4jOptions; Object parentOrShell; // SWT: Shell, Swing: JFrame, JDialog, etc @@ -51,14 +51,14 @@ public abstract class AbstractAtdl4jTesterPanel private FixatdlFileSelectionPanel fixatdlFileSelectionPanel; private FixMsgLoadPanel fixMsgLoadPanel; - abstract protected Object createValidateOutputSection(); - abstract protected void setValidateOutputText(String aText); + protected abstract Object createValidateOutputSection(); + protected abstract void setValidateOutputText(String aText); private Atdl4jCompositePanel atdl4jCompositePanel; - abstract public void setVisibleValidateOutputSection( boolean aVisible ); - abstract public void setVisibleFileSelectionSection( boolean aVisible ); - abstract public void setVisibleTestingInputSection( boolean aVisible ); - private List listenerList = new Vector(); + public abstract void setVisibleValidateOutputSection( boolean aVisible ); + public abstract void setVisibleFileSelectionSection( boolean aVisible ); + public abstract void setVisibleTestingInputSection( boolean aVisible ); + private List listenerList = new ArrayList<>(); protected void init( Object aParentOrShell, Atdl4jOptions aAtdl4jOptions ) @@ -124,7 +124,7 @@ private void setAtdl4jCompositePanel(Atdl4jCompositePanel aAtdl4jCompositePanel) } /** - * @param atdl4jInputAndFilterDataSelectionPanel the atdl4jInputAndFilterDataSelectionPanel to set + * @param aAtdl4jInputAndFilterDataSelectionPanel the atdl4jInputAndFilterDataSelectionPanel to set */ private void setAtdl4jInputAndFilterDataSelectionPanel(Atdl4jInputAndFilterDataSelectionPanel aAtdl4jInputAndFilterDataSelectionPanel) { @@ -198,7 +198,6 @@ private void setFixMsgLoadPanel(FixMsgLoadPanel fixMsgLoadPanel) /** * @return the Atdl4jInputAndFilterDataSelectionPanel - * @throws Atdl4jClassLoadException */ public Atdl4jInputAndFilterDataSelectionPanel getAtdl4jInputAndFilterDataSelectionPanel() { @@ -225,7 +224,6 @@ public Atdl4jCompositePanel getAtdl4jCompositePanel() /** * @return the FixMsgLoadPanel - * @throws Atdl4jClassLoadException */ public FixMsgLoadPanel getFixMsgLoadPanel() { @@ -275,7 +273,6 @@ protected void fixatdlFileSelectedNotCatchAllExceptions(String aFilename) /** * @return the FixatdlFileSelectionPanel - * @throws Atdl4jClassLoadException */ public FixatdlFileSelectionPanel getFixatdlFileSelectionPanel() { @@ -288,7 +285,6 @@ public FixatdlFileSelectionPanel getFixatdlFileSelectionPanel() /** * @return the Atdl4jUserMessageHandler - * @throws Atdl4jClassLoadException */ public Atdl4jUserMessageHandler getAtdl4jUserMessageHandler() { diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jUserMessageHandler.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jUserMessageHandler.java index ebac435..cd47244 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jUserMessageHandler.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractAtdl4jUserMessageHandler.java @@ -27,14 +27,7 @@ public abstract class AbstractAtdl4jUserMessageHandler */ public boolean isInitReqd() { - if ( atdl4jOptions != null ) - { - return false; - } - else - { - return true; - } + return atdl4jOptions == null; } /** @@ -58,7 +51,7 @@ public Atdl4jOptions getAtdl4jOptions() * Extracts the "message" value from Throwable. Handles JAXBException.getLinkedException().getMessage(). * * @param e - * @return + * @return String */ public static String extractExceptionMessage( Throwable e ) { diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractFixMsgLoadPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractFixMsgLoadPanel.java index c3e19d0..8b5fbbf 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractFixMsgLoadPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractFixMsgLoadPanel.java @@ -1,7 +1,7 @@ package org.atdl4j.ui.app.impl; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.FixMsgLoadPanel; @@ -18,7 +18,7 @@ public abstract class AbstractFixMsgLoadPanel { private Atdl4jOptions atdl4jOptions = null; - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); /** diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractFixatdlFileSelectionPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractFixatdlFileSelectionPanel.java index b345d11..bbda562 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractFixatdlFileSelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractFixatdlFileSelectionPanel.java @@ -1,9 +1,10 @@ package org.atdl4j.ui.app.impl; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.exception.FIXatdlFormatException; @@ -19,11 +20,11 @@ public abstract class AbstractFixatdlFileSelectionPanel implements FixatdlFileSelectionPanel { - private final Logger logger = Logger.getLogger(AbstractFixatdlFileSelectionPanel.class); + private final Logger logger = LoggerFactory.getLogger(AbstractFixatdlFileSelectionPanel.class); private Atdl4jOptions atdl4jOptions = null; - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); /** @@ -56,15 +57,20 @@ public void removeListener( FixatdlFileSelectionPanelListener aFixatdlFileSelect protected void fireFixatdlFileSelectedEvent( String aFilename ) { - try { - for ( FixatdlFileSelectionPanelListener tempListener : listenerList ) + try { - tempListener.fixatdlFileSelected( aFilename ); + for ( FixatdlFileSelectionPanelListener tempListener : listenerList ) + { + tempListener.fixatdlFileSelected( aFilename ); + } + } + catch (FIXatdlFormatException ex) + { + logger.info( "FIXatdlFormatException occured while loading file: {}", aFilename ); + if (Atdl4jConfig.getConfig().isThrowEventRuntimeExceptions()) + { + throw new RuntimeException("FIXatdlFormatException while loading file: " + aFilename, ex); + } } - } catch (FIXatdlFormatException ex) { - logger.info( "FIXatdlFormatException occured while loading file: " + aFilename ); - if (Atdl4jConfig.getConfig().isThrowEventRuntimeExceptions()) - throw new RuntimeException("FIXatdlFormatException while loading file: " + aFilename, ex); - } } } diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategyDescriptionPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategyDescriptionPanel.java index 6c2126d..9725d29 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategyDescriptionPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategyDescriptionPanel.java @@ -17,7 +17,7 @@ public abstract class AbstractStrategyDescriptionPanel { private Atdl4jOptions atdl4jOptions = null; - abstract protected void setStrategyDescriptionText( String aText ); + protected abstract void setStrategyDescriptionText( String aText ); /* * Loads aStrategy.getDescription() if populated and if Atdl4jOptions.isShowStrategyDescription(), diff --git a/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategySelectionPanel.java b/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategySelectionPanel.java index c543164..df2e10e 100644 --- a/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategySelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/app/impl/AbstractStrategySelectionPanel.java @@ -4,10 +4,11 @@ */ package org.atdl4j.ui.app.impl; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.fixatdl.core.StrategyT; import org.atdl4j.ui.app.StrategySelectionPanel; @@ -23,11 +24,11 @@ public abstract class AbstractStrategySelectionPanel implements StrategySelectionPanel { - public final Logger logger = Logger.getLogger(AbstractStrategySelectionPanel.class); + public static final Logger logger = LoggerFactory.getLogger(AbstractStrategySelectionPanel.class); private Atdl4jOptions atdl4jOptions = null; - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); private List strategiesList; diff --git a/src/main/java/org/atdl4j/ui/impl/AbstractAtdl4jWidget.java b/src/main/java/org/atdl4j/ui/impl/AbstractAtdl4jWidget.java index f27956a..fdcfe16 100644 --- a/src/main/java/org/atdl4j/ui/impl/AbstractAtdl4jWidget.java +++ b/src/main/java/org/atdl4j/ui/impl/AbstractAtdl4jWidget.java @@ -2,7 +2,8 @@ import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.InputAndFilterData; import org.atdl4j.data.Atdl4jConstants; @@ -37,7 +38,7 @@ public abstract class AbstractAtdl4jWidget> implements Atdl4jWidget { - private final Logger logger = Logger.getLogger( AbstractAtdl4jWidget.class ); + private final Logger logger = LoggerFactory.getLogger( AbstractAtdl4jWidget.class ); protected ParameterT parameter; protected ControlT control; @@ -66,7 +67,7 @@ public void init(ControlT aControl, ParameterT aParameter, Atdl4jOptions aAtdl4j if ( parameter != null ) { - parameterConverter = (ParameterTypeConverter) TypeConverterFactoryConfig.getTypeConverterFactory().createParameterTypeConverter( parameter ); + parameterConverter = TypeConverterFactoryConfig.getTypeConverterFactory().createParameterTypeConverter( parameter ); } // -- Pass parameterConverter (which may be null if parameter is null) -- @@ -285,7 +286,7 @@ && getParameter().getFixTag().intValue()!= Atdl4jConstants.TAG_STRATEGY_PARAMETE && getParameter().getFixTag().intValue()!= Atdl4jConstants.TAG_STRATEGY_PARAMETER_TYPE && getParameter().getFixTag().intValue()!= Atdl4jConstants.TAG_STRATEGY_PARAMETER_VALUE) { - builder.onField( getParameter().getFixTag().intValue(), value.toString() ); + builder.onField( getParameter().getFixTag().intValue(), value ); } else { @@ -299,7 +300,7 @@ && getParameter().getFixTag().intValue()!= Atdl4jConstants.TAG_STRATEGY_PARAMETE String type = Integer.toString( getFIXType() ); builder.onField( Atdl4jConstants.TAG_STRATEGY_PARAMETER_NAME, name ); builder.onField( Atdl4jConstants.TAG_STRATEGY_PARAMETER_TYPE, type ); - builder.onField( Atdl4jConstants.TAG_STRATEGY_PARAMETER_VALUE, value.toString() ); + builder.onField( Atdl4jConstants.TAG_STRATEGY_PARAMETER_VALUE, value ); } } } @@ -322,9 +323,9 @@ else if ( control instanceof RadioButtonT || control instanceof CheckBoxT ) { // validate checkedEnumRef and uncheckedEnumRef } - else if ( listItems == null || listItems.size() == 0 ) + else if ( listItems == null || listItems.isEmpty() ) { - if ( enumPairs != null && enumPairs.size() > 0 ) + if ( enumPairs != null && !enumPairs.isEmpty() ) { throw new IllegalArgumentException( "Parameter \"" + parameter.getName() + "\" has EnumPairs but Control \"" + control.getID() + "\" does not have ListItems." ); @@ -385,7 +386,7 @@ protected String getParameterValueAsEnumWireValue() // values to ParameterValues protected String getParameterValueAsMultipleValueString() { - String value = ""; + StringBuilder tmpStringBuilder = new StringBuilder(""); if ( getControlValue() != null ) { String enumIDs = getControlValue().toString(); @@ -393,18 +394,18 @@ protected String getParameterValueAsMultipleValueString() { for ( String enumID : enumIDs.split( "\\s" ) ) { - if ( "".equals( value ) ) + if ( tmpStringBuilder.toString().isEmpty() ) { - value += getEnumWireValue( enumID ); + tmpStringBuilder.append( getEnumWireValue( enumID ) ); } else { - value += " " + getEnumWireValue( enumID ); + tmpStringBuilder.append( " " ).append( getEnumWireValue( enumID ) ); } } } } - return "".equals( value ) ? null : value; + return tmpStringBuilder.toString().isEmpty() ? null : tmpStringBuilder.toString(); } // Helper method to get control ListItems @@ -440,9 +441,6 @@ else if ( control instanceof SliderT ) } else { - // TODO: this should maybe throw a runtime error??? - // return an empty list - // return new Vector(); return null; } } @@ -484,18 +482,19 @@ public boolean isNullValue() { // -- Special logic to treat non-visible and/or non-enabled as "null" // if nullValue is false -- - if ( getAtdl4jOptions() != null ) { if (isVisible()) { if (isControlExcludingLabelEnabled()){ return false; - } else if (getAtdl4jOptions().isTreatControlEnabledFalseAsNull()) + } + else if (getAtdl4jOptions().isTreatControlEnabledFalseAsNull()) { return true; } - } else if (getAtdl4jOptions().isTreatControlVisibleFalseAsNull()) + } + else if (getAtdl4jOptions().isTreatControlVisibleFalseAsNull()) { return true; } @@ -517,7 +516,7 @@ public Boolean getNullValue() /** * */ - abstract protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd); + protected abstract void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd); /** @@ -531,8 +530,8 @@ public void setNullValue(Boolean aNullValue) // -- Assign the value -- this.nullValue = aNullValue; - logger.debug( "setNullValue() control ID:" + getControl().getID() + " tempPreExistingNullValue: " + tempPreExistingNullValue + " aNullValue: " - + aNullValue ); + logger.debug( "setNullValue() control ID: {} tempPreExistingNullValue: {} aNullValue: {}" + , getControl().getID(), tempPreExistingNullValue, aNullValue ); // -- Check to see if aNullValue provided is different than the // pre-existing value -- @@ -544,8 +543,8 @@ public void setNullValue(Boolean aNullValue) if ( ( ( tempPreExistingNullValue == null ) || ( Boolean.FALSE.equals( tempPreExistingNullValue ) ) ) && ( Boolean.TRUE.equals( aNullValue ) ) ) { - logger.debug( "setNullValue() control ID:" + getControl().getID() + " tempPreExistingNullValue: " + tempPreExistingNullValue - + " aNullValue: " + aNullValue + " invoking setLastNonNullStateControlValueRaw( " + getControlValueRaw() + " )" ); + logger.debug( "setNullValue() control ID: {} tempPreExistingNullValue: {} aNullValue: {} invoking setLastNonNullStateControlValueRaw( {} )" + , getControl().getID(), tempPreExistingNullValue, aNullValue, getControlValueRaw() ); setLastNonNullStateControlValueRaw( getControlValueRaw() ); } @@ -554,16 +553,13 @@ public void setNullValue(Boolean aNullValue) // -- "restore" the Control's raw value if so configured when going // from aNullValue of true to non-null -- - if ( ( Boolean.FALSE.equals( aNullValue ) ) && ( getLastNonNullStateControlValueRaw() != null ) ) + if ( ( Boolean.FALSE.equals( aNullValue ) ) + && ( getLastNonNullStateControlValueRaw() != null ) + && ( getAtdl4jOptions().isRestoreLastNonNullStateControlValueBehavior() ) ) { - if ( getAtdl4jOptions().isRestoreLastNonNullStateControlValueBehavior() ) - { - logger - .debug( "setNullValue() control ID:" + getControl().getID() + " tempPreExistingNullValue: " + tempPreExistingNullValue - + " aNullValue: " + aNullValue + " invoking restoreLastNonNullStateControlValue( " + getLastNonNullStateControlValueRaw() - + " )" ); - restoreLastNonNullStateControlValue( getLastNonNullStateControlValueRaw() ); - } + logger.debug( "setNullValue() control ID: {} tempPreExistingNullValue: {} aNullValue: {} invoking restoreLastNonNullStateControlValue( {} )" + , getControl().getID(), tempPreExistingNullValue, aNullValue, getControlValueRaw() ); + restoreLastNonNullStateControlValue( getLastNonNullStateControlValueRaw() ); } } } @@ -608,12 +604,12 @@ public void setFIXValue( String aFIXValue ) if ( ( tempValue == null ) && ( getNullValue() != null ) ) { - logger.debug( "setFIXValue: " + aFIXValue + " Parameter value: " + tempParameterValue + " Control value: " + tempValue + ". Setting Control.nullValue=TRUE." ); + logger.debug( "setFIXValue: {} Parameter value: {} Control value: {}. Setting Control.nullValue=TRUE.", aFIXValue, tempParameterValue, tempValue ); setNullValue( Boolean.TRUE ); } else { - logger.debug( "setFIXValue: " + aFIXValue + " Parameter value: " + tempParameterValue + " Control value: " + tempValue ); + logger.debug( "setFIXValue: {} Parameter value: {} Control value: {}", aFIXValue, tempParameterValue, tempValue ); setNullValue( Boolean.FALSE ); } diff --git a/src/main/java/org/atdl4j/ui/impl/AbstractHiddenFieldWidget.java b/src/main/java/org/atdl4j/ui/impl/AbstractHiddenFieldWidget.java index d04b7e7..b5904e8 100644 --- a/src/main/java/org/atdl4j/ui/impl/AbstractHiddenFieldWidget.java +++ b/src/main/java/org/atdl4j/ui/impl/AbstractHiddenFieldWidget.java @@ -16,7 +16,7 @@ public abstract class AbstractHiddenFieldWidget * JAXBException { this.control = control; this.parameter = parameter; * this.setValue(getConstInitValue()); init(); } **/ - // -- Overriden -- + @Override protected void initPreCheck() { this.setValue( getConstInitValue() ); @@ -32,6 +32,7 @@ public String getControlValueRaw() return value; } + @Override public Object getParameterValue() { if ( ParameterHelper.getConstValue( parameter ) != null ) @@ -80,6 +81,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean /** * */ + @Override public void processConstValueHasBeenSet() { // -- no operation -- diff --git a/src/main/java/org/atdl4j/ui/impl/AbstractLabelWidget.java b/src/main/java/org/atdl4j/ui/impl/AbstractLabelWidget.java index c09b427..dcec654 100644 --- a/src/main/java/org/atdl4j/ui/impl/AbstractLabelWidget.java +++ b/src/main/java/org/atdl4j/ui/impl/AbstractLabelWidget.java @@ -10,7 +10,7 @@ public abstract class AbstractLabelWidget extends AbstractAtdl4jWidget { - // -- Overriden -- + @Override protected void initPreCheck() { this.parameter = null; @@ -26,6 +26,7 @@ public String getControlValueRaw() return null; // Labels cannot store values } + @Override public Object getParameterValue() { return null; // Labels cannot store values } @@ -41,6 +42,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean /** * */ + @Override public void processConstValueHasBeenSet() { // -- no operation -- diff --git a/src/main/java/org/atdl4j/ui/impl/AbstractStrategiesUI.java b/src/main/java/org/atdl4j/ui/impl/AbstractStrategiesUI.java index 9a5d34b..ed5a47f 100644 --- a/src/main/java/org/atdl4j/ui/impl/AbstractStrategiesUI.java +++ b/src/main/java/org/atdl4j/ui/impl/AbstractStrategiesUI.java @@ -7,9 +7,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Vector; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.ValidationRule; import org.atdl4j.fixatdl.core.StrategiesT; @@ -31,13 +31,13 @@ public abstract class AbstractStrategiesUI implements StrategiesUI { - protected static final Logger logger = Logger.getLogger( AbstractStrategiesUI.class ); + protected static final Logger logger = LoggerFactory.getLogger( AbstractStrategiesUI.class ); private Atdl4jOptions atdl4jOptions = null; - private List listenerList = new Vector(); + private List listenerList = new ArrayList<>(); - private List widgetListeners = new ArrayList(); + private List widgetListeners = new ArrayList<>(); private boolean preCached = false; diff --git a/src/main/java/org/atdl4j/ui/impl/AbstractStrategyUI.java b/src/main/java/org/atdl4j/ui/impl/AbstractStrategyUI.java index b5464ba..1a8ae38 100644 --- a/src/main/java/org/atdl4j/ui/impl/AbstractStrategyUI.java +++ b/src/main/java/org/atdl4j/ui/impl/AbstractStrategyUI.java @@ -6,7 +6,8 @@ import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.InputAndFilterData; @@ -49,13 +50,11 @@ /** * Base class for ValidationRule. - * - * @param */ public abstract class AbstractStrategyUI implements StrategyUI { - protected static final Logger logger = Logger.getLogger( AbstractStrategyUI.class ); + protected static final Logger logger = LoggerFactory.getLogger( AbstractStrategyUI.class ); protected Map parameterMap; @@ -73,53 +72,39 @@ public abstract class AbstractStrategyUI Atdl4jWidgetFactory atdl4jWidgetFactory; StrategyPanelHelper strategyPanelHelper; - abstract protected void buildAtdl4jWidgetMap( List aStrategyPanelList ) throws FIXatdlFormatException; - - // -- Note invoking this method may result in object construction as a result of down-casting its own map of a specific templatized instance of Atdl4jWidget -- - abstract public Map> getAtdl4jWidgetMap(); - - // -- Note invoking this method may result in object construction as a result of down-casting its own map of a specific templatized instance of Atdl4jWidget -- - abstract public Map> getAtdl4jWidgetWithParameterMap(); + protected abstract void buildAtdl4jWidgetMap( List aStrategyPanelList ) throws FIXatdlFormatException; // -- Used by init() -- - abstract protected void initBegin(Object parentContainer); - abstract protected void buildAtdl4jWidgetMap() throws FIXatdlFormatException; - abstract protected void createRadioGroups(); - abstract protected void buildAtdl4jWidgetWithParameterMap(); - abstract protected void attachGlobalStateRulesToControls() throws FIXatdlFormatException; - abstract protected void attachStateListenersToAllAtdl4jWidgets(); - abstract protected void initEnd(); - - abstract protected void addToAtdl4jWidgetMap( String aName, Atdl4jWidget aAtdl4jWidget ); - abstract protected void addToAtdl4jWidgetWithParameterMap( String aName, Atdl4jWidget aAtdl4jWidget ); - abstract protected void removeFromAtdl4jWidgetMap( String aName ); - abstract protected void removeFromAtdl4jWidgetWithParameterMap( String aName ); - abstract public void setCxlReplaceMode(boolean cxlReplaceMode); - abstract protected void fireStateListeners(); - abstract protected void fireStateListenersForAtdl4jWidget( Atdl4jWidget aAtdl4jWidget ); - abstract protected void fireLoadFixMessageStateListenersForAtdl4jWidget( Atdl4jWidget aAtdl4jWidget ); - - - abstract protected void applyRadioGroupRules(); + protected abstract void initBegin(Object parentContainer); + protected abstract void buildAtdl4jWidgetMap() throws FIXatdlFormatException; + protected abstract void createRadioGroups(); + protected abstract void buildAtdl4jWidgetWithParameterMap(); + protected abstract void attachGlobalStateRulesToControls() throws FIXatdlFormatException; + protected abstract void attachStateListenersToAllAtdl4jWidgets(); + protected abstract void initEnd(); + + protected abstract void addToAtdl4jWidgetMap( String aName, Atdl4jWidget aAtdl4jWidget ); + protected abstract void addToAtdl4jWidgetWithParameterMap( String aName, Atdl4jWidget aAtdl4jWidget ); + protected abstract void removeFromAtdl4jWidgetMap( String aName ); + protected abstract void removeFromAtdl4jWidgetWithParameterMap( String aName ); + protected abstract void fireStateListeners(); + protected abstract void fireStateListenersForAtdl4jWidget( Atdl4jWidget aAtdl4jWidget ); + protected abstract void fireLoadFixMessageStateListenersForAtdl4jWidget( Atdl4jWidget aAtdl4jWidget ); + + + protected abstract void applyRadioGroupRules(); /** * Standalone intializer * * @param strategy - * @param aStrategies - * @param aAtdl4jOptions (contains getStrategies()) - * @param strategiesRules + * @param options (contains getStrategies()) * @param parentContainer (should be swt.Composite) * @throws FIXatdlFormatException - * @throws Atdl4jClassLoadException */ public void init(StrategyT strategy, Atdl4jOptions options, Object parentContainer) throws FIXatdlFormatException { - init(strategy, - new StrategiesT(), - options, - new HashMap(), - parentContainer); + init(strategy, new StrategiesT(), options, new HashMap<>(), parentContainer); } /** @@ -257,7 +242,7 @@ protected void setStrategy(StrategyT aStrategy) */ protected Map buildParameters(StrategyT strategy) throws FIXatdlFormatException { - Map tempParameters = new HashMap(); + Map tempParameters = new HashMap<>(); // build parameters for ( ParameterT parameter : strategy.getParameter() ) @@ -410,7 +395,7 @@ else if ( parameter instanceof MultipleStringValueT ) */ protected Map buildGlobalAndLocalRuleMap(StrategyT strategy, Map strategiesRules) throws FIXatdlFormatException { - Map tempRuleMap = new HashMap( strategiesRules ); + Map tempRuleMap = new HashMap<>( strategiesRules ); // and add local rules for ( EditT edit : strategy.getEdit() ) @@ -445,14 +430,8 @@ protected Map buildGlobalAndLocalRuleMap(StrategyT strat { EditRefT editRef = se.getEditRef(); String id = editRef.getId(); - getStrategyRuleset().putRefRule( se, new ReferencedValidationRule( id ) ); // TODO: - // this - // line - // should - // be - // moved - // to - // RuleFactory? + // TODO: this line should be moved to RuleFactory? + getStrategyRuleset().putRefRule( se, new ReferencedValidationRule( id ) ); } } @@ -462,7 +441,7 @@ protected Map buildGlobalAndLocalRuleMap(StrategyT strat protected void checkForDuplicateControlIDs() throws FIXatdlFormatException { // -- Note getAtdl4jWidgetMap() constructs a new Map -- - Collection> tempAtdl4jWidgetMapValues = (Collection>) getAtdl4jWidgetMap().values(); + Collection> tempAtdl4jWidgetMapValues = getAtdl4jWidgetMap().values(); for ( Atdl4jWidget widget : tempAtdl4jWidgetMapValues ) { @@ -478,7 +457,7 @@ public Atdl4jWidget getAtdl4jWidgetForParameter( ParameterT aParameterRef ) { if ( ( aParameterRef != null ) && ( getAtdl4jWidgetWithParameterMap() != null ) ) { - Collection> tempAtdl4jWidgetWithParameterMapValues = (Collection>) getAtdl4jWidgetWithParameterMap().values(); + Collection> tempAtdl4jWidgetWithParameterMapValues = getAtdl4jWidgetWithParameterMap().values(); for ( Atdl4jWidget widget : tempAtdl4jWidgetWithParameterMapValues ) { @@ -581,7 +560,7 @@ public void validate() throws ValidationException } else { - logger.info( "No validation rule defined for strategy " + getStrategy().getName() ); + logger.info( "No validation rule defined for strategy {}", getStrategy().getName() ); } } @@ -605,7 +584,7 @@ public void getFIXMessage(FIXMessageBuilder builder) { if ( getStrategies().getStrategyIdentifierTag() != null ) { - builder.onField( getStrategies().getStrategyIdentifierTag().intValue(), strategyIdentifier.toString() ); + builder.onField( getStrategies().getStrategyIdentifierTag().intValue(), strategyIdentifier ); } else { @@ -620,22 +599,11 @@ public void getFIXMessage(FIXMessageBuilder builder) { if ( getStrategies().getVersionIdentifierTag() != null ) { - builder.onField( getStrategies().getVersionIdentifierTag().intValue(), strategyVersion.toString() ); + builder.onField( getStrategies().getVersionIdentifierTag().intValue(), strategyVersion ); } } } - /* - * TODO 2/1/2010 John Shields added Beginning of Repeating Group - * implementation. Currently there is an error in ATDL I believe where - * StrategyT can only have one RepeatingGroupT HashMap rgroups = new HashMap(); for - * (RepeatingGroupT rg : strategy.getRepeatingGroup()) { for (ParameterT - * rg : strategy.getRepeatingGroup()) { - * - * } } - */ - // -- Note that getAtdl4jWidgetMap() constructs a new Map -- for ( Atdl4jWidget control : getAtdl4jWidgetMap().values() ) { @@ -661,7 +629,7 @@ public void setFIXMessage(String fixMessage) int tag = Integer.parseInt( pair[ 0 ] ); String value = pair[ 1 ]; - logger.debug("setFIXMessage() i: " + i + " extracted tag: " + tag + " value: " + value ); + logger.debug("setFIXMessage() i: {} extracted tag: {} value: {}", i, tag, value ); // not repeating group if ( tag < Atdl4jConstants.TAG_NO_STRATEGY_PARAMETERS || tag > Atdl4jConstants.TAG_STRATEGY_PARAMETER_VALUE ) @@ -731,13 +699,13 @@ public void reinitStrategyPanel() for ( Atdl4jWidget tempAtdl4jWidget : getAtdl4jWidgetMap().values() ) { - logger.debug( "Invoking Atdl4jWidget.reinit() for: " + tempAtdl4jWidget.getControl().getID() ); + logger.debug( "Invoking Atdl4jWidget.reinit() for: {}", tempAtdl4jWidget.getControl().getID() ); tempAtdl4jWidget.reinit(); } // -- Set Strategy's CxlReplaceMode -- - setCxlReplaceMode( getAtdl4jOptions().getInputAndFilterData().getInputCxlReplaceMode() );; + setCxlReplaceMode( getAtdl4jOptions().getInputAndFilterData().getInputCxlReplaceMode() ); // -- Execute StateRules -- fireStateListeners(); diff --git a/src/main/java/org/atdl4j/ui/impl/BaseAtdl4jWidgetFactory.java b/src/main/java/org/atdl4j/ui/impl/BaseAtdl4jWidgetFactory.java index a0544b3..b052f7e 100644 --- a/src/main/java/org/atdl4j/ui/impl/BaseAtdl4jWidgetFactory.java +++ b/src/main/java/org/atdl4j/ui/impl/BaseAtdl4jWidgetFactory.java @@ -178,7 +178,6 @@ public Atdl4jOptions getAtdl4jOptions() * @param control * @param parameter * @return - * @throws Atdl4jClassLoadException */ public Atdl4jWidget createCheckBoxListT(CheckBoxListT control, ParameterT parameter) { @@ -193,7 +192,6 @@ public Atdl4jWidget createCheckBoxListT(CheckBoxListT control, ParameterT par * @param control * @param parameter * @return - * @throws Atdl4jClassLoadException */ public Atdl4jWidget createCheckBoxT(CheckBoxT control, ParameterT parameter) { @@ -208,7 +206,6 @@ public Atdl4jWidget createCheckBoxT(CheckBoxT control, ParameterT parameter) * @param control * @param parameter * @return - * @throws Atdl4jClassLoadException */ public Atdl4jWidget createClockT(ClockT control, ParameterT parameter) { @@ -223,7 +220,6 @@ public Atdl4jWidget createClockT(ClockT control, ParameterT parameter) * @param control * @param parameter * @return - * @throws Atdl4jClassLoadException */ public Atdl4jWidget createDoubleSpinnerT(DoubleSpinnerT control, ParameterT parameter) { @@ -238,7 +234,6 @@ public Atdl4jWidget createDoubleSpinnerT(DoubleSpinnerT control, ParameterT p * @param control * @param parameter * @return - * @throws Atdl4jClassLoadException */ public Atdl4jWidget createDropDownListT(DropDownListT control, ParameterT parameter) { diff --git a/src/main/java/org/atdl4j/ui/impl/BaseStrategyUIFactory.java b/src/main/java/org/atdl4j/ui/impl/BaseStrategyUIFactory.java index 20ef7c8..cf84645 100644 --- a/src/main/java/org/atdl4j/ui/impl/BaseStrategyUIFactory.java +++ b/src/main/java/org/atdl4j/ui/impl/BaseStrategyUIFactory.java @@ -3,7 +3,8 @@ import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.ValidationRule; @@ -21,7 +22,7 @@ */ public class BaseStrategyUIFactory { - protected static final Logger logger = Logger.getLogger( BaseStrategyUIFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( BaseStrategyUIFactory.class ); private static Atdl4jUserMessageHandler atdl4jUserMessageHandler = null; public static StrategyUI createStrategyUI(StrategyT strategy, StrategiesT aStrategies, Map strategiesRules, Object parentContainer, Atdl4jOptions aAtdl4jOptions) throws FIXatdlFormatException @@ -31,17 +32,8 @@ public static StrategyUI createStrategyUI(StrategyT strategy, StrategiesT aStrat return strategyUI; } - /** - * @param atdl4jUserMessageHandler the atdl4jUserMessageHandler to set - */ - public void setAtdl4jUserMessageHandler(Atdl4jUserMessageHandler anAtdl4jUserMessageHandler) - { - atdl4jUserMessageHandler = anAtdl4jUserMessageHandler; - } - /** * @return the atdl4jUserMessageHandler - * @throws Atdl4jClassLoadException */ public static Atdl4jUserMessageHandler getAtdl4jUserMessageHandler() { diff --git a/src/main/java/org/atdl4j/ui/impl/ControlHelper.java b/src/main/java/org/atdl4j/ui/impl/ControlHelper.java index 447573b..8cef02c 100644 --- a/src/main/java/org/atdl4j/ui/impl/ControlHelper.java +++ b/src/main/java/org/atdl4j/ui/impl/ControlHelper.java @@ -155,38 +155,64 @@ public static BigDecimal determineIncrementValue( Double aIncrement, String aInc if ( Atdl4jConstants.INCREMENT_POLICY_LOT_SIZE.equals( aIncrementPolicy ) ) { - if ( ( aAtdl4jOptions != null ) && - ( aAtdl4jOptions.getInputAndFilterData() != null ) && - ( aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicy_LotSize() != null ) ) + if ( aAtdl4jOptions != null ) { - return aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicy_LotSize(); - } - else if ( aIncrement != null ) - { - return new BigDecimal( aIncrement.toString() ); + if ( ( aAtdl4jOptions.getInputAndFilterData() != null ) + && ( aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicyLotSize()!= null ) ) + { + return aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicyLotSize(); + } + else if ( aIncrement != null ) + { + return new BigDecimal( aIncrement.toString() ); + } + else + { + return aAtdl4jOptions.getDefaultLotSizeIncrementValue(); + } } else { - return aAtdl4jOptions.getDefaultLotSizeIncrementValue(); + if ( aIncrement != null ) + { + return new BigDecimal( aIncrement.toString() ); + } + else + { + return Atdl4jOptions.SYSTEM_DEFAULT_LOT_SIZE_INCREMENT_VALUE; + } } } else if ( Atdl4jConstants.INCREMENT_POLICY_TICK.equals( aIncrementPolicy ) ) { - if ( ( aAtdl4jOptions != null ) && - ( aAtdl4jOptions.getInputAndFilterData() != null ) && - ( aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicy_Tick() != null ) ) - { - return aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicy_Tick(); - } - else if ( aIncrement != null ) + if ( aAtdl4jOptions != null ) { - return new BigDecimal( aIncrement.toString() ); + if ( ( aAtdl4jOptions.getInputAndFilterData() != null ) + && ( aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicyTick() != null ) ) + { + return aAtdl4jOptions.getInputAndFilterData().getInputIncrementPolicyTick(); + } + else if ( aIncrement != null ) + { + return new BigDecimal( aIncrement.toString() ); + } + else + { + return aAtdl4jOptions.getDefaultTickIncrementValue(); + } } else { - return aAtdl4jOptions.getDefaultTickIncrementValue(); + if ( aIncrement != null ) + { + return new BigDecimal( aIncrement.toString() ); + } + else + { + return Atdl4jOptions.SYSTEM_DEFAULT_TICK_INCREMENT_VALUE; + } } - } + } else // -- Use aIncrement value when aIncrementPolicy null or Atdl4jConstants.INCREMENT_POLICY_STATIC -- { if ( aIncrement != null ) @@ -209,9 +235,6 @@ else if ( aIncrement != null ) */ public static Object getInitValue( ControlT aControl, Atdl4jOptions aAtdl4jOptions ) { - // INIT_POLICY_USE_VALUE = "UseValue"; // -- use value from ControlT/@initValue -- - // INIT_POLICY_USE_FIX_FIELD = "UseFixField"; // -- use value from ControlT/@initFixField if available, else ControlT/@initValue -- - if ( Atdl4jConstants.INIT_POLICY_USE_FIX_FIELD.equals( aControl.getInitPolicy() ) ) { if ( aControl.getInitFixField() == null ) @@ -224,7 +247,7 @@ public static Object getInitValue( ControlT aControl, Atdl4jOptions aAtdl4jOptio throw new IllegalArgumentException( "ERROR: Control: " + aControl.getID() + " has initPolicy=\"" + aControl.getInitPolicy() + "\" but Atdl4jOptions is null." ); } - String tempFixFieldValue = aAtdl4jOptions.getInputAndFilterData().getInputHiddenFieldValue( aControl.getInitFixField().toString() ); + String tempFixFieldValue = aAtdl4jOptions.getInputAndFilterData().getInputHiddenFieldValue( aControl.getInitFixField() ); if ( tempFixFieldValue != null ) { diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jCompositePanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jCompositePanel.java index 34f3c7c..4f6e94e 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jCompositePanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jCompositePanel.java @@ -8,7 +8,8 @@ import javax.swing.JPanel; import javax.swing.SwingUtilities; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.fixatdl.core.StrategyT; import org.atdl4j.ui.Atdl4jWidget; @@ -25,9 +26,9 @@ * @version 1.0, Feb 28, 2010 */ public class SwingAtdl4jCompositePanel - extends AbstractAtdl4jCompositePanel + extends AbstractAtdl4jCompositePanel { - public final Logger logger = Logger.getLogger(SwingAtdl4jCompositePanel.class); + public static final Logger logger = LoggerFactory.getLogger(SwingAtdl4jCompositePanel.class); private Window parentComposite; private JPanel strPanel; private JPanel strategySelectionPanel; diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataPanel.java index 0fce918..c227ec2 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataPanel.java @@ -11,7 +11,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.StrategyFilterInputData; import org.atdl4j.data.Atdl4jConstants; @@ -26,7 +27,7 @@ public class SwingAtdl4jInputAndFilterDataPanel extends AbstractAtdl4jInputAndFilterDataPanel { - public final Logger logger = Logger.getLogger(SwingAtdl4jInputAndFilterDataPanel.class); + public final Logger logger = LoggerFactory.getLogger(SwingAtdl4jInputAndFilterDataPanel.class); private JDialog parentDialog; @@ -89,7 +90,7 @@ protected JPanel buildStrategyFilterPanel() JPanel panel1 = new JPanel(); panel1.add(new JLabel("FixMsgType:")); - strategyFilterFixMsgTypeCombo = new JComboBox(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_FIX_MSG_TYPES)); + strategyFilterFixMsgTypeCombo = new JComboBox<>(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_FIX_MSG_TYPES)); strategyFilterFixMsgTypeCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); panel1.add(strategyFilterFixMsgTypeCombo); @@ -98,24 +99,24 @@ protected JPanel buildStrategyFilterPanel() JPanel panel2 = new JPanel(); panel2.add(new JLabel("Region:")); - strategyFilterRegionCombo = new JComboBox(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_REGIONS)); + strategyFilterRegionCombo = new JComboBox<>(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_REGIONS)); strategyFilterRegionCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); panel2.add(strategyFilterRegionCombo); panel2.add(new JLabel("Country:")); - strategyFilterCountryCombo = new JComboBox(DEFAULT_STRATEGY_FILTER_COUNTRY_SUBSET_LIST); + strategyFilterCountryCombo = new JComboBox<>(DEFAULT_STRATEGY_FILTER_COUNTRY_SUBSET_LIST); strategyFilterCountryCombo.setEditable(true); strategyFilterCountryCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); panel2.add(strategyFilterCountryCombo); panel2.add(new JLabel("MIC Code:")); - strategyFilterMICCodeCombo = new JComboBox(DEFAULT_STRATEGY_FILTER_MIC_CODE_SUBSET_LIST); + strategyFilterMICCodeCombo = new JComboBox<>(DEFAULT_STRATEGY_FILTER_MIC_CODE_SUBSET_LIST); strategyFilterMICCodeCombo.setEditable(true); strategyFilterMICCodeCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); panel2.add(strategyFilterMICCodeCombo); panel2.add(new JLabel("Security Type:")); - strategyFilterSecurityTypeCombo = new JComboBox(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_SECURITY_TYPES)); + strategyFilterSecurityTypeCombo = new JComboBox<>(prepareContantsForGUI(Atdl4jConstants.STRATEGY_FILTER_SECURITY_TYPES)); strategyFilterSecurityTypeCombo.setEditable(true); strategyFilterSecurityTypeCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); panel2.add(strategyFilterSecurityTypeCombo); @@ -133,49 +134,49 @@ protected JPanel buildStandardFixFieldsPanel() standardFixFieldsPanel.add(new JLabel("OrdType:")); - fixFieldOrdTypeCombo = new JComboBox(DEFAULT_FIX_FIELD_ORD_TYPE_SUBSET_LIST); + fixFieldOrdTypeCombo = new JComboBox<>(DEFAULT_FIX_FIELD_ORD_TYPE_SUBSET_LIST); fixFieldOrdTypeCombo.setEditable(true); fixFieldOrdTypeCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldOrdTypeCombo); standardFixFieldsPanel.add(new JLabel("Side:")); - fixFieldSideCombo = new JComboBox(DEFAULT_FIX_FIELD_SIDE_SUBSET_LIST); + fixFieldSideCombo = new JComboBox<>(DEFAULT_FIX_FIELD_SIDE_SUBSET_LIST); fixFieldSideCombo.setEditable(true); fixFieldSideCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldSideCombo); standardFixFieldsPanel.add(new JLabel("OrderQty:")); - fixFieldOrderQtyCombo = new JComboBox(DEFAULT_FIX_FIELD_ORDER_QTY_SUBSET_LIST); + fixFieldOrderQtyCombo = new JComboBox<>(DEFAULT_FIX_FIELD_ORDER_QTY_SUBSET_LIST); fixFieldOrderQtyCombo.setEditable(true); fixFieldOrderQtyCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldOrderQtyCombo); standardFixFieldsPanel.add(new JLabel("Price:")); - fixFieldPriceCombo = new JComboBox(DEFAULT_FIX_FIELD_PRICE_SUBSET_LIST); + fixFieldPriceCombo = new JComboBox<>(DEFAULT_FIX_FIELD_PRICE_SUBSET_LIST); fixFieldPriceCombo.setEditable(true); fixFieldPriceCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldPriceCombo); standardFixFieldsPanel.add(new JLabel("HandlInst:")); - fixFieldHandlInstCombo = new JComboBox(DEFAULT_FIX_FIELD_HANDL_INST_SUBSET_LIST); + fixFieldHandlInstCombo = new JComboBox<>(DEFAULT_FIX_FIELD_HANDL_INST_SUBSET_LIST); fixFieldHandlInstCombo.setEditable(true); fixFieldHandlInstCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldHandlInstCombo); standardFixFieldsPanel.add(new JLabel("ExecInst:")); - fixFieldExecCombo = new JComboBox(DEFAULT_FIX_FIELD_EXEC_INST_SUBSET_LIST); + fixFieldExecCombo = new JComboBox<>(DEFAULT_FIX_FIELD_EXEC_INST_SUBSET_LIST); fixFieldExecCombo.setEditable(true); fixFieldExecCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldExecCombo); standardFixFieldsPanel.add(new JLabel("TimeInForce:")); - fixFieldTimeInForceCombo = new JComboBox(DEFAULT_FIX_FIELD_TIME_IN_FORCE_SUBSET_LIST); + fixFieldTimeInForceCombo = new JComboBox<>(DEFAULT_FIX_FIELD_TIME_IN_FORCE_SUBSET_LIST); fixFieldTimeInForceCombo.setEditable(true); fixFieldTimeInForceCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldTimeInForceCombo); standardFixFieldsPanel.add(new JLabel("ClOrdLinkID:")); - fixFieldClOrdLinkIDCombo = new JComboBox(DEFAULT_FIX_FIELD_CL_ORD_LINK_ID_SUBSET_LIST); + fixFieldClOrdLinkIDCombo = new JComboBox<>(DEFAULT_FIX_FIELD_CL_ORD_LINK_ID_SUBSET_LIST); fixFieldClOrdLinkIDCombo.setEditable(true); fixFieldClOrdLinkIDCombo.setMaximumRowCount(DEFAULT_DROP_DOWN_VISIBLE_ITEM_COUNT); standardFixFieldsPanel.add(fixFieldClOrdLinkIDCombo); @@ -231,31 +232,31 @@ public boolean loadScreenWithAtdl4jOptions() { StrategyFilterInputData tempStrategyFilterInputData = null; if ( ( getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList() != null ) && - ( getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().size() > 0 ) ) + ( !getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().isEmpty() ) ) { tempStrategyFilterInputData = getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().get( 0 ); } String tempFixMsgType = null; - String tempRegion_name = null; - String tempCountry_CountryCode = null; - String tempMarket_MICCode = null; - String tempSecurityType_name = null; + String tmpRegionName = null; + String tmpCountryCode = null; + String tmpMarketMicCode = null; + String tmpSecurityTypeName = null; if ( tempStrategyFilterInputData != null ) { tempFixMsgType = tempStrategyFilterInputData.getFixMsgType(); - tempRegion_name = tempStrategyFilterInputData.getRegion_name(); - tempCountry_CountryCode = tempStrategyFilterInputData.getCountry_CountryCode(); - tempMarket_MICCode = tempStrategyFilterInputData.getMarket_MICCode(); - tempSecurityType_name = tempStrategyFilterInputData.getSecurityType_name(); + tmpRegionName = tempStrategyFilterInputData.getRegion_name(); + tmpCountryCode = tempStrategyFilterInputData.getCountry_CountryCode(); + tmpMarketMicCode = tempStrategyFilterInputData.getMarket_MICCode(); + tmpSecurityTypeName = tempStrategyFilterInputData.getSecurityType_name(); } selectDropDownItem( strategyFilterFixMsgTypeCombo, tempFixMsgType ); - selectDropDownItem( strategyFilterRegionCombo, tempRegion_name ); - selectDropDownItem( strategyFilterCountryCombo, tempCountry_CountryCode ); - selectDropDownItem( strategyFilterMICCodeCombo, tempMarket_MICCode ); - selectDropDownItem( strategyFilterSecurityTypeCombo, tempSecurityType_name ); + selectDropDownItem( strategyFilterRegionCombo, tmpRegionName ); + selectDropDownItem( strategyFilterCountryCombo, tmpCountryCode ); + selectDropDownItem( strategyFilterMICCodeCombo, tmpMarketMicCode ); + selectDropDownItem( strategyFilterSecurityTypeCombo, tmpSecurityTypeName ); setCheckboxValue( checkboxInputCxlReplaceMode, getAtdl4jOptions().getInputAndFilterData().getInputCxlReplaceMode(), Boolean.FALSE ); diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataSelectionPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataSelectionPanel.java index d390008..7786f3e 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataSelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jInputAndFilterDataSelectionPanel.java @@ -5,11 +5,9 @@ import java.awt.event.ActionListener; import javax.swing.JButton; -import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JPanel; -import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.Atdl4jUserMessageHandler; import org.atdl4j.ui.app.impl.AbstractAtdl4jInputAndFilterDataSelectionPanel; @@ -24,9 +22,7 @@ public class SwingAtdl4jInputAndFilterDataSelectionPanel private JPanel parentPanel; private JButton atdl4jInputAndFilterDataPanelButton; private JDialog atdl4jInputAndFilterDataPanelDialog; - - private JCheckBox debugModeButton; - + /* (non-Javadoc) * @see org.atdl4j.ui.app.Atdl4jInputAndFilterDataSelectionPanel#buildAtdl4jInputAndFilterDataSelectionPanel(java.lang.Object, org.atdl4j.config.Atdl4jOptions, org.atdl4j.ui.app.Atdl4jUserMessageHandler) */ @@ -78,8 +74,7 @@ private void buttonInputAndFilterDataSelected() } getAtdl4jInputAndFilterDataPanel().loadScreenWithAtdl4jOptions(); - getDebugModeButton().setSelected( Atdl4jConfig.getConfig().isDebugLoggingLevel() ); - + atdl4jInputAndFilterDataPanelDialog.setVisible(true); } @@ -133,29 +128,9 @@ public void actionPerformed(ActionEvent e) } } ); footerPanel.add(cancelButton); - - setDebugModeButton(new JCheckBox("Debug Mode")); - getDebugModeButton().addActionListener( new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - Atdl4jConfig.getConfig().setDebugLoggingLevel( getDebugModeButton().isSelected() ); - } - } ); - footerPanel.add(getDebugModeButton()); - + tempDialog.pack(); return tempDialog; } - public JCheckBox getDebugModeButton() - { - return debugModeButton; - } - - public void setDebugModeButton(JCheckBox debugModeButton) - { - this.debugModeButton = debugModeButton; - } } diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterApp.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterApp.java index a9acdca..b9d7cdd 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterApp.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterApp.java @@ -2,8 +2,10 @@ import javax.swing.JFrame; import javax.swing.UIManager; +import javax.swing.WindowConstants; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jConfiguration; import org.atdl4j.config.Atdl4jOptions; @@ -17,8 +19,9 @@ * ->AbstractAtdl4jCompositePanel layering structure. * * */ -public class SwingAtdl4jTesterApp extends AbstractAtdl4jTesterApp { - public final Logger logger = Logger.getLogger(SwingAtdl4jTesterApp.class); +public class SwingAtdl4jTesterApp extends AbstractAtdl4jTesterApp +{ + public static final Logger logger = LoggerFactory.getLogger(SwingAtdl4jTesterApp.class); /** * @param args @@ -48,7 +51,7 @@ public static void main(String[] args) throws Exception { public void mainLine(String[] args, Atdl4jConfiguration config) throws Exception { JFrame frame = new JFrame(); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setTitle("atdl4j - The Open-Source Java Solution for FIXatdl (Swing)"); // -- Delegate setup to AbstractAtdl4jTesterApp, construct a new diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterPanel.java index 9d69606..d27f9cd 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jTesterPanel.java @@ -21,7 +21,8 @@ import javax.swing.JScrollPane; import javax.swing.JTextField; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.exception.ValidationException; @@ -41,7 +42,7 @@ public class SwingAtdl4jTesterPanel extends AbstractAtdl4jTesterPanel { - public final Logger logger = Logger.getLogger(SwingAtdl4jTesterPanel.class); + public final Logger logger = LoggerFactory.getLogger(SwingAtdl4jTesterPanel.class); private JFrame parentComposite; private JPanel inputAndFilterDataAndLoadMessageComposite; @@ -149,7 +150,7 @@ private void addListeners(Atdl4jCompositePanel atdl4jCompositePanel) { @Override public void widgetChanged(Atdl4jWidget widget) { if (logger.isDebugEnabled()) { - logger.debug("Widget changed notification :" + widget); + logger.debug("Widget changed notification :{}", widget); } } }); @@ -176,7 +177,7 @@ public void setVisibleFileSelectionSection( boolean aVisible ) } } - protected void createPopupMenuForPanel(JPanel _panel) + protected void createPopupMenuForPanel(JPanel aPanel) { final JPopupMenu menu = new JPopupMenu(); @@ -209,7 +210,7 @@ public void actionPerformed(ActionEvent e) { menu.add(showValidateOutputMenuItem); - _panel.addMouseListener(new MouseAdapter() { + aPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { @@ -261,18 +262,6 @@ public void setVisibleValidateOutputSection( boolean aVisible ) public void setVisibleTestingInputSection( boolean aVisible ) { - /* - if ( ( inputAndFilterDataAndLoadMessageComposite != null ) && ( ! inputAndFilterDataAndLoadMessageComposite.isDisposed() ) ) - { - inputAndFilterDataAndLoadMessageComposite.setVisible( aVisible ); - if ( inputAndFilterDataAndLoadMessageComposite.getLayoutData() instanceof GridData ) - { - ((GridData) inputAndFilterDataAndLoadMessageComposite.getLayoutData()).exclude = !aVisible; - } - - packLayout(); - } - */ } protected JPanel createOkCancelButtonSection() @@ -319,7 +308,11 @@ public void setVisibleOkCancelButtonSection( boolean aVisible ) protected void packLayout() { - getShell().pack(); + JFrame tmpJFrame = getShell(); + if ( tmpJFrame != null ) + { + tmpJFrame.pack(); + } } diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jUserMessageHandler.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jUserMessageHandler.java index 8dbf52e..dad2615 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jUserMessageHandler.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingAtdl4jUserMessageHandler.java @@ -5,7 +5,8 @@ import javax.swing.JOptionPane; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.impl.AbstractAtdl4jUserMessageHandler; @@ -19,7 +20,7 @@ public class SwingAtdl4jUserMessageHandler extends AbstractAtdl4jUserMessageHandler { - private final Logger logger = Logger.getLogger(SwingAtdl4jUserMessageHandler.class); + private final Logger logger = LoggerFactory.getLogger(SwingAtdl4jUserMessageHandler.class); private Window parentComposite; @@ -41,9 +42,7 @@ public void init(Window aParentComposite, Atdl4jOptions atdl4jOptions) public void displayException(String aTitle, String aMsgText, Throwable e) { String txt = ""; - //TODO: remove - e.printStackTrace(); - + if ( aTitle != null ) { txt += aTitle; diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingFixMsgLoadPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingFixMsgLoadPanel.java index 88b7af5..1d18df9 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingFixMsgLoadPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingFixMsgLoadPanel.java @@ -26,8 +26,7 @@ public class SwingFixMsgLoadPanel extends AbstractFixMsgLoadPanel { Container parentContainer; -// JPanel as we need TitledBorder private Container container; - + JTextField fixMsgText; JButton loadFixMsgButton; diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategyDescriptionPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategyDescriptionPanel.java index 9392458..0cf733a 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategyDescriptionPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategyDescriptionPanel.java @@ -20,7 +20,6 @@ public class SwingStrategyDescriptionPanel extends AbstractStrategyDescriptionPanel { - // JPanel as we need TitledBorder private Container container; private JPanel container; private JTextPane strategyDescription; @@ -58,7 +57,7 @@ public JPanel buildStrategyDescriptionPanel(Window aParentContainer, */ protected void setStrategyDescriptionText(String aText) { if (strategyDescription != null) { - String newText = aText.replaceAll("'", "'"); + String newText = aText.replace("'", "'"); String htmlText = "" + newText + ""; strategyDescription.setText(htmlText); strategyDescription.setSelectionStart(0); diff --git a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategySelectionPanel.java b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategySelectionPanel.java index 0bcdcf8..6de8595 100644 --- a/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategySelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/swing/app/impl/SwingStrategySelectionPanel.java @@ -11,7 +11,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.Atdl4jHelper; @@ -28,7 +29,7 @@ public class SwingStrategySelectionPanel extends AbstractStrategySelectionPanel { - private final Logger logger = Logger.getLogger(SwingStrategySelectionPanel.class); + private static final Logger logger = LoggerFactory.getLogger(SwingStrategySelectionPanel.class); private JComboBox strategiesDropDown; public Object buildStrategySelectionPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions) @@ -88,7 +89,7 @@ public void loadStrategyList( List aStrategyList ) for (StrategyT tempStrategy : getStrategiesList()) { - logger.debug( "loadStrategyList() [" + strategiesDropDown.getItemCount() + "] strategiesDropDown.add: " + Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); + logger.debug( "loadStrategyList() [{}] strategiesDropDown.add: {}", strategiesDropDown.getItemCount(), Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); strategiesDropDown.addItem( Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); } } @@ -96,7 +97,7 @@ public void loadStrategyList( List aStrategyList ) public void selectDropDownStrategy(int index) { - logger.debug( "selectDropDownStrategy() index: " + index ); + logger.debug( "selectDropDownStrategy() index: {}", index ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -119,7 +120,7 @@ public void selectDropDownStrategy(int index) // 4/16/2010 Scott Atwell public void selectDropDownStrategy(String strategyName) public void selectDropDownStrategyByStrategyName(String aStrategyName) { - logger.debug( "selectDropDownStrategyByStrategyName() aStrategyName: " + aStrategyName ); + logger.debug( "selectDropDownStrategyByStrategyName() aStrategyName: {}", aStrategyName ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -132,7 +133,7 @@ public void selectDropDownStrategyByStrategyName(String aStrategyName) if ( aStrategyName.equals( tempStrategy.getName() ) ) { - logger.debug( "selectDropDownStrategyByStrategyName() invoking selectDropDownStrategy( " + i + " )" ); + logger.debug( "selectDropDownStrategyByStrategyName() invoking selectDropDownStrategy( {} )", i ); selectDropDownStrategy( i ); } } @@ -141,7 +142,7 @@ public void selectDropDownStrategyByStrategyName(String aStrategyName) // 4/16/2010 Scott Atwell added public void selectDropDownStrategyByStrategyWireValue( String aStrategyWireValue ) { - logger.debug( "selectDropDownStrategyByStrategyWireValue() aStrategyWireValue: " + aStrategyWireValue ); + logger.debug( "selectDropDownStrategyByStrategyWireValue() aStrategyWireValue: {}", aStrategyWireValue ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -154,7 +155,7 @@ public void selectDropDownStrategyByStrategyWireValue( String aStrategyWireValue if ( aStrategyWireValue.equals( tempStrategy.getWireValue() ) ) { - logger.debug( "selectDropDownStrategyByStrategyWireValue() invoking selectDropDownStrategy( " + i + " )" ); + logger.debug( "selectDropDownStrategyByStrategyWireValue() invoking selectDropDownStrategy( {} )", i ); selectDropDownStrategy( i ); } } diff --git a/src/main/java/org/atdl4j/ui/swing/config/SwingAtdl4jConfiguration.java b/src/main/java/org/atdl4j/ui/swing/config/SwingAtdl4jConfiguration.java index 18be7ca..ad5b02a 100644 --- a/src/main/java/org/atdl4j/ui/swing/config/SwingAtdl4jConfiguration.java +++ b/src/main/java/org/atdl4j/ui/swing/config/SwingAtdl4jConfiguration.java @@ -12,7 +12,7 @@ public class SwingAtdl4jConfiguration extends AbstractAtdl4jConfiguration { - private static String PACKAGE_PATH_ORG_ATDL4J_UI_SWING = "org.atdl4j.ui.swing."; + private static final String PACKAGE_PATH_ORG_ATDL4J_UI_SWING = "org.atdl4j.ui.swing."; public SwingAtdl4jConfiguration() { @@ -86,7 +86,6 @@ protected String getDefaultClassNameAtdl4jWidgetForCheckBoxT() protected String getDefaultClassNameAtdl4jWidgetForClockT() { -// return PACKAGE_PATH_ORG_ATDL4J_UI_SWING + "widget.SwingClockWidget"; return PACKAGE_PATH_ORG_ATDL4J_UI_SWING + "widget.SwingJideClockWidget"; } diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStateListener.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStateListener.java index c23cf88..951a6f8 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStateListener.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStateListener.java @@ -51,7 +51,7 @@ public void handleEvent() { // Create a casted map so that Validatable can be used - Map> targets = new HashMap>( controls ); + Map> targets = new HashMap<>( controls ); try { @@ -95,7 +95,7 @@ protected void setBehaviorAsStateRule(Boolean state) // set value if ( stateRule.getValue() != null ) { - if ( state ) + if ( Boolean.TRUE.equals(state) ) { String value = stateRule.getValue(); affectedWidget.setValueAsString( value ); @@ -129,14 +129,12 @@ public SwingWidget getAffectedWidget() */ public boolean hasSetValueNullStateRule() { - if ( stateRule != null ) + if ( ( stateRule != null ) + && ( Atdl4jConstants.VALUE_NULL_INDICATOR.equals( stateRule.getValue() ) ) ) { - if ( Atdl4jConstants.VALUE_NULL_INDICATOR.equals( stateRule.getValue() ) ) - { - return true; - } + return true; } - + return false; } @@ -144,43 +142,40 @@ public boolean hasSetValueNullStateRule() * Used when panel is initially loaded with a FIX Message. * Effectively fires the StateRule in reverse (eg selects radio button or checkbox that normally * nulls the control's value to be selected when control has a value set) - * @param event */ public void handleLoadFixMessageEvent() { // -- If the StateRule sets value to VALUE_NULL_INDICATOR, however, the Control has 'externally' had // -- its value set to non-null value, then 'toggle' the state of the control (eg checkbox or radio button) // -- associated with this StateRule - if ( ( getAffectedWidget() != null ) && - ( ! getAffectedWidget().isNullValue() ) && - ( hasSetValueNullStateRule() ) ) + if ( ( ( getAffectedWidget() != null ) + && ( ! getAffectedWidget().isNullValue() ) + && ( hasSetValueNullStateRule() ) ) + && ( getRule() instanceof ValueOperatorValidationRule ) ) { - if ( getRule() instanceof ValueOperatorValidationRule ) + ValueOperatorValidationRule tempValueOperatorValidationRule = (ValueOperatorValidationRule) getRule(); + + Atdl4jWidget tempAssociatedControl = controls.get( tempValueOperatorValidationRule.getField() ); + + if ( ( tempAssociatedControl != null ) && + ( ControlHelper.isControlToggleable( tempAssociatedControl.getControl() ) ) ) { - ValueOperatorValidationRule tempValueOperatorValidationRule = (ValueOperatorValidationRule) getRule(); - - Atdl4jWidget tempAssociatedControl = controls.get( tempValueOperatorValidationRule.getField() ); - - if ( ( tempAssociatedControl != null ) && - ( ControlHelper.isControlToggleable( tempAssociatedControl.getControl() ) ) ) + String tempRuleNewValueAsString = null; + if ( "true".equals( tempValueOperatorValidationRule.getValue() ) ) { - String tempRuleNewValueAsString = null; - if ( "true".equals( tempValueOperatorValidationRule.getValue() ) ) - { - tempRuleNewValueAsString = "false"; - } - else if ( "false".equals( tempValueOperatorValidationRule.getValue() ) ) - { - tempRuleNewValueAsString = "true"; - } - - if ( tempRuleNewValueAsString != null ) + tempRuleNewValueAsString = "false"; + } + else if ( "false".equals( tempValueOperatorValidationRule.getValue() ) ) + { + tempRuleNewValueAsString = "true"; + } + + if ( tempRuleNewValueAsString != null ) + { + // -- Toggle the value -- + if ( ( OperatorT.EQ.equals( tempValueOperatorValidationRule.getOperator() ) ) ) { - // -- Toggle the value -- - if ( ( OperatorT.EQ.equals( tempValueOperatorValidationRule.getOperator() ) ) ) - { - tempAssociatedControl.setValueAsString( tempRuleNewValueAsString ); - } + tempAssociatedControl.setValueAsString( tempRuleNewValueAsString ); } } } diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategiesUI.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategiesUI.java index f968e82..721166d 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategiesUI.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategiesUI.java @@ -29,8 +29,6 @@ public class SwingStrategiesUI extends AbstractStrategiesUI { - private Window parentFrame; - private JPanel strategiesPanel; private Map swingWidgetListeners; @@ -42,7 +40,7 @@ public class SwingStrategiesUI */ public SwingStrategiesUI() { - this.swingWidgetListeners = new HashMap(); + this.swingWidgetListeners = new HashMap<>(); } public SwingStrategiesUI(Atdl4jOptions aAtdl4jOptions) @@ -62,8 +60,6 @@ public Object buildStrategiesPanel(Object parentOrShell, Atdl4jOptions atdl4jOpt public JPanel buildStrategiesPanel(Window aParentComposite, Atdl4jOptions atdl4jOptions, Atdl4jUserMessageHandler aAtdl4jUserMessageHandler) { - parentFrame = aParentComposite; - setAtdl4jOptions( atdl4jOptions ); setAtdl4jUserMessageHandler( aAtdl4jUserMessageHandler ); @@ -86,14 +82,17 @@ public void createStrategyPanels(StrategiesT aStrategies, List aFilte { setStrategies( aStrategies ); - setStrategiesRules( new HashMap() ); - for (EditT edit : getStrategies().getEdit()) { + setStrategiesRules( new HashMap<>() ); + for (EditT edit : getStrategies().getEdit()) + { String id = edit.getId(); - if (id != null) { - ValidationRule rule = ValidationRuleFactory.createRule(edit, - getStrategiesRules(), getStrategies()); + if (id != null) + { + ValidationRule rule = ValidationRuleFactory.createRule(edit, getStrategiesRules(), getStrategies()); getStrategiesRules().put(id, rule); - } else { + } + else + { throw new IllegalArgumentException("Strategies-scoped edit without id"); } } @@ -124,11 +123,11 @@ public void adjustLayoutForSelectedStrategy( StrategyT aStrategy ) if ( tempStrategyUI == null ) { - logger.info("ERROR: Strategy name: " + aStrategy.getName() + " was not found. (aStrategy: " + aStrategy + ")" ); + logger.info("ERROR: Strategy name: {} was not found. (aStrategy: {})", aStrategy.getName(), aStrategy ); return; } - logger.debug( "Invoking tempStrategyUI.reinitStrategyPanel() for: " + Atdl4jHelper.getStrategyUiRepOrName( tempStrategyUI.getStrategy() ) ); + logger.debug( "Invoking tempStrategyUI.reinitStrategyPanel() for: {}", Atdl4jHelper.getStrategyUiRepOrName( tempStrategyUI.getStrategy() ) ); tempStrategyUI.reinitStrategyPanel(); } allowWidgetNotification(); @@ -161,13 +160,11 @@ public void setVisible(boolean aVisible) } - // 12/15/2010 Scott Atwell public StrategyUI getStrategyUI( StrategyT aStrategy ) public StrategyUI getStrategyUI( StrategyT aStrategy, boolean aReinitPanelFlag ) { if ( aStrategy.equals( getCurrentlyDisplayedStrategy() ) ) { - logger.debug("Strategy name: " + aStrategy.getName() + " is currently being displayed. Returning getCurrentlyDisplayedStrategyUI()" ); - // 12/15/2010 Scott Atwell return getCurrentlyDisplayedStrategyUI(); + logger.debug("Strategy name: {} is currently being displayed. Returning getCurrentlyDisplayedStrategyUI()", aStrategy.getName() ); if ( aReinitPanelFlag ) { getCurrentlyDisplayedStrategyUI().reinitStrategyPanel(); @@ -178,13 +175,13 @@ public StrategyUI getStrategyUI( StrategyT aStrategy, boolean aReinitPanelFlag ) } else { - logger.debug("Strategy name: " + aStrategy.getName() + " is not currently displayed. Invoking removeAllStrategyPanels() and returning createStrategyPanel()" ); + logger.debug("Strategy name: {} is not currently displayed. Invoking removeAllStrategyPanels() and returning createStrategyPanel()", aStrategy.getName() ); removeAllStrategyPanels(); StrategyUI tempStrategyUI = SwingStrategyUIFactory.createStrategyUIAndContainer( this, aStrategy ); setCurrentlyDisplayedStrategyUI( tempStrategyUI ); - logger.debug("Invoking relayoutCollapsibleStrategyPanels() for: " + aStrategy.getName() ); + logger.debug("Invoking relayoutCollapsibleStrategyPanels() for: {}", aStrategy.getName() ); tempStrategyUI.relayoutCollapsibleStrategyPanels(); setWidgetListeners(getCurrentlyDisplayedStrategyUI()); @@ -201,10 +198,9 @@ private void setWidgetListeners(StrategyUI strategyUI) { // some widgets don't have a parameter reference, they are for control only (eg. radio buttons) if (widget.getParameter() != null) { - if (logger.isDebugEnabled()) { - logger.debug("Adding listener on " - + strategyUI.getStrategy().getName() + " " - + widget.getParameter().getName() + " widget " + widget); + if (logger.isDebugEnabled()) + { + logger.debug("Adding listener on {} {} widget {}", strategyUI.getStrategy().getName(), widget.getParameter().getName(), widget ); } swingWidgetListeners.put(widget.getParameter().getName(), new SwingWidgetListener((SwingWidget) widget)); } @@ -262,10 +258,12 @@ public void stateChanged(ChangeEvent e) { } private void fireWidgetChangedEvent(String aParamName) { - if (logger.isDebugEnabled()) { - logger.debug("Widget changed :" + aParamName); + if (logger.isDebugEnabled()) + { + logger.debug("Widget changed :{}", aParamName); } - if (isWidgetNotificationsAllowed()) { + if (isWidgetNotificationsAllowed()) + { fireWidgetChanged(swingWidget); } } diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelFactory.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelFactory.java index 9478c55..2423437 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelFactory.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelFactory.java @@ -11,7 +11,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.exception.FIXatdlFormatException; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.layout.ControlT; @@ -30,7 +31,7 @@ */ public class SwingStrategyPanelFactory { - protected static final Logger logger = Logger.getLogger( SwingStrategyPanelFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SwingStrategyPanelFactory.class ); private static SwingWidgetFactory swingWidgetFactory = new SwingWidgetFactory(); @@ -38,30 +39,29 @@ public class SwingStrategyPanelFactory // Can also process options for a group frame instead of a single panel public Map> createStrategyPanelAndWidgets(JPanel parent, StrategyPanelT panel, Map parameters, int style, Atdl4jWidgetFactory aAtdl4jWidgetFactory) throws FIXatdlFormatException { - logger.debug( "createStrategyPanelAndWidgets(Composite parent, StrategyPanelT panel, Map parameters, int style)" + " invoked with parms parent: " - + parent + " panel: " + panel + " parameters: " + parameters + " style: " + style ); + logger.debug( "createStrategyPanelAndWidgets(Composite parent, StrategyPanelT panel, Map parameters, int style) invoked with parms parent: {} panel: {} parameters: {} style: {}", parent, panel, parameters, style ); - Map> controlWidgets = new HashMap>(); + Map> controlWidgets = new HashMap<>(); // -- Handles StrategyPanel's Collapsible, Title, Border, etc. Sets its layout and layoutData and data. -- JPanel c = SwingStrategyPanelHelper.createStrategyPanelContainer( panel, parent, style ); parent.add(c); - if ( panel.getStrategyPanel().size() > 0 && panel.getControl().size() > 0 ) + if ( !panel.getStrategyPanel().isEmpty() && !panel.getControl().isEmpty() ) { // -- Wrap each Control with an auto-built StrategyPanel if setting is true -- if ( aAtdl4jWidgetFactory.getAtdl4jOptions().isAccommodateMixOfStrategyPanelsAndControls() ) { // -- FIXatdl 1.1 spec recommends against vs. prohibits. Mixed list may not be displayed 'in sequence' of file. -- - logger.warn( "StrategyPanel contains both StrategyPanel (" + panel.getStrategyPanel().size() +") and Control ( " + panel.getControl().size() + " elements.\nSee Atdl4jOptions.setAccommodateMixOfStrategyPanelsAndControls() as potential work-around, though Controls will appear after StrategyPanels." ); - + logger.warn( "StrategyPanel contains both StrategyPanel ({}) and Control ({}) elements.\nSee Atdl4jOptions.setAccommodateMixOfStrategyPanelsAndControls() as potential work-around, though Controls will appear after StrategyPanels.", panel.getStrategyPanel().size(), panel.getControl().size() ); + StrategyPanelT tempPanel = new StrategyPanelT(); tempPanel.setCollapsible( Boolean.FALSE ); tempPanel.setCollapsed( Boolean.FALSE ); tempPanel.setOrientation( panel.getOrientation() ); tempPanel.setColor( panel.getColor() ); - logger.warn( "Creating a StrategyPanel to contain " + panel.getControl().size() + " Controls." ); + logger.warn( "Creating a StrategyPanel to contain {} Controls.", panel.getControl().size() ); tempPanel.getControl().addAll( panel.getControl() ); panel.getControl().clear(); panel.getStrategyPanel().add( tempPanel ); @@ -130,11 +130,10 @@ public Map> createStrategyPanelAndWidgets(JPanel parent, * Display panel's children inside the given parent * @param parent * @param panel - * @param parameters * @param style - * @param aAtdl4jWidgetFactory * @param widgets * @param depth + * @param gcUpdater * @return * @throws FIXatdlFormatException */ @@ -179,8 +178,9 @@ public JPanel layoutStrategyPanel(JPanel parent, StrategyPanelT panel, gc = gcUpdater.size(1, gc); for (ControlT c : panel.getControl()) { gc = gcUpdater.panel(rowIndex, gc); - if (logger.isDebugEnabled()) { - logger.debug("Control :" + c.getLabel() + " rowIndex=" + rowIndex); + if (logger.isDebugEnabled()) + { + logger.debug("Control :{} rowIndex={}", c.getLabel(), rowIndex ); } SwingWidget< ? > swingWidget = widgets.get(c.getID()); @@ -197,10 +197,10 @@ public JPanel layoutStrategyPanel(JPanel parent, StrategyPanelT panel, int compIndex = 0; for (Component comp : brickComponents) { - if (logger.isDebugEnabled()) { - if (comp instanceof JLabel) { - logger.debug("Label " + ((JLabel) comp).getText()); - } + if ( ( logger.isDebugEnabled() ) + && ( comp instanceof JLabel ) ) + { + logger.debug("Label {}", ((JLabel) comp).getText() ); } if (compIndex == (size - 1)) { diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelHelper.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelHelper.java index e500983..16245e5 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelHelper.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyPanelHelper.java @@ -17,6 +17,8 @@ import org.atdl4j.ui.Atdl4jWidget; import org.atdl4j.ui.StrategyPanelHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -27,8 +29,8 @@ public class SwingStrategyPanelHelper implements StrategyPanelHelper { - - + private static final Logger logger = LoggerFactory.getLogger(SwingStrategyPanelHelper.class); + /** * Builds the appropriate 'container' JPanel for aStrategyPanel. * @@ -47,12 +49,6 @@ public static JPanel createStrategyPanelContainer(StrategyPanelT aStrategyPanel, { JPanel c = new JPanel(); -/* if ( aStrategyPanel.isCollapsible() ){ - c = new CollapsiblePanel(aStrategyPanel.getTitle() ); - } - // -- Check for titled border -- - else -*/ if ( aStrategyPanel.getTitle() != null ){ c.setBorder( BorderFactory.createTitledBorder(aStrategyPanel.getTitle())); } @@ -68,26 +64,26 @@ else if ( BorderT.LINE.equals( aStrategyPanel.getBorder() ) ) { return c; } - public static void createStrategyPanelSpringLayout(StrategyPanelT _panelT, JPanel _panel) throws FIXatdlFormatException { - - PanelOrientationT orientation = _panelT.getOrientation(); + public static void createStrategyPanelSpringLayout(StrategyPanelT aPanelT, JPanel aPanel) throws FIXatdlFormatException + { + PanelOrientationT orientation = aPanelT.getOrientation(); if ( orientation == PanelOrientationT.HORIZONTAL ) { // Lay out the panel. - makeCompactGrid(_panel, 1, _panel.getComponentCount(), // rows, cols + makeCompactGrid(aPanel, 1, aPanel.getComponentCount(), // rows, cols 5, 2, // initX, initY 5, 2); // xPad, yPad } else if ( orientation == PanelOrientationT.VERTICAL ) { // Lay out the panel. - makeCompactGrid(_panel, _panel.getComponentCount(), 1,// rows, cols + makeCompactGrid(aPanel, aPanel.getComponentCount(), 1,// rows, cols 5, 2, // initX, initY 5, 2); // xPad, yPad } else { - throw new FIXatdlFormatException( "StrategyPanel (" + _panelT.getTitle() + ") is missing orientation attribute." ); + throw new FIXatdlFormatException( "StrategyPanel (" + aPanelT.getTitle() + ") is missing orientation attribute." ); } } @@ -130,7 +126,7 @@ public static void makeCompactGrid(Container parent, int rows, int cols, int ini layout = (SpringLayout) parent.getLayout(); } catch (ClassCastException exc) { - System.err.println("The first argument to makeCompactGrid must use SpringLayout."); + logger.error("The first argument to makeCompactGrid must use SpringLayout."); return; } diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUI.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUI.java index 3aa0d7e..5340359 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUI.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUI.java @@ -2,19 +2,15 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import java.util.Vector; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.FIXatdlFormatException; import org.atdl4j.data.validation.Field2OperatorValidationRule; @@ -35,7 +31,7 @@ * */ public class SwingStrategyUI extends AbstractStrategyUI { - protected static final Logger logger = Logger.getLogger(SwingStrategyUI.class); + protected static final Logger logger = LoggerFactory.getLogger(SwingStrategyUI.class); protected Map> swingWidgetMap; @@ -57,8 +53,8 @@ public class SwingStrategyUI extends AbstractStrategyUI { * @see org.atdl4j.ui.StrategyUI#relayoutCollapsibleStrategyPanels() */ @Override - public void relayoutCollapsibleStrategyPanels() { - // TODO Auto-generated method stub + public void relayoutCollapsibleStrategyPanels() + { } /* @@ -79,7 +75,7 @@ protected void buildAtdl4jWidgetMap(List aStrategyPanelList) JPanel tmp = new JPanel(); - Map> tempSwingWidgetMap = new HashMap>(); + Map> tempSwingWidgetMap = new HashMap<>(); // build panels and widgets recursively for (StrategyPanelT panel : aStrategyPanelList) { Map> strategyPanelAndWidgets = strategyPanelFactory @@ -105,11 +101,14 @@ protected void buildAtdl4jWidgetMap(List aStrategyPanelList) * @see org.atdl4j.ui.impl.AbstractStrategyUI#getAtdl4jWidgetMap() */ @Override - public Map> getAtdl4jWidgetMap() { - if ( swingWidgetMap != null ) { - return new HashMap>( swingWidgetMap ); + public Map> getAtdl4jWidgetMap() + { + if ( swingWidgetMap != null ) + { + return new HashMap<>( swingWidgetMap ); } - else { + else + { return null; } } @@ -120,10 +119,11 @@ public Map> getAtdl4jWidgetMap() { * @see org.atdl4j.ui.impl.AbstractStrategyUI#getAtdl4jWidgetWithParameterMap() */ @Override - public Map> getAtdl4jWidgetWithParameterMap() { + public Map> getAtdl4jWidgetWithParameterMap() + { if ( swingWidgetWithParameterMap != null ) { - return new HashMap>( swingWidgetWithParameterMap ); + return new HashMap<>( swingWidgetWithParameterMap ); } else { @@ -139,8 +139,8 @@ public Map> getAtdl4jWidgetWithParameterMap() { @Override protected void initBegin(Object parentContainer) { parentComponent = (JPanel) parentContainer; - swingWidgetWithParameterMap = new HashMap>(); - widgetStateListenerMap = new HashMap, Set>(); + swingWidgetWithParameterMap = new HashMap<>(); + widgetStateListenerMap = new HashMap<>(); } /* @@ -158,7 +158,7 @@ protected void buildAtdl4jWidgetMap() throws FIXatdlFormatException { throw new FIXatdlFormatException("getStrategy().getStrategyLayout() was null (verify )"); } - if (getStrategy().getStrategyLayout() == null) { + if (getStrategy().getStrategyLayout().getStrategyPanel() == null) { throw new FIXatdlFormatException("getStrategy().getStrategyLayout().getStrategyPanel() was null (verify )"); } @@ -173,12 +173,12 @@ protected void buildAtdl4jWidgetMap() throws FIXatdlFormatException { */ @Override protected void createRadioGroups() { - Map tempRadioGroupMap = new HashMap(); + Map tempRadioGroupMap = new HashMap<>(); for ( SwingWidget widget : swingWidgetMap.values() ) { if ( widget.getControl() instanceof RadioButtonT && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != "" ) + && !Objects.equals(((RadioButtonT) widget.getControl()).getRadioGroup(), "")) { String rg = ( (RadioButtonT) widget.getControl() ).getRadioGroup(); if ( !tempRadioGroupMap.containsKey( rg ) ) @@ -200,7 +200,7 @@ protected void createRadioGroups() { */ @Override protected void buildAtdl4jWidgetWithParameterMap() { - Map> tempSwingWidgetWithParameterMap = new HashMap>(); + Map> tempSwingWidgetWithParameterMap = new HashMap<>(); // loop through all UI controls for ( SwingWidget widget : swingWidgetMap.values() ) { @@ -226,7 +226,7 @@ protected void buildAtdl4jWidgetWithParameterMap() { */ @Override protected void attachGlobalStateRulesToControls() throws FIXatdlFormatException { - List tempStateListenerList = new Vector(); + List tempStateListenerList = new ArrayList<>(); // loop through all UI controls for ( SwingWidget widget : swingWidgetMap.values() ) @@ -295,10 +295,10 @@ private void attachFieldToControls(String field, SwingStateListener stateRuleLis String rg = ( (RadioButtonT) targetParameterWidget.getControl() ).getRadioGroup(); for ( SwingWidget widget : swingWidgetMap.values() ) { - if ( widget.getControl() instanceof RadioButtonT && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( ! "".equals( ( (RadioButtonT) widget.getControl() ).getRadioGroup() ) ) - && ( (RadioButtonT) widget.getControl() ).getRadioGroup().equals( rg ) ) + if ( ( widget.getControl() instanceof RadioButtonT ) + && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null + && ( ! "".equals( ( (RadioButtonT) widget.getControl() ).getRadioGroup() ) ) + && ( (RadioButtonT) widget.getControl() ).getRadioGroup().equals( rg ) ) { putStateListener( widget, stateRuleListener ); } @@ -310,7 +310,7 @@ private void attachFieldToControls(String field, SwingStateListener stateRuleLis private void putStateListener(SwingWidget widget, SwingStateListener stateListener) { if ( !widgetStateListenerMap.containsKey( widget ) ) - widgetStateListenerMap.put( widget, new HashSet() ); + widgetStateListenerMap.put( widget, new HashSet<>() ); if ( !widgetStateListenerMap.get( widget ).contains( stateListener ) ) widgetStateListenerMap.get( widget ).add( stateListener ); } @@ -335,7 +335,8 @@ protected void attachStateListenersToAllAtdl4jWidgets() { * @see org.atdl4j.ui.impl.AbstractStrategyUI#initEnd() */ @Override - protected void initEnd() { + protected void initEnd() + { } /* diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUIFactory.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUIFactory.java index b31a486..4729db3 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUIFactory.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingStrategyUIFactory.java @@ -2,7 +2,8 @@ import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.Atdl4jHelper; import org.atdl4j.fixatdl.core.StrategyT; import org.atdl4j.ui.StrategyUI; @@ -17,7 +18,7 @@ */ public class SwingStrategyUIFactory extends BaseStrategyUIFactory { - protected static final Logger logger = Logger.getLogger( SwingStrategyUIFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SwingStrategyUIFactory.class ); public static StrategyUI createStrategyUIAndContainer(SwingStrategiesUI aStrategiesUI, StrategyT aStrategy) { diff --git a/src/main/java/org/atdl4j/ui/swing/impl/SwingWidgetFactory.java b/src/main/java/org/atdl4j/ui/swing/impl/SwingWidgetFactory.java index ab67778..466c897 100644 --- a/src/main/java/org/atdl4j/ui/swing/impl/SwingWidgetFactory.java +++ b/src/main/java/org/atdl4j/ui/swing/impl/SwingWidgetFactory.java @@ -2,7 +2,8 @@ import javax.swing.JPanel; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.layout.ControlT; import org.atdl4j.ui.Atdl4jWidgetFactory; @@ -17,22 +18,21 @@ */ public class SwingWidgetFactory { - protected static final Logger logger = Logger.getLogger( SwingWidgetFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SwingWidgetFactory.class ); // Used to create a single parameter widget public SwingWidget createWidget(JPanel parent, ControlT control, ParameterT parameter, int style, Atdl4jWidgetFactory aAtdl4jWidgetFactory) { SwingWidget parameterWidget = null; - logger.debug( "createWidget() invoked " + "with parms parent: " + parent - + " control: " + control + " parameter: " + parameter + " style: " + style ); + logger.debug( "createWidget() invoked with parms parent: {} control: {} parameter: {} style: {}", parent, control, parameter, style ); parameterWidget = (SwingWidget) aAtdl4jWidgetFactory.create( control, parameter ); - logger.debug( "createWidget() returned parameterWidget: " + parameterWidget ); + logger.debug( "createWidget() returned parameterWidget: {}", parameterWidget ); parameterWidget.createWidget(parent); - logger.debug( "createWidget() completed. parameterWidget: " + parameterWidget ); + logger.debug( "createWidget() completed. parameterWidget: {}", parameterWidget ); parameterWidget.applyConstOrInitValues(); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/AbstractSwingWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/AbstractSwingWidget.java index c8f14ff..33ed07f 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/AbstractSwingWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/AbstractSwingWidget.java @@ -99,8 +99,9 @@ public boolean isControlExcludingLabelEnabled() return brickComponents; } - protected List< ? extends Component> createBrickComponents() { - return new ArrayList(); + protected List< ? extends Component> createBrickComponents() + { + return new ArrayList<>(); } @Override diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingButtonWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingButtonWidget.java index 540cc51..415167e 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingButtonWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingButtonWidget.java @@ -20,10 +20,9 @@ * Implements either a CheckBox or a RadioButton */ public class SwingButtonWidget - extends AbstractSwingWidget + extends AbstractSwingWidget { private JToggleButton button; - //private SwingRadioButtonListener radioButtonListener; public void setValue(Boolean value) { @@ -49,7 +48,7 @@ else if (control instanceof RadioButtonT) public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(button); return widgets; } @@ -78,6 +77,7 @@ public Boolean getControlValueRaw() } // Parameter value looks up checkedEnumRef and uncheckedEnumRef + @Override public Object getParameterValue() { if ( getControlValue() == null ) @@ -134,7 +134,7 @@ public void processReinit( Object aControlInitValue ) { if ( ( button != null ) ) { - button.setSelected( (aControlInitValue != null ) ? ((Boolean) aControlInitValue).booleanValue() : false ); + button.setSelected( (aControlInitValue != null ) && ((Boolean) aControlInitValue).booleanValue() ); } } @@ -151,8 +151,7 @@ public List createBrickComponents() { // set label and tooltips if ( control.getLabel() != null ) button.setText( control.getLabel() ); if ( getTooltip() != null ) button.setToolTipText( getTooltip() ); - // if (control.getTooltip() != null) button.setToolTipText(control.getTooltip()); - + Boolean tempInitValue = (Boolean) ControlHelper.getInitValue( control, getAtdl4jOptions() ); if ( tempInitValue != null ) { diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingCheckBoxListWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingCheckBoxListWidget.java index d3a273d..5839170 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingCheckBoxListWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingCheckBoxListWidget.java @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import javax.swing.JCheckBox; import javax.swing.JLabel; -import javax.swing.JPanel; import org.atdl4j.fixatdl.core.EnumPairT; import org.atdl4j.fixatdl.layout.CheckBoxListT; @@ -18,10 +18,10 @@ public class SwingCheckBoxListWidget extends AbstractSwingWidget { - private List multiCheckBox = new ArrayList(); + private List multiCheckBox = new ArrayList<>(); private JLabel label; - // -- Overriden -- + @Override protected void initPreCheck() { // validate ListItems and EnumPairs @@ -33,25 +33,26 @@ protected void initPreCheck() public String getControlValueRaw() { - String value = ""; + StringBuilder tmpStringBuilder = new StringBuilder(""); for ( int i = 0; i < multiCheckBox.size(); i++ ) { JCheckBox b = multiCheckBox.get( i ); if ( b.isSelected() ) { - if ( "".equals( value ) ) + if ( tmpStringBuilder.toString().isEmpty() ) { - value += ( (CheckBoxListT) control ).getListItem().get( i ).getEnumID(); + tmpStringBuilder.append( ( (CheckBoxListT) control ).getListItem().get( i ).getEnumID() ); } else { - value += " " + ( (CheckBoxListT) control ).getListItem().get( i ).getEnumID(); + tmpStringBuilder.append( " " ).append( ( (CheckBoxListT) control ).getListItem().get( i ).getEnumID() ); } } } - return "".equals( value ) ? null : value; + return tmpStringBuilder.toString().isEmpty() ? null : tmpStringBuilder.toString(); } + @Override public String getParameterValue() { // Helper method from AbstractControlUI @@ -84,18 +85,17 @@ public void setValue(String value, boolean setValueAsControl) public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (label != null) widgets.add( label ); widgets.addAll( multiCheckBox ); return widgets; } - public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); - widgets.addAll( multiCheckBox ); - return widgets; - } - + public List getComponentsExcludingLabel() + { + return new ArrayList<>(multiCheckBox); + } + public void addListener(SwingListener listener) { for ( JCheckBox b : multiCheckBox ) { @@ -139,16 +139,14 @@ public void processReinit( Object aControlInitValue ) */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? + // ?? adjust the visual appearance of the control ?? } @Override public List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); - // wrapper - JPanel wrapper = new JPanel(); - + List components = new ArrayList<>(); + // tooltip String tooltip = control.getTooltip(); @@ -183,8 +181,8 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean if (parameter != null) { for (EnumPairT enumPair : parameter.getEnumPair()) { - if (enumPair.getEnumID() == listItem.getEnumID()) { - + if (Objects.equals(enumPair.getEnumID(), listItem.getEnumID())) + { // set tooltip if (enumPair.getDescription() != null) checkBox.setToolTipText(enumPair.getDescription()); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingDropDownListWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingDropDownListWidget.java index ad97285..844b96d 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingDropDownListWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingDropDownListWidget.java @@ -4,6 +4,7 @@ import java.awt.Dimension; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.swing.JComboBox; import javax.swing.JLabel; @@ -23,6 +24,7 @@ public class SwingDropDownListWidget private JLabel label; private JPanel wrapper; + @Override public void setVisible(boolean visible){ if (wrapper != null) wrapper.setVisible(visible); @@ -32,6 +34,7 @@ public void setVisible(boolean visible){ // Helper to get list items + @Override protected List getListItems() { return (control instanceof EditableDropDownListT) ? @@ -44,15 +47,15 @@ public String getControlValueRaw() if (selection >= 0) return getListItems().get(selection).getEnumID(); - else if (control instanceof EditableDropDownListT && - dropDownList.getSelectedItem() != null && - (String)dropDownList.getSelectedItem() != "") + else if ((control instanceof EditableDropDownListT) && + (dropDownList.getSelectedItem() != null) && + (!Objects.equals(dropDownList.getSelectedItem(),"")) ) { // use the enumID if the text matches a combo box item, // even if the dropdown was not used to select it for (int i = 0; i < dropDownList.getItemCount(); i++) { - if (((String)dropDownList.getItemAt(i)).equals((String)dropDownList.getSelectedItem())) + if (((String)dropDownList.getItemAt(i)).equals(dropDownList.getSelectedItem())) return getListItems().get(i+1).getEnumID(); } // else use the manually entered text string @@ -60,7 +63,8 @@ else if (control instanceof EditableDropDownListT && } return null; } - + + @Override public String getParameterValue() { int selection = dropDownList.getSelectedIndex(); @@ -74,7 +78,7 @@ public String getParameterValue() // item, even if the dropdown was not used to select it for (int i = 0; i < dropDownList.getItemCount(); i++) { - if (dropDownList.getItemAt(i).equals((String)dropDownList.getSelectedItem())) + if (dropDownList.getItemAt(i).equals(dropDownList.getSelectedItem())) return getEnumWireValue(getListItems().get(i+1).getEnumID()); } // else use the manually entered text string @@ -119,14 +123,14 @@ public void setValue(String value, boolean setValueAsControl) public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (label != null) widgets.add(label); widgets.add(dropDownList); return widgets; } public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(dropDownList); return widgets; } @@ -179,12 +183,12 @@ public void applyConstOrInitValues() { */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? + // ?? adjust the visual appearance of the control ?? } @Override protected List< ? extends Component> createBrickComponents() { - ArrayList components = new ArrayList(); + ArrayList components = new ArrayList<>(); String tooltip = getTooltip(); @@ -206,7 +210,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean // dropDownList items List listItems = ( control instanceof EditableDropDownListT ) ? ( (EditableDropDownListT) control ).getListItem() : ( (DropDownListT) control ).getListItem(); - // TODO: throw error if there are no list items + for ( ListItemT listItem : listItems ) dropDownList.addItem(listItem.getUiRep() != null ? listItem.getUiRep() : ""); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingHiddenFieldWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingHiddenFieldWidget.java index 5c2313a..43e4de2 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingHiddenFieldWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingHiddenFieldWidget.java @@ -61,7 +61,7 @@ public void processReinit( Object aControlInitValue ) } public List< ? extends Component> createBrickComponents() { - return new ArrayList(); + return new ArrayList<>(); } @Override diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingJideClockWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingJideClockWidget.java index 75cac33..6fa50dd 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingJideClockWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingJideClockWidget.java @@ -3,7 +3,11 @@ import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.swing.JCheckBox; @@ -11,7 +15,9 @@ import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.XMLGregorianCalendar; -import org.apache.log4j.Logger; +import org.atdl4j.config.Atdl4jOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.Atdl4jConstants; import org.atdl4j.data.converter.DateTimeConverter; import org.atdl4j.fixatdl.core.LocalMktDateT; @@ -25,8 +31,6 @@ import org.atdl4j.fixatdl.layout.ClockT; import org.atdl4j.ui.impl.ControlHelper; import org.atdl4j.ui.swing.SwingListener; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import com.jidesoft.spinner.DateSpinner; @@ -50,10 +54,10 @@ */ public class SwingJideClockWidget //3/18/2010 Scott Atwell avoid compile error "type parameter org.joda.time.DateTime is not within its bound" extends AbstractSwingWidget - extends AbstractSwingWidget> + extends AbstractSwingWidget> { - private static final Logger logger = Logger.getLogger( SwingJideClockWidget.class ); + private static final Logger logger = LoggerFactory.getLogger( SwingJideClockWidget.class ); public static boolean showEnabledButton = false; public static boolean show24HourClock = true; @@ -83,74 +87,85 @@ public class SwingJideClockWidget private boolean useNowAsDate = false; - public DateTimeZone getLocalMktTz() + public ZoneId getLocalMktTz() throws IllegalArgumentException { // This will throw IllegalArgumentException if ID cannot be resolved - return DateTimeConverter.convertTimezoneToDateTimeZone( ((ClockT) control).getLocalMktTz() ); + return DateTimeConverter.convertTimezoneToZoneId( ((ClockT) control).getLocalMktTz() ); } - public DateTime getControlValueRaw() + public Instant getControlValueRaw() { - if ((dateClock == null) && (timeClock == null)) + if ( ( (dateClock == null) + && ( (showMonthYear) || (showDay) ) ) + || ( (timeClock == null) + && (showTime) ) ) { return null; // disabled, no value to use } - if (!valueFilledIn) { return null; } - - DateTime now = null; - DateTime date = null; - DateTime time = null; - if (useNowAsDate) now = new DateTime( DateTimeZone.getDefault() ); - if (showMonthYear) date = new DateTime(dateClock.getValue()); - if (showTime) time = new DateTime(timeClock.getValue()); - DateTime result = new DateTime(useNowAsDate ? now.getYear() : showMonthYear ? date.getYear() : 1970, - useNowAsDate ? now.getMonthOfYear() : showMonthYear ? date.getMonthOfYear() : 1, - useNowAsDate ? now.getDayOfMonth() : showDay ? date.getDayOfMonth() : 1, - showTime ? time.getHourOfDay() : 0, - showTime ? time.getMinuteOfHour() : 0, - showTime ? time.getSecondOfMinute() : 0, - 0, - DateTimeZone.getDefault() ); - + + ZonedDateTime now = null; + ZonedDateTime date = null; + ZonedDateTime time = null; + if (useNowAsDate) + { + now = ZonedDateTime.now( ZoneId.systemDefault() ); + } + else if ( (showMonthYear) || (showDay) ) + { + date = ZonedDateTime.ofInstant( ((Date) dateClock.getValue()).toInstant(), ZoneId.systemDefault()); + } + if (showTime) + { + time = ZonedDateTime.ofInstant( ((Date) timeClock.getValue()).toInstant(), ZoneId.systemDefault()); + } + ZonedDateTime result = ZonedDateTime.of( useNowAsDate ? now.getYear() : showMonthYear ? date.getYear() : 1970 + , useNowAsDate ? now.getMonthValue() : showMonthYear ? date.getMonthValue() : 1 + , useNowAsDate ? now.getDayOfMonth() : showDay ? date.getDayOfMonth() : 1 + , showTime ? time.getHour() : 0 + , showTime ? time.getMinute() : 0 + , showTime ? time.getSecond() : 0 + , 0 + , ZoneId.systemDefault() + ); // Convert to UTC time for UTCTimestampT and UTCTimeOnlyT. // Performing UTCDateT and MonthYearT coversion could produce an unexpected result. // No conversion is needed for LocalMktTimeT, TZTimestampT, and TZTimeOnlyT. if ( parameter == null || parameter instanceof UTCTimestampT || parameter instanceof UTCTimeOnlyT ) { - result = result.withZone( DateTimeZone.UTC ); - logger.debug( "getControlValue() parameter: " + parameter + " result: " + result ); + result = result.withZoneSameInstant( ZoneId.of("UTC") ); + logger.debug( "getControlValue() parameter: {} result: {}", parameter, result ); } - return result; + return result.toInstant(); } - public void setValue(Comparable value) + public void setValue(Comparable value) { // Convert to UTC time for UTCTimestampT and UTCTimeOnlyT. // Performing UTCDateT and MonthYearT coversion could produce an unexpected result. // No conversion is needed for LocalMktTimeT, TZTimestampT, and TZTimeOnlyT. if ( parameter == null || parameter instanceof UTCTimestampT || parameter instanceof UTCTimeOnlyT ) { - logger.debug( "setValue() parameter: " + parameter + " value: " + value ); + logger.debug( "setValue() parameter: {} value: {}", parameter, value ); // -- no need to adjust DateTime -- } // -- Force control to display time portion in local - DateTime tempLocalTzDateTime = ((DateTime)value).withZone( DateTimeZone.getDefault() ); + ZonedDateTime tempLocalTzDateTime = ZonedDateTime.ofInstant((Instant)value, ZoneId.systemDefault()); - if (showMonthYear) dateClock.setValue(tempLocalTzDateTime.toDate()); - if (showTime) timeClock.setValue(tempLocalTzDateTime.toDate()); + if (showMonthYear) dateClock.setValue( Date.from( tempLocalTzDateTime.toInstant() ) ); + if (showTime) timeClock.setValue( Date.from( tempLocalTzDateTime.toInstant() ) ); valueFilledIn = true; updateFromModel(); } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (enabledButton != null) widgets.add(enabledButton); if (label != null) widgets.add(label); if (showMonthYear) widgets.add(dateClock); @@ -159,7 +174,7 @@ public List getComponents() { } public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (showMonthYear) widgets.add(dateClock); if (showTime) widgets.add(timeClock); return widgets; @@ -187,8 +202,8 @@ protected void setAndRenderInitValue( XMLGregorianCalendar aValue, int aInitValu { // -- Note that this will throw IllegalArgumentException if timezone ID // specified cannot be resolved -- - DateTimeZone tempLocalMktTz = getLocalMktTz(); - logger.debug( "control.getID(): " + control.getID() + " aValue: " + aValue + " getLocalMktTz(): " + tempLocalMktTz ); + ZoneId tempLocalMktTz = getLocalMktTz(); + logger.debug( "control.getID(): {} aValue: {} getLocalMktTz(): {}", control.getID(), aValue, tempLocalMktTz ); // -- localMktTz is required when using/interpreting aValue -- if ( tempLocalMktTz == null ) @@ -197,11 +212,11 @@ protected void setAndRenderInitValue( XMLGregorianCalendar aValue, int aInitValu + control.getID() + ")" ); } - DateTime tempNow = new DateTime( tempLocalMktTz ); + ZonedDateTime tempNow = ZonedDateTime.now( tempLocalMktTz ); - DateTime tempInit = new DateTime( + ZonedDateTime tempInit = ZonedDateTime.of( ( showMonthYear && aValue.getYear() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getYear() : tempNow.getYear(), - ( showMonthYear && aValue.getMonth() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMonth() : tempNow.getMonthOfYear(), + ( showMonthYear && aValue.getMonth() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMonth() : tempNow.getMonthValue(), ( showMonthYear && aValue.getDay() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getDay() : tempNow.getDayOfMonth(), ( showTime && aValue.getHour() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getHour() : 0, ( showTime && aValue.getMinute() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMinute() : 0, @@ -217,7 +232,7 @@ protected void setAndRenderInitValue( XMLGregorianCalendar aValue, int aInitValu } // -- Make sure that the value is rendered on the display in local timezone -- - setValue( tempInit.withZone( DateTimeZone.getDefault() ) ); + setValue( tempInit.withZoneSameInstant( ZoneId.systemDefault() ).toInstant() ); } } @@ -235,8 +250,8 @@ public void processReinit( Object aControlInitValue ) else { // -- reinit the time to present time -- - setValue( new DateTime() ); - valueFilledIn = (enabledButton!=null?false:true); // the editor requires a value but until the + setValue( Instant.now() ); + valueFilledIn = ( enabledButton == null ); // the editor requires a value but until the // enabledButton is checked, considere that no value is filled updateFromModel(); } @@ -247,7 +262,7 @@ public void processReinit( Object aControlInitValue ) */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? + // ?? adjust the visual appearance of the control ?? } /* (non-Javadoc) @@ -258,30 +273,30 @@ public void setFIXValue(String aFIXValue) { super.setFIXValue( aFIXValue ); - DateTime tempFIXValueTime = getControlValueRaw(); - DateTime tempCurrentTime = new DateTime(); + Instant tempFIXValueTime = getControlValueRaw(); + Instant tempCurrentTime = Instant.now(); // -- Check to see if the time set is < current time -- if ( tempCurrentTime.isAfter( tempFIXValueTime ) ) { - logger.debug( "setFIXValue(" + aFIXValue + ") resulted in time < present (" + tempFIXValueTime + " < " + tempCurrentTime + ")" ); + logger.debug( "setFIXValue({}) resulted in time < present ({} < {})", aFIXValue, tempFIXValueTime, tempCurrentTime ); Integer tempClockPastTimeSetFIXValueRule = getAtdl4jOptions().getClockPastTimeSetFIXValueRule( getControl() ); - logger.debug( "Control: " + getControl().getID() + " tempClockPastTimeSetFIXValueRule: " + tempClockPastTimeSetFIXValueRule ); + logger.debug( "Control: {} tempClockPastTimeSetFIXValueRule: {}", getControl().getID(), tempClockPastTimeSetFIXValueRule ); - if ( getAtdl4jOptions().CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS.equals( tempClockPastTimeSetFIXValueRule ) ) + if ( Atdl4jOptions.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS.equals( tempClockPastTimeSetFIXValueRule ) ) { // -- keep as-is -- - logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS rule -- Retaining: " + tempFIXValueTime ); + logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_USE_AS_IS rule -- Retaining: {}", tempFIXValueTime ); } - else if ( getAtdl4jOptions().CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT.equals( tempClockPastTimeSetFIXValueRule ) ) + else if ( Atdl4jOptions.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT.equals( tempClockPastTimeSetFIXValueRule ) ) { - logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT rule -- Setting: " + tempCurrentTime + " ( vs. " + tempFIXValueTime + ")" ); + logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_CURRENT rule -- Setting: {} ( vs. {})", tempCurrentTime, tempFIXValueTime ); setValue( tempCurrentTime ); } - else if ( getAtdl4jOptions().CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL.equals( tempClockPastTimeSetFIXValueRule ) ) + else if ( Atdl4jOptions.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL.equals( tempClockPastTimeSetFIXValueRule ) ) { - logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL rule -- Setting control to 'null value' ( vs. " + tempFIXValueTime + ")" ); + logger.debug("Per Atdl4jConfig.CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL rule -- Setting control to 'null value' ( vs. {})", tempFIXValueTime ); setValueAsString( Atdl4jConstants.VALUE_NULL_INDICATOR ); } } @@ -291,7 +306,7 @@ else if ( getAtdl4jOptions().CLOCK_PAST_TIME_SET_FIX_VALUE_RULE_SET_TO_NULL.equa @Override protected List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); // tooltip String tooltip = control.getTooltip(); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingLabelWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingLabelWidget.java index 977cd04..df6009e 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingLabelWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingLabelWidget.java @@ -38,7 +38,7 @@ public void generateStateRuleListener(SwingListener listener) } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(label); return widgets; } @@ -115,7 +115,7 @@ public void processReinit( Object aControlInitValue ) } private List createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); // label label = new JLabel(); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingListBoxWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingListBoxWidget.java index 4f224e7..8ce6e0b 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingListBoxWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingListBoxWidget.java @@ -21,24 +21,26 @@ public class SwingListBoxWidget { private JList listBox; private JLabel label; - private Vector list = new Vector(); + private Vector list = new Vector<>(); public String getControlValueRaw() { - String value = ""; - List listItems = control instanceof MultiSelectListT ? ( (MultiSelectListT) control ).getListItem() - : ( (SingleSelectListT) control ).getListItem(); + List listItems = control instanceof MultiSelectListT ? ( (MultiSelectListT) control ).getListItem() : ( (SingleSelectListT) control ).getListItem(); int[] selection = listBox.getSelectedIndices(); + StringBuilder tmpStringBuilder = new StringBuilder(""); for ( int i = 0; i < selection.length; i++ ) { - value += listItems.get( selection[ i ] ).getEnumID(); + tmpStringBuilder.append( listItems.get( selection[ i ] ).getEnumID() ); if ( i + 1 != selection.length ) - value += " "; + { + tmpStringBuilder.append( " " ); + } } - return "".equals( value ) ? null : value; + return tmpStringBuilder.toString().isEmpty() ? null : tmpStringBuilder.toString(); } + @Override public String getParameterValue() { // Helper method from AbstractControlUI @@ -79,7 +81,7 @@ public void setValue(String value, boolean setValueAsControl) } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (label != null) widgets.add(label); widgets.add(listBox); return widgets; @@ -87,7 +89,7 @@ public List getComponents() { public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add( listBox ); return widgets; } @@ -117,7 +119,7 @@ public void processReinit( Object aControlInitValue ) else { // -- set to first when no initValue exists -- - if ( list.size() > 0 ) + if ( !list.isEmpty() ) { listBox.setSelectedIndex( 0 ); } @@ -141,13 +143,13 @@ public void applyConstOrInitValues() { */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? + // adjust the visual appearance of the control ?? } @Override protected List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); String tooltip = getTooltip(); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingNullableSpinner.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingNullableSpinner.java index e16848f..aad9a37 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingNullableSpinner.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingNullableSpinner.java @@ -8,29 +8,24 @@ import java.text.ParseException; import java.util.Locale; -import javax.swing.AbstractSpinnerModel; -import javax.swing.JComponent; -import javax.swing.JFormattedTextField; -import javax.swing.JSpinner; -import javax.swing.JTextField; -import javax.swing.SpinnerModel; -import javax.swing.SpinnerNumberModel; +import javax.swing.*; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; -public class SwingNullableSpinner extends JSpinner { - +public class SwingNullableSpinner extends JSpinner +{ private static final long serialVersionUID = 2947835451995064559L; - public static BigDecimal MIN_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( -Integer.MAX_VALUE ); - public static BigDecimal MAX_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( Integer.MAX_VALUE ); + public static final BigDecimal MIN_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( -Integer.MAX_VALUE ); + public static final BigDecimal MAX_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( Integer.MAX_VALUE ); public SwingNullableSpinner() { super(); setModel(new SpinnerNumberModelNull()); setValue(null); } - + + @Override protected JComponent createEditor(SpinnerModel model) { return new NumberEditorNull(this); } @@ -48,15 +43,16 @@ public SpinnerNumberModelNull(Number value, Comparable minimum, Comparable maxim } public SpinnerNumberModelNull(int value, int minimum, int maximum, int stepSize) { - this(new Integer(value), new Integer(minimum), new Integer(maximum), new Integer(stepSize)); + this(Integer.valueOf(value), Integer.valueOf(minimum), Integer.valueOf(maximum), Integer.valueOf(stepSize)); } - public SpinnerNumberModelNull(double value, double minimum, double maximum, double stepSize) { - this(new BigDecimal(value), new BigDecimal(minimum), new BigDecimal(maximum), new BigDecimal(stepSize)); + public SpinnerNumberModelNull(double value, double minimum, double maximum, double stepSize) + { + this( BigDecimal.valueOf(value), BigDecimal.valueOf(minimum), BigDecimal.valueOf(maximum), BigDecimal.valueOf(stepSize)); } public SpinnerNumberModelNull() { - this(new BigDecimal(0), null, null, new BigDecimal(1.00)); + this(BigDecimal.ZERO, null, null, BigDecimal.ONE); } public void setMinimum(Comparable minimum) { @@ -97,39 +93,40 @@ public Number getStepSize() { private Number incrValue(int dir) { Number newValue; - if ((value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) { - if (value == null) value = 0; - + if ((value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) + { long v = value.longValue() + (stepSize.longValue() * (long) dir); if (value instanceof Long) { - newValue = new Long(v); + newValue = Long.valueOf(v); } else if (value instanceof Integer) { - newValue = new Integer((int) v); + newValue = Integer.valueOf((int) v); } else if (value instanceof Short) { - newValue = new Short((short) v); + newValue = Short.valueOf((short) v); } else { - newValue = new Byte((byte) v); + newValue = Byte.valueOf((byte) v); } } - else { - if (value instanceof Float) { - if (value == null) value = 0.; + else + { + if (value instanceof Float) + { double v = value.doubleValue() + (stepSize.doubleValue() * (double) dir); - newValue = new Float(v); + newValue = Float.valueOf(Double.valueOf(v).floatValue()); } - else if (value instanceof Double) { - if (value == null) value = 0.; + else if (value instanceof Double) + { double v = value.doubleValue() + (stepSize.doubleValue() * (double) dir); - newValue = new Double(v); + newValue = Double.valueOf(v); } - else { + else + { if (value == null) value = 0.; double v = value.doubleValue() + (stepSize.doubleValue() * (double) dir); - newValue = new BigDecimal(v); + newValue = BigDecimal.valueOf(v); } } @@ -185,8 +182,8 @@ public NumberEditorNull(JSpinner spinner) { this(spinner, getDefaultPattern(spinner.getLocale())); } - public NumberEditorNull(JSpinner spinner, String decimalFormatPattern) { -// this(spinner, new DecimalFormat(decimalFormatPattern)); + public NumberEditorNull(JSpinner spinner, String decimalFormatPattern) + { this(spinner, new DecimalFormat("0.######")); } @@ -202,7 +199,7 @@ private NumberEditorNull(JSpinner spinner, DecimalFormat format) { JFormattedTextField ftf = getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); - ftf.setHorizontalAlignment(JTextField.RIGHT); + ftf.setHorizontalAlignment(SwingConstants.RIGHT); try { String maxString = formatter.valueToString(model.getMinimum()); @@ -234,20 +231,28 @@ private static class NumberEditorFormatterNull extends NumberFormatter { setCommitsOnValidEdit(true); } - - public void setMinimum(Comparable min) { + + @Override + public void setMinimum(Comparable min) + { model.setMinimum(min); } - - public Comparable getMinimum() { + + @Override + public Comparable getMinimum() + { return model.getMinimum(); } - - public void setMaximum(Comparable max) { + + @Override + public void setMaximum(Comparable max) + { model.setMaximum(max); } - - public Comparable getMaximum() { + + @Override + public Comparable getMaximum() + { return model.getMaximum(); } diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingRadioButtonListWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingRadioButtonListWidget.java index 4435735..c0485d0 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingRadioButtonListWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingRadioButtonListWidget.java @@ -3,6 +3,7 @@ import java.awt.Component; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.swing.ButtonGroup; import javax.swing.JLabel; @@ -18,7 +19,7 @@ public class SwingRadioButtonListWidget extends AbstractSwingWidget { - private List buttons = new ArrayList(); + private List buttons = new ArrayList<>(); private ButtonGroup group = new ButtonGroup(); private JLabel label; @@ -36,6 +37,7 @@ public String getControlValueRaw() return null; } + @Override public String getParameterValue() { return getParameterValueAsEnumWireValue(); @@ -61,18 +63,17 @@ public void setValue(String value, boolean setValueAsControl) public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (label != null) widgets.add( label ); widgets.addAll( buttons ); return widgets; } - public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); - widgets.addAll( buttons ); - return widgets; - } - + public List getComponentsExcludingLabel() + { + return new ArrayList<>(buttons); + } + public void addListener(SwingListener listener) { for ( JRadioButton b : buttons ) { @@ -116,12 +117,11 @@ public void processReinit( Object aControlInitValue ) */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? } - + @Override protected List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); JPanel wrapper = new JPanel(); String tooltip = getTooltip(); @@ -134,20 +134,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean if ( tooltip != null ) label.setToolTipText( tooltip ); components.add(label); } - - /* - //TODO: implement horiz/vert orientation for Swing - if ( ((RadioButtonListT) control).getOrientation() != null && - PanelOrientationT.VERTICAL.equals( ((RadioButtonListT) control).getOrientation() ) ) - { - c.setLayout( new GridLayout( 1, false ) ); - } else { - RowLayout rl = new RowLayout(); - rl.wrap = false; - c.setLayout( rl ); - } - */ - + // radioButton for ( ListItemT listItem : ( (RadioButtonListT) control ).getListItem() ) { @@ -158,7 +145,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean { for ( EnumPairT enumPair : parameter.getEnumPair() ) { - if ( enumPair.getEnumID() == listItem.getEnumID() ) + if (Objects.equals(enumPair.getEnumID(), listItem.getEnumID())) { radioElement.setToolTipText( enumPair.getDescription() ); break; diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingSliderWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingSliderWidget.java index 3d6313f..35912a4 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingSliderWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingSliderWidget.java @@ -2,11 +2,11 @@ import java.awt.Component; import java.util.ArrayList; +import java.util.Dictionary; import java.util.Hashtable; import java.util.List; -import javax.swing.JLabel; -import javax.swing.JSlider; +import javax.swing.*; import org.atdl4j.fixatdl.core.EnumPairT; import org.atdl4j.fixatdl.layout.ListItemT; @@ -25,6 +25,7 @@ public String getControlValueRaw() return ( (SliderT) control ).getListItem().get( slider.getValue() ).getEnumID(); } + @Override public String getParameterValue() { return getParameterValueAsEnumWireValue(); @@ -59,7 +60,7 @@ public void setValue(String value, boolean setValueAsControl) } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(label); widgets.add(slider); return widgets; @@ -67,7 +68,7 @@ public List getComponents() { public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(slider); return widgets; } @@ -108,12 +109,11 @@ public void processReinit( Object aControlInitValue ) */ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean aNewNullValueInd) { - // TODO ?? adjust the visual appearance of the control ?? } @Override protected List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); // label label = new JLabel(); @@ -123,7 +123,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean int numColumns = ((SliderT)control).getListItem().size(); // slider - slider = new JSlider(JSlider.HORIZONTAL, 0, numColumns - 1, 0); + slider = new JSlider(SwingConstants.HORIZONTAL, 0, numColumns - 1, 0); slider.setName(getName()+"/slider"); // add major tick marks @@ -131,32 +131,29 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean slider.setPaintTicks(true); // labels based on parameter ListItemTs - // if ( ( (SliderT) control ).getListItem() != null ) - // { - Hashtable labelTable = new Hashtable(); - int i = 0; - for ( ListItemT li : ( (SliderT) control ).getListItem() ) - { - JLabel label = new JLabel(); - label.setName(getName()+"/slider/"+li.getEnumID()+"/label"); - if (li.getUiRep() != null && !li.getUiRep().equals("")) - { - label.setText( li.getUiRep() ); - } - for ( EnumPairT ep : parameter.getEnumPair() ) - { - if (ep.getEnumID().equals(li.getEnumID()) && ep.getDescription() != null && !ep.getDescription().equals("")) - { - label.setToolTipText(ep.getDescription()); - } - } - labelTable.put(new Integer(i), label); - i++; - } - slider.setLabelTable(labelTable); - slider.setPaintLabels(true); - // } - + Dictionary labelTable = new Hashtable<>(); + int i = 0; + for ( ListItemT li : ( (SliderT) control ).getListItem() ) + { + JLabel tmpJLabel = new JLabel(); + tmpJLabel.setName(getName()+"/slider/"+li.getEnumID()+"/label"); + if (li.getUiRep() != null && !li.getUiRep().equals("")) + { + tmpJLabel.setText( li.getUiRep() ); + } + for ( EnumPairT ep : parameter.getEnumPair() ) + { + if (ep.getEnumID().equals(li.getEnumID()) && ep.getDescription() != null && !ep.getDescription().equals("")) + { + tmpJLabel.setToolTipText(ep.getDescription()); + } + } + labelTable.put(Integer.valueOf(i), tmpJLabel); + i++; + } + slider.setLabelTable(labelTable); + slider.setPaintLabels(true); + // tooltip if ( getTooltip() != null ) { @@ -165,9 +162,10 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, Boolean } if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null ) - setValue( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ), true ); - - //TODO: make this a composite + { + setValue((String) ControlHelper.getInitValue(control, getAtdl4jOptions()), true); + } + components.add(label); components.add(slider); diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingSpinnerWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingSpinnerWidget.java index 965cd18..42d0568 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingSpinnerWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingSpinnerWidget.java @@ -19,6 +19,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; +import javax.swing.SwingConstants; import javax.swing.plaf.basic.BasicArrowButton; import org.atdl4j.data.converter.DecimalConverter; @@ -34,8 +35,6 @@ public class SwingSpinnerWidget extends AbstractSwingWidget { private JLabel label; private JButton buttonUp; private JButton buttonDown; - private static final BigDecimal DEFAULT_INNER_INCREMENT = new BigDecimal(1); - private static final BigDecimal DEFAULT_OUTER_INCREMENT = new BigDecimal(1); private int digits = 0; private JPanel wrapper; @@ -61,16 +60,18 @@ public void actionPerformed(ActionEvent arg0) { spinner.setValue(((BigDecimal) value).add(increment)); } } - - + + + @Override public void setVisible(boolean visible){ if (wrapper != null) wrapper.setVisible(visible); else super.setVisible(visible); } - - + + + @Override public void createWidget(JPanel parent) { List< ? extends Component> components = getBrickComponents(); @@ -104,8 +105,8 @@ private void doButtonsLayout(JPanel buttonPanel) { buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx=0; - buttonUp = new BasicArrowButtonFixedSize(BasicArrowButton.NORTH); - buttonDown = new BasicArrowButtonFixedSize(BasicArrowButton.SOUTH); + buttonUp = new BasicArrowButtonFixedSize(SwingConstants.NORTH); + buttonDown = new BasicArrowButtonFixedSize(SwingConstants.SOUTH); buttonPanel.add(buttonUp, gc); buttonPanel.add(buttonDown, gc); } @@ -141,7 +142,7 @@ public void processReinit(Object aControlInitValue) { protected void applyInitialValue() { Double initValue = (Double) ControlHelper.getInitValue(control, getAtdl4jOptions()); if (initValue != null) { - setValue(new BigDecimal(initValue)); + setValue(BigDecimal.valueOf(initValue)); } else { setValue(null); } @@ -152,7 +153,7 @@ protected void processNullValueIndicatorChange(Boolean aOldNullValueInd, } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(label); widgets.add(spinner); if (control instanceof DoubleSpinnerT) @@ -164,7 +165,7 @@ public List getComponents() { } public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(spinner); if (control instanceof DoubleSpinnerT) { @@ -221,7 +222,7 @@ public Dimension getPreferredSize() { @Override public List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); String tooltip = getTooltip(); @@ -292,7 +293,7 @@ else if (control instanceof DoubleSpinnerT) SpinnerNumberModelNull model = (SpinnerNumberModelNull)spinner.getModel(); // Set min/max/precision if a parameter is attached - if ( parameterConverter != null && parameterConverter instanceof DecimalConverter ) + if ( parameterConverter instanceof DecimalConverter ) { DecimalConverter tempDecimalConverter = (DecimalConverter) parameterConverter; @@ -321,7 +322,7 @@ else if (control instanceof DoubleSpinnerT) model.setMaximum( tempControlMax.setScale( digits, RoundingMode.HALF_UP ) ); } } - else if ( parameterConverter != null && parameterConverter instanceof IntegerConverter ) + else if ( parameterConverter instanceof IntegerConverter ) { IntegerConverter tempIntegerConverter = (IntegerConverter) parameterConverter; @@ -384,11 +385,11 @@ else if ( control instanceof SingleSpinnerT ) if ( digits != 0 ) { // -- Set the increment to the precision associated with digits (eg ".01" when digits=2, ".001" when digits=3) -- - model.setStepSize( new BigDecimal( Math.pow( 10, -digits ) ).setScale( digits, RoundingMode.HALF_UP ) ); + model.setStepSize( BigDecimal.valueOf( Math.pow( 10, -digits ) ).setScale( digits, RoundingMode.HALF_UP ) ); } else { - model.setStepSize( new BigDecimal( "1" ) ); + model.setStepSize( BigDecimal.ONE ); } } diff --git a/src/main/java/org/atdl4j/ui/swing/widget/SwingTextFieldWidget.java b/src/main/java/org/atdl4j/ui/swing/widget/SwingTextFieldWidget.java index 55e83df..aa5a466 100644 --- a/src/main/java/org/atdl4j/ui/swing/widget/SwingTextFieldWidget.java +++ b/src/main/java/org/atdl4j/ui/swing/widget/SwingTextFieldWidget.java @@ -16,12 +16,13 @@ import org.atdl4j.ui.swing.SwingListener; public class SwingTextFieldWidget - extends AbstractSwingWidget + extends AbstractSwingWidget { private JFormattedTextField textField; private JLabel label; private JPanel wrapper; + @Override public void createWidget(JPanel parent) { // tooltip @@ -46,24 +47,26 @@ public void createWidget(JPanel parent) // tooltip if (tooltip != null) textField.setToolTipText(tooltip); - if (label != null){ + if (label != null) + { wrapper = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 1; - c.weightx = 1.0; - c.weighty = 1.0; - c.insets = new Insets(0, 0, 0, 0); - wrapper.add( label, c); + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 1; + c.weightx = 1.0; + c.weighty = 1.0; + c.insets = new Insets(0, 0, 0, 0); + wrapper.add( label, c); c.gridx = 1; - c.gridy = 0; - c.insets = new Insets(0, 0, 0, 0); - wrapper.add( textField, c); + c.gridy = 0; + c.insets = new Insets(0, 0, 0, 0); + wrapper.add( textField, c); parent.add(wrapper); } - else { + else + { parent.add(textField); } @@ -71,8 +74,7 @@ public void createWidget(JPanel parent) textField.revalidate(); } - - + @Override public void setVisible(boolean visible){ if (wrapper != null) wrapper.setVisible(visible); @@ -96,18 +98,18 @@ public String getControlValueRaw() public void setValue(String value) { - textField.setText( ( value == null ) ? "" : value.toString() ); + textField.setText( ( value == null ) ? "" : value ); } public List getComponents() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if (label != null) widgets.add(label); widgets.add(textField); return widgets; } public List getComponentsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add(textField); return widgets; } @@ -123,6 +125,7 @@ public void removeListener(SwingListener listener) { /** * Overridden -- makes the textField appear non-editable vs. the default of disabled. */ + @Override public void processConstValueHasBeenSet() { textField.setEditable( false ); @@ -155,7 +158,7 @@ public void processReinit( Object aControlInitValue ) @Override public List< ? extends Component> createBrickComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); // tooltip String tooltip = control.getTooltip(); diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jCompositePanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jCompositePanel.java index db633f2..ba5614b 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jCompositePanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jCompositePanel.java @@ -1,6 +1,5 @@ package org.atdl4j.ui.swt.app.impl; -import org.apache.log4j.Logger; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.StrategySelectionEvent; @@ -24,7 +23,6 @@ public class SWTAtdl4jCompositePanel extends AbstractAtdl4jCompositePanel { - public final Logger logger = Logger.getLogger(SWTAtdl4jCompositePanel.class); private Composite parentComposite; private Composite okCancelButtonSection; @@ -71,7 +69,8 @@ protected Composite createOkCancelButtonSection() okButton.setToolTipText( "Validate and accept the specified strategy and parameters" ); okButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) + @Override + public void widgetSelected(SelectionEvent e) { okButtonSelected(); } @@ -84,7 +83,8 @@ public void widgetSelected(SelectionEvent e) cancelButton.setToolTipText( "Cancel ignoring any specified changes" ); cancelButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) + @Override + public void widgetSelected(SelectionEvent e) { cancelButtonSelected(); } @@ -111,8 +111,12 @@ public void setVisibleOkCancelButtonSection( boolean aVisible ) protected void packLayout() { - getShell().layout(); - getShell().pack(); + Shell tmpShell = getShell(); + if ( tmpShell != null ) + { + tmpShell.layout(); + tmpShell.pack(); + } } /** diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataPanel.java index a05be50..578b10c 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataPanel.java @@ -6,7 +6,8 @@ import java.util.Arrays; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.config.StrategyFilterInputData; @@ -32,7 +33,7 @@ public class SWTAtdl4jInputAndFilterDataPanel extends AbstractAtdl4jInputAndFilterDataPanel { - public final Logger logger = Logger.getLogger(SWTAtdl4jInputAndFilterDataPanel.class); + public final Logger logger = LoggerFactory.getLogger(SWTAtdl4jInputAndFilterDataPanel.class); private Composite parentComposite; private Combo dropDownListStrategyFilterFixMsgType; @@ -71,7 +72,7 @@ public Object buildAtdl4jInputAndFilterDataPanel(Object aParentOrShell, Atdl4jOp public Composite buildAtdl4jInputAndFilterDataPanel(Composite aParentOrShell, Atdl4jOptions aAtdl4jOptions) { - parentComposite = (Composite) aParentOrShell; + parentComposite = aParentOrShell; // -- Delegate back to AbstractAtdl4jInputAndFilterDataPanel -- init( aParentOrShell, aAtdl4jOptions ); @@ -123,7 +124,7 @@ protected Composite buildStrategyFilterPanel( Composite aParent ) Label tempLabelStrategyFilterFixMsgType = new Label( tempRowOne, SWT.NONE ); tempLabelStrategyFilterFixMsgType.setText( "FixMsgType:" ); dropDownListStrategyFilterFixMsgType = new Combo( tempRowOne, SWT.READ_ONLY ); - List tempFixMsgTypeList = new ArrayList(); + List tempFixMsgTypeList = new ArrayList<>(); tempFixMsgTypeList.add( "" ); // add empty string at top tempFixMsgTypeList.addAll( Arrays.asList( Atdl4jConstants.STRATEGY_FILTER_FIX_MSG_TYPES ) ); dropDownListStrategyFilterFixMsgType.setItems( tempFixMsgTypeList.toArray( new String[0] ) ); @@ -139,7 +140,7 @@ protected Composite buildStrategyFilterPanel( Composite aParent ) Label tempLabelStrategyFilterRegion = new Label( tempRowTwo, SWT.NONE ); tempLabelStrategyFilterRegion.setText( "Region:" ); dropDownListStrategyFilterRegion = new Combo( tempRowTwo, SWT.READ_ONLY ); - List tempRegionList = new ArrayList(); + List tempRegionList = new ArrayList<>(); tempRegionList.add( "" ); // add empty string at top tempRegionList.addAll( Arrays.asList( Atdl4jConstants.STRATEGY_FILTER_REGIONS ) ); dropDownListStrategyFilterRegion.setItems( tempRegionList.toArray( new String[0] ) ); @@ -162,7 +163,7 @@ protected Composite buildStrategyFilterPanel( Composite aParent ) Label tempLabelStrategyFilterSecurityType = new Label( tempRowTwo, SWT.NONE ); tempLabelStrategyFilterSecurityType.setText( "Security Type:" ); dropDownListStrategyFilterSecurityType = new Combo( tempRowTwo, SWT.NONE ); - List tempSecurityTypeList = new ArrayList(); + List tempSecurityTypeList = new ArrayList<>(); tempSecurityTypeList.add( "" ); // add empty string at top tempSecurityTypeList.addAll( Arrays.asList( Atdl4jConstants.STRATEGY_FILTER_SECURITY_TYPES ) ); dropDownListStrategyFilterSecurityType.setItems( tempSecurityTypeList.toArray( new String[0] ) ); @@ -329,14 +330,14 @@ protected Composite buildIncrementPolicyPanel( Composite aParent ) textIncrementPolicyLotSize = new Text( tempIncrementPolicyGroup, SWT.NONE ); textIncrementPolicyLotSize.setToolTipText( "May be used in conjunction with Control/@incrementPolicy on spinner controls" ); textIncrementPolicyLotSize.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false )); - setTextValue( textIncrementPolicyLotSize, getAtdl4jOptions().getInputAndFilterData().getInputIncrementPolicy_LotSize() ); + setTextValue( textIncrementPolicyLotSize, getAtdl4jOptions().getInputAndFilterData().getInputIncrementPolicyLotSize() ); Label tempLabelIncrementPolicyTick = new Label( tempIncrementPolicyGroup, SWT.NONE ); tempLabelIncrementPolicyTick.setText( "Tick Size:" ); textIncrementPolicyTick = new Text( tempIncrementPolicyGroup, SWT.NONE ); textIncrementPolicyTick.setToolTipText( "May be used in conjunction with Control/@incrementPolicy on spinner controls" ); textIncrementPolicyTick.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false )); - setTextValue( textIncrementPolicyTick, getAtdl4jOptions().getInputAndFilterData().getInputIncrementPolicy_Tick() ); + setTextValue( textIncrementPolicyTick, getAtdl4jOptions().getInputAndFilterData().getInputIncrementPolicyTick() ); return tempIncrementPolicyGroup; } @@ -382,8 +383,8 @@ public boolean extractAtdl4jOptionsFromScreen() Atdl4jConfig.getConfig().setShowTesterPanelOkCancelButtonSection( getCheckboxValue( checkboxAtd4ljShowTesterPanelOkCancelButtonSection, null ).booleanValue() ); getAtdl4jOptions().setAccommodateMixOfStrategyPanelsAndControls( getCheckboxValue( checkboxAtd4ljAccommodateMixOfStrategyPanelsAndControls, null ).booleanValue() ); - getAtdl4jOptions().getInputAndFilterData().setInputIncrementPolicy_LotSize( getTextValueAsBigDecimal( textIncrementPolicyLotSize ) ); - getAtdl4jOptions().getInputAndFilterData().setInputIncrementPolicy_Tick( getTextValueAsBigDecimal( textIncrementPolicyTick ) ); + getAtdl4jOptions().getInputAndFilterData().setInputIncrementPolicyLotSize( getTextValueAsBigDecimal( textIncrementPolicyLotSize ) ); + getAtdl4jOptions().getInputAndFilterData().setInputIncrementPolicyTick( getTextValueAsBigDecimal( textIncrementPolicyTick ) ); return true; } @@ -396,31 +397,31 @@ public boolean loadScreenWithAtdl4jOptions() { StrategyFilterInputData tempStrategyFilterInputData = null; if ( ( getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList() != null ) && - ( getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().size() > 0 ) ) + ( ! getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().isEmpty() ) ) { tempStrategyFilterInputData = getAtdl4jOptions().getInputAndFilterData().getStrategyFilterInputDataList().get( 0 ); } String tempFixMsgType = null; - String tempRegion_name = null; - String tempCountry_CountryCode = null; - String tempMarket_MICCode = null; - String tempSecurityType_name = null; + String tempRegionName = null; + String tempCountryCountryCode = null; + String tempMarketMicCode = null; + String tempSecurityTypeName = null; if ( tempStrategyFilterInputData != null ) { tempFixMsgType = tempStrategyFilterInputData.getFixMsgType(); - tempRegion_name = tempStrategyFilterInputData.getRegion_name(); - tempCountry_CountryCode = tempStrategyFilterInputData.getCountry_CountryCode(); - tempMarket_MICCode = tempStrategyFilterInputData.getMarket_MICCode(); - tempSecurityType_name = tempStrategyFilterInputData.getSecurityType_name(); + tempRegionName = tempStrategyFilterInputData.getRegion_name(); + tempCountryCountryCode = tempStrategyFilterInputData.getCountry_CountryCode(); + tempMarketMicCode = tempStrategyFilterInputData.getMarket_MICCode(); + tempSecurityTypeName = tempStrategyFilterInputData.getSecurityType_name(); } selectDropDownItem( dropDownListStrategyFilterFixMsgType, tempFixMsgType ); - selectDropDownItem( dropDownListStrategyFilterRegion, tempRegion_name ); - selectDropDownItem( dropDownListStrategyFilterCountry, tempCountry_CountryCode ); - selectDropDownItem( dropDownListStrategyFilterMICCode, tempMarket_MICCode ); - selectDropDownItem( dropDownListStrategyFilterSecurityType, tempSecurityType_name ); + selectDropDownItem( dropDownListStrategyFilterRegion, tempRegionName ); + selectDropDownItem( dropDownListStrategyFilterCountry, tempCountryCountryCode ); + selectDropDownItem( dropDownListStrategyFilterMICCode, tempMarketMicCode ); + selectDropDownItem( dropDownListStrategyFilterSecurityType, tempSecurityTypeName ); setCheckboxValue( checkboxInputCxlReplaceMode, getAtdl4jOptions().getInputAndFilterData().getInputCxlReplaceMode(), Boolean.FALSE ); @@ -468,18 +469,18 @@ public static void setTextList( Text aText, List aList ) } else { - StringBuffer tempBuffer = new StringBuffer(); + StringBuilder tmpStringBuilder = new StringBuilder(); for (String tempString : aList ) { - if ( tempBuffer.length() > 0 ) + if ( tmpStringBuilder.length() > 0 ) { - tempBuffer.append( '\n' ); + tmpStringBuilder.append( '\n' ); } - - tempBuffer.append( tempString ); + + tmpStringBuilder.append( tempString ); } - aText.setText( tempBuffer.toString() ); + aText.setText( tmpStringBuilder.toString() ); } } @@ -568,7 +569,7 @@ public static Boolean getCheckboxValue( Button aCheckbox, Boolean aNullIfState ) } else { - return new Boolean( tempBool ); + return Boolean.valueOf( tempBool ); } } diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataSelectionPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataSelectionPanel.java index 503b437..ec2b6e6 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataSelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jInputAndFilterDataSelectionPanel.java @@ -1,7 +1,7 @@ package org.atdl4j.ui.swt.app.impl; -import org.apache.log4j.Logger; -import org.atdl4j.config.Atdl4jConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.Atdl4jUserMessageHandler; import org.atdl4j.ui.app.impl.AbstractAtdl4jInputAndFilterDataSelectionPanel; @@ -23,13 +23,12 @@ public class SWTAtdl4jInputAndFilterDataSelectionPanel extends AbstractAtdl4jInputAndFilterDataSelectionPanel { - public final Logger logger = Logger.getLogger(SWTAtdl4jInputAndFilterDataSelectionPanel.class); + public final Logger logger = LoggerFactory.getLogger(SWTAtdl4jInputAndFilterDataSelectionPanel.class); private Composite parentComposite; private Button atdl4jInputAndFilterDataPanelButton; private Shell atdl4jInputAndFilterDataPanelShell; - private Button debugModeButton; - + public Object buildAtdl4jInputAndFilterDataSelectionPanel(Object aParentOrShell, Atdl4jOptions aAtdl4jOptions, Atdl4jUserMessageHandler aAtdl4jUserMessageHandler) { return buildAtdl4jInputAndFilterDataSelectionPanel( (Composite) aParentOrShell, aAtdl4jOptions, aAtdl4jUserMessageHandler ); @@ -37,7 +36,7 @@ public Object buildAtdl4jInputAndFilterDataSelectionPanel(Object aParentOrShell, public Composite buildAtdl4jInputAndFilterDataSelectionPanel(Composite aParentOrShell, Atdl4jOptions aAtdl4jOptions, Atdl4jUserMessageHandler aAtdl4jUserMessageHandler) { - parentComposite = (Composite) aParentOrShell; + parentComposite = aParentOrShell; // -- Delegate back to AbstractAtdl4jInputAndFilterDataSelectionPanel -- init( aParentOrShell, aAtdl4jOptions, aAtdl4jUserMessageHandler ); @@ -47,6 +46,7 @@ public Composite buildAtdl4jInputAndFilterDataSelectionPanel(Composite aParentOr atdl4jInputAndFilterDataPanelButton.setText( "Input And Filter Data" ); atdl4jInputAndFilterDataPanelButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { buttonInputAndFilterDataSelected(); @@ -75,8 +75,7 @@ private void buttonInputAndFilterDataSelected() } getAtdl4jInputAndFilterDataPanel().loadScreenWithAtdl4jOptions(); - getDebugModeButton().setSelection( Atdl4jConfig.getConfig().isDebugLoggingLevel() ); - + // -- Open/Pop-up the dialog window -- atdl4jInputAndFilterDataPanelShell.open(); } @@ -113,6 +112,7 @@ private Shell createAtdl4jInputAndFilterDataPanelShell() tempOkButton.setText( "OK" ); tempOkButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { buttonOkSelected(); @@ -123,6 +123,7 @@ public void widgetSelected(SelectionEvent e) tempCancelButton.setText( "Cancel" ); tempCancelButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { buttonCancelSelected(); @@ -133,37 +134,10 @@ public void widgetSelected(SelectionEvent e) Button tempBlankButton = new Button(tempFooter, SWT.NONE); tempBlankButton.setVisible(false); - setDebugModeButton( new Button(tempFooter, SWT.CHECK) ); - getDebugModeButton().setText("Debug Mode"); - - getDebugModeButton().addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - Atdl4jConfig.getConfig().setDebugLoggingLevel( getDebugModeButton().getSelection() ); - } - }); - tempAtdl4jInputAndFilterDataPanelShell.layout( true ); tempAtdl4jInputAndFilterDataPanelShell.pack(); return tempAtdl4jInputAndFilterDataPanelShell; } - /** - * @return the debugModeButton - */ - public Button getDebugModeButton() - { - return this.debugModeButton; - } - - /** - * @param aDebugModeButton the debugModeButton to set - */ - public void setDebugModeButton(Button aDebugModeButton) - { - this.debugModeButton = aDebugModeButton; - } - } diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterApp.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterApp.java index 79d49d7..0d481c2 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterApp.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterApp.java @@ -4,7 +4,8 @@ */ package org.atdl4j.ui.swt.app.impl; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jConfiguration; import org.atdl4j.config.Atdl4jOptions; @@ -28,7 +29,7 @@ public class SWTAtdl4jTesterApp extends AbstractAtdl4jTesterApp { - public final Logger logger = Logger.getLogger( SWTAtdl4jTesterApp.class ); + public final Logger logger = LoggerFactory.getLogger( SWTAtdl4jTesterApp.class ); private Shell shell; /** @@ -63,10 +64,6 @@ public void mainLine(String[] args, Atdl4jConfiguration config) throws Exception shell = new Shell( display ); GridLayout shellLayout = new GridLayout( 1, true ); shell.setLayout( shellLayout ); - // shell.setText( - // "atdl4j(sm)- The Open-Source Java Solution for FIXatdl(sm)" ); - // \u2120 should work but just get square box shell.setText( - // "atdl4j\u2120 - The Open-Source Java Solution for FIXatdl\u2120" ); shell.setText( "atdl4j - The Open-Source Java Solution for FIXatdl" ); // -- Delegate setup to AbstractAtdl4jTesterApp, construct a new @@ -77,7 +74,6 @@ public void mainLine(String[] args, Atdl4jConfiguration config) throws Exception getAtdl4jTesterPanel().buildAtdl4jTesterPanel( shell, getAtdl4jOptions() ); // -- SWT-specific stuff to improve layout -- - // screen sizing works better with pack() after open() shell.pack(); shell.open(); shell.pack(); diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterPanel.java index 41fae92..18111ba 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jTesterPanel.java @@ -4,7 +4,8 @@ */ package org.atdl4j.ui.swt.app.impl; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.exception.ValidationException; @@ -38,7 +39,7 @@ public class SWTAtdl4jTesterPanel extends AbstractAtdl4jTesterPanel { - public final Logger logger = Logger.getLogger(SWTAtdl4jTesterPanel.class); + public final Logger logger = LoggerFactory.getLogger(SWTAtdl4jTesterPanel.class); private Composite parentComposite; private Composite inputAndFilterDataAndLoadMessageComposite; @@ -62,23 +63,6 @@ public Composite buildAtdl4jTesterPanel(Composite aParentOrShell, Atdl4jOptions // -- Delegate back to AbstractAtdl4jTesterPanel -- init( aParentOrShell, aAtdl4jOptions ); - -//TODO any "tester-specific stuff" to add??? - -//TODO -// if (getAtdl4jOptions().isShowTimezoneSelector()) -// { -// -// Label tzLabel = new Label(headerComposite, SWT.NONE); -// tzLabel.setText("Timezone:"); -// // dropDownList -// Combo tzDropDown = new Combo(headerComposite, SWT.READ_ONLY | SWT.BORDER); -// GridData tzData = new GridData(SWT.FILL, SWT.CENTER, true, true); -// tzData.horizontalSpan = 2; -// tzDropDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, -// false)); -// } - inputAndFilterDataAndLoadMessageComposite = new Group( aParentOrShell, SWT.NONE ); ((Group) inputAndFilterDataAndLoadMessageComposite).setText( "Testing Input" ); @@ -105,16 +89,7 @@ public Composite buildAtdl4jTesterPanel(Composite aParentOrShell, Atdl4jOptions // -- Build the SWT MenuItems -- createMenuItems(); - - - // -- Implied -- -/** - setVisibleTestingInputSection( true ); - setVisibleFileSelectionSection( true ); - setVisibleValidateOutputSection( true ); - setVisibleOkCancelButtonSection( true ); -**/ - + return parentComposite; } @@ -186,7 +161,8 @@ protected Composite createValidateOutputSection() validateButton.setText("Validate Output"); validateButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) + @Override + public void widgetSelected(SelectionEvent e) { try { validateButtonSelected(); @@ -252,7 +228,8 @@ protected Composite createOkCancelButtonSection() okButton.setToolTipText( "Validate and accept the specified strategy and parameters" ); okButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) + @Override + public void widgetSelected(SelectionEvent e) { okButtonSelected(); } @@ -265,7 +242,8 @@ public void widgetSelected(SelectionEvent e) cancelButton.setToolTipText( "Cancel ignoring any specified changes" ); cancelButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) + @Override + public void widgetSelected(SelectionEvent e) { cancelButtonSelected(); } @@ -291,8 +269,12 @@ public void setVisibleOkCancelButtonSection( boolean aVisible ) protected void packLayout() { - getShell().layout(); - getShell().pack(); + Shell tmpShell = getShell(); + if (tmpShell != null) + { + tmpShell.layout(); + tmpShell.pack(); + } } diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jUserMessageHandler.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jUserMessageHandler.java index 24b56ba..2be880b 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jUserMessageHandler.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTAtdl4jUserMessageHandler.java @@ -1,7 +1,8 @@ package org.atdl4j.ui.swt.app.impl; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.ui.app.impl.AbstractAtdl4jUserMessageHandler; import org.eclipse.swt.SWT; @@ -19,7 +20,7 @@ public class SWTAtdl4jUserMessageHandler extends AbstractAtdl4jUserMessageHandler { - private final Logger logger = Logger.getLogger(SWTAtdl4jUserMessageHandler.class); + private final Logger logger = LoggerFactory.getLogger(SWTAtdl4jUserMessageHandler.class); private Composite parentComposite; diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTFixMsgLoadPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTFixMsgLoadPanel.java index 50215ae..f9da685 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTFixMsgLoadPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTFixMsgLoadPanel.java @@ -48,6 +48,7 @@ public Composite buildFixMsgLoadPanel(Composite aParentComposite, Atdl4jOptions loadFixMsgButton.setText("Load Message"); loadFixMsgButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { loadFixMessage(); diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategyDescriptionPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategyDescriptionPanel.java index 5767921..3f78720 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategyDescriptionPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategyDescriptionPanel.java @@ -22,8 +22,7 @@ public class SWTStrategyDescriptionPanel private Composite composite; private Text strategyDescription; - private int DEFAULT_COMPOSITE_HEIGHT_HINT = 45; - private int DEFAULT_STRATEGY_DESCRIPTION_HEIGHT_HINT = 35; + private static final int DEFAULT_STRATEGY_DESCRIPTION_HEIGHT_HINT = 35; public Object buildStrategyDescriptionPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions) { diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategySelectionPanel.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategySelectionPanel.java index 009520e..ccc0db4 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategySelectionPanel.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTStrategySelectionPanel.java @@ -3,7 +3,8 @@ import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jConfig; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.Atdl4jHelper; @@ -32,7 +33,7 @@ public class SWTStrategySelectionPanel extends AbstractStrategySelectionPanel { - private final Logger logger = Logger.getLogger(SWTStrategySelectionPanel.class); + private static final Logger logger = LoggerFactory.getLogger(SWTStrategySelectionPanel.class); private Composite dropdownComposite; private Combo strategiesDropDown; @@ -76,9 +77,7 @@ public void widgetDisposed(DisposeEvent e) newFont.dispose(); } }); - -// TODO wish to avoid issue with changing the font causes the initial combo box display to be very narrow - + if ( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth() != null ) { strategiesDropDown.setVisibleItemCount( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth().intValue() ); @@ -92,7 +91,7 @@ public void widgetDisposed(DisposeEvent e) public void widgetSelected(SelectionEvent event) { int index = strategiesDropDown.getSelectionIndex(); - logger.debug( "strategiesDropDown.widgetSelected. strategiesDropDown.getSelectionIndex(): " + index ); + logger.debug( "strategiesDropDown.widgetSelected. strategiesDropDown.getSelectionIndex(): {}", index ); selectDropDownStrategy( index ); } } @@ -115,7 +114,7 @@ public void loadStrategyList( List aStrategyList ) for (StrategyT tempStrategy : getStrategiesList()) { - logger.debug( "loadStrategyList() [" + strategiesDropDown.getItemCount() + "] strategiesDropDown.add: " + Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); + logger.debug( "loadStrategyList() [{}] strategiesDropDown.add: {}", strategiesDropDown.getItemCount(), Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); // create dropdown item for strategy strategiesDropDown.add( Atdl4jHelper.getStrategyUiRepOrName( tempStrategy ) ); @@ -127,7 +126,7 @@ public void loadStrategyList( List aStrategyList ) public void selectDropDownStrategy(int index) { - logger.debug( "selectDropDownStrategy() index: " + index ); + logger.debug( "selectDropDownStrategy() index: {}", index ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -149,7 +148,7 @@ public void selectDropDownStrategy(int index) public void selectDropDownStrategyByStrategyName(String aStrategyName) { - logger.debug( "selectDropDownStrategyByStrategyName() aStrategyName: " + aStrategyName ); + logger.debug( "selectDropDownStrategyByStrategyName() aStrategyName: {}", aStrategyName ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -162,7 +161,7 @@ public void selectDropDownStrategyByStrategyName(String aStrategyName) if ( aStrategyName.equals( tempStrategy.getName() ) ) { - logger.debug( "selectDropDownStrategyByStrategyName() invoking selectDropDownStrategy( " + i + " )" ); + logger.debug( "selectDropDownStrategyByStrategyName() invoking selectDropDownStrategy( {} )", i ); selectDropDownStrategy( i ); } } @@ -170,7 +169,7 @@ public void selectDropDownStrategyByStrategyName(String aStrategyName) public void selectDropDownStrategyByStrategyWireValue( String aStrategyWireValue ) { - logger.debug( "selectDropDownStrategyByStrategyWireValue() aStrategyWireValue: " + aStrategyWireValue ); + logger.debug( "selectDropDownStrategyByStrategyWireValue() aStrategyWireValue: {}", aStrategyWireValue ); if ( getStrategiesList().size() != strategiesDropDown.getItemCount() ) { @@ -183,7 +182,7 @@ public void selectDropDownStrategyByStrategyWireValue( String aStrategyWireValue if ( aStrategyWireValue.equals( tempStrategy.getWireValue() ) ) { - logger.debug( "selectDropDownStrategyByStrategyWireValue() invoking selectDropDownStrategy( " + i + " )" ); + logger.debug( "selectDropDownStrategyByStrategyWireValue() invoking selectDropDownStrategy( {} )", i ); selectDropDownStrategy( i ); } } diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleComposite.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleComposite.java index 53910bf..10b69c2 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleComposite.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleComposite.java @@ -19,7 +19,7 @@ public class SWTVisibleComposite extends Composite { - public static Point POINT_0_0 = new Point( 0, 0 ); + public static final Point POINT_0_0 = new Point( 0, 0 ); /** * @param aParent @@ -36,6 +36,7 @@ public SWTVisibleComposite(Composite aParent, int aStyle) * Override * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean) */ + @Override public Point computeSize(int wHint, int hHint, boolean changed) { if ( !isVisible() ) @@ -53,6 +54,7 @@ public Point computeSize(int wHint, int hHint, boolean changed) * @see http://www.eclipsezone.com/eclipse/forums/t88689.html * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean) */ + @Override protected void checkSubclass() { // Disable the check that prevents subclassing of SWT components diff --git a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleGroup.java b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleGroup.java index 6382d91..b5ce090 100644 --- a/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleGroup.java +++ b/src/main/java/org/atdl4j/ui/swt/app/impl/SWTVisibleGroup.java @@ -21,7 +21,7 @@ public class SWTVisibleGroup extends Group { - public static Point POINT_0_0 = new Point( 0, 0 ); + public static final Point POINT_0_0 = new Point( 0, 0 ); /** * @param aParent @@ -38,6 +38,7 @@ public SWTVisibleGroup(Composite aParent, int aStyle) * Override * @see org.eclipse.swt.widgets.Group#computeSize(int, int, boolean) */ + @Override public Point computeSize(int wHint, int hHint, boolean changed) { if ( !isVisible() ) @@ -55,6 +56,7 @@ public Point computeSize(int wHint, int hHint, boolean changed) * @see http://www.eclipsezone.com/eclipse/forums/t88689.html * @see org.eclipse.swt.widgets.Group#computeSize(int, int, boolean) */ + @Override protected void checkSubclass() { // Disable the check that prevents subclassing of SWT components diff --git a/src/main/java/org/atdl4j/ui/swt/config/SWTAtdl4jConfiguration.java b/src/main/java/org/atdl4j/ui/swt/config/SWTAtdl4jConfiguration.java index c5575a2..60ad8ab 100644 --- a/src/main/java/org/atdl4j/ui/swt/config/SWTAtdl4jConfiguration.java +++ b/src/main/java/org/atdl4j/ui/swt/config/SWTAtdl4jConfiguration.java @@ -12,7 +12,7 @@ public class SWTAtdl4jConfiguration extends AbstractAtdl4jConfiguration { - private static String PACKAGE_PATH_ORG_ATDL4J_UI_SWT = "org.atdl4j.ui.swt."; + private static final String PACKAGE_PATH_ORG_ATDL4J_UI_SWT = "org.atdl4j.ui.swt."; public SWTAtdl4jConfiguration() { diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTControlEvent.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTControlEvent.java index bf12b36..1d2eb89 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTControlEvent.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTControlEvent.java @@ -9,8 +9,8 @@ public class SWTControlEvent extends Event { private SWTWidget widget; - public SWTControlEvent(SWTWidget widget) { - this.widget = widget; + public SWTControlEvent(SWTWidget aWidget) { + this.widget = aWidget; } public SWTWidget getWidget() { diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTExpandBarResizer.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTExpandBarResizer.java index e934252..c8f8d43 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTExpandBarResizer.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTExpandBarResizer.java @@ -21,12 +21,14 @@ public SWTExpandBarResizer( Composite aComposite ) { composite = aComposite; } - + + @Override public void itemCollapsed(ExpandEvent aE) { SWTStrategyPanelHelper.revalidateLayoutAsync( (ExpandBar)composite.getParent() ); } + @Override public void itemExpanded(ExpandEvent aE) { SWTStrategyPanelHelper.revalidateLayoutAsync( (ExpandBar)composite.getParent() ); diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStateListener.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStateListener.java index 137261e..65edd9d 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStateListener.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStateListener.java @@ -48,7 +48,7 @@ public void handleEvent(Event event) { // Create a casted map so that Validatable can be used - Map> targets = new HashMap>( controls ); + Map> targets = new HashMap<>( controls ); try { @@ -88,7 +88,7 @@ protected void setBehaviorAsStateRule(Boolean state) // set value if ( stateRule.getValue() != null ) { - if ( state ) + if (Boolean.TRUE.equals(state) ) { String value = stateRule.getValue(); affectedWidget.setValueAsString( value ); diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategiesUI.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategiesUI.java index ba3277d..1255df2 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategiesUI.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategiesUI.java @@ -3,7 +3,8 @@ import java.util.HashMap; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.config.Atdl4jOptions; import org.atdl4j.data.Atdl4jHelper; import org.atdl4j.data.ValidationRule; @@ -23,7 +24,7 @@ public class SWTStrategiesUI extends AbstractStrategiesUI { - private final Logger logger = Logger.getLogger( SWTStrategiesUI.class ); + private final Logger logger = LoggerFactory.getLogger( SWTStrategiesUI.class ); private Composite strategiesPanel; @@ -77,7 +78,7 @@ public void createStrategyPanels(StrategiesT aStrategies, List aFilte { setStrategies( aStrategies ); - setStrategiesRules( new HashMap() ); + setStrategiesRules( new HashMap<>() ); for (EditT edit : getStrategies().getEdit()) { String id = edit.getId(); if (id != null) { @@ -95,23 +96,19 @@ public void createStrategyPanels(StrategiesT aStrategies, List aFilte for ( StrategyT strategy : aFilteredStrategyList ) { - /******************************************************************************************** +/* + ******************************************************************************************** * 6/23/2010 Scott Atwell * Note that we are creating the StrategyUI for each Strategy in the file, however, we are * disposing/discarding the previously built StrategyUI instances. * SWTStrategiesPanel will have at most only one StrategyUI that has not been disposed. * This is required to avoid very large FIXatdl instance files (or multiple instances of SWTAtdl4jCompositePanel with own file) * consuming tons of Windows USER Objects and generating "org.eclipse.swt.SWTError: No more handles" - *********************************************************************************************/ + ********************************************************************************************* +*/ removeAllStrategyPanels(); StrategyUI ui = SWTStrategyUIFactory.createStrategyUIAndContainer( this, strategy ); setCurrentlyDisplayedStrategyUI( ui ); - - if ( ui == null ) - { - // skip to next strategy - continue; - } } setPreCached( true ); } @@ -126,11 +123,11 @@ public void adjustLayoutForSelectedStrategy( StrategyT aStrategy ) if ( tempStrategyUI == null ) { - logger.info("ERROR: Strategy name: " + aStrategy.getName() + " was not found. (aStrategy: " + aStrategy + ")" ); + logger.info("ERROR: Strategy name: {} was not found. (aStrategy: {})", aStrategy.getName(), aStrategy ); return; } - logger.debug( "Invoking tempStrategyUI.reinitStrategyPanel() for: " + Atdl4jHelper.getStrategyUiRepOrName( tempStrategyUI.getStrategy() ) ); + logger.debug( "Invoking tempStrategyUI.reinitStrategyPanel() for: {}", Atdl4jHelper.getStrategyUiRepOrName( tempStrategyUI.getStrategy() ) ); tempStrategyUI.reinitStrategyPanel(); strategiesPanel.layout(); @@ -158,8 +155,7 @@ public StrategyUI getStrategyUI( StrategyT aStrategy, boolean aReinitPanelFlag ) { if ( aStrategy.equals( getCurrentlyDisplayedStrategy() ) ) { - logger.debug("Strategy name: " + aStrategy.getName() + " is currently being displayed. Returning getCurrentlyDisplayedStrategyUI()" ); -// 12/15/2010 Scott Atwell return getCurrentlyDisplayedStrategyUI(); + logger.debug("Strategy name: {} is currently being displayed. Returning getCurrentlyDisplayedStrategyUI()", aStrategy.getName() ); if ( aReinitPanelFlag ) { getCurrentlyDisplayedStrategyUI().reinitStrategyPanel(); @@ -169,13 +165,13 @@ public StrategyUI getStrategyUI( StrategyT aStrategy, boolean aReinitPanelFlag ) } else { - logger.debug("Strategy name: " + aStrategy.getName() + " is not currently displayed. Invoking removeAllStrategyPanels() and returning createStrategyPanel()" ); + logger.debug("Strategy name: {} is not currently displayed. Invoking removeAllStrategyPanels() and returning createStrategyPanel()", aStrategy.getName() ); removeAllStrategyPanels(); StrategyUI tempStrategyUI = SWTStrategyUIFactory.createStrategyUIAndContainer( this, aStrategy ); setCurrentlyDisplayedStrategyUI( tempStrategyUI ); - logger.debug("Invoking relayoutCollapsibleStrategyPanels() for: " + aStrategy.getName() ); + logger.debug("Invoking relayoutCollapsibleStrategyPanels() for: {}", aStrategy.getName() ); tempStrategyUI.relayoutCollapsibleStrategyPanels(); return tempStrategyUI; diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelFactory.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelFactory.java index dafaf4c..70630c8 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelFactory.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelFactory.java @@ -4,7 +4,8 @@ import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.layout.ControlT; import org.atdl4j.fixatdl.layout.StrategyPanelT; @@ -22,27 +23,27 @@ */ public class SWTStrategyPanelFactory { - protected static final Logger logger = Logger.getLogger( SWTStrategyPanelFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SWTStrategyPanelFactory.class ); // Given a panel, recursively populates a map of Panels and Parameter widgets // Can also process options for a group frame instead of a single panel public static Map> createStrategyPanelAndWidgets(Composite parent, StrategyPanelT panel, Map parameters, int style, List aExpandBarList, Atdl4jWidgetFactory aAtdl4jWidgetFactory) { - logger.debug( "createStrategyPanelAndWidgets(Composite parent, StrategyPanelT panel, Map parameters, int style)" + " invoked with parms parent: " - + parent + " panel: " + panel + " parameters: " + parameters + " style: " + style ); - - Map> controlWidgets = new HashMap>(); - + logger.debug( "createStrategyPanelAndWidgets(Composite parent, StrategyPanelT panel, Map parameters, int style) invoked with parms parent: {} panel: {} parameters: {} style: {}", parent, panel, parameters, style ); + + Map> controlWidgets = new HashMap<>(); + // -- Handles StrategyPanel's Collapsible, Title, Border, etc. Sets its layout and layoutData and data. -- Composite c = SWTStrategyPanelHelper.createStrategyPanelContainer( panel, parent, style ); - if ( panel.getStrategyPanel().size() > 0 && panel.getControl().size() > 0 ) + if ( !panel.getStrategyPanel().isEmpty() && !panel.getControl().isEmpty() ) { // -- Wrap each Control with an auto-built StrategyPanel if setting is true -- if ( aAtdl4jWidgetFactory.getAtdl4jOptions().isAccommodateMixOfStrategyPanelsAndControls() ) { // -- FIXatdl 1.1 spec recommends against vs. prohibits. Mixed list may not be displayed 'in sequence' of file. -- - logger.warn( "StrategyPanel contains both StrategyPanel (" + panel.getStrategyPanel().size() +") and Control ( " + panel.getControl().size() + " elements.\nSee Atdl4jOptions.setAccommodateMixOfStrategyPanelsAndControls() as potential work-around, though Controls will appear after StrategyPanels." ); + logger.warn( "StrategyPanel contains both StrategyPanel ({}) and Control ( {} elements.\nSee Atdl4jOptions.setAccommodateMixOfStrategyPanelsAndControls() as potential work-around, though Controls will appear after StrategyPanels." + , panel.getStrategyPanel().size(), panel.getControl().size() ); StrategyPanelT tempPanel = new StrategyPanelT(); tempPanel.setCollapsible( Boolean.FALSE ); @@ -50,7 +51,7 @@ public static Map> createStrategyPanelAndWidgets(Composite tempPanel.setOrientation( panel.getOrientation() ); tempPanel.setColor( panel.getColor() ); - logger.warn( "Creating a StrategyPanel to contain " + panel.getControl().size() + " Controls." ); + logger.warn( "Creating a StrategyPanel to contain {} Controls.", panel.getControl().size() ); tempPanel.getControl().addAll( panel.getControl() ); panel.getControl().clear(); panel.getStrategyPanel().add( tempPanel ); diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelHelper.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelHelper.java index 07f0824..02d8d38 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelHelper.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyPanelHelper.java @@ -1,6 +1,7 @@ package org.atdl4j.ui.swt.impl; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.fixatdl.layout.BorderT; import org.atdl4j.fixatdl.layout.PanelOrientationT; import org.atdl4j.fixatdl.layout.StrategyPanelT; @@ -30,13 +31,13 @@ public class SWTStrategyPanelHelper implements StrategyPanelHelper { - private static final Logger logger = Logger.getLogger( SWTStrategyPanelHelper.class ); + private static final Logger logger = LoggerFactory.getLogger( SWTStrategyPanelHelper.class ); /** * Invokes revalidateLayout() within Display.getCurrent().asyncExec(new * Runnable() ... ) * - * @param aControl + * @param anExpandBar */ public static void revalidateLayoutAsync(ExpandBar anExpandBar) { @@ -51,7 +52,7 @@ public static void revalidateLayoutAsync(ExpandBar anExpandBar) * -require-a-call-to-resize-to-layout-correctl * * @author http://stackoverflow.com/users/63293/peter-walser - * @param control + * @param expandBar */ // 3/13/2010 John Shields // streamlined method to increase speed; previously was doing too much @@ -67,22 +68,22 @@ public static void relayoutExpandBar(ExpandBar expandBar, boolean relayoutParent Composite c = expandBar; int tempMaxControlX = 0; - logger.debug( "----- relayoutExpandBar (relayoutParents: " + relayoutParents + " expandBar: " + expandBar + " -----" ); + logger.debug( "----- relayoutExpandBar (relayoutParents: {} expandBar: {} -----", relayoutParents, expandBar ); do { - logger.debug( "c: " + c.getClass() + " c.getParent(): " + c.getParent().getClass() ); + logger.debug( "c: {} c.getParent(): {}", c.getClass(), c.getParent().getClass() ); if ( c instanceof ExpandBar ) { ExpandBar eb = (ExpandBar) c; - logger.debug( "ExpandBar.getSize(): " + eb.getSize() ); + logger.debug( "ExpandBar.getSize(): {}", eb.getSize() ); for ( ExpandItem expandItem : eb.getItems() ) { - logger.debug( "expandItem: " + expandItem + " text: " + expandItem.getText() + " control: " + expandItem.getControl() + " controlLocation: " + expandItem.getControl().getLocation()); - logger.debug( "before pack(): expandItem.getControl().getSize(): " + expandItem.getControl().getSize() ); + logger.debug( "expandItem: {} text: {} control: {} controlLocation: {}", expandItem, expandItem.getText(), expandItem.getControl(), expandItem.getControl().getLocation() ); + logger.debug( "before pack(): expandItem.getControl().getSize(): {}", expandItem.getControl().getSize() ); expandItem.getControl().pack(); @@ -91,7 +92,7 @@ public static void relayoutExpandBar(ExpandBar expandBar, boolean relayoutParent tempMaxControlX = expandItem.getControl().getSize().x; } - logger.debug( "before: expandItem.getHeight(): " + expandItem.getHeight() + " expandItem.getControl().getSize(): " + expandItem.getControl().getSize() ); + logger.debug( "before: expandItem.getHeight(): {} expandItem.getControl().getSize(): {}", expandItem.getHeight(), expandItem.getControl().getSize() ); expandItem.setHeight( expandItem.getControl().computeSize( eb.getSize().x, SWT.DEFAULT, true ).y ); } @@ -99,7 +100,6 @@ public static void relayoutExpandBar(ExpandBar expandBar, boolean relayoutParent // -- Need to set ExpandBar's GridData.widthHint to the width of the widest control within it -- GridData tempGridData2 = (GridData) expandBar.getLayoutData(); tempGridData2.widthHint = tempMaxControlX; - // do not set height as ExpandBar handles this tempGridData2.heightHint = expandBar.getSize().y; expandBar.setLayoutData( tempGridData2 ); @@ -166,8 +166,6 @@ public static Composite createStrategyPanelContainer(StrategyPanelT aStrategyPan { ExpandBar tempExpandBar = new ExpandBar( aParent, SWT.NONE ); tempExpandBar.setSpacing( 1 ); -//TODO if want to get rid of white background, likely want a border around whole thing... -//TODO tempExpandBar.setBackground( aParent.getBackground() ); if ( aParent.getLayout() instanceof GridLayout ) { @@ -232,7 +230,7 @@ else if ( BorderT.LINE.equals( aStrategyPanel.getBorder() ) ) /** * Creates the layout for the SWT Composite containing the set of FIXatdl Controls * - * @param c + * @param panel * @return */ protected static Layout createStrategyPanelLayout(StrategyPanelT panel) @@ -244,15 +242,11 @@ protected static Layout createStrategyPanelLayout(StrategyPanelT panel) int panelCount = panel.getStrategyPanel() != null ? panel.getStrategyPanel().size() : 0; // make 2 columns for each parameter and 1 column for each sub-panel - GridLayout l = new GridLayout( parameterCount * 2 + panelCount, false ); - return l; + return new GridLayout( parameterCount * 2 + panelCount, false ); } else if ( orientation == PanelOrientationT.VERTICAL ) { -// TODO ???? WHY TWO VS. ONE ????? GridLayout l = new GridLayout( 2, false ); - // GridLayout l = new GridLayout( 1, false ); - GridLayout l = new GridLayout( 2, false ); - return l; + return new GridLayout( 2, false ); } else { @@ -306,7 +300,7 @@ else if ( ( c.getParent() instanceof ExpandBar ) && ( c.getData() instanceof Str public boolean expandAtdl4jWidgetParentStrategyPanel( Atdl4jWidget aWidget ) { boolean tempAdjustedFlag = false; - if ( ( aWidget.getParent() != null ) && ( aWidget.getParent() instanceof Composite ) ) + if ( aWidget.getParent() instanceof Composite ) { Composite tempParent = (Composite) aWidget.getParent(); @@ -329,9 +323,9 @@ public boolean expandAtdl4jWidgetParentStrategyPanel( Atdl4jWidget aWidget ) } // -- Iterate to next parent -- - if ( ( tempParent.getParent() != null ) && ( ( tempParent.getParent() instanceof Composite ) ) ) + if ( tempParent.getParent() instanceof Composite ) { - tempParent = (Composite) tempParent.getParent(); + tempParent = tempParent.getParent(); } else { diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUI.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUI.java index 366c03d..e3429ea 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUI.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUI.java @@ -1,15 +1,10 @@ package org.atdl4j.ui.swt.impl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; +import java.util.*; import java.util.Map.Entry; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.ValidationRule; import org.atdl4j.data.exception.FIXatdlFormatException; import org.atdl4j.data.validation.Field2OperatorValidationRule; @@ -37,7 +32,7 @@ public class SWTStrategyUI extends AbstractStrategyUI { - protected static final Logger logger = Logger.getLogger( SWTStrategyUI.class ); + protected static final Logger logger = LoggerFactory.getLogger( SWTStrategyUI.class ); protected Map> swtWidgetMap; @@ -68,10 +63,9 @@ public void initBegin(Object parentContainer) { setParent( (Composite) parentContainer ); - setSWTWidgetWithParameterMap( new HashMap>() ); - -//TODO !!! verify, as it does not appear that getWidgetStateListenerMap() is ever being populated (though, is being initialized) - setWidgetStateListenerMap( new HashMap, Set>() ); + setSWTWidgetWithParameterMap( new HashMap<>() ); + + setWidgetStateListenerMap( new HashMap<>() ); } protected void buildAtdl4jWidgetMap() @@ -86,7 +80,7 @@ protected void buildAtdl4jWidgetMap() throw new IllegalStateException("Unexpected error: getStrategy().getStrategyLayout() was null . (verify )"); } - if ( getStrategy().getStrategyLayout() == null ) + if ( getStrategy().getStrategyLayout().getStrategyPanel() == null ) { throw new IllegalStateException("Unexpected error: getStrategy().getStrategyLayout().getStrategyPanel() was null . (verify )"); } @@ -124,7 +118,7 @@ public void setCxlReplaceMode(boolean cxlReplaceMode) private void putStateListener(SWTWidget widget, SWTStateListener stateListener) { if ( !getWidgetStateListenerMap().containsKey( widget ) ) - getWidgetStateListenerMap().put( widget, new HashSet() ); + getWidgetStateListenerMap().put( widget, new HashSet<>() ); if ( !getWidgetStateListenerMap().get( widget ).contains( stateListener ) ) getWidgetStateListenerMap().get( widget ).add( stateListener ); } @@ -166,10 +160,10 @@ private void attachFieldToControls(String field, SWTStateListener stateRuleListe String rg = ( (RadioButtonT) targetParameterWidget.getControl() ).getRadioGroup(); for ( SWTWidget widget : getSWTWidgetMap().values() ) { - if ( widget.getControl() instanceof RadioButtonT && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( ! "".equals( ( (RadioButtonT) widget.getControl() ).getRadioGroup() ) ) - && ( (RadioButtonT) widget.getControl() ).getRadioGroup().equals( rg ) ) + if ( widget.getControl() instanceof RadioButtonT + && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null + && ( ! "".equals( ( (RadioButtonT) widget.getControl() ).getRadioGroup() ) ) + && ( (RadioButtonT) widget.getControl() ).getRadioGroup().equals( rg ) ) { putStateListener( widget, stateRuleListener ); } @@ -188,7 +182,7 @@ public Map> getAtdl4jWidgetWithParameterMap() { if ( getSWTWidgetWithParameterMap() != null ) { - return new HashMap>( getSWTWidgetWithParameterMap() ); + return new HashMap<>( getSWTWidgetWithParameterMap() ); } else { @@ -205,7 +199,7 @@ public Map> getAtdl4jWidgetMap() { if ( getSWTWidgetMap() != null ) { - return new HashMap>( getSWTWidgetMap() ); + return new HashMap<>( getSWTWidgetMap() ); } else { @@ -235,13 +229,12 @@ protected void setSWTWidgetMap(Map> aSWTWidgetMap) /** * @param aStrategyPanelList * @return - * @throws Atdl4jClassLoadException */ protected void buildAtdl4jWidgetMap( List aStrategyPanelList ) { - Map> tempSWTWidgetMap = new HashMap>(); + Map> tempSWTWidgetMap = new HashMap<>(); - setExpandBarList( new ArrayList() ); + setExpandBarList( new ArrayList<>() ); // build panels and widgets recursively for ( StrategyPanelT panel : aStrategyPanelList ) @@ -278,12 +271,12 @@ public void relayoutCollapsibleStrategyPanels() protected void createRadioGroups() { - Map tempRadioGroupMap = new HashMap(); + Map tempRadioGroupMap = new HashMap<>(); for ( SWTWidget widget : getSWTWidgetMap().values() ) { if ( widget.getControl() instanceof RadioButtonT && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != null - && ( (RadioButtonT) widget.getControl() ).getRadioGroup() != "" ) + && !Objects.equals(((RadioButtonT) widget.getControl()).getRadioGroup(), "")) { String rg = ( (RadioButtonT) widget.getControl() ).getRadioGroup(); if ( !tempRadioGroupMap.containsKey( rg ) ) @@ -342,7 +335,7 @@ protected void removeFromAtdl4jWidgetWithParameterMap( String aName ) */ protected void buildAtdl4jWidgetWithParameterMap() { - Map> tempSWTWidgetWithParameterMap = new HashMap>(); + Map> tempSWTWidgetWithParameterMap = new HashMap<>(); // loop through all UI controls for ( SWTWidget widget : getSWTWidgetMap().values() ) @@ -368,7 +361,7 @@ protected void buildAtdl4jWidgetWithParameterMap() */ protected void attachGlobalStateRulesToControls() throws FIXatdlFormatException { - List tempStateListenerList = new Vector(); + List tempStateListenerList = new ArrayList<>(); // loop through all UI controls for ( SWTWidget widget : getSWTWidgetMap().values() ) @@ -454,7 +447,6 @@ protected void setWidgetStateListenerMap(Map, Set */ protected void attachStateListenersToAllAtdl4jWidgets() { -//TODO !!! verify, as it does not appear that getWidgetStateListenerMap() is ever being populated (though, is being initialized) // add all StateListeners to the controls for ( Entry, Set> entry : getWidgetStateListenerMap().entrySet() ) { diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUIFactory.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUIFactory.java index fe33b59..492d382 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUIFactory.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTStrategyUIFactory.java @@ -1,6 +1,7 @@ package org.atdl4j.ui.swt.impl; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.data.Atdl4jHelper; import org.atdl4j.fixatdl.core.StrategyT; import org.atdl4j.ui.StrategyUI; @@ -21,7 +22,7 @@ public class SWTStrategyUIFactory extends BaseStrategyUIFactory { - protected static final Logger logger = Logger.getLogger( SWTStrategyUIFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SWTStrategyUIFactory.class ); public static StrategyUI createStrategyUIAndContainer(SWTStrategiesUI aStrategiesUI, StrategyT aStrategy) { diff --git a/src/main/java/org/atdl4j/ui/swt/impl/SWTWidgetFactory.java b/src/main/java/org/atdl4j/ui/swt/impl/SWTWidgetFactory.java index 4d5a52e..022bd3a 100644 --- a/src/main/java/org/atdl4j/ui/swt/impl/SWTWidgetFactory.java +++ b/src/main/java/org/atdl4j/ui/swt/impl/SWTWidgetFactory.java @@ -1,7 +1,8 @@ package org.atdl4j.ui.swt.impl; import org.eclipse.swt.widgets.Composite; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.atdl4j.fixatdl.core.ParameterT; import org.atdl4j.fixatdl.layout.ControlT; import org.atdl4j.ui.Atdl4jWidgetFactory; @@ -16,22 +17,21 @@ */ public class SWTWidgetFactory { - protected static final Logger logger = Logger.getLogger( SWTWidgetFactory.class ); + protected static final Logger logger = LoggerFactory.getLogger( SWTWidgetFactory.class ); // Used to create a single parameter widget public static SWTWidget createWidget(Composite parent, ControlT control, ParameterT parameter, int style, Atdl4jWidgetFactory aAtdl4jWidgetFactory) { SWTWidget parameterWidget = null; - logger.debug( "createWidget() invoked " + "with parms parent: " + parent - + " control: " + control + " parameter: " + parameter + " style: " + style ); + logger.debug( "createWidget() invoked " + "with parms parent: {} control: {} parameter: {} style: {}", parent, control, parameter, style ); parameterWidget = (SWTWidget) aAtdl4jWidgetFactory.create( control, parameter ); - logger.debug( "createWidget() returned parameterWidget: " + parameterWidget ); + logger.debug( "createWidget() returned parameterWidget: {}", parameterWidget ); parameterWidget.createWidget( parent, style ); - logger.debug( "createWidget() completed. parameterWidget: " + parameterWidget ); + logger.debug( "createWidget() completed. parameterWidget: {}", parameterWidget ); parameterWidget.applyConstOrInitValues(); diff --git a/src/main/java/org/atdl4j/ui/swt/util/SWTNullableSpinner.java b/src/main/java/org/atdl4j/ui/swt/util/SWTNullableSpinner.java index 276eee2..0cb6d24 100644 --- a/src/main/java/org/atdl4j/ui/swt/util/SWTNullableSpinner.java +++ b/src/main/java/org/atdl4j/ui/swt/util/SWTNullableSpinner.java @@ -5,7 +5,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.events.SelectionListener; @@ -20,7 +21,7 @@ public class SWTNullableSpinner extends Composite { - private static final Logger logger = Logger.getLogger( SWTNullableSpinner.class ); + private static final Logger logger = LoggerFactory.getLogger( SWTNullableSpinner.class ); static final int BUTTON_WIDTH = 20; Text text; @@ -28,18 +29,13 @@ public class SWTNullableSpinner extends Composite BigDecimal minimum, maximum; BigDecimal increment = new BigDecimal( 1 ); int digits = 0; - public static BigDecimal MIN_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( -Integer.MAX_VALUE ); - public static BigDecimal MAX_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( Integer.MAX_VALUE ); + public static final BigDecimal MIN_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( -Integer.MAX_VALUE ); + public static final BigDecimal MAX_INTEGER_VALUE_AS_BIG_DECIMAL = new BigDecimal( Integer.MAX_VALUE ); public SWTNullableSpinner(Composite parent, int style) { super(parent, style); - - /* - GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - this.setLayoutData(gd);*/ - - text = new Text(this, SWT.SINGLE | SWT.NONE); + + text = new Text(this, SWT.SINGLE | SWT.NONE); up = new Button(this, SWT.ARROW | SWT.UP); down = new Button(this, SWT.ARROW | SWT.DOWN); @@ -178,6 +174,7 @@ void focusIn() { text.setFocus(); } + @Override public void setFont(Font font) { super.setFont(font); text.setFont(font); @@ -186,19 +183,16 @@ public void setFont(Font font) { public void setValue(BigDecimal aValue) { BigDecimal tempValue = aValue; - -// 12/15/2010 Scott Atwell if ( ( getMinimum() != null ) && ( tempValue.compareTo( getMinimum() ) < 0 ) ) + if ( ( getMinimum() != null ) && ( tempValue != null ) && ( tempValue.compareTo( getMinimum() ) < 0 ) ) { tempValue = getMinimum(); } -// 12/15/2010 Scott Atwell else if ( ( getMaximum() != null ) && ( tempValue.compareTo( getMaximum() ) > 0 ) ) else if ( ( getMaximum() != null ) && ( tempValue != null ) && ( tempValue.compareTo( getMaximum() ) > 0 ) ) { tempValue = getMaximum(); } - -// 12/15/2010 Scott Atwell text.setText( tempValue.toPlainString() ); + if ( tempValue != null ) { text.setText( tempValue.toPlainString() ); @@ -219,23 +213,21 @@ public BigDecimal getValue() } else { -// note this is what we had to use in SWTSpinnerWidget when getSelection() returned equiv of BigDecimal.unscaledValue() -// return BigDecimal.valueOf( spinner.getSelection(), spinner.getDigits() ); BigDecimal tempValue = new BigDecimal( text.getText() ); BigDecimal tempValueScaled = tempValue.setScale( getDigits(), RoundingMode.HALF_UP ); if ( ! tempValue.equals( tempValueScaled ) ) { String tempNewValueString = tempValueScaled.toPlainString(); - logger.debug( "tempValue: " + tempValue + " tempValueScaled: " + tempValueScaled + " tempValueScaled.toPlainString(): " + tempNewValueString ); + logger.debug( "tempValue: {} tempValueScaled: {} tempValueScaled.toPlainString(): {}", tempValue, tempValueScaled, tempNewValueString ); int tempCaretPosition = text.getCaretPosition(); - logger.debug( "getCaretPosition(): " + text.getCaretPosition() ); + logger.debug( "getCaretPosition(): {}", text.getCaretPosition() ); // -- Handle user entering ".12" and formatter converting to "0.12" -- avoid result of "0.21") -- if ( ( tempCaretPosition == 2 ) && ( text.getText().charAt(0) == '.' ) && ( tempNewValueString.startsWith( "0." ) ) ) { // -- we're notified at ".1" but formatted value is converting to "0.1" -- - logger.debug("Incrementing CaretPosition (was " + tempCaretPosition + ") to account for formatted string having \".\" converted to \"0.\" automatically." ); + logger.debug("Incrementing CaretPosition (was {}) to account for formatted string having \".\" converted to \"0.\" automatically.", tempCaretPosition ); tempCaretPosition++; } @@ -257,7 +249,8 @@ void resize() { down.setBounds(textWidth, pt.y - buttonHeight - 3, BUTTON_WIDTH, buttonHeight); } - + + @Override public Point computeSize(int wHint, int hHint, boolean changed) { int width = 100; int height = 20; @@ -381,9 +374,9 @@ private boolean stripExtraDecimalPoints() int tempNextDecimalPoint = tempText.indexOf( '.', (tempFirstDecimalPoint + 1) ); if ( tempNextDecimalPoint >= 0 ) { - logger.debug(" Multiple decimal points... tempText: " + tempText ); + logger.debug(" Multiple decimal points... tempText: {}", tempText ); boolean tempDecimalPointFound = false; - StringBuffer tempStringBuffer = new StringBuffer(); + StringBuilder tmpStringBuilder = new StringBuilder(); for ( int i=0; i < tempText.length(); i++ ) { if ( tempText.charAt( i ) == '.' ) @@ -398,13 +391,12 @@ private boolean stripExtraDecimalPoints() continue; } } - - tempStringBuffer.append( tempText.charAt( i ) ); + tmpStringBuilder.append( tempText.charAt( i ) ); } - logger.debug(" text.setText( tempStringBuffer.toString() ): " + tempStringBuffer.toString() ); + logger.debug(" text.setText( tempStringBuffer.toString() ): {}", tmpStringBuilder ); int tempCaretPosition = text.getCaretPosition(); - text.setText( tempStringBuffer.toString() ); + text.setText( tmpStringBuilder.toString() ); text.setSelection( tempCaretPosition, tempCaretPosition ); return true; } diff --git a/src/main/java/org/atdl4j/ui/swt/util/SWTNumberFormatVerifyListener.java b/src/main/java/org/atdl4j/ui/swt/util/SWTNumberFormatVerifyListener.java index 283a070..40f7fb2 100644 --- a/src/main/java/org/atdl4j/ui/swt/util/SWTNumberFormatVerifyListener.java +++ b/src/main/java/org/atdl4j/ui/swt/util/SWTNumberFormatVerifyListener.java @@ -32,7 +32,7 @@ public class SWTNumberFormatVerifyListener implements VerifyListener { /** * - * @param formatter + * @param format * Format used to validate the text entered by the user. * @param allowEmpty * Flag which indicates whether an empty field is valid. @@ -69,8 +69,7 @@ public String getFutureText(VerifyEvent e) { String old = text.getText(); String start = old.substring(0, e.start); String end = old.substring(e.end); - String value = start + e.text + end; - return value; + return start + e.text + end; } return ""; } diff --git a/src/main/java/org/atdl4j/ui/swt/widget/SWTButtonWidget.java b/src/main/java/org/atdl4j/ui/swt/widget/SWTButtonWidget.java index 0bc7537..f3fc6e1 100644 --- a/src/main/java/org/atdl4j/ui/swt/widget/SWTButtonWidget.java +++ b/src/main/java/org/atdl4j/ui/swt/widget/SWTButtonWidget.java @@ -62,7 +62,7 @@ public void setValue(Boolean value) public List getControls() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); if ( label != null ) { widgets.add( label ); @@ -73,7 +73,7 @@ public List getControls() public List getControlsExcludingLabel() { - List widgets = new ArrayList(); + List widgets = new ArrayList<>(); widgets.add( button ); return widgets; } @@ -99,6 +99,7 @@ public Boolean getControlValueRaw() } // Parameter value looks up checkedEnumRef and uncheckedEnumRef + @Override public Object getParameterValue() { if ( getControlValue() == null ) @@ -156,7 +157,7 @@ public void processReinit( Object aControlInitValue ) { if ( ( button != null ) && ( ! button.isDisposed() ) ) { - button.setSelection( (aControlInitValue != null ) ? ((Boolean) aControlInitValue).booleanValue() : false ); + button.setSelection( Boolean.TRUE.equals( aControlInitValue ) ); } } diff --git a/src/main/java/org/atdl4j/ui/swt/widget/SWTCheckBoxListWidget.java b/src/main/java/org/atdl4j/ui/swt/widget/SWTCheckBoxListWidget.java index 2bc4d0a..d8018fd 100644 --- a/src/main/java/org/atdl4j/ui/swt/widget/SWTCheckBoxListWidget.java +++ b/src/main/java/org/atdl4j/ui/swt/widget/SWTCheckBoxListWidget.java @@ -24,10 +24,10 @@ public class SWTCheckBoxListWidget extends AbstractSWTWidget { - private List