Author: vrubezhny
Date: 2007-08-16 15:34:13 -0400 (Thu, 16 Aug 2007)
New Revision: 3191
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/IHyperLinkPartitionPriority.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-735 Open-Ons for Beans and Bean properties
don't work in Seam projects.
A support is added for hiperlinkPartitioners ordering
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2007-08-16
19:28:49 UTC (rev 3190)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2007-08-16
19:34:13 UTC (rev 3191)
@@ -23,7 +23,8 @@
org.eclipse.ui.editors,
org.eclipse.core.runtime,
org.eclipse.swt,
- org.eclipse.ui,org.eclipse.text,
+ org.eclipse.ui,
+ org.eclipse.text,
org.eclipse.jface,
org.eclipse.jface.text,
org.eclipse.ui.workbench,
@@ -31,11 +32,11 @@
org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.eclipse.core.resources,
- org.eclipse.wst.sse.core,
- org.eclipse.wst.sse.ui,
- org.eclipse.wst.xml.core,
- org.eclipse.jst.jsp.core,
- org.eclipse.jst.j2ee.web,
- org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.sse.core;visibility:=reexport,
+ org.eclipse.wst.sse.ui;visibility:=reexport,
+ org.eclipse.wst.xml.core;visibility:=reexport,
+ org.eclipse.jst.jsp.core;visibility:=reexport,
+ org.eclipse.jst.j2ee.web;visibility:=reexport,
+ org.eclipse.wst.common.modulecore;visibility:=reexport,
org.eclipse.emf.ecore
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java 2007-08-16
19:28:49 UTC (rev 3190)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java 2007-08-16
19:34:13 UTC (rev 3191)
@@ -10,9 +10,14 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IExtension;
import org.eclipse.jface.text.IDocument;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.sse.ui.internal.util.Sorter;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.w3c.dom.Attr;
@@ -28,9 +33,18 @@
IHyperlinkRegion childRegion = parse(document, superRegion);
if (childRegion == null) return null;
HyperlinkPartitionerDefinition[] hyperlinkPartitionerDefinitions =
HyperlinkPartitionerBuilder.getInstance().getHyperlinkPartitionerDefinitions(childRegion.getContentType(),
childRegion.getType(), childRegion.getAxis());
+
+ List<IHyperlinkPartitioner> partitioners = new
ArrayList<IHyperlinkPartitioner>();
for(int i=0; i<hyperlinkPartitionerDefinitions.length; i++) {
HyperlinkPartitionerDefinition def = hyperlinkPartitionerDefinitions[i];
IHyperlinkPartitioner partitioner = def.createHyperlinkPartitioner();
+ if (partitioner != null)
+ partitioners.add(partitioner);
+ }
+ IHyperlinkPartitioner[] sortedPartitioners =
orderHyperlinkPartitioners(partitioners.toArray(new IHyperlinkPartitioner[0]));
+
+ for(int i=0; sortedPartitioners != null &&
i<sortedPartitioners.length; i++) {
+ IHyperlinkPartitioner partitioner = sortedPartitioners[i];
if((!(partitioner instanceof IHyperlinkPartitionRecognizer)) ||
((IHyperlinkPartitionRecognizer)partitioner).recognize(document,
childRegion)) {
if (partitioner instanceof IExclusiblePartitionerRecognition) {
@@ -46,6 +60,41 @@
return childRegion.getType();
}
+ protected Sorter createSorter() {
+ return new Sorter() {
+ public boolean compare(Object partitioner1, Object partitioner2) {
+ IHyperlinkPartitioner p1 = (IHyperlinkPartitioner)partitioner1;
+ IHyperlinkPartitioner p2 = (IHyperlinkPartitioner)partitioner2;
+
+ String s1 = ((IHyperlinkPartitioner) partitioner1).getClass().getName();
+ String s2 = ((IHyperlinkPartitioner) partitioner2).getClass().getName();
+
+ int pp1 = Integer.MAX_VALUE;
+ int pp2 = Integer.MAX_VALUE;
+
+ if (p1 instanceof IHyperLinkPartitionPriority)
+ pp1 = ((IHyperLinkPartitionPriority)p1).getPriority();
+
+ if (p2 instanceof IHyperLinkPartitionPriority)
+ pp2 = ((IHyperLinkPartitionPriority)p2).getPriority();
+
+ if (pp1 == pp2) {
+ return s2.compareTo(s1) > 0;
+ }
+
+ return (pp1 < pp2);
+ }
+ };
+ }
+
+ protected IHyperlinkPartitioner[] orderHyperlinkPartitioners(IHyperlinkPartitioner[]
partitioners) {
+ Object[] sorted = createSorter().sort(partitioners);
+ IHyperlinkPartitioner[] sortedPartitioners = new IHyperlinkPartitioner[sorted.length];
+ System.arraycopy(sorted, 0, sortedPartitioners, 0, sorted.length);
+ return sortedPartitioners;
+ }
+
+
IHyperlinkPartitioner findExclusionPartitioner (String partitionType,
HyperlinkPartitionerDefinition[] hyperlinkPartitionerDefinitions, IDocument document,
IHyperlinkRegion region) {
for(int i=0; i<hyperlinkPartitionerDefinitions.length; i++) {
HyperlinkPartitionerDefinition def = hyperlinkPartitionerDefinitions[i];
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/IHyperLinkPartitionPriority.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/IHyperLinkPartitionPriority.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/IHyperLinkPartitionPriority.java 2007-08-16
19:34:13 UTC (rev 3191)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.text.ext.hyperlink;
+
+/**
+ * @author Jeremy
+ *
+ */
+public interface IHyperLinkPartitionPriority {
+ int getPriority();
+}