Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-07-15 15:55:30 +0000
committerGerrit Code Review @ Eclipse.org2016-07-16 12:31:58 +0000
commit2fb82a8d63e5d5954e77c74f765731bc61ce0eb8 (patch)
tree17d2ec326ab470a88ef8a6fc659b6a38f45d0ee7 /plugins/infra/core
parent4c2ccf24adcf0da61e78f4be62f61def2362bb4e (diff)
downloadorg.eclipse.papyrus-2fb82a8d63e5d5954e77c74f765731bc61ce0eb8.tar.gz
org.eclipse.papyrus-2fb82a8d63e5d5954e77c74f765731bc61ce0eb8.tar.xz
org.eclipse.papyrus-2fb82a8d63e5d5954e77c74f765731bc61ce0eb8.zip
Bug 461709: [Performances] Opening a model for the first time in a new workspace causes all dependencies to be resolved
https://bugs.eclipse.org/bugs/show_bug.cgi?id=461709 When creating the *.sash resource initially, create it from a template resource so that it the SashWindowsMngr isn't added explicitly after the fact, which triggers many content adapters in the ModelSet including the ProxyModificationTrackingAdapter, which resolves all proxies in the resource set. Change-Id: Iee75d148f342b9f3c12e986eb88763294cbe6b6a (cherry picked from commit 69247471827b1fa1b11499983a771d048cb92d94)
Diffstat (limited to 'plugins/infra/core')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties23
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java48
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/templates/model.sash8
3 files changed, 73 insertions, 6 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties b/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
index a192f915df4..f023f068a02 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
@@ -1,6 +1,25 @@
#
-#Mon Sep 12 09:29:37 CEST 2011
-bin.includes=META-INF/,.,plugin.xml,schema/,plugin.properties,.options,about.ini,about.properties,about.html
+# Copyright (c) 2009, 2016 LIFL, CEA LIST, Christian W. Damus, 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:
+# LIFL - Initial API and implementation
+# Christian W. Damus - bug 461709
+#
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ schema/,\
+ plugin.properties,\
+ .options,\
+ about.ini,\
+ about.properties,\
+ about.html,\
+ templates/
output..=bin/
src.includes = about.html
source..=src/
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java
index 9b356bb68c9..800f7a9e981 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java
@@ -10,13 +10,16 @@
* Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Rewrite the sash model - store in the plugin's PreferenceStore (Bug 429239)
* Christian W. Damus (CEA) - bugs 429242, 436468
- * Christian W. Damus - bugs 434983, 469188, 485220
+ * Christian W. Damus - bugs 434983, 469188, 485220, 461709
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.resource.sasheditor;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
import java.util.Collections;
import java.util.Map;
@@ -38,6 +41,7 @@ import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
import com.google.common.base.Objects;
+import com.google.common.io.Resources;
/**
* <p>
@@ -206,23 +210,59 @@ public class SashModel extends EMFLogicalModel implements IModel {
try {
super.loadModel(sashModelURI.trimFileExtension());
} catch (Exception ex) {
- createModel(sashModelURI.trimFileExtension());
+ // Unload it and try again by creating it
+ Resource resource = getModelManager().getResource(sashModelURI, false);
+ if (resource != null) {
+ resource.unload();
+ resource.getResourceSet().getResources().remove(resource);
+ }
+
+ // This will create the private sash model if that's what we need
+ createModel(uriWithoutExtension);
}
if (resource == null) {
- createModel(sashModelURI.trimFileExtension());
+ // This will create the private sash model if that's what we need
+ createModel(uriWithoutExtension);
}
}
@Override
public void createModel(URI uriWithoutExtension) {
if (isLegacy(uriWithoutExtension)) {
- super.createModel(getSashModelStoreURI(uriWithoutExtension).trimFileExtension());
+ // http://eclip.se/461709
+ // Initialize the workspace-private sash model from our template
+ // to avoid resolving all proxies in the ProxyModificationTrackingAdapter
+ URI sashURI = getSashModelStoreURI(uriWithoutExtension);
+ try {
+ intantiateTemplate(sashURI);
+ loadModel(uriWithoutExtension);
+ } catch (IOException e) {
+ // Fall back to the default (pre-461709) strategy
+ Activator.log.error("Failed to initialize workspace private sash model", e); //$NON-NLS-1$
+ super.createModel(sashURI.trimFileExtension());
+ }
} else {
super.createModel(uriWithoutExtension);
}
}
+ /**
+ * Intantiates the sash resource template on the given URI.
+ *
+ * @param sashResourceURI
+ * the new sash resource URI
+ *
+ * @throws IOException
+ * on failure to copy the template to this URI for any reason
+ */
+ void intantiateTemplate(URI sashResourceURI) throws IOException {
+ try (OutputStream output = getModelManager().getURIConverter().createOutputStream(sashResourceURI)) {
+ URL template = Activator.getDefault().getBundle().getEntry("templates/model.sash"); //$NON-NLS-1$
+ Resources.copy(template, output);
+ }
+ }
+
@Override
public void setModelURI(URI uriWithoutExtension) {
URI oldPrivateURI = getPrivateResourceURI();
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/templates/model.sash b/plugins/infra/core/org.eclipse.papyrus.infra.core/templates/model.sash
new file mode 100644
index 00000000000..8ddff4f06bf
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/templates/model.sash
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0" restoreActivePage="true">
+ <windows>
+ <children xsi:type="di:TabFolder"/>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>

Back to the top