Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java')
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java114
1 files changed, 57 insertions, 57 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java
index 382f07a1e..aec88e5d3 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/ImportModelAssist.java
@@ -1,57 +1,57 @@
-package org.eclipse.etrice.core.ui.contentassist;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.etrice.core.room.util.RelativePathHelpers;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider;
-import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
-import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
-
-public class ImportModelAssist {
-
- public static void addPaths(final AbstractContentProposalProvider provider, final ContentAssistContext context,
- final ICompletionProposalAcceptor acceptor, final String extension) {
- final IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getFullPath();
- IPath modelPath = new Path(context.getRootModel().eResource().getURI().toPlatformString(false));
- modelPath = ResourcesPlugin.getWorkspace().getRoot().getFile(modelPath).getLocation();
- final URI modelURI = URI.createFileURI(modelPath.toOSString()).trimSegments(1);
- IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
-
- @Override
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (proxy.getType() != IResource.FILE)
- return true;
-
- if (proxy.getName().endsWith(extension)) {
- IPath relModelPath = proxy.requestFullPath();
- relModelPath = ResourcesPlugin.getWorkspace().getRoot().getFile(relModelPath).getLocation();
- URI relURI = URI.createFileURI(relModelPath.toOSString());
- String relPath = RelativePathHelpers.getRelativePath(modelURI, relURI, true);
- if (relPath==null)
- relPath = "file:/"+(relURI.toFileString().replaceAll("\\\\", "/"));
- IPath relWorkspacePath = proxy.requestFullPath().makeRelativeTo(rootPath);
- String proposal = "\"" + relPath + "\"";
- String displayString = relModelPath.lastSegment() + " - "
- + relWorkspacePath;
- acceptor.accept(provider.createCompletionProposal(proposal,
- new StyledString(displayString), null, context));
- }
- return false;
- }
- };
- try {
- ResourcesPlugin.getWorkspace().getRoot()
- .accept(visitor, IResource.NONE);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
-}
+package org.eclipse.etrice.core.ui.contentassist;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.etrice.core.room.util.RelativePathHelpers;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider;
+import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
+import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
+
+public class ImportModelAssist {
+
+ public static void addPaths(final AbstractContentProposalProvider provider, final ContentAssistContext context,
+ final ICompletionProposalAcceptor acceptor, final String extension) {
+ final IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getFullPath();
+ IPath modelPath = new Path(context.getRootModel().eResource().getURI().toPlatformString(false));
+ modelPath = ResourcesPlugin.getWorkspace().getRoot().getFile(modelPath).getLocation();
+ final URI modelURI = URI.createFileURI(modelPath.toOSString()).trimSegments(1);
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
+
+ @Override
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() != IResource.FILE)
+ return true;
+
+ if (proxy.getName().endsWith(extension)) {
+ IPath relModelPath = proxy.requestFullPath();
+ relModelPath = ResourcesPlugin.getWorkspace().getRoot().getFile(relModelPath).getLocation();
+ URI relURI = URI.createFileURI(relModelPath.toOSString());
+ String relPath = RelativePathHelpers.getRelativePath(modelURI, relURI, true);
+ if (relPath==null)
+ relPath = "file:/"+(relURI.toFileString().replaceAll("\\\\", "/"));
+ IPath relWorkspacePath = proxy.requestFullPath().makeRelativeTo(rootPath);
+ String proposal = "\"" + relPath + "\"";
+ String displayString = relModelPath.lastSegment() + " - "
+ + relWorkspacePath;
+ acceptor.accept(provider.createCompletionProposal(proposal,
+ new StyledString(displayString), null, context));
+ }
+ return false;
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().getRoot()
+ .accept(visitor, IResource.NONE);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+}

Back to the top