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/ui
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/ui')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java33
2 files changed, 31 insertions, 5 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF
index 97e65ebedbb..223f3ffe63a 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.6.0,2.0.0)",
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java
index 05e987f060b..72813b1919f 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Benoit Maggi benoit.maggi@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
@@ -41,6 +42,7 @@ import org.eclipse.papyrus.infra.emf.resource.DependencyManagementHelper;
import org.eclipse.papyrus.infra.emf.resource.MoveFileURIReplacementStrategy;
import org.eclipse.papyrus.infra.emf.resource.RestoreDependencyHelper;
import org.eclipse.papyrus.infra.emf.utils.ResourceUtils;
+import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils;
import org.eclipse.papyrus.infra.onefile.internal.ui.Activator;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -83,9 +85,8 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper
destinationPaths[i] = destination.append(source.getName());
IPath relativSourcePath = source.getFullPath();
String sourceFileName = relativSourcePath.removeFileExtension().lastSegment();
- if (sourceFileName.equals(oldName)) {
- String fileExtension = relativSourcePath.getFileExtension();
- destinationPaths[i] = relativSourcePath.removeLastSegments(1).append(newName).addFileExtension(fileExtension);
+ if (!oldName.isEmpty() && sourceFileName.startsWith(oldName)) {
+ destinationPaths[i] = getDestinationPath(relativSourcePath, newName, oldName);
} else {
oldName = sourceFileName;
if (workspace.getRoot().exists(destinationPaths[i]) && destinationPaths[i].getFileExtension().equals(DiModel.MODEL_FILE_EXTENSION)) {
@@ -111,7 +112,28 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper
return true;
}
+ /**
+ * Get the new destination path for the current relative source path.
+ *
+ * @param relativeSourcePath
+ * The relative source path.
+ * @param newName
+ * The new name to set.
+ * @param oldName
+ * The old name.
+ * @return The destination path.
+ */
+ public IPath getDestinationPath(final IPath relativeSourcePath, final String newName, final String oldName) {
+ final String fileExtension = relativeSourcePath.getFileExtension();
+ // Get the source file name
+ final String sourceFileName = relativeSourcePath.removeFileExtension().lastSegment();
+ // Replace the oldName by the newName
+ final String destinationFileName = sourceFileName.replace(oldName, newName);
+ // Retrieve the last segment and append the new one with the file extension
+ return relativeSourcePath.removeLastSegments(1).append(destinationFileName).addFileExtension(fileExtension);
+ }
+
/*
* (non-Javadoc)
*
@@ -222,7 +244,10 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper
for (Entry<URI, URI> oneInternalCopyMapping : constructInternalMapping.entrySet()) {
DependencyManagementHelper.updateDependencies(oneInternalCopyMapping.getKey(), oneInternalCopyMapping.getValue(), resource);
}
- resource.save(ResourceUtils.getSaveOptions());
+ // Don't save the resource properties, the model resource manage it at create model call
+ if(!resource.getURI().fileExtension().equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)){
+ resource.save(ResourceUtils.getSaveOptions());
+ }
IPath fullPath = copyResources.getFullPath();
Resource sashResource = null;

Back to the top