summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jbrown>2001-08-03 03:21:45 +0000
committerJeff Brown <jbrown>2001-08-03 03:21:45 +0000
commita3cf6edf2759347dfed8be8789cf18f42c61b40d (patch)
treeb1d6e038b9c2cf005e6520ec03fef50badbf932d
parent6f1ca9da79569ee49d3430f1aad6de7eee9d9184 (diff)
downloadeclipse.platform.swt-a3cf6edf2759347dfed8be8789cf18f42c61b40d.tar.gz
eclipse.platform.swt-a3cf6edf2759347dfed8be8789cf18f42c61b40d.tar.xz
eclipse.platform.swt-a3cf6edf2759347dfed8be8789cf18f42c61b40d.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java44
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java105
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java69
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java21
18 files changed, 189 insertions, 375 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
index 41f7d95a58..7026c5cb87 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -110,7 +110,7 @@ void deselectAll() {
}
}
public void dispose() {
- if (!isValidWidget ()) return;
+ if (isDisposed()) return;
Vector children = getChildren();
AbstractTreeItem child;
while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
@@ -141,18 +141,14 @@ Vector getChildren() {
* false - the receiver is collapsed, making its children invisible
*/
public boolean getExpanded() {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-
+ checkWidget();
return isExpanded;
}
/**
* Answer the number of children.
*/
public int getItemCount() {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-
+ checkWidget();
return getChildren().size();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
index 65b0bb8122..22f1026e29 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -33,8 +33,7 @@ static int checkStyle (int style) {
}
public void addSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
@@ -73,8 +72,7 @@ void click () {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int border = getBorderWidth ();
int width = border * 2, height = border * 2;
if ((style & SWT.ARROW) != 0) {
@@ -159,8 +157,7 @@ void createHandle (int index) {
}
public int getAlignment () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.ARROW) != 0) {
if ((style & SWT.UP) != 0) return SWT.UP;
if ((style & SWT.DOWN) != 0) return SWT.DOWN;
@@ -182,14 +179,12 @@ boolean getDefault () {
}
public Image getImage () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return image;
}
public boolean getSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -201,8 +196,7 @@ String getNameText () {
}
public String getText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.ARROW) != 0) return "";
int [] args = {
OS.Pt_ARG_TEXT_STRING, 0, 0,
@@ -308,8 +302,7 @@ void releaseWidget () {
}
public void removeSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
@@ -334,8 +327,7 @@ void selectRadio () {
}
public void setAlignment (int alignment) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.ARROW) != 0) {
if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return;
style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
@@ -360,16 +352,14 @@ void setDefault (boolean value) {
}
public void setSelection (boolean selected) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
OS.PtSetResources (handle, args.length / 3, args);
}
public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.ARROW) != 0) return;
this.image = image;
int imageHandle = 0;
@@ -383,8 +373,7 @@ public void setImage (Image image) {
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.ARROW) != 0) return;
char [] text = new char [string.length ()];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
index 24007b320d..667087c120 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -21,8 +21,7 @@ public Canvas (Composite parent, int style) {
}
public Caret getCaret () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return caret;
}
@@ -115,8 +114,7 @@ void releaseWidget () {
}
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (width <= 0 || height <= 0) return;
int deltaX = destX - x, deltaY = destY - y;
if (deltaX == 0 && deltaY == 0) return;
@@ -130,8 +128,7 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
}
void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
boolean isVisible = (caret != null) && (caret.isVisible ());
if (isVisible) caret.hideCaret ();
super.setBounds (x, y, width, height, move, resize);
@@ -139,8 +136,7 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean resiz
}
public void setCaret (Caret caret) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
Caret newCaret = caret;
Caret oldCaret = this.caret;
this.caret = newCaret;
@@ -150,4 +146,4 @@ public void setCaret (Caret caret) {
}
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
index 5d6a427547..a8271df354 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
@@ -62,8 +62,7 @@ boolean drawCaret () {
}
public Rectangle getBounds () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return new Rectangle (x, y, width, height);
}
@@ -74,32 +73,27 @@ public Display getDisplay () {
}
public Font getFont () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent.getFont ();
}
public Point getLocation () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return new Point (x, y);
}
public Canvas getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent;
}
public Point getSize () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return new Point (width, height);
}
public boolean getVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return isVisible;
}
@@ -112,8 +106,7 @@ boolean hideCaret () {
}
public boolean isVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return isVisible && parent.isVisible () && parent.hasFocus ();
}
@@ -140,8 +133,7 @@ void releaseWidget () {
}
public void setBounds (int x, int y, int width, int height) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
boolean samePosition, sameExtent, showing;
samePosition = (this.x == x) && (this.y == y);
sameExtent = (this.width == width) && (this.height == height);
@@ -172,39 +164,33 @@ void setFocus () {
}
public void setFont (Font font) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
}
public void setLocation (int x, int y) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
setBounds (x, y, width, height);
}
public void setLocation (Point location) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
public void setSize (int width, int height) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
setBounds (x, y, width, height);
}
public void setSize (Point size) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
public void setVisible (boolean visible) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (visible == isVisible) return;
if (isVisible = visible) {
showCaret ();
@@ -219,4 +205,4 @@ boolean showCaret () {
isShowing = true;
return drawCaret ();
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
index dd2d8b6b81..084d914ad7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
@@ -48,4 +48,4 @@ public void setRGB (RGB rgb) {
this.rgb = rgb;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
index 48ac1aabc6..39e712b69d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -46,8 +46,7 @@ static int checkStyle (int style) {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
//NOT DONE: this only works with a DROP_DOWN combo
if ((style & SWT.SIMPLE) != 0) return new Point(100, 100);
PhDim_t dim = new PhDim_t();
@@ -107,8 +106,7 @@ void createHandle (int index) {
}
public void deselect (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (args [1] == index) {
@@ -121,8 +119,7 @@ public void deselect (int index) {
}
public void deselectAll () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_TEXT_STRING, 0, 0,
OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0
@@ -131,8 +128,7 @@ public void deselectAll () {
}
public void add (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
byte [] buffer = Converter.wcsToMbcs (null, string, true);
int ptr = OS.malloc (buffer.length);
@@ -142,8 +138,7 @@ public void add (String string) {
}
public void add (String string, int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == -1) error (SWT.ERROR_INVALID_RANGE);
byte [] buffer = Converter.wcsToMbcs (null, string, true);
@@ -160,16 +155,14 @@ public void add (String string, int index) {
}
public void addModifyListener (ModifyListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Modify, typedListener);
}
public void addSelectionListener(SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
@@ -181,8 +174,7 @@ protected void checkSubclass () {
}
public void clearSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
}
@@ -204,8 +196,7 @@ int focusHandle () {
}
public String getItem (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
OS.Pt_ARG_ITEMS, 0, 0,
@@ -224,23 +215,20 @@ public String getItem (int index) {
}
public int getItemCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return args [1];
}
public int getItemHeight () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
//NOT DONE - NOT NEEDED
return 0;
}
public String [] getItems () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
OS.Pt_ARG_ITEMS, 0, 0,
@@ -264,8 +252,7 @@ String getNameText () {
}
public Point getSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (((style & SWT.DROP_DOWN) != 0) && ((style & SWT.READ_ONLY) != 0)) {
int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -287,8 +274,7 @@ public Point getSelection () {
}
public int getSelectionIndex () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (args [1] == 0) return -1;
@@ -296,8 +282,7 @@ public int getSelectionIndex () {
}
public String getText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (args [1] == 0) return "";
@@ -309,8 +294,7 @@ public String getText () {
}
public int getTextHeight () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
//NOT DONE - Only works for DROP_DOWN
PhDim_t dim = new PhDim_t();
if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
@@ -323,8 +307,7 @@ public int getTextHeight () {
}
public int getTextLimit () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return args [1];
@@ -342,15 +325,13 @@ void hookEvents () {
}
public int indexOf (String string) {
- if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
byte [] buffer = Converter.wcsToMbcs (null, string, true);
return OS.PtListItemPos(handle, buffer) - 1;
}
public int indexOf (String string, int start) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
// NOT DONE - start is ignored
@@ -385,8 +366,7 @@ void register () {
}
public void remove (int start, int end) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (!(0 < start && start <= end && end < args [1])) {
@@ -398,8 +378,7 @@ public void remove (int start, int end) {
}
public void remove (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
@@ -408,30 +387,26 @@ public void remove (int index) {
}
public void remove (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int index = indexOf (string, 0);
if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
remove (index);
}
public void removeAll () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
OS.PtListDeleteAllItems (handle);
}
public void removeModifyListener (ModifyListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Modify, listener);
}
public void removeSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
@@ -439,23 +414,20 @@ public void removeSelectionListener (SelectionListener listener) {
}
public void select (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (index < 0) return;
int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0};
OS.PtSetResources (handle, args.length / 3, args);
}
void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
super.setBounds (x, y, width, newHeight, move, resize);
}
public void setItem (int index, String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -470,8 +442,7 @@ public void setItem (int index, String string) {
}
public void setItems (String [] items) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.PtListDeleteAllItems (handle);
int[] itemsPtr = new int [items.length];
@@ -490,15 +461,13 @@ public void setItems (String [] items) {
}
public void setSelection (Point selection) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
byte [] buffer = Converter.wcsToMbcs (null, string, true);
if ((style & SWT.READ_ONLY) != 0) {
@@ -518,8 +487,7 @@ public void setText (String string) {
}
public void setTextLimit (int limit) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};
OS.PtSetResources (handle, args.length / 3, args);
@@ -547,4 +515,4 @@ boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
return translated;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
index 7d5f7b0fb1..661b3c8bfe 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -51,8 +51,7 @@ protected void checkSubclass () {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
Point size;
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -134,8 +133,7 @@ void createScrolledHandle (int parentHandle) {
}
public Rectangle getClientArea () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (scrolledHandle == 0) return super.getClientArea ();
PhArea_t area = new PhArea_t ();
OS.PtWidgetArea (handle, area);
@@ -215,8 +213,7 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
}
public Control [] getChildren () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return _getChildren ();
}
@@ -231,8 +228,7 @@ int getChildrenCount () {
}
public Layout getLayout () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return layout;
}
@@ -251,8 +247,7 @@ void hookEvents () {
}
public void layout () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
layout (true);
}
@@ -268,8 +263,7 @@ Point minimumSize () {
}
public void layout (boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (layout == null) return;
int count = getChildrenCount ();
if (count == 0) return;
@@ -455,8 +449,7 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean resiz
}
public void setLayout (Layout layout) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
this.layout = layout;
}
@@ -465,4 +458,4 @@ int traversalCode (int key_sym, PhKeyEvent_t ke) {
return super.traversalCode (key_sym, ke);
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
index 8648f57ee4..eb7502bbc4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -53,32 +53,27 @@ protected void checkSubclass () {
}
public Button getDefaultButton () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return defaultButton;
}
public Image getImage () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return image;
}
public boolean getMaximized () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return false;
}
public boolean getMinimized () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return false;
}
public Menu getMenuBar () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return menuBar;
}
@@ -87,8 +82,7 @@ String getNameText () {
}
public String getText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return text;
}
@@ -155,8 +149,7 @@ void resizeBounds (int width, int height) {
}
public void setDefaultButton (Button button) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
setDefaultButton (button, true);
}
void setDefaultButton (Button button, boolean save) {
@@ -178,32 +171,27 @@ void setDefaultButton (Button button, boolean save) {
}
public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
this.image = image;
}
public void setMaximized (boolean maximized) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
}
public void setMenuBar (Menu menu) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
//NOT DONE
}
public void setMinimized (boolean minimized) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
text = string;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
index d030f4382b..91ec43e80b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
@@ -122,4 +122,4 @@ public void setFilterPath (String string) {
filterPath = string;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
index 3737d6d850..860493f893 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
@@ -56,4 +56,4 @@ public FontData open () {
public void setFontData (FontData fontData) {
this.fontData = fontData;
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
index cd6c3535ff..13abc84079 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -28,8 +28,7 @@ static int checkStyle (int style) {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
Point titleSize = getTitleSize();
Point size;
if (layout != null) {
@@ -65,8 +64,7 @@ void createHandle (int index) {
}
public String getText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = {OS.Pt_ARG_TITLE, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (args [1] == 0) return "";
@@ -105,8 +103,7 @@ int processPaint (int damage) {
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA | OS.Pt_GRADIENT_TITLE_AREA;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
@@ -120,4 +117,4 @@ public void setText (String string) {
OS.free (ptr);
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
index c77ad8aa33..68e25b2b80 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
@@ -38,8 +38,7 @@ Header(Table parent) {
* Answer the size of the receiver needed to display all items.
*/
public Point computeSize(int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int width = 0;
int height = 0;
@@ -286,8 +285,7 @@ void redraw(int itemIndex) {
* Set a new font. Recalculate the header height and redraw the header.
*/
public void setFont(Font font) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (font == null || font.equals(getFont()) == true) {
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
index fafa16af7c..7c8fbb9e4b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -23,8 +23,7 @@ static int checkStyle (int style) {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SEPARATOR) != 0) {
int border = getBorderWidth ();
int width = border * 2, height = border * 2;
@@ -147,8 +146,7 @@ void createHandle (int index) {
}
public int getAlignment () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SEPARATOR) != 0) return 0;
if ((style & SWT.LEFT) != 0) return SWT.LEFT;
if ((style & SWT.CENTER) != 0) return SWT.CENTER;
@@ -157,8 +155,7 @@ public int getAlignment () {
}
public Image getImage () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return image;
}
@@ -167,8 +164,7 @@ String getNameText () {
}
public String getText () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SEPARATOR) != 0) return "";
return text;
}
@@ -205,8 +201,7 @@ void releaseWidget () {
}
public void setAlignment (int alignment) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SEPARATOR) != 0) return;
if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
@@ -232,8 +227,7 @@ public void setFont (Font font) {
}
public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SEPARATOR) != 0) return;
this.image = image;
int imageHandle = 0;
@@ -247,8 +241,7 @@ public void setImage (Image image) {
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
text = string;
@@ -309,4 +302,4 @@ public void setText (String string) {
OS.free (ptr2);
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index 042df8e3d3..bf249700f2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -22,8 +22,7 @@ static int checkStyle (int style) {
}
public void add (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
byte [] buffer = Converter.wcsToMbcs (null, string, true);
int ptr = OS.malloc (buffer.length);
@@ -33,8 +32,7 @@ public void add (String string) {
}
public void addSelectionListener(SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
@@ -42,8 +40,7 @@ public void addSelectionListener(SelectionListener listener) {
}
public void add (String string, int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == -1) error (SWT.ERROR_INVALID_RANGE);
byte [] buffer = Converter.wcsToMbcs (null, string, true);
@@ -60,8 +57,7 @@ public void add (String string, int index) {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
/**
* Feature in Photon - The preferred width calculated by
@@ -144,15 +140,13 @@ byte [] defaultFont () {
}
public void deselect (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (index < 0) return;
OS.PtListUnselectPos (handle, index + 1);
}
public void deselect (int start, int end) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (start > end) return;
if ((style & SWT.SINGLE) != 0) {
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
@@ -168,8 +162,7 @@ public void deselect (int start, int end) {
}
public void deselect (int [] indices) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
for (int i=0; i<indices.length; i++) {
@@ -181,8 +174,7 @@ public void deselect (int [] indices) {
}
public void deselectAll () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
int count = args [1];
@@ -196,8 +188,7 @@ public int getFocusIndex () {
}
public String getItem (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
OS.Pt_ARG_ITEMS, 0, 0,
@@ -216,16 +207,14 @@ public String getItem (int index) {
}
public int getItemCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return args [1];
}
public int getItemHeight () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
@@ -244,8 +233,7 @@ public int getItemHeight () {
}
public String [] getItems () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
OS.Pt_ARG_ITEMS, 0, 0,
@@ -266,8 +254,7 @@ public String [] getItems () {
}
public String [] getSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] indices = getSelectionIndices ();
String [] result = new String [indices.length];
for (int i=0; i<indices.length; i++) {
@@ -277,16 +264,14 @@ public String [] getSelection () {
}
public int getSelectionCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return args [1];
}
public int getSelectionIndex () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
@@ -299,8 +284,7 @@ public int getSelectionIndex () {
}
public int [] getSelectionIndices () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
@@ -316,8 +300,7 @@ public int [] getSelectionIndices () {
}
public int getTopIndex () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return args [1] - 1;
@@ -331,15 +314,13 @@ void hookEvents () {
}
public int indexOf (String string) {
- if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
byte [] buffer = Converter.wcsToMbcs (null, string, true);
return OS.PtListItemPos(handle, buffer) - 1;
}
public int indexOf (String string, int start) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
// NOT DONE - start is ignored
@@ -347,8 +328,7 @@ public int indexOf (String string, int start) {
}
public boolean isSelected (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
@@ -384,8 +364,7 @@ int processSelection (int info) {
}
public void remove (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
@@ -394,16 +373,14 @@ public void remove (int index) {
}
public void remove (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int index = indexOf (string, 0);
if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
remove (index);
}
public void remove (int [] indices) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
int [] newIndices = new int [indices.length];
System.arraycopy (indices, 0, newIndices, 0, indices.length);
@@ -420,8 +397,7 @@ public void remove (int [] indices) {
}
public void remove (int start, int end) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
if (!(0 < start && start <= end && end < args [1])) {
@@ -433,14 +409,12 @@ public void remove (int start, int end) {
}
public void removeAll () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
OS.PtListDeleteAllItems (handle);
}
public void removeSelectionListener(SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
@@ -448,8 +422,7 @@ public void removeSelectionListener(SelectionListener listener) {
}
public void select (int start, int end) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (start > end) return;
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -470,8 +443,7 @@ public void select (int start, int end) {
}
public void select (int [] indices) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
@@ -489,8 +461,7 @@ public void select (int [] indices) {
}
public void select (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (index < 0) return;
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -501,8 +472,7 @@ public void select (int index) {
}
public void selectAll () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.SINGLE) != 0) return;
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -513,8 +483,7 @@ public void selectAll () {
}
public void setItem (int index, String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
@@ -529,8 +498,7 @@ public void setItem (int index, String string) {
}
public void setItems (String [] items) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.PtListDeleteAllItems (handle);
int[] itemsPtr = new int [items.length];
@@ -562,8 +530,7 @@ public void setSelection(int[] indices) {
}
public void setSelection (String [] items) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.MULTI) != 0) deselectAll ();
for (int i=items.length-1; i>=0; --i) {
@@ -581,15 +548,13 @@ public void setSelection (String [] items) {
}
public void setTopIndex (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0};
OS.PtSetResources (handle, args.length / 3, args);
}
public void showSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = new int [] {
OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
index d3104c21b9..5f8bdebd15 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -54,16 +54,14 @@ static int checkStyle (int style) {
}
public void addHelpListener (HelpListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Help, typedListener);
}
public void addMenuListener (MenuListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Hide,typedListener);
@@ -91,8 +89,7 @@ void createWidget (int index) {
}
public MenuItem getDefaultItem () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return defaultItem;
}
@@ -103,16 +100,14 @@ public Display getDisplay () {
}
public boolean getEnabled () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
return (args [1] & OS.Pt_BLOCKED) == 0;
}
public int getItemCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int count = 0;
int child = OS.PtWidgetChildBack (handle);
if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
@@ -124,8 +119,7 @@ public int getItemCount () {
}
public MenuItem getItem (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (index < 0) error (SWT.ERROR_INVALID_RANGE);
int i = 0;
int child = OS.PtWidgetChildBack (handle);
@@ -142,8 +136,7 @@ public MenuItem getItem (int index) {
}
public MenuItem [] getItems () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int count = 0;
int child = OS.PtWidgetChildBack (handle);
if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
@@ -187,27 +180,23 @@ public Decorations getParent () {
}
public MenuItem getParentItem () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return cascade;
}
public Menu getParentMenu () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (cascade != null) return cascade.parent;
return null;
}
public Shell getShell () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent.getShell ();
}
public boolean getVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return true;
}
@@ -217,8 +206,7 @@ void hookEvents () {
}
public int indexOf (MenuItem item) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
int i = 0;
int child = OS.PtWidgetChildBack (handle);
@@ -233,16 +221,14 @@ public int indexOf (MenuItem item) {
}
public boolean isEnabled () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
Menu parentMenu = getParentMenu ();
if (parentMenu == null) return getEnabled ();
return getEnabled () && parentMenu.isEnabled ();
}
public boolean isVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return getVisible ();
}
@@ -281,16 +267,14 @@ void releaseWidget () {
}
public void removeHelpListener (HelpListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Help, listener);
}
public void removeMenuListener (MenuListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Hide, listener);
@@ -298,14 +282,12 @@ public void removeMenuListener (MenuListener listener) {
}
public void setDefaultItem (MenuItem item) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
defaultItem = item;
}
public void setEnabled (boolean enabled) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int [] args = {
OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
@@ -314,15 +296,13 @@ public void setEnabled (boolean enabled) {
}
public void setLocation (int x, int y) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
this.x = x; this.y = y;
hasLocation = true;
}
public void setVisible (boolean visible) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & SWT.POP_UP) == 0) return;
if (visible == OS.PtWidgetIsRealized (handle)) return;
if (visible) {
@@ -348,4 +328,4 @@ public void setVisible (boolean visible) {
}
}
-}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index fd88c600a2..2307e8c5e1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -1010,6 +1010,7 @@ public Thread getThread () {
* @private
*/
public int internal_new_GC (GCData data) {
+ if (isDisposed()) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
int hDC = OS.GetDC (0);
if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
if (data != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index 290f65253b..f54e74dbdb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -143,8 +143,7 @@ ScrollBar (Scrollable parent, int style) {
* @see SelectionEvent
*/
public void addSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener (SWT.Selection,typedListener);
@@ -204,8 +203,7 @@ public Display getDisplay () {
* </ul>
*/
public boolean getEnabled () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return (state & DISABLED) == 0;
}
@@ -222,8 +220,7 @@ public boolean getEnabled () {
* </ul>
*/
public int getIncrement () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return increment;
}
@@ -238,8 +235,7 @@ public int getIncrement () {
* </ul>
*/
public int getMaximum () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_RANGE;
@@ -260,8 +256,7 @@ public int getMaximum () {
* </ul>
*/
public int getMinimum () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_RANGE;
@@ -284,8 +279,7 @@ public int getMinimum () {
* </ul>
*/
public int getPageIncrement () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return pageIncrement;
}
@@ -300,8 +294,7 @@ public int getPageIncrement () {
* </ul>
*/
public Scrollable getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent;
}
@@ -316,8 +309,7 @@ public Scrollable getParent () {
* </ul>
*/
public int getSelection () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_POS;
@@ -340,8 +332,7 @@ public int getSelection () {
* </ul>
*/
public Point getSize () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
RECT rect = new RECT ();
OS.GetClientRect (parent.handle, rect);
int width, height;
@@ -369,8 +360,7 @@ public Point getSize () {
* @see ScrollBar
*/
public int getThumb () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_PAGE;
@@ -399,8 +389,7 @@ public int getThumb () {
* </ul>
*/
public boolean getVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return (state & HIDDEN) == 0;
}
@@ -427,8 +416,7 @@ int hwndScrollBar () {
* </ul>
*/
public boolean isEnabled () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return getEnabled () && parent.isEnabled ();
}
@@ -450,8 +438,7 @@ public boolean isEnabled () {
* </ul>
*/
public boolean isVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return getVisible () && parent.isVisible ();
}
@@ -484,8 +471,7 @@ void releaseWidget () {
* @see #addSelectionListener
*/
public void removeSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
@@ -518,8 +504,7 @@ int scrollBarType () {
* </ul>
*/
public void setEnabled (boolean enabled) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int hwnd = hwndScrollBar (), type = scrollBarType ();
int flags = OS.ESB_DISABLE_BOTH;
if (enabled) flags = OS.ESB_ENABLE_BOTH;
@@ -542,8 +527,7 @@ public void setEnabled (boolean enabled) {
* </ul>
*/
public void setIncrement (int value) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (value < 1) return;
increment = value;
}
@@ -561,8 +545,7 @@ public void setIncrement (int value) {
* </ul>
*/
public void setMaximum (int value) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (value < 0) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
@@ -612,8 +595,7 @@ public void setMaximum (int value) {
* </ul>
*/
public void setMinimum (int value) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (value < 0) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
@@ -664,8 +646,7 @@ public void setMinimum (int value) {
* </ul>
*/
public void setPageIncrement (int value) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (value < 1) return;
pageIncrement = value;
}
@@ -683,8 +664,7 @@ public void setPageIncrement (int value) {
* </ul>
*/
public void setSelection (int selection) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (selection < 0) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
@@ -709,8 +689,7 @@ public void setSelection (int selection) {
* @see ScrollBar
*/
public void setThumb (int value) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
/* Position the thumb */
if (value < 1) return;
@@ -772,8 +751,7 @@ public void setThumb (int value) {
* </ul>
*/
public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (selection < 0) return;
if (minimum < 0) return;
if (maximum < 0) return;
@@ -837,8 +815,7 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
* </ul>
*/
public void setVisible (boolean visible) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int hwnd = hwndScrollBar (), type = scrollBarType ();
if (OS.ShowScrollBar (hwnd, type, visible)) {
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index a6874b5463..70a8451254 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -240,6 +240,7 @@ static int checkBits (int style, int int0, int int1, int int2, int int3, int int
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
@@ -248,6 +249,7 @@ static int checkBits (int style, int int0, int int1, int int2, int int3, int int
void checkParent (Widget parent) {
if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
}
/**
@@ -307,7 +309,7 @@ protected void checkSubclass () {
*/
protected void checkWidget () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
/**
@@ -359,7 +361,7 @@ public void dispose () {
* Note: It is valid to attempt to dispose a widget
* more than once. If this happens, fail silently.
*/
- if (!isValidWidget ()) return;
+ if (!isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
releaseChild ();
releaseWidget ();
@@ -581,21 +583,6 @@ boolean isValidThread () {
return getDisplay ().isValidThread ();
}
-/**
- * Returns <code>true</code> if the widget is not disposed,
- * and <code>false</code> otherwise.
- * <p>
- * Note: This method is no longer required and will be deprecated.
- * </p>
- *
- * @return <code>true</code> when the widget is not disposed and <code>false</code> otherwise
- *
- * @see #isDisposed
- */
-boolean isValidWidget () {
- return (state & DISPOSED) == 0;
-}
-
/*
* Returns a single character, converted from the multi-byte
* character set (MBCS) used by the operating system widgets