Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-06-03 09:55:39 -0400
committerGerrit Code Review @ Eclipse.org2014-06-03 09:55:39 -0400
commitabf5a7c7209b1fb9732e97fe4e7201caf2317e04 (patch)
tree653889a9806935c6ac2c87fc9500fc24a5d73504
parentdf2afc7cae8444c6dcf5fc768f001e0ec1deea5c (diff)
parent7ec45c332917dd5bbfbe537a166474b921d48c69 (diff)
downloadorg.eclipse.papyrus-abf5a7c7209b1fb9732e97fe4e7201caf2317e04.tar.gz
org.eclipse.papyrus-abf5a7c7209b1fb9732e97fe4e7201caf2317e04.tar.xz
org.eclipse.papyrus-abf5a7c7209b1fb9732e97fe4e7201caf2317e04.zip
Merge "417409: [Performances - Properties view] Delay in UI when reorganizing diagram layout. https://bugs.eclipse.org/bugs/show_bug.cgi?id=417409"
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngine.java7
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngineListener.java30
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintsChangedEvent.java43
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/DefaultConstraintEngine.java29
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ModelRuleConstraintEngine.java15
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java9
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ViewConstraintEngineImpl.java6
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java20
8 files changed, 153 insertions, 6 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngine.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngine.java
index b29a1299e8c..fcbc89d7c82 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngine.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngine.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 417409
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.constraints.runtime;
@@ -49,4 +51,7 @@ public interface ConstraintEngine<E extends DisplayUnit> {
*/
public void refresh();
+ void addConstraintEngineListener(ConstraintEngineListener listener);
+
+ void removeConstraintEngineListener(ConstraintEngineListener listener);
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngineListener.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngineListener.java
new file mode 100644
index 00000000000..65f0e5d70e8
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintEngineListener.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2014 CEA 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:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.constraints.runtime;
+
+import java.util.EventListener;
+
+
+/**
+ * Protocol for notifications of changes in the constraint listener that may affect its clients.
+ */
+public interface ConstraintEngineListener extends EventListener {
+
+ /**
+ * Notifies listeners that the engine's constraints have changed, so any remembered calculation results may need to be recomputed.
+ *
+ * @param event
+ * the notification object
+ */
+ void constraintsChanged(ConstraintsChangedEvent event);
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintsChangedEvent.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintsChangedEvent.java
new file mode 100644
index 00000000000..9cd8c914c31
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintsChangedEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014 CEA 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:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.constraints.runtime;
+
+import java.util.EventObject;
+
+
+/**
+ * Notification object for the {@linkplain ConstraintEngineListener#constraintsChanged(ConstraintsChangedEvent) constraints-changed event}.
+ */
+public class ConstraintsChangedEvent extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Initializes me with my originating constraint engine.
+ *
+ * @param source
+ * my source
+ */
+ public ConstraintsChangedEvent(ConstraintEngine<?> source) {
+ super(source);
+ }
+
+ /**
+ * Queries the constraint engine that generated this event.
+ *
+ * @return the source constraint engine
+ */
+ public ConstraintEngine<?> getConstraintEngine() {
+ return (ConstraintEngine<?>)getSource();
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/DefaultConstraintEngine.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/DefaultConstraintEngine.java
index e81eeafcb40..b6a0716a5d0 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/DefaultConstraintEngine.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/DefaultConstraintEngine.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 417409
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.constraints.runtime;
@@ -15,6 +17,7 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.constraints.Activator;
@@ -31,6 +34,8 @@ import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
*/
public abstract class DefaultConstraintEngine<E extends DisplayUnit> implements ConstraintEngine<E> {
+ private final ListenerList listeners = new ListenerList(ListenerList.IDENTITY);
+
/**
* The constraints instantiated by this Engine
*/
@@ -127,4 +132,26 @@ public abstract class DefaultConstraintEngine<E extends DisplayUnit> implements
}
return displayUnits;
}
+
+ public void addConstraintEngineListener(ConstraintEngineListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeConstraintEngineListener(ConstraintEngineListener listener) {
+ listeners.remove(listener);
+ }
+
+ protected void fireConstraintsChanged() {
+ if(!listeners.isEmpty()) {
+ Object[] toNotify = listeners.getListeners();
+ ConstraintsChangedEvent event = new ConstraintsChangedEvent(this);
+ for(int i = 0; i < toNotify.length; i++) {
+ try {
+ ((ConstraintEngineListener)toNotify[i]).constraintsChanged(event);
+ } catch (Exception e) {
+ Activator.log.error("Uncaught exception in constraints-changed listener.", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ModelRuleConstraintEngine.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ModelRuleConstraintEngine.java
index 0f589bde14e..eb4675dba26 100644
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ModelRuleConstraintEngine.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ModelRuleConstraintEngine.java
@@ -1,6 +1,16 @@
-/**
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 417409
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.infra.viewpoints.policy;
import java.util.ArrayList;
@@ -36,6 +46,7 @@ public class ModelRuleConstraintEngine extends DefaultConstraintEngine<ModelRule
*/
public void refresh() {
modelRule2Constraints.clear();
+ fireConstraintsChanged();
}
public boolean matchesRule(ModelRule rule, EObject element) {
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
index c057263f513..dc5360b25b5 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
@@ -138,6 +138,15 @@ public class DefaultDisplayEngine implements DisplayEngine {
public void dispose() {
disposeControls();
}
+
+ /**
+ * Invalidates any caches that I may have because the displayed property UI contexts, constraints, or views have
+ * changed in some way.
+ */
+ public void invalidate() {
+ // Forget the cached XML property definitions because they may have changed
+ xmlCache = null;
+ }
public Control createSection(Composite parent, Section section, DataSource source) {
if(source == null) {
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ViewConstraintEngineImpl.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ViewConstraintEngineImpl.java
index 1dd6e927198..848803eae39 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ViewConstraintEngineImpl.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ViewConstraintEngineImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 417409
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.runtime;
@@ -34,6 +36,8 @@ public class ViewConstraintEngineImpl extends DefaultConstraintEngine<View> impl
for(Context context : contexts) {
addContext(context);
}
+
+ fireConstraintsChanged();
}
public void addContext(final Context context) {
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
index d2aa3ccc120..5ff47ffabdd 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 417409
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.xwt;
@@ -23,6 +25,8 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.papyrus.infra.constraints.runtime.ConstraintEngineListener;
+import org.eclipse.papyrus.infra.constraints.runtime.ConstraintsChangedEvent;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.View;
import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
@@ -53,6 +57,20 @@ public class XWTTabDescriptorProvider implements ITabDescriptorProvider {
private final Map<IWorkbenchPart, DisplayEngine> displays = new HashMap<IWorkbenchPart, DisplayEngine>();
+
+ public XWTTabDescriptorProvider() {
+ ConfigurationManager.getInstance().getConstraintEngine().addConstraintEngineListener(new ConstraintEngineListener() {
+
+ public void constraintsChanged(ConstraintsChangedEvent event) {
+ // Purge the caches of all display engines because the XML view descriptions
+ // they cached are out of date
+ for(DisplayEngine next : displays.values()) {
+ ((DefaultDisplayEngine)next).invalidate();
+ }
+ }
+ });
+ }
+
private DisplayEngine getDisplay(final IWorkbenchPart part) {
if(!displays.containsKey(part)) {
displays.put(part, new DefaultDisplayEngine());

Back to the top