aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-08-30 16:39:37 (EDT)
committerRoland Grunberg2013-09-05 16:58:03 (EDT)
commit366b253f036a61092ffe2567b5ea263af1a699a9 (patch)
tree52bf771ff42e351d1efb224d37cc2e8624ed1d36
parentb129bb7105a71dbbae4d4eb7f62b4ba5e2ea1993 (diff)
downloadorg.eclipse.linuxtools-366b253f036a61092ffe2567b5ea263af1a699a9.zip
org.eclipse.linuxtools-366b253f036a61092ffe2567b5ea263af1a699a9.tar.gz
org.eclipse.linuxtools-366b253f036a61092ffe2567b5ea263af1a699a9.tar.bz2
RPM: remove unresolved urls as option B#414882refs/changes/15/16015/9
Eclipse by default attaches a hyperlink detector to the specfile editor that does not resolve urls with macros in them. RPM already has its own hyperlink detector that resolves macros and ctrl + hovering on a hyperlink would show both resolved and unresolved versions of the url. SpecfileConfiguration now has a bit more control over what hyperlink detectors are used on the specfile editor. For a start, URLHyperlinkDetector (the one that didn't resolve macros) will not be added when working on a specfile, rather, URLHyperlinkWithMacroDetector will be used instead. Change-Id: I37006b5346f0169c328cad63ab9f81e0b7614742 Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/16015 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com> Tested-by: Hudson CI
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileConfiguration.java43
1 files changed, 41 insertions, 2 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileConfiguration.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileConfiguration.java
index 80e18d2..7383869 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileConfiguration.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
+ * Copyright (c) 2007, 2013 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,8 +11,12 @@
package org.eclipse.linuxtools.internal.rpm.ui.editor;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.DefaultLineTracker;
@@ -27,7 +31,9 @@ import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
@@ -35,6 +41,7 @@ import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.URLHyperlinkWithMacroDetector;
import org.eclipse.linuxtools.internal.rpm.ui.editor.preferences.PreferenceConstants;
import org.eclipse.linuxtools.internal.rpm.ui.editor.scanners.SpecfileChangelogScanner;
import org.eclipse.linuxtools.internal.rpm.ui.editor.scanners.SpecfilePackagesScanner;
@@ -42,7 +49,10 @@ import org.eclipse.linuxtools.internal.rpm.ui.editor.scanners.SpecfilePartitionS
import org.eclipse.linuxtools.internal.rpm.ui.editor.scanners.SpecfileScanner;
import org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+import org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor;
+import org.eclipse.ui.texteditor.HyperlinkDetectorRegistry;
public class SpecfileConfiguration extends TextSourceViewerConfiguration {
private SpecfileDoubleClickStrategy doubleClickStrategy;
@@ -220,7 +230,36 @@ public class SpecfileConfiguration extends TextSourceViewerConfiguration {
if (sourceViewer == null) {
return null;
}
- return getRegisteredHyperlinkDetectors(sourceViewer);
+ Map<?, ?> targets = getHyperlinkDetectorTargets(sourceViewer);
+ HyperlinkDetectorRegistry hlDetectorRegistry = EditorsUI.getHyperlinkDetectorRegistry();
+ HyperlinkDetectorDescriptor[] hlDetectorDescriptor = hlDetectorRegistry.getHyperlinkDetectorDescriptors();
+ List<IHyperlinkDetector> tempHDList = new ArrayList<IHyperlinkDetector>();
+
+ for (Map.Entry<?, ?> entry : targets.entrySet()) {
+ for (HyperlinkDetectorDescriptor hdd : hlDetectorDescriptor) {
+ try {
+ AbstractHyperlinkDetector ahld = hdd.createHyperlinkDetector();
+ // filter using target id and not instance of URLHyperlinkDetector
+ // so that an option to open url with unresolved macros won't show
+ // however, allow URLHyperlinkWithMacroDetector
+ if (hdd.getTargetId().equals(entry.getKey()) &&
+ (!(ahld instanceof URLHyperlinkDetector) || ahld instanceof URLHyperlinkWithMacroDetector)) {
+ ahld.setContext((IAdaptable)entry.getValue());
+ tempHDList.add(ahld);
+ }
+ } catch (CoreException e) {
+ SpecfileLog.logError(e);
+ }
+ }
+ }
+
+ if (!tempHDList.isEmpty()) {
+ IHyperlinkDetector[] rc = new IHyperlinkDetector[tempHDList.size()];
+ rc = tempHDList.toArray(rc);
+ return rc;
+ } else {
+ return null;
+ }
}
/* (non-Javadoc)