View | Details | Raw Unified | Return to bug 383750
Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Text.java (-47 / +51 lines)
Lines 2066-2094 Link Here
2066
 * </ul>
2066
 * </ul>
2067
 */
2067
 */
2068
public void setText (String string) {
2068
public void setText (String string) {
2069
	checkWidget ();
2069
   java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat("HH:mm:ss:SSS");
2070
	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
2070
   System.out.println(simpleDateFormat.format(new java.util.Date()) +" setText() called on (" +hashCode() +"). OldValue: " +new String(getEditText()) +", NewValue: " +string);
2071
	if (hooks (SWT.Verify) || filters (SWT.Verify)) {
2071
   checkWidget ();
2072
		string = verifyText (string, 0, getCharCount (), null);
2072
   if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
2073
		if (string == null) return;
2073
   if (hooks (SWT.Verify) || filters (SWT.Verify)) {
2074
	}
2074
      string = verifyText (string, 0, getCharCount (), null);
2075
	if ((style & SWT.SINGLE) != 0) {
2075
      if (string == null) return;
2076
		setEditText (string);
2076
   }
2077
		NSText fieldEditor = ((NSControl)view).currentEditor();
2077
   if ((style & SWT.SINGLE) != 0) {
2078
		if (fieldEditor != null) {
2078
      setEditText (string);
2079
			NSRange range = new NSRange();
2079
      NSText fieldEditor = ((NSControl)view).currentEditor();
2080
			fieldEditor.setSelectedRange (range);
2080
      if (fieldEditor != null) {
2081
			fieldEditor.scrollRangeToVisible (range);
2081
         NSRange range = new NSRange();
2082
		}
2082
         fieldEditor.setSelectedRange (range);
2083
	} else {
2083
         fieldEditor.scrollRangeToVisible (range);
2084
		NSTextView widget = (NSTextView)view;
2084
      }
2085
		char[] buffer = new char [Math.min(string.length (), textLimit)];
2085
   } else {
2086
		string.getChars (0, buffer.length, buffer, 0);
2086
      NSTextView widget = (NSTextView)view;
2087
		NSString str = NSString.stringWithCharacters(buffer, buffer.length);
2087
      char[] buffer = new char [Math.min(string.length (), textLimit)];
2088
		widget.setString (str);
2088
      string.getChars (0, buffer.length, buffer, 0);
2089
		widget.setSelectedRange(new NSRange());
2089
      NSString str = NSString.stringWithCharacters(buffer, buffer.length);
2090
	}
2090
      widget.setString (str);
2091
	sendEvent (SWT.Modify);
2091
      widget.setSelectedRange(new NSRange());
2092
   }
2093
   sendEvent (SWT.Modify);
2092
}
2094
}
2093
2095
2094
/**
2096
/**
Lines 2111-2140 Link Here
2111
 * @since 3.7
2113
 * @since 3.7
2112
 */
2114
 */
2113
public void setTextChars (char[] text) {
2115
public void setTextChars (char[] text) {
2114
	checkWidget ();
2116
   java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat("HH:mm:ss:SSS");
2115
	if (text == null) error (SWT.ERROR_NULL_ARGUMENT);
2117
   System.out.println(simpleDateFormat.format(new java.util.Date()) +" setTextChars() called on (" +hashCode() +"). OldValue: " +new String(getEditText()) +", NewValue: " +new String(text));
2116
	if (hooks (SWT.Verify) || filters (SWT.Verify)) {
2118
   checkWidget ();
2117
		String string = verifyText (new String (text), 0, getCharCount (), null);
2119
   if (text == null) error (SWT.ERROR_NULL_ARGUMENT);
2118
		if (string == null) return;
2120
   if (hooks (SWT.Verify) || filters (SWT.Verify)) {
2119
		text = new char [string.length()];
2121
      String string = verifyText (new String (text), 0, getCharCount (), null);
2120
		string.getChars (0, text.length, text, 0);
2122
      if (string == null) return;
2121
	}
2123
      text = new char [string.length()];
2122
	if ((style & SWT.SINGLE) != 0) {
2124
      string.getChars (0, text.length, text, 0);
2123
		setEditText (text);
2125
   }
2124
		NSText fieldEditor = ((NSControl)view).currentEditor();
2126
   if ((style & SWT.SINGLE) != 0) {
2125
		if (fieldEditor != null) {
2127
      setEditText (text);
2126
			NSRange range = new NSRange();
2128
      NSText fieldEditor = ((NSControl)view).currentEditor();
2127
			fieldEditor.setSelectedRange (range);
2129
      if (fieldEditor != null) {
2128
			fieldEditor.scrollRangeToVisible (range);
2130
         NSRange range = new NSRange();
2129
		}
2131
         fieldEditor.setSelectedRange (range);
2130
	} else {
2132
         fieldEditor.scrollRangeToVisible (range);
2131
		NSTextView widget = (NSTextView)view;
2133
      }
2132
		int length = Math.min(text.length, textLimit);
2134
   } else {
2133
		NSString str = NSString.stringWithCharacters(text, length);
2135
      NSTextView widget = (NSTextView)view;
2134
		widget.setString (str);
2136
      int length = Math.min(text.length, textLimit);
2135
		widget.setSelectedRange(new NSRange());
2137
      NSString str = NSString.stringWithCharacters(text, length);
2136
	}
2138
      widget.setString (str);
2137
	sendEvent (SWT.Modify);
2139
      widget.setSelectedRange(new NSRange());
2140
   }
2141
   sendEvent (SWT.Modify);
2138
}
2142
}
2139
2143
2140
/**
2144
/**
(-)src/org/eclipse/swt/widgets/Widget.java (-4 / +31 lines)
Lines 565-574 Link Here
565
 * </ul>
565
 * </ul>
566
 */
566
 */
567
protected void checkWidget () {
567
protected void checkWidget () {
568
	Display display = this.display;
568
   if(this instanceof Text)
569
	if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
569
   {
570
	if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
570
      String content = new String(((Text)this).getEditText());
571
	if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
571
      int hashCode = hashCode();
572
      if("NoName".equals(content)  || "somePrefix".equals(content))
573
      {
574
         java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat("HH:mm:ss:SSS");
575
         String msg = simpleDateFormat.format(new java.util.Date()) +" checkWidget (" +hashCode +"), content: '" +new String(((Text)this).getEditText()) +"'";
576
         Throwable fillInStackTrace = new RuntimeException(msg).fillInStackTrace();
577
         boolean printIt = true;
578
         StackTraceElement[] stackTrace = fillInStackTrace.getStackTrace();
579
         for (int i=0; i < stackTrace.length; i++)
580
         {
581
            String traceLine = stackTrace[i].toString();
582
            if(!traceLine.contains("setText") && (traceLine.contains("hitTest") || traceLine.contains("isActive")  || traceLine.contains("isEnabled")))
583
            {
584
               printIt = false;
585
               break;
586
            }
587
         }
588
         if(printIt)
589
         {
590
            fillInStackTrace.printStackTrace();
591
         }
592
      }
593
   }
594
595
   Display display = this.display;
596
   if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
597
   if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
598
   if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
572
}
599
}
573
600
574
void clearDeferFlushing (long /*int*/ id, long /*int*/ sel) {
601
void clearDeferFlushing (long /*int*/ id, long /*int*/ sel) {

Return to bug 383750