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 89737 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), 63.95 KB, created by
Benno Baumgartner
on 2008-02-14 10:38:08 EST
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2008-02-14 10:38:08 EST
Size:
63.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.text >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 14 Feb 2008 15:35:43 -0000 >@@ -21,7 +21,20 @@ > import java.util.regex.PatternSyntaxException; > > 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.hyperlink.HyperlinkManager.DETECTION_STRATEGY; >+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; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.Viewer; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.LineBackgroundEvent; > import org.eclipse.swt.custom.LineBackgroundListener; >@@ -61,20 +74,6 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.ScrollBar; > >-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; >-import org.eclipse.jface.viewers.ISelectionProvider; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.jface.viewers.Viewer; >- > > /** > * SWT based implementation of {@link ITextViewer} and its extension interfaces. >@@ -5366,7 +5365,15 @@ > */ > private void ensureHyperlinkManagerInstalled() { > if (fHyperlinkDetectors != null && fHyperlinkDetectors.length > 0 && fHyperlinkPresenter != null && fHyperlinkManager == null) { >- fHyperlinkManager= new HyperlinkManager(HyperlinkManager.FIRST); >+ >+ DETECTION_STRATEGY strategy; >+ if (fHyperlinkPresenter.canShowMultipleHyperlinks()) { >+ strategy= HyperlinkManager.ALL; >+ } else { >+ strategy= HyperlinkManager.FIRST; >+ } >+ fHyperlinkManager= new HyperlinkManager(strategy); >+ > fHyperlinkManager.install(this, fHyperlinkPresenter, fHyperlinkDetectors, fHyperlinkStateMask); > } > } >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 14 Feb 2008 15:35:42 -0000 >@@ -11,30 +11,22 @@ > > package org.eclipse.jface.text; > >+import org.eclipse.core.runtime.Assert; >+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 +37,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,11 +104,6 @@ > */ > 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 */ >@@ -127,7 +114,8 @@ > private int fMaxWidth= -1; > /** The control height constraint */ > private int fMaxHeight= -1; >- >+ /** Style to use for the text control **/ >+ private final int fTextStyle; > > /** > * Creates a default information control with the given shell as parent. The given >@@ -157,32 +145,10 @@ > * @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,18 +203,43 @@ > 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) > */ >- public void setInformation(String content) { >+ public void setInput(Object input) { >+ super.setInput(input); >+ Assert.isLegal(input instanceof String); >+ String content= (String) input; >+ > if (fPresenter == null) { > fText.setText(content); > } else { > fPresentation.clear(); > if (fPresenter instanceof IInformationPresenterExtension) >- content= ((IInformationPresenterExtension)fPresenter).updatePresentation(fPopupDialog.getShell(), content, fPresentation, fMaxWidth, fMaxHeight); >+ content= ((IInformationPresenterExtension) fPresenter).updatePresentation(getShell(), content, fPresentation, fMaxWidth, fMaxHeight); > else >- content= fPresenter.updatePresentation(fPopupDialog.getShell().getDisplay(), content, fPresentation, fMaxWidth, fMaxHeight); >+ content= fPresenter.updatePresentation(getShell().getDisplay(), content, fPresentation, fMaxWidth, fMaxHeight); > if (content != null) { > fText.setText(content); > TextPresentation.applyTextPresentation(fPresentation, fText); >@@ -264,43 +255,23 @@ > 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); >+ } >+ >+ super.setVisible(visible); > } > > /* > * @see IInformationControl#setSizeConstraints(int, int) > */ > public void setSizeConstraints(int maxWidth, int maxHeight) { >+ super.setSizeConstraints(maxWidth, maxHeight); >+ > fMaxWidth= maxWidth; > fMaxHeight= maxHeight; > } >@@ -314,74 +285,22 @@ > 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)); >- >- // 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; >+ return getShell().computeSize(widthHint, SWT.DEFAULT, true); > } > >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize() >- * @since 3.0 >- */ >- public boolean restoresSize() { >- return false; >- } >- >- /* >- * @see IInformationControl#addDisposeListener(DisposeListener) >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#computeTrim(org.eclipse.swt.graphics.Rectangle) > */ >- public void addDisposeListener(DisposeListener listener) { >- fPopupDialog.getShell().addDisposeListener(listener); >- } >- >- /* >- * @see IInformationControl#removeDisposeListener(DisposeListener) >- */ >- 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,22 +308,17 @@ > * @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(); > } > >@@ -412,6 +326,8 @@ > * @see IInformationControl#addFocusListener(FocusListener) > */ > public void addFocusListener(FocusListener listener) { >+ super.addFocusListener(listener); >+ > fText.addFocusListener(listener); > } > >@@ -419,70 +335,8 @@ > * @see IInformationControl#removeFocusListener(FocusListener) > */ > public void removeFocusListener(FocusListener listener) { >+ super.removeFocusListener(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/URLHyperlink.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlink.java,v >retrieving revision 1.12 >diff -u -r1.12 URLHyperlink.java >--- src/org/eclipse/jface/text/hyperlink/URLHyperlink.java 8 Feb 2008 08:54:53 -0000 1.12 >+++ src/org/eclipse/jface/text/hyperlink/URLHyperlink.java 14 Feb 2008 15:35:43 -0000 >@@ -10,12 +10,13 @@ > *******************************************************************************/ > package org.eclipse.jface.text.hyperlink; > >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.jface.text.IRegion; > import org.eclipse.swt.SWT; > import org.eclipse.swt.program.Program; > >-import org.eclipse.core.runtime.Assert; >+import com.ibm.icu.text.MessageFormat; > >-import org.eclipse.jface.text.IRegion; > > > /** >@@ -81,6 +82,9 @@ > * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText() > */ > public String getHyperlinkText() { >+ if (fURLString != null) >+ return MessageFormat.format(HyperlinkMessages.getString("URLHyperlink.hyperlinkText"), new Object[] { fURLString }); //$NON-NLS-1$ >+ > return null; > } > >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,261 @@ >+/******************************************************************************* >+ * 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.core.runtime.Assert; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.text.AbstractInformationControl; >+import org.eclipse.jface.text.IInformationControl; >+import org.eclipse.jface.text.IInformationControlCreator; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.information.IInformationProvider; >+import org.eclipse.jface.text.information.IInformationProviderExtension; >+import org.eclipse.jface.text.information.IInformationProviderExtension2; >+import org.eclipse.jface.text.information.InformationPresenter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.layout.GridData; >+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 information pop up >+ * >+ * @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 { >+ >+ /** >+ * 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.IInformationControlExtension2#setInput(java.lang.Object) >+ */ >+ public void setInput(Object input) { >+ super.setInput(input); >+ Assert.isTrue(input instanceof IHyperlink[], "Must provide an array of IHyperlink as input"); //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createContent(Composite parent) { >+ >+ IHyperlink[] links= (IHyperlink[]) getInput(); >+ for (int i= 0; i < links.length; i++) { >+ final IHyperlink link= links[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 MultipleHyperlinkInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 { >+ >+ /** >+ * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ * @deprecated >+ */ >+ public String getInformation(ITextViewer textViewer, IRegion subject) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int) >+ */ >+ public IRegion getSubject(ITextViewer textViewer, int offset) { >+ return fSubjectRegion; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ */ >+ public Object getInformation2(ITextViewer textViewer, IRegion subject) { >+ return fHyperlinks; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.information.IInformationProviderExtension2#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 final ITextViewer fTextViewer; >+ private final InformationPresenter fPresenter; >+ >+ private IHyperlink[] fHyperlinks; >+ private Region fSubjectRegion; >+ >+ /** >+ * 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 >+ * @param viewer the viewer in which to present the hyperlinks >+ */ >+ public MultipleHyperlinkPresenter(IPreferenceStore store, ITextViewer viewer) { >+ super(store); >+ >+ fTextViewer= viewer; >+ fPresenter= createInformationPresenter(); >+ fPresenter.install(fTextViewer); >+ } >+ >+ /** >+ * Creates a new multiple hyperlink presenter. >+ * >+ * @param color the hyperlink color, to be disposed by the caller >+ * @param viewer the viewer in which to present the hyperlinks >+ */ >+ public MultipleHyperlinkPresenter(RGB color, ITextViewer viewer) { >+ super(color); >+ >+ fTextViewer= viewer; >+ fPresenter= createInformationPresenter(); >+ fPresenter.install(fTextViewer); >+ } >+ >+ /* (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; >+ >+ fHyperlinks= hyperlinks; >+ fPresenter.disposeInformationControl(); >+ >+ 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); >+ >+ fPresenter.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; >+ } >+ >+ private InformationPresenter createInformationPresenter() { >+ final MultipleHyperlinkInformationProvider informationProvider= new MultipleHyperlinkInformationProvider(); >+ >+ InformationPresenter result= new InformationPresenter(informationProvider.getInformationPresenterControlCreator()) { >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.information.InformationPresenter#getInformationProvider(java.lang.String) >+ */ >+ public IInformationProvider getInformationProvider(String contentType) { >+ return informationProvider; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControlManager#showInformation() >+ */ >+ public void showInformation() { >+ doShowInformation(); >+ } >+ }; >+ >+ result.takesFocusWhenVisible(false); >+ return result; >+ } >+} >Index: src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.java >=================================================================== >RCS file: src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.java >diff -N src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 java.util.MissingResourceException; >+import java.util.ResourceBundle; >+ >+/** >+ * @since 3.4 >+ */ >+public class HyperlinkMessages { >+ private static final String BUNDLE_NAME= "org.eclipse.jface.text.hyperlink.HyperlinkMessages"; //$NON-NLS-1$ >+ >+ private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); >+ >+ private HyperlinkMessages() { >+ } >+ >+ public static String getString(String key) { >+ try { >+ return RESOURCE_BUNDLE.getString(key); >+ } catch (MissingResourceException e) { >+ return '!' + key + '!'; >+ } >+ } >+} >Index: src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.properties >=================================================================== >RCS file: src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.properties >diff -N src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/text/hyperlink/HyperlinkMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+LinkListInformationControl.defaultLinkPattern={0} (default) >+LinkListInformationControl.unknownLink=Unknown Hyperlink >+ >+MultipleHyperlinkPresenter.clickLinkAfordance=Click link to open >+ >+URLHyperlink.hyperlinkText=Open ''{0}'' in a browser >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,513 @@ >+/******************************************************************************* >+ * 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; >+ >+import java.util.List; >+ >+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.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+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.Label; >+import org.eclipse.swt.widgets.Layout; >+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)}</p> >+ * >+ * @since 3.4 >+ */ >+public abstract class AbstractInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, IInformationControlExtension3, IInformationControlExtension5, DisposeListener { >+ >+ /** 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; >+ /** The input for this control, if set*/ >+ private Object fInput; >+ >+ /** >+ * 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) { >+ 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); >+ >+ GridData data= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); >+ data.horizontalIndent= 0; >+ data.verticalIndent= 0; >+ composite.setLayoutData(data); >+ >+ 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)); >+ fContentComposite.setLayout(new GridLayout(1, false)); >+ >+ 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 input for the control or null if not yet set >+ * >+ * @return the input for the control or null if not yet set >+ * @since 3.4 >+ */ >+ protected Object getInput() { >+ return fInput; >+ } >+ >+ /** >+ * The shell of the popup window >+ * >+ * @return the shell used for the popup window >+ * @since 3.4 >+ */ >+ protected Shell getShell() { >+ return fPopupDialog.getShell(); >+ } >+ >+ /** >+ * Create the content of the popup window. This method >+ * is called after the input has been set. >+ * >+ * @param parent the container of the content. >+ * @since 3.4 >+ */ >+ protected abstract void createContent(Composite parent); >+ >+ /* >+ * @see IInformationControl#setInformation(String) >+ */ >+ public void setInformation(String content) { >+ setInput(content); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object) >+ */ >+ public void setInput(Object input) { >+ fInput= input; >+ createContent(fContentComposite); >+ } >+ >+ /* >+ * @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) { >+ } >+ >+ /* >+ * @see IInformationControl#computeSizeHint() >+ */ >+ public Point computeSizeHint() { >+ return fPopupDialog.getShell().computeSize(SWT.DEFAULT, 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); >+ >+ 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() >+ * @since 3.4 >+ */ >+ protected Rectangle computeTrim(Rectangle trim) { >+ 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); >+ } >+ >+ /* >+ * @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(FocusListener listener) { >+ } >+ >+ /* >+ * @see IInformationControl#removeFocusListener(FocusListener) >+ */ >+ public void removeFocusListener(FocusListener listener) { >+ } >+ >+ /* >+ * @see IInformationControlExtension#hasContents() >+ */ >+ public boolean hasContents() { >+ return true; >+ } >+ >+ /** >+ * @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(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 14 Feb 2008 15:35:46 -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 DefaultHyperlinkPresenter(fPreferenceStore); >+ return new MultipleHyperlinkPresenter(new RGB(0, 0, 255), sourceViewer); >+ >+ return new MultipleHyperlinkPresenter(fPreferenceStore, sourceViewer); > } > > /** >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java,v >retrieving revision 1.13 >diff -u -r1.13 NLSKeyHyperlinkDetector.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java 27 Aug 2007 14:39:36 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java 14 Feb 2008 15:35:48 -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 >@@ -49,7 +49,7 @@ > */ > public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { > ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); >- if (region == null || textEditor == null || canShowMultipleHyperlinks) >+ if (region == null || textEditor == null) > return null; > > IEditorSite site= textEditor.getEditorSite(); >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.properties,v >retrieving revision 1.157 >diff -u -r1.157 JavaEditorMessages.properties >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.properties 22 Jan 2008 09:13:04 -0000 1.157 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.properties 14 Feb 2008 15:35:47 -0000 >@@ -153,8 +153,12 @@ > JavaEditor_occurrence_tooltip=Occurrence of ''{0}'' > JavaEditorBreadcrumbActionGroup_go_to_editor_action_label=&Go to Editor > >+JavaElementHyperlink_hyperlinkTextDetail=Open declaration of ''{0}'' >+JavaElementHyperlink_hyperlinkTextGeneric=Open declaration >+ > Editor_OpenPropertiesFile_error_keyNotFound= The key "{0}" is not defined in this properties file > Editor_OpenPropertiesFile_error_fileNotFound_dialogMessage= Could not determine properties file > Editor_OpenPropertiesFile_error_openEditor_dialogMessage= Could not open the properties file editor for: {0} >+Editor_OpenPropertiesFile_hyperlinkText=Open ''{0}'' in ''{1}'' > > Editor_MoveLines_IllegalMove_status= Move not possible - Uncheck "Show Source of Selected Element Only" to see the entire document >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java,v >retrieving revision 1.7 >diff -u -r1.7 JavaElementHyperlink.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java 29 May 2007 18:41:46 -0000 1.7 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlink.java 14 Feb 2008 15:35:47 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 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 >@@ -10,13 +10,21 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.javaeditor; > >+import com.ibm.icu.text.MessageFormat; >+ > import org.eclipse.core.runtime.Assert; > > import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.StructuredSelection; > > import org.eclipse.jface.text.IRegion; > import org.eclipse.jface.text.hyperlink.IHyperlink; > >+import org.eclipse.jdt.core.IJavaElement; >+ >+import org.eclipse.jdt.ui.JavaElementLabels; >+import org.eclipse.jdt.ui.actions.SelectionDispatchAction; >+ > > /** > * Java element hyperlink. >@@ -27,17 +35,22 @@ > > private final IRegion fRegion; > private final IAction fOpenAction; >+ private final IJavaElement[] fElements; > > > /** > * Creates a new Java element hyperlink. >+ * @param region the region of the link >+ * @param openAction the action to use to open the java elements >+ * @param elements the java elements to open > */ >- public JavaElementHyperlink(IRegion region, IAction openAction) { >+ public JavaElementHyperlink(IRegion region, IAction openAction, IJavaElement[] elements) { > Assert.isNotNull(openAction); > Assert.isNotNull(region); > > fRegion= region; > fOpenAction= openAction; >+ fElements= elements; > } > > /* >@@ -53,7 +66,11 @@ > * @since 3.1 > */ > public void open() { >- fOpenAction.run(); >+ if (fOpenAction instanceof SelectionDispatchAction) { >+ ((SelectionDispatchAction) fOpenAction).run(new StructuredSelection(fElements)); >+ } else { >+ fOpenAction.run(); >+ } > } > > /* >@@ -69,6 +86,10 @@ > * @since 3.1 > */ > public String getHyperlinkText() { >- return null; >+ if (fElements.length != 1) { >+ return JavaEditorMessages.JavaElementHyperlink_hyperlinkTextGeneric; >+ } else { >+ return MessageFormat.format(JavaEditorMessages.JavaElementHyperlink_hyperlinkTextDetail, new Object[] { JavaElementLabels.getElementLabel(fElements[0], JavaElementLabels.ALL_POST_QUALIFIED) }); >+ } > } > } >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.java,v >retrieving revision 1.30 >diff -u -r1.30 JavaEditorMessages.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.java 22 Jan 2008 09:13:04 -0000 1.30 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorMessages.java 14 Feb 2008 15:35:47 -0000 >@@ -156,9 +156,14 @@ > public static String JavaEditor_markOccurrences_job_name; > public static String JavaEditor_occurrence_tooltip; > public static String JavaEditorBreadcrumbActionGroup_go_to_editor_action_label; >+ >+ public static String JavaElementHyperlink_hyperlinkTextDetail; >+ public static String JavaElementHyperlink_hyperlinkTextGeneric; >+ > public static String Editor_OpenPropertiesFile_error_keyNotFound; > public static String Editor_OpenPropertiesFile_error_fileNotFound_dialogMessage; > public static String Editor_OpenPropertiesFile_error_openEditor_dialogMessage; >+ public static String Editor_OpenPropertiesFile_hyperlinkText; > public static String Editor_MoveLines_IllegalMove_status; > public static String BasicEditorActionContributor_specific_content_assist_menu; > >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java,v >retrieving revision 1.12 >diff -u -r1.12 JavaElementHyperlinkDetector.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java 23 Nov 2007 14:11:23 -0000 1.12 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java 14 Feb 2008 15:35:47 -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 >@@ -39,7 +39,7 @@ > */ > public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { > ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); >- if (region == null || canShowMultipleHyperlinks || !(textEditor instanceof JavaEditor)) >+ if (region == null || !(textEditor instanceof JavaEditor)) > return null; > > IAction openAction= textEditor.getAction("OpenEditor"); //$NON-NLS-1$ >@@ -61,7 +61,7 @@ > IJavaElement[] elements= null; > elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength()); > if (elements != null && elements.length > 0) >- return new IHyperlink[] {new JavaElementHyperlink(wordRegion, openAction)}; >+ return new IHyperlink[] { new JavaElementHyperlink(wordRegion, openAction, elements) }; > } catch (JavaModelException e) { > return null; > } >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java,v >retrieving revision 1.18 >diff -u -r1.18 NLSKeyHyperlink.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 3 Oct 2007 13:03:32 -0000 1.18 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 14 Feb 2008 15:35:47 -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 >@@ -36,6 +36,7 @@ > > import org.eclipse.jdt.internal.corext.refactoring.nls.AccessorClassReference; > import org.eclipse.jdt.internal.corext.refactoring.nls.NLSHintHelper; >+import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring; > import org.eclipse.jdt.internal.corext.refactoring.nls.PropertyFileDocumentModel; > import org.eclipse.jdt.internal.corext.util.Messages; > >@@ -194,6 +195,8 @@ > * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText() > */ > public String getHyperlinkText() { >- return null; >+ String bundleName= fAccessorClassReference.getResourceBundleName(); >+ String propertyFileName= bundleName.substring(bundleName.lastIndexOf('.') + 1, bundleName.length()) + NLSRefactoring.PROPERTY_FILE_EXT; >+ return Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_hyperlinkText, new Object[] { fKeyName, propertyFileName }); > } > } >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlinkDetector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlinkDetector.java,v >retrieving revision 1.12 >diff -u -r1.12 PropertyKeyHyperlinkDetector.java >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlinkDetector.java 26 Jan 2007 10:02:40 -0000 1.12 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlinkDetector.java 14 Feb 2008 15:35:48 -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 >@@ -50,7 +50,7 @@ > */ > public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { > ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); >- if (region == null || textEditor == null || canShowMultipleHyperlinks) >+ if (region == null || textEditor == null) > return null; > > IEditorSite site= textEditor.getEditorSite(); >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.java,v >retrieving revision 1.7 >diff -u -r1.7 PropertiesFileEditorMessages.java >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.java 19 Apr 2005 13:29:11 -0000 1.7 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.java 14 Feb 2008 15:35:48 -0000 >@@ -51,6 +51,7 @@ > public static String OpenAction_error_messageErrorResolvingSelection; > public static String OpenAction_error_messageErrorSearchingKey; > public static String OpenAction_error_messageNoResult; >+ public static String OpenAction_hyperlinkText; > public static String OpenAction_SelectionDialog_title; > public static String OpenAction_SelectionDialog_details; > public static String OpenAction_SelectionDialog_message; >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.properties,v >retrieving revision 1.9 >diff -u -r1.9 PropertiesFileEditorMessages.properties >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.properties 13 Apr 2005 17:35:12 -0000 1.9 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEditorMessages.properties 14 Feb 2008 15:35:48 -0000 >@@ -21,6 +21,7 @@ > OpenAction_error_messageErrorResolvingSelection= Error resolving current text selection > OpenAction_error_messageErrorSearchingKey= Error searching references to the selected properties key > OpenAction_error_messageNoResult= Found no references to the selected properties key >+OpenAction_hyperlinkText=Search for usages of ''{0}'' > > OpenAction_SelectionDialog_title= Open > OpenAction_SelectionDialog_details= &Details >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlink.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlink.java,v >retrieving revision 1.21 >diff -u -r1.21 PropertyKeyHyperlink.java >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlink.java 29 Oct 2007 12:09:49 -0000 1.21 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertyKeyHyperlink.java 14 Feb 2008 15:35:48 -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 >@@ -504,6 +504,6 @@ > * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText() > */ > public String getHyperlinkText() { >- return null; >+ return Messages.format(PropertiesFileEditorMessages.OpenAction_hyperlinkText, fPropertiesKey); > } > }
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