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 90174 Details for
Bug 215473
[navigation] Show more then one hyperlink per modifier key
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fix
fix_215473.txt (text/plain), 55.33 KB, created by
Benno Baumgartner
on 2008-02-20 08:30:56 EST
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2008-02-20 08:30:56 EST
Size:
55.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.text >Index: src/org/eclipse/jface/text/AbstractInformationControlManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java,v >retrieving revision 1.45 >diff -u -r1.45 AbstractInformationControlManager.java >--- src/org/eclipse/jface/text/AbstractInformationControlManager.java 4 Feb 2008 11:41:48 -0000 1.45 >+++ src/org/eclipse/jface/text/AbstractInformationControlManager.java 20 Feb 2008 13:29:03 -0000 >@@ -15,7 +15,8 @@ > > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.Platform; >- >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.util.Geometry; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >@@ -26,9 +27,6 @@ > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Monitor; > >-import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.util.Geometry; >- > > /** > * Manages the life cycle, visibility, layout, and contents of an >@@ -389,7 +387,7 @@ > * take place > * @since 3.4 > */ >- void setInformationControlReplacer(IInformationControlReplacer replacer) { >+ protected void setInformationControlReplacer(IInformationControlReplacer replacer) { > if (fInformationControlReplacer != null) > fInformationControlReplacer.dispose(); > fInformationControlReplacer= replacer; >Index: src/org/eclipse/jface/text/TextViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java,v >retrieving revision 1.191 >diff -u -r1.191 TextViewer.java >--- src/org/eclipse/jface/text/TextViewer.java 4 Feb 2008 11:24:10 -0000 1.191 >+++ src/org/eclipse/jface/text/TextViewer.java 20 Feb 2008 13:29:04 -0000 >@@ -20,8 +20,6 @@ > import java.util.Set; > import java.util.regex.PatternSyntaxException; > >-import org.eclipse.core.runtime.Assert; >- > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.LineBackgroundEvent; > import org.eclipse.swt.custom.LineBackgroundListener; >@@ -61,13 +59,9 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.ScrollBar; > >+import org.eclipse.core.runtime.Assert; >+ > import org.eclipse.jface.internal.text.NonDeletingPositionUpdater; >-import org.eclipse.jface.text.hyperlink.HyperlinkManager; >-import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; >-import org.eclipse.jface.text.hyperlink.IHyperlinkDetectorExtension; >-import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; >-import org.eclipse.jface.text.projection.ChildDocument; >-import org.eclipse.jface.text.projection.ChildDocumentManager; > import org.eclipse.jface.viewers.IPostSelectionProvider; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionChangedListener; >@@ -75,6 +69,14 @@ > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.Viewer; > >+import org.eclipse.jface.text.hyperlink.HyperlinkManager; >+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; >+import org.eclipse.jface.text.hyperlink.IHyperlinkDetectorExtension; >+import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; >+import org.eclipse.jface.text.hyperlink.HyperlinkManager.DETECTION_STRATEGY; >+import org.eclipse.jface.text.projection.ChildDocument; >+import org.eclipse.jface.text.projection.ChildDocumentManager; >+ > > /** > * SWT based implementation of {@link ITextViewer} and its extension interfaces. >@@ -5366,7 +5368,8 @@ > */ > private void ensureHyperlinkManagerInstalled() { > if (fHyperlinkDetectors != null && fHyperlinkDetectors.length > 0 && fHyperlinkPresenter != null && fHyperlinkManager == null) { >- fHyperlinkManager= new HyperlinkManager(HyperlinkManager.FIRST); >+ DETECTION_STRATEGY strategy= fHyperlinkPresenter.canShowMultipleHyperlinks() ? HyperlinkManager.ALL : HyperlinkManager.FIRST; >+ fHyperlinkManager= new HyperlinkManager(strategy); > fHyperlinkManager.install(this, fHyperlinkPresenter, fHyperlinkDetectors, fHyperlinkStateMask); > } > } >Index: src/org/eclipse/jface/text/StickyHoverManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/StickyHoverManager.java,v >retrieving revision 1.7 >diff -u -r1.7 StickyHoverManager.java >--- src/org/eclipse/jface/text/StickyHoverManager.java 7 Feb 2008 11:00:55 -0000 1.7 >+++ src/org/eclipse/jface/text/StickyHoverManager.java 20 Feb 2008 13:29:03 -0000 >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.jface.text; > >+import org.eclipse.jface.internal.text.html.HTMLTextPresenter; >+import org.eclipse.jface.text.information.IInformationProviderExtension2; >+import org.eclipse.jface.util.Geometry; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ControlEvent; > import org.eclipse.swt.events.ControlListener; >@@ -27,10 +30,6 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; > >-import org.eclipse.jface.internal.text.html.HTMLTextPresenter; >-import org.eclipse.jface.text.information.IInformationProviderExtension2; >-import org.eclipse.jface.util.Geometry; >- > > /** > * Implements a sticky hover control, i.e. a control that replaces a hover >@@ -48,7 +47,7 @@ > * > * @since 3.4 > */ >-class StickyHoverManager extends AbstractInformationControlManager implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension, IInformationControlReplacer { >+public class StickyHoverManager extends AbstractInformationControlManager implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension, IInformationControlReplacer { > > /** > * Priority of the info controls managed by this sticky hover manager. >@@ -289,7 +288,17 @@ > * @param textViewer the text viewer > */ > public StickyHoverManager(TextViewer textViewer) { >- super(new DefaultInformationControlCreator()); >+ this(textViewer, new DefaultInformationControlCreator()); >+ } >+ >+ /** >+ * Creates a new sticky hover manager. >+ * >+ * @param textViewer the text viewer >+ * @param creator the information control creator for the sticky hover >+ */ >+ public StickyHoverManager(TextViewer textViewer, IInformationControlCreator creator) { >+ super(creator); > > fTextViewer= textViewer; > setCloser(new Closer()); >Index: src/org/eclipse/jface/text/DefaultInformationControl.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java,v >retrieving revision 1.41 >diff -u -r1.41 DefaultInformationControl.java >--- src/org/eclipse/jface/text/DefaultInformationControl.java 4 Feb 2008 11:34:08 -0000 1.41 >+++ src/org/eclipse/jface/text/DefaultInformationControl.java 20 Feb 2008 13:29:03 -0000 >@@ -11,30 +11,20 @@ > > package org.eclipse.jface.text; > >+import org.eclipse.jface.util.Geometry; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.events.DisposeEvent; >-import org.eclipse.swt.events.DisposeListener; >-import org.eclipse.swt.events.FocusListener; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.KeyListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Drawable; >-import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Layout; > import org.eclipse.swt.widgets.Shell; > >-import org.eclipse.jface.dialogs.PopupDialog; >-import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.jface.util.Geometry; >- > > /** > * Default implementation of {@link org.eclipse.jface.text.IInformationControl}. >@@ -45,7 +35,7 @@ > * > * @since 2.0 > */ >-public class DefaultInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5, DisposeListener { >+public class DefaultInformationControl extends AbstractInformationControl { > > /** > * An information presenter determines the style presentation >@@ -112,22 +102,18 @@ > */ > private static final int INNER_BORDER= 1; > >- /** >- * The control's popup dialog. >- * @since 3.2 >- */ >- private PopupDialog fPopupDialog; > /** The control's text widget */ > private StyledText fText; > /** The information presenter */ > private IInformationPresenter fPresenter; > /** A cached text presentation */ > private TextPresentation fPresentation= new TextPresentation(); >- /** The control width constraint */ >- private int fMaxWidth= -1; >- /** The control height constraint */ >- private int fMaxHeight= -1; > >+ /** >+ * Style to use for the text control. >+ * @since 3.4 >+ */ >+ private final int fTextStyle; > > /** > * Creates a default information control with the given shell as parent. The given >@@ -157,32 +143,9 @@ > * @since 3.0 > */ > public DefaultInformationControl(Shell parentShell, int shellStyle, final int style, IInformationPresenter presenter, String statusFieldText) { >- shellStyle= shellStyle | SWT.NO_FOCUS | SWT.ON_TOP; >- fPopupDialog= new PopupDialog(parentShell, shellStyle, false, false, false, false, null, statusFieldText) { >- protected Control createDialogArea(Composite parent) { >- // Text field >- fText= new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | style); >- GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); >- gd.horizontalIndent= INNER_BORDER; >- gd.verticalIndent= INNER_BORDER; >- fText.setLayoutData(gd); >- fText.addKeyListener(new KeyListener() { >- >- public void keyPressed(KeyEvent e) { >- if (e.character == 0x1B) // ESC >- close(); >- } >- >- public void keyReleased(KeyEvent e) {} >- }); >- return fText; >- } >- }; >- >+ super(parentShell, shellStyle, statusFieldText); >+ fTextStyle= style; > fPresenter= presenter; >- >- // Force create early so that listeners can be added at all times with API. >- fPopupDialog.create(); > } > > /** >@@ -237,6 +200,27 @@ > this(parent, SWT.NONE, presenter); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createContent(Composite parent) { >+ fText= new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | fTextStyle); >+ GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); >+ gd.horizontalIndent= INNER_BORDER; >+ gd.verticalIndent= INNER_BORDER; >+ fText.setLayoutData(gd); >+ fText.addKeyListener(new KeyListener() { >+ >+ public void keyPressed(KeyEvent e) { >+ if (e.character == 0x1B) // ESC >+ dispose(); >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ } >+ }); >+ } >+ > /* > * @see IInformationControl#setInformation(String) > */ >@@ -245,10 +229,19 @@ > fText.setText(content); > } else { > fPresentation.clear(); >+ >+ int maxWidth= -1; >+ int maxHight= -1; >+ Point constraints= getSizeConstraints(); >+ if (constraints != null) { >+ maxWidth= constraints.x; >+ maxHight= constraints.y; >+ } >+ > if (fPresenter instanceof IInformationPresenterExtension) >- content= ((IInformationPresenterExtension)fPresenter).updatePresentation(fPopupDialog.getShell(), content, fPresentation, fMaxWidth, fMaxHeight); >+ content= ((IInformationPresenterExtension) fPresenter).updatePresentation(getShell(), content, fPresentation, maxWidth, maxHight); > else >- content= fPresenter.updatePresentation(fPopupDialog.getShell().getDisplay(), content, fPresentation, fMaxWidth, fMaxHeight); >+ content= fPresenter.updatePresentation(getShell().getDisplay(), content, fPresentation, maxWidth, maxHight); > if (content != null) { > fText.setText(content); > TextPresentation.applyTextPresentation(fPresentation, fText); >@@ -264,45 +257,15 @@ > public void setVisible(boolean visible) { > if (visible) { > if (fText.getWordWrap()) { >- Point currentSize= fPopupDialog.getShell().getSize(); >- fPopupDialog.getShell().pack(true); >- Point newSize= fPopupDialog.getShell().getSize(); >+ Point currentSize= getShell().getSize(); >+ getShell().pack(true); >+ Point newSize= getShell().getSize(); > if (newSize.x > currentSize.x || newSize.y > currentSize.y) > setSize(currentSize.x, currentSize.y); // restore previous size > } >- fPopupDialog.open(); >- } else >- fPopupDialog.getShell().setVisible(false); >- } >- >- /* >- * @see IInformationControl#dispose() >- */ >- public void dispose() { >- fPopupDialog.close(); >- fPopupDialog= null; >- } >- >- /* >- * @see IInformationControl#setSize(int, int) >- */ >- public void setSize(int width, int height) { >- fPopupDialog.getShell().setSize(width, height); >- } >- >- /* >- * @see IInformationControl#setLocation(Point) >- */ >- public void setLocation(Point location) { >- fPopupDialog.getShell().setLocation(location); >- } >- >- /* >- * @see IInformationControl#setSizeConstraints(int, int) >- */ >- public void setSizeConstraints(int maxWidth, int maxHeight) { >- fMaxWidth= maxWidth; >- fMaxHeight= maxHeight; >+ } >+ >+ super.setVisible(visible); > } > > /* >@@ -311,77 +274,26 @@ > public Point computeSizeHint() { > // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602 > int widthHint= SWT.DEFAULT; >- if (fMaxWidth > -1 && fText.getWordWrap()) >- widthHint= fMaxWidth; >- >- return fPopupDialog.getShell().computeSize(widthHint, SWT.DEFAULT, true); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim() >- * @since 3.0 >- */ >- public Rectangle computeTrim() { >- Shell shell= fPopupDialog.getShell(); >- Rectangle trim= shell.computeTrim(0, 0, 0, 0); >- trim= Geometry.add(trim, fText.computeTrim(0, 0, 0, 0)); >+ Point constrains= getSizeConstraints(); >+ if (constrains != null && fText.getWordWrap()) >+ widthHint= constrains.x; > >- // PopupDialog adds a 1 pixel border when SWT.NO_TRIM is set: >- Layout layout= shell.getLayout(); >- if (layout instanceof GridLayout) { >- GridLayout gridLayout= (GridLayout) layout; >- int left= gridLayout.marginLeft + gridLayout.marginWidth; >- int top= gridLayout.marginTop + gridLayout.marginHeight; >- trim.x-= left; >- trim.y-= top; >- trim.width+= left + gridLayout.marginRight + gridLayout.marginWidth; >- trim.height+= top + gridLayout.marginBottom + gridLayout.marginHeight; >- } >- return trim; >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds() >- * @since 3.0 >- */ >- public Rectangle getBounds() { >- return fPopupDialog.getShell().getBounds(); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation() >- * @since 3.0 >- */ >- public boolean restoresLocation() { >- return false; >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize() >- * @since 3.0 >- */ >- public boolean restoresSize() { >- return false; >- } >- >- /* >- * @see IInformationControl#addDisposeListener(DisposeListener) >- */ >- public void addDisposeListener(DisposeListener listener) { >- fPopupDialog.getShell().addDisposeListener(listener); >+ return getShell().computeSize(widthHint, SWT.DEFAULT, true); > } > >- /* >- * @see IInformationControl#removeDisposeListener(DisposeListener) >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#computeTrim(org.eclipse.swt.graphics.Rectangle) > */ >- public void removeDisposeListener(DisposeListener listener) { >- fPopupDialog.getShell().removeDisposeListener(listener); >+ protected Rectangle computeTrim(Rectangle trim) { >+ return Geometry.add(trim, fText.computeTrim(0, 0, 0, 0)); > } > > /* > * @see IInformationControl#setForegroundColor(Color) > */ > public void setForegroundColor(Color foreground) { >+ super.setForegroundColor(foreground); >+ > fText.setForeground(foreground); > } > >@@ -389,100 +301,16 @@ > * @see IInformationControl#setBackgroundColor(Color) > */ > public void setBackgroundColor(Color background) { >+ super.setBackgroundColor(background); > fText.setBackground(background); > } > > /* >- * @see IInformationControl#isFocusControl() >- */ >- public boolean isFocusControl() { >- Shell shell= fPopupDialog.getShell(); >- return shell.getDisplay().getActiveShell() == shell; >- } >- >- /* > * @see IInformationControl#setFocus() > */ > public void setFocus() { >- fPopupDialog.getShell().forceFocus(); >+ super.setFocus(); > fText.setFocus(); > } > >- /* >- * @see IInformationControl#addFocusListener(FocusListener) >- */ >- public void addFocusListener(FocusListener listener) { >- fText.addFocusListener(listener); >- } >- >- /* >- * @see IInformationControl#removeFocusListener(FocusListener) >- */ >- public void removeFocusListener(FocusListener listener) { >- fText.removeFocusListener(listener); >- } >- >- /* >- * @see IInformationControlExtension#hasContents() >- */ >- public boolean hasContents() { >- return fText.getCharCount() > 0; >- } >- >- /** >- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) >- * @since 3.0 >- * @deprecated As of 3.2, no longer used and called >- */ >- public void widgetDisposed(DisposeEvent event) { >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control) >- * @since 3.4 >- */ >- public boolean containsControl(Control control) { >- do { >- Shell popupShell= fPopupDialog.getShell(); >- if (control == popupShell) >- return true; >- if (control instanceof Shell) >- return false; >- control= control.getParent(); >- } while (control != null); >- return false; >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension5#isVisible() >- * @since 3.4 >- */ >- public boolean isVisible() { >- Shell popupShell= fPopupDialog.getShell(); >- return popupShell != null && ! popupShell.isDisposed() && popupShell.isVisible(); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl() >- * @since 3.4 >- */ >- public boolean allowMoveIntoControl() { >- return true; >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int) >- * @since 3.4 >- */ >- public Point computeSizeConstraints(int widthInChars, int heightInChars) { >- GC gc= new GC(fText); >- gc.setFont(JFaceResources.getDialogFont()); >- int width= gc.getFontMetrics().getAverageCharWidth(); >- int height = gc.getFontMetrics().getHeight(); >- gc.dispose(); >- >- return new Point (widthInChars * width, heightInChars * height); >- } >- > } >- >Index: src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java >=================================================================== >RCS file: src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java >diff -N src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,444 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text.hyperlink; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.text.AbstractHoverInformationControlManager; >+import org.eclipse.jface.text.AbstractInformationControl; >+import org.eclipse.jface.text.IInformationControl; >+import org.eclipse.jface.text.IInformationControlCreator; >+import org.eclipse.jface.text.IInformationControlExtension2; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextHover; >+import org.eclipse.jface.text.ITextHoverExtension; >+import org.eclipse.jface.text.ITextHoverExtension2; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.ITextViewerExtension5; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.StickyHoverManager; >+import org.eclipse.jface.text.TextViewer; >+import org.eclipse.jface.util.Geometry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Link; >+import org.eclipse.swt.widgets.Shell; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+ >+/** >+ * A hyperlink presenter capable of showing multiple hyperlinks in a hover. >+ * >+ * @since 3.4 >+ */ >+public class MultipleHyperlinkPresenter extends DefaultHyperlinkPresenter { >+ >+ /** >+ * An information control capable of showing a list of links. The links can be opened. >+ */ >+ private static class LinkListInformationControl extends AbstractInformationControl implements IInformationControlExtension2 { >+ >+ private IHyperlink[] fInput; >+ private Composite fParent; >+ >+ /** >+ * Creates a link list information control with the given shell as parent. >+ * >+ * @param parentShell the parent shell >+ * @param shellStyle the additional styles for the shell >+ * @param statusFieldText the text to be used in the optional status field >+ * or <code>null</code> if the status field should be hidden >+ */ >+ public LinkListInformationControl(Shell parentShell, int shellStyle, String statusFieldText) { >+ super(parentShell, shellStyle, statusFieldText); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String) >+ */ >+ public void setInformation(String information) { >+ //replaced by IInformationControlExtension2#setInput(java.lang.Object) >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object) >+ */ >+ public void setInput(Object input) { >+ fInput= (IHyperlink[]) input; >+ deferredCreateContent(fParent); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createContent(Composite parent) { >+ fParent= new Composite(parent, SWT.NONE); >+ fParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ fParent.setLayout(new GridLayout(1, false)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint() >+ */ >+ public Point computeSizeHint() { >+ Point minSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true); >+ >+ Point constraints= getSizeConstraints(); >+ if (constraints == null) >+ return minSize; >+ >+ return Geometry.min(minSize, constraints); >+ } >+ >+ private void deferredCreateContent(Composite parent) { >+ for (int i= 0; i < fInput.length; i++) { >+ final IHyperlink link= fInput[i]; >+ >+ Link linkControl= new Link(parent, SWT.NONE); >+ linkControl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); >+ >+ String text= link.getHyperlinkText(); >+ if (text == null) >+ text= HyperlinkMessages.getString("LinkListInformationControl.unknownLink"); //$NON-NLS-1$ >+ >+ if (i == 0) { >+ text= MessageFormat.format(HyperlinkMessages.getString("LinkListInformationControl.defaultLinkPattern"), new Object[] { text }); //$NON-NLS-1$ >+ } >+ >+ linkControl.setText("<a>" + text + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ >+ linkControl.setBackground(parent.getBackground()); >+ linkControl.setForeground(parent.getForeground()); >+ >+ linkControl.addSelectionListener(new SelectionAdapter() { >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ LinkListInformationControl.this.dispose(); >+ link.open(); >+ } >+ }); >+ >+ } >+ } >+ } >+ >+ private class MultipleHyperlinkHover implements ITextHover, ITextHoverExtension, ITextHoverExtension2 { >+ >+ /** >+ * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ * @deprecated >+ */ >+ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int) >+ */ >+ public IRegion getHoverRegion(ITextViewer textViewer, int offset) { >+ return fSubjectRegion; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ */ >+ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { >+ return fHyperlinks; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator() >+ */ >+ public IInformationControlCreator getHoverControlCreator() { >+ return new IInformationControlCreator() { >+ public IInformationControl createInformationControl(Shell parent) { >+ return new LinkListInformationControl(parent, SWT.NONE, HyperlinkMessages.getString("MultipleHyperlinkPresenter.clickLinkAfordance")); //$NON-NLS-1$ >+ } >+ }; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator() >+ */ >+ public IInformationControlCreator getInformationPresenterControlCreator() { >+ return new IInformationControlCreator() { >+ public IInformationControl createInformationControl(Shell parent) { >+ return new LinkListInformationControl(parent, SWT.RESIZE | SWT.TOOL, HyperlinkMessages.getString("MultipleHyperlinkPresenter.clickLinkAfordance")); //$NON-NLS-1$ >+ } >+ }; >+ } >+ } >+ >+ private static class MultipleHyperlinkHoverManager extends AbstractHoverInformationControlManager { >+ >+ private final MultipleHyperlinkHover fHover; >+ private final ITextViewer fTextViewer; >+ private final StickyHoverManager fStickyManager; >+ >+ protected MultipleHyperlinkHoverManager(MultipleHyperlinkHover hover, ITextViewer viewer) { >+ super(hover.getHoverControlCreator()); >+ >+ fHover= hover; >+ fTextViewer= viewer; >+ >+ fStickyManager= new StickyHoverManager((TextViewer) viewer, fHover.getInformationPresenterControlCreator()); >+ setInformationControlReplacer(fStickyManager); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformation() >+ */ >+ protected void computeInformation() { >+ >+ IRegion region= fHover.getHoverRegion(fTextViewer, -1); >+ if (region == null) { >+ setInformation(null, null); >+ return; >+ } >+ >+ Rectangle area= computeArea(region); >+ if (area == null || area.isEmpty()) { >+ setInformation(null, null); >+ return; >+ } >+ >+ Object information= fHover.getHoverInfo2(fTextViewer, region); >+ setCustomInformationControlCreator(fHover.getHoverControlCreator()); >+ setInformation(information, area); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControlManager#disposeInformationControl() >+ */ >+ public void disposeInformationControl() { >+ super.disposeInformationControl(); >+ >+ fStickyManager.disposeInformationControl(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractHoverInformationControlManager#dispose() >+ */ >+ public void dispose() { >+ super.dispose(); >+ >+ fStickyManager.dispose(); >+ } >+ >+ /** >+ * Copied from TextViewerHoverManager >+ * >+ * Determines graphical area covered by the given text region. >+ * >+ * @param region the region whose graphical extend must be computed >+ * @return the graphical extend of the given region >+ */ >+ private Rectangle computeArea(IRegion region) { >+ >+ int start= 0; >+ int end= 0; >+ IRegion widgetRegion= modelRange2WidgetRange(region); >+ if (widgetRegion != null) { >+ start= widgetRegion.getOffset(); >+ end= start + widgetRegion.getLength(); >+ } >+ >+ StyledText styledText= fTextViewer.getTextWidget(); >+ Rectangle bounds; >+ if (end > 0 && start < end) >+ bounds= styledText.getTextBounds(start, end - 1); >+ else { >+ Point loc= styledText.getLocationAtOffset(start); >+ bounds= new Rectangle(loc.x, loc.y, getAverageCharWidth(), styledText.getLineHeight(start)); >+ } >+ >+ return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); >+ } >+ >+ /** >+ * Copied from TextViewerHoverManager >+ * >+ * Translates a given region of the text viewer's document into >+ * the corresponding region of the viewer's widget. >+ * >+ * @param region the document region >+ * @return the corresponding widget region >+ * @since 2.1 >+ */ >+ private IRegion modelRange2WidgetRange(IRegion region) { >+ if (fTextViewer instanceof ITextViewerExtension5) { >+ ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer; >+ return extension.modelRange2WidgetRange(region); >+ } >+ >+ IRegion visibleRegion= fTextViewer.getVisibleRegion(); >+ int start= region.getOffset() - visibleRegion.getOffset(); >+ int end= start + region.getLength(); >+ if (end > visibleRegion.getLength()) >+ end= visibleRegion.getLength(); >+ >+ return new Region(start, end - start); >+ } >+ >+ /** >+ * Copied from TextViewer#getAverageCharWidth() >+ * >+ * Returns the average character width of this viewer's widget. >+ * >+ * @return the average character width of this viewer's widget >+ */ >+ private int getAverageCharWidth() { >+ GC gc= new GC(fTextViewer.getTextWidget()); >+ gc.setFont(fTextViewer.getTextWidget().getFont()); >+ int increment= gc.getFontMetrics().getAverageCharWidth(); >+ gc.dispose(); >+ return increment; >+ } >+ } >+ >+ private ITextViewer fTextViewer; >+ >+ private IHyperlink[] fHyperlinks; >+ private Region fSubjectRegion; >+ private MultipleHyperlinkHoverManager fManager; >+ >+ private KeyListener fKeyListener; >+ >+ /** >+ * Creates a new multiple hyperlink presenter which uses >+ * {@link #HYPERLINK_COLOR} to read the color from the given preference store. >+ * >+ * @param store the preference store >+ */ >+ public MultipleHyperlinkPresenter(IPreferenceStore store) { >+ super(store); >+ } >+ >+ /** >+ * Creates a new multiple hyperlink presenter. >+ * >+ * @param color the hyperlink color, to be disposed by the caller >+ */ >+ public MultipleHyperlinkPresenter(RGB color) { >+ super(color); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#install(org.eclipse.jface.text.ITextViewer) >+ */ >+ public void install(ITextViewer viewer) { >+ super.install(viewer); >+ fTextViewer= viewer; >+ >+ fManager= new MultipleHyperlinkHoverManager(new MultipleHyperlinkHover(), fTextViewer); >+ fManager.install(viewer.getTextWidget()); >+ fManager.setSizeConstraints(100, 12, false, true); >+ >+ fKeyListener= new KeyListener() { >+ public void keyPressed(KeyEvent e) { >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ fManager.disposeInformationControl(); >+ } >+ }; >+ fTextViewer.getTextWidget().addKeyListener(fKeyListener); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#uninstall() >+ */ >+ public void uninstall() { >+ super.uninstall(); >+ >+ if (fTextViewer != null) { >+ fManager.dispose(); >+ >+ fTextViewer.getTextWidget().removeKeyListener(fKeyListener); >+ fTextViewer= null; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#canShowMultipleHyperlinks() >+ */ >+ public boolean canShowMultipleHyperlinks() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#hideHyperlinks() >+ */ >+ public void hideHyperlinks() { >+ super.hideHyperlinks(); >+ >+ fHyperlinks= null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#showHyperlinks(org.eclipse.jface.text.hyperlink.IHyperlink[]) >+ */ >+ public void showHyperlinks(final IHyperlink[] hyperlinks) { >+ super.showHyperlinks(new IHyperlink[] { hyperlinks[0] }); >+ >+ if (equals(fHyperlinks, hyperlinks)) >+ return; >+ >+ fManager.disposeInformationControl(); >+ fSubjectRegion= null; >+ fHyperlinks= hyperlinks; >+ >+ if (hyperlinks.length == 1) >+ return; >+ >+ int start= hyperlinks[0].getHyperlinkRegion().getOffset(); >+ int end= start + hyperlinks[0].getHyperlinkRegion().getLength(); >+ >+ for (int i= 1; i < hyperlinks.length; i++) { >+ int hstart= hyperlinks[i].getHyperlinkRegion().getOffset(); >+ int hend= hstart + hyperlinks[i].getHyperlinkRegion().getLength(); >+ >+ start= Math.min(start, hstart); >+ end= Math.max(end, hend); >+ } >+ >+ fSubjectRegion= new Region(start, end - start); >+ >+ fManager.showInformation(); >+ } >+ >+ private boolean equals(IHyperlink[] oldLinks, IHyperlink[] newLinks) { >+ if (oldLinks == null) >+ return false; >+ >+ if (oldLinks.length != newLinks.length) >+ return false; >+ >+ for (int i= 0; i < newLinks.length; i++) { >+ if (!oldLinks[i].getHyperlinkRegion().equals(newLinks[i].getHyperlinkRegion())) >+ return false; >+ } >+ >+ return true; >+ } >+} >Index: src/org/eclipse/jface/text/AbstractInformationControl.java >=================================================================== >RCS file: src/org/eclipse/jface/text/AbstractInformationControl.java >diff -N src/org/eclipse/jface/text/AbstractInformationControl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/AbstractInformationControl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,532 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.text; >+ >+import java.util.List; >+ >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.jface.action.ToolBarManager; >+import org.eclipse.jface.dialogs.PopupDialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.FocusListener; >+import org.eclipse.swt.events.MouseAdapter; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseMoveListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.ToolBar; >+ >+ >+/** >+ * The abstract information control can show any content inside a popup window. >+ * Additionally it can present either a status line containing a status text or >+ * a toolbar containing toolbar buttons. >+ * <p> >+ * Clients must implement {@link #createContent(Composite)} and {@link IInformationControl#setInformation(String)} >+ * </p> >+ * >+ * @since 3.4 >+ */ >+public abstract class AbstractInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5 { >+ >+ /** The control's popup dialog. */ >+ private PopupDialog fPopupDialog; >+ /** Composite containing the content created by subclasses. */ >+ private Composite fContentComposite; >+ /** Composite containing the status line content, if any.*/ >+ private Composite fStatusComposite; >+ /** Separator between content and status line, if any */ >+ private Label fSeparator; >+ /** Label in the status line, if any */ >+ private Label fStatusLabel; >+ /** Status line toolbar, if any */ >+ private ToolBar fToolBar; >+ /** Listener for shell activation/deactivation */ >+ private Listener fShellListener; >+ /** All focus listeners registered to this information control */ >+ private ListenerList fFocusListeners= new ListenerList(ListenerList.IDENTITY); >+ /** Size constrains, x is the maxWidth and y is the maxHeight, if any */ >+ private Point fSizeConstains; >+ /** The toolbar manager used by the toolbar, if any */ >+ private final ToolBarManager fToolBarManager; >+ >+ /** >+ * Creates a abstract information control with the given shell as parent. The given shell >+ * style is used for popup shell. >+ * >+ * @param parentShell the parent of the popup shell >+ * @param shellStyle style of the popup shell >+ */ >+ public AbstractInformationControl(Shell parentShell, int shellStyle) { >+ this(parentShell, shellStyle, null, null); >+ } >+ >+ /** >+ * Creates a abstract information control with the given shell as parent. The given shell >+ * style is used for popup shell. The control will show a status line with the given >+ * status field text. >+ * >+ * @param parentShell the parent of the popup shell >+ * @param shellStyle style of the popup shell >+ * @param statusFieldText text to show in the status line >+ */ >+ public AbstractInformationControl(Shell parentShell, int shellStyle, String statusFieldText) { >+ this(parentShell, shellStyle, statusFieldText, null); >+ } >+ >+ /** >+ * Creates a abstract information control with the given shell as parent. The given shell >+ * style is used for popup shell. The control will show tool bar managed by the given >+ * tool bar manager. >+ * >+ * @param parentShell the parent of the popup shell >+ * @param shellStyle style of the popup shell >+ * @param toolBarManager the manager of the popup tool bar >+ */ >+ public AbstractInformationControl(Shell parentShell, int shellStyle, ToolBarManager toolBarManager) { >+ this(parentShell, shellStyle, null, toolBarManager); >+ } >+ >+ /** >+ * Creates a abstract information control with the given shell as parent. The given shell >+ * style is used for popup shell. The control will show tool bar managed by the given >+ * tool bar manager. >+ * >+ * @param parentShell the parent of the popup shell >+ * @param shellStyle style of the popup shell >+ * @param statusFieldText text to show in the status line, if any >+ * @param toolBarManager the manager of the popup tool bar, if any >+ */ >+ private AbstractInformationControl(Shell parentShell, int shellStyle, final String statusFieldText, final ToolBarManager toolBarManager) { >+ fToolBarManager= toolBarManager; >+ fPopupDialog= new PopupDialog(parentShell, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP, false, false, false, false, null, null) { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite composite= new Composite(parent, SWT.NONE); >+ >+ composite.setLayoutData(new GridData(GridData.BEGINNING | GridData.FILL_BOTH)); >+ >+ GridLayout layout= new GridLayout(); >+ layout.marginHeight= 0; >+ layout.marginWidth= 0; >+ layout.verticalSpacing= 0; >+ composite.setLayout(layout); >+ >+ fContentComposite= new Composite(composite, SWT.NONE); >+ fContentComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ GridLayout contentLayout= new GridLayout(1, false); >+ contentLayout.marginHeight= 0; >+ contentLayout.marginWidth= 0; >+ fContentComposite.setLayout(contentLayout); >+ createContent(fContentComposite); >+ >+ if (toolBarManager != null || statusFieldText != null) { >+ fStatusComposite= new Composite(composite, SWT.NONE); >+ GridData gridData= new GridData(SWT.FILL, SWT.BOTTOM, true, false); >+ fStatusComposite.setLayoutData(gridData); >+ GridLayout gridLayout= new GridLayout(1, false); >+ gridLayout.marginHeight= 0; >+ gridLayout.marginWidth= 0; >+ gridLayout.verticalSpacing= 0; >+ fStatusComposite.setLayout(gridLayout); >+ >+ createStatusLine(fStatusComposite, statusFieldText, toolBarManager); >+ } >+ >+ return composite; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.PopupDialog#getBackgroundColorExclusions() >+ */ >+ protected List getBackgroundColorExclusions() { >+ List result= super.getBackgroundColorExclusions(); >+ >+ if (fToolBar != null) { >+ result.add(fStatusComposite); >+ result.add(fSeparator); >+ result.add(fToolBar); >+ } >+ >+ return result; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.PopupDialog#getForegroundColorExclusions() >+ */ >+ protected List getForegroundColorExclusions() { >+ List result= super.getForegroundColorExclusions(); >+ >+ if (fStatusLabel != null) { >+ result.add(fStatusLabel); >+ } >+ >+ return result; >+ } >+ }; >+ >+ // Force create early so that listeners can be added at all times with API. >+ fPopupDialog.create(); >+ } >+ >+ /** >+ * The shell of the popup window >+ * >+ * @return the shell used for the popup window >+ */ >+ protected Shell getShell() { >+ return fPopupDialog.getShell(); >+ } >+ >+ /** >+ * The toolbar manager used to manage the toolbar, or <code>null</code> if >+ * no toolbar is shown. >+ * >+ * @return the tool bar manager or <code>null</code> >+ */ >+ protected ToolBarManager getToolBarManager() { >+ return fToolBarManager; >+ } >+ >+ /** >+ * Creates the content of the popup window. >+ * >+ * @param parent the container of the content >+ */ >+ protected abstract void createContent(Composite parent); >+ >+ /* >+ * @see IInformationControl#setVisible(boolean) >+ */ >+ public void setVisible(boolean visible) { >+ if (visible) >+ fPopupDialog.open(); >+ else >+ fPopupDialog.getShell().setVisible(false); >+ } >+ >+ /* >+ * @see IInformationControl#dispose() >+ */ >+ public void dispose() { >+ fPopupDialog.close(); >+ fPopupDialog= null; >+ } >+ >+ /* >+ * @see IInformationControl#setSize(int, int) >+ */ >+ public void setSize(int width, int height) { >+ fPopupDialog.getShell().setSize(width, height); >+ } >+ >+ /* >+ * @see IInformationControl#setLocation(Point) >+ */ >+ public void setLocation(Point location) { >+ fPopupDialog.getShell().setLocation(location); >+ } >+ >+ /* >+ * @see IInformationControl#setSizeConstraints(int, int) >+ */ >+ public void setSizeConstraints(int maxWidth, int maxHeight) { >+ fSizeConstains= new Point(maxWidth, maxHeight); >+ } >+ >+ /** >+ * The size constraint or <b>null</b> if not set. >+ * >+ * @return the size constraint if set >+ * @see #setSizeConstraints(int, int) >+ */ >+ protected Point getSizeConstraints() { >+ return fSizeConstains; >+ } >+ >+ /* >+ * @see IInformationControl#computeSizeHint() >+ */ >+ public Point computeSizeHint() { >+ Point constrains= getSizeConstraints(); >+ if (constrains == null) >+ return fPopupDialog.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true); >+ >+ return fPopupDialog.getShell().computeSize(constrains.x, constrains.y, true); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim() >+ */ >+ public Rectangle computeTrim() { >+ Shell shell= fPopupDialog.getShell(); >+ Rectangle trim= shell.computeTrim(0, 0, 0, 0); >+ >+ if (fToolBar != null) { >+ trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ trim.height+= fToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ } else if (fStatusLabel != null) { >+ trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ trim.height+= fStatusLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ } >+ >+ // PopupDialog adds a 1 pixel border when SWT.NO_TRIM is set: >+ Layout layout= shell.getLayout(); >+ if (layout instanceof GridLayout) { >+ GridLayout gridLayout= (GridLayout) layout; >+ int left= gridLayout.marginLeft + gridLayout.marginWidth; >+ int top= gridLayout.marginTop + gridLayout.marginHeight; >+ trim.x-= left; >+ trim.y-= top; >+ trim.width+= left + gridLayout.marginRight + gridLayout.marginWidth; >+ trim.height+= top + gridLayout.marginBottom + gridLayout.marginHeight; >+ } >+ >+ return computeTrim(trim); >+ } >+ >+ /** >+ * Compute the trim based on the given trim. >+ * Subclasses can either adapt the given trim according to there needs >+ * or overwrite {@link #computeTrim()} directly. >+ * >+ * @param trim the proposed trim size >+ * @return the trim of the popup dialogs >+ * >+ * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim() >+ */ >+ protected Rectangle computeTrim(Rectangle trim) { >+ return trim; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds() >+ */ >+ public Rectangle getBounds() { >+ return fPopupDialog.getShell().getBounds(); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation() >+ */ >+ public boolean restoresLocation() { >+ return false; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize() >+ */ >+ public boolean restoresSize() { >+ return false; >+ } >+ >+ /* >+ * @see IInformationControl#addDisposeListener(DisposeListener) >+ */ >+ public void addDisposeListener(DisposeListener listener) { >+ fPopupDialog.getShell().addDisposeListener(listener); >+ } >+ >+ /* >+ * @see IInformationControl#removeDisposeListener(DisposeListener) >+ */ >+ public void removeDisposeListener(DisposeListener listener) { >+ fPopupDialog.getShell().removeDisposeListener(listener); >+ } >+ >+ /* >+ * @see IInformationControl#setForegroundColor(Color) >+ */ >+ public void setForegroundColor(Color foreground) { >+ fContentComposite.setForeground(foreground); >+ } >+ >+ /* >+ * @see IInformationControl#setBackgroundColor(Color) >+ */ >+ public void setBackgroundColor(Color background) { >+ fContentComposite.setBackground(background); >+ } >+ >+ /* >+ * @see IInformationControl#isFocusControl() >+ */ >+ public boolean isFocusControl() { >+ Shell shell= fPopupDialog.getShell(); >+ return shell.getDisplay().getActiveShell() == shell; >+ } >+ >+ /* >+ * @see IInformationControl#setFocus() >+ */ >+ public void setFocus() { >+ fPopupDialog.getShell().forceFocus(); >+ } >+ >+ /* >+ * @see IInformationControl#addFocusListener(FocusListener) >+ */ >+ public void addFocusListener(final FocusListener listener) { >+ if (fFocusListeners.isEmpty()) { >+ fShellListener= new Listener() { >+ >+ public void handleEvent(Event event) { >+ Object[] listeners= fFocusListeners.getListeners(); >+ for (int i= 0; i < listeners.length; i++) { >+ FocusListener focusListener= (FocusListener)listeners[i]; >+ if (event.type == SWT.Activate) { >+ focusListener.focusGained(new FocusEvent(event)); >+ } else { >+ focusListener.focusLost(new FocusEvent(event)); >+ } >+ } >+ } >+ }; >+ getShell().addListener(SWT.Deactivate, fShellListener); >+ getShell().addListener(SWT.Activate, fShellListener); >+ } >+ fFocusListeners.add(listener); >+ } >+ >+ /* >+ * @see IInformationControl#removeFocusListener(FocusListener) >+ */ >+ public void removeFocusListener(FocusListener listener) { >+ fFocusListeners.remove(listener); >+ if (fFocusListeners.isEmpty()) { >+ getShell().removeListener(SWT.Activate, fShellListener); >+ getShell().removeListener(SWT.Deactivate, fShellListener); >+ fShellListener= null; >+ } >+ } >+ >+ /* >+ * @see IInformationControlExtension#hasContents() >+ */ >+ public boolean hasContents() { >+ return true; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control) >+ */ >+ public boolean containsControl(Control control) { >+ do { >+ Shell popupShell= fPopupDialog.getShell(); >+ if (control == popupShell) >+ return true; >+ if (control instanceof Shell) >+ return false; >+ control= control.getParent(); >+ } while (control != null); >+ return false; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension5#isVisible() >+ */ >+ public boolean isVisible() { >+ Shell popupShell= fPopupDialog.getShell(); >+ return popupShell != null && !popupShell.isDisposed() && popupShell.isVisible(); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl() >+ */ >+ public boolean allowMoveIntoControl() { >+ return true; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int) >+ */ >+ public Point computeSizeConstraints(int widthInChars, int heightInChars) { >+ GC gc= new GC(fContentComposite); >+ gc.setFont(JFaceResources.getDialogFont()); >+ int width= gc.getFontMetrics().getAverageCharWidth(); >+ int height= gc.getFontMetrics().getHeight(); >+ gc.dispose(); >+ >+ return new Point(widthInChars * width, heightInChars * height); >+ } >+ >+ private void createStatusLine(Composite parent, String statusFieldText, ToolBarManager toolBarManager) { >+ fSeparator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); >+ fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ if (toolBarManager != null) { >+ fToolBar= toolBarManager.createControl(parent); >+ fToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); >+ >+ addMoveSupport(parent); >+ } else { >+ fStatusLabel= new Label(parent, SWT.RIGHT); >+ fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); >+ fStatusLabel.setText(statusFieldText); >+ >+ FontData[] fontDatas= fStatusLabel.getFont().getFontData(); >+ for (int i= 0; i < fontDatas.length; i++) { >+ fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); >+ } >+ fStatusLabel.setFont(new Font(fStatusLabel.getDisplay(), fontDatas)); >+ fStatusLabel.setForeground(fStatusLabel.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); >+ } >+ } >+ >+ private void addMoveSupport(final Control control) { >+ MouseAdapter moveSupport= new MouseAdapter() { >+ private MouseMoveListener fMoveListener; >+ >+ public void mouseDown(MouseEvent e) { >+ Point shellLoc= fPopupDialog.getShell().getLocation(); >+ final int shellX= shellLoc.x; >+ final int shellY= shellLoc.y; >+ Point mouseLoc= control.toDisplay(e.x, e.y); >+ final int mouseX= mouseLoc.x; >+ final int mouseY= mouseLoc.y; >+ fMoveListener= new MouseMoveListener() { >+ public void mouseMove(MouseEvent e2) { >+ Point mouseLoc2= control.toDisplay(e2.x, e2.y); >+ int dx= mouseLoc2.x - mouseX; >+ int dy= mouseLoc2.y - mouseY; >+ fPopupDialog.getShell().setLocation(shellX + dx, shellY + dy); >+ } >+ }; >+ control.addMouseMoveListener(fMoveListener); >+ } >+ >+ public void mouseUp(MouseEvent e) { >+ control.removeMouseMoveListener(fMoveListener); >+ fMoveListener= null; >+ } >+ }; >+ control.addMouseListener(moveSupport); >+ } >+} >#P org.eclipse.ui.editors >Index: src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java,v >retrieving revision 1.40 >diff -u -r1.40 TextSourceViewerConfiguration.java >--- src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java 18 Dec 2007 10:20:07 -0000 1.40 >+++ src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java 20 Feb 2008 13:29:06 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -16,16 +16,11 @@ > import java.util.StringTokenizer; > import java.util.Map.Entry; > >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.widgets.Shell; >- > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.IAdaptable; >- > import org.eclipse.jface.action.Action; > import org.eclipse.jface.internal.text.html.HTMLTextPresenter; > import org.eclipse.jface.preference.IPreferenceStore; >- > import org.eclipse.jface.text.DefaultInformationControl; > import org.eclipse.jface.text.DefaultTextHover; > import org.eclipse.jface.text.IInformationControl; >@@ -35,9 +30,9 @@ > import org.eclipse.jface.text.ITextViewerExtension2; > import org.eclipse.jface.text.IUndoManager; > import org.eclipse.jface.text.TextViewerUndoManager; >-import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter; > import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; > import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; >+import org.eclipse.jface.text.hyperlink.MultipleHyperlinkPresenter; > import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; > import org.eclipse.jface.text.quickassist.QuickAssistAssistant; > import org.eclipse.jface.text.reconciler.IReconciler; >@@ -48,7 +43,9 @@ > import org.eclipse.jface.text.source.IAnnotationHover; > import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.jface.text.source.SourceViewerConfiguration; >- >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; > import org.eclipse.ui.texteditor.AnnotationPreference; > import org.eclipse.ui.texteditor.HyperlinkDetectorRegistry; >@@ -300,9 +297,9 @@ > */ > public IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer) { > if (fPreferenceStore == null) >- return super.getHyperlinkPresenter(sourceViewer); >+ return new MultipleHyperlinkPresenter(new RGB(0, 0, 255)); > >- return new DefaultHyperlinkPresenter(fPreferenceStore); >+ return new MultipleHyperlinkPresenter(fPreferenceStore); > } > > /**
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 215473
:
88383
|
89409
|
89737
|
89992
|
90174
|
90984
|
90996
|
91522
|
92145