Author: dazarov
Date: 2010-02-28 04:59:15 -0500 (Sun, 28 Feb 2010)
New Revision: 20536
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
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
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-4876
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2010-02-28
09:28:32 UTC (rev 20535)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2010-02-28
09:59:15 UTC (rev 20536)
@@ -70,6 +70,7 @@
public static String WebAppFoldersFormLayoutData_Persistence;
public static String WebCompoundEditor_WebXMLEditor;
public static String XActionProvider_CompanyName;
+ public static String AddTLDMarkerResolution_Name;
static {
// initialize resource bundle
Modified:
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 2010-02-28
09:28:32 UTC (rev 20535)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2010-02-28
09:59:15 UTC (rev 20536)
@@ -10,19 +10,17 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.action;
-import java.util.HashMap;
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.core.runtime.NullProgressMonitor;
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.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
+import org.jboss.tools.jst.web.ui.Messages;
import org.jboss.tools.jst.web.ui.WebUiPlugin;
/**
@@ -32,62 +30,31 @@
*
*/
public class AddTLDMarkerResolution implements IMarkerResolution{
- private IFile file;
- private IDocument document;
+ private IDocumentProvider provider;
+ private FileEditorInput input;
private Properties properties;
- 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 AddTLDMarkerResolution(IFile file, IDocument document, Properties properties){
- this.file = file;
- this.document = document;
+ public AddTLDMarkerResolution(IDocumentProvider provider, FileEditorInput input,
Properties properties){
+ this.provider = provider;
+ this.input = input;
this.properties = properties;
}
public String getLabel() {
- return "Insert tag library defenition";
+ return Messages.AddTLDMarkerResolution_Name;
}
- 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) {
+ IDocument document = provider.getDocument(input);
PaletteTaglibInserter inserter = new PaletteTaglibInserter();
inserter.inserTaglib(document, properties);
+ try{
+ provider.saveDocument(new NullProgressMonitor(), input, document, true);
+ }catch(CoreException ex){
+ WebUiPlugin.getPluginLog().logError(ex);
+ }
}
}
\ No newline at end of file
Modified:
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 2010-02-28
09:28:32 UTC (rev 20535)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2010-02-28
09:59:15 UTC (rev 20536)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.action;
+import java.util.HashMap;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
@@ -22,6 +23,9 @@
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
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;
@@ -34,15 +38,30 @@
*
*/
public class JSPProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator {
+
+ 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$
+ }
+
private IFile file;
- private IDocument document;
+ private IDocumentProvider provider;
+ private FileEditorInput input;
private Properties properties;
public IMarkerResolution[] getResolutions(IMarker marker) {
try{
if(isOurCase(marker)){
return new IMarkerResolution[] {
- new AddTLDMarkerResolution(file, document, properties)
+ new AddTLDMarkerResolution(provider, input, properties)
};
}
@@ -56,22 +75,22 @@
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"))
+ if(!message.startsWith("Unknown tag")) //$NON-NLS-1$
return false;
- String prefix = AddTLDMarkerResolution.getPrifix(message);
+ String prefix = getPrifix(message);
if(prefix == null)
return false;
- if(!AddTLDMarkerResolution.libs.containsKey(prefix))
+ if(!libs.containsKey(prefix))
return false;
file = (IFile)marker.getResource();
- document = AddTLDMarkerResolution.getDocument(file);
+ IDocument document = getDocument(file);
properties = new Properties();
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI,
AddTLDMarkerResolution.libs.get(prefix));
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, libs.get(prefix));
properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new
ISelectionProvider() {
@@ -98,4 +117,34 @@
return true;
}
+
+ public static String getPrifix(String message){
+ String prefix=""; //$NON-NLS-1$
+
+ int start = message.indexOf("("); //$NON-NLS-1$
+ if(start < 0)
+ return null;
+
+ int end = message.indexOf(":", start); //$NON-NLS-1$
+ if(end < 0)
+ return null;
+
+ prefix = message.substring(start+1, end);
+
+ return prefix;
+ }
+
+
+ public IDocument getDocument(IFile file) {
+ input = new FileEditorInput(file);
+ provider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ WebUiPlugin.getPluginLog().logError(e);
+ }
+
+ return provider.getDocument(input);
+ }
+
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2010-02-28
09:28:32 UTC (rev 20535)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2010-02-28
09:59:15 UTC (rev 20536)
@@ -64,3 +64,4 @@
WebAppFoldersFormLayoutData_WebAppMimeMapping=WebAppMimeMapping
WebCompoundEditor_WebXMLEditor=Web XML Editor
XActionProvider_CompanyName=Red Hat
+AddTLDMarkerResolution_Name=Insert tag library definition