Author: dazarov
Date: 2010-02-27 10:15:07 -0500 (Sat, 27 Feb 2010)
New Revision: 20533
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4876
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2010-02-27
14:27:27 UTC (rev 20532)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2010-02-27
15:15:07 UTC (rev 20533)
@@ -26,15 +26,16 @@
public JSPPaletteInsertHelper() {}
protected void modify(ISourceViewer v, Properties p, String[] texts) {
+ p.put("viewer", v);
String tagname = p.getProperty(PROPOPERTY_TAG_NAME);
String uri = p.getProperty(PROPOPERTY_TAGLIBRARY_URI);
String startText = texts[0];
if(startText != null && startText.startsWith("<%@ taglib")) {
//$NON-NLS-1$
- if(PaletteTaglibInserter.inserTaglibInXml(v, p)) {
+ if(PaletteTaglibInserter.inserTaglibInXml(v.getDocument(), p)) {
return;
}
} else {
- p = PaletteTaglibInserter.inserTaglib(v, p);
+ p = PaletteTaglibInserter.inserTaglib(v.getDocument(), p);
}
String defaultPrefix = p.getProperty(PROPOPERTY_DEFAULT_PREFIX);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java 2010-02-27
14:27:27 UTC (rev 20532)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java 2010-02-27
15:15:07 UTC (rev 20533)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.jspeditor.dnd;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
@@ -17,8 +18,10 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
@@ -30,6 +33,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.jsp.util.XmlUtil;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
@@ -46,9 +50,9 @@
private static final String TAGLIB_START = "<%@ taglib"; //$NON-NLS-1$
- public Properties inserTaglib(ISourceViewer v, Properties p) {
- if(!inserTaglibInXml(v, p)) {
- inserTaglibInOldJsp(v, p);
+ public Properties inserTaglib(IDocument d, Properties p) {
+ if(!inserTaglibInXml(d, p)) {
+ inserTaglibInOldJsp(d, p);
}
return p;
}
@@ -63,12 +67,11 @@
p.getProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT) != null;
}
- public boolean inserTaglibInOldJsp(ISourceViewer v, Properties p) {
+ public boolean inserTaglibInOldJsp(IDocument d, Properties p) {
if(!checkProperties(p)) {
return false;
}
- IDocument d = v.getDocument();
IStructuredModel model = null;
try {
@@ -77,7 +80,7 @@
if (xmlDocument == null) {
return false;
}
- Properties tl = getPrefixes(v);
+ Properties tl = getPrefixes(d, p);
if(tl == null) tl = JSPPaletteInsertHelper.getPrefixes(d.get());
Element root = xmlDocument.getDocumentElement();
@@ -93,9 +96,9 @@
p.setProperty(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX,
(String)tl.get(uri_p));
}
} else if(!tl.containsValue(defaultPrefix_p)) {
- if (checkplace(xmlDocument, d, "jsp:directive.taglib", tg, p, v) == false)
{ //$NON-NLS-1$
+ if (checkplace(xmlDocument, d, "jsp:directive.taglib", tg, p) == false) {
//$NON-NLS-1$
d.replace(0, 0, tg.toString());
- mouveFocusOnPage(p,v, tg.toString().length(), 0);
+ mouveFocusOnPage(p, tg.toString().length(), 0);
return true;
}
}
@@ -103,9 +106,9 @@
DocumentImpl docImpl = (DocumentImpl)xmlDocument;
// Only for JSP
if(docImpl.isJSPType()) {
- if (checkplace(xmlDocument, d, "jsp:directive.page", tg, p, v) == false) {
//$NON-NLS-1$
+ if (checkplace(xmlDocument, d, "jsp:directive.page", tg, p) == false) {
//$NON-NLS-1$
d.replace(0, 0, tg.toString());
- mouveFocusOnPage(p,v, tg.toString().length(), 0);
+ mouveFocusOnPage(p, tg.toString().length(), 0);
return true;
}
}
@@ -118,7 +121,39 @@
return false;
}
- private static Node getSelectedNode(ISourceViewer v, Properties p){
+ /**
+ * copied from ContentAssistUtils
+ * @param viewer
+ * @param documentOffset
+ * @return
+ */
+ public static IndexedRegion getNodeAt(IDocument d, int documentOffset) {
+
+ if (d == null)
+ return null;
+
+ IndexedRegion node = null;
+ IModelManager mm = StructuredModelManager.getModelManager();
+ IStructuredModel model = null;
+ if (mm != null)
+ model = mm.getExistingModelForRead(d);
+ try {
+ if (model != null) {
+ int lastOffset = documentOffset;
+ node = model.getIndexedRegion(documentOffset);
+ while (node == null && lastOffset >= 0) {
+ lastOffset--;
+ node = model.getIndexedRegion(lastOffset);
+ }
+ }
+ } finally {
+ if (model != null)
+ model.releaseFromRead();
+ }
+ return node;
+ }
+
+ private static Node getSelectedNode(IDocument d, Properties p){
ISelectionProvider selProvider =
(ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
if(selProvider == null) return null;
@@ -128,7 +163,7 @@
selection = (ITextSelection)selProvider.getSelection();
else return null;
- IndexedRegion region = ContentAssistUtils.getNodeAt(v, selection.getOffset());
+ IndexedRegion region = getNodeAt(d, selection.getOffset());
if(region == null) return null;
if(!(region instanceof Node)) return null;
@@ -142,11 +177,11 @@
return text;
}
- private static boolean checkSelectedElement(HashMap<String,String> map,
ISourceViewer v, Properties p){
+ private static boolean checkSelectedElement(HashMap<String,String> map, IDocument
d, Properties p){
String taglibUri = p.getProperty(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
if(taglibUri == null) return false;
- Node selectedNode = getSelectedNode(v, p);
+ Node selectedNode = getSelectedNode(d, p);
if(selectedNode == null) return false;
return checkElement(map, selectedNode, taglibUri);
@@ -171,12 +206,11 @@
}
}
- public boolean inserTaglibInXml(ISourceViewer v, Properties p) {
+ public boolean inserTaglibInXml(IDocument d, Properties p) {
if(!checkProperties(p)) {
return false;
}
- IDocument d = v.getDocument();
IStructuredModel model = null;
try {
@@ -187,7 +221,7 @@
return false;
}
- Properties tl = getPrefixes(v);
+ Properties tl = getPrefixes(d, p);
if(tl == null) tl = JSPPaletteInsertHelper.getPrefixes(d.get());
Element root = xmlDocument.getDocumentElement();
if(root != null) {
@@ -195,11 +229,11 @@
if (xmlDocument.getDoctype() != null /* && tagLibListConainsFacelet(tl)*/ )
{
String publicId = xmlDocument.getDoctype().getPublicId();
if (publicId!=null && publicId.toUpperCase().startsWith("-//W3C//DTD
XHTML")) { // &&
root.getNodeName().equalsIgnoreCase(HTML_SOURCE_ROOT_ELEMENT)) { //$NON-NLS-1$
- checkTL(root, v, p, d);
+ checkTL(root, p, d);
return true;
}
} else if(xmlDocument.isXMLType() ||
root.getNodeName().equals(JSP_SOURCE_ROOT_ELEMENT)) {
- checkTL(root, v, p, d);
+ checkTL(root, p, d);
return true;
}
}
@@ -224,19 +258,36 @@
/*
* analyse source for taglib, return the list of taglib
*/
- private static Properties getPrefixes(ISourceViewer viewer) {
- VpeTaglibManager tldManager = null;
- if((tldManager == null) && (viewer instanceof VpeTaglibManagerProvider)) {
- tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
- if(tldManager != null) {
- List list = tldManager.getTagLibs();
- Properties p = new Properties();
- for (int i = 0; i < list.size(); i++) {
- TaglibData data = (TaglibData)list.get(i);
- p.setProperty(data.getUri(), data.getPrefix());
+ public static Properties getPrefixes(IDocument d, Properties properties) {
+ List list = getTaglibData(d, properties);
+ Properties p = new Properties();
+ for (int i = 0; i < list.size(); i++) {
+ TaglibData data = (TaglibData)list.get(i);
+ p.setProperty(data.getUri(), data.getPrefix());
+ }
+ return p;
+ }
+
+ private static List<TaglibData> getTaglibData(IDocument d, Properties p){
+ ISourceViewer viewer= getViewer(p);
+ if(viewer != null){
+ VpeTaglibManager tldManager = null;
+ if(viewer instanceof VpeTaglibManagerProvider) {
+ tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
+ if(tldManager != null) {
+ return tldManager.getTagLibs();
+ }
+ }
+ }else{
+ List<TaglibData> result = XmlUtil.getTaglibsForJSPDocument(d, new
ArrayList<TaglibData>());
+
+ if(result == null || result.isEmpty()){
+ Node node = getSelectedNode(d, p);
+ if(node != null){
+ result = XmlUtil.processNode(node, new ArrayList<TaglibData>());
}
- return p;
- }
+ }
+ return result;
}
return null;
}
@@ -245,7 +296,7 @@
* for jsp:root and html check the taglib if exist check the prefix else add the taglib
* with text formatting
*/
- private static Properties checkTL(Element root, ISourceViewer v, Properties p, IDocument
d) {
+ private static Properties checkTL(Element root, Properties p, IDocument d) {
String uri_p = p.getProperty(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI);
String defaultPrefix_p =
p.getProperty(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX);
@@ -260,7 +311,7 @@
}
}
- if (map.containsKey(uri_p) || checkSelectedElement(map, v, p)) {
+ if (map.containsKey(uri_p) || checkSelectedElement(map, d, p)) {
if (!map.get(uri_p).equals(defaultPrefix_p)) {
p.setProperty(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, (String)
map.get(uri_p));
}
@@ -299,8 +350,13 @@
ca[i]=' ';
return ca;
}
+
+ private static ISourceViewer getViewer(Properties p){
+ return (ISourceViewer)p.get("viewer"); //$NON-NLS-1$
+ }
- private static void mouveFocusOnPage(Properties p, ISourceViewer v, int length, int
pos){
+ private static void mouveFocusOnPage(Properties p, int length, int pos){
+ ISourceViewer v = getViewer(p);
ISelectionProvider selProvider =
(ISelectionProvider)p.get(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER);
IDocument doc = v.getDocument();
@@ -331,7 +387,7 @@
return st;
}
- private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st,
StringBuffer tg, Properties p, ISourceViewer v) throws BadLocationException {
+ private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st,
StringBuffer tg, Properties p) throws BadLocationException {
NodeList nl = xmlDocument.getChildNodes();
boolean docType = false;
IndexedRegion irdt = null;
@@ -371,12 +427,12 @@
if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
tgleft.append(tg);
d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ mouveFocusOnPage(p, eo + tgleft.length(), eo);
} else {
tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)),
so-d.getLineOffset(d.getLineOfOffset(so)))));
tgleft.append(tg);
d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ mouveFocusOnPage(p, eo + tgleft.length(), eo);
}
return true;
}
@@ -388,12 +444,12 @@
if (d.getLineOffset(d.getLineOfOffset(so)) == so) {
tgleft.append(tg);
d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ mouveFocusOnPage(p, eo + tgleft.length(), eo);
} else {
tgleft.append(analyseSubstring(d.get(d.getLineOffset(d.getLineOfOffset(so)),
so-d.getLineOffset(d.getLineOfOffset(so)))));
tgleft.append(tg);
d.replace(eo, 0, tgleft.toString());
- mouveFocusOnPage(p,v, eo + tgleft.length(), eo);
+ mouveFocusOnPage(p, eo + tgleft.length(), eo);
}
return true;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-02-27 14:27:27 UTC (rev
20532)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-02-27 15:15:07 UTC (rev
20533)
@@ -676,5 +676,19 @@
</labelDecorator>
</extension>
+
+ <extension point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.eclipse.jst.jsp.core.validationMarker"
+ class="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+ <extension point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.eclipse.wst.html.core.validationMarker"
+ class="org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+
</plugin>
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2010-02-27
15:15:07 UTC (rev 20533)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.web.ui.action;
+
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+
+/**
+ * The Marker Resolution that adds tag lib declaration to jsp or xhtml file
+ *
+ * @author Daniel Azarov
+ *
+ */
+public class AddTLDMarkerResolution implements IMarkerResolution{
+
+ public static HashMap<String, String> libs = new HashMap<String, String>();
+ static{
+ libs.put("s", "http://jboss.com/products/seam/taglib");
//$NON-NLS-1$//$NON-NLS-2$
+ libs.put("ui", "http://java.sun.com/jsf/facelets"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("f", "http://java.sun.com/jsf/core"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("h", "http://java.sun.com/jsf/html"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("rich", "http://richfaces.org/rich"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("a4j", "http://richfaces.org/a4j"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("a", "http://richfaces.org/a4j"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("c", "http://java.sun.com/jstl/core"); //$NON-NLS-1$
//$NON-NLS-2$
+ libs.put("jsp", "http://java.sun.com/JSP/Page"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ public String getLabel() {
+ return "Insert tag library defenition";
+ }
+
+ public static String getPrifix(String message){
+ String prefix="";
+
+ int start = message.indexOf("(");
+ if(start < 0)
+ return null;
+
+ int end = message.indexOf(":", start);
+ if(end < 0)
+ return null;
+
+ prefix = message.substring(start+1, end);
+
+ return prefix;
+ }
+
+ public static IDocument getDocument(IFile file) {
+ FileEditorInput input = new FileEditorInput(file);
+ IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ WebUiPlugin.getPluginLog().logError(e);
+ }
+ return provider.getDocument(input);
+ }
+
+ public void run(IMarker marker) {
+
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2010-02-27
15:15:07 UTC (rev 20533)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.web.ui.action;
+
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+
+/**
+ * Shows the Marker Resolutions for Unknown tag JSP Problem Marker
+ *
+ * @author Daniel Azarov
+ *
+ */
+public class JSPProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator {
+ public IMarkerResolution[] getResolutions(IMarker marker) {
+ try{
+ if(isOurCase(marker)){
+ return new IMarkerResolution[] {
+ new AddTLDMarkerResolution()
+ };
+ }
+
+ }catch(CoreException ex){
+ WebUiPlugin.getPluginLog().logError(ex);
+ }
+ return new IMarkerResolution[]{};
+ }
+
+ private boolean isOurCase(IMarker marker) throws CoreException{
+ String message = (String)marker.getAttribute(IMarker.MESSAGE);
+ final int start = ((Integer)marker.getAttribute(IMarker.CHAR_START)).intValue();
+ final int end = ((Integer)marker.getAttribute(IMarker.CHAR_END)).intValue();
+ if(!message.startsWith("Unknown tag"))
+ return false;
+
+ String prefix = AddTLDMarkerResolution.getPrifix(message);
+ if(prefix == null)
+ return false;
+
+ //System.out.println("Prefix - "+prefix);
+
+ if(!AddTLDMarkerResolution.libs.containsKey(prefix))
+ return false;
+
+ IFile file = (IFile)marker.getResource();
+
+ //System.out.println("File - "+file.getFullPath());
+
+ IDocument document = AddTLDMarkerResolution.getDocument(file);
+
+ Properties properties = new Properties();
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI,
AddTLDMarkerResolution.libs.get(prefix));
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
+ properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new
ISelectionProvider() {
+
+ public void setSelection(ISelection selection) {
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ return new TextSelection(start, end-start);
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+ });
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true");
//$NON-NLS-1$
+
+ Properties p = PaletteTaglibInserter.getPrefixes(document, properties);
+
+ if(p.containsValue(prefix))
+ return false;
+
+
+// ArrayList<TaglibData> includeTaglibs = new ArrayList<TaglibData>();
+
+// List<TaglibData> taglibs = XmlUtil.getTaglibsForJSPDocument(document,
includeTaglibs);
+//
+// for(TaglibData data : taglibs){
+// System.out.println("Taglib prefix - "+data.getPrefix()+" URI -
"+data.getUri());
+// }
+
+// if(XmlUtil.getTaglibForPrefix(prefix, taglibs) != null)
+// return false;
+
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain