Skip to content

Commit

Permalink
eclipse-capella#2681 [Capella properties] Bad concurrent modification
Browse files Browse the repository at this point in the history
Refresh Capella widgets when they are enabled in case its semantic
target was updated remotely.

Signed-off-by: Steve Monnier <[email protected]>
  • Loading branch information
SteveMonnier committed Jan 26, 2024
1 parent 9533338 commit 9dbe1ff
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -21,6 +21,7 @@
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.polarsys.capella.common.data.modellingcore.ModellingcorePackage;
import org.polarsys.capella.common.mdsofa.common.constant.ICommonConstants;
import org.polarsys.capella.core.data.capellacore.CapellaElement;
import org.polarsys.capella.core.data.capellacore.CapellacorePackage;
import org.polarsys.capella.core.data.core.properties.Messages;
import org.polarsys.capella.core.ui.properties.fields.AbstractSemanticField;
Expand Down Expand Up @@ -145,5 +146,9 @@ public void enableSummaryField(boolean enabled) {
public void setEnabled(boolean enabled) {
LockHelper.getInstance().enable(nameTextField, enabled);
LockHelper.getInstance().enable(summaryTextField, enabled);
if (enabled && semanticElement instanceof CapellaElement) {
// Refresh widgets from semantic element in case of remote update
loadData(semanticElement);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -14,6 +14,7 @@

import java.util.List;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -61,7 +62,12 @@ protected Button createButton(Composite group, String label, Object data, boolea
*/
protected void enableButton(Button button, boolean enabled) {
if (null != button && !button.isDisposed()) {
button.setEnabled(enabled);
button.setEnabled(enabled);
if (enabled && semanticElement != null && button.getData() instanceof EAttribute
&& semanticElement.eGet((EAttribute) button.getData()) instanceof Boolean) {
// Refresh widget from semantic element in case of remote update
button.setSelection((Boolean) semanticElement.eGet(((EAttribute) button.getData())));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -107,6 +107,10 @@ protected void fillComboField(CCombo comboField) {
public void setEnabled(boolean enabled) {
if (null != _valueField && !_valueField.isDisposed()) {
_valueField.setEnabled(enabled);
if (enabled) {
// Refresh widget from semantic element in case of remote update
loadComboValue();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -305,6 +305,10 @@ public void setEnabled(boolean enabled) {
LockHelper.getInstance().enable(_valueOpenBtn, enabled);
LockHelper.getInstance().enable(_valueShortcutBtn, enabled);
LockHelper.getInstance().update(_valueTextField, enabled);
if (enabled && this.semanticElement != null && this.semanticFeature != null) {
// Refresh widget from semantic element in case of remote update
setValueTextField(this.semanticElement.eGet(this.semanticFeature));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -167,6 +167,10 @@ protected void fillComboField(CCombo comboField) {
public void setEnabled(boolean enabled) {
if (null != _valueField && !_valueField.isDisposed()) {
_valueField.setEnabled(enabled);
if (enabled) {
// Refresh widget from semantic element in case of remote update
loadComboValue();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -152,6 +152,10 @@ protected void fillTextField(Text textField) {
public void setEnabled(boolean enabled) {
if (null != valueField && !valueField.isDisposed()) {
valueField.setEnabled(enabled);
if (enabled) {
// Refresh widget from semantic element in case of remote update
loadTextValue();
}
}
if (null != valueResetBtn && !valueResetBtn.isDisposed()) {
valueResetBtn.setEnabled(enabled);
Expand Down

0 comments on commit 9dbe1ff

Please sign in to comment.