Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Caks2016-03-16 14:15:19 +0000
committerChristoph Caks2016-03-16 14:15:19 +0000
commitaa71c74f50697dada863b88cdbb5debd9f3334b1 (patch)
tree7ff4930e9127d060ee22f7f81099764dc05444d8
parentdeb1ea24de5e6d455022551bd0454ae919b2ed93 (diff)
downloadorg.eclipse.efxclipse-aa71c74f50697dada863b88cdbb5debd9f3334b1.tar.gz
org.eclipse.efxclipse-aa71c74f50697dada863b88cdbb5debd9f3334b1.tar.xz
org.eclipse.efxclipse-aa71c74f50697dada863b88cdbb5debd9f3334b1.zip
Bug 489749 - StyledTextArea - QuickLink Support
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.e4/META-INF/MANIFEST.MF3
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.e4/OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2.xml9
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.e4/src/org/eclipse/fx/code/editor/e4/internal/NavigationProviderTypeProviderCF2.java29
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx.themes/css/dark-highlight.css5
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx.themes/css/highlight.css9
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx/META-INF/MANIFEST.MF5
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/SimpleSourceTextEditorBuilder.java8
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java18
-rw-r--r--bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/services/internal/DefaultSourceViewerConfiguration.java104
-rw-r--r--bundles/code/org.eclipse.fx.code.editor/META-INF/MANIFEST.MF1
-rw-r--r--bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java2
-rw-r--r--bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/SourceSelection.java14
-rw-r--r--bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProvider.java12
-rw-r--r--bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProviderTypeProvider.java5
-rw-r--r--bundles/code/org.eclipse.fx.text.ui/META-INF/MANIFEST.MF1
-rw-r--r--bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewer.java15
-rw-r--r--bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewerConfiguration.java9
-rw-r--r--bundles/code/org.eclipse.fx.text/META-INF/MANIFEST.MF1
-rw-r--r--bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationRegion.java10
-rw-r--r--bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationTarget.java8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java6
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java1
22 files changed, 265 insertions, 10 deletions
diff --git a/bundles/code/org.eclipse.fx.code.editor.e4/META-INF/MANIFEST.MF b/bundles/code/org.eclipse.fx.code.editor.e4/META-INF/MANIFEST.MF
index 8d58226fe..c22a2526e 100644
--- a/bundles/code/org.eclipse.fx.code.editor.e4/META-INF/MANIFEST.MF
+++ b/bundles/code/org.eclipse.fx.code.editor.e4/META-INF/MANIFEST.MF
@@ -31,5 +31,6 @@ Service-Component: OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.Docu
OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.ProposalComputerTypeProviderContextFunction.xml,
OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.HoverInformationProviderTypeProviderCF.xml,
OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.SearchProviderTypeProviderCF.xml,
- OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.InputContextContextFunction.xml
+ OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.InputContextContextFunction.xml,
+ OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2.xml
Bundle-ActivationPolicy: lazy
diff --git a/bundles/code/org.eclipse.fx.code.editor.e4/OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2.xml b/bundles/code/org.eclipse.fx.code.editor.e4/OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2.xml
new file mode 100644
index 000000000..f7387b6e4
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.code.editor.e4/OSGI-INF/services/org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0" name="org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2">
+ <property name="service.context.key" value="org.eclipse.fx.code.editor.services.NavigationProvider"/>
+ <service>
+ <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
+ </service>
+ <reference bind="registerService" cardinality="0..n" interface="org.eclipse.fx.code.editor.services.NavigationProviderTypeProvider" name="registerService" policy="dynamic" policy-option="greedy" unbind="unregisterService"/>
+ <implementation class="org.eclipse.fx.code.editor.e4.internal.NavigationProviderTypeProviderCF2"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/code/org.eclipse.fx.code.editor.e4/src/org/eclipse/fx/code/editor/e4/internal/NavigationProviderTypeProviderCF2.java b/bundles/code/org.eclipse.fx.code.editor.e4/src/org/eclipse/fx/code/editor/e4/internal/NavigationProviderTypeProviderCF2.java
new file mode 100644
index 000000000..c69a67903
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.code.editor.e4/src/org/eclipse/fx/code/editor/e4/internal/NavigationProviderTypeProviderCF2.java
@@ -0,0 +1,29 @@
+package org.eclipse.fx.code.editor.e4.internal;
+
+import java.util.Map;
+
+import org.eclipse.e4.core.contexts.IContextFunction;
+import org.eclipse.fx.code.editor.e4.InputBasedContextFunction;
+import org.eclipse.fx.code.editor.services.NavigationProvider;
+import org.eclipse.fx.code.editor.services.NavigationProviderTypeProvider;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
+
+@SuppressWarnings("restriction")
+@Component(service=IContextFunction.class, property={"service.context.key=org.eclipse.fx.code.editor.services.NavigationProvider"})
+public class NavigationProviderTypeProviderCF2 extends InputBasedContextFunction<NavigationProvider, NavigationProviderTypeProvider> {
+
+ @Override
+ @Reference(cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC, policyOption=ReferencePolicyOption.GREEDY)
+ public void registerService(NavigationProviderTypeProvider service, Map<String, Object> properties) {
+ super.registerService(service, properties);
+ }
+
+ @Override
+ public void unregisterService(NavigationProviderTypeProvider service) {
+ super.unregisterService(service);
+ }
+}
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/dark-highlight.css b/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/dark-highlight.css
index 4e0fc4837..ee546bdbf 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/dark-highlight.css
+++ b/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/dark-highlight.css
@@ -2,6 +2,11 @@
-type-info-color: lightgray;
}
+.styled-text-area .dart.quick_link {
+ -styled-text-color: lightblue !important;
+ -efx-decoration: "underline";
+}
+
.styled-text-area .list-view {
-source-editor-code: #b8c4d1;
-source-editor-operator: #b8c4d1;
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/highlight.css b/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/highlight.css
index b25c6418e..8dc69af8b 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/highlight.css
+++ b/bundles/code/org.eclipse.fx.code.editor.fx.themes/css/highlight.css
@@ -2,6 +2,15 @@
-type-info-color: darkgray;
}
+.styled-text-area .dart.quick_link {
+ -styled-text-color: blue !important;
+ -efx-decoration: "underline";
+}
+
+.styled-text-area .dart.quick_link Text {
+ -fx-fill: red !important;
+}
+
.styled-text-area .list-view {
-fx-background-color: white;
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx/META-INF/MANIFEST.MF b/bundles/code/org.eclipse.fx.code.editor.fx/META-INF/MANIFEST.MF
index ea1facf96..fb05ad63c 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx/META-INF/MANIFEST.MF
+++ b/bundles/code/org.eclipse.fx.code.editor.fx/META-INF/MANIFEST.MF
@@ -4,14 +4,17 @@ Bundle-Name: Basic editor APIs for JavaFX
Bundle-SymbolicName: org.eclipse.fx.code.editor.fx
Bundle-Version: 2.3.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: javax.inject,
+Import-Package: com.google.common.collect;version="15.0.0",
+ javax.inject,
org.eclipse.e4.ui.di,
org.eclipse.fx.code.editor;version="2.3.0",
org.eclipse.fx.code.editor.services;version="2.3.0",
org.eclipse.fx.core;version="2.3.0",
org.eclipse.fx.core.di;version="2.3.0",
+ org.eclipse.fx.core.event;version="2.3.0",
org.eclipse.fx.core.preferences;version="2.3.0",
org.eclipse.fx.text.hover,
+ org.eclipse.fx.text.navigation,
org.eclipse.fx.text.rules;version="2.3.0",
org.eclipse.fx.text.ui;version="2.3.0",
org.eclipse.fx.text.ui.contentassist;version="2.3.0",
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/SimpleSourceTextEditorBuilder.java b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/SimpleSourceTextEditorBuilder.java
index 48003ceca..478645475 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/SimpleSourceTextEditorBuilder.java
+++ b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/SimpleSourceTextEditorBuilder.java
@@ -18,8 +18,11 @@ import org.eclipse.fx.code.editor.Input;
import org.eclipse.fx.code.editor.LocalSourceFileInput;
import org.eclipse.fx.code.editor.fx.services.CompletionProposalPresenter;
import org.eclipse.fx.code.editor.fx.services.internal.DefaultSourceViewerConfiguration;
+import org.eclipse.fx.code.editor.services.EditorOpener;
import org.eclipse.fx.code.editor.services.HoverInformationProvider;
+import org.eclipse.fx.code.editor.services.NavigationProvider;
import org.eclipse.fx.code.editor.services.ProposalComputer;
+import org.eclipse.fx.code.editor.services.SearchProvider;
import org.eclipse.fx.text.rules.CombinedWordRule;
import org.eclipse.fx.text.rules.JavaLikeWordDetector;
import org.eclipse.fx.text.ui.presentation.PresentationReconciler;
@@ -62,6 +65,9 @@ public class SimpleSourceTextEditorBuilder {
private final String languageName;
private CompletionProposalPresenter completionProposalPresenter;
private HoverInformationProvider hoverInformationProvider;
+ private SearchProvider searchProvider;
+ private NavigationProvider navigationProvider;
+ private EditorOpener editorOpener;
static class MultiLine {
private final String start;
@@ -164,7 +170,7 @@ public class SimpleSourceTextEditorBuilder {
}
editor.setPartitioner(new FastPartitioner(new PartitionerImpl(this), contentTypes.toArray(new String[0])));
- editor.setSourceViewerConfiguration(new DefaultSourceViewerConfiguration(input, new ReconcilerImpl(this), proposalComputer, annotationModel, annotationPresenter, hoverInformationProvider, completionProposalPresenter));
+ editor.setSourceViewerConfiguration(new DefaultSourceViewerConfiguration(input, new ReconcilerImpl(this), proposalComputer, annotationModel, annotationPresenter, hoverInformationProvider, completionProposalPresenter, searchProvider, navigationProvider, editorOpener));
return editor;
}
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java
index 42161be88..a4624bcb4 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java
+++ b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java
@@ -17,10 +17,15 @@ import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
+import org.eclipse.fx.code.editor.Constants;
import org.eclipse.fx.code.editor.Input;
+import org.eclipse.fx.code.editor.SourceSelection;
+import org.eclipse.fx.code.editor.services.URIProvider;
import org.eclipse.fx.core.di.ContextValue;
+import org.eclipse.fx.core.event.EventBus;
import org.eclipse.fx.text.ui.source.SourceViewer;
import org.eclipse.fx.text.ui.source.SourceViewerConfiguration;
+import org.eclipse.fx.ui.controls.styledtext.TextSelection;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IDocumentPartitioner;
@@ -46,6 +51,8 @@ public class TextEditor {
private SourceViewer viewer;
+
+
@Inject
public void setDocument(IDocument document) {
if( viewer != null ) {
@@ -87,7 +94,7 @@ public class TextEditor {
}
@PostConstruct
- public void initUI(BorderPane pane) {
+ public void initUI(BorderPane pane, EventBus eventBus) {
viewer = createSourceViewer();
if( document instanceof IDocumentExtension3 ) {
((IDocumentExtension3)document).setDocumentPartitioner(configuration.getConfiguredDocumentPartitioning(viewer),partitioner);
@@ -103,6 +110,15 @@ public class TextEditor {
if( activeInput != null ) {
activeInput.setValue(input);
}
+
+ eventBus.subscribe(Constants.TOPIC_SELECT_SOURCE, EventBus.data(this::onSourceSelect));
+ }
+
+ private void onSourceSelect(SourceSelection data) {
+ if (((URIProvider)input).getURI().equals(data.uri)) {
+ getSourceViewer().getTextWidget().setSelection(new TextSelection(data.selection.getOffset(), data.selection.getLength()));
+ getSourceViewer().getTextWidget().revealCaret();
+ }
}
protected SourceViewer createSourceViewer() {
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/services/internal/DefaultSourceViewerConfiguration.java b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/services/internal/DefaultSourceViewerConfiguration.java
index 51240797f..d0b37b893 100644
--- a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/services/internal/DefaultSourceViewerConfiguration.java
+++ b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/services/internal/DefaultSourceViewerConfiguration.java
@@ -1,9 +1,14 @@
package org.eclipse.fx.code.editor.fx.services.internal;
+import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.function.Function;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -11,13 +16,21 @@ import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.fx.code.editor.Constants;
import org.eclipse.fx.code.editor.Input;
+import org.eclipse.fx.code.editor.SourceSelection;
import org.eclipse.fx.code.editor.fx.services.CompletionProposalPresenter;
import org.eclipse.fx.code.editor.services.CompletionProposal;
+import org.eclipse.fx.code.editor.services.EditorOpener;
import org.eclipse.fx.code.editor.services.HoverInformationProvider;
+import org.eclipse.fx.code.editor.services.NavigationProvider;
import org.eclipse.fx.code.editor.services.ProposalComputer;
import org.eclipse.fx.code.editor.services.ProposalComputer.ProposalContext;
+import org.eclipse.fx.code.editor.services.SearchProvider;
+import org.eclipse.fx.code.editor.services.URIProvider;
+import org.eclipse.fx.core.event.EventBus;
import org.eclipse.fx.core.preferences.Preference;
import org.eclipse.fx.text.hover.HoverInfo;
+import org.eclipse.fx.text.navigation.NavigationRegion;
+import org.eclipse.fx.text.navigation.NavigationTarget;
import org.eclipse.fx.text.ui.Feature;
import org.eclipse.fx.text.ui.ITextHover;
import org.eclipse.fx.text.ui.ITextViewer;
@@ -31,12 +44,18 @@ import org.eclipse.fx.text.ui.presentation.PresentationReconciler;
import org.eclipse.fx.text.ui.source.AnnotationPresenter;
import org.eclipse.fx.text.ui.source.ISourceViewer;
import org.eclipse.fx.text.ui.source.SourceViewerConfiguration;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.QuickLink;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.QuickLinkable;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.SimpleQuickLink;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.CustomQuickLink;
import org.eclipse.fx.ui.controls.styledtext.TextSelection;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
+import com.google.common.collect.Range;
+
import javafx.beans.property.SetProperty;
import javafx.beans.property.SimpleSetProperty;
import javafx.collections.FXCollections;
@@ -51,6 +70,12 @@ public class DefaultSourceViewerConfiguration extends SourceViewerConfiguration
private final AnnotationPresenter annotationPresenter;
private final HoverInformationProvider hoverInformationProvider;
private final CompletionProposalPresenter proposalPresenter;
+ private final SearchProvider searchProvider;
+ private final NavigationProvider navigationProvider;
+ private final EditorOpener editorOpener;
+
+ @Inject private EventBus eventBus;
+
private ContentAssistant contentAssistant;
private SetProperty<Feature> featureSet = new SimpleSetProperty<Feature>(this, "featureSet", FXCollections.observableSet());
@@ -62,7 +87,10 @@ public class DefaultSourceViewerConfiguration extends SourceViewerConfiguration
@Optional IAnnotationModel annotationModel,
@Optional AnnotationPresenter annotationPresenter,
@Optional HoverInformationProvider hoverInformationProvider,
- @Optional CompletionProposalPresenter proposalPresenter
+ @Optional CompletionProposalPresenter proposalPresenter,
+ @Optional SearchProvider searchProvider,
+ @Optional NavigationProvider navigationProvider,
+ @Optional EditorOpener editorOpener
) {
this.input = input;
this.hoverInformationProvider = hoverInformationProvider;
@@ -72,6 +100,9 @@ public class DefaultSourceViewerConfiguration extends SourceViewerConfiguration
this.proposalPresenter = proposalPresenter == null ? DefaultProposal::new : proposalPresenter;
this.annotationPresenter = annotationPresenter;
+ this.searchProvider = searchProvider;
+ this.navigationProvider = navigationProvider;
+ this.editorOpener = editorOpener;
}
@Inject
@@ -84,6 +115,77 @@ public class DefaultSourceViewerConfiguration extends SourceViewerConfiguration
}
}
+ private Range<Integer> convertRegion(IRegion region) {
+ return Range.closed(region.getOffset(), region.getOffset() + region.getLength());
+ }
+
+ private QuickLink convertNavigationTarget(NavigationTarget target) {
+ return new CustomQuickLink() {
+
+ @Override
+ public String getLabel() {
+ // TODO
+ return "need some label here!";
+ }
+
+ @Override
+ public Runnable getAction() {
+ return () -> {
+ editorOpener.openEditor(target.getFile().toString());
+ eventBus.publish(Constants.TOPIC_SELECT_SOURCE, new SourceSelection(target.getFile().toString(), target.getRegion()), true);
+ };
+ }
+
+ @Override
+ public String toString() {
+ return "CustombQuickLink in " + target.getFile() + " @ " + target.getRegion();
+ }
+
+ };
+ }
+
+ private QuickLinkable convertNavigationRegion(NavigationRegion region) {
+ return new QuickLinkable() {
+ @Override
+ public Range<Integer> getRegion() {
+ return convertRegion(region.getRegion());
+ }
+
+ @Override
+ public List<QuickLink> getLinks() {
+ return region.getTargets().stream().map(DefaultSourceViewerConfiguration.this::convertNavigationTarget).collect(Collectors.toList());
+ }
+ };
+ }
+
+ @Override
+ public Function<Integer, java.util.Optional<QuickLinkable>> getQuicklinkCallback() {
+
+ if (navigationProvider != null) {
+
+ return (offset) -> {
+ try {
+ Future<List<NavigationRegion>> navigationRegions = navigationProvider.getNavigationRegions();
+ List<NavigationRegion> list = navigationRegions.get(400, TimeUnit.MILLISECONDS);
+
+ for (NavigationRegion region : list) {
+ if (region.getRegion().getOffset() <= offset && region.getRegion().getOffset() + region.getRegion().getLength() > offset) {
+ return java.util.Optional.of(convertNavigationRegion(region));
+ }
+ }
+ }
+ catch (InterruptedException | TimeoutException | ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ return java.util.Optional.empty();
+ };
+ }
+ else {
+ return super.getQuicklinkCallback();
+ }
+ }
+
@Override
public SetProperty<Feature> getFeatures() {
return this.featureSet;
diff --git a/bundles/code/org.eclipse.fx.code.editor/META-INF/MANIFEST.MF b/bundles/code/org.eclipse.fx.code.editor/META-INF/MANIFEST.MF
index 5ee6d1018..7a207d51e 100644
--- a/bundles/code/org.eclipse.fx.code.editor/META-INF/MANIFEST.MF
+++ b/bundles/code/org.eclipse.fx.code.editor/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Import-Package: javax.inject,
org.eclipse.fx.core.event;version="2.3.0",
org.eclipse.fx.core.function;version="2.3.0",
org.eclipse.fx.text.hover,
+ org.eclipse.fx.text.navigation,
org.eclipse.jface.text.rules,
org.osgi.service.component.annotations;version="1.2.0"
Require-Bundle: org.eclipse.text;bundle-version="3.5.400",
diff --git a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java
index 3bc0854c3..a22446b18 100644
--- a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java
+++ b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java
@@ -12,6 +12,8 @@ public class Constants {
public static final Topic<SourceFileInput> TOPIC_SOURCE_FILE_INPUT_DISPOSED = new Topic<>("at/bestsolution/dart/editor/file-input/disposed");
public static final Topic<SourceFileInput> TOPIC_SOURCE_FILE_INPUT_SAVED = new Topic<>("at/bestsolution/dart/editor/file-input/saved");
+ public static final Topic<SourceSelection> TOPIC_SELECT_SOURCE = new Topic<>("at/bestsolution/dart/editor/select-source");
+
public static final String DOCUMENT_URL = "documentUrl";
public static final String VCS_URL = "vcsUrl";
diff --git a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/SourceSelection.java b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/SourceSelection.java
new file mode 100644
index 000000000..832ee717c
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/SourceSelection.java
@@ -0,0 +1,14 @@
+package org.eclipse.fx.code.editor;
+
+import org.eclipse.jface.text.IRegion;
+
+public class SourceSelection {
+ public final String uri;
+ public final IRegion selection;
+
+ public SourceSelection(String uri, IRegion selection) {
+ this.uri = uri;
+ this.selection = selection;
+ }
+
+}
diff --git a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProvider.java b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProvider.java
new file mode 100644
index 000000000..bf1b6b5f6
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProvider.java
@@ -0,0 +1,12 @@
+package org.eclipse.fx.code.editor.services;
+
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.eclipse.fx.text.navigation.NavigationRegion;
+
+
+public interface NavigationProvider {
+
+ Future<List<NavigationRegion>> getNavigationRegions();
+}
diff --git a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProviderTypeProvider.java b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProviderTypeProvider.java
new file mode 100644
index 000000000..51ba38a4a
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/services/NavigationProviderTypeProvider.java
@@ -0,0 +1,5 @@
+package org.eclipse.fx.code.editor.services;
+
+public interface NavigationProviderTypeProvider extends InputDependentTypeProviderService<NavigationProvider> {
+
+}
diff --git a/bundles/code/org.eclipse.fx.text.ui/META-INF/MANIFEST.MF b/bundles/code/org.eclipse.fx.text.ui/META-INF/MANIFEST.MF
index e4b5b683c..0cd243dd8 100644
--- a/bundles/code/org.eclipse.fx.text.ui/META-INF/MANIFEST.MF
+++ b/bundles/code/org.eclipse.fx.text.ui/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Bundle-Vendor: Eclipse.org
Import-Package: com.google.common.collect;version="15.0.0",
org.eclipse.fx.core;version="2.3.0",
org.eclipse.fx.text.hover,
+ org.eclipse.fx.text.navigation,
org.eclipse.fx.ui.controls.list;version="2.3.0",
org.eclipse.fx.ui.controls.styledtext;version="2.3.0",
org.eclipse.fx.ui.controls.styledtext.events;version="2.3.0",
diff --git a/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewer.java b/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewer.java
index 38055949e..8fef58f23 100644
--- a/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewer.java
+++ b/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewer.java
@@ -12,12 +12,17 @@
*******************************************************************************/
package org.eclipse.fx.text.ui.source;
+import java.net.URI;
+import java.util.List;
+import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
+import java.util.stream.Collectors;
import org.eclipse.fx.text.hover.HoverInfo;
-import org.eclipse.fx.text.ui.Feature;
+import org.eclipse.fx.text.navigation.NavigationRegion;
+import org.eclipse.fx.text.navigation.NavigationTarget;
import org.eclipse.fx.text.ui.ITextViewerExtension2;
import org.eclipse.fx.text.ui.TextViewer;
import org.eclipse.fx.text.ui.contentassist.ContentAssistant;
@@ -28,7 +33,9 @@ import org.eclipse.fx.text.ui.internal.WrappedLineRulerAnnotationPresenter;
import org.eclipse.fx.text.ui.internal.WrappedTextAnnotationPresenter;
import org.eclipse.fx.text.ui.presentation.IPresentationReconciler;
import org.eclipse.fx.text.ui.reconciler.IReconciler;
-import org.eclipse.fx.ui.controls.styledtext.VerifyEvent;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.QuickLink;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.QuickLinkable;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.SimpleQuickLink;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ISynchronizable;
@@ -39,6 +46,8 @@ import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelExtension;
+import com.google.common.collect.Range;
+
public class SourceViewer extends TextViewer implements ISourceViewer, ISourceViewerExtension, ISourceViewerExtension2, ISourceViewerExtension3, ISourceViewerExtension4 {
private IPresentationReconciler fPresentationReconciler;
@@ -232,6 +241,8 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
// });
}
+ getTextWidget().setQuickLinkCallback(configuration.getQuicklinkCallback());
+
new SimpleSmartIndent(this);
diff --git a/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewerConfiguration.java b/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewerConfiguration.java
index 144414baf..3d7772786 100644
--- a/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewerConfiguration.java
+++ b/bundles/code/org.eclipse.fx.text.ui/src/org/eclipse/fx/text/ui/source/SourceViewerConfiguration.java
@@ -11,10 +11,12 @@
package org.eclipse.fx.text.ui.source;
import java.util.Collections;
-import java.util.List;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Function;
import org.eclipse.fx.text.hover.HoverInfo;
+import org.eclipse.fx.text.navigation.NavigationRegion;
import org.eclipse.fx.text.ui.DefaultUndoManager;
import org.eclipse.fx.text.ui.Feature;
import org.eclipse.fx.text.ui.ITextHover;
@@ -23,6 +25,7 @@ import org.eclipse.fx.text.ui.contentassist.IContentAssistant;
import org.eclipse.fx.text.ui.presentation.IPresentationReconciler;
import org.eclipse.fx.text.ui.presentation.PresentationReconciler;
import org.eclipse.fx.text.ui.reconciler.IReconciler;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea.QuickLinkable;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.source.Annotation;
@@ -91,4 +94,8 @@ public abstract class SourceViewerConfiguration {
return ".";
}
+ public Function<Integer, Optional<QuickLinkable>> getQuicklinkCallback() {
+ return (offset) -> Optional.empty();
+ }
+
}
diff --git a/bundles/code/org.eclipse.fx.text/META-INF/MANIFEST.MF b/bundles/code/org.eclipse.fx.text/META-INF/MANIFEST.MF
index 1985562d3..cd04a5414 100644
--- a/bundles/code/org.eclipse.fx.text/META-INF/MANIFEST.MF
+++ b/bundles/code/org.eclipse.fx.text/META-INF/MANIFEST.MF
@@ -5,6 +5,7 @@ Bundle-SymbolicName: org.eclipse.fx.text
Bundle-Version: 2.3.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.fx.text.hover,
+ org.eclipse.fx.text.navigation,
org.eclipse.fx.text.rules;version="2.3.0";x-internal:=true
Require-Bundle: org.eclipse.text;bundle-version="3.5.300",
org.eclipse.equinox.common;bundle-version="3.6.200"
diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationRegion.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationRegion.java
new file mode 100644
index 000000000..14306c9d1
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationRegion.java
@@ -0,0 +1,10 @@
+package org.eclipse.fx.text.navigation;
+
+import java.util.List;
+
+import org.eclipse.jface.text.IRegion;
+
+public interface NavigationRegion {
+ IRegion getRegion();
+ List<NavigationTarget> getTargets();
+}
diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationTarget.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationTarget.java
new file mode 100644
index 000000000..1262561bb
--- /dev/null
+++ b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/navigation/NavigationTarget.java
@@ -0,0 +1,8 @@
+package org.eclipse.fx.text.navigation;
+
+import org.eclipse.jface.text.IRegion;
+
+public interface NavigationTarget {
+ String getFile();
+ IRegion getRegion();
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
index 2caae6007..be2ce8ff4 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
@@ -1494,7 +1494,7 @@ public class StyledTextArea extends Control {
if (selection.length == 0) {
setCaretOffset(selection.offset);
} else {
- // this.caretOffsetProperty.set(selection.offset+selection.length);
+ this.caretOffsetProperty.set(selection.offset+selection.length);
this.currentSelection.set(selection);
}
}
@@ -1757,4 +1757,8 @@ public class StyledTextArea extends Control {
setCaretOffset(offset);
}
}
+
+ public void revealCaret() {
+ // TODO reveal caret
+ }
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
index 678b5b856..9acae1a88 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
@@ -341,7 +341,6 @@ public class StyledTextBehavior {
private void doLink(QuickLink link) {
if (link instanceof SimpleQuickLink) {
SimpleQuickLink simple = (SimpleQuickLink) link;
- getControl().setCaretOffset(simple.getRegion().upperEndpoint());
getControl().setSelection(new TextSelection(simple.getRegion().lowerEndpoint(), simple.getRegion().upperEndpoint() - simple.getRegion().lowerEndpoint()));
}
else if (link instanceof CustomQuickLink) {

Back to the top