Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-11-24 11:20:54 +0000
committerGerrit Code Review @ Eclipse.org2016-11-29 10:57:50 +0000
commitb3141df23ca644573f8b2813ad8859722d418bd9 (patch)
tree6db261c6f918988a7117bfe93731af4ca17f0723 /plugins/infra/core
parent6d4f41d7e479bfa607ffde18b16fe8ebdae561c2 (diff)
downloadorg.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.tar.gz
org.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.tar.xz
org.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.zip
Bug 496905: [Diagram][ModelExplorer][Table][Dialog] Papyrus must integrate
the internationalization feature provided by UML. https://bugs.eclipse.org/bugs/show_bug.cgi?id=496905 Commit of infra for internationalization. Change-Id: I1b1859bf111e1ef7a7522212fbe639cf2bd13890 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/infra/core')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java5
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java28
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java10
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java124
6 files changed, 160 insertions, 11 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
index be0b3be7e36..8725c017613 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
@@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.emf.workspace;bundle-version="[1.5.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.2.0.qualifier
+Bundle-Version: 2.3.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.infra.core.Activator
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml
index 2524dc5f316..5511a52363f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.core</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
index 884a997c7e4..2f2eaf40748 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
@@ -9,6 +9,7 @@
* Contributors:
* LIFL - Initial API and implementation
* Christian W. Damus - bugs 485220, 496299
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.resource;
@@ -46,8 +47,10 @@ public abstract class AbstractModelWithSharedResource<T extends EObject> extends
/**
* Model kind.
+ *
+ * @since 2.0
*/
- private ModelKind modelKind;
+ protected ModelKind modelKind;
/**
*
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java
index 46a6003edc5..9b2709a4e9a 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Christian W. Damus - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
@@ -89,16 +90,29 @@ public class AdjunctResourceModelSnippet implements IModelSnippet {
if (converter.exists(adjunctURI, Collections.emptyMap())) {
// Best effort load. This must not interfere with other
// resource set operations
- try {
- resourceSet.getResource(adjunctURI, true);
- } catch (Exception e) {
- Activator.log.error(
- String.format("Failed to load %s resource", model.getModelFileExtension()), //$NON-NLS-1$
- e);
- }
+ loadResource(model, resourceSet, adjunctURI);
}
}
}
}
+ /**
+ * This allows to load the model.
+ *
+ * @param model The {@link EMFLogicalModel}.
+ * @param resourceSet The resource set.
+ * @param adjunctURI The adjunct URI.
+ *
+ * @since 2.3
+ */
+ protected void loadResource(final EMFLogicalModel model, final ResourceSet resourceSet, final URI adjunctURI){
+ try {
+ resourceSet.getResource(adjunctURI, true);
+ } catch (final Exception e) {
+ Activator.log.error(
+ String.format("Failed to load %s resource", model.getModelFileExtension()), //$NON-NLS-1$
+ e);
+ }
+ }
+
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
index 85a7c146bca..b66c3aa0526 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
@@ -17,6 +17,7 @@
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998
* Christian W. Damus - bugs 436998, 468030, 485220
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.resource;
@@ -853,7 +854,14 @@ public class ModelSet extends ResourceSetImpl {
return result;
}
- protected boolean deleteResource(URI uri) {
+ /**
+ * This allows to delete a resource from the uri.
+ *
+ * @param uri The uri of the resource to delete.
+ * @return <code>true</code> if the resource is deleted, <code>false</code> otherwise.
+ * @since 2.3
+ */
+ public boolean deleteResource(final URI uri) {
boolean result = false;
try {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java
new file mode 100644
index 00000000000..635d3388e7f
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.resource;
+
+import org.eclipse.core.internal.preferences.AbstractScope;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+
+/**
+ * This papyrus scope for the papyrus project preference store.
+ * This need to manage the preference for the papyrus project with the papyrus project name (to retrieve the correct name).
+ *
+ * @since 2.2
+ */
+@SuppressWarnings("restriction")
+public class PapyrusProjectScope extends AbstractScope {
+
+ /**
+ * String constant (value of <code>"papyrusProject"</code>) used for the scope name for this preference scope.
+ */
+ public static final String SCOPE = "papyrusProject"; //$NON-NLS-1$
+
+ /**
+ * The papyrus project name.
+ */
+ private String papyrusProjectName;
+
+ /**
+ * The context project.
+ */
+ private IProject context;
+
+ /**
+ * Constructor.
+ *
+ * @param project
+ * The project.
+ * @param papyrusProjectName
+ * The name of the '.di' file.
+ */
+ public PapyrusProjectScope(final IProject project, final String papyrusProjectName) {
+ this.context = project;
+ this.papyrusProjectName = papyrusProjectName;
+ }
+
+ /**
+ * Default path hierarchy for nodes is /<scope>/<qualifier>.
+ *
+ * @param qualifier The qualifier.
+ * @return The path hierarchy.
+ */
+ @Override
+ public IEclipsePreferences getNode(final String qualifier) {
+ if (qualifier == null)
+ throw new IllegalArgumentException();
+ final StringBuilder node = new StringBuilder(context.getName());
+ node.append("/"); //$NON-NLS-1$
+ node.append(papyrusProjectName);
+ return (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(SCOPE).node(node.toString()).node(qualifier);
+ }
+
+ /**
+ * The papyrus scope name.
+ *
+ * @return The papyrus scope name.
+ */
+ @Override
+ public String getName() {
+ return SCOPE;
+ }
+
+ /**
+ * The location of the scope.
+ *
+ * @return The location of the scope.
+ */
+ @Override
+ public IPath getLocation() {
+ // This must not be save
+ return null;
+ }
+
+ /**
+ * This allows to determinate if the object in parameter is equals to the current.
+ *
+ * @param obj The object to compare.
+ * @return <code>true</code> if this is equals, <code>false</code> otherwise.
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (!(obj instanceof PapyrusProjectScope))
+ return false;
+ PapyrusProjectScope other = (PapyrusProjectScope) obj;
+ return context.equals(other.context) && papyrusProjectName.equals(other.papyrusProjectName);
+ }
+
+ /**
+ * This allows to define the int hash code.
+ *
+ * @return The int representing the hascode.
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() + context.getFullPath().hashCode() + "/".hashCode() + papyrusProjectName.hashCode(); //$NON-NLS-1$
+ }
+
+}

Back to the top