[jbosstools-commits] JBoss Tools SVN: r42638 - in trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink: xpl and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jul 18 19:29:09 EDT 2012


Author: scabanovich
Date: 2012-07-18 19:29:08 -0400 (Wed, 18 Jul 2012)
New Revision: 42638

Removed:
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/AbstractInformationControl.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java
Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/AlternativeInjectedPointListHyperlink.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventListHyperlink.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/MultipleHyperlinkPresenterManager.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodListHyperlink.java
   trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java
Log:
JBIDE-12295
https://issues.jboss.org/browse/JBIDE-12295
Open-on of multiple declarations of ui:param with the same name are supported.

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/AlternativeInjectedPointListHyperlink.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/AlternativeInjectedPointListHyperlink.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/AlternativeInjectedPointListHyperlink.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -47,7 +47,7 @@
 		if(hyperlinks.length == 1){
 			((InjectedPointHyperlink)hyperlinks[0]).doHyperlink(region);
 		}else{
-			InformationControlManager.showHyperlinks(CDIExtensionsMessages.CDI_SHOW_ALL_ELIGIBLE_BEANS_TITLE, viewer, hyperlinks);
+			InformationControlManager.instance.showHyperlinks(CDIExtensionsMessages.CDI_SHOW_ALL_ELIGIBLE_BEANS_TITLE, viewer, hyperlinks);
 		}
 	}
 

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventListHyperlink.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventListHyperlink.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventListHyperlink.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -48,7 +48,7 @@
 		if(hyperlinks.length == 1){
 			((EventHyperlink)hyperlinks[0]).doHyperlink(region);
 		}else{
-			InformationControlManager.showHyperlinks(CDIExtensionsMessages.CDI_EVENT_TITLE, viewer, hyperlinks);
+			InformationControlManager.instance.showHyperlinks(CDIExtensionsMessages.CDI_EVENT_TITLE, viewer, hyperlinks);
 		}
 	}
 

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -10,35 +10,17 @@
  ******************************************************************************/ 
 package org.jboss.tools.cdi.text.ext.hyperlink;
 
-import org.eclipse.jface.text.AbstractInformationControlManager;
 import org.eclipse.jface.text.IInformationControl;
 import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.hyperlink.IHyperlink;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
 import org.jboss.tools.cdi.text.ext.hyperlink.xpl.HierarchyInformationControl;
-import org.jboss.tools.cdi.text.ext.hyperlink.xpl.InformationPresenter;
 
-public class InformationControlManager {
-	public static IInformationControl showHyperlinks(String title, ITextViewer viewer, IHyperlink[] hyperlinks){
-		return showHyperlinks(title, viewer, hyperlinks, false);
-	}
+public class InformationControlManager extends org.jboss.tools.common.text.ext.hyperlink.InformationControlManager {
+	public static final InformationControlManager instance = new InformationControlManager();
 	
-	public static IInformationControl showHyperlinks(String title, ITextViewer viewer, IHyperlink[] hyperlinks, boolean test){
-		InformationPresenter presenter= new InformationPresenter(viewer, getHierarchyPresenterControlCreator(title, hyperlinks));
-		presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
-		presenter.setSizeConstraints(60, 10, true, false);
-		presenter.install(viewer.getTextWidget());
-		if(test){
-			return presenter.showInformationForTest();
-		} else {
-			presenter.showInformation();
-			return null;
-		}
-	}
-	
-	private static IInformationControlCreator getHierarchyPresenterControlCreator(final String title, final IHyperlink[] hyperlinks) {
+	protected IInformationControlCreator getHierarchyPresenterControlCreator(final String title, final IHyperlink[] hyperlinks) {
 		return new IInformationControlCreator() {
 			public IInformationControl createInformationControl(Shell parent) {
 				int shellStyle= SWT.RESIZE;
@@ -49,4 +31,5 @@
 			}
 		};
 	}
+
 }

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/MultipleHyperlinkPresenterManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/MultipleHyperlinkPresenterManager.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/MultipleHyperlinkPresenterManager.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -16,7 +16,7 @@
 import org.eclipse.ui.IPartListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.cdi.text.ext.hyperlink.xpl.MultipleHyperlinkPresenter;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.MultipleHyperlinkPresenter;
 
 public class MultipleHyperlinkPresenterManager {
 	private static MultipleHyperlinkPresenter mhp = new MultipleHyperlinkPresenter(new RGB(0, 0, 255));

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodListHyperlink.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodListHyperlink.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodListHyperlink.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -48,7 +48,7 @@
 		if(hyperlinks.length == 1){
 			((ObserverMethodHyperlink)hyperlinks[0]).doHyperlink(region);
 		}else{
-			InformationControlManager.showHyperlinks(CDIExtensionsMessages.CDI_OBSERVER_METHODS_TITLE, viewer, hyperlinks);
+			InformationControlManager.instance.showHyperlinks(CDIExtensionsMessages.CDI_OBSERVER_METHODS_TITLE, viewer, hyperlinks);
 		}
 	}
 

Deleted: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/AbstractInformationControl.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/AbstractInformationControl.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/AbstractInformationControl.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -1,708 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 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
- *     Red Hat, Inc.
- *******************************************************************************/
-package org.jboss.tools.cdi.text.ext.hyperlink.xpl;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.util.StringMatcher;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.PopupDialog;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.IInformationControlExtension2;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-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.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ActionHandler;
-import org.eclipse.ui.commands.HandlerSubmission;
-import org.eclipse.ui.commands.ICommand;
-import org.eclipse.ui.commands.ICommandManager;
-import org.eclipse.ui.commands.IKeySequenceBinding;
-import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.keys.KeySequence;
-
-/**
- * Abstract class for Show hierarchy in light-weight controls.
- *
- * @since 2.1
- */
-public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
-
-	/** The control's text widget */
-	private Text fFilterText;
-	/** The control's table widget */
-	private TableViewer fTableViewer;
-	/** The current string matcher */
-	protected StringMatcher fStringMatcher;
-	private ICommand fInvokingCommand;
-	private KeySequence[] fInvokingCommandKeySequences;
-
-	/**
-	 * Fields that support the dialog menu
-	 * @since 3.0
-	 * @since 3.2 - now appended to framework menu
-	 */
-	private Composite fViewMenuButtonComposite;
-
-	private IAction fShowViewMenuAction;
-	private HandlerSubmission fShowViewMenuHandlerSubmission;
-
-	/**
-	 * Field for table style since it must be remembered by the instance.
-	 *
-	 * @since 3.2
-	 */
-	private int fTableStyle;
-
-	/**
-	 * The initially selected type.
-	 * @since 3.5
-	 */
-	protected IType fInitiallySelectedType;
-
-	/**
-	 * Creates a table information control with the given shell as parent. The given
-	 * styles are applied to the shell and the table widget.
-	 *
-	 * @param parent the parent shell
-	 * @param shellStyle the additional styles for the shell
-	 * @param tableStyle the additional styles for the table widget
-	 * @param invokingCommandId the id of the command that invoked this control or <code>null</code>
-	 * @param showStatusField <code>true</code> iff the control has a status field at the bottom
-	 */
-	public AbstractInformationControl(Shell parent, int shellStyle, int tableStyle, String invokingCommandId, boolean showStatusField) {
-		super(parent, shellStyle, true, true, false, true, true, null, null);
-		if (invokingCommandId != null) {
-			ICommandManager commandManager= PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
-			fInvokingCommand= commandManager.getCommand(invokingCommandId);
-			if (fInvokingCommand != null && !fInvokingCommand.isDefined())
-				fInvokingCommand= null;
-			else
-				// Pre-fetch key sequence - do not change because scope will change later.
-				getInvokingCommandKeySequences();
-		}
-		fTableStyle= tableStyle;
-		// Title and status text must be set to get the title label created, so force empty values here.
-		if (hasHeader())
-			setTitleText(""); //$NON-NLS-1$
-		setInfoText(""); //  //$NON-NLS-1$
-
-		// Create all controls early to preserve the life cycle of the original implementation.
-		create();
-
-		// Status field text can only be computed after widgets are created.
-		setInfoText(getStatusFieldText());
-	}
-
-	/**
-	 * Create the main content for this information control.
-	 *
-	 * @param parent The parent composite
-	 * @return The control representing the main content.
-	 * @since 3.2
-	 */
-	@Override
-	protected Control createDialogArea(Composite parent) {
-		fTableViewer= createTableViewer(parent, fTableStyle);
-
-		final Table table= fTableViewer.getTable();
-		table.addKeyListener(new KeyListener() {
-			public void keyPressed(KeyEvent e)  {
-				if (e.character == 0x1B) // ESC
-					dispose();
-			}
-			public void keyReleased(KeyEvent e) {
-				// do nothing
-			}
-		});
-
-		table.addSelectionListener(new SelectionListener() {
-			public void widgetSelected(SelectionEvent e) {
-				// do nothing
-			}
-			public void widgetDefaultSelected(SelectionEvent e) {
-				gotoSelectedElement();
-			}
-		});
-
-		table.addMouseMoveListener(new MouseMoveListener()	 {
-			TableItem fLastItem= null;
-			public void mouseMove(MouseEvent e) {
-				if (table.equals(e.getSource())) {
-					Object o= table.getItem(new Point(e.x, e.y));
-					if (fLastItem == null ^ o == null) {
-						table.setCursor(o == null ? null : table.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
-					}
-					if (o instanceof TableItem) {
-						Rectangle clientArea = table.getClientArea();
-						if (!o.equals(fLastItem)) {
-							fLastItem= (TableItem)o;
-							table.setSelection(new TableItem[] { fLastItem });
-						} else if (e.y - clientArea.y < table.getItemHeight() / 4) {
-							// Scroll up
-							Point p= table.toDisplay(e.x, e.y);
-							Item item= fTableViewer.scrollUp(p.x, p.y);
-							if (item instanceof TableItem) {
-								fLastItem= (TableItem)item;
-								table.setSelection(new TableItem[] { fLastItem });
-							}
-						} else if (clientArea.y + clientArea.height - e.y < table.getItemHeight() / 4) {
-							// Scroll down
-							Point p= table.toDisplay(e.x, e.y);
-							Item item= fTableViewer.scrollDown(p.x, p.y);
-							if (item instanceof TableItem) {
-								fLastItem= (TableItem)item;
-								table.setSelection(new TableItem[] { fLastItem });
-							}
-						}
-					} else if (o == null) {
-						fLastItem= null;
-					}
-				}
-			}
-		});
-
-		table.addMouseListener(new MouseAdapter() {
-			@Override
-			public void mouseUp(MouseEvent e) {
-
-				if (table.getSelectionCount() < 1)
-					return;
-
-				if (e.button != 1)
-					return;
-
-				if (table.equals(e.getSource())) {
-					Object o= table.getItem(new Point(e.x, e.y));
-					TableItem selection= table.getSelection()[0];
-					if (selection.equals(o))
-						gotoSelectedElement();
-				}
-			}
-		});
-
-		installFilter();
-
-		addDisposeListener(this);
-		return fTableViewer.getControl();
-	}
-
-	/**
-	 * Creates a table information control with the given shell as parent. The given
-	 * styles are applied to the shell and the table widget.
-	 *
-	 * @param parent the parent shell
-	 * @param shellStyle the additional styles for the shell
-	 * @param tableStyle the additional styles for the table widget
-	 */
-	public AbstractInformationControl(Shell parent, int shellStyle, int tableStyle) {
-		this(parent, shellStyle, tableStyle, null, false);
-	}
-
-	protected abstract TableViewer createTableViewer(Composite parent, int style);
-
-	/**
-	 * Returns the name of the dialog settings section.
-	 *
-	 * @return the name of the dialog settings section
-	 */
-	protected abstract String getId();
-
-	protected TableViewer getTableViewer() {
-		return fTableViewer;
-	}
-
-	/**
-	 * Returns <code>true</code> if the control has a header, <code>false</code> otherwise.
-	 * <p>
-	 * The default is to return <code>false</code>.
-	 * </p>
-	 *
-	 * @return <code>true</code> if the control has a header
-	 */
-	protected boolean hasHeader() {
-		// default is to have no header
-		return false;
-	}
-
-	protected Text getFilterText() {
-		return fFilterText;
-	}
-
-	protected Text createFilterText(Composite parent) {
-		fFilterText= new Text(parent, SWT.NONE);
-		Dialog.applyDialogFont(fFilterText);
-
-		GridData data= new GridData(GridData.FILL_HORIZONTAL);
-		data.horizontalAlignment= GridData.FILL;
-		data.verticalAlignment= GridData.CENTER;
-		fFilterText.setLayoutData(data);
-
-		fFilterText.addKeyListener(new KeyListener() {
-			public void keyPressed(KeyEvent e) {
-				if (e.keyCode == 0x0D) // return
-					gotoSelectedElement();
-				if (e.keyCode == SWT.ARROW_DOWN)
-					fTableViewer.getTable().setFocus();
-				if (e.keyCode == SWT.ARROW_UP)
-					fTableViewer.getTable().setFocus();
-				if (e.character == 0x1B) // ESC
-					dispose();
-			}
-			public void keyReleased(KeyEvent e) {
-				// do nothing
-			}
-		});
-
-		return fFilterText;
-	}
-
-	protected void createHorizontalSeparator(Composite parent) {
-		Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
-		separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-	}
-
-	protected void updateStatusFieldText() {
-		setInfoText(getStatusFieldText());
-	}
-
-	protected String getStatusFieldText() {
-		return ""; //$NON-NLS-1$
-	}
-
-	private void installFilter() {
-		fFilterText.setText(""); //$NON-NLS-1$
-
-		fFilterText.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				fTableViewer.refresh();
-			}
-		});
-	}
-
-
-	protected StringMatcher getMatcher() {
-		return fStringMatcher;
-	}
-
-	/**
-	 * Implementers can modify
-	 *
-	 * @return the selected element
-	 */
-	protected Object getSelectedElement() {
-		if (fTableViewer == null)
-			return null;
-
-		return ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement();
-	}
-
-	private void gotoSelectedElement() {
-		Object selectedElement= getSelectedElement();
-		if (selectedElement instanceof IHyperlink) {
-			((IHyperlink)selectedElement).open();
-		}
-	}
-
-	/**
-	 * Selects the first element in the table which
-	 * matches the current filter pattern.
-	 */
-	protected void selectFirstMatch() {
-		Object selectedElement= fTableViewer.testFindItem(fInitiallySelectedType);
-		TableItem element;
-		final Table table = fTableViewer.getTable();
-		if (selectedElement instanceof TableItem)
-			element= findElement(new TableItem[] { (TableItem)selectedElement });
-		else
-			element= findElement(table.getItems());
-
-		if (element != null) {
-			table.setSelection(element);
-			table.showItem(element);
-		} else
-			fTableViewer.setSelection(StructuredSelection.EMPTY);
-	}
-
-	private TableItem findElement(TableItem[] items) {
-		return findElement(items, null, true);
-	}
-
-	private TableItem findElement(TableItem[] items, TableItem[] toBeSkipped, boolean allowToGoUp) {
-		if (fStringMatcher == null)
-			return items.length > 0 ? items[0] : null;
-
-		ILabelProvider labelProvider= (ILabelProvider)fTableViewer.getLabelProvider();
-
-		// First search at same level
-		for (int i= 0; i < items.length; i++) {
-			final TableItem item= items[i];
-			IHyperlink element= (IHyperlink)item.getData();
-			if (element != null) {
-				String label= labelProvider.getText(element);
-				if (fStringMatcher.match(label))
-					return item;
-			}
-		}
-
-		return null;
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setInformation(String information) {
-		// this method is ignored, see IInformationControlExtension2
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public abstract void setInput(Object information);
-
-	/**
-	 * Fills the view menu.
-	 * Clients can extend or override.
-	 *
-	 * @param viewMenu the menu manager that manages the menu
-	 * @since 3.0
-	 */
-	protected void fillViewMenu(IMenuManager viewMenu) {
-		//fCustomFiltersActionGroup.fillViewMenu(viewMenu);
-	}
-
-	/*
-	 * Overridden to call the old framework method.
-	 *
-	 * @see org.eclipse.jface.dialogs.PopupDialog#fillDialogMenu(IMenuManager)
-	 * @since 3.2
-	 */
-	@Override
-	protected void fillDialogMenu(IMenuManager dialogMenu) {
-		super.fillDialogMenu(dialogMenu);
-		fillViewMenu(dialogMenu);
-	}
-
-	protected void inputChanged(Object newInput, Object newSelection) {
-		fFilterText.setText(""); //$NON-NLS-1$
-		fInitiallySelectedType= null;
-		fTableViewer.setInput(newInput);
-		if (newSelection != null)
-			fTableViewer.setSelection(new StructuredSelection(newSelection));
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setVisible(boolean visible) {
-		if (visible) {
-			open();
-		} else {
-			removeHandlerAndKeyBindingSupport();
-			saveDialogBounds(getShell());
-			getShell().setVisible(false);
-		}
-	}
-
-	/*
-	 * @see org.eclipse.jface.dialogs.PopupDialog#open()
-	 * @since 3.3
-	 */
-	@Override
-	public int open() {
-		addHandlerAndKeyBindingSupport();
-		return super.open();
-	}
-	
-	protected Control getFocusControl() {
-		return fFilterText;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public final void dispose() {
-		close();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * @param event can be null
-	 * <p>
-	 * Subclasses may extend.
-	 * </p>
-	 */
-	public void widgetDisposed(DisposeEvent event) {
-		removeHandlerAndKeyBindingSupport();
-		fTableViewer= null;
-		fFilterText= null;
-	}
-
-	/**
-	 * Adds handler and key binding support.
-	 *
-	 * @since 3.2
-	 */
-	protected void addHandlerAndKeyBindingSupport() {
-		// Register action with command support
-		if (fShowViewMenuHandlerSubmission == null) {
-			fShowViewMenuHandlerSubmission= new HandlerSubmission(null, getShell(), null, fShowViewMenuAction.getActionDefinitionId(), new ActionHandler(fShowViewMenuAction), Priority.MEDIUM);
-			PlatformUI.getWorkbench().getCommandSupport().addHandlerSubmission(fShowViewMenuHandlerSubmission);
-		}
-	}
-
-	/**
-	 * Removes handler and key binding support.
-	 *
-	 * @since 3.2
-	 */
-	protected void removeHandlerAndKeyBindingSupport() {
-		// Remove handler submission
-		if (fShowViewMenuHandlerSubmission != null)
-			PlatformUI.getWorkbench().getCommandSupport().removeHandlerSubmission(fShowViewMenuHandlerSubmission);
-
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public boolean hasContents() {
-		return fTableViewer != null && fTableViewer.getInput() != null;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setSizeConstraints(int maxWidth, int maxHeight) {
-		// ignore
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public Point computeSizeHint() {
-		// return the shell's size - note that it already has the persisted size if persisting
-		// is enabled.
-		return getShell().getSize();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setLocation(Point location) {
-		/*
-		 * If the location is persisted, it gets managed by PopupDialog - fine. Otherwise, the location is
-		 * computed in Window#getInitialLocation, which will center it in the parent shell / main
-		 * monitor, which is wrong for two reasons:
-		 * - we want to center over the editor / subject control, not the parent shell
-		 * - the center is computed via the initalSize, which may be also wrong since the size may
-		 *   have been updated since via min/max sizing of AbstractInformationControlManager.
-		 * In that case, override the location with the one computed by the manager. Note that
-		 * the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
-		 * entirely visible.
-		 */
-		if (!getPersistLocation() || getDialogSettings() == null)
-			getShell().setLocation(location);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setSize(int width, int height) {
-		getShell().setSize(width, height);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void addDisposeListener(DisposeListener listener) {
-		getShell().addDisposeListener(listener);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void removeDisposeListener(DisposeListener listener) {
-		getShell().removeDisposeListener(listener);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setForegroundColor(Color foreground) {
-		applyForegroundColor(foreground, getContents());
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setBackgroundColor(Color background) {
-		applyBackgroundColor(background, getContents());
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public boolean isFocusControl() {
-		return getShell().getDisplay().getActiveShell() == getShell();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void setFocus() {
-		getShell().forceFocus();
-		fFilterText.setFocus();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void addFocusListener(FocusListener listener) {
-		getShell().addFocusListener(listener);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void removeFocusListener(FocusListener listener) {
-		getShell().removeFocusListener(listener);
-	}
-
-	final protected ICommand getInvokingCommand() {
-		return fInvokingCommand;
-	}
-
-	final protected KeySequence[] getInvokingCommandKeySequences() {
-		if (fInvokingCommandKeySequences == null) {
-			if (getInvokingCommand() != null) {
-				List<IKeySequenceBinding> list= getInvokingCommand().getKeySequenceBindings();
-				if (!list.isEmpty()) {
-					fInvokingCommandKeySequences= new KeySequence[list.size()];
-					for (int i= 0; i < fInvokingCommandKeySequences.length; i++) {
-						fInvokingCommandKeySequences[i]= list.get(i).getKeySequence();
-					}
-					return fInvokingCommandKeySequences;
-				}
-			}
-		}
-		return fInvokingCommandKeySequences;
-	}
-
-	/*
-	 * @see org.eclipse.jface.dialogs.PopupDialog#getDialogSettings()
-	 */
-	@Override
-	protected IDialogSettings getDialogSettings() {
-		String sectionName= getId();
-
-		IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings().getSection(sectionName);
-		if (settings == null)
-			settings= JavaPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
-
-		return settings;
-	}
-
-	/*
-	 * Overridden to insert the filter text into the title and menu area.
-	 *
-	 * @since 3.2
-	 */
-	@Override
-	protected Control createTitleMenuArea(Composite parent) {
-		fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);
-
-		// If there is a header, then the filter text must be created
-		// underneath the title and menu area.
-
-		if (hasHeader()) {
-			fFilterText= createFilterText(parent);
-		}
-
-		// Create show view menu action
-		fShowViewMenuAction= new Action("showViewMenu") { //$NON-NLS-1$
-			/*
-			 * @see org.eclipse.jface.action.Action#run()
-			 */
-			@Override
-			public void run() {
-				showDialogMenu();
-			}
-		};
-		fShowViewMenuAction.setEnabled(true);
-		fShowViewMenuAction.setActionDefinitionId(IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU);
-
-		return fViewMenuButtonComposite;
-	}
-
-	/*
-	 * Overridden to insert the filter text into the title control
-	 * if there is no header specified.
-	 * @since 3.2
-	 */
-	@Override
-	protected Control createTitleControl(Composite parent) {
-		if (hasHeader()) {
-			return super.createTitleControl(parent);
-		}
-		fFilterText= createFilterText(parent);
-		return fFilterText;
-	}
-
-	/*
-	 * @see org.eclipse.jface.dialogs.PopupDialog#setTabOrder(org.eclipse.swt.widgets.Composite)
-	 */
-	@Override
-	protected void setTabOrder(Composite composite) {
-		if (hasHeader()) {
-			composite.setTabList(new Control[] { fFilterText, fTableViewer.getTable() });
-		} else {
-			fViewMenuButtonComposite.setTabList(new Control[] { fFilterText });
-			composite.setTabList(new Control[] { fViewMenuButtonComposite, fTableViewer.getTable() });
-		}
-	}
-}

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -11,26 +11,11 @@
  *******************************************************************************/
 package org.jboss.tools.cdi.text.ext.hyperlink.xpl;
 
-import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
-import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
 import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.StyledString.Styler;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.TextStyle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.dialogs.SearchPattern;
 import org.jboss.tools.cdi.core.CDIImages;
 import org.jboss.tools.cdi.core.ICDIElement;
@@ -42,149 +27,34 @@
  *
  * @since 3.0
  */
-public class HierarchyInformationControl extends AbstractInformationControl {
-	private IHyperlink[] hyperlinks;
-
-	private BeanTableLabelProvider fLabelProvider;
-
+public class HierarchyInformationControl extends org.jboss.tools.common.text.ext.hyperlink.xpl.HierarchyInformationControl {
 	public HierarchyInformationControl(Shell parent, String title, int shellStyle, int tableStyle, IHyperlink[] hyperlinks) {
-		super(parent, shellStyle, tableStyle, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, true);
-		this.hyperlinks = hyperlinks;
-		setTitleText(title);
+		super(parent, title, shellStyle, tableStyle, hyperlinks);
 	}
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	protected boolean hasHeader() {
-		return true;
+	protected BeanTableLabelProvider createTableLableProvider() {
+		return new BeanTableLabelProvider2();
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.jdt.internal.ui.text.JavaOutlineInformationControl#createTableViewer(org.eclipse.swt.widgets.Composite, int)
-	 */
 	@Override
-	protected TableViewer createTableViewer(Composite parent, int style) {
-		Table table = new Table(parent, SWT.SINGLE | (style & ~SWT.MULTI));
-		GridData gd= new GridData(GridData.FILL_BOTH);
-		gd.heightHint= table.getItemHeight() * 12;
-		table.setLayoutData(gd);
-
-		TableViewer tableViewer= new TableViewer(table);
-		
-		tableViewer.addFilter(new BeanFilter());
-
-		fLabelProvider= new BeanTableLabelProvider();
-
-		tableViewer.setLabelProvider(fLabelProvider);
-
-		return tableViewer;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void setInput(Object information) {
-		if(!(information instanceof IHyperlink[])){
-			inputChanged(null, null);
-			return;
-		}
-		
-		hyperlinks = (IHyperlink[])information;
-
-		BeanTableContentProvider contentProvider= new BeanTableContentProvider(hyperlinks);
-		getTableViewer().setContentProvider(contentProvider);
-
-
-		inputChanged(hyperlinks, hyperlinks[0]);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	protected Object getSelectedElement() {
-		Object selectedElement= super.getSelectedElement();
-		return selectedElement;
-	}
-
-	@Override
 	protected String getId() {
 		return "org.jboss.tools.cdi.text.ext.InformationControl";
 	}
 	
-	public static class BeanTableContentProvider implements IStructuredContentProvider{
-		private IHyperlink[] hyperlinks;
-		
-		public BeanTableContentProvider(IHyperlink[] beans){
-			this.hyperlinks = beans;
-		}
-
-		@Override
-		public void dispose() {
-		}
-
-		@Override
-		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-		}
-
-		@Override
-		public Object[] getElements(Object inputElement) {
-			return hyperlinks;
-		}
-
-	}
-	
-	public class BeanFilter extends ViewerFilter {
-		SearchPattern patternMatcher = new SearchPattern();
-		public boolean isConsistentItem(Object item) {
+	protected boolean select2(SearchPattern patternMatcher, Object element) {
+		if (element instanceof IInformationItem) {
+			String name = ((IInformationItem)element).getCDIElement().getElementName();
+			if(getFilterText().getText().isEmpty()){
+				patternMatcher.setPattern("*");
+			}else{
+				patternMatcher.setPattern(getFilterText().getText());
+			}
+			return patternMatcher.matches(name);
+		}else
 			return true;
-		}
-
-		public boolean select(Viewer viewer, Object parentElement,
-	            Object element) {
-			
-			if (element instanceof IInformationItem) {
-				String name = ((IInformationItem)element).getCDIElement().getElementName();
-				if(getFilterText().getText().isEmpty()){
-					patternMatcher.setPattern("*");
-				}else{
-					patternMatcher.setPattern(getFilterText().getText());
-				}
-				return patternMatcher.matches(name);
-			}else
-				return true;
-		}
 	}
-	
-	static Color gray = new Color(null, 128, 128, 128);
-	static Color black = new Color(null, 0, 0, 0);
 
-	static Styler NAME_STYLE = new DefaultStyler(black, false);
-	static Styler PACKAGE_STYLE = new DefaultStyler(gray, false);
-	
-	private static class DefaultStyler extends Styler {
-		private final Color foreground;
-		private final boolean italic;
-
-		public DefaultStyler(Color foreground, boolean italic) {
-			this.foreground = foreground;
-			this.italic = italic;
-		}
-
-		public void applyStyles(TextStyle textStyle) {
-			if (foreground != null) {
-				textStyle.foreground = foreground;
-			}
-			if(italic) {
-				textStyle.font = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
-			}
-		}
-	}
-	
-	class BeanTableLabelProvider extends StyledCellLabelProvider implements DelegatingStyledCellLabelProvider.IStyledLabelProvider {
+	class BeanTableLabelProvider2 extends BeanTableLabelProvider {
 		public void update(ViewerCell cell) {
 			Object element = cell.getElement();
 			StyledString styledString = getStyledText(element);

Deleted: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 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
- *     Red Hat, Inc.
- *******************************************************************************/
-package org.jboss.tools.cdi.text.ext.hyperlink.xpl;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-public class InformationPresenter extends AbstractInformationControlManager{
-	private ITextViewer viwer;
-
-	public InformationPresenter(ITextViewer viwer, IInformationControlCreator creator) {
-		super(creator);
-		this.viwer = viwer;
-		setCloser(new Closer());
-	}
-
-	@Override
-	public void showInformation() {
-		showInformation_internal(false);
-	}
-	
-	private IInformationControl showInformation_internal(boolean test){
-		IInformationControl iControl = getInformationControl();
-		Point sizeConstraints= computeSizeConstraints(viwer.getTextWidget(), null, iControl);
-		iControl.setSizeConstraints(sizeConstraints.x, sizeConstraints.y);
-		Point size= null;
-		Rectangle bounds= restoreInformationControlBounds();
-
-		if (bounds != null) {
-			if (bounds.width > -1 && bounds.height > -1)
-				size= Geometry.getSize(bounds);
-		}
-
-		if (size == null)
-			size= iControl.computeSizeHint();
-
-		size= Geometry.max(size, sizeConstraints);
-
-		iControl.setSize(size.x, size.y);
-		if(test){
-			((HierarchyInformationControl)iControl).setBlockOnOpen(false);
-		}
-		iControl.setVisible(true);
-		return iControl;
-	}
-	
-	public IInformationControl showInformationForTest(){
-		return showInformation_internal(true);
-	}
-
-	@Override
-	protected void computeInformation() {
-		setInformation("Information", new Rectangle(1,1,100,100));
-	}
-	
-	class Closer implements IInformationControlCloser, ControlListener, MouseListener, FocusListener, IViewportListener, KeyListener {
-
-		/** The subject control. */
-		private Control fSubjectControl;
-		/** The information control. */
-		private IInformationControl fInformationControlToClose;
-		/** Indicates whether this closer is active. */
-		private boolean fIsActive= false;
-
-		/*
-		 * @see IInformationControlCloser#setSubjectControl(Control)
-		 */
-		public void setSubjectControl(Control control) {
-			fSubjectControl= control;
-		}
-
-		/*
-		 * @see IInformationControlCloser#setInformationControl(IInformationControl)
-		 */
-		public void setInformationControl(IInformationControl control) {
-			fInformationControlToClose= control;
-		}
-
-		/*
-		 * @see IInformationControlCloser#start(Rectangle)
-		 */
-		public void start(Rectangle informationArea) {
-
-			if (fIsActive)
-				return;
-			fIsActive= true;
-
-			if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
-				fSubjectControl.addControlListener(this);
-				fSubjectControl.addMouseListener(this);
-				fSubjectControl.addFocusListener(this);
-				fSubjectControl.addKeyListener(this);
-			}
-
-			if (fInformationControlToClose != null)
-				fInformationControlToClose.addFocusListener(this);
-
-			viwer.addViewportListener(this);
-		}
-
-		/*
-		 * @see IInformationControlCloser#stop()
-		 */
-		public void stop() {
-
-			if (!fIsActive)
-				return;
-			fIsActive= false;
-
-			viwer.removeViewportListener(this);
-
-			if (fInformationControlToClose != null)
-				fInformationControlToClose.removeFocusListener(this);
-
-			if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
-				fSubjectControl.removeControlListener(this);
-				fSubjectControl.removeMouseListener(this);
-				fSubjectControl.removeFocusListener(this);
-				fSubjectControl.removeKeyListener(this);
-			}
-		}
-
-		/*
-		 * @see ControlListener#controlResized(ControlEvent)
-		 */
-		 public void controlResized(ControlEvent e) {
-			 hideInformationControl();
-		}
-
-		/*
-		 * @see ControlListener#controlMoved(ControlEvent)
-		 */
-		 public void controlMoved(ControlEvent e) {
-			 hideInformationControl();
-		}
-
-		/*
-		 * @see MouseListener#mouseDown(MouseEvent)
-		 */
-		 public void mouseDown(MouseEvent e) {
-			 hideInformationControl();
-		}
-
-		/*
-		 * @see MouseListener#mouseUp(MouseEvent)
-		 */
-		public void mouseUp(MouseEvent e) {
-		}
-
-		/*
-		 * @see MouseListener#mouseDoubleClick(MouseEvent)
-		 */
-		public void mouseDoubleClick(MouseEvent e) {
-			hideInformationControl();
-		}
-
-		/*
-		 * @see FocusListener#focusGained(FocusEvent)
-		 */
-		public void focusGained(FocusEvent e) {
-		}
-
-		/*
-		 * @see FocusListener#focusLost(FocusEvent)
-		 */
-		 public void focusLost(FocusEvent e) {
-			Display d= fSubjectControl.getDisplay();
-			d.asyncExec(new Runnable() {
-				// Without the asyncExec, mouse clicks to the workbench window are swallowed.
-				public void run() {
-					if (fInformationControlToClose == null || !fInformationControlToClose.isFocusControl())
-						hideInformationControl();
-				}
-			});
-		}
-
-		/*
-		 * @see IViewportListenerListener#viewportChanged(int)
-		 */
-		public void viewportChanged(int topIndex) {
-			hideInformationControl();
-		}
-
-		/*
-		 * @see KeyListener#keyPressed(KeyEvent)
-		 */
-		public void keyPressed(KeyEvent e) {
-			hideInformationControl();
-		}
-
-		/*
-		 * @see KeyListener#keyReleased(KeyEvent)
-		 */
-		public void keyReleased(KeyEvent e) {
-		}
-	}
-
-
-}

Deleted: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java	2012-07-18 23:28:14 UTC (rev 42637)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java	2012-07-18 23:29:08 UTC (rev 42638)
@@ -1,812 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 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
- *     Exadel, Inc.
- *     Red Hat, Inc.
- *******************************************************************************/
-package org.jboss.tools.cdi.text.ext.hyperlink.xpl;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.AbstractInformationControl;
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IInformationControlExtension2;
-import org.eclipse.jface.text.IInformationControlExtension3;
-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.IWidgetTokenKeeper;
-import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
-import org.eclipse.jface.text.IWidgetTokenOwner;
-import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
-import org.eclipse.jface.text.JFaceTextUtil;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Color;
-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.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-public class MultipleHyperlinkPresenter  extends DefaultHyperlinkPresenter {
-
-	private static final boolean IS_WIN32= "win32".equals(SWT.getPlatform()); //$NON-NLS-1$
-
-	/**
-	 * An information control capable of showing a list of hyperlinks. The hyperlinks can be opened.
-	 */
-	private static class LinkListInformationControl extends AbstractInformationControl implements IInformationControlExtension2 {
-
-		private static final class LinkContentProvider implements IStructuredContentProvider {
-
-			/*
-			 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
-			 */
-			public Object[] getElements(Object inputElement) {
-				return (Object[]) inputElement;
-			}
-
-			/*
-			 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
-			 */
-			public void dispose() {
-			}
-
-			/*
-			 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
-			 */
-			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-			}
-		}
-
-		private static final class LinkLabelProvider extends ColumnLabelProvider {
-			/*
-			 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
-			 */
-			public String getText(Object element) {
-				IHyperlink link= (IHyperlink)element;
-				String text= link.getHyperlinkText();
-				if (text != null)
-					return text;
-				return "Unknown Link";
-			}
-		}
-
-		private final MultipleHyperlinkHoverManager fManager;
-
-		private IHyperlink[] fInput;
-		private Composite fParent;
-		private Table fTable;
-
-		private Color fForegroundColor;
-		private Color fBackgroundColor;
-
-
-		/**
-		 * Creates a link list information control with the given shell as parent.
-		 *
-		 * @param parentShell the parent shell
-		 * @param manager the hover manager
-		 * @param foregroundColor the foreground color, must not be disposed
-		 * @param backgroundColor the background color, must not be disposed
-		 */
-		public LinkListInformationControl(Shell parentShell, MultipleHyperlinkHoverManager manager, Color foregroundColor, Color backgroundColor) {
-			super(parentShell, false);
-			fManager= manager;
-			fForegroundColor= foregroundColor;
-			fBackgroundColor= backgroundColor;
-			create();
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
-		 */
-		public void setInformation(String information) {
-			//replaced by IInformationControlExtension2#setInput(java.lang.Object)
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
-		 */
-		public void setInput(Object input) {
-			fInput= (IHyperlink[]) input;
-			deferredCreateContent(fParent);
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite)
-		 */
-		protected void createContent(Composite parent) {
-			fParent= parent;
-			if (IS_WIN32) {
-				GridLayout layout= new GridLayout();
-				layout.marginWidth= 0;
-				layout.marginRight= 4;
-				fParent.setLayout(layout);
-			}
-			fParent.setForeground(fForegroundColor);
-			fParent.setBackground(fBackgroundColor);
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint()
-		 */
-		public Point computeSizeHint() {
-			Point preferedSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
-
-			Point constraints= getSizeConstraints();
-			if (constraints == null)
-				return preferedSize;
-
-			if (fTable.getVerticalBar() == null || fTable.getHorizontalBar() == null)
-				return Geometry.min(constraints, preferedSize);
-
-			int scrollBarWidth= fTable.getVerticalBar().getSize().x;
-			int scrollBarHeight= fTable.getHorizontalBar().getSize().y;
-
-			int width;
-			if (preferedSize.y - scrollBarHeight <= constraints.y) {
-				width= preferedSize.x - scrollBarWidth;
-				fTable.getVerticalBar().setVisible(false);
-			} else {
-				width= Math.min(preferedSize.x, constraints.x);
-			}
-
-			int height;
-			if (preferedSize.x - scrollBarWidth <= constraints.x) {
-				height= preferedSize.y - scrollBarHeight;
-				fTable.getHorizontalBar().setVisible(false);
-			} else {
-				height= Math.min(preferedSize.y, constraints.y);
-			}
-
-			return new Point(width, height);
-		}
-
-		private void deferredCreateContent(Composite parent) {
-			fTable= new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION);
-			fTable.setLinesVisible(false);
-			fTable.setHeaderVisible(false);
-			fTable.setForeground(fForegroundColor);
-			fTable.setBackground(fBackgroundColor);
-			fTable.setFont(JFaceResources.getDialogFont());
-
-			if (IS_WIN32) {
-				GridData data= new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
-				fTable.setLayoutData(data);
-			}
-
-			final TableViewer viewer= new TableViewer(fTable);
-			viewer.setContentProvider(new LinkContentProvider());
-			viewer.setLabelProvider(new LinkLabelProvider());
-			viewer.setInput(fInput);
-			fTable.setSelection(0);
-
-			registerTableListeners();
-
-			getShell().addShellListener(new ShellAdapter() {
-
-				/*
-				 * @see org.eclipse.swt.events.ShellAdapter#shellActivated(org.eclipse.swt.events.ShellEvent)
-				 */
-				public void shellActivated(ShellEvent e) {
-					if (viewer.getTable().getSelectionCount() == 0) {
-						viewer.getTable().setSelection(0);
-					}
-
-					viewer.getTable().setFocus();
-				}
-			});
-		}
-
-		private void registerTableListeners() {
-
-			fTable.addMouseMoveListener(new MouseMoveListener() {
-				TableItem fLastItem= null;
-
-				public void mouseMove(MouseEvent e) {
-					if (fTable.equals(e.getSource())) {
-						Object o= fTable.getItem(new Point(e.x, e.y));
-						if (o instanceof TableItem) {
-							TableItem item= (TableItem) o;
-							if (!o.equals(fLastItem)) {
-								fLastItem= (TableItem) o;
-								fTable.setSelection(new TableItem[] { fLastItem });
-							} else if (e.y < fTable.getItemHeight() / 4) {
-								// Scroll up
-								int index= fTable.indexOf(item);
-								if (index > 0) {
-									fLastItem= fTable.getItem(index - 1);
-									fTable.setSelection(new TableItem[] { fLastItem });
-								}
-							} else if (e.y > fTable.getBounds().height - fTable.getItemHeight() / 4) {
-								// Scroll down
-								int index= fTable.indexOf(item);
-								if (index < fTable.getItemCount() - 1) {
-									fLastItem= fTable.getItem(index + 1);
-									fTable.setSelection(new TableItem[] { fLastItem });
-								}
-							}
-						}
-					}
-				}
-			});
-
-			fTable.addSelectionListener(new SelectionAdapter() {
-				public void widgetSelected(SelectionEvent e) {
-					openSelectedLink();
-				}
-			});
-
-			fTable.addMouseListener(new MouseAdapter() {
-				public void mouseUp(MouseEvent e) {
-					if (fTable.getSelectionCount() < 1)
-						return;
-
-					if (e.button != 1)
-						return;
-
-					if (fTable.equals(e.getSource())) {
-						Object o= fTable.getItem(new Point(e.x, e.y));
-						TableItem selection= fTable.getSelection()[0];
-						if (selection.equals(o))
-							openSelectedLink();
-					}
-				}
-			});
-
-			fTable.addKeyListener(new KeyAdapter() {
-				public void keyPressed(KeyEvent e) {
-					if (e.keyCode == 0x0D) // return
-						openSelectedLink();
-				}
-			});
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
-		 */
-		public boolean hasContents() {
-			return true;
-		}
-
-		/**
-		 * Opens the currently selected link.
-		 */
-		private void openSelectedLink() {
-			if (fTable.getSelectionCount() < 1)
-				return;
-			
-			TableItem selection= fTable.getSelection()[0];
-			IHyperlink link= (IHyperlink)selection.getData();
-			fManager.hideInformationControl();
-			fManager.setCaret();
-			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 As of 3.4, replaced by
-		 *             {@link ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)}
-		 */
-		public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
-			return null;
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
-		 */
-		public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
-			return fSubjectRegion;
-		}
-
-		/*
-		 * @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;
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
-		 */
-		public IInformationControlCreator getHoverControlCreator() {
-			return new IInformationControlCreator() {
-				public IInformationControl createInformationControl(Shell parent) {
-					Color foregroundColor= fTextViewer.getTextWidget().getForeground();
-					Color backgroundColor= fTextViewer.getTextWidget().getBackground();
-					return new LinkListInformationControl(parent, fManager, foregroundColor, backgroundColor);
-				}
-			};
-		}
-	}
-
-	private static class MultipleHyperlinkHoverManager extends AbstractInformationControlManager implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-
-		private class Closer implements IInformationControlCloser, Listener, KeyListener, MouseListener {
-
-			private Control fSubjectControl;
-			private Display fDisplay;
-			private IInformationControl fControl;
-			private Rectangle fSubjectArea;
-			private long startTime;
-			
-			public Closer(){
-				startTime = System.currentTimeMillis();
-			}
-			
-			/**
-			 * Attempt to avoid losing focus just after opening. See JBIDE-9390
-			 * @return
-			 */
-			private boolean isItTime(){
-				return System.currentTimeMillis() - startTime > 500;
-			}
-
-			/*
-			 * @see org.eclipse.jface.text.AbstractInformationControlManager.IInformationControlCloser#setInformationControl(org.eclipse.jface.text.IInformationControl)
-			 */
-			public void setInformationControl(IInformationControl control) {
-				fControl= control;
-			}
-
-			/*
-			 * @see org.eclipse.jface.text.AbstractInformationControlManager.IInformationControlCloser#setSubjectControl(org.eclipse.swt.widgets.Control)
-			 */
-			public void setSubjectControl(Control subject) {
-				fSubjectControl= subject;
-			}
-
-			/*
-			 * @see org.eclipse.jface.text.AbstractInformationControlManager.IInformationControlCloser#start(org.eclipse.swt.graphics.Rectangle)
-			 */
-			public void start(Rectangle subjectArea) {
-				fSubjectArea= subjectArea;
-
-				fDisplay= fSubjectControl.getDisplay();
-				if (!fDisplay.isDisposed()) {
-					fDisplay.addFilter(SWT.FocusOut, this);
-					fDisplay.addFilter(SWT.MouseMove, this);
-					fTextViewer.getTextWidget().addKeyListener(this);
-					fTextViewer.getTextWidget().addMouseListener(this);
-				}
-			}
-
-			/*
-			 * @see org.eclipse.jface.text.AbstractInformationControlManager.IInformationControlCloser#stop()
-			 */
-			public void stop() {
-				if (fDisplay != null && !fDisplay.isDisposed()) {
-					fDisplay.removeFilter(SWT.FocusOut, this);
-					fDisplay.removeFilter(SWT.MouseMove, this);
-					fTextViewer.getTextWidget().removeKeyListener(this);
-					fTextViewer.getTextWidget().removeMouseListener(this);
-				}
-
-				fSubjectArea= null;
-			}
-
-			/*
-			 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
-			 */
-			public void handleEvent(Event event) {
-				switch (event.type) {
-					case SWT.FocusOut:
-						if (isItTime() && !fControl.isFocusControl())
-							disposeInformationControl();
-						break;
-					case SWT.MouseMove:
-						handleMouseMove(event);
-						break;
-				}
-			}
-
-			/**
-			 * Handle mouse movement events.
-			 *
-			 * @param event the event
-			 */
-			private void handleMouseMove(Event event) {
-				if (!(event.widget instanceof Control))
-					return;
-
-				if (fControl.isFocusControl())
-					return;
-
-				Control eventControl= (Control) event.widget;
-
-				//transform coordinates to subject control:
-				Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y);
-
-				if (fSubjectArea.contains(mouseLoc))
-					return;
-
-				if (inKeepUpZone(mouseLoc.x, mouseLoc.y, ((IInformationControlExtension3) fControl).getBounds()))
-					return;
-
-				hideInformationControl();
-			}
-
-			/**
-			 * Tests whether a given mouse location is within the keep-up zone.
-			 * The hover should not be hidden as long as the mouse stays inside this zone.
-			 *
-			 * @param x the x coordinate, relative to the <em>subject control</em>
-			 * @param y the y coordinate, relative to the <em>subject control</em>
-			 * @param controlBounds the bounds of the current control
-			 *
-			 * @return <code>true</code> iff the mouse event occurred in the keep-up zone
-			 */
-			private boolean inKeepUpZone(int x, int y, Rectangle controlBounds) {
-				//  +-----------+
-				//  |subjectArea|
-				//  +-----------+
-				//  |also keepUp|
-				// ++-----------+-------+
-				// | totalBounds        |
-				// +--------------------+
-				if (fSubjectArea.contains(x, y))
-					return true;
-
-				Rectangle iControlBounds= fSubjectControl.getDisplay().map(null, fSubjectControl, controlBounds);
-				Rectangle totalBounds= Geometry.copy(iControlBounds);
-				if (totalBounds.contains(x, y))
-					return true;
-
-				int keepUpY= fSubjectArea.y + fSubjectArea.height;
-				Rectangle alsoKeepUp= new Rectangle(fSubjectArea.x, keepUpY, fSubjectArea.width, totalBounds.y - keepUpY);
-				return alsoKeepUp.contains(x, y);
-			}
-
-			/*
-			 * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
-			 */
-			public void keyPressed(KeyEvent e) {
-			}
-
-			/*
-			 * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
-			 */
-			public void keyReleased(KeyEvent e) {
-				hideInformationControl();
-			}
-
-			/*
-			 * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
-			 * @since 3.5
-			 */
-			public void mouseDoubleClick(MouseEvent e) {
-			}
-
-			/*
-			 * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
-			 * @since 3.5
-			 */
-			public void mouseDown(MouseEvent e) {
-			}
-
-			/*
-			 * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
-			 * @since 3.5
-			 */
-			public void mouseUp(MouseEvent e) {
-				hideInformationControl();
-			}
-
-		}
-
-		/**
-		 * Priority of the hover managed by this manager.
-		 * Default value: One higher then for the hovers
-		 * managed by TextViewerHoverManager.
-		 */
-		private static final int WIDGET_TOKEN_PRIORITY= 1;
-
-		private final MultipleHyperlinkHover fHover;
-		private final ITextViewer fTextViewer;
-		private final MultipleHyperlinkPresenter fHyperlinkPresenter;
-		private Closer fCloser;
-		private boolean fIsControlVisible;
-
-
-		/**
-		 * Create a new MultipleHyperlinkHoverManager. The MHHM can show and hide
-		 * the given MultipleHyperlinkHover inside the given ITextViewer.
-		 *
-		 * @param hover the hover to manage
-		 * @param viewer the viewer to show the hover in
-		 * @param hyperlinkPresenter the hyperlink presenter using this manager to present hyperlinks
-		 */
-		public MultipleHyperlinkHoverManager(MultipleHyperlinkHover hover, ITextViewer viewer, MultipleHyperlinkPresenter hyperlinkPresenter) {
-			super(hover.getHoverControlCreator());
-
-			fHover= hover;
-			fTextViewer= viewer;
-			fHyperlinkPresenter= hyperlinkPresenter;
-
-			fCloser= new Closer();
-			setCloser(fCloser);
-			fIsControlVisible= false;
-		}
-
-		/*
-		 * @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= JFaceTextUtil.computeArea(region, fTextViewer);
-			if (area == null || area.isEmpty()) {
-				setInformation(null, null);
-				return;
-			}
-
-			Object information= fHover.getHoverInfo2(fTextViewer, region);
-			setCustomInformationControlCreator(fHover.getHoverControlCreator());
-			setInformation(information, area);
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformationControlLocation(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.Point)
-		 */
-		protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
-			Point point = Display.getCurrent().getCursorLocation();
-			Point location = new Point(point.x-20, point.y-20);
-			return location;
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControlManager#showInformationControl(org.eclipse.swt.graphics.Rectangle)
-		 */
-		protected void showInformationControl(Rectangle subjectArea) {
-			if (fTextViewer instanceof IWidgetTokenOwnerExtension) {
-				if (((IWidgetTokenOwnerExtension) fTextViewer).requestWidgetToken(this, WIDGET_TOKEN_PRIORITY))
-					super.showInformationControl(subjectArea);
-			} else if (fTextViewer instanceof IWidgetTokenOwner) {
-				if (((IWidgetTokenOwner) fTextViewer).requestWidgetToken(this))
-					super.showInformationControl(subjectArea);
-			} else {
-				super.showInformationControl(subjectArea);
-			}
-
-			fIsControlVisible= true;
-		}
-
-		/**
-		 * Sets the caret where hyperlinking got initiated.
-		 * 
-		 * @since 3.5
-		 */
-		private void setCaret() {
-			fHyperlinkPresenter.setCaret();
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControlManager#hideInformationControl()
-		 */
-		protected void hideInformationControl() {
-			super.hideInformationControl();
-
-			if (fTextViewer instanceof IWidgetTokenOwner) {
-				((IWidgetTokenOwner) fTextViewer).releaseWidgetToken(this);
-			}
-
-			fIsControlVisible= false;
-			fHyperlinkPresenter.hideHyperlinks();
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.AbstractInformationControlManager#disposeInformationControl()
-		 */
-		public void disposeInformationControl() {
-			super.disposeInformationControl();
-
-			if (fTextViewer instanceof IWidgetTokenOwner) {
-				((IWidgetTokenOwner) fTextViewer).releaseWidgetToken(this);
-			}
-
-			fIsControlVisible= false;
-			fHyperlinkPresenter.hideHyperlinks();
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner)
-		 */
-		public boolean requestWidgetToken(IWidgetTokenOwner owner) {
-			hideInformationControl();
-			return true;
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner, int)
-		 */
-		public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
-			if (priority < WIDGET_TOKEN_PRIORITY)
-				return false;
-
-			hideInformationControl();
-			return true;
-		}
-
-		/*
-		 * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner)
-		 */
-		public boolean setFocus(IWidgetTokenOwner owner) {
-			return false;
-		}
-
-		/**
-		 * Returns <code>true</code> if the information control managed by
-		 * this manager is visible, <code>false</code> otherwise.
-		 *
-		 * @return <code>true</code> if information control is visible
-		 */
-		public boolean isInformationControlVisible() {
-			return fIsControlVisible;
-		}
-	}
-
-	private ITextViewer fTextViewer;
-
-	private IHyperlink[] fHyperlinks;
-	private Region fSubjectRegion;
-	private MultipleHyperlinkHoverManager fManager;
-
-	/**
-	 * The offset in the text viewer where hyperlinking got initiated.
-	 * @since 3.5
-	 */
-	private int fCursorOffset;
-
-	/**
-	 * 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);
-	}
-
-	/*
-	 * @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, this);
-		fManager.install(viewer.getTextWidget());
-		fManager.setSizeConstraints(100, 12, false, true);
-	}
-
-	/*
-	 * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#uninstall()
-	 */
-	public void uninstall() {
-		super.uninstall();
-
-		if (fTextViewer != null) {
-			fManager.dispose();
-
-			fTextViewer= null;
-		}
-	}
-
-	/*
-	 * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#canShowMultipleHyperlinks()
-	 */
-	public boolean canShowMultipleHyperlinks() {
-		return true;
-	}
-
-	/*
-	 * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#canHideHyperlinks()
-	 */
-	public boolean canHideHyperlinks() {
-		return !fManager.isInformationControlVisible();
-	}
-
-	/*
-	 * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#hideHyperlinks()
-	 */
-	public void hideHyperlinks() {
-		super.hideHyperlinks();
-		fHyperlinks= null;
-	}
-	
-	/*
-	 * @see org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter#showHyperlinks(org.eclipse.jface.text.hyperlink.IHyperlink[])
-	 */
-	public void showHyperlinks(IHyperlink[] hyperlinks) {
-		super.showHyperlinks(new IHyperlink[] { hyperlinks[0] });
-		
-		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);
-		fCursorOffset= JFaceTextUtil.getOffsetForCursorLocation(fTextViewer);
-
-		fManager.showInformation();
-	}
-
-	/**
-	 * Sets the caret where hyperlinking got initiated.
-	 * 
-	 * @since 3.5
-	 */
-	private void setCaret() {
-		Point selectedRange= fTextViewer.getSelectedRange();
-		if (fCursorOffset != -1 && !(fSubjectRegion.getOffset() <= selectedRange.x && selectedRange.x + selectedRange.y <= fSubjectRegion.getOffset() + fSubjectRegion.getLength()))
-			fTextViewer.setSelectedRange(fCursorOffset, 0);
-	}
-
-
-}



More information about the jbosstools-commits mailing list