Author: rwhitcomb Date: Tue Mar 6 19:04:46 2018 New Revision: 1826023 URL: http://svn.apache.org/viewvc?rev=1826023&view=rev Log: PIVOT-1032: Fix more *Test classes to tidy up style errors in them. Along the way, provide more functionality in the SliderTest just for fun. Tidy up a couple of "core" pieces for style violations as well. As a side effort: add a "toBoolean" method to StringUtils in preparation for future work.
Modified: pivot/trunk/core/src/org/apache/pivot/util/ClassUtils.java pivot/trunk/core/src/org/apache/pivot/util/StringUtils.java pivot/trunk/tests/src/org/apache/pivot/tests/SliderTest.java pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java pivot/trunk/tests/src/org/apache/pivot/tests/SplashScreenTest.java pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java pivot/trunk/tests/src/org/apache/pivot/tests/TablePaneTest.java pivot/trunk/tests/src/org/apache/pivot/tests/TableViewCellRendererCustom.java pivot/trunk/tests/src/org/apache/pivot/tests/TableViewTest2.java pivot/trunk/tests/src/org/apache/pivot/tests/TagDecoratorTest.java pivot/trunk/tests/src/org/apache/pivot/tests/TestUtils.java pivot/trunk/tests/src/org/apache/pivot/tests/TextInputValidatorTest.java pivot/trunk/tests/src/org/apache/pivot/tests/VFSBrowserTest.java pivot/trunk/tests/src/org/apache/pivot/tests/WatermarkDecoratorTest.java pivot/trunk/tests/src/org/apache/pivot/tests/slider_test.bxml pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java Modified: pivot/trunk/core/src/org/apache/pivot/util/ClassUtils.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/ClassUtils.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/ClassUtils.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/ClassUtils.java Tue Mar 6 19:04:46 2018 @@ -19,9 +19,12 @@ package org.apache.pivot.util; /** * Utility class for dealing with classes. */ -public class ClassUtils { +public final class ClassUtils { public static final String UNKNOWN_CALLER = "<unknown caller>"; + private ClassUtils() { + } + /** * Return the description (name, location) of a caller of this method. * @@ -31,14 +34,15 @@ public class ClassUtils { * caller at the given level. * @throws IllegalArgumentException if the level value is negative. */ - public static String getCallingMethod(int level) { + public static String getCallingMethod(final int level) { Utils.checkNonNegative(level, "level"); StackTraceElement[] elements = Thread.currentThread().getStackTrace(); // level + 2 because 0 = inside "getStackTrace", 1 = inside here, so // 2 is the caller of this method, etc. - if (elements == null || level + 2 >= elements.length) + if (elements == null || level + 2 >= elements.length) { return UNKNOWN_CALLER; + } return elements[level + 2].toString(); } @@ -50,9 +54,9 @@ public class ClassUtils { * any alternative implementation of <tt>toString()</tt> that may be implemented * in the class or any intervening superclass. */ - public static String defaultToString(Object obj) { - return obj.getClass().getName() + "@" + - Integer.toHexString(System.identityHashCode(obj)); + public static String defaultToString(final Object obj) { + return obj.getClass().getName() + "@" + + Integer.toHexString(System.identityHashCode(obj)); } /** @@ -64,9 +68,9 @@ public class ClassUtils { * in the class or any intervening superclass, except that the simple name * of the class is used (without any package designation). */ - public static String simpleToString(Object obj) { - return obj.getClass().getSimpleName() + "@" + - Integer.toHexString(System.identityHashCode(obj)); + public static String simpleToString(final Object obj) { + return obj.getClass().getSimpleName() + "@" + + Integer.toHexString(System.identityHashCode(obj)); } } Modified: pivot/trunk/core/src/org/apache/pivot/util/StringUtils.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/StringUtils.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/StringUtils.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/StringUtils.java Tue Mar 6 19:04:46 2018 @@ -24,7 +24,9 @@ import java.math.BigInteger; * A set of static methods that perform various string manipulation * functions. */ -public class StringUtils { +public final class StringUtils { + private StringUtils() { + } /** * Make a string the consists of "n" copies of the given character. @@ -34,7 +36,7 @@ public class StringUtils { * @param n The number of times to copy this character. * @return The resulting string. */ - public static String fromNChars(char ch, int n) { + public static String fromNChars(final char ch, final int n) { if (n == 0) { return ""; } @@ -61,11 +63,11 @@ public class StringUtils { * @return A string in the form of <tt>"[xx,xx,xx...]"</tt> * where the "xx" are the hex representations of each character. */ - public static String toHexString(CharSequence charSequence) { - StringBuilder builder = new StringBuilder(charSequence.length()*3+1); + public static String toHexString(final CharSequence charSequence) { + StringBuilder builder = new StringBuilder(charSequence.length() * 3 + 1); for (int i = 0; i < charSequence.length(); i++) { builder.append((i == 0) ? '[' : ','); - builder.append(Integer.toHexString((int)charSequence.charAt(i))); + builder.append(Integer.toHexString((int) charSequence.charAt(i))); } builder.append(']'); return builder.toString(); @@ -87,7 +89,8 @@ public class StringUtils { * @throws NumberFormatException if the input string doesn't contain a value * parseable by one of these methods. */ - public static <T extends Number> Number toNumber(String string, Class<? extends Number> type) { + public static <T extends Number> Number toNumber(final String string, + final Class<? extends Number> type) { Utils.checkNullOrEmpty(string, "string"); if (type == null) { @@ -123,5 +126,49 @@ public class StringUtils { } } + /** + * Extension of {@link Boolean#parseBoolean} that is both more exact + * and supports more features. Specifically it will recognize: + * <ul> + * <li><tt>true</tt> or <tt>false</tt> in mixed case. + * <li><tt>yes</tt> or <tt>no</tt> in mixed case. + * <li><tt>on</tt> or <tt>off</tt> in mixed case. + * <li><tt>T</tt> or <tt>F</tt> in mixed case. + * <li><tt>Y</tt> or <tt>N</tt> in mixed case. + * <li><tt>1</tt> or <tt>0</tt>. + * </ul> + * + * @param input The string value to convert to a boolean. + * @return The boolean value. + * @throws IllegalArgumentException if the value can't be converted according to the + * above rules. + */ + public static boolean toBoolean(final String input) { + Utils.checkNullOrEmpty(input, "input"); + + if (input.equalsIgnoreCase("true") || input.equalsIgnoreCase("T") + || input.equalsIgnoreCase("yes") || input.equalsIgnoreCase("Y") + || input.equalsIgnoreCase("on")) { + return true; + } else if (input.equalsIgnoreCase("false") || input.equalsIgnoreCase("F") + || input.equalsIgnoreCase("no") || input.equalsIgnoreCase("N") + || input.equalsIgnoreCase("off")) { + return false; + } else { + try { + double d = Double.parseDouble(input); + if (d == 1.0d) { + return true; + } else if (d == 0.0d) { + return false; + } + throw new IllegalArgumentException("Unable to convert \"" + input + "\"" + + " to a boolean value."); + } catch (NumberFormatException nfe) { + throw nfe; + } + } + } + } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SliderTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SliderTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/SliderTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/SliderTest.java Tue Mar 6 19:04:46 2018 @@ -16,6 +16,9 @@ */ package org.apache.pivot.tests; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; import org.apache.pivot.beans.BXMLSerializer; import org.apache.pivot.collections.Map; import org.apache.pivot.wtk.Application; @@ -23,47 +26,90 @@ import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.DesktopApplicationContext; import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Label; +import org.apache.pivot.wtk.ImageView; import org.apache.pivot.wtk.Slider; -import org.apache.pivot.wtk.SliderValueListener; import org.apache.pivot.wtk.Window; +import org.apache.pivot.wtk.media.Picture; -public class SliderTest implements Application { +public final class SliderTest implements Application { private Window window = null; private Slider slider1 = null; private Slider slider2 = null; private Label valueLabel1 = null; private Label valueLabel2 = null; + private ImageView image = null; + private SliderPicture picture = null; + + private static class SliderPicture extends Picture { + SliderPicture(final int width, final int height) { + super(new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB)); + } + + public void clear(final Color color) { + BufferedImage image = getBufferedImage(); + Graphics2D graphics = image.createGraphics(); + graphics.setPaint(color); + graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); + graphics.dispose(); + } + + public void drawPoint(final int x, final int y, final Color color) { + BufferedImage image = getBufferedImage(); + Graphics2D graphics = image.createGraphics(); + graphics.setPaint(color); + graphics.fillOval(x - 3, y - 3, 6, 6); + graphics.dispose(); + } + } + + private void drawPoint(final int x, final int y, + final int xMin, final int xMax, final int yMin, final int yMax) { + // Scale and translate the x, y values to the size of the picture + int width = picture.getWidth(); + int height = picture.getHeight(); + int ourX = (x - xMin) * width / (xMax - xMin); + int ourY = (y - yMin) * height / (yMax - yMin); + picture.drawPoint(ourX, ourY, Color.RED); + image.repaint(); + } @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); window = new Window((Component) bxmlSerializer.readObject(getClass().getResource( "slider_test.bxml"))); slider1 = (Slider) bxmlSerializer.getNamespace().get("slider1"); - slider1.getSliderValueListeners().add(new SliderValueListener() { - @Override - public void valueChanged(Slider slider, int previousValue) { - valueLabel1.setText(Integer.toString(slider.getValue())); - } + slider1.getSliderValueListeners().add((slider, previousValue) -> { + valueLabel1.setText(Integer.toString(slider.getValue())); + drawPoint(slider.getValue(), slider2.getValue(), slider.getStart(), slider.getEnd(), + slider2.getStart(), slider2.getEnd()); }); slider2 = (Slider) bxmlSerializer.getNamespace().get("slider2"); - slider2.getSliderValueListeners().add(new SliderValueListener() { - @Override - public void valueChanged(Slider slider, int previousValue) { - valueLabel2.setText(Integer.toString(slider.getValue())); - } + slider2.getSliderValueListeners().add((slider, previousValue) -> { + valueLabel2.setText(Integer.toString(slider.getValue())); + drawPoint(slider1.getValue(), slider.getValue(), slider1.getStart(), slider1.getEnd(), + slider.getStart(), slider.getEnd()); }); valueLabel1 = (Label) bxmlSerializer.getNamespace().get("valueLabel1"); valueLabel2 = (Label) bxmlSerializer.getNamespace().get("valueLabel2"); + image = (ImageView) bxmlSerializer.getNamespace().get("imageView"); + int width = slider1.getEnd() - slider1.getStart(); + int height = slider2.getEnd() - slider2.getStart(); + picture = new SliderPicture(width, height); + picture.clear(Color.LIGHT_GRAY); + drawPoint(slider1.getValue(), slider2.getValue(), slider1.getStart(), slider1.getEnd(), + slider2.getStart(), slider2.getEnd()); + image.setImage(picture); + window.setTitle("Slider Test"); window.setMaximized(true); window.open(display); } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -71,7 +117,7 @@ public class SliderTest implements Appli return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(SliderTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java Tue Mar 6 19:04:46 2018 @@ -27,12 +27,12 @@ import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Frame; import org.apache.pivot.wtk.Spinner; -public class SpinnerFocusTest implements Application { +public final class SpinnerFocusTest implements Application { private Frame frame = null; private Spinner spinner = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { Action action = new Action() { @Override public String getDescription() { @@ -40,7 +40,7 @@ public class SpinnerFocusTest implements } @Override - public void perform(Component source) { + public void perform(final Component source) { String msg = "Selected: " + spinner.getSelectedItem().toString(); Alert.alert(msg, frame); @@ -64,7 +64,7 @@ public class SpinnerFocusTest implements } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (frame != null) { frame.close(); } @@ -72,7 +72,7 @@ public class SpinnerFocusTest implements return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(SpinnerFocusTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SplashScreenTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SplashScreenTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/SplashScreenTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/SplashScreenTest.java Tue Mar 6 19:04:46 2018 @@ -64,9 +64,9 @@ import org.apache.pivot.wtk.Window; * @see DesktopApplicationContext#replaceSplashScreen(Display) * @see DesktopApplicationContext#PRESERVE_SPLASH_SCREEN_ARGUMENT */ -public class SplashScreenTest implements Application { +public final class SplashScreenTest implements Application { - private static class SplashScreenProgressOverlay { + private static final class SplashScreenProgressOverlay { private final SplashScreen splashScreen; private final Meter meter = new Meter(Orientation.HORIZONTAL); private Graphics2D graphics; @@ -119,11 +119,12 @@ public class SplashScreenTest implements } @Override - public void startup(final Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { File splashFile = new File("org/apache/pivot/tests/splash.png"); System.out.println("Startup the application at " + new Date()); - System.out.println("To show the Splash Screen, remember to run as a Standard Java Application this way:\n" + System.out.println( + "To show the Splash Screen, remember to run as a Standard Java Application this way:\n" + "java -splash:" + splashFile.getPath() + " <mainclassname> --preserveSplashScreen=true\n" + "or no splash screen will be shown."); @@ -156,20 +157,17 @@ public class SplashScreenTest implements // Load the Pivot UI private void loadBXML(final Display displayArgument, final double weight) { try { - ApplicationContext.queueCallback(new Runnable() { - @Override - public void run() { - Window window = null; - try { - window = (Window) new BXMLSerializer().readObject(this.getClass().getResource( - "splash.bxml")); - } catch (Exception e) { - throw new RuntimeException(e); - } - if (window != null) { - window.open(displayArgument); - progressOverlay.increment(weight); - } + ApplicationContext.queueCallback(() -> { + Window window = null; + try { + window = (Window) new BXMLSerializer().readObject(this.getClass().getResource( + "splash.bxml")); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (window != null) { + window.open(displayArgument); + progressOverlay.increment(weight); } }); } catch (Exception e) { @@ -182,12 +180,12 @@ public class SplashScreenTest implements // window visible. final TaskListener<Void> taskListener = new TaskListener<Void>() { @Override - public void taskExecuted(Task<Void> task) { + public void taskExecuted(final Task<Void> task) { finished(); } @Override - public void executeFailed(Task<Void> task) { + public void executeFailed(final Task<Void> task) { System.err.println(String.format("Failed\n%s", task.getFault())); task.getFault().printStackTrace(); finished(); @@ -203,12 +201,12 @@ public class SplashScreenTest implements } @Override - public boolean shutdown(boolean optional) throws Exception { + public boolean shutdown(final boolean optional) throws Exception { System.out.println("Shutdown the application at " + new Date()); return false; } - public static void main(String[] args) { + public static void main(final String[] args) { // Allow the BXML to be loaded on a background thread Container.setEventDispatchThreadChecker(null); Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java Tue Mar 6 19:04:46 2018 @@ -30,18 +30,16 @@ import org.apache.pivot.wtk.TextInput; import org.apache.pivot.wtk.TextInputContentListener; import org.apache.pivot.wtk.Window; -public class SuggestionPopupTest implements Application { +public final class SuggestionPopupTest implements Application { private Window window = null; - @BXML - private TextInput textInput = null; - @BXML - private Label selectedIndexLabel = null; + @BXML private TextInput textInput = null; + @BXML private Label selectedIndexLabel = null; private SuggestionPopup suggestionPopup = new SuggestionPopup(); @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); window = (Window) bxmlSerializer.readObject(SuggestionPopupTest.class, "suggestion_popup_test.bxml"); @@ -49,13 +47,12 @@ public class SuggestionPopupTest impleme textInput.getTextInputContentListeners().add(new TextInputContentListener() { @Override - public void textInserted(TextInput textInputArgument, int index, int count) { - ArrayList<String> suggestions = new ArrayList<>("One", "Two", "Three", "Four", - "Five"); + public void textInserted(final TextInput textInputArgument, final int index, final int count) { + ArrayList<String> suggestions = new ArrayList<>("One", "Two", "Three", "Four", "Five"); suggestionPopup.setSuggestionData(suggestions); suggestionPopup.open(textInputArgument, new SuggestionPopupCloseListener() { @Override - public void suggestionPopupClosed(SuggestionPopup suggestionPopupArgument) { + public void suggestionPopupClosed(final SuggestionPopup suggestionPopupArgument) { if (suggestionPopupArgument.getResult()) { selectedIndexLabel.setText("You selected suggestion number " + suggestionPopupArgument.getSelectedIndex() + "."); @@ -67,7 +64,7 @@ public class SuggestionPopupTest impleme } @Override - public void textRemoved(TextInput textInputArgument, int index, int count) { + public void textRemoved(final TextInput textInputArgument, final int index, final int count) { suggestionPopup.close(); } }); @@ -76,7 +73,7 @@ public class SuggestionPopupTest impleme } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -84,7 +81,7 @@ public class SuggestionPopupTest impleme return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(SuggestionPopupTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TablePaneTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TablePaneTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TablePaneTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TablePaneTest.java Tue Mar 6 19:04:46 2018 @@ -23,18 +23,18 @@ import org.apache.pivot.wtk.DesktopAppli import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Window; -public class TablePaneTest implements Application { +public final class TablePaneTest implements Application { private Window window = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); window = (Window) bxmlSerializer.readObject(TablePaneTest.class, "table_pane_test.bxml"); window.open(display); } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -42,7 +42,7 @@ public class TablePaneTest implements Ap return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(TablePaneTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TableViewCellRendererCustom.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TableViewCellRendererCustom.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TableViewCellRendererCustom.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TableViewCellRendererCustom.java Tue Mar 6 19:04:46 2018 @@ -22,20 +22,20 @@ import org.apache.pivot.wtk.content.Tabl /** * Minimal sample for a customized version of table cell renderer. Renders cell * contents as a string, but in this case, transformed. <br/> Note that here - * it's possible to extends Label implements TableView.CellRenderer, or even to - * extends directly TableViewCellRenderer (because it extends Label and - * implements TableView.CellRenderer). + * it's possible to "extends Label implements TableView.CellRenderer", + * or even to extend directly TableViewCellRenderer (because it already extends + * Label and implements TableView.CellRenderer). */ -public class TableViewCellRendererCustom extends TableViewCellRenderer { +public final class TableViewCellRendererCustom extends TableViewCellRenderer { @Override - public String toString(Object row, String columnName) { + public String toString(final Object row, final String columnName) { Object cellData = JSON.get(row, columnName); - String text = (cellData == null) ? null : cellData.toString(); - if (text == null) { - return text; + if (cellData == null) { + return null; } + String text = cellData.toString(); // return new StringBuffer(text).reverse().toString(); // reverse text return text.toUpperCase(); // to upper text } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TableViewTest2.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TableViewTest2.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TableViewTest2.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TableViewTest2.java Tue Mar 6 19:04:46 2018 @@ -27,13 +27,13 @@ import org.apache.pivot.wtk.Window; import org.apache.pivot.wtk.content.TableViewRowEditor; import org.apache.pivot.wtk.skin.CardPaneSkin; -public class TableViewTest2 implements Application { +public final class TableViewTest2 implements Application { private Window window = null; private TableView tableView = null; private Window menu = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); System.out.println("Double Click on Table elements to open the Row Editor"); @@ -57,7 +57,7 @@ public class TableViewTest2 implements A } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -65,7 +65,7 @@ public class TableViewTest2 implements A return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(TableViewTest2.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TagDecoratorTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TagDecoratorTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TagDecoratorTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TagDecoratorTest.java Tue Mar 6 19:04:46 2018 @@ -26,11 +26,11 @@ import org.apache.pivot.wtk.VerticalAlig import org.apache.pivot.wtk.effects.TagDecorator; import org.apache.pivot.wtk.media.Image; -public class TagDecoratorTest implements Application { +public final class TagDecoratorTest implements Application { private Frame frame = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { frame = new Frame(); frame.setTitle("Tag Decorator Test"); frame.setPreferredSize(480, 360); @@ -44,7 +44,7 @@ public class TagDecoratorTest implements } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (frame != null) { frame.close(); } @@ -52,7 +52,7 @@ public class TagDecoratorTest implements return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(TagDecoratorTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TestUtils.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TestUtils.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TestUtils.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TestUtils.java Tue Mar 6 19:04:46 2018 @@ -19,11 +19,11 @@ package org.apache.pivot.tests; /** * Test utilities methods. */ -public class TestUtils { +public final class TestUtils { private static final String NA = "not available"; - public TestUtils() { + private TestUtils() { } static final void testJavaSecurity() { Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TextInputValidatorTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TextInputValidatorTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/TextInputValidatorTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/TextInputValidatorTest.java Tue Mar 6 19:04:46 2018 @@ -44,7 +44,7 @@ import org.apache.pivot.wtk.validation.V /** * Text input validator test. */ -public class TextInputValidatorTest implements Application { +public final class TextInputValidatorTest implements Application { private Locale locale = Locale.getDefault(); // the default locale private Window window = null; @@ -62,8 +62,12 @@ public class TextInputValidatorTest impl private TextInput textinputNotEmptyText = null; private TextInput textinputEmptyText = null; + private String validText(final TextInput textInput) { + return (textInput.isTextValid() ? "valid" : "invalid"); + } + @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { System.out.println("Starting TextInputValidatorTest ..."); System.out.println("current Locale is " + locale); @@ -79,7 +83,8 @@ public class TextInputValidatorTest impl // BXMLSerializer bxmlSerializer = new BXMLSerializer(); - window = new Window((Component) bxmlSerializer.readObject(getClass().getResource("text_input_validator_test.bxml"))); + window = new Window((Component) bxmlSerializer.readObject( + getClass().getResource("text_input_validator_test.bxml"))); Map<String, Object> namespace = bxmlSerializer.getNamespace(); @@ -117,8 +122,8 @@ public class TextInputValidatorTest impl textinputComparableRange.setValidator(bdCompRange); textinputComparableRange.getTextInputListeners().add(new TextInputListener() { @Override - public void textValidChanged(TextInput textInput) { - invalidComparableRangeLabel.setText(textInput.isTextValid() ? "valid" : "invalid"); + public void textValidChanged(final TextInput textInput) { + invalidComparableRangeLabel.setText(validText(textInput)); } }); invalidComparableRangeLabel = (Label) namespace.get("invalidComparableRangeLabel"); @@ -147,8 +152,8 @@ public class TextInputValidatorTest impl // test the listener by updating a label textinputFloatRange.getTextInputListeners().add(new TextInputListener() { @Override - public void textValidChanged(TextInput textInput) { - invalidLabel.setText(textInput.isTextValid() ? "valid" : "invalid"); + public void textValidChanged(final TextInput textInput) { + invalidLabel.setText(validText(textInput)); } }); @@ -167,7 +172,7 @@ public class TextInputValidatorTest impl textinputCustomBoolean.setText("true"); textinputCustomBoolean.setValidator(new Validator() { @Override - public boolean isValid(String s) { + public boolean isValid(final String s) { return "true".equals(s) || "false".equals(s); } }); @@ -186,7 +191,7 @@ public class TextInputValidatorTest impl } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -194,8 +199,10 @@ public class TextInputValidatorTest impl return false; } - public static void main(String[] args) { - DesktopApplicationContext.main(new String[] { TextInputValidatorTest.class.getName() }); + public static void main(final String[] args) { + DesktopApplicationContext.main(new String[] { + TextInputValidatorTest.class.getName() + }); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/VFSBrowserTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/VFSBrowserTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/VFSBrowserTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/VFSBrowserTest.java Tue Mar 6 19:04:46 2018 @@ -39,7 +39,7 @@ import org.apache.pivot.wtk.Style; import org.apache.pivot.wtk.VerticalAlignment; import org.apache.pivot.wtk.VFSBrowserSheet; -public class VFSBrowserTest implements Application { +public final class VFSBrowserTest implements Application { public VFSBrowserTest() { } @@ -47,7 +47,7 @@ public class VFSBrowserTest implements A private Frame frame = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BoxPane windowContent = new BoxPane(); windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER); @@ -58,7 +58,7 @@ public class VFSBrowserTest implements A button.getStyles().put(Style.padding, "[2, 4, 2, 4]"); button.getButtonPressListeners().add(new ButtonPressListener() { @Override - public void buttonPressed(Button buttonArgument) { + public void buttonPressed(final Button buttonArgument) { try { final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet( VFSBrowserSheet.Mode.OPEN); @@ -67,7 +67,7 @@ public class VFSBrowserTest implements A vfsBrowserSheet.open(frame, new SheetCloseListener() { @Override - public void sheetClosed(Sheet sheet) { + public void sheetClosed(final Sheet sheet) { if (sheet.getResult()) { Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles(); @@ -97,7 +97,7 @@ public class VFSBrowserTest implements A } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (frame != null) { frame.close(); } @@ -105,7 +105,7 @@ public class VFSBrowserTest implements A return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(VFSBrowserTest.class, args); } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/WatermarkDecoratorTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/WatermarkDecoratorTest.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/WatermarkDecoratorTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/WatermarkDecoratorTest.java Tue Mar 6 19:04:46 2018 @@ -23,11 +23,11 @@ import org.apache.pivot.wtk.DesktopAppli import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Window; -public class WatermarkDecoratorTest implements Application { +public final class WatermarkDecoratorTest implements Application { private Window window = null; @Override - public void startup(Display display, Map<String, String> properties) throws Exception { + public void startup(final Display display, final Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); window = (Window) bxmlSerializer.readObject(WatermarkDecoratorTest.class, "watermark_decorator_test.bxml"); @@ -36,7 +36,7 @@ public class WatermarkDecoratorTest impl } @Override - public boolean shutdown(boolean optional) { + public boolean shutdown(final boolean optional) { if (window != null) { window.close(); } @@ -44,7 +44,7 @@ public class WatermarkDecoratorTest impl return false; } - public static void main(String[] args) { + public static void main(final String[] args) { DesktopApplicationContext.main(WatermarkDecoratorTest.class, args); } } Modified: pivot/trunk/tests/src/org/apache/pivot/tests/slider_test.bxml URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/slider_test.bxml?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/slider_test.bxml (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/slider_test.bxml Tue Mar 6 19:04:46 2018 @@ -16,10 +16,24 @@ See the License for the specific languag limitations under the License. --> -<BoxPane xmlns:bxml="http://pivot.apache.org/bxml" - xmlns="org.apache.pivot.wtk"> - <Slider bxml:id="slider1" range="{start:-100, end:100}" value="0" styles="{ tickSpacing:10}"/> - <Label bxml:id="valueLabel1" text="0"/> - <Slider bxml:id="slider2" range="{start:-100, end:100}" value="0" orientation="vertical" styles="{ tickSpacing:10}"/> - <Label bxml:id="valueLabel2" text="0"/> -</BoxPane> +<TablePane xmlns:bxml="http://pivot.apache.org/bxml" + xmlns="org.apache.pivot.wtk" + styles="{padding:8,verticalSpacing:6,horizontalSpacing:6}"> + <columns> + <TablePane.Column width="-1"/> + <TablePane.Column width="-1"/> + </columns> + <rows> + <TablePane.Row height="-1"> + <Slider bxml:id="slider1" range="{start:-100, end:100}" value="0" styles="{tickSpacing:10}"/> + <Label bxml:id="valueLabel1" text="0"/> + </TablePane.Row> + <TablePane.Row height="-1"> + <ImageView bxml:id="imageView" preferredWidth="120" preferredHeight="120"/> + <BoxPane> + <Slider bxml:id="slider2" range="{start:-100, end:100}" value="0" orientation="vertical" styles="{tickSpacing:10}"/> + <Label bxml:id="valueLabel2" text="0"/> + </BoxPane> + </TablePane.Row> + </rows> +</TablePane> Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java?rev=1826023&r1=1826022&r2=1826023&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java Tue Mar 6 19:04:46 2018 @@ -41,29 +41,33 @@ public class Slider extends Container { this(Orientation.HORIZONTAL); } - public Slider(Orientation orientation) { + public Slider(final Orientation orientation) { this.orientation = orientation; installSkin(Slider.class); } - public int getStart() { + public final int getStart() { return start; } - public void setStart(int start) { + public final void setStart(final int start) { setRange(start, end); } - public int getEnd() { + public final int getEnd() { return end; } - public void setEnd(int end) { + public final void setEnd(final int end) { setRange(start, end); } - public void setRange(int start, int end) { + public final Span getRange() { + return new Span(start, end); + } + + public final void setRange(final int start, final int end) { if (start > end) { throw new IllegalArgumentException("start " + start + " is greater than maximum " + end + "."); } @@ -91,29 +95,29 @@ public class Slider extends Container { } } - public final void setRange(Span range) { + public final void setRange(final Span range) { Utils.checkNull(range, "range"); setRange(range.start, range.end); } - public final void setRange(Dictionary<String, ?> range) { + public final void setRange(final Dictionary<String, ?> range) { setRange(new Span(range)); } - public final void setRange(Sequence<?> range) { + public final void setRange(final Sequence<?> range) { setRange(new Span(range)); } - public final void setRange(String range) { + public final void setRange(final String range) { setRange(Span.decode(range)); } - public int getValue() { + public final int getValue() { return value; } - public void setValue(int value) { + public final void setValue(final int value) { if (value < start) { throw new IllegalArgumentException("value " + value + " is less than minimum " + start + "."); } @@ -130,11 +134,11 @@ public class Slider extends Container { } } - public Orientation getOrientation() { + public final Orientation getOrientation() { return orientation; } - public void setOrientation(Orientation orientation) { + public final void setOrientation(final Orientation orientation) { Utils.checkNull(orientation, "orientation"); if (this.orientation != orientation) { @@ -143,11 +147,11 @@ public class Slider extends Container { } } - public ListenerList<SliderListener> getSliderListeners() { + public final ListenerList<SliderListener> getSliderListeners() { return sliderListeners; } - public ListenerList<SliderValueListener> getSliderValueListeners() { + public final ListenerList<SliderValueListener> getSliderValueListeners() { return sliderValueListeners; } }