Author: dazarov
Date: 2010-03-03 05:34:07 -0500 (Wed, 03 Mar 2010)
New Revision: 20587
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.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
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/PaletteTaglibInserter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java 2010-03-03
09:38:04 UTC (rev 20586)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteTaglibInserter.java 2010-03-03
10:34:07 UTC (rev 20587)
@@ -76,7 +76,7 @@
IStructuredModel model = null;
try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(d);
+ model =
StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)d);
IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel)
model).getDocument() : null;
if (xmlDocument == null) {
return false;
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-03-03
09:38:04 UTC (rev 20586)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2010-03-03
10:34:07 UTC (rev 20587)
@@ -12,12 +12,14 @@
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.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.web.ui.Messages;
@@ -30,29 +32,33 @@
*
*/
public class AddTLDMarkerResolution implements IMarkerResolution{
- private IDocumentProvider provider;
- private FileEditorInput input;
+ private IFile file;
private Properties properties;
- public AddTLDMarkerResolution(IDocumentProvider provider, FileEditorInput input,
Properties properties){
- this.provider = provider;
- this.input = input;
+ public AddTLDMarkerResolution(IFile file, Properties properties){
+ this.file = file;
this.properties = properties;
}
public String getLabel() {
return Messages.AddTLDMarkerResolution_Name;
}
-
-
public void run(IMarker marker) {
- IDocument document = provider.getDocument(input);
- PaletteTaglibInserter inserter = new PaletteTaglibInserter();
- inserter.inserTaglib(document, properties);
- try{
+ FileEditorInput input = new FileEditorInput(file);
+ IDocumentProvider provider =
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+
+ IDocument document = provider.getDocument(input);
+
+ PaletteTaglibInserter inserter = new PaletteTaglibInserter();
+ inserter.inserTaglib(document, properties);
+
+ provider.aboutToChange(input);
provider.saveDocument(new NullProgressMonitor(), input, document, true);
+ provider.disconnect(input);
}catch(CoreException ex){
WebUiPlugin.getPluginLog().logError(ex);
}
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-03-03
09:38:04 UTC (rev 20586)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2010-03-03
10:34:07 UTC (rev 20587)
@@ -52,15 +52,13 @@
}
private IFile file;
- private IDocumentProvider provider;
- private FileEditorInput input;
private Properties properties;
public IMarkerResolution[] getResolutions(IMarker marker) {
try{
if(isOurCase(marker)){
return new IMarkerResolution[] {
- new AddTLDMarkerResolution(provider, input, properties)
+ new AddTLDMarkerResolution(file, properties)
};
}
@@ -86,8 +84,16 @@
file = (IFile)marker.getResource();
- IDocument document = getDocument(file);
+ FileEditorInput input = new FileEditorInput(file);
+ IDocumentProvider provider =
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ WebUiPlugin.getPluginLog().logError(e);
+ }
+ IDocument document = provider.getDocument(input);
+
properties = new Properties();
properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true");
//$NON-NLS-1$
properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, ""); //$NON-NLS-1$
@@ -113,9 +119,11 @@
Properties p = PaletteTaglibInserter.getPrefixes(document, properties);
+ provider.disconnect(input);
+
if(p.containsValue(prefix))
return false;
-
+
return true;
}
@@ -134,18 +142,4 @@
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