[jbosstools-commits] JBoss Tools SVN: r42067 - in trunk/jsf/tests/org.jboss.tools.jsf.ui.test: src/org/jboss/tools/jsf/ui/test and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Mon Jun 18 17:06:01 EDT 2012
Author: dazarov
Date: 2012-06-18 17:05:58 -0400 (Mon, 18 Jun 2012)
New Revision: 42067
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.jsp
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.xhtml
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java
Log:
Make Quick fix for problem markers "Unknown tag" work on temporary WTP annotations https://issues.jboss.org/browse/JBIDE-10958
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.jsp 2012-06-18 21:05:58 UTC (rev 42067)
@@ -0,0 +1,13 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <h:commandButton value="" action=""/>
+ </f:view>
+ </body>
+</html>
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.jsp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.xhtml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.xhtml 2012-06-18 21:05:58 UTC (rev 42067)
@@ -0,0 +1,28 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ template="layout/template.xhtml">
+
+ <ui:define name="body">
+
+ <h1>Welcome to Seam!</h1>
+ <rich:panel>
+ <h:panelGrid columns="2">
+ <h:graphicImage value="/img/seamlogo.png" alt="Seam logo"/>
+ <s:div styleClass="info">
+ <p><strong>Your seam-gen project is deployed!</strong> Here are some of the features this project provides:</p>
+ <ul class="bullets">
+ <li>RichFaces panels and tables</li>
+ <li>Default CSS stylesheet</li>
+ <li>Internationalization support</li>
+ </ul>
+ </s:div>
+ </h:panelGrid>
+ </rich:panel>
+
+ </ui:define>
+</ui:composition>
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/test_jsf_project/WebContent/pages/test_page3.xhtml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java 2012-06-18 19:32:14 UTC (rev 42066)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java 2012-06-18 21:05:58 UTC (rev 42067)
@@ -3,6 +3,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -13,16 +14,33 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jst.jsp.ui.internal.validation.JSPContentSourceValidator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
+import org.eclipse.wst.validation.ValidationFramework;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.internal.MarkerManager;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.common.text.xml.quickfix.QuickFixManager;
import org.jboss.tools.jsf.ui.JsfUiPlugin;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator;
+import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
public class JSPProblemMarkerResolutionTest extends AbstractResourceMarkerTest{
@@ -31,6 +49,10 @@
private static final String XHTML_MARKER_TYPE = "org.eclipse.wst.html.core.validationMarker";
private static final String JSP_EXT = "jsp";
private static final String XHTML_EXT = "xhtml";
+
+ private static final int MAX_SECONDS_TO_WAIT = 10;
+
+ protected final static String EDITOR_ID = "org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"; //$NON-NLS-1$
public JSPProblemMarkerResolutionTest() {
super("JSP Problem Marker Resolution Tests");
@@ -39,12 +61,20 @@
public JSPProblemMarkerResolutionTest(String name) {
super(name);
}
+
+ private static boolean isSuspendedValidationDefaultValue;
@Override
protected void setUp() throws Exception {
project = ResourcesPlugin.getWorkspace().getRoot().getProject("test_jsf_project");
+ isSuspendedValidationDefaultValue = ValidationFramework.getDefault().isSuspended();
+ ValidationFramework.getDefault().suspendAllValidation(false);
}
+ public void tearDown() throws Exception {
+ ValidationFramework.getDefault().suspendAllValidation(isSuspendedValidationDefaultValue);
+ }
+
private void validate(IFile file) throws CoreException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException{
MarkerManager manager = MarkerManager.getDefault();
@@ -171,4 +201,92 @@
assertMarkerIsNotCreated(jspFile, XHTML_MARKER_TYPE, "Unknown tag (ui:insert).");
}
+
+ public void testQuickFixesForTemporaryAnnotationInJSP() throws PartInitException, BadLocationException{
+ checkQuickFixForTemporaryAnnotation("WebContent/pages/test_page3.jsp", 1);
+ }
+
+ public void testQuickFixesForTemporaryAnnotationInXHTML() throws PartInitException, BadLocationException{
+ checkQuickFixForTemporaryAnnotation("WebContent/pages/test_page3.xhtml", 5);
+ }
+
+ private void checkQuickFixForTemporaryAnnotation(String fileName, int lineToDelete) throws PartInitException, BadLocationException{
+ IFile jspFile = project.getFile(fileName);
+
+ assertTrue("File not found",jspFile.exists());
+
+ IEditorInput input = new FileEditorInput(jspFile);
+
+ IEditorPart editor = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().openEditor(input,
+ EDITOR_ID, true);
+
+ if(editor instanceof JSPMultiPageEditor){
+ JSPMultiPageEditor jspEditor = (JSPMultiPageEditor)editor;
+ IAnnotationModel aModel = jspEditor.getJspEditor().getTextViewer().getAnnotationModel();
+
+ // change file
+ IDocument document = jspEditor.getJspEditor().getTextViewer().getDocument();
+ IRegion region = document.getLineInformation(lineToDelete);
+ document.replace(region.getOffset(), region.getLength(), "");
+
+ // Find annotation
+ TemporaryAnnotation problemAnnotation = waitForProblemAnnotationAppearance(
+ aModel, MAX_SECONDS_TO_WAIT);
+ assertNotNull("No ProblemAnnotation found for Marker Type: "
+ + MARKER_TYPE, problemAnnotation);
+
+ if(problemAnnotation != null){
+ problemAnnotation.setAdditionalFixInfo(document);
+ // get all relevant quick fixes for this annotation
+ if(QuickFixManager.getInstance().hasProposals(problemAnnotation)){
+ List<ICompletionProposal> proposals = QuickFixManager.getInstance().getProposals(problemAnnotation);
+ assertNotSame("Quick fix not found", 0, proposals.size());
+ }else{
+ fail("Quick fix not found");
+ }
+ }else{
+ fail("Annotation not found");
+ }
+ }else{
+ fail("Editor must be instance of JSPMultiPageEditor, was - "+editor.getClass());
+ }
+ }
+
+ private TemporaryAnnotation waitForProblemAnnotationAppearance(
+ final IAnnotationModel annotationModel, final int seconds) {
+ final TemporaryAnnotation[] result = new TemporaryAnnotation[] { null };
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ int secondsLeft = seconds;
+ while (secondsLeft-- > 0) {
+ JobUtils.delay(1000);
+
+ // clean deffered events
+ while (Display.getCurrent().readAndDispatch())
+ ;
+
+ //boolean found = false;
+ Iterator it = annotationModel.getAnnotationIterator();
+ while (it.hasNext()) {
+ Object o = it.next();
+
+ if (!(o instanceof TemporaryAnnotation))
+ continue;
+
+ TemporaryAnnotation temporaryAnnotation = (TemporaryAnnotation) o;
+ Position position = annotationModel
+ .getPosition(temporaryAnnotation);
+
+
+ result[0] = temporaryAnnotation;
+ return;
+ }
+ }
+ }
+ });
+
+ return result[0];
+ }
}
\ No newline at end of file
More information about the jbosstools-commits
mailing list