diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FillColorComposite.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FillColorComposite.java index c816e014b..2c1737ab1 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FillColorComposite.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FillColorComposite.java @@ -19,6 +19,7 @@ import com.archimatetool.editor.preferences.IPreferenceConstants; import com.archimatetool.editor.ui.ColorFactory; import com.archimatetool.editor.ui.components.ColorChooser; +import com.archimatetool.model.IArchimateModelObject; import com.archimatetool.model.IArchimatePackage; import com.archimatetool.model.IDiagramModelObject; @@ -112,23 +113,33 @@ private void createColorControl(Composite parent) { } void updateControl() { - IDiagramModelObject lastSelected = (IDiagramModelObject)section.getFirstSelectedObject(); + IDiagramModelObject firstSelected = (IDiagramModelObject)section.getFirstSelectedObject(); - String colorValue = lastSelected.getFillColor(); - RGB rgb = ColorFactory.convertStringToRGB(colorValue); + RGB rgb = ColorFactory.convertStringToRGB(firstSelected.getFillColor()); if(rgb == null) { - rgb = ColorFactory.getDefaultFillColor(lastSelected).getRGB(); + rgb = ColorFactory.getDefaultFillColor(firstSelected).getRGB(); } fColorChooser.setColorValue(rgb); + fColorChooser.setEnabled(!section.isLocked(firstSelected)); - fColorChooser.setEnabled(!section.isLocked(lastSelected)); - + // Set default enabled based on all selected objects. + // Note that the default button might not show the correct enabled state depending on what's selected at the time of the action. + boolean isDefaultColor = true; // If user pref is to save the color then it's a different meaning of default - boolean isDefaultColor = (colorValue == null); - if(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) { - isDefaultColor = (colorValue != null) && rgb.equals(ColorFactory.getDefaultFillColor(lastSelected).getRGB()); + boolean saveUserDefaultColor = ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR); + + for(IArchimateModelObject object : section.getEObjects()) { + if(object instanceof IDiagramModelObject dmo) { + if(saveUserDefaultColor) { + isDefaultColor &= (dmo.getFillColor() != null && rgb.equals(ColorFactory.getDefaultFillColor(dmo).getRGB())); + } + else { + isDefaultColor &= dmo.getFillColor() == null; + } + } } + fColorChooser.setIsDefaultColor(isDefaultColor); } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java index c0dd26401..3e66d682c 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java @@ -27,6 +27,7 @@ import com.archimatetool.editor.ui.ColorFactory; import com.archimatetool.editor.ui.components.ColorChooser; import com.archimatetool.editor.ui.components.FontChooser; +import com.archimatetool.model.IArchimateModelObject; import com.archimatetool.model.IArchimatePackage; import com.archimatetool.model.IDiagramModelComponent; import com.archimatetool.model.IFontAttribute; @@ -203,19 +204,23 @@ private void updateFontControl() { } private void updateColorControl() { - String colorValue = ((IFontAttribute)getFirstSelectedObject()).getFontColor(); - RGB rgb = ColorFactory.convertStringToRGB(colorValue); + IFontAttribute firstSelected = (IFontAttribute)getFirstSelectedObject(); - if(rgb != null) { - fColorChooser.setColorValue(rgb); - } - else { - // Null is the default system color - fColorChooser.setColorValue(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB()); + RGB rgb = ColorFactory.convertStringToRGB(firstSelected.getFontColor()); + fColorChooser.setColorValue(rgb != null ? rgb : Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB()); // Null is the default system color + + fColorChooser.setEnabled(!isLocked(firstSelected)); + + // Set default enabled based on all selected objects. + // Note that the default button might not show the correct enabled state depending on what's selected at the time of the action. + boolean isDefaultColor = true; + for(IArchimateModelObject object : getEObjects()) { + if(object instanceof IFontAttribute fontObject) { + isDefaultColor &= fontObject.getFontColor() == null; + } } - fColorChooser.setEnabled(!isLocked(getFirstSelectedObject())); - fColorChooser.setIsDefaultColor(colorValue == null); + fColorChooser.setIsDefaultColor(isDefaultColor); } @Override diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/IconColorSection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/IconColorSection.java index f30d6b2fe..50344bb73 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/IconColorSection.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/IconColorSection.java @@ -18,6 +18,7 @@ import com.archimatetool.editor.model.commands.FeatureCommand; import com.archimatetool.editor.ui.ColorFactory; import com.archimatetool.editor.ui.components.ColorChooser; +import com.archimatetool.model.IArchimateModelObject; import com.archimatetool.model.IArchimatePackage; import com.archimatetool.model.IDiagramModelArchimateObject; import com.archimatetool.model.IDiagramModelObject; @@ -104,17 +105,23 @@ protected void notifyChanged(Notification msg) { @Override protected void update() { - IDiagramModelObject lastSelected = (IDiagramModelObject)getFirstSelectedObject(); + IDiagramModelObject firstSelected = (IDiagramModelObject)getFirstSelectedObject(); - String colorValue = lastSelected.getIconColor(); - RGB rgb = ColorFactory.convertStringToRGB(colorValue); - if(rgb == null) { - rgb = new RGB(0, 0, 0); + RGB rgb = ColorFactory.convertStringToRGB(firstSelected.getIconColor()); + fColorChooser.setColorValue(rgb != null ? rgb : new RGB(0, 0, 0)); // Null is black + + fColorChooser.setEnabled(!isLocked(firstSelected)); + + // Set default enabled based on all selected objects. + // Note that the default button might not show the correct enabled state depending on what's selected at the time of the action. + boolean isDefaultColor = true; + for(IArchimateModelObject object : getEObjects()) { + if(object instanceof IDiagramModelObject dmo) { + isDefaultColor &= IDiagramModelObject.FEATURE_ICON_COLOR_DEFAULT.equals(dmo.getIconColor()); + } } - fColorChooser.setColorValue(rgb); - fColorChooser.setIsDefaultColor(IDiagramModelObject.FEATURE_ICON_COLOR_DEFAULT.equals(colorValue)); - fColorChooser.setEnabled(!isLocked(lastSelected)); + fColorChooser.setIsDefaultColor(isDefaultColor); } @Override diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorComposite.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorComposite.java index 9d8f10099..b0e3ce4a7 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorComposite.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorComposite.java @@ -22,6 +22,7 @@ import com.archimatetool.editor.preferences.IPreferenceConstants; import com.archimatetool.editor.ui.ColorFactory; import com.archimatetool.editor.ui.components.ColorChooser; +import com.archimatetool.model.IArchimateModelObject; import com.archimatetool.model.IArchimatePackage; import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.IFeatures; @@ -132,35 +133,39 @@ public void run() { } void updateControl() { - ILineObject lineObject = (ILineObject)section.getFirstSelectedObject(); + ILineObject firstSelected = (ILineObject)section.getFirstSelectedObject(); - String colorValue = lineObject.getLineColor(); - RGB rgb = ColorFactory.convertStringToRGB(colorValue); + RGB rgb = ColorFactory.convertStringToRGB(firstSelected.getLineColor()); if(rgb == null) { - rgb = ColorFactory.getDefaultLineColor(lineObject).getRGB(); + rgb = ColorFactory.getDefaultLineColor(firstSelected).getRGB(); } fColorChooser.setColorValue(rgb); - - // Locked - boolean enabled = !section.isLocked(lineObject); + fColorChooser.setEnabled(!section.isLocked(firstSelected)); - fColorChooser.setEnabled(enabled); + // Set default enabled based on all selected objects. + // Note that the default button might not show the correct enabled state depending on what's selected at the time of the action. + boolean isDefaultColor = true; + // If user pref is to save the color then it's a different meaning of default + boolean saveUserDefaultColor = ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR); - if(!enabled) { - return; + for(IArchimateModelObject object : section.getEObjects()) { + if(object instanceof ILineObject lo) { + if(saveUserDefaultColor) { + isDefaultColor &= (lo.getLineColor() != null && rgb.equals(ColorFactory.getDefaultLineColor(lo).getRGB())); + } + else { + isDefaultColor &= lo.getLineColor() == null; + } + } } - // If the user pref is to save the color in the file, then it's a different meaning of default - boolean isDefaultColor = (colorValue == null); - if(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) { - isDefaultColor = (colorValue != null) && rgb.equals(ColorFactory.getDefaultLineColor(lineObject).getRGB()); - } fColorChooser.setIsDefaultColor(isDefaultColor); - // If this is an element line enable or disable some things - if(lineObject instanceof IDiagramModelObject dmo) { + // If this is an object line enable or disable some things + if(firstSelected instanceof IDiagramModelObject dmo) { boolean deriveElementLineColor = dmo.getDeriveElementLineColor(); + fColorChooser.setDoShowColorImage(!deriveElementLineColor); fColorChooser.getColorButton().setEnabled(!deriveElementLineColor); fColorChooser.setDoShowDefaultMenuItem(!deriveElementLineColor); @@ -168,6 +173,7 @@ void updateControl() { fColorChooser.addMenuAction(fDeriveLineColorAction); fDeriveLineColorAction.setChecked(deriveElementLineColor); } + // Connection line else { fColorChooser.setDoShowColorImage(true); fColorChooser.getColorButton().setEnabled(true);