Revision: 6208
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6208&view=rev
Author: wis775
Date: 2011-03-26 13:06:54 +0000 (Sat, 26 Mar 2011)
Log Message:
-----------
Editing numeric values: Now, Squirrel has the same behavior for signed values for all different numeric data types.
A minus sign is allowed only at the first position and if the data type is signed.
Added FEST-dependency to FW for UI-testing.
Modified Paths:
--------------
trunk/sql12/fw/pom.xml
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/BaseKeyTextHandler.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimal.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDouble.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloat.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeInteger.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java
Added Paths:
-----------
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/AbstractNumericDataTypeUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimalUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDoubleUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloatUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeIntegerUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLongUITest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShortUITest.java
Modified: trunk/sql12/fw/pom.xml
===================================================================
--- trunk/sql12/fw/pom.xml 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/pom.xml 2011-03-26 13:06:54 UTC (rev 6208)
@@ -226,6 +226,10 @@
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-swing-junit-4.5</artifactId>
+ </dependency>
+ <dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/BaseKeyTextHandler.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/BaseKeyTextHandler.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/BaseKeyTextHandler.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -21,6 +21,12 @@
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+import javax.swing.text.JTextComponent;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+import org.apache.commons.lang.StringUtils;
+
public class BaseKeyTextHandler extends KeyAdapter {
/**
@@ -72,4 +78,63 @@
}
}
}
+
+ /**
+ * Ensure, that a sign character is entered at the right position.
+ * Valid characters for a sign is the <code>-</code>. If the corresponding {@link ColumnDisplayDefinition#isSigned()} is
+ * <code>false</code>, than a sign is not allowed for this column.
+ * Otherwise, a sign character is allowed at the first position of the text if there is not already a sign char present.
+ * <B>If the entered sign character is not valid, then the keyEvent will be consumed and a beep will be processed.</B>
+ * <p>For example:</p>
+ * Allowed:
+ * <li>42</li>
+ * <li>-42</li>
+ * Not allowed:
+ * <li>-.42</li>
+ * <li>--42</li>
+ * <li>42-42</li>
+ * <li>-42-42</li>
+ * <li>42-</li>
+ * @param keyEvent KeyEvent, which insert a character
+ * @param textComponent Text component, where the character was typed.
+ * @param colDef Display definition of the affected column. This will be used, for finding out, if the data type can be signed.
+ * @param beepHelper Helper for beeping, if a sign char is would be inserted at a wrong position.
+ */
+ protected void checkSignCharacter(KeyEvent keyEvent, JTextComponent textComponent, ColumnDisplayDefinition colDef, IToolkitBeepHelper beepHelper) {
+ char c = keyEvent.getKeyChar();
+ String text = textComponent.getText();
+
+ if ( isSignCharacter(c)){
+ boolean ok = true;
+ if(colDef.isSigned() == false){
+ ok = false;
+ }else if(!text.equals("<null>") && text.length() != 0){
+ int caretPosition = textComponent.getCaretPosition();
+ if(caretPosition != 0 || isSignCharacter(text.charAt(0))){
+ ok = false;
+ }
+ }
+ if(ok == false){
+ /*
+ * user entered '+' or '-' at a bad place,
+ * Maybe not at the first position, or there is not a numeric char at the beginning - maybe we have already a sign
+ */
+ beepHelper.beep(textComponent);
+ keyEvent.consume();
+ }
+ }
+ }
+
+ /**
+ * Checks, if the specified character is a <code>-</code>;
+ * @param c Character, which should be checked.
+ * @return true, if the character is a sign character, otherwise false
+ */
+ protected boolean isSignCharacter(char c){
+ if(c == '-'){
+ return true;
+ }else{
+ return false;
+ }
+ }
}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimal.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimal.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimal.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -415,23 +415,10 @@
- if ( (c == '-' || c=='+') &&
- ! (text.equals("<null>") || text.length() == 0)
- ) {
- int caretPosition = _theComponent.getCaretPosition();
- if(caretPosition != 0 || !StringUtils.isNumeric(text.substring(0, 1))
- ){
- /*
- * user entered '+' or '-' at a bad place,
- * Maybe not at the first position, or there is not a numeric char at the beginning - maybe we have already a sign
- */
- _beepHelper.beep(_theComponent);
- e.consume();
- }
- }
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
if ( ! ( Character.isDigit(c) ||
- (c == '-') || (c == '+') ||
+ (isSignCharacter(c)) ||
(c == '.') || (c == ',') || // several number formats use '.' as decimal separator, others use ','
(c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE) ) ) {
@@ -475,6 +462,8 @@
handleNotNullableField(text, c, e, _textComponent);
}
}
+
+
}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDouble.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDouble.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDouble.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -315,7 +315,7 @@
// could typecast every reference, but this makes the code cleaner
JTextComponent _theComponent = (JTextComponent) DataTypeDouble.this._textComponent;
String text = _theComponent.getText();
-
+
// tabs and newlines get put into the text before this check,
// so remove them
// This only applies to Popup editing since these chars are
@@ -339,6 +339,8 @@
}
e.consume();
}
+
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
if (!(Character.isDigit(c) || (c == '-') || (c == '+') || (c == 'e') || (c == 'E') || (c == 'f')
|| (c == 'F') || (c == 'd') || (c == 'D') || (c == '.') || (c == ',') || // several number formats
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloat.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloat.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloat.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -340,10 +340,12 @@
}
e.consume();
}
+
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
if ( ! ( Character.isDigit(c) ||
- (c == '-') || (c == '+') ||
+ (isSignCharacter(c)) ||
(c == 'e') || (c == 'E') ||
(c == 'f') || (c == 'F') ||
(c == '.') || (c == ',') || // several number formats use '.' as decimal separator, others use ','
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeInteger.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeInteger.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeInteger.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -279,12 +279,7 @@
JTextComponent _theComponent = (JTextComponent)DataTypeInteger.this._textComponent;
String text = _theComponent.getText();
- // look for illegal chars
- if ( ! DataTypeInteger.this._isSigned && c == '-') {
- // cannot use '-' when unsigned
- _beepHelper.beep(_theComponent);
- e.consume();
- }
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
// tabs and newlines get put into the text before this check,
// so remove them
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -270,12 +270,7 @@
JTextComponent _theComponent = (JTextComponent)DataTypeLong.this._textComponent;
String text = _theComponent.getText();
- // look for illegal chars
- if ( ! DataTypeLong.this._isSigned && c == '-') {
- // cannot use '-' when unsigned
- _beepHelper.beep(_theComponent);
- e.consume();
- }
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
// tabs and newlines get put into the text before this check,
// so remove them
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java 2011-03-26 12:52:09 UTC (rev 6207)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -271,12 +271,7 @@
JTextComponent _theComponent = (JTextComponent)DataTypeShort.this._textComponent;
String text = _theComponent.getText();
- // look for illegal chars
- if ( ! DataTypeShort.this._isSigned && c == '-') {
- // cannot use '-' when unsigned
- _beepHelper.beep(_theComponent);
- e.consume();
- }
+ checkSignCharacter(e, _theComponent, _colDef, _beepHelper);
// tabs and newlines get put into the text before this check,
// so remove them
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/AbstractNumericDataTypeUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/AbstractNumericDataTypeUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/AbstractNumericDataTypeUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,377 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import static org.easymock.EasyMock.expect;
+
+import java.awt.Dimension;
+import java.awt.event.KeyEvent;
+import java.sql.Types;
+
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.text.JTextComponent;
+
+import net.sourceforge.squirrel_sql.BaseSQuirreLJUnit4TestCase;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+import org.fest.swing.edt.GuiActionRunner;
+import org.fest.swing.edt.GuiQuery;
+import org.fest.swing.fixture.FrameFixture;
+import org.fest.swing.fixture.JTextComponentFixture;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * An abstract test case, that provide some generic tests for the text components
+ * of the different numeric data types.
+ * This test case was written, to ensure the same behavior of different numeric data
+ * types when editing the value through the {@link JTextField}
+ * @author Stefan Willinger
+ *
+ */
+public abstract class AbstractNumericDataTypeUITest extends BaseSQuirreLJUnit4TestCase {
+
+ /**
+ *
+ */
+ private static final String TA_UN_SIGNED = "taUnSigned";
+ /**
+ *
+ */
+ private static final String TA_SIGNED = "taSigned";
+ /**
+ *
+ */
+ private static final String TF_UN_SIGNED = "tfUnSigned";
+ /**
+ *
+ */
+ private static final String TF_SIGNED = "tfSigned";
+ protected FrameFixture fixture = null;
+
+
+ /**
+ * Sets up the test environment.
+ * It's important, that swing components and mock objects are created within the event dispatcher thread.
+ */
+ @Before
+ public void setUp() throws Exception {
+ JFrame frame = constructTestFrameInEDT();
+
+ fixture = new FrameFixture(frame);
+ fixture.show();
+
+ }
+
+ @After
+ public void tearDown() {
+ fixture.cleanUp();
+ }
+
+ /**
+ * Set up the environment within the event dispatcher thread
+ * @return JFrame, which contains the testable components.
+ */
+ protected JFrame constructTestFrameInEDT() {
+ return GuiActionRunner.execute(new GuiQuery<JFrame>() {
+ protected JFrame executeInEDT() {
+ return constructTestFrame();
+ }
+ });
+ }
+
+ /**
+ * Create a simple JFrame, which contains the {@link JTextField} and a {@link JTextArea} of the {@link IDataTypeComponent} for testing.
+ * One for signed and unsigned data types.
+ * @see #TF_SIGNED
+ * @see #TF_UN_SIGNED
+ * @see #TA_SIGNED
+ * @see #TA_UN_SIGNED
+ */
+ private JFrame constructTestFrame() {
+
+ ColumnDisplayDefinition columnDisplayDefinitionUnsigned = getMockColumnDisplayDefinition(false);
+ ColumnDisplayDefinition columnDisplayDefinitionSigned = getMockColumnDisplayDefinition(true);
+ mockHelper.replayAll();
+
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, 1));
+ panel.setPreferredSize(new Dimension(100, 50));
+
+ IDataTypeComponent dataType;
+
+ // text field signed
+ dataType = initClassUnderTest(columnDisplayDefinitionSigned);
+ addTextComponentToPanel(panel, dataType.getJTextField(), TF_SIGNED);
+
+ // text field unSigned
+ dataType = initClassUnderTest(columnDisplayDefinitionUnsigned);
+ addTextComponentToPanel(panel, dataType.getJTextField(), TF_UN_SIGNED);
+
+ // text area signed
+ dataType = initClassUnderTest(columnDisplayDefinitionSigned);
+ addTextComponentToPanel(panel, dataType.getJTextArea(null), TA_SIGNED);
+
+ // text area unSigned
+ dataType = initClassUnderTest(columnDisplayDefinitionUnsigned);
+ addTextComponentToPanel(panel, dataType.getJTextArea(null), TA_UN_SIGNED);
+
+ final JFrame frame = new JFrame("Test edit Numeric DataTypes");
+ frame.getContentPane().add(panel);
+ frame.setSize(new Dimension(300, 300));
+ frame.setPreferredSize(new Dimension(300, 300));
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLocation(10, 10);
+ return frame;
+
+
+ }
+
+ private void addTextComponentToPanel(JPanel panel, JTextComponent textComponent, String name){
+ JPanel subPanel = new JPanel();
+ subPanel.add(new JLabel(name));
+ textComponent.setName(name);
+ textComponent.setPreferredSize(new Dimension(100, 20));
+ subPanel.add(textComponent);
+ panel.add(subPanel);
+ }
+
+
+ /**
+ * Create the concrete {@link IDataTypeComponent} that should be tested.
+ * @param columnDisplayDefinition Display definition to use.
+ */
+ protected abstract IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition);
+
+
+
+ /**
+ * Some DataTypeComponents require a ColumnDisplayDefinition in their
+ * constructor. This returns a mock which can be passed into the
+ * constructor.
+ */
+ protected ColumnDisplayDefinition getMockColumnDisplayDefinition(boolean signed) {
+ ColumnDisplayDefinition columnDisplayDefinition = mockHelper.createMock(
+ "testColumnDisplayDefinition", ColumnDisplayDefinition.class);
+ expect(columnDisplayDefinition.isNullable()).andStubReturn(true);
+ expect(columnDisplayDefinition.isSigned()).andStubReturn(signed);
+ expect(columnDisplayDefinition.getPrecision()).andStubReturn(10);
+ expect(columnDisplayDefinition.getScale()).andStubReturn(3);
+ expect(columnDisplayDefinition.getColumnSize()).andStubReturn(10);
+ expect(columnDisplayDefinition.getColumnName()).andStubReturn("testLabel");
+ expect(columnDisplayDefinition.getSqlType()).andStubReturn(Types.NUMERIC);
+ expect(columnDisplayDefinition.getSqlTypeName()).andStubReturn("NUMERIC");
+ return columnDisplayDefinition;
+ }
+
+
+
+ @Test
+ public void testInsertMinusSign() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.enterText("-");
+ textBox.requireText("-");
+
+ textBox = fixture.textBox(TF_UN_SIGNED);
+ textBox.enterText("-");
+ textBox.requireText("");
+
+ textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("");
+ textBox.enterText("-");
+ textBox.requireText("-");
+
+ textBox = fixture.textBox(TA_UN_SIGNED);
+ textBox.setText("");
+ textBox.enterText("-");
+ textBox.requireText("");
+
+
+ }
+
+ @Test
+ public void testInsertMinusSignIfANumberIsPresent() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("-0");
+
+ textBox = fixture.textBox(TF_UN_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("-0");
+
+ textBox = fixture.textBox(TA_UN_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("0");
+ }
+
+ /**
+ * A <code>+</code> character is not allowed as sign.
+ */
+ @Test
+ public void testInsertPlusSign() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.enterText("+");
+ textBox.requireText("");
+
+ fixture.textBox(TF_UN_SIGNED);
+ textBox.enterText("+");
+ textBox.requireText("");
+
+ fixture.textBox(TA_SIGNED);
+ textBox.enterText("+");
+ textBox.requireText("");
+
+ fixture.textBox(TA_UN_SIGNED);
+ textBox.enterText("+");
+ textBox.requireText("");
+ }
+
+
+
+ /**
+ * A <code>+</code> character is not allowed as sign.
+ */
+ @Test
+ public void testInsertPlusSignIfANumberIsPresent() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("+");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TF_UN_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("+");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("+");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TA_UN_SIGNED);
+ textBox.setText("0");
+ // go to the first position
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("+");
+ textBox.requireText("0");
+ }
+
+
+
+ @Test
+ public void testInsertMinusSignWhenSignAllreadyPresent() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.setText("-0");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("-0");
+
+ textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("-0");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("-0");
+ }
+
+ @Test
+ public void testInsertMinusSignAtBadLocation() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TF_SIGNED);
+ textBox.setText("0");
+ textBox.enterText("-");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TF_UN_SIGNED);
+ textBox.setText("0");
+ textBox.enterText("-");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("");
+ textBox.enterText("0");
+ textBox.enterText("-");
+ textBox.requireText("0");
+
+ textBox = fixture.textBox(TA_UN_SIGNED);
+ textBox.setText("");
+ textBox.enterText("0");
+ textBox.enterText("-");
+ textBox.requireText("0");
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testInsertMinusSignWhenNullValue() throws Exception {
+ JTextComponentFixture textBox = fixture.textBox(TA_SIGNED);
+ textBox.setText("<null>");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_END);
+ textBox.enterText("-");
+ textBox.requireText("-");
+
+ textBox.setText("<null>");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("-");
+
+
+ textBox = fixture.textBox(TA_UN_SIGNED);
+ textBox.setText("<null>");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_END);
+ textBox.enterText("-");
+ textBox.requireText("");
+
+ textBox.setText("<null>");
+ textBox.pressAndReleaseKeys(KeyEvent.VK_HOME);
+ textBox.enterText("-");
+ textBox.requireText("");
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/AbstractNumericDataTypeUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimalUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimalUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimalUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeBigDecimalUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeBigDecimalUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeBigDecimal(null, columnDisplayDefinition);
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBigDecimalUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDoubleUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDoubleUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDoubleUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeDoubleUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeDoubleUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeDouble(null, columnDisplayDefinition);
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDoubleUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloatUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloatUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloatUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeFloatUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeFloatUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeFloat(null, columnDisplayDefinition);
+
+ }
+
+
+// @Test
+// public void testInsertMinusSign_2() throws Exception {
+// textField.setText("0");
+// textField.setCaretPosition(1);
+// textField.dispatchEvent(createKeyEvent_Typed('-'));
+// assertEquals("0-", textField.getText());
+// }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeFloatUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeIntegerUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeIntegerUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeIntegerUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeIntegerUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeIntegerUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeInteger(null, columnDisplayDefinition);
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeIntegerUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLongUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLongUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLongUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeLongUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeLongUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeLong(null, columnDisplayDefinition);
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLongUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShortUITest.java
===================================================================
--- trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShortUITest.java (rev 0)
+++ trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShortUITest.java 2011-03-26 13:06:54 UTC (rev 6208)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import javax.swing.JFrame;
+
+import org.fest.swing.edt.GuiActionRunner;
+import org.fest.swing.edt.GuiQuery;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+
+/**
+ * @author Stefan Willinger
+ *
+ */
+public class DataTypeShortUITest extends AbstractNumericDataTypeUITest {
+
+ /**
+ * The main method is not used at all in the test - it is just here to allow
+ * for user interaction testing with the graphical component, which doesn't
+ * require launching SQuirreL.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame frame = new DataTypeShortUITest().constructTestFrameInEDT();
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.AbstractNumericDataTypeUITest#initClassUnderTests(net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition)
+ */
+ @Override
+ protected IDataTypeComponent initClassUnderTest(ColumnDisplayDefinition columnDisplayDefinition) {
+ return new DataTypeShort(null, columnDisplayDefinition);
+
+ }
+
+}
Property changes on: trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShortUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|