Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 75243 Details for
Bug 197745
[IRC] Hyperlink support for IRC channels within the IRC UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to add chat room hyperlink
197745_patch.diff (text/plain), 10.37 KB, created by
Abner Ballardo
on 2007-08-02 12:15:32 EDT
(
hide
)
Description:
Patch to add chat room hyperlink
Filename:
MIME Type:
Creator:
Abner Ballardo
Created:
2007-08-02 12:15:32 EDT
Size:
10.37 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.provider.irc.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.27 >diff -u -r1.27 MANIFEST.MF >--- META-INF/MANIFEST.MF 14 Jul 2007 21:04:47 -0000 1.27 >+++ META-INF/MANIFEST.MF 2 Aug 2007 15:56:37 -0000 >@@ -12,7 +12,8 @@ > org.eclipse.ecf.presence, > org.eclipse.ecf.presence.ui, > org.eclipse.jface.text, >- org.eclipse.ecf.provider.irc >+ org.eclipse.ecf.provider.irc, >+ org.eclipse.ui.workbench.texteditor > Eclipse-LazyStart: true > Export-Package: org.eclipse.ecf.internal.irc.ui;x-internal:=true, > org.eclipse.ecf.internal.irc.ui.wizards;x-internal:=true >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/plugin.properties,v >retrieving revision 1.4 >diff -u -r1.4 plugin.properties >--- plugin.properties 24 Jul 2007 15:25:19 -0000 1.4 >+++ plugin.properties 2 Aug 2007 15:56:37 -0000 >@@ -11,6 +11,7 @@ > > TextEditorHyperlinkTarget= Textual Editors > IRCHyperlinkDetector= IRC >+ChannelHyperlinkDetector= Channel > > KickAction_Label=Kick > BanAction_Label=Ban >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 24 Jul 2007 15:25:19 -0000 1.6 >+++ plugin.xml 2 Aug 2007 15:56:37 -0000 >@@ -9,6 +9,7 @@ > id="org.eclipse.ecf.provider.ui.irc.connectWizard" > name="IRC"/> > </extension> >+ > > <extension > point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> >@@ -19,6 +20,13 @@ > name="%IRCHyperlinkDetector" > targetId="org.eclipse.ui.DefaultTextEditor"> > </hyperlinkDetector> >+ <hyperlinkDetector >+ activate="true" >+ class="org.eclipse.ecf.internal.irc.ui.hyperlink.ChannelHyperlinkDetector" >+ id="org.eclipse.ecf.internal.irc.ui.hyperlink.ChannelHyperlinkDetector" >+ name="%ChannelHyperlinkDetector" >+ targetId="org.eclipse.ui.DefaultTextEditor"> >+ </hyperlinkDetector> > </extension> > <extension > point="org.eclipse.ui.popupMenus"> >@@ -75,5 +83,15 @@ > </visibility> > </viewerContribution> > </extension> >+ <extension >+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets"> >+ <target >+ id="org.eclipse.ui.DefaultTextEditor" >+ name="Charoom View"> >+ <context >+ type="org.eclipse.ui.IViewPart"> >+ </context> >+ </target> >+ </extension> > > </plugin> >Index: src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlink.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlink.java >diff -N src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlink.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlink.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+package org.eclipse.ecf.internal.irc.ui.hyperlink; >+ >+import org.eclipse.ecf.presence.chatroom.IChatRoomContainer; >+import org.eclipse.ecf.presence.chatroom.IChatRoomManager; >+import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.hyperlink.IHyperlink; >+ >+public class ChannelHyperlink implements IHyperlink { >+ private Region region; >+ >+ private String channel; >+ >+ private String typeLabel; >+ >+ private String hyperlinkText; >+ >+ private ChatRoomManagerView view; >+ >+ public ChannelHyperlink(ChatRoomManagerView view, String channel, >+ Region region) { >+ this.channel = channel; >+ this.region = region; >+ this.view = view; >+ } >+ >+ public IRegion getHyperlinkRegion() { >+ return this.region; >+ } >+ >+ public String getHyperlinkText() { >+ return this.hyperlinkText; >+ } >+ >+ public String getTypeLabel() { >+ return this.typeLabel; >+ } >+ >+ public void open() { >+ IChatRoomContainer container = view.getActiveChatRoomContainer(); >+ IChatRoomManager manager = (IChatRoomManager) container >+ .getAdapter(IChatRoomManager.class); >+ >+ view.joinRoom(manager.getChatRoomInfo(channel), ""); >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlinkDetector.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlinkDetector.java >diff -N src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlinkDetector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/irc/ui/hyperlink/ChannelHyperlinkDetector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+package org.eclipse.ecf.internal.irc.ui.hyperlink; >+ >+import java.util.StringTokenizer; >+ >+import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView; >+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.ui.IViewPart; >+ >+public class ChannelHyperlinkDetector extends >+ org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector { >+ public static final String DEFAULT_PREFIX = "#"; //$NON-NLS-1$ >+ public static final String DEFAULT_ENDDELIMITERS = " \t\n\r\f<>"; //$NON-NLS-1$ >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, >+ * org.eclipse.jface.text.IRegion, boolean) >+ */ >+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, >+ IRegion region, boolean canShowMultipleHyperlinks) { >+ if (region == null || textViewer == null) >+ return null; >+ >+ ChatRoomManagerView view = (ChatRoomManagerView) getAdapter(IViewPart.class); >+ >+ IDocument document = textViewer.getDocument(); >+ if (document == null) >+ return null; >+ >+ int offset = region.getOffset(); >+ >+ IRegion lineInfo; >+ String line; >+ try { >+ lineInfo = document.getLineInformationOfOffset(offset); >+ line = document.get(lineInfo.getOffset(), lineInfo.getLength()); >+ } catch (BadLocationException ex) { >+ return null; >+ } >+ >+ String detectedSubstring = detectSubstring(line, offset >+ - lineInfo.getOffset()); >+ >+ if (detectedSubstring != null) >+ return createHyperLinksForChannel(view, detectedSubstring, new Region( >+ lineInfo.getOffset() + line.indexOf(detectedSubstring), >+ detectedSubstring.length())); >+ >+ return null; >+ } >+ >+ private IHyperlink[] createHyperLinksForChannel(ChatRoomManagerView view, String channel, >+ Region region) { >+ return new IHyperlink[] { new ChannelHyperlink(view, channel, region) }; >+ } >+ >+ private String detectSubstring(String fromLine, int offsetInLine) { >+ int resultLength = 0; >+ >+ int separatorOffset = fromLine.indexOf(DEFAULT_PREFIX); >+ while (separatorOffset >= 0) { >+ StringTokenizer tokenizer = new StringTokenizer(fromLine >+ .substring(separatorOffset + DEFAULT_PREFIX.length()), >+ DEFAULT_ENDDELIMITERS, false); >+ if (!tokenizer.hasMoreTokens()) >+ return null; >+ >+ resultLength = tokenizer.nextToken().length() >+ + DEFAULT_PREFIX.length(); >+ if (offsetInLine >= separatorOffset >+ && offsetInLine <= separatorOffset + resultLength) >+ break; >+ >+ separatorOffset = fromLine.indexOf(DEFAULT_PREFIX, >+ separatorOffset + 1); >+ } >+ >+ if (separatorOffset < 0) >+ return null; >+ >+ return fromLine.substring(separatorOffset, separatorOffset >+ + resultLength); >+ } >+ >+} >#P org.eclipse.ecf.provider.irc >Index: src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java,v >retrieving revision 1.10 >diff -u -r1.10 IRCChannelContainer.java >--- src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java 26 May 2007 16:57:24 -0000 1.10 >+++ src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java 2 Aug 2007 15:56:40 -0000 >@@ -290,6 +290,9 @@ > * @see org.eclipse.ecf.core.IContainer#getAdapter(java.lang.Class) > */ > public Object getAdapter(Class serviceType) { >+ if (serviceType != null && serviceType.isInstance(rootContainer)) >+ return rootContainer; >+ > return null; > } > >#P org.eclipse.ecf.presence.ui >Index: src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java,v >retrieving revision 1.23 >diff -u -r1.23 ChatRoomManagerView.java >--- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 30 Jul 2007 20:56:48 -0000 1.23 >+++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 2 Aug 2007 15:56:43 -0000 >@@ -17,6 +17,7 @@ > import java.text.SimpleDateFormat; > import java.util.ArrayList; > import java.util.Date; >+import java.util.HashMap; > import java.util.Hashtable; > import java.util.Iterator; > import java.util.Map; >@@ -56,6 +57,7 @@ > import org.eclipse.jface.text.Document; > import org.eclipse.jface.text.ITextSelection; > import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.jface.text.source.SourceViewer; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; >@@ -282,7 +284,16 @@ > true, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI > | SWT.READ_ONLY); > result.configure(new TextSourceViewerConfiguration(EditorsUI >- .getPreferenceStore())); >+ .getPreferenceStore()){ >+ protected Map getHyperlinkDetectorTargets( >+ ISourceViewer sourceViewer) { >+ Map targets = new HashMap(); >+ targets >+ .put( >+ "org.eclipse.ui.DefaultTextEditor", ChatRoomManagerView.this); //$NON-NLS-1$ >+ return targets; >+ } >+ }); > result.setDocument(new Document()); > return result.getTextWidget(); > } catch (Exception e) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 197745
:
75243
|
75267
|
94158
|
94159