private class KeyTextHandler extends BaseKeyTextHandler { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); // as a coding convenience, create a reference to the text component // that is typecast to JTextComponent. this is not essential, as we // could typecast every reference, but this makes the code cleaner JTextComponent _theComponent = (JTextComponent)DataTypeBinary.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 // not passed to this level by the in-cell editor. if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) { // remove all instances of the offending char int index = text.indexOf(c); if (index != -1) { if (index == text.length() -1) { text = text.substring(0, text.length()-1); // truncate string } else { text = text.substring(0, index) + text.substring(index+1); } ((IRestorableTextComponent)_theComponent).updateText( text); _beepHelper.beep(_theComponent); } e.consume(); } // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeBinary.this._isNullable) { // user enters something when field is null if (text.equals("<null>")) { if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { // delete when null => original value DataTypeBinary.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeBinary.this._textComponent.updateText(""); // fall through to normal processing of this key stroke } } else { // check for user deletes last thing in field if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { if (text.length() <= 1 ) { // about to delete last thing in field, so replace with null DataTypeBinary.this._textComponent.updateText("<null>"); e.consume(); } } } } else { // field is not nullable // handleNotNullableField(text, c, e, _textComponent)
private class KeyTextHandler extends BaseKeyTextHandler { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); // as a coding convenience, create a reference to the text component // that is typecast to JTextComponent. this is not essential, as we // could typecast every reference, but this makes the code cleaner JTextComponent _theComponent = (JTextComponent)DataTypeTimestamp.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 // not passed to this level by the in-cell editor. if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) { // remove all instances of the offending char int index = text.indexOf(c); if (index != -1) { if (index == text.length() -1) { text = text.substring(0, text.length()-1); // truncate string } else { text = text.substring(0, index) + text.substring(index+1); } ((IRestorableTextComponent)_theComponent).updateText( text); _beepHelper.beep(_theComponent); } e.consume(); } // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeTimestamp.this._isNullable) { // user enters something when field is null if (text.equals("<null>")) { if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { // delete when null => original value DataTypeTimestamp.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeTimestamp.this._textComponent.updateText(""); // fall through to normal processing of this key stroke } } else { // check for user deletes last thing in field if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { if (text.length() <= 1 ) { // about to delete last thing in field, so replace with null DataTypeTimestamp.this._textComponent.updateText("<null>"); e.consume(); } } } } else { // field is not nullable // handleNotNullableField(text, c, e, _textComponent)
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBinary.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeTimestamp.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
private class KeyTextHandler extends BaseKeyTextHandler {
1
private class KeyTextHandler extends BaseKeyTextHandler {
2
	 	public void keyTyped(KeyEvent e) {
2
       public void keyTyped(KeyEvent e) {
3
				char c = e.getKeyChar();
3
            char c = e.getKeyChar();
4
				
5
				
6
// as a coding convenience, create a reference to the text component
4
            // as a coding convenience, create a reference to the text component
7
				// that is typecast to JTextComponent.  this is not essential, as we
5
            // that is typecast to JTextComponent. this is not essential, as we
8
				// could typecast every reference, but this makes the code cleaner
6
            // could typecast every reference, but this makes the code cleaner
9
				JTextComponent _theComponent = (JTextComponent)DataTypeBinary.this._textComponent;
7
            JTextComponent _theComponent = (JTextComponent)DataTypeTimestamp.this._textComponent;
10
				String text = _theComponent.getText();
8
            String text = _theComponent.getText();
11
												
12
				
13
// tabs and newlines get put into the text before this check,
9
            // tabs and newlines get put into the text before this check,
14
				// so remove them
10
            // so remove them
15
				// This only applies to Popup editing since these chars are
11
            // This only applies to Popup editing since these chars are
16
				// not passed to this level by the in-cell editor.
12
            // not passed to this level by the in-cell editor.
17
				if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
13
            if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
18
					// remove all instances of the offending char
14
               // remove all instances of the offending char
19
					int index = text.indexOf(c);
15
               int index = text.indexOf(c);
20
					if (index != -1) {
16
               if (index != -1) {
21
						if (index == text.length() -1) {
17
	               if (index == text.length() -1) {
22
							text = text.substring(0, text.length()-1);	// truncate string
18
	                  text = text.substring(0, text.length()-1);	// truncate string
23
						}
19
	
24
						else {
25
							
20
               }
21
	               else {
26
text = text.substring(0, index) + text.substring(index+1);
22
	                  text = text.substring(0, index) + text.substring(index+1);
27
						}
23
	
28
						
24
               }
29
((IRestorableTextComponent)_theComponent).updateText( text);
25
	               ((IRestorableTextComponent)_theComponent).updateText( text);
30
						_beepHelper.beep(_theComponent);
26
	               _beepHelper.beep(_theComponent);
31
					}
32
					e.consume();
33
				}
34
				
27
               }
28
               e.consume();
29
            }
35
// handle cases of null
30
            // handle cases of null
36
				// The processing is different when nulls are allowed and when they are not.
31
            // The processing is different when nulls are allowed and when they are not.
37
				//
38
				
32
            //
39
if ( DataTypeBinary.this._isNullable) {
33
            if ( DataTypeTimestamp.this._isNullable) {
40
					// user enters something when field is null
34
               // user enters something when field is null
41
					if (text.equals("<null>")) {
35
               if (text.equals("<null>")) {
42
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
36
                  if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
43
							// delete when null => original value
37
                     // delete when null => original value
44
							DataTypeBinary.this._textComponent.restoreText();
45
							e.consume();
46
						}
47
						else {
48
							
38
                     DataTypeTimestamp.this._textComponent.restoreText();
39
                     e.consume();
40
                  }
41
                  else {
49
// non-delete when null => clear field and add text
42
                     // non-delete when null => clear field and add text
50
							DataTypeBinary.this._textComponent.updateText("");
43
                     DataTypeTimestamp.this._textComponent.updateText("");
51
							// fall through to normal processing of this key stroke
44
                     // fall through to normal processing of this key stroke
52
						}
53
					}
54
					else {
55
						
45
                  }
46
               }
47
               else {
56
// check for user deletes last thing in field
48
                  // check for user deletes last thing in field
57
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
49
                  if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
58
							if (text.length() <= 1 ) {
50
                     if (text.length() <= 1 ) {
59
								// about to delete last thing in field, so replace with null
51
                        // about to delete last thing in field, so replace with null
60
								DataTypeBinary.this._textComponent.updateText("<null>");
52
                        DataTypeTimestamp.this._textComponent.updateText("<null>");
61
								e.consume();
62
							}
63
						}
64
					}
65
				}
66
				
53
                        e.consume();
54
                     }
55
                  }
56
               }
57
            }
67
else {
58
            else {
68
                    // field is not nullable
59
                    // field is not nullable
69
                    //
60
                    //
70
                    handleNotNullableField(text, c, e, _textComponent)
61
                    handleNotNullableField(text, c, e, _textComponent)
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0