Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2005-02-03 22:14:55 +0000
committerCarolyn MacLeod2005-02-03 22:14:55 +0000
commitc4b7ee214c46c877489319bff8d41fcf7dbb272e (patch)
tree104dfe8b3f3a82c76fcdfb125387272a50dd46c4 /examples
parent93a747937409a27c517ca4a327031f8d31c2bfcd (diff)
downloadeclipse.platform.swt-c4b7ee214c46c877489319bff8d41fcf7dbb272e.tar.gz
eclipse.platform.swt-c4b7ee214c46c877489319bff8d41fcf7dbb272e.tar.xz
eclipse.platform.swt-c4b7ee214c46c877489319bff8d41fcf7dbb272e.zip
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control.properties18
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CComboTab.java8
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CLabelTab.java8
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java1
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java1
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java65
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java27
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java14
8 files changed, 87 insertions, 55 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties
index b4a63927a9..1921c27744 100644
--- a/examples/org.eclipse.swt.examples/src/examples_control.properties
+++ b/examples/org.eclipse.swt.examples/src/examples_control.properties
@@ -38,8 +38,22 @@ Select_Listeners = Select Listeners
Listen = Listen
Clear = Clear
Set_Get = Set/Get API
-Eg = e.g.
-Hello = hello
+Parameter_Info = {0} e.g. {1}
+Info_int = 4
+Info_intA = 1,2,3
+Info_long = 4
+Info_longA = 1,2,3
+Info_char = c
+Info_charA = c,d,e
+Info_boolean = true
+Info_booleanA = true,true
+Info_String = hello
+Info_StringA = hello,there
+Info_Point = 0,0
+Info_TableItem = Index:2
+Info_TableItemA = Index:2,Index:4
+Info_TreeItem = Node 1
+Info_TreeItemA = Node 1,Node 3
Select_All = Select All
Deselect_All = Deselect All
OK = OK
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CComboTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CComboTab.java
index ab35141bec..b8e3a02426 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CComboTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CComboTab.java
@@ -97,6 +97,14 @@ class CComboTab extends Tab {
}
/**
+ * Returns a list of set/get API method names (without the set/get prefix)
+ * that can be used to set/get values in the example control(s).
+ */
+ String[] getMethodNames() {
+ return new String[] {"Editable", "Items", "Selection", "Text", "TextLimit", "VisibleItemCount"};
+ }
+
+ /**
* Gets the text for the tab folder item.
*/
String getTabText () {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CLabelTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CLabelTab.java
index 2c0bb1cd51..f3007e0672 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CLabelTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CLabelTab.java
@@ -107,6 +107,14 @@ class CLabelTab extends AlignableTab {
}
/**
+ * Returns a list of set/get API method names (without the set/get prefix)
+ * that can be used to set/get values in the example control(s).
+ */
+ String[] getMethodNames() {
+ return new String[] {"Text"};
+ }
+
+ /**
* Gets the text for the tab folder item.
*/
String getTabText () {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java
index 464c6a0af0..18c6e06af0 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java
@@ -382,6 +382,7 @@ class DialogTab extends Tab {
*/
void createExampleGroup () {
super.createExampleGroup ();
+ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true));
/*
* Create a group for the text widget to display
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
index df104681f2..683d5229a1 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java
@@ -62,6 +62,7 @@ class SashTab extends Tab {
*/
void createExampleGroup () {
super.createExampleGroup ();
+ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true));
exampleGroup.setLayout(new FillLayout());
/* Create a group for the sash widgets */
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
index 1d89c3d54c..1eebde33de 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
@@ -582,7 +582,7 @@ abstract class Tab {
void resetLabels() {
String methodRoot = nameCombo.getText();
- returnTypeLabel.setText(instructions(methodRoot));
+ returnTypeLabel.setText(parameterInfo(methodRoot));
setButton.setText(setMethodName(methodRoot));
getButton.setText("get" + methodRoot);
setText.setText("");
@@ -595,40 +595,23 @@ abstract class Tab {
return "set" + methodRoot;
}
- String instructions(String methodRoot) {
- String instructions = null;
+ String parameterInfo(String methodRoot) {
String typeName = null;
Class returnType = getReturnType(methodRoot);
- if (returnType.isArray()) {
+ boolean isArray = returnType.isArray();
+ if (isArray) {
typeName = returnType.getComponentType().getName();
- instructions = typeName + "[]";
} else {
typeName = returnType.getName();
- instructions = typeName;
}
- instructions += " " + ControlExample.getResourceString("Eg");
- if (typeName.equals("int") || typeName.equals("long")) {
- instructions += "4";
- if (returnType.isArray()) instructions += ",5,6";
- } else if (typeName.equals("char")) {
- instructions += "c";
- if (returnType.isArray()) instructions += ",d,e";
- } else if (typeName.equals("boolean")) {
- instructions += "true";
- if (returnType.isArray()) instructions += ",true";
- } else if (typeName.equals("java.lang.String")) {
- instructions += ControlExample.getResourceString("Hello");
- if (returnType.isArray()) instructions += "," + ControlExample.getResourceString("Hello");
- } else if (typeName.equals("org.eclipse.swt.graphics.Point")) {
- instructions += "0,0";
- } else {
- instructions += instructionsForType(returnType.getName());
+ String typeNameString = typeName;
+ int index = typeName.lastIndexOf('.');
+ if (index != -1 && index+1 < typeName.length()) typeNameString = typeName.substring(index+1);
+ String info = ControlExample.getResourceString("Info_" + typeNameString + (isArray ? "A" : ""));
+ if (isArray) {
+ typeNameString += "[]";
}
- return instructions;
- }
-
- String instructionsForType(String typeName) {
- return "x";
+ return ControlExample.getResourceString("Parameter_Info", new Object[] {typeNameString, info});
}
void getValue() {
@@ -639,7 +622,9 @@ abstract class Tab {
try {
java.lang.reflect.Method method = controls[i].getClass().getMethod(methodName, null);
Object result = method.invoke(controls[i], null);
- if (result.getClass().isArray()) {
+ if (result == null) {
+ getText.append("null");
+ } else if (result.getClass().isArray()) {
Object [] arrayResult = (Object[]) result;
for (int j = 0; j < arrayResult.length; j++) {
getText.append(arrayResult[j].toString() + "\n");
@@ -679,33 +664,33 @@ abstract class Tab {
try {
java.lang.reflect.Method method = controls[i].getClass().getMethod(methodName, new Class[] {returnType});
String typeName = returnType.getName();
- Object[] parameters = null;
+ Object[] parameter = null;
if (typeName.equals("int")) {
- parameters = new Object[] {new Integer(value)};
+ parameter = new Object[] {new Integer(value)};
} else if (typeName.equals("long")) {
- parameters = new Object[] {new Long(value)};
+ parameter = new Object[] {new Long(value)};
} else if (typeName.equals("char")) {
- parameters = new Object[] {value.length() == 1 ? new Character(value.charAt(0)) : new Character('\0')};
+ parameter = new Object[] {value.length() == 1 ? new Character(value.charAt(0)) : new Character('\0')};
} else if (typeName.equals("boolean")) {
- parameters = new Object[] {new Boolean(value)};
+ parameter = new Object[] {new Boolean(value)};
} else if (typeName.equals("java.lang.String")) {
- parameters = new Object[] {value};
+ parameter = new Object[] {value};
} else if (typeName.equals("org.eclipse.swt.graphics.Point")) {
String xy[] = value.split(",");
- parameters = new Object[] {new Point(new Integer(xy[0]).intValue(),new Integer(xy[1]).intValue())};
+ parameter = new Object[] {new Point(new Integer(xy[0]).intValue(),new Integer(xy[1]).intValue())};
} else if (typeName.equals("[Ljava.lang.String;")) {
- parameters = new Object[] {value.split(",")};
+ parameter = new Object[] {value.split(",")};
} else {
- parameters = parametersForType(typeName, value, controls[i]);
+ parameter = parameterForType(typeName, value, controls[i]);
}
- method.invoke(controls[i], parameters);
+ method.invoke(controls[i], parameter);
} catch (Exception e) {
getText.setText(e.toString());
}
}
}
- Object[] parametersForType(String typeName, String value, Control control) {
+ Object[] parameterForType(String typeName, String value, Control control) {
return new Object[] {value};
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
index c9ee49c47e..f987d483cb 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -279,7 +279,7 @@ class TableTab extends ScrollableTab {
* that can be used to set/get values in the example control(s).
*/
String[] getMethodNames() {
- return new String[] {"ItemCount", "SelectionIndex", "TopIndex"};
+ return new String[] {"ItemCount", "Selection", "SelectionIndex", "TopIndex"};
}
String setMethodName(String methodRoot) {
@@ -287,6 +287,31 @@ class TableTab extends ScrollableTab {
return (methodRoot.equals("SelectionIndex")) ? "setSelection" : "set" + methodRoot;
}
+ Object[] parameterForType(String typeName, String value, Control control) {
+ if (value.equals("")) return new Object[] {new TableItem[0]}; // bug in Table?
+ if (typeName.equals("org.eclipse.swt.widgets.TableItem")) {
+ TableItem item = findItem(value, ((Table) control).getItems());
+ if (item != null) return new Object[] {item};
+ }
+ if (typeName.equals("[Lorg.eclipse.swt.widgets.TableItem;")) {
+ String[] values = value.split(",");
+ TableItem[] items = new TableItem[values.length];
+ for (int i = 0; i < values.length; i++) {
+ items[i] = findItem(values[i], ((Table) control).getItems());
+ }
+ return new Object[] {items};
+ }
+ return super.parameterForType(typeName, value, control);
+ }
+
+ TableItem findItem(String value, TableItem[] items) {
+ for (int i = 0; i < items.length; i++) {
+ TableItem item = items[i];
+ if (item.getText().equals(value)) return item;
+ }
+ return null;
+ }
+
/**
* Gets the text for the tab folder item.
*/
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
index 4d1519fb70..20e6bf38fa 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
@@ -321,7 +321,7 @@ class TreeTab extends ScrollableTab {
return new String[] {"Selection", "TopItem"};
}
- Object[] parametersForType(String typeName, String value, Control control) {
+ Object[] parameterForType(String typeName, String value, Control control) {
if (typeName.equals("org.eclipse.swt.widgets.TreeItem")) {
TreeItem item = findItem(value, ((Tree) control).getItems());
if (item != null) return new Object[] {item};
@@ -336,7 +336,7 @@ class TreeTab extends ScrollableTab {
}
return new Object[] {items};
}
- return super.parametersForType(typeName, value, control);
+ return super.parameterForType(typeName, value, control);
}
TreeItem findItem(String value, TreeItem[] items) {
@@ -349,16 +349,6 @@ class TreeTab extends ScrollableTab {
return null;
}
- String instructionsForType(String typeName) {
- if (typeName.equals("org.eclipse.swt.widgets.TreeItem")) {
- return "Node 1";
- }
- if (typeName.equals("[Lorg.eclipse.swt.widgets.TreeItem;")) {
- return "Node 1,Node 3";
- }
- return super.instructionsForType(typeName);
- }
-
/**
* Gets the text for the tab folder item.
*/

Back to the top