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)DataTypeBlob.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeBlob.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 DataTypeBlob.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeBlob.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 DataTypeBlob.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)DataTypeClob.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeClob.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 DataTypeClob.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeClob.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 DataTypeClob.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/DataTypeBlob.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeClob.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
				// as a coding convenience, create a reference to the text component
4
				// as a coding convenience, create a reference to the text component
5
				// that is typecast to JTextComponent.  this is not essential, as we
5
				// that is typecast to JTextComponent.  this is not essential, as we
6
				// could typecast every reference, but this makes the code cleaner
6
				// could typecast every reference, but this makes the code cleaner
7
				JTextComponent _theComponent = (JTextComponent)DataTypeBlob.this._textComponent;
7
				JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
8
				String text = _theComponent.getText();
8
				String text = _theComponent.getText();
9
				// handle cases of null
9
				// handle cases of null
10
				// The processing is different when nulls are allowed and when they are not.
10
				// The processing is different when nulls are allowed and when they are not.
11
				//
11
				//
12
				if ( DataTypeBlob.this._isNullable) {
12
				if ( DataTypeClob.this._isNullable) {
13
					// user enters something when field is null
13
					// user enters something when field is null
14
					if (text.equals("<null>")) {
14
					if (text.equals("<null>")) {
15
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
15
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
16
							// delete when null => original value
16
							// delete when null => original value
17
							DataTypeBlob.this._textComponent.restoreText();
17
							DataTypeClob.this._textComponent.restoreText();
18
							e.consume();
18
							e.consume();
19
						}
19
						}
20
						else {
20
						else {
21
							// non-delete when null => clear field and add text
21
							// non-delete when null => clear field and add text
22
							DataTypeBlob.this._textComponent.updateText("");
22
							DataTypeClob.this._textComponent.updateText("");
23
							// fall through to normal processing of this key stroke
23
							// fall through to normal processing of this key stroke
24
						}
24
						}
25
					}
25
					}
26
					else {
26
					else {
27
						// check for user deletes last thing in field
27
						// check for user deletes last thing in field
28
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
28
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
29
							if (text.length() <= 1 ) {
29
							if (text.length() <= 1 ) {
30
								// about to delete last thing in field, so replace with null
30
								// about to delete last thing in field, so replace with null
31
								DataTypeBlob.this._textComponent.updateText("<null>");
31
								DataTypeClob.this._textComponent.updateText("<null>");
32
								e.consume();
32
								e.consume();
33
							}
33
							}
34
						}
34
						}
35
					}
35
					}
36
				}
36
				}
37
				else {
37
				else {
38
                    // field is not nullable
38
                    // field is not nullable
39
                    //
39
                    //
40
                    handleNotNullableField(text, c, e, _textComponent)
40
                    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