Skip to content

Commit

Permalink
[Property Sections] Fix multi-composite sections not hiding controls
Browse files Browse the repository at this point in the history
- If a composite is hidden because it should not be shown for that element we need to actually dispose the composite and re-layout
  • Loading branch information
Phillipus committed Oct 7, 2024
1 parent ebb11dd commit 98e20e3
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ class FillColorComposite {

private ColorChooser fColorChooser;
private AbstractECorePropertySection section;
private Composite composite;

FillColorComposite(AbstractECorePropertySection section, Composite parent) {
this.section = section;
createColorControl(section.createComposite(parent, 2, false));
composite = section.createComposite(parent, 2, false);
createColorControl(composite);
addListeners();
}

Composite getComposite() {
return composite;
}

/**
* Color listener
*/
Expand Down Expand Up @@ -119,6 +125,8 @@ void updateControl() {

void dispose() {
removeListeners();
composite.dispose();
composite = null;
section = null;
fColorChooser = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ private void updateColorControl() {
if(show) {
if(fillColorComposite == null) {
fillColorComposite = new FillColorComposite(this, parentComposite);

// If we're showing the GradientComposite move the FillColorComposite above/before it
if(gradientComposite != null) {
fillColorComposite.getComposite().moveAbove(gradientComposite.getComposite());
parentComposite.requestLayout();
}
}

fillColorComposite.updateControl();
}
else if(fillColorComposite != null) {
fillColorComposite.dispose();
fillColorComposite = null;
parentComposite.requestLayout();
}
}

Expand All @@ -112,6 +120,7 @@ private void updateGradientControl() {
else if(gradientComposite != null) {
gradientComposite.dispose();
gradientComposite = null;
parentComposite.requestLayout();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ class GradientComposite {

private Combo fGradientCombo;
private AbstractECorePropertySection section;
private Composite composite;

GradientComposite(AbstractECorePropertySection section, Composite parent) {
this.section = section;
createGradientControl(section.createComposite(parent, 2, false));
composite = section.createComposite(parent, 2, false);
createGradientControl(composite);
}

Composite getComposite() {
return composite;
}

private void createGradientControl(Composite parent) {
section.createLabel(parent, Messages.GradientSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);

Expand Down Expand Up @@ -76,6 +82,8 @@ void updateControl() {
}

void dispose() {
composite.dispose();
composite = null;
section = null;
fGradientCombo = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ class LineColorComposite {
private ColorChooser fColorChooser;
private Action fDeriveLineColorAction;
private AbstractECorePropertySection section;
private Composite composite;

LineColorComposite(AbstractECorePropertySection section, Composite parent) {
this.section = section;
createColorControl(section.createComposite(parent, 2, false));
composite = section.createComposite(parent, 2, false);
createColorControl(composite);
addListeners();
}

Composite getComposite() {
return composite;
}

/**
* Color listener
*/
Expand Down Expand Up @@ -169,6 +175,8 @@ void updateControl() {

void dispose() {
removeListeners();
composite.dispose();
composite = null;
section = null;
fColorChooser = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ private void updateColorControl() {
if(show) {
if(lineColorComposite == null) {
lineColorComposite = new LineColorComposite(this, parentComposite);

// If we're showing the LineWidthComposite move the LineColorComposite above/before it
if(lineWidthComposite != null) {
lineColorComposite.getComposite().moveAbove(lineWidthComposite.getComposite());
parentComposite.requestLayout();
}
}
lineColorComposite.updateControl();
}
else if(lineColorComposite != null) {
lineColorComposite.dispose();
lineColorComposite = null;
parentComposite.requestLayout();
}
}

Expand All @@ -113,6 +120,7 @@ private void updateLineWidthControl() {
else if(lineWidthComposite != null) {
lineWidthComposite.dispose();
lineWidthComposite = null;
parentComposite.requestLayout();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ class LineWidthComposite {

private Combo fComboLineWidth;
private AbstractECorePropertySection section;
private Composite composite;

LineWidthComposite(AbstractECorePropertySection section, Composite parent) {
this.section = section;
createLineWidthControl(section.createComposite(parent, 2, false));
composite = section.createComposite(parent, 2, false);
createLineWidthControl(composite);
}

Composite getComposite() {
return composite;
}

private void createLineWidthControl(Composite parent) {
Expand Down Expand Up @@ -73,6 +79,8 @@ void updateControl() {
}

void dispose() {
composite.dispose();
composite = null;
section = null;
fComboLineWidth = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ abstract class OpacityComposite {

private Spinner fSpinner;
private AbstractECorePropertySection section;
private Composite composite;

OpacityComposite(AbstractECorePropertySection section, Composite parent, String label) {
this.section = section;
createSpinnerControl(section.createComposite(parent, 2, false), label);
composite = section.createComposite(parent, 2, false);
createSpinnerControl(composite, label);
}

Composite getComposite() {
return composite;
}

private void createSpinnerControl(Composite parent, String label) {
Expand Down Expand Up @@ -84,6 +90,8 @@ void updateControl() {
}

void dispose() {
composite.dispose();
composite = null;
fSpinner = null;
section = null;
}
Expand Down

0 comments on commit 98e20e3

Please sign in to comment.