Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-04-26 19:53:22 +0000
committerslewis2007-04-26 19:53:22 +0000
commit9cd8a481eccca619ff0659e0526fe8fe36def506 (patch)
treed513ccf475307434c44eedbf19bce1ad97088c7b /providers/bundles/org.eclipse.ecf.provider.irc.ui
parent16d679fd318e7d05992cd47ca7cf456cbc3397b0 (diff)
downloadorg.eclipse.ecf-9cd8a481eccca619ff0659e0526fe8fe36def506.tar.gz
org.eclipse.ecf-9cd8a481eccca619ff0659e0526fe8fe36def506.tar.xz
org.eclipse.ecf-9cd8a481eccca619ff0659e0526fe8fe36def506.zip
Added support for hyperlink detection for xmpp/xmpps, irc, ECF generic (ecftcp), and torrent urls.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.irc.ui')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml10
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlink.java104
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlinkDetector.java115
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java29
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlink.java55
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlinkDetector.java24
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties1
8 files changed, 111 insertions, 230 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF
index 55341ed69..12a3a7323 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF
@@ -11,8 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ecf.presence,
org.eclipse.ecf.presence.ui,
- org.eclipse.jface.text,
- org.eclipse.ui.workbench.texteditor
+ org.eclipse.jface.text
Eclipse-LazyStart: true
Export-Package: org.eclipse.ecf.internal.irc.ui;x-internal:=true,
org.eclipse.ecf.internal.irc.ui.wizards;x-internal:=true
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml
index d71e7dde2..1fcdc02dc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml
@@ -11,18 +11,10 @@
</extension>
<extension
- point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
- <target
- id="org.eclipse.ui.DefaultTextEditor"
- name="%TextEditorHyperlinkTarget">
- </target>
- </extension>
-
- <extension
point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
<hyperlinkDetector
activate="true"
- class="org.eclipse.ecf.internal.irc.hyperlink.IRCHyperlinkDetector"
+ class="org.eclipse.ecf.internal.irc.ui.hyperlink.IRCHyperlinkDetector"
id="org.eclipse.ecf.internal.irc.hyperlink.IRCHyperlinkDetector"
name="%IRCHyperlinkDetector"
targetId="org.eclipse.ui.DefaultTextEditor">
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlink.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlink.java
deleted file mode 100644
index 20208c42e..000000000
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlink.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2004 Composent, Inc. and others.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Composent, Inc. - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.ecf.internal.irc.hyperlink;
-
-import java.net.URI;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.core.ContainerFactory;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.internal.irc.ui.wizards.IRCConnectWizard;
-import org.eclipse.ecf.ui.IConnectWizard;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- *
- */
-public class IRCHyperlink implements IHyperlink {
-
- private static final String ECF_IRC_CONTAINER_NAME = "ecf.irc.irclib";
- private URI fURI;
- private IRegion fRegion;
-
- /**
- * Creates a new URL hyperlink.
- *
- * @param region
- * @param urlString
- */
- public IRCHyperlink(IRegion region, URI uri) {
- Assert.isNotNull(uri);
- Assert.isNotNull(region);
-
- fRegion= region;
- fURI= uri;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
- */
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open()
- */
- public void open() {
- openConnectWizard(fURI.toString());
- }
-
- private void openConnectWizard(String uri) {
- try {
- IContainer container = ContainerFactory.getDefault()
- .createContainer(ECF_IRC_CONTAINER_NAME);
- IConnectWizard icw = (IConnectWizard) new IRCConnectWizard(uri);
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- icw.init(workbench, container);
- WizardDialog dialog = new WizardDialog(window.getShell(), icw);
- dialog.open();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- return null;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- return null;
- }
-
- /**
- * Returns the URL string of this hyperlink.
- *
- * @return the URL string
- * @since 3.2
- */
- public String getURLString() {
- return fURI.toString();
- }
-
-}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlinkDetector.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlinkDetector.java
deleted file mode 100644
index 067ef5131..000000000
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/hyperlink/IRCHyperlinkDetector.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.eclipse.ecf.internal.irc.hyperlink;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector;
-
-public class IRCHyperlinkDetector extends URLHyperlinkDetector {
-
- public static final String IRC_PROTOCOL = "irc";
-
- public IRCHyperlinkDetector() {
- }
-
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
- IRegion region, boolean canShowMultipleHyperlinks) {
- if (region == null || textViewer == null)
- return null;
-
- IDocument document = textViewer.getDocument();
-
- int offset = region.getOffset();
-
- String urlString = null;
- if (document == null)
- return null;
-
- IRegion lineInfo;
- String line;
- try {
- lineInfo = document.getLineInformationOfOffset(offset);
- line = document.get(lineInfo.getOffset(), lineInfo.getLength());
- } catch (BadLocationException ex) {
- return null;
- }
-
- int offsetInLine = offset - lineInfo.getOffset();
-
- boolean startDoubleQuote = false;
- int urlOffsetInLine = 0;
- int urlLength = 0;
-
- int urlSeparatorOffset = line.indexOf("://"); //$NON-NLS-1$
- while (urlSeparatorOffset >= 0) {
-
- // URL protocol (left to "://")
- urlOffsetInLine = urlSeparatorOffset;
- char ch;
- do {
- urlOffsetInLine--;
- ch = ' ';
- if (urlOffsetInLine > -1)
- ch = line.charAt(urlOffsetInLine);
- startDoubleQuote = ch == '"';
- } while (Character.isUnicodeIdentifierStart(ch));
- urlOffsetInLine++;
-
- // Right to "://"
- StringTokenizer tokenizer = new StringTokenizer(line
- .substring(urlSeparatorOffset + 3), " \t\n\r\f<>", false); //$NON-NLS-1$
- if (!tokenizer.hasMoreTokens())
- return null;
-
- urlLength = tokenizer.nextToken().length() + 3 + urlSeparatorOffset
- - urlOffsetInLine;
- if (offsetInLine >= urlOffsetInLine
- && offsetInLine <= urlOffsetInLine + urlLength)
- break;
-
- urlSeparatorOffset = line.indexOf("://", urlSeparatorOffset + 1); //$NON-NLS-1$
- }
-
- if (urlSeparatorOffset < 0)
- return null;
-
- if (startDoubleQuote) {
- int endOffset = -1;
- int nextDoubleQuote = line.indexOf('"', urlOffsetInLine);
- int nextWhitespace = line.indexOf(' ', urlOffsetInLine);
- if (nextDoubleQuote != -1 && nextWhitespace != -1)
- endOffset = Math.min(nextDoubleQuote, nextWhitespace);
- else if (nextDoubleQuote != -1)
- endOffset = nextDoubleQuote;
- else if (nextWhitespace != -1)
- endOffset = nextWhitespace;
- if (endOffset != -1)
- urlLength = endOffset - urlOffsetInLine;
- }
-
- // Set and validate URL string
- URI uri = null;
- try {
- urlString = line.substring(urlOffsetInLine, urlOffsetInLine
- + urlLength);
- uri = new URI(urlString);
- String protocol = uri.getScheme();
- if (protocol == null || !protocol.equals(IRC_PROTOCOL))
- return null;
- } catch (URISyntaxException e) {
- return null;
- }
-
- IRegion urlRegion = new Region(lineInfo.getOffset() + urlOffsetInLine,
- urlLength);
- return new IHyperlink[] { new IRCHyperlink(urlRegion, uri) };
- }
-
-}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java
new file mode 100644
index 000000000..981303916
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java
@@ -0,0 +1,29 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.irc.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.irc.ui.messages"; //$NON-NLS-1$
+ public static String IRCHyperlink_EXCEPTION_IRC_HYPERLINK;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlink.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlink.java
new file mode 100644
index 000000000..727cd601c
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlink.java
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.irc.ui.hyperlink;
+
+import java.net.URI;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.internal.irc.ui.wizards.IRCConnectWizard;
+import org.eclipse.ecf.ui.IConnectWizard;
+import org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlink;
+import org.eclipse.jface.text.IRegion;
+
+/**
+ *
+ */
+public class IRCHyperlink extends AbstractURLHyperlink {
+
+ private static final String ECF_IRC_CONTAINER_NAME = "ecf.irc.irclib"; //$NON-NLS-1$
+
+ /**
+ * Creates a new URL hyperlink.
+ *
+ * @param region
+ * @param urlString
+ */
+ public IRCHyperlink(IRegion region, URI uri) {
+ super(region, uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlink#createConnectWizard()
+ */
+ protected IConnectWizard createConnectWizard() {
+ return new IRCConnectWizard(getURI().toString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlink#createContainer()
+ */
+ protected IContainer createContainer() throws ContainerCreateException {
+ return ContainerFactory.getDefault().createContainer(ECF_IRC_CONTAINER_NAME);
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlinkDetector.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlinkDetector.java
new file mode 100644
index 000000000..9d344e5a2
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/hyperlink/IRCHyperlinkDetector.java
@@ -0,0 +1,24 @@
+package org.eclipse.ecf.internal.irc.ui.hyperlink;
+
+import java.net.URI;
+
+import org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlinkDetector;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+
+public class IRCHyperlinkDetector extends AbstractURLHyperlinkDetector {
+
+ public static final String IRC_PROTOCOL = "irc"; //$NON-NLS-1$
+
+ public IRCHyperlinkDetector() {
+ setProtocols(new String [] { IRC_PROTOCOL });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlinkDetector#createHyperLinksForURI(org.eclipse.jface.text.IRegion, java.net.URI)
+ */
+ protected IHyperlink[] createHyperLinksForURI(IRegion region, URI uri) {
+ return new IHyperlink[] { new IRCHyperlink(region, uri) };
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties
new file mode 100644
index 000000000..4f22b430b
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties
@@ -0,0 +1 @@
+IRCHyperlink_EXCEPTION_IRC_HYPERLINK=Exception in IRC hyperlink open

Back to the top