Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-12-15 09:05:38 +0000
committerStéphane Bégaudeau2017-01-27 08:58:27 +0000
commit31c25928c9d3a7250c49e61da8ec932481dd267e (patch)
tree54ac5af1b1f8cf6a395aa01ae3f0d411f5897804 /plugins/org.eclipse.eef.ide.ui
parent525c08d3fe109ce3f1ad573aeb054c04ccad49b9 (diff)
downloadorg.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.tar.gz
org.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.tar.xz
org.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.zip
[refactoring] Improve some code thanks to JavaSE-8.0
Change-Id: If0cb48804b274f430b6aa7b30750c242c366643e Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.eef.ide.ui')
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFLifecycleManager.java36
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java41
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFButtonLifecycleManager.java10
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java25
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java16
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java32
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java35
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFLabelLifecycleManager.java26
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java29
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFRadioLifecycleManager.java54
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java16
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java58
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java40
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/RadioGroup.java25
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFQuickFixPage.java40
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFValidationMessagesPage.java38
16 files changed, 190 insertions, 331 deletions
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFLifecycleManager.java
index 9a3eee21e..88b13e319 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFLifecycleManager.java
@@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.eef.ide.ui.api.widgets;
-import java.util.List;
-
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFController;
import org.eclipse.eef.core.api.controllers.IInvalidValidationRuleResult;
import org.eclipse.eef.core.api.controllers.IValidationRuleResult;
@@ -51,26 +48,23 @@ public abstract class AbstractEEFLifecycleManager implements IEEFLifecycleManage
*/
@Override
public void aboutToBeShown() {
- this.getController().onValidation(new IConsumer<List<IValidationRuleResult>>() {
- @Override
- public void apply(List<IValidationRuleResult> validationRuleResults) {
- IMessageManager messageManager = container.getForm().getMessageManager();
+ this.getController().onValidation((validationRuleResults) -> {
+ IMessageManager messageManager = container.getForm().getMessageManager();
- for (IValidationRuleResult validationRuleResult : validationRuleResults) {
- if (validationRuleResult instanceof IInvalidValidationRuleResult) {
- IInvalidValidationRuleResult result = (IInvalidValidationRuleResult) validationRuleResult;
- if (getValidationControl() != null) {
- messageManager.addMessage(result.getValidationRule(), result.getMessage(), result.getData(), result.getSeverity(),
- getValidationControl());
- } else {
- messageManager.addMessage(result.getValidationRule(), result.getMessage(), result.getData(), result.getSeverity());
- }
+ for (IValidationRuleResult validationRuleResult : validationRuleResults) {
+ if (validationRuleResult instanceof IInvalidValidationRuleResult) {
+ IInvalidValidationRuleResult result = (IInvalidValidationRuleResult) validationRuleResult;
+ if (getValidationControl() != null) {
+ messageManager.addMessage(result.getValidationRule(), result.getMessage(), result.getData(), result.getSeverity(),
+ getValidationControl());
+ } else {
+ messageManager.addMessage(result.getValidationRule(), result.getMessage(), result.getData(), result.getSeverity());
+ }
+ } else {
+ if (getValidationControl() != null) {
+ messageManager.removeMessage(validationRuleResult.getValidationRule(), getValidationControl());
} else {
- if (getValidationControl() != null) {
- messageManager.removeMessage(validationRuleResult.getValidationRule(), getValidationControl());
- } else {
- messageManager.removeMessage(validationRuleResult.getValidationRule());
- }
+ messageManager.removeMessage(validationRuleResult.getValidationRule());
}
}
}
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 01b1c3eb2..2140fc918 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
@@ -279,23 +279,16 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec
public void aboutToBeShown() {
super.aboutToBeShown();
- this.getController().onNewLabel(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- if (!label.isDisposed() && !(label.getText() != null && label.getText().equals(value))) {
- label.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
- }
- AbstractEEFWidgetLifecycleManager.this.setLabelFontStyle();
+ this.getController().onNewLabel((value) -> {
+ if (!label.isDisposed() && !(label.getText() != null && label.getText().equals(value))) {
+ label.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
}
-
+ AbstractEEFWidgetLifecycleManager.this.setLabelFontStyle();
});
- this.getController().onNewHelp(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- if (help != null && !help.isDisposed() && !(help.getText() != null && help.getText().equals(value))) {
- help.setToolTipText(Objects.firstNonNull(value, Messages.AbstractEEFWidgetLifecycleManager_noDescriptionAvailable));
- }
+ this.getController().onNewHelp((value) -> {
+ if (help != null && !help.isDisposed() && !(help.getText() != null && help.getText().equals(value))) {
+ help.setToolTipText(Objects.firstNonNull(value, Messages.AbstractEEFWidgetLifecycleManager_noDescriptionAvailable));
}
});
@@ -321,21 +314,11 @@ 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.lockStatusChangedListener = (events) -> {
+ Display.getDefault().asyncExec(() -> {
+ events.stream().filter(event -> this.getWidgetSemanticElement().equals(event.getElement()))
+ .forEach(event -> this.handleLockStatus(event.getStatus()));
+ });
};
this.contextAdapter.addLockStatusChangedListener(this.lockStatusChangedListener);
}
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 d9d11631f..c65965603 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
@@ -19,7 +19,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFButtonController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -157,12 +156,9 @@ public class EEFButtonLifecycleManager extends AbstractEEFWidgetLifecycleManager
};
this.button.addSelectionListener(this.selectionListener);
- this.controller.onNewButtonLabel(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- if (!button.isDisposed() && !(button.getText() != null && button.getText().equals(value))) {
- button.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
- }
+ this.controller.onNewButtonLabel((value) -> {
+ if (!button.isDisposed() && !(button.getText() != null && button.getText().equals(value))) {
+ button.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
}
});
}
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 8c121d688..e4c627292 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
@@ -21,7 +21,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFCheckboxController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -154,14 +153,13 @@ public class EEFCheckboxLifecycleManager extends AbstractEEFWidgetLifecycleManag
@Override
public void aboutToBeShown() {
super.aboutToBeShown();
- this.getController().onNewLabel(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- if (!checkbox.isDisposed() && !(checkbox.getText() != null && checkbox.getText().equals(value))) {
- checkbox.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
- }
+
+ this.getController().onNewLabel((value) -> {
+ if (!this.checkbox.isDisposed() && !(this.checkbox.getText() != null && this.checkbox.getText().equals(value))) {
+ this.checkbox.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
}
});
+
// UI edited by user => update model if possible, revert UI change otherwise
this.selectionListener = new SelectionListener() {
@Override
@@ -183,14 +181,11 @@ public class EEFCheckboxLifecycleManager extends AbstractEEFWidgetLifecycleManag
this.checkbox.addSelectionListener(this.selectionListener);
// Model changed => update UI
- this.controller.onNewValue(new IConsumer<Boolean>() {
- @Override
- public void apply(Boolean value) {
- if (!checkbox.isDisposed()) {
- if (value != null && checkbox.getSelection() != value.booleanValue()) {
- checkbox.setSelection(value.booleanValue());
- referenceValue = value.booleanValue();
- }
+ this.controller.onNewValue((value) -> {
+ if (!checkbox.isDisposed()) {
+ if (value != null && checkbox.getSelection() != value.booleanValue()) {
+ checkbox.setSelection(value.booleanValue());
+ referenceValue = value.booleanValue();
}
}
});
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java
index 4d4952fb2..0dfb9fd7e 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java
@@ -136,9 +136,7 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager {
*/
@Override
public void aboutToBeShown() {
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.aboutToBeShown();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeShown);
}
/**
@@ -148,9 +146,7 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager {
*/
@Override
public void refresh() {
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.refresh();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::refresh);
}
/**
@@ -160,9 +156,7 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager {
*/
@Override
public void aboutToBeHidden() {
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.aboutToBeHidden();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeHidden);
}
/**
@@ -172,9 +166,7 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager {
*/
@Override
public void dispose() {
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.dispose();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::dispose);
}
}
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
index ea3106204..02e9520a7 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFGroupLifecycleManager.java
@@ -25,7 +25,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFController;
import org.eclipse.eef.core.api.controllers.IEEFGroupController;
import org.eclipse.eef.core.api.utils.EvalFactory;
@@ -153,12 +152,8 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager {
this.section.setText(""); //$NON-NLS-1$
String labelExpression = this.description.getLabelExpression();
- EvalFactory.of(this.interpreter, this.variableManager).logIfInvalidType(String.class).call(labelExpression, new IConsumer<String>() {
- @Override
- public void apply(String value) {
- EEFGroupLifecycleManager.this.section.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
- }
- });
+ EvalFactory.of(this.interpreter, this.variableManager).logIfInvalidType(String.class).call(labelExpression,
+ (value) -> this.section.setText(Objects.firstNonNull(value, ""))); //$NON-NLS-1$
this.section.setLayout(new GridLayout(1, false));
GridData sectionLayoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
@@ -293,16 +288,9 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager {
public void aboutToBeShown() {
super.aboutToBeShown();
- this.controller.onNewLabel(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- EEFGroupLifecycleManager.this.section.setText(value);
- }
- });
+ this.controller.onNewLabel((value) -> this.section.setText(value));
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.aboutToBeShown();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeShown);
}
/**
@@ -314,9 +302,7 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager {
public void refresh() {
super.refresh();
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.refresh();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::refresh);
}
/**
@@ -330,9 +316,7 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager {
this.controller.removeNewLabelConsumer();
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.aboutToBeHidden();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeHidden);
}
/**
@@ -342,9 +326,7 @@ public class EEFGroupLifecycleManager extends AbstractEEFLifecycleManager {
*/
@Override
public void dispose() {
- for (IEEFLifecycleManager lifecycleManager : lifecycleManagers) {
- lifecycleManager.dispose();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::dispose);
}
}
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 7cf7816e6..8e286817c 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
@@ -23,7 +23,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFHyperlinkController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -204,19 +203,16 @@ public class EEFHyperlinkLifecycleManager extends AbstractEEFWidgetLifecycleMana
this.hyperlinkListener = new EEFHyperlinkListener(this, this.hyperlink, this.container, this.controller);
hyperlink.addMouseListener(hyperlinkListener);
- this.controller.onNewValue(new IConsumer<Object>() {
- @Override
- public void apply(Object value) {
- if (!hyperlink.isDisposed()) {
- if (!(hyperlink.getText() != null && hyperlink.getText().equals(value))) {
- String text = controller.computeDisplayValue(value);
- hyperlink.setText(text);
- hyperlink.setData(value);
- }
- EEFHyperlinkLifecycleManager.this.setStyle();
- if (!hyperlink.isEnabled()) {
- hyperlink.setEnabled(true);
- }
+ this.controller.onNewValue((value) -> {
+ if (!hyperlink.isDisposed()) {
+ if (!(hyperlink.getText() != null && hyperlink.getText().equals(value))) {
+ String text = controller.computeDisplayValue(value);
+ hyperlink.setText(text);
+ hyperlink.setData(value);
+ }
+ this.setStyle();
+ if (!hyperlink.isEnabled()) {
+ hyperlink.setEnabled(true);
}
}
});
@@ -295,9 +291,7 @@ public class EEFHyperlinkLifecycleManager extends AbstractEEFWidgetLifecycleMana
this.hyperlink.removeMouseListener(this.hyperlinkListener);
}
- for (ActionButton actionButton : this.actionButtons) {
- actionButton.removeSelectionListener();
- }
+ this.actionButtons.forEach(ActionButton::removeSelectionListener);
this.controller.removeNewValueConsumer();
}
@@ -312,11 +306,8 @@ public class EEFHyperlinkLifecycleManager extends AbstractEEFWidgetLifecycleMana
if (!this.hyperlink.isDisposed()) {
this.hyperlink.setEnabled(isEnabled);
}
- for (ActionButton actionButton : this.actionButtons) {
- if (!actionButton.getButton().isDisposed()) {
- actionButton.setEnabled(isEnabled);
- }
- }
+ this.actionButtons.stream().filter(actionButton -> !actionButton.getButton().isDisposed())
+ .forEach(actionButton -> 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 25945708c..fefca699c 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
@@ -25,7 +25,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFLabelController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -187,15 +186,12 @@ public class EEFLabelLifecycleManager extends AbstractEEFWidgetLifecycleManager
public void aboutToBeShown() {
super.aboutToBeShown();
- this.controller.onNewValue(new IConsumer<String>() {
- @Override
- public void apply(String value) {
- if (!body.isDisposed()) {
- if (!(body.getText() != null && body.getText().equals(value))) {
- body.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
- }
- EEFLabelLifecycleManager.this.setStyle();
+ this.controller.onNewValue((value) -> {
+ if (!body.isDisposed()) {
+ if (!(body.getText() != null && body.getText().equals(value))) {
+ body.setText(Objects.firstNonNull(value, "")); //$NON-NLS-1$
}
+ this.setStyle();
}
});
@@ -243,11 +239,8 @@ public class EEFLabelLifecycleManager extends AbstractEEFWidgetLifecycleManager
if (!this.body.isDisposed()) {
this.body.setEnabled(isEnabled);
}
- for (ActionButton actionButton : this.actionButtons) {
- if (!actionButton.getButton().isDisposed()) {
- actionButton.setEnabled(isEnabled);
- }
- }
+ this.actionButtons.stream().filter(actionButton -> !actionButton.getButton().isDisposed())
+ .forEach(actionButton -> actionButton.setEnabled(isEnabled));
}
/**
@@ -258,9 +251,8 @@ public class EEFLabelLifecycleManager extends AbstractEEFWidgetLifecycleManager
@Override
public void aboutToBeHidden() {
super.aboutToBeHidden();
- for (ActionButton actionButton : this.actionButtons) {
- actionButton.removeSelectionListener();
- }
+
+ this.actionButtons.forEach(ActionButton::removeSelectionListener);
this.controller.removeNewValueConsumer();
}
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 75aaff12f..1fcb82bac 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
@@ -21,7 +21,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFListController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -219,14 +218,11 @@ public class EEFListLifecycleManager extends AbstractEEFWidgetLifecycleManager {
this.tableSelectionListener = new EEFListSelectionListener(this.controller);
this.tableViewer.getTable().addSelectionListener(tableSelectionListener);
- this.controller.onNewValue(new IConsumer<Object>() {
- @Override
- public void apply(Object value) {
- if (value == null) {
- return;
- }
- EEFListLifecycleManager.this.setListValue(value);
+ this.controller.onNewValue((value) -> {
+ if (value == null) {
+ return;
}
+ this.setListValue(value);
});
for (final ActionButton actionButton : actionButtons) {
@@ -283,17 +279,12 @@ public class EEFListLifecycleManager extends AbstractEEFWidgetLifecycleManager {
*/
@Override
protected void setEnabled(boolean isEnabled) {
- if (!this.tableViewer.getTable().isDisposed()) {
- if (this.tableViewer != null && this.tableViewer.getTable() != null) {
- this.tableViewer.getTable().setBackground(this.getBackgroundColor(isEnabled));
- }
+ if (this.tableViewer != null && this.tableViewer.getTable() != null && !this.tableViewer.getTable().isDisposed()) {
+ this.tableViewer.getTable().setBackground(this.getBackgroundColor(isEnabled));
this.tableViewer.getTable().setEnabled(isEnabled);
}
- for (ActionButton actionButton : this.actionButtons) {
- if (!actionButton.getButton().isDisposed()) {
- actionButton.setEnabled(isEnabled);
- }
- }
+ this.actionButtons.stream().filter(actionButton -> !actionButton.getButton().isDisposed())
+ .forEach(actionButton -> actionButton.setEnabled(isEnabled));
}
/**
@@ -321,9 +312,7 @@ public class EEFListLifecycleManager extends AbstractEEFWidgetLifecycleManager {
public void aboutToBeHidden() {
super.aboutToBeHidden();
- for (ActionButton actionButton : this.actionButtons) {
- actionButton.removeSelectionListener();
- }
+ this.actionButtons.forEach(ActionButton::removeSelectionListener);
if (this.tableViewer != null && this.tableViewer.getTable() != null && !this.tableViewer.getTable().isDisposed()) {
this.tableViewer.getTable().removeSelectionListener(this.tableSelectionListener);
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 3328dfc8a..32682d277 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
@@ -11,7 +11,6 @@
package org.eclipse.eef.ide.ui.internal.widgets;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -25,7 +24,6 @@ import org.eclipse.eef.core.api.EEFExpressionUtils;
import org.eclipse.eef.core.api.EEFExpressionUtils.EEFSelect;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFRadioController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.core.api.utils.EvalFactory;
@@ -200,40 +198,34 @@ public class EEFRadioLifecycleManager extends AbstractEEFWidgetLifecycleManager
this.radioGroup.addSelectionListener(this.selectionListener);
// Set radio group value
- this.controller.onNewValue(new IConsumer<Object>() {
- @Override
- public void apply(Object value) {
- if (!radioGroup.isDisposed()) {
- final ISelection selection;
- if (value != null) {
- selection = new StructuredSelection(value);
- } else {
- selection = null;
- }
- radioGroupViewer.setSelection(selection);
- referenceSelection = selection;
- if (!radioGroup.isEnabled()) {
- radioGroup.setEnabled(true);
- }
+ this.controller.onNewValue((value) -> {
+ if (!this.radioGroup.isDisposed()) {
+ final ISelection selection;
+ if (value != null) {
+ selection = new StructuredSelection(value);
+ } else {
+ selection = null;
+ }
+ this.radioGroupViewer.setSelection(selection);
+ this.referenceSelection = selection;
+ if (!this.radioGroup.isEnabled()) {
+ this.radioGroup.setEnabled(true);
}
}
});
// Set radio group items
- this.controller.onNewCandidates(new IConsumer<List<Object>>() {
- @Override
- public void apply(List<Object> candidates) {
- if (!radioGroup.isDisposed()) {
- if (candidates != null) {
- radioGroupViewer.setInput(candidates.toArray());
- } else {
- radioGroupViewer.setInput(null);
- }
- if (!radioGroup.isEnabled()) {
- radioGroup.setEnabled(true);
- }
- radioGroupViewer.refresh(true);
+ this.controller.onNewCandidates((candidates) -> {
+ if (!this.radioGroup.isDisposed()) {
+ if (candidates != null) {
+ this.radioGroupViewer.setInput(candidates.toArray());
+ } else {
+ this.radioGroupViewer.setInput(null);
}
+ if (!this.radioGroup.isEnabled()) {
+ this.radioGroup.setEnabled(true);
+ }
+ this.radioGroupViewer.refresh(true);
}
});
}
@@ -246,7 +238,7 @@ public class EEFRadioLifecycleManager extends AbstractEEFWidgetLifecycleManager
@Override
public void aboutToBeHidden() {
super.aboutToBeHidden();
- if (!radioGroup.isDisposed()) {
+ if (!this.radioGroup.isDisposed()) {
this.radioGroup.removeSelectionListener(this.selectionListener);
}
this.controller.removeNewValueConsumer();
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java
index b7fe1b240..db5087c43 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSectionLifecycleManager.java
@@ -101,9 +101,7 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager {
this.container.getForm().addMessageHyperlinkListener(this.hyperlinkListener);
- for (IEEFLifecycleManager lifecycleManager : this.lifecycleManagers) {
- lifecycleManager.aboutToBeShown();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeShown);
}
/**
@@ -117,9 +115,7 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager {
this.controller.refresh();
- for (IEEFLifecycleManager lifecycleManager : this.lifecycleManagers) {
- lifecycleManager.refresh();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::refresh);
this.container.getForm().getMessageManager().update();
}
@@ -138,9 +134,7 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager {
this.container.getForm().getMessageManager().removeAllMessages();
}
- for (IEEFLifecycleManager lifecycleManager : this.lifecycleManagers) {
- lifecycleManager.aboutToBeHidden();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::aboutToBeHidden);
}
/**
@@ -170,9 +164,7 @@ public class EEFSectionLifecycleManager extends AbstractEEFLifecycleManager {
*/
@Override
public void dispose() {
- for (IEEFLifecycleManager lifecycleManager : this.lifecycleManagers) {
- lifecycleManager.dispose();
- }
+ this.lifecycleManagers.forEach(IEEFLifecycleManager::dispose);
}
}
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 f700d10f5..5dd740ca3 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
@@ -11,7 +11,6 @@
package org.eclipse.eef.ide.ui.internal.widgets;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
@@ -24,7 +23,6 @@ import org.eclipse.eef.core.api.EEFExpressionUtils;
import org.eclipse.eef.core.api.EEFExpressionUtils.EEFSelect;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFSelectController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.core.api.utils.EvalFactory;
@@ -204,44 +202,38 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
this.combo.addSelectionListener(this.selectionListener);
// Set combo value
- this.controller.onNewValue(new IConsumer<Object>() {
- @Override
- public void apply(Object value) {
- if (!combo.isDisposed() && !(combo.getText() != null && combo.getText().equals(value))) {
- final ISelection selection;
- if (value != null) {
- selection = new StructuredSelection(value);
- } else {
- selection = null;
- }
- referenceValue = selection;
- comboViewer.setSelection(referenceValue, true);
- if (!combo.isEnabled()) {
- combo.setEnabled(true);
- }
+ this.controller.onNewValue((value) -> {
+ if (!this.combo.isDisposed() && !(this.combo.getText() != null && this.combo.getText().equals(value))) {
+ final ISelection selection;
+ if (value != null) {
+ selection = new StructuredSelection(value);
+ } else {
+ selection = null;
+ }
+ this.referenceValue = selection;
+ this.comboViewer.setSelection(this.referenceValue, true);
+ if (!this.combo.isEnabled()) {
+ this.combo.setEnabled(true);
}
}
});
// Set combo items
- this.controller.onNewCandidates(new IConsumer<List<Object>>() {
- @Override
- public void apply(List<Object> value) {
- if (!combo.isDisposed()) {
- if (value != null) {
- Object[] candidates = value.toArray();
- for (int i = 0; i < candidates.length; i++) {
- if (candidates[i] == null) {
- candidates[i] = NO_VALUE;
- }
+ this.controller.onNewCandidates((value) -> {
+ if (!this.combo.isDisposed()) {
+ if (value != null) {
+ Object[] candidates = value.toArray();
+ for (int i = 0; i < candidates.length; i++) {
+ if (candidates[i] == null) {
+ candidates[i] = NO_VALUE;
}
- comboViewer.setInput(candidates);
- } else {
- comboViewer.setInput(null);
- }
- if (!combo.isEnabled()) {
- combo.setEnabled(true);
}
+ this.comboViewer.setInput(candidates);
+ } else {
+ this.comboViewer.setInput(null);
+ }
+ if (!this.combo.isEnabled()) {
+ this.combo.setEnabled(true);
}
}
});
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 21682b6b0..4dbb77ab1 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
@@ -22,7 +22,6 @@ import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.EEFControllersFactory;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFTextController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
@@ -38,7 +37,6 @@ import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
@@ -212,12 +210,9 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager {
public void aboutToBeShown() {
super.aboutToBeShown();
- this.modifyListener = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (!EEFTextLifecycleManager.this.container.isRenderingInProgress() && !updateInProgress.get()) {
- EEFTextLifecycleManager.this.isDirty = true;
- }
+ this.modifyListener = (event) -> {
+ if (!this.container.isRenderingInProgress() && !updateInProgress.get()) {
+ this.isDirty = true;
}
};
this.text.addModifyListener(this.modifyListener);
@@ -254,22 +249,19 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager {
this.text.addKeyListener(this.keyListener);
}
- this.controller.onNewValue(new IConsumer<Object>() {
- @Override
- public void apply(Object value) {
- if (!text.isDisposed()) {
- String display = ""; //$NON-NLS-1$
- if (value != null) {
- display = Util.firstNonNull(value.toString(), display);
- }
- if (!(text.getText() != null && text.getText().equals(display))) {
- text.setText(display);
- referenceValue = text.getText();
- }
- EEFTextLifecycleManager.this.setStyle();
- if (!text.isEnabled()) {
- text.setEnabled(true);
- }
+ this.controller.onNewValue((value) -> {
+ if (!text.isDisposed()) {
+ String display = ""; //$NON-NLS-1$
+ if (value != null) {
+ display = Util.firstNonNull(value.toString(), display);
+ }
+ if (!(text.getText() != null && text.getText().equals(display))) {
+ text.setText(display);
+ referenceValue = text.getText();
+ }
+ this.setStyle();
+ if (!text.isEnabled()) {
+ text.setEnabled(true);
}
}
});
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/RadioGroup.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/RadioGroup.java
index d8470eb33..11fd2ba9e 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/RadioGroup.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/RadioGroup.java
@@ -69,12 +69,7 @@ public class RadioGroup extends Composite {
this.setLayout(new GridLayout(numberOfColumns, true));
}
- addListener(SWT.Dispose, new Listener() {
- @Override
- public void handleEvent(Event event) {
- handleDispose(event);
- }
- });
+ this.addListener(SWT.Dispose, (event) -> this.handleDispose(event));
}
/**
@@ -155,9 +150,7 @@ public class RadioGroup extends Composite {
* The selection listener
*/
public void removeSelectionListener(SelectionListener listener) {
- for (Button button : buttons.values()) {
- button.removeSelectionListener(listener);
- }
+ buttons.values().forEach(button -> button.removeSelectionListener(listener));
}
/**
@@ -223,16 +216,14 @@ public class RadioGroup extends Composite {
* the index of the item to select
*/
public void select(int index) {
- buttons.get(Integer.valueOf(index)).setSelection(true);
+ this.buttons.get(Integer.valueOf(index)).setSelection(true);
}
/**
* Deselects all selected items in the receiver's list.
*/
public void deselectAll() {
- for (Button button : buttons.values()) {
- button.setSelection(false);
- }
+ this.buttons.values().forEach(button -> button.setSelection(false));
}
/**
@@ -242,9 +233,7 @@ public class RadioGroup extends Composite {
*/
@Override
public void dispose() {
- for (Button button : buttons.values()) {
- button.dispose();
- }
+ this.buttons.values().forEach(Button::dispose);
super.dispose();
}
@@ -256,8 +245,6 @@ public class RadioGroup extends Composite {
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- for (Button button : buttons.values()) {
- button.setEnabled(enabled);
- }
+ this.buttons.values().forEach(button -> button.setEnabled(enabled));
}
}
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFQuickFixPage.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFQuickFixPage.java
index ca9397ba9..21b6347c9 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFQuickFixPage.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFQuickFixPage.java
@@ -24,7 +24,6 @@ import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -168,30 +167,27 @@ public class EEFQuickFixPage extends WizardPage {
*/
public void performFinish(IProgressMonitor monitor) {
try {
- this.getWizard().getContainer().run(false, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
- progressMonitor.beginTask(Messages.EEFQuickFixWizard_applyQuickFix, 1);
- EEFQuickFixPage.this.getShell().getDisplay().readAndDispatch();
- if (progressMonitor.isCanceled()) {
- return;
- }
+ this.getWizard().getContainer().run(false, true, (progressMonitor) -> {
+ progressMonitor.beginTask(Messages.EEFQuickFixWizard_applyQuickFix, 1);
+ this.getShell().getDisplay().readAndDispatch();
+ if (progressMonitor.isCanceled()) {
+ return;
+ }
- ISelection selection = EEFQuickFixPage.this.quickFixesList.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- // Only one quick fix can be selected
- Object element = structuredSelection.getFirstElement();
- if (element instanceof EEFValidationFixDescription) {
- // Run the quick fix using the given eval
- EEFValidationFixDescription validationFix = (EEFValidationFixDescription) element;
- EAttribute expressionEAttribute = EefPackage.Literals.EEF_VALIDATION_FIX_DESCRIPTION__FIX_EXPRESSION;
- EEFQuickFixPage.this.eval.logIfBlank(expressionEAttribute).call(validationFix.getFixExpression());
- }
+ ISelection selection = this.quickFixesList.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ // Only one quick fix can be selected
+ Object element = structuredSelection.getFirstElement();
+ if (element instanceof EEFValidationFixDescription) {
+ // Run the quick fix using the given eval
+ EEFValidationFixDescription validationFix = (EEFValidationFixDescription) element;
+ EAttribute expressionEAttribute = EefPackage.Literals.EEF_VALIDATION_FIX_DESCRIPTION__FIX_EXPRESSION;
+ this.eval.logIfBlank(expressionEAttribute).call(validationFix.getFixExpression());
}
-
- progressMonitor.worked(1);
}
+
+ progressMonitor.worked(1);
});
} catch (InvocationTargetException e) {
EEFIdeUiPlugin.getPlugin().error(e.getMessage(), e);
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFValidationMessagesPage.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFValidationMessagesPage.java
index cf7ea5cd6..732767be1 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFValidationMessagesPage.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/quickfix/EEFValidationMessagesPage.java
@@ -16,9 +16,7 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.WizardPage;
@@ -107,30 +105,26 @@ public class EEFValidationMessagesPage extends WizardPage {
this.validationMessagesList.setContentProvider(new EEFValidationMessagesTableContentProvider());
this.validationMessagesList.setLabelProvider(new EEFValidationMessagesTableLabelProvider());
this.validationMessagesList.setComparator(new EEFValidationMessagesTableComparator());
- this.validationMessagesList.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- // Sets the new selected message
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object element = structuredSelection.getFirstElement();
- if (element instanceof IMessage) {
- EEFValidationMessagesPage.this.selectedMessage = (IMessage) element;
- }
+ this.validationMessagesList.addSelectionChangedListener((event) -> {
+ // Sets the new selected message
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object element = structuredSelection.getFirstElement();
+ if (element instanceof IMessage) {
+ this.selectedMessage = (IMessage) element;
}
+ }
- if (EEFValidationMessagesPage.this.selectedMessage.getKey() instanceof EEFValidationRuleDescription) {
- EEFValidationRuleDescription validationRuleDescription = (EEFValidationRuleDescription) EEFValidationMessagesPage.this.selectedMessage
- .getKey();
- if (validationRuleDescription.getFixes().size() == 0) {
- EEFValidationMessagesPage.this.setMessage(Messages.EEFQuickFixWizard_noQuickFixAvailable, IMessageProvider.ERROR);
- } else {
- EEFValidationMessagesPage.this.setMessage(null);
- }
+ if (this.selectedMessage.getKey() instanceof EEFValidationRuleDescription) {
+ EEFValidationRuleDescription validationRuleDescription = (EEFValidationRuleDescription) this.selectedMessage.getKey();
+ if (validationRuleDescription.getFixes().size() == 0) {
+ this.setMessage(Messages.EEFQuickFixWizard_noQuickFixAvailable, IMessageProvider.ERROR);
+ } else {
+ this.setMessage(null);
}
- EEFValidationMessagesPage.this.setPageComplete(true);
}
+ this.setPageComplete(true);
});
FormData listData = new FormData();

Back to the top