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)
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) DerbyClobDataTypeComponent.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are // not. // if (DerbyClobDataTypeComponent.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 DerbyClobDataTypeComponent.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DerbyClobDataTypeComponent.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 DerbyClobDataTypeComponent.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/DataTypeClob.java File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.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)DataTypeClob.this._textComponent;
7
         JTextComponent _theComponent = (JTextComponent) DerbyClobDataTypeComponent.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
11
				//
12
				if ( 
11
         // not.
12
         //
13
DataTypeClob.this._isNullable) {
13
         if (DerbyClobDataTypeComponent.this._isNullable) {
14
					// user enters something when field is null
14
            // user enters something when field is null
15
					if (text.equals("<null>")) {
15
            if (text.equals("<null>")) {
16
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
16
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
17
							// delete when null => original value
17
                  // delete when null => original value
18
							DataTypeClob.this._textComponent.restoreText();
18
                  DerbyClobDataTypeComponent.this._textComponent.restoreText();
19
							e.consume();
20
						}
21
						else {
22
							
19
                  e.consume();
20
               } else {
23
// non-delete when null => clear field and add text
21
                  // non-delete when null => clear field and add text
24
							DataTypeClob.this._textComponent.updateText("");
22
                  DerbyClobDataTypeComponent.this._textComponent.updateText("");
25
							// fall through to normal processing of this key stroke
23
                  // fall through to normal processing of this key stroke
26
						}
27
					}
28
					else {
29
						
24
               }
25
            } else {
30
// check for user deletes last thing in field
26
               // check for user deletes last thing in field
31
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
27
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
32
							if (text.length() <= 1 ) {
28
                  if (text.length() <= 1) {
33
								// about to delete last thing in field, so replace with null
29
                     // about to delete last thing in field, so replace with
34
								
30
                     // null
35
DataTypeClob.this._textComponent.updateText("<null>");
31
                     DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
36
								e.consume();
37
							}
38
						}
39
					}
40
				}
41
				else {
42
        
32
                     e.consume();
33
                  }
34
               }
35
            }
36
         } else {
43
            // field is not nullable
37
            // field is not nullable
44
                    //
38
            
45
        
39
//
46
            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