JBoss Tools SVN: r42641 - trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-07-18 19:32:13 -0400 (Wed, 18 Jul 2012)
New Revision: 42641
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELVarListHyperlink.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlinkDetector.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/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlinkDetector.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlinkDetector.java 2012-07-18 23:30:55 UTC (rev 42640)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlinkDetector.java 2012-07-18 23:32:13 UTC (rev 42641)
@@ -33,6 +33,7 @@
import org.jboss.tools.common.el.core.resolver.ELSegment;
import org.jboss.tools.common.el.core.resolver.ELSegmentImpl;
import org.jboss.tools.common.el.core.resolver.IOpenableReference;
+import org.jboss.tools.common.el.core.resolver.ELSegmentImpl.VarOpenable;
import org.jboss.tools.jst.web.kb.PageContextFactory;
public class ELHyperlinkDetector extends AbstractHyperlinkDetector{
@@ -65,9 +66,22 @@
if(openables.length == 0) {
links.add(new ELHyperlink(textViewer.getDocument(), reference, segment, null));
} else {
+ List<ELHyperlink> vars = new ArrayList<ELHyperlink>();
for (IOpenableReference openable: openables) {
- links.add(new ELHyperlink(textViewer.getDocument(), reference, segment, openable));
+ ELHyperlink link = new ELHyperlink(textViewer.getDocument(), reference, segment, openable);
+ if(openable instanceof VarOpenable) {
+ vars.add(link);
+ } else {
+ links.add(link);
+ }
}
+ if(vars.isEmpty()) {
+ // do nothing
+ } else if(vars.size() == 1) {
+ links.add(0, vars.get(0));
+ } else {
+ links.add(0, new ELVarListHyperlink(textViewer, reference, segment, vars.toArray(new ELHyperlink[0])));
+ }
}
} else if(segment != null && ((ELSegmentImpl)segment).getVar() != null && unresolved == null && segment.getOpenable().length > 0) {
unresolved = segment;
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELVarListHyperlink.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELVarListHyperlink.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELVarListHyperlink.java 2012-07-18 23:32:13 UTC (rev 42641)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+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.hyperlink.IHyperlink;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.common.el.core.ELReference;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.ELSegmentImpl.VarOpenable;
+import org.jboss.tools.common.el.core.resolver.Var;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.InformationControlManager;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.HierarchyInformationControl;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.text.ext.JSTExtensionsPlugin;
+
+public class ELVarListHyperlink extends AbstractHyperlink {
+ ITextViewer viewer;
+ ELHyperlink[] hyperlinks;
+ private ELReference reference;
+ private ELSegment segment;
+
+ public ELVarListHyperlink(ITextViewer viewer, ELReference reference, ELSegment segment, ELHyperlink[] hyperlinks) {
+ this.viewer = viewer;
+ this.hyperlinks = hyperlinks;
+ this.reference = reference;
+ this.segment = segment;
+ setDocument(viewer.getDocument());
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ @Override
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ IRegion region = super.doGetHyperlinkRegion(offset);
+ return (region != null ? region : new HyperlinkRegion(
+ reference.getStartPosition()+segment.getSourceReference().getStartPosition(),
+ segment.getSourceReference().getLength()));
+ }
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ VarInformationControlManager.instance.showHyperlinks("Open Var Declaration", viewer, hyperlinks); //$NON-NLS-1$
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ return "Open Var Declaration"; //$NON-NLS-1$
+ }
+
+}
+
+class VarInformationControlManager extends InformationControlManager {
+ static VarInformationControlManager instance = new VarInformationControlManager();
+
+ protected IInformationControlCreator getHierarchyPresenterControlCreator(final String title, final IHyperlink[] hyperlinks) {
+ return new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ int shellStyle= SWT.RESIZE;
+ int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
+ HierarchyInformationControl iControl = new VarHierarchyInformationControl(parent, title, shellStyle, treeStyle, hyperlinks);
+ iControl.setInput(hyperlinks);
+ return iControl;
+ }
+ };
+ }
+}
+
+class VarHierarchyInformationControl extends HierarchyInformationControl {
+ public VarHierarchyInformationControl(Shell parent, String title, int shellStyle, int tableStyle, IHyperlink[] hyperlinks) {
+ super(parent, title, shellStyle, tableStyle, hyperlinks);
+ }
+
+ protected BeanTableLabelProvider createTableLableProvider() {
+ return new VarTableLabelProvider();
+ }
+
+
+ class VarTableLabelProvider extends BeanTableLabelProvider {
+
+ public StyledString getStyledText(Object element) {
+ StyledString sb = new StyledString();
+ if(element instanceof ELHyperlink) {
+ ELHyperlink el = (ELHyperlink)element;
+ VarOpenable v = (VarOpenable)el.openable;
+ Var var = v.getVar();
+ IDocument doc = new Document(FileUtil.getContentFromEditorOrFile(var.getFile()));
+ int line = -1;
+ try {
+ if(var.getDeclarationOffset() < doc.getLength()) {
+ line = doc.getLineOfOffset(var.getDeclarationOffset()) + 1;
+ }
+ } catch (BadLocationException e) {
+ JSTExtensionsPlugin.getDefault().logError(e);
+ }
+ sb.append(var.getFile().getName(), NAME_STYLE);
+ if(line > 0) {
+ sb.append(", line " + line, NAME_STYLE);
+ }
+ sb.append(" - " + var.getFile().getParent().getFullPath().toString(), PACKAGE_STYLE);
+ } else if(element instanceof IHyperlink){
+ sb.append(((IHyperlink)element).getHyperlinkText(), NAME_STYLE);
+ }
+ return sb;
+ }
+
+ }
+
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELVarListHyperlink.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 8 months
JBoss Tools SVN: r42640 - trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-07-18 19:30:55 -0400 (Wed, 18 Jul 2012)
New Revision: 42640
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointListHyperlink.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.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointListHyperlink.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointListHyperlink.java 2012-07-18 23:29:55 UTC (rev 42639)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointListHyperlink.java 2012-07-18 23:30:55 UTC (rev 42640)
@@ -60,7 +60,7 @@
}
private void showHyperlinks(IHyperlink[] hyperlinks){
- InformationControlManager.showHyperlinks(CDISeamExtMessages.CDI_SHOW_GENERIC_CONFIGURATION_POINTS_TITLE, viewer, hyperlinks);
+ InformationControlManager.instance.showHyperlinks(CDISeamExtMessages.CDI_SHOW_GENERIC_CONFIGURATION_POINTS_TITLE, viewer, hyperlinks);
}
}
13 years, 8 months
JBoss Tools SVN: r42639 - trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-07-18 19:29:55 -0400 (Wed, 18 Jul 2012)
New Revision: 42639
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.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/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java 2012-07-18 23:29:08 UTC (rev 42638)
+++ trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java 2012-07-18 23:29:55 UTC (rev 42639)
@@ -51,7 +51,7 @@
hyperlinks[index++] = new InjectedPointHyperlink(new Region(1,1), b, document);
}
- IInformationControl informationControl = InformationControlManager.showHyperlinks("Title", ((JavaEditor)part).getViewer(), hyperlinks, true);
+ IInformationControl informationControl = InformationControlManager.instance.showHyperlinks("Title", ((JavaEditor)part).getViewer(), hyperlinks, true);
assertNotNull("InformationControl not found", informationControl);
informationControl.setVisible(false);
13 years, 8 months
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.
by jbosstools-commits@lists.jboss.org
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);
- }
-
-
-}
13 years, 8 months
JBoss Tools SVN: r42637 - in trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core: ca and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-07-18 19:28:14 -0400 (Wed, 18 Jul 2012)
New Revision: 42637
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELSegmentImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.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/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2012-07-18 23:27:09 UTC (rev 42636)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2012-07-18 23:28:14 UTC (rev 42637)
@@ -318,7 +318,7 @@
sufixIsNotResolved = !segment.isResolved();
}
firstSegment = segment;
- ((ELSegmentImpl)firstSegment).setVar(var);
+ ((ELSegmentImpl)firstSegment).setVars(varSearcher.findVarsForEl(oldEl, context, vars, true));
((ELSegmentImpl)firstSegment).setToken(firstOriginalToken);
((ELSegmentImpl)firstSegment).setResolved(!sufixIsNotResolved);
// if(firstSegment instanceof JavaMemberELSegmentImpl) {
@@ -355,7 +355,7 @@
} else {
resolution = resolveELOperand(file, context, operand, returnEqualedVariablesOnly, false, offset);
if(var != null && !resolution.getSegments().isEmpty()) {
- ((ELSegmentImpl)resolution.getSegments().get(0)).setVar(var);
+ ((ELSegmentImpl)resolution.getSegments().get(0)).setVars(varSearcher.findVarsForEl(oldEl, context, vars, true));
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2012-07-18 23:27:09 UTC (rev 42636)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2012-07-18 23:28:14 UTC (rev 42637)
@@ -31,4 +31,4 @@
OpenBundle=Open bundle ''{0}''
OpenBundleProperty=Open property ''{0}'' of bundle ''{1}''
-OpenVarDefinition=Open Definition of ''{0}''
+OpenVarDefinition=Open Definition of ''{0}'' in ''{1}''
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELSegmentImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELSegmentImpl.java 2012-07-18 23:27:09 UTC (rev 42636)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELSegmentImpl.java 2012-07-18 23:28:14 UTC (rev 42637)
@@ -39,7 +39,8 @@
protected boolean resolved = false;
protected boolean validatable = true;
protected List<IVariable> variables = new ArrayList<IVariable>();
- protected Var var = null;
+ protected List<Var> vars = new ArrayList<Var>();
+
public ELSegmentImpl(LexicalToken token) {
this.token = token;
@@ -71,43 +72,56 @@
}
return sourceReference;
}
+
+ public static class VarOpenable implements IOpenableReference {
+ Var var;
+ VarOpenable(Var var) {
+ this.var = var;
+ }
+ @Override
+ public boolean open() {
+ IEditorPart part = null;
+ IWorkbenchWindow window = ELCorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) return false;
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ part = IDE.openEditor(page, var.getFile());
+ } catch (PartInitException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+ if(part != null) {
+ part.getEditorSite().getSelectionProvider().setSelection(new TextSelection(var.getDeclarationOffset(), var.getDeclarationLength()));
+ }
+ return false;
+ }
+
+ @Override
+ public String getLabel() {
+ return MessageFormat.format(ElCoreMessages.OpenVarDefinition, var.getName(), var.getFile().getName());
+ }
+ public Var getVar() {
+ return var;
+ }
+
+ @Override
+ public Image getImage() {
+ return null;
+ }
+ }
+
/**
* Default empty implementation. Subclasses should override this method.
*
* @return
*/
public IOpenableReference[] getOpenable() {
- if(var != null) {
- IOpenableReference result = new IOpenableReference() {
- @Override
- public boolean open() {
- IEditorPart part = null;
- IWorkbenchWindow window = ELCorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- if (window == null) return false;
- IWorkbenchPage page = window.getActivePage();
- try {
- part = IDE.openEditor(page, var.getFile());
- } catch (PartInitException e) {
- ELCorePlugin.getDefault().logError(e);
- }
- if(part != null) {
- part.getEditorSite().getSelectionProvider().setSelection(new TextSelection(var.getDeclarationOffset(), var.getDeclarationLength()));
- }
- return false;
- }
-
- @Override
- public String getLabel() {
- return MessageFormat.format(ElCoreMessages.OpenVarDefinition, var.getName());
- }
-
- @Override
- public Image getImage() {
- return null;
- }
- };
- return new IOpenableReference[]{result};
+ if(!vars.isEmpty()) {
+ List<IOpenableReference> rs = new ArrayList<IOpenableReference>();
+ for (Var var: vars) {
+ rs.add(new VarOpenable(var));
+ }
+ return rs.toArray(new VarOpenable[0]);
}
return new IOpenableReference[0];
}
@@ -192,11 +206,11 @@
this.validatable = validatable;
}
- public void setVar(Var var) {
- this.var = var;
+ public void setVars(List<Var> vars) {
+ this.vars = vars;
}
public Var getVar() {
- return var;
+ return vars.isEmpty() ? null : vars.iterator().next();
}
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2012-07-18 23:27:09 UTC (rev 42636)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2012-07-18 23:28:14 UTC (rev 42637)
@@ -306,39 +306,62 @@
if(vars!=null) {
ArrayList<Var> parentVars = new ArrayList<Var>();
for (Var var : vars) {
- ELExpression token = var.getElToken();
- if(token!=null && !token.getText().endsWith(".")) { //$NON-NLS-1$
- String varName = var.getName();
- if(el.equals(varName) || el.startsWith(varName.trim()+".")) { //$NON-NLS-1$
- if(var.getElToken()!=null && initializeNestedVars) {
- Var parentVar = findVarForEl(var.getElToken().getText(), context, parentVars, true);
- if(parentVar!=null) {
- ELExpression resolvedToken = parentVar.getResolvedElToken();
- if(resolvedToken==null && parentVar.getElToken()!=null) {
- try {
- // Initialize parent vars.
- engine.resolveELOperand(file, context, var.getElToken(), true, parentVars, this, (var.getRegion() == null ? 0 : var.getRegion().getOffset()));
- resolvedToken = parentVar.getResolvedElToken();
- } catch (StringIndexOutOfBoundsException e) {
- ELCorePlugin.getPluginLog().logError(e);
- } catch (BadLocationException e) {
- ELCorePlugin.getPluginLog().logError(e);
- }
- }
- if(resolvedToken!=null) {
- String oldText = var.getElToken().getText();
- String newValue = "#{" + resolvedToken.getText() + oldText.substring(parentVar.getName().length()) + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- var.value = newValue;
- var.elToken = var.parseEl(newValue);
- }
+ if(isRelevantVar(var, el, context, vars, parentVars, initializeNestedVars)) {
+ return var;
+ }
+ }
+ }
+ return null;
+ }
+
+ public List<Var> findVarsForEl(String el, ELContext context, List<Var> vars, boolean initializeNestedVars) {
+ List<Var> result = new ArrayList<Var>();
+ ArrayList<Var> parentVars = new ArrayList<Var>();
+ for (Var var : vars) {
+ if(isRelevantVar(var, el, context, vars, parentVars, initializeNestedVars)) {
+ result.add(var);
+ }
+ }
+ return result;
+ }
+
+ private boolean isRelevantVar(Var var, String el, ELContext context, List<Var> vars, ArrayList<Var> parentVars, boolean initializeNestedVars) {
+ boolean result = false;
+ ELExpression token = var.getElToken();
+ if(token!=null && !token.getText().endsWith(".")) { //$NON-NLS-1$
+ String varName = var.getName();
+ if(el.equals(varName) || el.startsWith(varName.trim()+".")) { //$NON-NLS-1$
+ if(var.getElToken()!=null && initializeNestedVars) {
+ ELContext c = context;
+ if(!var.getFile().equals(context.getResource())) {
+ //TODO
+ }
+ Var parentVar = findVarForEl(var.getElToken().getText(), c, parentVars, true);
+ if(parentVar!=null) {
+ ELExpression resolvedToken = parentVar.getResolvedElToken();
+ if(resolvedToken==null && parentVar.getElToken()!=null) {
+ try {
+ // Initialize parent vars.
+ engine.resolveELOperand(file, context, var.getElToken(), true, parentVars, this, (var.getRegion() == null ? 0 : var.getRegion().getOffset()));
+ resolvedToken = parentVar.getResolvedElToken();
+ } catch (StringIndexOutOfBoundsException e) {
+ ELCorePlugin.getPluginLog().logError(e);
+ } catch (BadLocationException e) {
+ ELCorePlugin.getPluginLog().logError(e);
}
}
- return var;
+ if(resolvedToken!=null) {
+ String oldText = var.getElToken().getText();
+ String newValue = "#{" + resolvedToken.getText() + oldText.substring(parentVar.getName().length()) + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ var.value = newValue;
+ var.elToken = var.parseEl(newValue);
+ }
}
}
- parentVars.add(var);
+ result = true;
}
}
- return null;
+ parentVars.add(var);
+ return result;
}
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2012-07-18 23:27:09 UTC (rev 42636)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2012-07-18 23:28:14 UTC (rev 42637)
@@ -212,7 +212,12 @@
return null;
}
};
- if(os.length == 1) return new IOpenableReference[]{os[0], openable};
+ if(os.length > 0) {
+ IOpenableReference[] os1 = new IOpenableReference[os.length + 1];
+ System.arraycopy(os, 0, os1, 0, os.length);
+ os1[os.length] = openable;
+ return os1;
+ }
return new IOpenableReference[]{openable};
}
return os;
13 years, 8 months
JBoss Tools SVN: r42636 - in trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink: xpl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-07-18 19:27:09 -0400 (Wed, 18 Jul 2012)
New Revision: 42636
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/InformationControlManager.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractInformationControl.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HierarchyInformationControl.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/InformationPresenter.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.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.
Added: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/InformationControlManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/InformationControlManager.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/InformationControlManager.java 2012-07-18 23:27:09 UTC (rev 42636)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.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.common.text.ext.hyperlink.xpl.HierarchyInformationControl;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.InformationPresenter;
+
+public class InformationControlManager {
+ public static final InformationControlManager instance = new InformationControlManager();
+
+ public IInformationControl showHyperlinks(String title, ITextViewer viewer, IHyperlink[] hyperlinks){
+ return showHyperlinks(title, viewer, hyperlinks, false);
+ }
+
+ public 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;
+ }
+ }
+
+ protected IInformationControlCreator getHierarchyPresenterControlCreator(final String title, final IHyperlink[] hyperlinks) {
+ return new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ int shellStyle= SWT.RESIZE;
+ int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
+ HierarchyInformationControl iControl = new HierarchyInformationControl(parent, title, shellStyle, treeStyle, hyperlinks);
+ iControl.setInput(hyperlinks);
+ return iControl;
+ }
+ };
+ }
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/InformationControlManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractInformationControl.java (from rev 42449, trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/AbstractInformationControl.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractInformationControl.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractInformationControl.java 2012-07-18 23:27:09 UTC (rev 42636)
@@ -0,0 +1,708 @@
+/*******************************************************************************
+ * 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.common.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() });
+ }
+ }
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractInformationControl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HierarchyInformationControl.java (from rev 42449, trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HierarchyInformationControl.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HierarchyInformationControl.java 2012-07-18 23:27:09 UTC (rev 42636)
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * 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.common.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;
+
+/**
+ * Show hierarchy in light-weight control.
+ *
+ * @since 3.0
+ */
+public class HierarchyInformationControl extends AbstractInformationControl {
+ private IHyperlink[] hyperlinks;
+
+ private BeanTableLabelProvider fLabelProvider;
+
+ 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);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean hasHeader() {
+ return true;
+ }
+
+ /* (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= createTableLableProvider();
+
+ tableViewer.setLabelProvider(fLabelProvider);
+
+ return tableViewer;
+ }
+
+ protected BeanTableLabelProvider createTableLableProvider() {
+ return new BeanTableLabelProvider();
+ }
+
+ /**
+ * {@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;
+ }
+
+ }
+
+ protected boolean select2(SearchPattern patternMatcher, Object element) {
+ return true;
+ }
+
+ public class BeanFilter extends ViewerFilter {
+ SearchPattern patternMatcher = new SearchPattern();
+ public boolean isConsistentItem(Object item) {
+ return true;
+ }
+
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ return select2(patternMatcher, element);
+ }
+
+ }
+
+ protected static Color gray = new Color(null, 128, 128, 128);
+ protected static Color black = new Color(null, 0, 0, 0);
+
+ protected static Styler NAME_STYLE = new DefaultStyler(black, false);
+ protected 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);
+ }
+ }
+ }
+
+ protected class BeanTableLabelProvider extends StyledCellLabelProvider implements DelegatingStyledCellLabelProvider.IStyledLabelProvider {
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+ StyledString styledString = getStyledText(element);
+ cell.setText(styledString.getString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ cell.setImage(getImage(element));
+
+ super.update(cell);
+ }
+
+ public String getText(Object element) {
+ return getStyledText(element).getString();
+ }
+ public StyledString getStyledText(Object element) {
+ StyledString sb = new StyledString();
+ if(element instanceof IHyperlink){
+ sb.append(((IHyperlink)element).getHyperlinkText(), NAME_STYLE);
+ }
+ return sb;
+ }
+
+ public Image getImage(Object element) {
+ return null;
+ }
+ }
+}
+
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HierarchyInformationControl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/InformationPresenter.java (from rev 42449, trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/InformationPresenter.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/InformationPresenter.java 2012-07-18 23:27:09 UTC (rev 42636)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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.common.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) {
+ }
+ }
+
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/InformationPresenter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java (from rev 42449, trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java 2012-07-18 23:27:09 UTC (rev 42636)
@@ -0,0 +1,812 @@
+/*******************************************************************************
+ * 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.common.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);
+ }
+
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/MultipleHyperlinkPresenter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 8 months
JBoss Tools SVN: r42635 - in trunk: cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-18 18:04:00 -0400 (Wed, 18 Jul 2012)
New Revision: 42635
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java
Log:
Make CDI Quick Fixes work for As-You-Type validator annotations https://issues.jboss.org/browse/JBIDE-12328
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -25,6 +25,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
@@ -68,15 +69,15 @@
@Override
public void run(IMarker marker) {
- internal_run(false);
+ do_run(false, false);
}
@Override
public void runForTest(IMarker marker) {
- internal_run(true);
+ do_run(false, true);
}
- private void internal_run(boolean test){
+ private void do_run(boolean leaveDirty, boolean test){
if(!test){
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
boolean cont = MessageDialog.openQuestion(shell, CDIUIMessages.QUESTION, CDIUIMessages.DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS);
@@ -92,6 +93,9 @@
CompilationUnitChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
+ if(leaveDirty){
+ change.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
change.perform(new NullProgressMonitor());
cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
@@ -168,7 +172,7 @@
@Override
public void apply(IDocument document) {
- internal_run(false);
+ do_run(true, false);
}
@Override
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -2,7 +2,10 @@
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.cdi.internal.core.validation.CDICoreValidator;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationErrorManager;
+import org.jboss.tools.cdi.ui.marker.MakeFieldStaticMarkerResolution;
+import org.jboss.tools.common.base.test.MarkerResolutionTestUtil;
import org.jboss.tools.common.base.test.QuickFixTestUtil;
import org.jboss.tools.common.ui.marker.ConfigureProblemSeverityMarkerResolution;
@@ -15,6 +18,7 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonStaticProducerBroken.qfxresult",
CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME,
CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID,
- ConfigureProblemSeverityMarkerResolution.class);
- }
+ MakeFieldStaticMarkerResolution.class);
+ }
+
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -18,6 +18,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.swt.graphics.Point;
import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.quickfix.IQuickFix;
@@ -40,14 +41,17 @@
return label;
}
- protected void run_internal(){
+ protected void do_run(boolean leaveDirty){
try{
if(cUnit != null){
ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
- TextChange change = getChange(compilationUnit);
+ TextFileChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
+ if(leaveDirty){
+ change.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
change.perform(new NullProgressMonitor());
cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
@@ -60,7 +64,7 @@
@Override
public final void run(IMarker marker) {
- run_internal();
+ do_run(false);
}
@Override
@@ -99,7 +103,7 @@
@Override
public void apply(IDocument document) {
- run_internal();
+ do_run(true);
}
@Override
@@ -127,5 +131,5 @@
return 100;
}
- abstract protected TextChange getChange(ICompilationUnit compilationUnit);
+ abstract protected TextFileChange getChange(ICompilationUnit compilationUnit);
}
Modified: trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -24,7 +24,6 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
-import org.jboss.tools.common.base.test.validation.TestUtil;
import org.jboss.tools.common.quickfix.QuickFixManager;
import org.jboss.tools.common.refactoring.TestableResolutionWithDialog;
import org.jboss.tools.common.refactoring.TestableResolutionWithRefactoringProcessor;
@@ -89,6 +88,10 @@
// Find annotation
TempJavaProblemAnnotation[] annotations = waitForProblemAnnotationAppearance(viewer);
+ System.out.println("ANNOTATIONS Before...");
+ for(TempJavaProblemAnnotation a : annotations){
+ System.out.println(a.getText());
+ }
Assert.assertTrue("No annotations found", annotations.length > 0);
@@ -116,16 +119,21 @@
} else if(proposal instanceof TestableResolutionWithDialog){
((TestableResolutionWithDialog) proposal).runForTest(null);
} else {
- //proposal.apply(document);
+ proposal.apply(document);
}
//TestUtil.validate(file);
- //TempJavaProblemAnnotation[] newAnnotations = waitForProblemAnnotationAppearance(viewer);
+ TempJavaProblemAnnotation[] newAnnotations = waitForProblemAnnotationAppearance(viewer);
+ System.out.println("ANNOTATIONS After...");
+ for(TempJavaProblemAnnotation a : newAnnotations){
+ System.out.println(a.getText());
+ }
+
- //Assert.assertTrue("Quick fix did not decrease number of problems. was: "+annotations.length+" now: "+newAnnotations.length, newAnnotations.length < annotations.length);
+ Assert.assertTrue("Quick fix did not decrease number of problems. was: "+annotations.length+" now: "+newAnnotations.length, newAnnotations.length <= annotations.length);
- //checkResults(project, fileNames, results);
+ checkResults(file, document.get());
return;
}
@@ -151,16 +159,10 @@
return proposals.toArray(new IJavaCompletionProposal[]{});
}
- private static void checkResults(IProject project, String[] fileNames, String[] results) throws CoreException{
- for(int i = 0; i < results.length; i++){
- IFile file = project.getFile(fileNames[i]);
- IFile resultFile = project.getFile(results[i]);
-
- String fileContent = FileUtil.readStream(file);
- String resultContent = FileUtil.readStream(resultFile);
-
- Assert.assertEquals("Wrong result of resolution", resultContent, fileContent);
- }
+ private static void checkResults(IFile file, String text) throws CoreException{
+ String fileContent = FileUtil.readStream(file);
+
+ Assert.assertEquals("Wrong result of resolution", fileContent, text);
}
protected TempJavaProblemAnnotation[] waitForProblemAnnotationAppearance(final ISourceViewer viewer) {
@@ -170,7 +172,8 @@
public void run() {
int secondsLeft = MAX_SECONDS_TO_WAIT;
boolean isFirstPass = true;
- while (secondsLeft-- > 0) {
+ boolean found = false;
+ while (secondsLeft-- > 0 && !found) {
if (!isFirstPass) {
JobUtils.delay(1000);
@@ -189,6 +192,7 @@
if (o instanceof TempJavaProblemAnnotation){
annotations.add((TempJavaProblemAnnotation) o);
+ found = true;
}
}
13 years, 8 months
JBoss Tools SVN: r42634 - in trunk/common/plugins: org.jboss.tools.common.validation/src/org/jboss/tools/common/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-18 14:07:02 -0400 (Wed, 18 Jul 2012)
New Revision: 42634
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
Log:
Make Quick Fix "Add @SuppressWarnings" work on Temporary annotations https://issues.jboss.org/browse/JBIDE-12303
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-07-18 12:09:03 UTC (rev 42633)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-07-18 18:07:02 UTC (rev 42634)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaMarkerAnnotation;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.ui.IMarkerResolution;
@@ -49,9 +50,8 @@
String preferenceKey = getPreferenceKey(marker);
String preferencePageId = getPreferencePageId(marker);
if(preferenceKey != null && preferencePageId != null){
- boolean enabled = marker.getAttribute(ValidationErrorManager.SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, false);
int severity = marker.getAttribute(IMarker.SEVERITY, 0);
- if(enabled && severity == IMarker.SEVERITY_WARNING){
+ if(severity == IMarker.SEVERITY_WARNING){
IJavaElement element = findJavaElement(file, position);
if(element != null){
if(element instanceof IMethod){
@@ -169,22 +169,24 @@
if(preferenceKey != null && preferencePageId != null){
if(annotation instanceof TempJavaProblemAnnotation){
TempJavaProblemAnnotation tAnnotation = (TempJavaProblemAnnotation)annotation;
- int position = getPosition(tAnnotation);
- IFile file = getFile(tAnnotation);
- if(file != null){
- IJavaElement element = findJavaElement(tAnnotation, position);
- if(element != null){
- if(element instanceof IMethod){
- try{
- ILocalVariable parameter = findParameter((IMethod)element, position);
- if(parameter != null){
- proposals.add(new AddSuppressWarningsMarkerResolution(file, parameter, preferenceKey, tAnnotation.getCompilationUnit()));
+ if(JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(tAnnotation.getType())){
+ int position = getPosition(tAnnotation);
+ IFile file = getFile(tAnnotation);
+ if(file != null){
+ IJavaElement element = findJavaElement(tAnnotation, position);
+ if(element != null){
+ if(element instanceof IMethod){
+ try{
+ ILocalVariable parameter = findParameter((IMethod)element, position);
+ if(parameter != null){
+ proposals.add(new AddSuppressWarningsMarkerResolution(file, parameter, preferenceKey, tAnnotation.getCompilationUnit()));
+ }
+ }catch(JavaModelException ex){
+ CommonUIPlugin.getDefault().logError(ex);
}
- }catch(JavaModelException ex){
- CommonUIPlugin.getDefault().logError(ex);
}
+ proposals.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey, tAnnotation.getCompilationUnit()));
}
- proposals.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey, tAnnotation.getCompilationUnit()));
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-07-18 12:09:03 UTC (rev 42633)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-07-18 18:07:02 UTC (rev 42634)
@@ -51,7 +51,6 @@
static String VALIDATION_MARKER_GROUP = "groupName"; //$NON-NLS-1$
public static final String PREFERENCE_KEY_ATTRIBUTE_NAME = "preference_key"; //$NON-NLS-1$
public static final String PREFERENCE_PAGE_ID_NAME = "preference_page_id"; //$NON-NLS-1$
- public static final String SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE = "sup_warn_ena"; //$NON-NLS-1$
public static final String MESSAGE_ID_ATTRIBUTE_NAME = "Message_id"; //$NON-NLS-1$
protected IStatus OK_STATUS = new Status(IStatus.OK, "org.eclipse.wst.validation", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -174,13 +173,6 @@
CommonPlugin.getDefault().logError(e);
}
- if(marker != null){
- try {
- marker.setAttribute(SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, true);
- } catch (CoreException e) {
- CommonPlugin.getDefault().logError(e);
- }
- }
return marker;
}
13 years, 8 months
JBoss Tools SVN: r42633 - trunk/build/target-platform.
by jbosstools-commits@lists.jboss.org
Author: mickael_istria
Date: 2012-07-18 08:09:03 -0400 (Wed, 18 Jul 2012)
New Revision: 42633
Modified:
trunk/build/target-platform/jbds.target
trunk/build/target-platform/multiple.target
trunk/build/target-platform/unified.target
Log:
JBIDE-11726: Remove includedBundles since
* Build resolves those IUs from composite site
* They cause trouble in IDE
* Tycho ignores it.
Modified: trunk/build/target-platform/jbds.target
===================================================================
--- trunk/build/target-platform/jbds.target 2012-07-18 11:38:44 UTC (rev 42632)
+++ trunk/build/target-platform/jbds.target 2012-07-18 12:09:03 UTC (rev 42633)
@@ -363,11 +363,5 @@
<unit id="com.google.gwt.eclipse.sdkbundle.e42.feature.feature.group" version="2.4.0.v201206290132-rel-r42"/>
</location>
</locations>
- <includeBundles>
- <!-- JBIDE-12292 include m2e.wtp like a component, rather than an upstream dependency -->
- <feature id="org.eclipse.m2e.wtp.feature"/>
- <feature id="org.mozilla.xulrunner.feature"/>
- <feature id="org.mozilla.xpcom.feature"/>
- </includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
</target>
Modified: trunk/build/target-platform/multiple.target
===================================================================
--- trunk/build/target-platform/multiple.target 2012-07-18 11:38:44 UTC (rev 42632)
+++ trunk/build/target-platform/multiple.target 2012-07-18 12:09:03 UTC (rev 42633)
@@ -363,11 +363,5 @@
<unit id="com.google.gwt.eclipse.sdkbundle.e42.feature.feature.group" version="2.4.0.v201206290132-rel-r42"/>
</location>
</locations>
- <includeBundles>
- <!-- JBIDE-12292 include m2e.wtp like a component, rather than an upstream dependency -->
- <feature id="org.eclipse.m2e.wtp.feature"/>
- <feature id="org.mozilla.xulrunner.feature"/>
- <feature id="org.mozilla.xpcom.feature"/>
- </includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
</target>
Modified: trunk/build/target-platform/unified.target
===================================================================
--- trunk/build/target-platform/unified.target 2012-07-18 11:38:44 UTC (rev 42632)
+++ trunk/build/target-platform/unified.target 2012-07-18 12:09:03 UTC (rev 42633)
@@ -364,11 +364,5 @@
<unit id="com.google.gwt.eclipse.sdkbundle.e42.feature.feature.group" version="2.4.0.v201206290132-rel-r42"/>
</location>
</locations>
- <includeBundles>
- <!-- JBIDE-12292 include m2e.wtp like a component, rather than an upstream dependency -->
- <feature id="org.eclipse.m2e.wtp.feature"/>
- <feature id="org.mozilla.xulrunner.feature"/>
- <feature id="org.mozilla.xpcom.feature"/>
- </includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
</target>
13 years, 8 months
JBoss Tools SVN: r42632 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2012-07-18 07:38:44 -0400 (Wed, 18 Jul 2012)
New Revision: 42632
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
Log:
https://issues.jboss.org/browse/JBIDE-12343
Unfortunately JavaProject.getAdapter(JpaProject.class) returns null while IProject.getAdapter(JpaProject.class) not
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2012-07-18 10:43:26 UTC (rev 42631)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2012-07-18 11:38:44 UTC (rev 42632)
@@ -6,7 +6,9 @@
import java.util.Collections;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -432,7 +434,7 @@
}
if (ConnectionProfileCtrl.JPA_CONNECTIN_NAME.equals(cpName)){
- JpaProject jpaProject = (JpaProject) findJavaProject.getAdapter(JpaProject.class);
+ JpaProject jpaProject = (JpaProject) findJavaProject.getProject().getAdapter(JpaProject.class);
if (jpaProject == null){
setErrorMessage(NLS.bind(HibernateConsoleMessages.ConsoleConfigurationMainTab_project_must_be_jpa, getProjectName()));
return false;
13 years, 8 months