Fix IllegalArgumentException in Colors view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / colors / ColorsView.java
index eabe4ffaa5848e20ba38d4dba96ae52ab589780c..436af2d0f4748491189b0d6053baababc4edb365 100644 (file)
@@ -41,6 +41,7 @@ import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -443,9 +444,12 @@ public class ColorsView extends TmfView {
                     dialog.setRGB(colorSetting.getForegroundRGB());
                     dialog.setText(Messages.ColorsView_ForegroundDialogText);
                     dialog.open();
-                    colorSetting.setForegroundRGB(dialog.getRGB());
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
-                    label.setForeground(colorSetting.getForegroundColor());
+                    RGB rgb = dialog.getRGB();
+                    if (rgb != null) {
+                        colorSetting.setForegroundRGB(rgb);
+                        ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                        label.setForeground(colorSetting.getForegroundColor());
+                    }
                 }});
 
             bgButton.addSelectionListener(new SelectionAdapter() {
@@ -457,10 +461,13 @@ public class ColorsView extends TmfView {
                     dialog.setRGB(colorSetting.getBackgroundRGB());
                     dialog.setText(Messages.ColorsView_BackgroundDialogText);
                     dialog.open();
-                    colorSetting.setBackgroundRGB(dialog.getRGB());
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
-                    labelComposite.setBackground(colorSetting.getBackgroundColor());
-                    label.setBackground(colorSetting.getBackgroundColor());
+                    RGB rgb = dialog.getRGB();
+                    if (rgb != null) {
+                        colorSetting.setBackgroundRGB(rgb);
+                        ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                        labelComposite.setBackground(colorSetting.getBackgroundColor());
+                        label.setBackground(colorSetting.getBackgroundColor());
+                    }
                 }});
 
             final Button tickButton = new Button(this, SWT.PUSH);
@@ -499,9 +506,12 @@ public class ColorsView extends TmfView {
                     dialog.setRGB(colorSetting.getTickColorRGB());
                     dialog.setText(Messages.TickColorDialog_TickColorDialogTitle);
                     dialog.open();
-                    colorSetting.setTickColorRGB(dialog.getRGB());
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
-                    refresh();
+                    RGB rgb = dialog.getRGB();
+                    if (rgb != null) {
+                        colorSetting.setTickColorRGB(rgb);
+                        ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                        refresh();
+                    }
                 }});
 
             final Button filterButton = new Button(this, SWT.PUSH);
This page took 0.026289 seconds and 5 git commands to generate.