Skip to content

Commit

Permalink
Make the "None" border colour a check menu option
Browse files Browse the repository at this point in the history
- Before this to remove the "None" border colour you had to open the color chooser and choose a different color than black for it to take effect
- This was because the color chooser returns null if the colour is the same
- This gives the user an easier way to remove the "None" option and set the border colour to the default of black
  • Loading branch information
Phillipus committed Dec 16, 2024
1 parent ba07da5 commit 5c0d30a
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@ public Class<?> getAdaptableType() {
private IPropertyChangeListener colorListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
RGB rgb = fColorChooser.getColorValue();
String newColor = ColorFactory.convertRGBToString(rgb);

CompoundCommand result = new CompoundCommand();

for(EObject bo : getEObjects()) {
if(isAlive(bo)) {
RGB rgb = fColorChooser.getColorValue();
String newColor = ColorFactory.convertRGBToString(rgb);
if(!newColor.equals(((IBorderObject)bo).getBorderColor())) {
Command cmd = new BorderColorCommand((IBorderObject)bo, newColor);
if(cmd.canExecute()) {
result.add(cmd);
}
for(EObject eObject : getEObjects()) {
if(isAlive(eObject) && eObject instanceof IBorderObject bo) {
Command cmd = new BorderColorCommand(bo, newColor);
if(cmd.canExecute()) {
result.add(cmd);
}
}
}
Expand Down Expand Up @@ -95,14 +94,15 @@ private void createColorControl(Composite parent) {
fColorChooser.setDoShowPreferencesMenuItem(false);

// No border action
fNoBorderAction = new Action(Messages.BorderColorSection_1) {
fNoBorderAction = new Action(Messages.BorderColorSection_1, SWT.CHECK) {
@Override
public void run() {
CompoundCommand result = new CompoundCommand();

for(EObject bo : getEObjects()) {
if(isAlive(bo)) {
Command cmd = new BorderColorCommand((IBorderObject)bo, null);
for(EObject eObject : getEObjects()) {
if(isAlive(eObject) && eObject instanceof IBorderObject bo) {
String color = isChecked() ? null : "#000000"; //$NON-NLS-1$
Command cmd = new BorderColorCommand(bo, color);
if(cmd.canExecute()) {
result.add(cmd);
}
Expand Down Expand Up @@ -140,7 +140,7 @@ protected void update() {

fColorChooser.setEnabled(!isLocked(bo));

fNoBorderAction.setEnabled(colorValue != null);
fNoBorderAction.setChecked(colorValue == null);
fColorChooser.setDoShowColorImage(colorValue != null);
}

Expand Down

0 comments on commit 5c0d30a

Please sign in to comment.