Added hyperlinking and bumped version numbers

This commit is contained in:
Eyck Jentzsch 2018-06-03 10:45:09 +02:00
parent 9a55dd5a21
commit 1eea28e55c
17 changed files with 278 additions and 31 deletions

View File

@ -1,23 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature id="com.minres.rdl.feature"
label="RDL Feature "
version="1.0.0.qualifier">
<plugin
id="com.minres.rdl"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.minres.rdl.ide"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.minres.rdl.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<feature
id="com.minres.rdl.feature"
label="RDL Feature "
version="1.0.0.qualifier"
provider-name="MINRES Technologies GmbH">
<plugin
id="com.minres.rdl"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.minres.rdl.ide"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.minres.rdl.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View File

@ -3,7 +3,7 @@
id="com.minres.rdl.platform.feature"
label="Xtext Platform Feature"
version="1.0.0.qualifier"
provider-name="MINRES">
provider-name="MINRES Technologies GmbH">
<description url="http://www.example.com/description">
[Enter Feature Description here.]

View File

@ -2,7 +2,8 @@
<feature
id="com.minres.rdl.product.feature"
label="RDL Feature "
version="1.0.0.qualifier">
version="1.0.0.qualifier"
provider-name="MINRES Technologies GmbH">
<requires>
<import feature="com.minres.rdl.feature" version="1.0.0.qualifier"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="RDL Editor" uid="com.minres.rdl.product.product" id="com.minres.rdl.product.product" application="org.eclipse.ui.ide.workbench" version="1.1.1.qualifier" useFeatures="true" includeLaunchers="true">
<product name="RDL Editor" uid="com.minres.rdl.product.product" id="com.minres.rdl.product.product" application="org.eclipse.ui.ide.workbench" version="1.2.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>

View File

@ -3,6 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: RDL Editor
Bundle-SymbolicName: com.minres.rdl.product;singleton:=true
Bundle-Version: 1.1.1.qualifier
Bundle-Vendor: MINRES
Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0"
Automatic-Module-Name: com.minres.rdl.product

View File

@ -1,5 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View File

@ -2,8 +2,8 @@ Manifest-Version: 1.0
Automatic-Module-Name: com.minres.rdl.ui
Bundle-ManifestVersion: 2
Bundle-Name: com.minres.rdl.ui
Bundle-Vendor: My Company
Bundle-Version: 1.1.1.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-Version: 1.2.0.qualifier
Bundle-SymbolicName: com.minres.rdl.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: com.minres.rdl,

View File

@ -18,5 +18,5 @@
</plugins>
</build>
<version>1.1.1-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</project>

View File

@ -0,0 +1,17 @@
package com.minres.rdl.ui;
import org.eclipse.xtext.ui.XtextProjectHelper;
import com.minres.rdl.ui.wizard.RDLProjectCreator;
public class JDTFreeStructuralProjectCreator extends RDLProjectCreator {
@Override
protected String[] getProjectNatures() {
return new String[] {XtextProjectHelper.NATURE_ID};
}
@Override
protected String[] getBuilders() {
return new String[] {XtextProjectHelper.BUILDER_ID};
}
}

View File

@ -6,6 +6,13 @@ package com.minres.rdl.ui
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
import org.eclipse.xtext.ui.wizard.IProjectCreator
import org.eclipse.xtext.ui.resource.IResourceSetProvider
import org.eclipse.xtext.ui.resource.SimpleResourceSetProvider
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper
import com.minres.structural.ui.hyperlink.MyHyperlinkHelper
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink
import com.minres.structural.ui.hyperlink.MyXtextHyperlink
/**
* Use this class to register components to be used within the Eclipse IDE.
@ -21,4 +28,20 @@ class RDLUiModule extends AbstractRDLUiModule {
typeof(RDLEObjectDocumentationProvider);
}
override Class<? extends IProjectCreator> bindIProjectCreator() {
return JDTFreeStructuralProjectCreator;
}
override Class<? extends IResourceSetProvider> bindIResourceSetProvider() {
return SimpleResourceSetProvider
}
def Class<? extends HyperlinkHelper> bindHyperlinkHelper() {
return MyHyperlinkHelper
}
def Class<? extends XtextHyperlink> bindHyperlink() {
return MyXtextHyperlink
}
}

View File

@ -0,0 +1,52 @@
package com.minres.structural.ui.hyperlink
import com.google.inject.Inject
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.jface.text.Region
import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
import org.eclipse.xtext.resource.XtextResource
import org.eclipse.xtext.scoping.impl.ImportUriResolver
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor
import org.eclipse.xtext.util.TextRegion
class MyHyperlinkHelper extends HyperlinkHelper {
@Inject ImportUriResolver resolver;
override createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
val region = new TextRegion(offset, 0)
val crossRefNode = getEObjectAtOffsetHelper().getCrossReferenceNode(resource, region);
if (crossRefNode === null){
val parseResult = resource.getParseResult();
if (parseResult !== null) {
val leaf = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), region.getOffset());
//val rule = EcoreUtil2.getContainerOfType(leaf.grammarElement, AbstractRule);
val semObj = NodeModelUtils.findActualSemanticObjectFor(leaf);
val importURI = resolver.resolve(semObj);
if (importURI !== null && EcoreUtil2.isValidUri(semObj, URI.createURI(importURI))) {
val referencedResource = EcoreUtil2.getResource(resource, importURI)
if(referencedResource !== null && referencedResource.contents.size>0){
val top = referencedResource.contents.get(0)
val textRegion = leaf.getTextRegion();
val uri = EcoreUtil.getURI(top);
val result = hyperlinkProvider.get();
result.setHyperlinkRegion(new Region(textRegion.getOffset(), textRegion.getLength()));
result.setURI(if(uri.isPlatformResource()) uri else resource.getResourceSet().getURIConverter().normalize(uri));
result.setHyperlinkText(labelProvider.getText(top));
if(result instanceof MyXtextHyperlink) result.selectTarget=false
acceptor.accept(result);
}
}
}
} else {
val crossLinkedEObject = getEObjectAtOffsetHelper().getCrossReferencedElement(crossRefNode);
if (crossLinkedEObject !== null && !crossLinkedEObject.eIsProxy()) {
createHyperlinksTo(resource, crossRefNode, crossLinkedEObject, acceptor);
}
}
}
}

View File

@ -0,0 +1,24 @@
package com.minres.structural.ui.hyperlink
import com.google.inject.Inject
import org.eclipse.xtext.ui.editor.IURIEditorOpener
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink
class MyXtextHyperlink extends XtextHyperlink {
var boolean select = true
@Inject var IURIEditorOpener uriEditorOpener;
override void open() {
uriEditorOpener.open(getURI(), select);
}
def boolean getSelectTarget(){
return select
}
def void setSelectTarget(boolean select){
this.select=select
}
}

View File

@ -4,12 +4,20 @@
package com.minres.rdl.ui;
import com.minres.rdl.ui.AbstractRDLUiModule;
import com.minres.rdl.ui.JDTFreeStructuralProjectCreator;
import com.minres.rdl.ui.RDLEObjectDocumentationProvider;
import com.minres.rdl.ui.RDLEObjectHoverProvider;
import com.minres.structural.ui.hyperlink.MyHyperlinkHelper;
import com.minres.structural.ui.hyperlink.MyXtextHyperlink;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.ui.resource.SimpleResourceSetProvider;
import org.eclipse.xtext.ui.wizard.IProjectCreator;
/**
* Use this class to register components to be used within the Eclipse IDE.
@ -25,6 +33,24 @@ public class RDLUiModule extends AbstractRDLUiModule {
return RDLEObjectDocumentationProvider.class;
}
@Override
public Class<? extends IProjectCreator> bindIProjectCreator() {
return JDTFreeStructuralProjectCreator.class;
}
@Override
public Class<? extends IResourceSetProvider> bindIResourceSetProvider() {
return SimpleResourceSetProvider.class;
}
public Class<? extends HyperlinkHelper> bindHyperlinkHelper() {
return MyHyperlinkHelper.class;
}
public Class<? extends XtextHyperlink> bindHyperlink() {
return MyXtextHyperlink.class;
}
public RDLUiModule(final AbstractUIPlugin arg0) {
super(arg0);
}

View File

@ -0,0 +1,72 @@
package com.minres.structural.ui.hyperlink;
import com.google.inject.Inject;
import com.minres.structural.ui.hyperlink.MyXtextHyperlink;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.text.Region;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.nodemodel.ILeafNode;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.scoping.impl.ImportUriResolver;
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
import org.eclipse.xtext.util.ITextRegion;
import org.eclipse.xtext.util.TextRegion;
@SuppressWarnings("all")
public class MyHyperlinkHelper extends HyperlinkHelper {
@Inject
private ImportUriResolver resolver;
@Override
public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) {
final TextRegion region = new TextRegion(offset, 0);
final INode crossRefNode = this.getEObjectAtOffsetHelper().getCrossReferenceNode(resource, region);
if ((crossRefNode == null)) {
final IParseResult parseResult = resource.getParseResult();
if ((parseResult != null)) {
final ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), region.getOffset());
final EObject semObj = NodeModelUtils.findActualSemanticObjectFor(leaf);
final String importURI = this.resolver.resolve(semObj);
if (((importURI != null) && EcoreUtil2.isValidUri(semObj, URI.createURI(importURI)))) {
final Resource referencedResource = EcoreUtil2.getResource(resource, importURI);
if (((referencedResource != null) && (referencedResource.getContents().size() > 0))) {
final EObject top = referencedResource.getContents().get(0);
final ITextRegion textRegion = leaf.getTextRegion();
final URI uri = EcoreUtil.getURI(top);
final XtextHyperlink result = this.getHyperlinkProvider().get();
int _offset = textRegion.getOffset();
int _length = textRegion.getLength();
Region _region = new Region(_offset, _length);
result.setHyperlinkRegion(_region);
URI _xifexpression = null;
boolean _isPlatformResource = uri.isPlatformResource();
if (_isPlatformResource) {
_xifexpression = uri;
} else {
_xifexpression = resource.getResourceSet().getURIConverter().normalize(uri);
}
result.setURI(_xifexpression);
result.setHyperlinkText(this.getLabelProvider().getText(top));
if ((result instanceof MyXtextHyperlink)) {
((MyXtextHyperlink)result).setSelectTarget(false);
}
acceptor.accept(result);
}
}
}
} else {
final EObject crossLinkedEObject = this.getEObjectAtOffsetHelper().getCrossReferencedElement(crossRefNode);
if (((crossLinkedEObject != null) && (!crossLinkedEObject.eIsProxy()))) {
this.createHyperlinksTo(resource, crossRefNode, crossLinkedEObject, acceptor);
}
}
}
}

View File

@ -0,0 +1,26 @@
package com.minres.structural.ui.hyperlink;
import com.google.inject.Inject;
import org.eclipse.xtext.ui.editor.IURIEditorOpener;
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
@SuppressWarnings("all")
public class MyXtextHyperlink extends XtextHyperlink {
private boolean select = true;
@Inject
private IURIEditorOpener uriEditorOpener;
@Override
public void open() {
this.uriEditorOpener.open(this.getURI(), this.select);
}
public boolean getSelectTarget() {
return this.select;
}
public void setSelectTarget(final boolean select) {
this.select = select;
}
}

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: com.minres.rdl
Bundle-ManifestVersion: 2
Bundle-Name: com.minres.rdl
Bundle-Vendor: My Company
Bundle-Vendor: MINRES Technologies GmbH
Bundle-Version: 1.1.0.qualifier
Bundle-SymbolicName: com.minres.rdl; singleton:=true
Bundle-ActivationPolicy: lazy

View File

@ -23,7 +23,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess
class Main {
private val USAGE_STR = "RDL2code [-h] [-v] [-I <RDL include dir] [-o <output dir>] <input file> <input file>";
val USAGE_STR = "RDL2code [-h] [-v] [-I <RDL include dir] [-o <output dir>] <input file> <input file>";
def static main(String[] args) {
if (args.empty) {