Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2012-03-08 10:53:58 -0500
committerCarolyn MacLeod2012-03-08 10:53:58 -0500
commitfb6985a6c3c2a2721b38a8390ce747b43f09fc90 (patch)
tree939d45cf6cffea10ff01e503bd7db321b37cc8af
parent4531a4cbb8748e1e247b44157a3c7d317922559f (diff)
downloadeclipse.platform.swt-car_branch.tar.gz
eclipse.platform.swt-car_branch.tar.xz
eclipse.platform.swt-car_branch.zip
Bug 212023 - limitation of SWT ColorDialogcar_branch
Use splitString for CLDC compatibility instead of String.split().
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
index 4d18517410..e602bc95af 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
@@ -218,8 +218,12 @@ public RGB open () {
buffer = new byte [length];
OS.memmove (buffer, ptr [0], length);
OS.g_free (ptr [0]);
- String [] gdkColorStrings = new String(Converter.mbcsToWcs (null, buffer)).split(":");
- length = length == 0 ? 0 : gdkColorStrings.length;
+ String [] gdkColorStrings = null;
+ if (length > 0) {
+ String gtk_color_palette = new String(Converter.mbcsToWcs (null, buffer));
+ gdkColorStrings = splitString(gtk_color_palette, ':');
+ length = gdkColorStrings.length;
+ }
rgbs = new RGB [length];
for (int i=0; i<length; i++) {
String colorString = gdkColorStrings[i];
@@ -260,4 +264,21 @@ public void setRGB (RGB rgb) {
public void setRGBs(RGB[] rgbs) {
this.rgbs = rgbs;
}
+static String[] splitString(String text, char ch) {
+ String[] substrings = new String[1];
+ int start = 0, pos = 0;
+ while (pos != -1) {
+ pos = text.indexOf(ch, start);
+ if (pos == -1) {
+ substrings[substrings.length - 1] = text.substring(start);
+ } else {
+ substrings[substrings.length - 1] = text.substring(start, pos);
+ start = pos + 1;
+ String[] newSubstrings = new String[substrings.length+1];
+ System.arraycopy(substrings, 0, newSubstrings, 0, substrings.length);
+ substrings = newSubstrings;
+ }
+ }
+ return substrings;
+}
}

Back to the top