Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-03-25 05:28:54 -0400
committerPierre-Charles David2016-03-25 05:28:54 -0400
commit694709e380833fc7d2013de3299aa416230d8b8b (patch)
tree6e0e4f4b8e4fe4e843c7763cc1ad4134ca749f24 /samples
parent5ff35902e0f45da1aa73abb0424f1108b51adc7f (diff)
downloadorg.eclipse.eef-694709e380833fc7d2013de3299aa416230d8b8b.tar.gz
org.eclipse.eef-694709e380833fc7d2013de3299aa416230d8b8b.tar.xz
org.eclipse.eef-694709e380833fc7d2013de3299aa416230d8b8b.zip
Improve color picker sample widget
Change-Id: I2ac8cd3c11346899a1f136c48a5ba5e74e1e3435 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Diffstat (limited to 'samples')
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/build.properties3
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/plugin.properties2
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPicker.java3
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java26
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java12
5 files changed, 39 insertions, 7 deletions
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/build.properties b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/build.properties
index 962cf74fb..bb85c49f5 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/build.properties
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/build.properties
@@ -11,6 +11,7 @@ bin.includes = META-INF/,\
.,\
about.html,\
plugin.properties,\
- plugin.xml
+ plugin.xml,\
+ icons/
javacProjectSettings = true
additional.bundles = org.eclipse.emf.transaction
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/plugin.properties b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/plugin.properties
index b112c730f..d602c4f31 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/plugin.properties
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/plugin.properties
@@ -5,5 +5,5 @@
# http://www.eclipse.org/legal/epl-v10.htm
# Contributors: Obeo - initial API and implementation
-pluginName=EEF Multi/Mono references widgets
+pluginName=EEF Color Picker Custom Widget
providerName=Eclipse Modeling Project \ No newline at end of file
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPicker.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPicker.java
index ce84e0f32..7cca44193 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPicker.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPicker.java
@@ -83,6 +83,9 @@ public class ColorPicker extends CLabel {
*/
private void update(RGB selected) {
this.selectedColor = ColorHelper.getColor(selected);
+ if (image != null) {
+ image.dispose();
+ }
setImage(getColorImage(selectedColor));
}
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
index 19c5aa7b3..8d3b8a7d6 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
package org.eclipse.eef.sample.custom.widget.colorpicker;
import java.util.HashMap;
@@ -89,11 +99,17 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
int blue = DEFAULT_COLOR_CODE;
if (value != null) {
String[] rgb = value.split(SEPARATOR);
- red = Integer.parseInt(rgb[0]);
- green = Integer.parseInt(rgb[1]);
- blue = Integer.parseInt(rgb[2]);
- Color color = ColorHelper.getColor(red, green, blue);
- ColorPickerController.this.newValueConsumer.apply(color);
+ if (rgb.length == 3) {
+ try {
+ red = Integer.parseInt(rgb[0]);
+ green = Integer.parseInt(rgb[1]);
+ blue = Integer.parseInt(rgb[2]);
+ Color color = ColorHelper.getColor(red, green, blue);
+ ColorPickerController.this.newValueConsumer.apply(color);
+ } catch (NumberFormatException e) {
+ // TODO Log warning about unexpected result format from the expression.
+ }
+ }
}
}
});
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
index 1437d4892..21d386ffb 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
package org.eclipse.eef.sample.custom.widget.colorpicker;
import org.eclipse.eef.EEFCustomWidgetDescription;
@@ -164,6 +174,8 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag
*/
@Override
public void aboutToBeHidden() {
+ this.colorPicker.removeMouseListener(mouseListener);
+ this.controller.removeNewValueConsumer();
super.aboutToBeHidden();
}
}

Back to the top