diff options
17 files changed, 326 insertions, 68 deletions
diff --git a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/AbstractEEFExtReferenceLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/AbstractEEFExtReferenceLifecycleManager.java index f140a4f54..7a10e4326 100644 --- a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/AbstractEEFExtReferenceLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/AbstractEEFExtReferenceLifecycleManager.java @@ -277,14 +277,23 @@ public abstract class AbstractEEFExtReferenceLifecycleManager extends AbstractEE } this.setLabelFontStyle(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) + */ + @Override + protected void setEnabled(boolean isEnabled) { if (this.addButton != null && !this.addButton.isDisposed()) { - this.addButton.setEnabled(this.isEnabled()); + this.addButton.setEnabled(isEnabled); } if (this.removeButton != null && !this.removeButton.isDisposed()) { - this.removeButton.setEnabled(this.isEnabled()); + this.removeButton.setEnabled(isEnabled); } if (this.browseButton != null && !this.browseButton.isDisposed()) { - this.browseButton.setEnabled(this.isEnabled()); + this.browseButton.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java index 2cf224474..0017d67a9 100644 --- a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java @@ -219,6 +219,10 @@ public class EEFExtMultipleReferenceLifecycleManager extends AbstractEEFExtRefer IItemPropertySource propertySource = (IItemPropertySource) adapter; IItemPropertyDescriptor propertyDescriptor = propertySource.getPropertyDescriptor(this.target, this.eReference); if (propertyDescriptor != null) { + List<EObject> elements = new ArrayList<>(); + elements.add(this.target); + this.contextAdapter.lock(elements); + ArrayList<Object> choiceOfValues = new ArrayList<Object>(propertyDescriptor.getChoiceOfValues(this.target)); FeatureEditorDialog dialog = new FeatureEditorDialog(this.tableViewer.getTable().getShell(), new AdapterFactoryLabelProvider( this.composedAdapterFactory), this.target, this.eReference, propertyDescriptor.getDisplayName(this.target), choiceOfValues); @@ -228,6 +232,8 @@ public class EEFExtMultipleReferenceLifecycleManager extends AbstractEEFExtRefer if (result != null) { this.target.eSet(this.eReference, result); } + + this.contextAdapter.unlock(elements); } } } @@ -239,9 +245,15 @@ public class EEFExtMultipleReferenceLifecycleManager extends AbstractEEFExtRefer */ @Override protected void addButtonCallback() { + List<EObject> elements = new ArrayList<>(); + elements.add(this.target); + this.contextAdapter.lock(elements); + IWizard wizard = new EEFExtEObjectCreationWizard(this.target, this.eReference, this.contextAdapter); WizardDialog wizardDialog = new WizardDialog(this.tableViewer.getTable().getShell(), wizard); wizardDialog.open(); + + this.contextAdapter.unlock(elements); } /** @@ -350,11 +362,22 @@ public class EEFExtMultipleReferenceLifecycleManager extends AbstractEEFExtRefer this.tableViewer.setInput(this.target); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.ide.ui.ext.widgets.reference.internal.AbstractEEFExtReferenceLifecycleManager#setEnabled(boolean) + */ + @Override + protected void setEnabled(boolean isEnabled) { + super.setEnabled(isEnabled); + if (this.upButton != null && !this.upButton.isDisposed()) { - this.upButton.setEnabled(this.isEnabled()); + this.upButton.setEnabled(isEnabled); } if (this.downButton != null && !this.downButton.isDisposed()) { - this.downButton.setEnabled(this.isEnabled()); + this.downButton.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtSingleReferenceLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtSingleReferenceLifecycleManager.java index 43c3fb741..6ba496f64 100644 --- a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtSingleReferenceLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtSingleReferenceLifecycleManager.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.eef.ide.ui.ext.widgets.reference.internal; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.eef.common.ui.api.IEEFFormContainer; import org.eclipse.eef.core.api.EditingContextAdapter; import org.eclipse.eef.core.ext.widgets.reference.internal.EEFExtReferenceController; @@ -155,9 +158,15 @@ public class EEFExtSingleReferenceLifecycleManager extends AbstractEEFExtReferen */ @Override protected void browseButtonCallback() { + List<EObject> elements = new ArrayList<>(); + elements.add(this.target); + this.contextAdapter.lock(elements); + IWizard wizard = new EEFExtEObjectSelectionWizard(this.target, this.eReference, this.contextAdapter); WizardDialog wizardDialog = new WizardDialog(this.text.getShell(), wizard); wizardDialog.open(); + + this.contextAdapter.unlock(elements); } /** @@ -167,9 +176,15 @@ public class EEFExtSingleReferenceLifecycleManager extends AbstractEEFExtReferen */ @Override protected void addButtonCallback() { + List<EObject> elements = new ArrayList<>(); + elements.add(this.target); + this.contextAdapter.lock(elements); + IWizard wizard = new EEFExtEObjectCreationWizard(this.target, this.eReference, this.contextAdapter); WizardDialog wizardDialog = new WizardDialog(this.text.getShell(), wizard); wizardDialog.open(); + + this.contextAdapter.unlock(elements); } /** @@ -208,9 +223,19 @@ public class EEFExtSingleReferenceLifecycleManager extends AbstractEEFExtReferen this.image.setImage(null); this.text.setText(Messages.SingleReference_noValue); } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.ide.ui.ext.widgets.reference.internal.AbstractEEFExtReferenceLifecycleManager#setEnabled(boolean) + */ + @Override + protected void setEnabled(boolean isEnabled) { + super.setEnabled(isEnabled); if (this.browseButton != null && !this.browseButton.isDisposed()) { - this.browseButton.setEnabled(this.isEnabled()); + this.browseButton.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui/plugin.properties b/plugins/org.eclipse.eef.ide.ui/plugin.properties index 7058202c5..91654f2f3 100644 --- a/plugins/org.eclipse.eef.ide.ui/plugin.properties +++ b/plugins/org.eclipse.eef.ide.ui/plugin.properties @@ -34,3 +34,5 @@ EEFValidationRulesPage_description=Select the message to fix EEFValidationRulesPage_label=Select a message: AbstractEEFWidgetLifecycleManager_noDescriptionAvailable=No description available +AbstractEEFWidgetLifecycleManager_lockedByOther=This widget is locked by another user +AbstractEEFWidgetLifecycleManager_lockedByMe=This widget is locked for other users diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java index 8e2d0b629..3d001fa9d 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java @@ -12,6 +12,8 @@ package org.eclipse.eef.ide.ui.api.widgets; import com.google.common.base.Objects; +import java.util.Collection; + import org.eclipse.eef.EEFDynamicMappingFor; import org.eclipse.eef.EEFDynamicMappingIf; import org.eclipse.eef.EEFGroupDescription; @@ -20,7 +22,10 @@ import org.eclipse.eef.EEFWidgetStyle; import org.eclipse.eef.common.api.utils.Util; import org.eclipse.eef.common.ui.api.EEFWidgetFactory; import org.eclipse.eef.common.ui.api.IEEFFormContainer; +import org.eclipse.eef.core.api.EEFExpressionUtils; import org.eclipse.eef.core.api.EditingContextAdapter; +import org.eclipse.eef.core.api.LockStatusChangeEvent; +import org.eclipse.eef.core.api.LockStatusChangeEvent.LockStatus; import org.eclipse.eef.core.api.controllers.IConsumer; import org.eclipse.eef.core.api.controllers.IEEFWidgetController; import org.eclipse.eef.core.api.utils.EvalFactory; @@ -32,6 +37,7 @@ import org.eclipse.eef.ide.ui.internal.widgets.EEFStyledTextStyleCallback; import org.eclipse.eef.ide.ui.internal.widgets.styles.EEFColor; import org.eclipse.eef.ide.ui.internal.widgets.styles.EEFFont; import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; @@ -47,6 +53,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; /** * Parent of all the lifecycle managers. @@ -90,6 +97,21 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec private MouseTrackListener mouseTrackListener; /** + * The listener used to react to changes in the lock status of a semantic element. + */ + private IConsumer<Collection<LockStatusChangeEvent>> lockStatusChangedListener; + + /** + * Indicates if the current widget is locked. + */ + private boolean isLocked; + + /** + * The decorator used to indicate the permission on the validation widget. + */ + private ControlDecoration controlDecoration; + + /** * The constructor. * * @param variableManager @@ -170,6 +192,13 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec } this.createMainControl(composite, formContainer); + + this.controlDecoration = new ControlDecoration(this.getValidationControl(), SWT.TOP | SWT.LEFT); + Object self = this.variableManager.getVariables().get(EEFExpressionUtils.SELF); + if (self instanceof EObject) { + LockStatus status = this.contextAdapter.geLockStatus((EObject) self); + this.handleLockStatus(status); + } } /** @@ -289,6 +318,119 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec }; this.help.addMouseTrackListener(mouseTrackListener); } + + this.lockStatusChangedListener = new IConsumer<Collection<LockStatusChangeEvent>>() { + @Override + public void apply(final Collection<LockStatusChangeEvent> events) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + for (LockStatusChangeEvent event : events) { + if (AbstractEEFWidgetLifecycleManager.this.getWidgetSemanticElement().equals(event.getElement())) { + handleLockStatus(event.getStatus()); + } + } + } + }); + } + }; + this.contextAdapter.addLockStatusChangedListener(this.lockStatusChangedListener); + } + + /** + * Handles the change in the lock status by switching the user interface to a "locked by me", "locked by other" or + * "unlocked" state. + * + * @param status + * The lock status + */ + private void handleLockStatus(LockStatus status) { + if (status != null) { + switch (status) { + case LOCKED_BY_ME: + AbstractEEFWidgetLifecycleManager.this.lockedByMe(); + break; + case LOCKED_BY_OTHER: + AbstractEEFWidgetLifecycleManager.this.lockedByOther(); + break; + case UNLOCKED: + AbstractEEFWidgetLifecycleManager.this.unlocked(); + break; + default: + AbstractEEFWidgetLifecycleManager.this.unlocked(); + break; + } + } + } + + /** + * Returns the semantic element of the current widget. + * + * @return The semantic element of the current widget + */ + protected Object getWidgetSemanticElement() { + return this.variableManager.getVariables().get(EEFExpressionUtils.SELF); + } + + /** + * Sets the appearance and behavior of the widget in order to indicate that the semantic element used by the widget + * is currently locked by the current user. By default, it will only display a small green lock next to the + * validation control. + */ + protected void lockedByMe() { + this.isLocked = false; + + this.controlDecoration.hide(); + this.controlDecoration.setDescriptionText(Messages.AbstractEEFWidgetLifecycleManager_lockedByMe); + this.controlDecoration.setImage(EEFIdeUiPlugin.getPlugin().getImageRegistry().get(Icons.PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY)); + this.controlDecoration.show(); + } + + /** + * Sets the appearance and behavior of the widget in order to indicate that the semantic element used by the widget + * is currently locked by another user. As a result, it will set the user interface in a disabled mode along with a + * red lock next to the widget. + */ + protected void lockedByOther() { + this.isLocked = true; + this.setEnabled(false); + + this.controlDecoration.hide(); + this.controlDecoration.setDescriptionText(Messages.AbstractEEFWidgetLifecycleManager_lockedByOther); + this.controlDecoration.setImage(EEFIdeUiPlugin.getPlugin().getImageRegistry().get(Icons.PERMISSION_DENIED)); + this.controlDecoration.show(); + } + + /** + * Sets the appearance and behavior of the widget in order to indicate that the semantic element used by the widget is + * currently unlocked. As a result, it will set back the widget to its default state. + */ + protected void unlocked() { + this.isLocked = false; + this.setEnabled(this.isEnabled()); + + this.controlDecoration.hide(); + } + + /** + * Sets the enablement of the widget. + * + * @param isEnabled + * <code>true</code> when the widget should have its default behavior, <code>false</code> when the widget + * should be in a read only mode. + */ + protected abstract void setEnabled(boolean isEnabled); + + /** + * Check if a widget is enabled. + * + * @return True if the widget should be enabled otherwise false. + */ + protected boolean isEnabled() { + Boolean result = EvalFactory.of(interpreter, variableManager).logIfInvalidType(Boolean.class).defaultValue(Boolean.TRUE) + .evaluate(getWidgetDescription().getIsEnabledExpression()); + return result.booleanValue(); } /** @@ -327,6 +469,20 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec /** * {@inheritDoc} * + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager#refresh() + */ + @Override + public void refresh() { + super.refresh(); + + if (!this.isLocked) { + this.setEnabled(this.isEnabled()); + } + } + + /** + * {@inheritDoc} + * * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager#aboutToBeHidden() */ @Override @@ -337,6 +493,7 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec } this.getController().removeNewLabelConsumer(); + this.contextAdapter.removeLockStatusChangedListener(this.lockStatusChangedListener); } /** @@ -370,14 +527,4 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec throw new ClassCastException(Messages.AbstractEEFWidgetLifecycleManager_invalidSelectionType); } - /** - * Check if a widget is enabled. - * - * @return True if the widget should be enabled otherwise false. - */ - protected boolean isEnabled() { - Boolean result = EvalFactory.of(interpreter, variableManager).logIfInvalidType(Boolean.class).defaultValue(Boolean.TRUE) - .evaluate(getWidgetDescription().getIsEnabledExpression()); - return result.booleanValue(); - } } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/EEFIdeUiPlugin.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/EEFIdeUiPlugin.java index d2756f055..ad7d46f63 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/EEFIdeUiPlugin.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/EEFIdeUiPlugin.java @@ -123,6 +123,9 @@ public class EEFIdeUiPlugin extends EMFPlugin { this.imageRegistry.put(Icons.WARNING, this.getImageDescriptor(Icons.WARNING)); this.imageRegistry.put(Icons.ERROR, this.getImageDescriptor(Icons.ERROR)); this.imageRegistry.put(Icons.FIX, this.getImageDescriptor(Icons.FIX)); + this.imageRegistry.put(Icons.PERMISSION_DENIED, this.getImageDescriptor(Icons.PERMISSION_DENIED)); + this.imageRegistry.put(Icons.PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY, + this.getImageDescriptor(Icons.PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY)); } /** diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Icons.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Icons.java index adcb44f3b..5fd0edc7c 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Icons.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Icons.java @@ -70,4 +70,14 @@ public interface Icons { * Fix. */ String FIX = "icons/full/fix.gif"; //$NON-NLS-1$ + + /** + * Permission Denied. + */ + String PERMISSION_DENIED = "icons/full/permission_denied.gif"; //$NON-NLS-1$ + + /** + * Permission Granted to current user exclusively. + */ + String PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY = "icons/full/permission_granted_to_current_user_exclusively.gif"; //$NON-NLS-1$ } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Messages.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Messages.java index c1a1f96d1..f212b5bc0 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Messages.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/Messages.java @@ -73,6 +73,12 @@ public final class Messages { @TranslatableMessage public static String AbstractEEFWidgetLifecycleManager_noDescriptionAvailable; + @TranslatableMessage + public static String AbstractEEFWidgetLifecycleManager_lockedByOther; + + @TranslatableMessage + public static String AbstractEEFWidgetLifecycleManager_lockedByMe; + // CHECKSTYLE:ON /** diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFButtonLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFButtonLifecycleManager.java index 993406530..dbf7947cf 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFButtonLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFButtonLifecycleManager.java @@ -190,11 +190,10 @@ public class EEFButtonLifecycleManager extends AbstractEEFWidgetLifecycleManager /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.button.setEnabled(isEnabled()); + protected void setEnabled(boolean isEnabled) { + this.button.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java index 1ab1959df..3ae6e5294 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java @@ -218,7 +218,6 @@ public class EEFCheckboxLifecycleManager extends AbstractEEFWidgetLifecycleManag @Override public void refresh() { super.refresh(); - this.checkbox.setEnabled(isEnabled()); EEFStyleHelper styleHelper = new EEFStyleHelper(this.interpreter, this.variableManager); EEFWidgetStyle widgetStyle = styleHelper.getWidgetStyle(this.description); @@ -229,4 +228,14 @@ public class EEFCheckboxLifecycleManager extends AbstractEEFWidgetLifecycleManag this.checkbox.getFont(), style.getLabelBackgroundColorExpression(), style.getLabelForegroundColorExpression(), callback); } } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) + */ + @Override + protected void setEnabled(boolean isEnabled) { + this.checkbox.setEnabled(isEnabled); + } } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java index 5a67f8c06..4a89c2b85 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java @@ -305,15 +305,14 @@ public class EEFHyperlinkLifecycleManager extends AbstractEEFWidgetLifecycleMana /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.hyperlink.setEnabled(isEnabled()); + protected void setEnabled(boolean isEnabled) { + this.hyperlink.setEnabled(isEnabled); for (ActionButton actionButton : this.actionButtons) { - actionButton.setEnabled(this.isEnabled()); + actionButton.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFLabelLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFLabelLifecycleManager.java index b6052b848..9bec2f24a 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFLabelLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFLabelLifecycleManager.java @@ -236,15 +236,14 @@ public class EEFLabelLifecycleManager extends AbstractEEFWidgetLifecycleManager /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.body.setEnabled(isEnabled()); + protected void setEnabled(boolean isEnabled) { + this.body.setEnabled(isEnabled); for (ActionButton actionButton : this.actionButtons) { - actionButton.setEnabled(this.isEnabled()); + actionButton.setEnabled(isEnabled); } } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java index d075adb97..cd8324345 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java @@ -269,44 +269,43 @@ public class EEFListLifecycleManager extends AbstractEEFWidgetLifecycleManager { values.add(value); } tableViewer.setInput(values.toArray()); - if (!this.tableViewer.getTable().isEnabled() && this.isEnabled()) { - this.tableViewer.getTable().setEnabled(true); - } } } /** - * Get the background color according to the current valid style. - * - * @return The background color to use in the text field. - */ - private Color getBackgroundColor() { - Color color = defaultBackgroundColor; - if (!isEnabled()) { - color = widgetFactory.getColors().getInactiveBackground(); - } - return color; - } - - /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - + protected void setEnabled(boolean isEnabled) { if (this.tableViewer != null && this.tableViewer.getTable() != null) { - this.tableViewer.getTable().setBackground(getBackgroundColor()); + this.tableViewer.getTable().setBackground(this.getBackgroundColor(isEnabled)); } + this.tableViewer.getTable().setEnabled(isEnabled); for (ActionButton actionButton : this.actionButtons) { - actionButton.setEnabled(this.isEnabled()); + actionButton.setEnabled(isEnabled); } } /** + * Get the background color according to the current valid style. + * + * @param isEnabled + * <code>true</code> if the widget is enabled, <code>false</code> otherwise + * + * @return The background color to use in the text field. + */ + private Color getBackgroundColor(boolean isEnabled) { + Color color = defaultBackgroundColor; + if (!isEnabled) { + color = widgetFactory.getColors().getInactiveBackground(); + } + return color; + } + + /** * {@inheritDoc} * * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#aboutToBeHidden() diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFRadioLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFRadioLifecycleManager.java index 6f9d657f4..a91946713 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFRadioLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFRadioLifecycleManager.java @@ -256,12 +256,11 @@ public class EEFRadioLifecycleManager extends AbstractEEFWidgetLifecycleManager /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.radioGroup.setEnabled(isEnabled()); + protected void setEnabled(boolean isEnabled) { + this.radioGroup.setEnabled(isEnabled); } /** diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java index cfdf2363d..d61b0d432 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java @@ -266,12 +266,11 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.combo.setEnabled(isEnabled()); + protected void setEnabled(boolean isEnabled) { + this.combo.setEnabled(isEnabled); } /** diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java index 59966fa07..ef6badeb4 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.eef.ide.ui.internal.widgets; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.IStatus; @@ -20,6 +22,7 @@ import org.eclipse.eef.EEFWidgetStyle; import org.eclipse.eef.common.api.utils.Util; import org.eclipse.eef.common.ui.api.EEFWidgetFactory; import org.eclipse.eef.common.ui.api.IEEFFormContainer; +import org.eclipse.eef.core.api.EEFExpressionUtils; import org.eclipse.eef.core.api.EditingContextAdapter; import org.eclipse.eef.core.api.controllers.EEFControllersFactory; import org.eclipse.eef.core.api.controllers.IConsumer; @@ -30,6 +33,7 @@ import org.eclipse.eef.ide.ui.api.widgets.EEFStyleHelper; import org.eclipse.eef.ide.ui.api.widgets.EEFStyleHelper.IEEFTextStyleCallback; import org.eclipse.eef.ide.ui.internal.EEFIdeUiPlugin; import org.eclipse.eef.ide.ui.internal.widgets.styles.EEFColor; +import org.eclipse.emf.ecore.EObject; import org.eclipse.sirius.common.interpreter.api.IInterpreter; import org.eclipse.sirius.common.interpreter.api.IVariableManager; import org.eclipse.swt.SWT; @@ -217,6 +221,13 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager { public void modifyText(ModifyEvent e) { if (!EEFTextLifecycleManager.this.container.isRenderingInProgress() && !updateInProgress.get()) { EEFTextLifecycleManager.this.isDirty = true; + + List<EObject> elements = new ArrayList<EObject>(); + Object object = EEFTextLifecycleManager.this.variableManager.getVariables().get(EEFExpressionUtils.SELF); + if (object instanceof EObject) { + elements.add((EObject) object); + } + EEFTextLifecycleManager.this.contextAdapter.lock(elements); } } }; @@ -297,6 +308,13 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager { this.setStyle(); } finally { updateInProgress.set(false); + + List<EObject> elements = new ArrayList<EObject>(); + Object object = this.variableManager.getVariables().get(EEFExpressionUtils.SELF); + if (object instanceof EObject) { + elements.add((EObject) object); + } + this.contextAdapter.unlock(elements); } } } @@ -356,23 +374,25 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager { /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#refresh() + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) */ @Override - public void refresh() { - super.refresh(); - this.text.setEnabled(isEnabled()); - this.text.setBackground(getBackgroundColor()); + protected void setEnabled(boolean isEnabled) { + this.text.setEnabled(isEnabled); + this.text.setBackground(this.getBackgroundColor(isEnabled)); } /** * Get the background color according to the current valid style. * + * @param isEnabled + * <code>true</code> to indicate that the widget is currently enabled, <code>false</code> otherwise + * * @return The background color to use in the text field. */ - private Color getBackgroundColor() { + private Color getBackgroundColor(boolean isEnabled) { Color color = defaultBackgroundColor; - if (!isEnabled()) { + if (!isEnabled) { color = widgetFactory.getColors().getInactiveBackground(); } else { EEFWidgetStyle widgetStyle = new EEFStyleHelper(this.interpreter, this.variableManager).getWidgetStyle(this.description); diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java index 9a05e0f03..8ec8e2374 100644 --- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java +++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java @@ -157,6 +157,16 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag /** * {@inheritDoc} * + * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#setEnabled(boolean) + */ + @Override + protected void setEnabled(boolean isEnabled) { + // do not support read only for now + } + + /** + * {@inheritDoc} + * * @see org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager#aboutToBeHidden() */ @Override |