Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-07-17 11:02:52 +0000
committerCamille Letavernier2013-07-17 11:02:52 +0000
commit760b53a67156cc8dec462b48d2f4cb1863c29161 (patch)
treed835ac2efa6de795320372b32735d7d248290824 /extraplugins/uml
parentffc76d52eaa000c46a7638eea089f800b5513d83 (diff)
downloadorg.eclipse.papyrus-760b53a67156cc8dec462b48d2f4cb1863c29161.tar.gz
org.eclipse.papyrus-760b53a67156cc8dec462b48d2f4cb1863c29161.tar.xz
org.eclipse.papyrus-760b53a67156cc8dec462b48d2f4cb1863c29161.zip
408491: Papyrus shall enable to easily switch between local and
registered profiles. https://bugs.eclipse.org/bugs/show_bug.cgi?id=408491 Initial contribution
Diffstat (limited to 'extraplugins/uml')
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java
index 376ff1db5c4..f5be935c83d 100644
--- a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java
@@ -26,6 +26,7 @@ import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
@@ -170,7 +171,7 @@ public class EditProfileApplicationAction extends ActionDelegate implements IAct
public void run(IAction action) {
if(files != null) {
Iterator<IFile> filesIt = files.iterator();
- IFile file = filesIt.next();
+ final IFile file = filesIt.next();
ResourceSet resourceSet = new ResourceSetImpl();
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
@@ -183,7 +184,7 @@ public class EditProfileApplicationAction extends ActionDelegate implements IAct
final IDocument doc = buffer.getDocument();
final FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(doc);
final MultiTextEdit multiEdit = new MultiTextEdit();
- Resource umlResource = WSFileUtil.loadResource(file.getFullPath().toString(), resourceSet);
+ final Resource umlResource = WSFileUtil.loadResource(file.getFullPath().toString(), resourceSet);
if(umlResource.getContents().isEmpty()) {
// The root doesn't exist.
try {
@@ -217,20 +218,22 @@ public class EditProfileApplicationAction extends ActionDelegate implements IAct
Object[] profiles = dialog.getResult();
for(int i = 0; i < profiles.length; i++) {
if(profiles[i] instanceof Profile) {
- // TODO Auto-generated method stub
-
- String localProfileURI = ((Profile)profiles[i]).eResource().getURI().toString();
-
-
- //the applied local profile in the xmi file has an uri that is relative to the workspace,
- //so adapt the uri that is in the preferences to fit in this format
- localProfileURI = localProfileURI.replace("platform:/resource/", "../"); //$NON-NLS-1$ //$NON-NLS-2$
+ //Absolute profile URI (platform:/resource/)
+ URI localProfileURI = ((Profile)profiles[i]).eResource().getURI();
+
+ //Absolute model URI (platform:/resource)
+ IPath filePath = file.getFullPath();
+ URI modelURI = umlResource.getURI();
+
+ //Relative profile URI
+ URI relativeProfileURI = localProfileURI.deresolve(modelURI);
String installedProfileURI = findCorrespondingInstalledProfile((Profile)profiles[i]);
if(installedProfileURI != null) {
try {
- WSFileUtil.replaceString(localProfileURI, installedProfileURI, adapter, doc, 0, multiEdit);
+ WSFileUtil.replaceString(localProfileURI.toString(), installedProfileURI, adapter, doc, 0, multiEdit);
+ WSFileUtil.replaceString(relativeProfileURI.toString(), installedProfileURI, adapter, doc, 0, multiEdit);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();

Back to the top