private void createColorControl(Composite parent) { createLabel( parent, Messages.FillColorSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER); fColorChooser = new ColorChooser(parent); getWidgetFactory().adapt(fColorChooser.getControl(), true, true); fColorChooser.addListener(colorListener); }
@Override public void dispose() { super.dispose(); if (fColorChooser != null) { fColorChooser.removeListener(colorListener); } Preferences.STORE.removePropertyChangeListener(prefsListener); }
protected void refreshControls() { String colorValue = fDiagramModelObject.getFillColor(); RGB rgb = ColorFactory.convertStringToRGB(colorValue); if (rgb == null) { rgb = ColorFactory.getDefaultFillColor(fDiagramModelObject).getRGB(); } fColorChooser.setColorValue(rgb); boolean enabled = fDiagramModelObject instanceof ILockable ? !((ILockable) fDiagramModelObject).isLocked() : true; fColorChooser.setEnabled(enabled); // If user pref is to save the color then it's a different meaning of default boolean isDefaultColor = (colorValue == null); if (Preferences.STORE.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) { isDefaultColor = (colorValue != null) && rgb.equals(ColorFactory.getDefaultFillColor(fDiagramModelObject).getRGB()); } fColorChooser.setIsDefaultColor(isDefaultColor); }