aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarwa rostren2014-01-30 10:26:26 (EST)
committerEd Willink2014-03-06 10:07:41 (EST)
commit179f1d8962ae3bd8ab28373a301395e045312f50 (patch)
tree6c1bf51e07d4b123eb47b7068dc07162d312289d
parent98a24445da7412c1d87c872dcbd6a12f58df3f2d (diff)
downloadorg.eclipse.ocl-179f1d8962ae3bd8ab28373a301395e045312f50.zip
org.eclipse.ocl-179f1d8962ae3bd8ab28373a301395e045312f50.tar.gz
org.eclipse.ocl-179f1d8962ae3bd8ab28373a301395e045312f50.tar.bz2
[425799] Add refresh Action to the view
This forces the view content refresh. It can be used when loading new resources to the opened model. Change-Id: I8f038bb99cc049a3a59e901b8ad2ed6fe2104a0e Signed-off-by: marwa rostren <mrostren@obeo.fr>
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/icons/refresh.gifbin0 -> 327 bytes
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/actions/ForceValidityViewRefreshAction.java50
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.java6
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.properties4
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/view/ValidityView.java4
-rw-r--r--emfv/org.eclipse.ocl.examples.emf.validation.validity/src/org/eclipse/ocl/examples/emf/validation/validity/manager/ValidityManager.java11
6 files changed, 73 insertions, 2 deletions
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/icons/refresh.gif b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/icons/refresh.gif
new file mode 100644
index 0000000..3ca04d0
--- /dev/null
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/icons/refresh.gif
Binary files differ
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/actions/ForceValidityViewRefreshAction.java b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/actions/ForceValidityViewRefreshAction.java
new file mode 100644
index 0000000..24a33f8
--- /dev/null
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/actions/ForceValidityViewRefreshAction.java
@@ -0,0 +1,50 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2014 Obeo and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *
+ * </copyright>
+ */
+package org.eclipse.ocl.examples.emf.validation.validity.ui.actions;
+
+import java.net.URL;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ocl.examples.emf.validation.validity.ui.messages.ValidationDebugMessages;
+import org.eclipse.ocl.examples.emf.validation.validity.ui.plugin.ValidityUIPlugin;
+import org.eclipse.ocl.examples.emf.validation.validity.ui.view.IDEValidityManager;
+import org.eclipse.ocl.examples.emf.validation.validity.ui.view.ValidityView;
+
+public class ForceValidityViewRefreshAction extends Action {
+ protected final @NonNull
+ IDEValidityManager validityManager;
+
+ protected final @NonNull
+ ValidityView validityView;
+ public ForceValidityViewRefreshAction(
+ @NonNull IDEValidityManager validityManager, @NonNull ValidityView validityView) {
+ super(ValidationDebugMessages.ValidityView_Action_ForceRefresh_Title);
+ this.validityManager = validityManager;
+ this.validityView = validityView;
+ setToolTipText(ValidationDebugMessages.ValidityView_Action_ForceRefresh_ToolTipText);
+ URL image = (URL) ValidityUIPlugin.INSTANCE
+ .getImage(ValidationDebugMessages.ValidityView_Action_ForceRefresh_ImageLocation);
+ setImageDescriptor(ImageDescriptor.createFromURL(image));
+ }
+
+ @Override
+ public void run() {
+ validityManager.forceRefresh();
+ validityView.getConstrainingNodesViewer().refresh();
+ validityView.getValidatableNodesViewer().refresh();
+ }
+}
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.java b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.java
index 6cc42b8..2280a74 100644
--- a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.java
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.java
@@ -38,7 +38,11 @@ public class ValidationDebugMessages
public static String ValidityView_Action_ShowInEditor_Title;
public static String ValidityView_Action_ShowInEditor_ToolTipText;
public static String ValidityView_Action_ShowInEditor_ImageLocation;
-
+
+ public static String ValidityView_Action_ForceRefresh_Title;
+ public static String ValidityView_Action_ForceRefresh_ImageLocation;
+ public static String ValidityView_Action_ForceRefresh_ToolTipText;
+
public static String ValidityView_Action_RunValidity_Title;
public static String ValidityView_Action_RunValidity_ImageLocation;
public static String ValidityView_Action_RunValidity_ToolTipText;
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.properties b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.properties
index 3cf592f..130ac6f 100644
--- a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.properties
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/messages/ValidationDebugMessages.properties
@@ -20,6 +20,10 @@ ValidityView_Action_ShowInEditor_Title = Show In Editor
ValidityView_Action_ShowInEditor_ImageLocation = show.gif
ValidityView_Action_ShowInEditor_ToolTipText = Show Model Element In Editor
+ValidityView_Action_ForceRefresh_Title = Refresh View
+ValidityView_Action_ForceRefresh_ImageLocation = refresh.gif
+ValidityView_Action_ForceRefresh_ToolTipText = Refresh the view content
+
ValidityView_Action_RunValidity_Title = Validate Selection
ValidityView_Action_RunValidity_ImageLocation = run_exc.gif
ValidityView_Action_RunValidity_ToolTipText = Validate the selected Constraints on the selected Model Elements
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/view/ValidityView.java b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/view/ValidityView.java
index a1c1d01..a5f719d 100644
--- a/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/view/ValidityView.java
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity.ui/src/org/eclipse/ocl/examples/emf/validation/validity/ui/view/ValidityView.java
@@ -69,6 +69,7 @@ import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.EnableAllNode
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.ExpandAllNodesAction;
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.ExportValidationResultAction;
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.FilterValidationResultAction;
+import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.ForceValidityViewRefreshAction;
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.LockValidatableNodesAction;
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.RunValidityAction;
import org.eclipse.ocl.examples.emf.validation.validity.ui.actions.ShowElementInEditorAction;
@@ -172,6 +173,7 @@ public class ValidityView extends ViewPart implements ISelectionListener
private Action collapseAllNodesAction;
private Action runValidationAction;
private Action lockValidatableNodesAction;
+ private Action forceValidityViewRefreshAction;
private Action exportValidationResultAction;
private IAction filterValidationResultAction;
@@ -585,6 +587,7 @@ public class ValidityView extends ViewPart implements ISelectionListener
manager.add(collapseAllNodesAction);
manager.add(new Separator());
manager.add(lockValidatableNodesAction);
+ manager.add(forceValidityViewRefreshAction);
manager.add(runValidationAction);
manager.add(new Separator());
manager.add(filterValidationResultAction);
@@ -665,6 +668,7 @@ public class ValidityView extends ViewPart implements ISelectionListener
private void makeActions() {
lockValidatableNodesAction = new LockValidatableNodesAction();
+ forceValidityViewRefreshAction = new ForceValidityViewRefreshAction(validityManager, this);
showValidatableElementInEditorAction = new ShowElementInEditorAction(validityManager, getValidatableNodesViewer());
showConstrainingElementInEditorAction = new ShowElementInEditorAction(validityManager, getConstrainingNodesViewer());
diff --git a/emfv/org.eclipse.ocl.examples.emf.validation.validity/src/org/eclipse/ocl/examples/emf/validation/validity/manager/ValidityManager.java b/emfv/org.eclipse.ocl.examples.emf.validation.validity/src/org/eclipse/ocl/examples/emf/validation/validity/manager/ValidityManager.java
index 1fc8217..286a3b5 100644
--- a/emfv/org.eclipse.ocl.examples.emf.validation.validity/src/org/eclipse/ocl/examples/emf/validation/validity/manager/ValidityManager.java
+++ b/emfv/org.eclipse.ocl.examples.emf.validation.validity/src/org/eclipse/ocl/examples/emf/validation/validity/manager/ValidityManager.java
@@ -140,6 +140,8 @@ public class ValidityManager
protected final @SuppressWarnings("null")@NonNull Map<Object, Object> context = Diagnostician.INSTANCE.createDefaultContext();
private @Nullable ValidityModel model = null;
protected @Nullable ResultSet lastResultSet = null;
+ private boolean forceRefresh = false;
+ private @Nullable Object lastInput = null;
public ValidityManager() {
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
@@ -406,6 +408,12 @@ public class ValidityManager
return new ValidatableURI(uri);
}
+ public void forceRefresh() {
+ this.forceRefresh = true;
+ setInput(lastInput, new BasicMonitor());
+ this.forceRefresh = false;
+ }
+
public void setInput(Object newInput) {
setInput(newInput, new BasicMonitor());
}
@@ -417,6 +425,7 @@ public class ValidityManager
Resource selectedResource = null;
EObject selectedObject = null;
newResources.clear();
+ lastInput = newInput;
if (newInput == null) {
oldResources.clear();
@@ -462,7 +471,7 @@ public class ValidityManager
return;
}
- if (!oldResources.isEmpty() && oldResources.equals(newResources)) {
+ if (!forceRefresh && !oldResources.isEmpty() && oldResources.equals(newResources)) {
return;
}