JBoss Tools SVN: r18118 - in trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test: create and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-10-15 19:25:45 -0400 (Thu, 15 Oct 2009)
New Revision: 18118
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
Log:
Compilation error fixed to keep build running
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-15 22:51:53 UTC (rev 18117)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-15 23:25:45 UTC (rev 18118)
@@ -176,6 +176,12 @@
bot.radio(type).click();
bot.comboBoxWithLabel("Connection profile:").setSelection(projectProperties.getProperty("connName"));
bot.button("Finish").click();
+ /* All Jobs are executed inside New SeamProject Wizard so there is no reason to
+ * find a way to track that all jobs or particular jobs are finished. Just wait
+ * until active shell is closed. Move 30000 to constant or setup default timeout
+ * for SWTBot long enough to be sure dialog is finished.
+ */
+ bot.waitUntil(Conditions.shellCloses(bot.activeShell()),30000);
}
/**Creates any Seam Action, Form etc. */
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-15 22:51:53 UTC (rev 18117)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-15 23:25:45 UTC (rev 18118)
@@ -6,7 +6,7 @@
public void testCreateSeamProject12war(){
createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_WAR);
- waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
}
// public void testCreateSeamProject12ear(){
14 years, 8 months
JBoss Tools SVN: r18117 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-10-15 18:51:53 -0400 (Thu, 15 Oct 2009)
New Revision: 18117
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
Log:
JUnit test for https://jira.jboss.org/jira/browse/JBIDE-3473 has been fixed.
nsiAccessible is no more available in the XULRunner 1.9.
XULRunner 1.9 related issue (https://jira.jboss.org/jira/browse/JBIDE-2248 ).
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-10-15 17:58:55 UTC (rev 18116)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-10-15 22:51:53 UTC (rev 18117)
@@ -2,10 +2,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
@@ -14,6 +16,7 @@
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -24,7 +27,7 @@
*
*/
public class JBIDE3473Test extends VpeTest {
- private static final int INSERTING_POSITION = 179;
+ private static final Point INSERTION_POSITION = new Point(15, 12);
private static final String TABLE_ID = "table-id"; //$NON-NLS-1$
private static final String TEST_PAGE_NAME = "JBIDE/3473/JBIDE-3473.html"; //$NON-NLS-1$
private static final String INSERTING_TEXT = " id=\"td-id\""; //$NON-NLS-1$
@@ -55,12 +58,13 @@
// open and get editor
JSPMultiPageEditor jspEditor = openEditor(input);
- StyledText styledText = jspEditor.getSourceEditor().getTextViewer()
- .getTextWidget();
+ final StructuredTextViewer textViewer = jspEditor.getSourceEditor().getTextViewer();
+ StyledText styledText = textViewer.getTextWidget();
- styledText.setCaretOffset(INSERTING_POSITION);
- IndexedRegion indexedRegion = ContentAssistUtils.getNodeAt(jspEditor
- .getSourceEditor().getTextViewer(), INSERTING_POSITION);
+ final int offset = TestUtil.getLinePositionOffcet(textViewer,
+ INSERTION_POSITION.x, INSERTION_POSITION.y);
+ styledText.setCaretOffset(offset);
+ IndexedRegion indexedRegion = ContentAssistUtils.getNodeAt(textViewer, offset);
Node tdTextEditorNode = (Node) indexedRegion;
assertNotNull(tdTextEditorNode);
assertTrue("Text under cursor is not TD node", HTML.TAG_TD.equalsIgnoreCase(tdTextEditorNode.getNodeName())); //$NON-NLS-1$
@@ -94,14 +98,15 @@
* @return bounds of the element with given {@code id}
* or {@code null} if the element is not found or not accessible
*
- * @see VisualDomUtil#getBounds(nsIDOMNode)
+ * @see XulRunnerVpeUtils#getElementBounds(nsIDOMNode)
*/
private Rectangle getBoundsOfElementById(nsIDOMDocument document, String id) {
Rectangle bounds = null;
nsIDOMElement element = document.getElementById(id);
if (element != null) {
- bounds = VisualDomUtil.getBounds(element);
+ //bounds = VisualDomUtil.getBounds(element);
+ bounds = XulRunnerVpeUtils.getElementBounds(element);
}
return bounds;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-10-15 17:58:55 UTC (rev 18116)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-10-15 22:51:53 UTC (rev 18117)
@@ -14,11 +14,10 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.mozilla.interfaces.nsIAccessible;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
@@ -249,30 +248,32 @@
// return accessibilityService;
// }
- /**
- * Returns on screen bounds of the {@code node}
- *
- * @param node cannot be {@code null}
- * @return bounds of the {@code node} or {@code null} if it is not accessible
- *
- * @author yradtsevich
- */
- public static Rectangle getBounds(nsIDOMNode node) {
- Rectangle bounds = null;
-
- nsIAccessible accessible = (nsIAccessible) node.queryInterface(nsIAccessible.NS_IACCESSIBLE_IID);
- if (accessible != null) {
- int[] xArray = new int[1]; // Left hand corner of the node
- int[] yArray = new int[1]; // Top corner of the node
- int[] widthArray = new int[1]; // Width of the node
- int[] heightArray = new int[1]; // Height of the node
-
- accessible.getBounds(xArray, yArray, widthArray, heightArray);
- bounds = new Rectangle(xArray[0], yArray[0], widthArray[0], heightArray[0]);
- }
-
- return bounds;
- }
+// XULRunner 1.9 throws an error when we try to get nsIAccessible.
+// Use XulRunnerVpeUtils#getElementBounds(nsIDOMNode) instead.
+// /**
+// * Returns on screen bounds of the {@code node}
+// *
+// * @param node cannot be {@code null}
+// * @return bounds of the {@code node} or {@code null} if it is not accessible
+// *
+// * @author yradtsevich
+// */
+// public static Rectangle getBounds(nsIDOMNode node) {
+// Rectangle bounds = null;
+//
+// nsIAccessible accessible = (nsIAccessible) node.queryInterface(nsIAccessible.NS_IACCESSIBLE_IID);
+// if (accessible != null) {
+// int[] xArray = new int[1]; // Left hand corner of the node
+// int[] yArray = new int[1]; // Top corner of the node
+// int[] widthArray = new int[1]; // Width of the node
+// int[] heightArray = new int[1]; // Height of the node
+//
+// accessible.getBounds(xArray, yArray, widthArray, heightArray);
+// bounds = new Rectangle(xArray[0], yArray[0], widthArray[0], heightArray[0]);
+// }
+//
+// return bounds;
+// }
/**
* Creates HTML container (element) borders of that are
14 years, 8 months
JBoss Tools SVN: r18115 - in trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test: create and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-15 13:10:38 -0400 (Thu, 15 Oct 2009)
New Revision: 18115
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/SeamAllBotTests.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
Log:
Seam SWTBot tests correction.
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/SeamAllBotTests.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/SeamAllBotTests.java 2009-10-15 16:54:31 UTC (rev 18114)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/SeamAllBotTests.java 2009-10-15 17:10:38 UTC (rev 18115)
@@ -1,16 +1,11 @@
package org.jboss.tools.seam.ui.bot.test;
-import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.seam.ui.bot.test.create.CreateSeamRuntimes;
import org.jboss.tools.seam.ui.bot.test.create.CreateSeamProjects;
import org.jboss.tools.seam.ui.bot.test.create.CreateForms;
import org.jboss.tools.seam.ui.bot.test.create.CreateActions;
import org.jboss.tools.seam.ui.bot.test.create.CreateConversations;
import org.jboss.tools.seam.ui.bot.test.create.CreateEntities;
-import org.jboss.tools.seam.ui.bot.test.create.DeleteSeamProjects;
-import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
-
-import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-15 16:54:31 UTC (rev 18114)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-15 17:10:38 UTC (rev 18115)
@@ -3,16 +3,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matcher;
import org.jboss.tools.test.TestProperties;
import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -27,11 +21,11 @@
protected static Properties seam2fpSettings;
protected static Properties seam21Settings;
- private static String PROJECT_PROPERTIES = "projectProperties.properties";
- private static String EAP_RUNTIME = "jbossEAPRuntime.properties";
- private static String SEAM_SET_12 = "seam12Settings.properties";
- private static String SEAM_SET_2FP = "seam2fpSettings.properties";
- private static String SEAM_SET_21 = "seam21Settings.properties";
+ private static final String PROJECT_PROPERTIES = "projectProperties.properties";
+ private static final String EAP_RUNTIME = "jbossEAPRuntime.properties";
+ private static final String SEAM_SET_12 = "seam12Settings.properties";
+ private static final String SEAM_SET_2FP = "seam2fpSettings.properties";
+ private static final String SEAM_SET_21 = "seam21Settings.properties";
public static String JBOSS_EAP_HOME;
public static String SEAM_12_SETTINGS_HOME;
@@ -46,6 +40,9 @@
};
static {
+// System.setProperty("jbosstools.test.seam.1.2.1.eap.home", "C:/jbdevstudio0609/jboss-eap/seam");
+// System.setProperty("jbosstools.test.seam.2fp.eap.home", "C:/jbdevstudio0609/jboss-eap/seamfp");
+// System.setProperty("jbosstools.test.seam.2.1.0.GA.home", "C:/jbdevstudio0609/jboss-eap/jboss-seam-2.1.1.GA");
try {
InputStream is = TestControl.class.getResourceAsStream("/" + PROJECT_PROPERTIES);
projectProperties = new TestProperties();
@@ -96,14 +93,10 @@
catch (IllegalStateException e) {
fail("Property file " + SEAM_SET_21 + " was not found");
}
- JBOSS_EAP_HOME = System.getProperty("jbosstools.test.jboss.home",jbossEAPRuntime.getProperty("runtimePath"));
- SEAM_12_SETTINGS_HOME = System.getProperty("jbosstools.test.seam.1.2.1.eap.home",seam12Settings.getProperty("seamRuntimePath"));
-
- //Property SEAM_21_SETTINGS_HOME should be deleted or commented. There is no such property on hudson
- SEAM_21_SETTINGS_HOME = System.getProperty("jbosstools.test.seam.home.2.1",seam21Settings.getProperty("seamRuntimePath"));
-
-
- SEAM_2FP_SETTINGS_HOME = System.getProperty("jbosstools.test.seam.2.0.1.GA.home",seam2fpSettings.getProperty("seamRuntimePath"));
+ JBOSS_EAP_HOME = jbossEAPRuntime.getProperty("runtimePath");
+ SEAM_12_SETTINGS_HOME = seam12Settings.getProperty("seamRuntimePath");
+ SEAM_21_SETTINGS_HOME = seam21Settings.getProperty("seamRuntimePath");
+ SEAM_2FP_SETTINGS_HOME = seam2fpSettings.getProperty("seamRuntimePath");
}
@@ -118,19 +111,6 @@
}
}
- private static void substituteSystemProperties(Properties projectProperties2) {
- for (Object opject : projectProperties2.keySet()) {
- String propertyValue = projectProperties2.get(opject).toString();
- if(propertyValue.matches("\\$\\{.*")) {
- for (String substitute : SUBSTITUTE_PROPERTIES) {
- String regexp = "\\$\\{" + substitute + "}";
- if(propertyValue.matches(regexp)) {
- projectProperties2.put(opject, propertyValue.replaceAll(regexp, System.getProperty(substitute)));
- }
- }
- }
- }
- }
/*protected void setUp() throws Exception {
super.setUp();
@@ -196,7 +176,6 @@
bot.radio(type).click();
bot.comboBoxWithLabel("Connection profile:").setSelection(projectProperties.getProperty("connName"));
bot.button("Finish").click();
- bot.waitUntil(Conditions.shellCloses(bot.activeShell()),30000);
}
/**Creates any Seam Action, Form etc. */
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-15 16:54:31 UTC (rev 18114)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-15 17:10:38 UTC (rev 18115)
@@ -6,31 +6,47 @@
public void testCreateSeamProject12war(){
createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_WAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS);
}
-/* public void testCreateSeamProject12ear(){
- createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_EAR);
- waitForJobs();
- }
+// public void testCreateSeamProject12ear(){
+// createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_EAR);
+// try {
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// } catch (InterruptedException e) {
+// }
+// }
+//
+// public void testCreateSeamProject2fpwar(){
+// createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_WAR);
+// try {
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// } catch (InterruptedException e) {
+// }
+// }
+//
+// public void testCreateSeamProject2fpear(){
+// createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_EAR);
+// try {
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// } catch (InterruptedException e) {
+// }
+// }
+//
+// public void testCreateSeamProject21war(){
+// createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_WAR);
+// try {
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// } catch (InterruptedException e) {
+// }
+// }
+//
+// public void testCreateSeamProject21ear(){
+// createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_EAR);
+// try {
+// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+// } catch (InterruptedException e) {
+// }
+// }
- public void testCreateSeamProject2fpwar(){
- createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_WAR);
- waitForJobs();
- }
-
- public void testCreateSeamProject2fpear(){
- createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_EAR);
- waitForJobs();
- }
-
- public void testCreateSeamProject21war(){
- createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_WAR);
- waitForJobs();
- }
-
- public void testCreateSeamProject21ear(){
- createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_EAR);
- waitForJobs();
- }*/
-
}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r18114 - trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/editor/menu.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-10-15 12:54:31 -0400 (Thu, 15 Oct 2009)
New Revision: 18114
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/editor/menu/VpePopupMenuTest.java
Log:
JUnit test for the VPE pop-up menu has been fixed.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/editor/menu/VpePopupMenuTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/editor/menu/VpePopupMenuTest.java 2009-10-15 15:36:36 UTC (rev 18113)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/editor/menu/VpePopupMenuTest.java 2009-10-15 16:54:31 UTC (rev 18114)
@@ -10,13 +10,18 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.menu;
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
@@ -25,12 +30,32 @@
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
import org.jboss.tools.vpe.ui.test.VpeUiTests;
import org.w3c.dom.Node;
+/**
+ * Performs tests for the VPE pop-up menu.
+ *
+ * @author dmaliarevich
+ * @author yradtsevich
+ */
public class VpePopupMenuTest extends VpeTest {
+ private static final String[] REQUIRED_MENU_ITEMS = {
+ MessageFormat.format(
+ VpeUIMessages.ATTRIBUTES_MENU_ITEM, "h:outputText"),
+ MessageFormat.format(
+ VpeUIMessages.PARENT_TAG_MENU_ITEM, "h3"),
+ VpeUIMessages.INSERT_AROUND,
+ VpeUIMessages.INSERT_BEFORE,
+ VpeUIMessages.INSERT_AFTER,
+ VpeUIMessages.INSERT_INTO,
+ VpeUIMessages.REPLACE_WITH,
+ VpeUIMessages.STRIP_TAG_MENU_ITEM
+ };
+ private static final Point CODE_POINT = new Point(14, 25);
private final String INITIALIZATION_FAILED = "Initialization failed!"; //$NON-NLS-1$
private final String FILE_NAME = "hello.jsp"; //$NON-NLS-1$
@@ -62,16 +87,22 @@
MozillaEditor visualEditor = vep.getVisualEditor();
StructuredTextEditor sourceEditor = vc. getSourceEditor();
- /*
- * Selecting h:outputText tag for popup menu.
- */
- int position = TestUtil.getLinePositionOffcet(sourceEditor.getTextViewer(), 14, 25);
+ // Selecting h:outputText tag for popup menu.
+ int position = TestUtil.getLinePositionOffcet(
+ sourceEditor.getTextViewer(), CODE_POINT.x, CODE_POINT.y);
Node sourceNode = SelectionUtil.getNodeBySourcePosition(sourceEditor, position);
- /*
- * Creating popup menu.
- */
+
+ // Creating popup menu.
MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
final Menu contextMenu = menuManager.createContextMenu(visualEditor.getControl());
+
+ VpeMenuCreator menuCreator = new VpeMenuCreator(menuManager, sourceNode);
+ assertEquals("Menu Manger should have no items before creation.", //$NON-NLS-1$
+ 0, menuManager.getSize());
+ menuCreator.createMenu();
+
+
+
contextMenu.addMenuListener(new MenuListener() {
Menu menu = contextMenu;
public void menuHidden(MenuEvent e) {
@@ -82,40 +113,33 @@
});
}
public void menuShown(MenuEvent e) {
- /*
- * Close popup menu after it is displayed.
- */
- menu.setVisible(false);
+ try {
+ // Check pop-up menu items menu after it is displayed.
+ Set<String> menuItemNames = new HashSet<String>();
+ for (MenuItem item : contextMenu.getItems()) {
+ menuItemNames.add(item.getText());
+ }
+
+ for (String itemName : REQUIRED_MENU_ITEMS) {
+ assertTrue("There is no '" + itemName //$NON-NLS-1$
+ + "' item in the pop-up menu." //$NON-NLS-1$
+ , menuItemNames.contains(itemName));
+ }
+ } finally {
+ // close pop-up menu
+ menu.setVisible(false);
+ }
}
});
- VpeMenuCreator menuCreator = new VpeMenuCreator(menuManager, sourceNode);
- assertNotNull(INITIALIZATION_FAILED, menuCreator);
- assertEquals("Menu Manger should have no items before initialization.", //$NON-NLS-1$
- 0, menuManager.getSize());
- menuCreator.createMenu();
- assertEquals(
- "After menu creation the Menu Manger should have 13 items in it.", //$NON-NLS-1$
- 13, menuManager.getSize());
/*
- * Searching InsertContributionItem among menu manger items.
- */
- IContributionItem[] menuItems = menuManager.getItems();
- InsertContributionItem insertItem = null;
- for (IContributionItem item : menuItems) {
- if (item instanceof InsertContributionItem) {
- insertItem = (InsertContributionItem) item;
- }
- }
- assertNotNull(
- "InsertContributionItem should exist in the list of menu items but it is not.", //$NON-NLS-1$
- insertItem);
- /*
* Show context menu on the display.
* Menu will be filled in with items and drew on the screen.
* If there are any exceptions - they'll be thrown.
* After displaying the menu will be automatically hidden.
*/
contextMenu.setVisible(true);
+// TestUtil.waitForJobs();
+// TestUtil.delay(5000);
/*
* It is possible to send synthetic mouse and key events in XULRunner 1.9.
@@ -134,5 +158,4 @@
// assertNotNull(INITIALIZATION_FAILED, utils);
// utils.sendMouseEvent("mousedown", 10, 10, 0, 1, 0);
}
-
}
14 years, 8 months
JBoss Tools SVN: r18113 - in trunk: jst/plugins/org.jboss.tools.jst.jsp and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-10-15 11:36:36 -0400 (Thu, 15 Oct 2009)
New Revision: 18113
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/KBProblemMarkerResolutionGenerator.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/actions/
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4978
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -75,9 +75,12 @@
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.preferences.JSFSeverityPreferences;
+import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.internal.KbProject;
import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatingProjectSet;
import org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager;
import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
import org.jboss.tools.jst.web.kb.validation.ELReference;
@@ -93,6 +96,8 @@
*/
public class ELValidator extends ValidationErrorManager implements IValidator {
+ public static final String ID = "org.jboss.tools.jsf.ELValidator";
+
protected static final String UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID = "UNKNOWN_EL_VARIABLE_NAME"; //$NON-NLS-1$
protected static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID = "UNKNOWN_EL_VARIABLE_PROPERTY_NAME"; //$NON-NLS-1$
protected static final String UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID = "UNPAIRED_GETTER_OR_SETTER"; //$NON-NLS-1$
@@ -529,30 +534,48 @@
return names;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#getPreference(org.eclipse.core.resources.IProject, java.lang.String)
+ */
@Override
protected String getPreference(IProject project, String preferenceKey) {
- // TODO
- return null;
+ return JSFSeverityPreferences.getInstance().getProjectPreference(project, preferenceKey);
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#getId()
+ */
public String getId() {
- // TODO
- return null;
+ return ID;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#getValidatingProjects(org.eclipse.core.resources.IProject)
+ */
public IValidatingProjectSet getValidatingProjects(IProject project) {
List<IProject> projects = new ArrayList<IProject>();
projects.add(project);
IKbProject kbProject = KbProjectFactory.getKbProject(project, false);
if(kbProject!=null) {
- // IValidationContext context = kbProject.getValidationContext();
-
+ IValidationContext rootContext = null; // kbProject.getValidationContext();
+ return new ValidatingProjectSet(project, projects, rootContext);
}
return null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#shouldValidate(org.eclipse.core.resources.IProject)
+ */
public boolean shouldValidate(IProject project) {
- // TODO
+ try {
+ return project.hasNature(JSFNature.NATURE_ID) && KbProject.checkKBBuilderInstalled(project);
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
return false;
}
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-15 15:36:36 UTC (rev 18113)
@@ -8,7 +8,6 @@
Bundle-Localization: plugin
Export-Package: org.jboss.tools.jst.jsp,
org.jboss.tools.jst.jsp.contentassist,
- org.jboss.tools.jst.jsp.contentassist.actions,
org.jboss.tools.jst.jsp.contentassist.xpl,
org.jboss.tools.jst.jsp.drop.treeviewer.model,
org.jboss.tools.jst.jsp.drop.treeviewer.ui,
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2009-10-15 15:36:36 UTC (rev 18113)
@@ -8,6 +8,4 @@
occurrenceStructureProvidersExtensionPoint= Occurrence Structure Providers
defaultOccurrenceStructureProviderName= Default Occurrence Provider
-Bundle-Name.0 = Jsp Editor Plug-in
-
-KBProblemName=KB Problem
\ No newline at end of file
+Bundle-Name.0 = Jsp Editor Plug-in
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-10-15 15:36:36 UTC (rev 18113)
@@ -575,25 +575,8 @@
</key>
</extension>
- <extension id="kbproblemmarker" name="%KBProblemName" point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.core.resources.problemmarker">
- </super>
- <persistent value="true">
- </persistent>
-
- </extension>
-
- <extension point="org.eclipse.ui.ide.markerResolution">
- <markerResolutionGenerator
- markerType="org.jboss.tools.jst.jsp.kbproblemmarker"
- class="org.jboss.tools.jst.jsp.contentassist.actions.KBProblemMarkerResolutionGenerator">
- </markerResolutionGenerator>
- </extension>
-
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.jboss.tools.jst.jsp.preferences.VpePreferencesInitializer"/>
</extension>
-
-
-</plugin>
+</plugin>
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -10,18 +10,12 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
@@ -58,13 +52,9 @@
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-import org.jboss.tools.jst.web.kb.IKbProject;
-import org.jboss.tools.jst.web.kb.KbProjectFactory;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.KbBuilder;
+import org.jboss.tools.jst.web.kb.internal.KbProject;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -93,119 +83,12 @@
this.fDocument = (viewer == null ? null : viewer.getDocument());
this.fDocumentPosition = offset;
this.fContext = createContext();
-
- checkKBBuilderInstalled();
+
+ IFile resource = fContext == null ? null : fContext.getResource();
+ KbProject.checkKBBuilderInstalled(resource);
return super.computeCompletionProposals(viewer, offset);
}
-
- private void checkKBBuilderInstalled() {
- ELContext context = getContext();
- IFile resource = context == null ? null : context.getResource();
- IProject project = resource == null ? null : resource.getProject();
- if (project == null)
- return; // Cannot check anything
-
- boolean kbNatureFound = false;
- boolean kbBuilderFound = false;
- try {
- kbNatureFound = (project.getNature(IKbProject.NATURE_ID) != null);
-
- IProjectDescription description = project.getDescription();
- ICommand command = null;
- ICommand commands[] = description.getBuildSpec();
- for (int i = 0; i < commands.length && command == null; ++i) {
- if (commands[i].getBuilderName().equals(KbBuilder.BUILDER_ID)) {
- kbBuilderFound = true;
- break;
- }
- }
- } catch (CoreException ex) {
- JspEditorPlugin.getPluginLog().logError(ex);
- }
-
- if (kbNatureFound && kbBuilderFound) {
- // Find existing KBNATURE problem marker and kill it if exists
- IMarker[] markers = getOwnedMarkers(project);
- if (markers != null && markers.length > 0) {
- for (IMarker m : markers) {
- try {
- project.deleteMarkers(KB_PROBLEM_MARKER_TYPE, true, IResource.DEPTH_ONE);
- project.setPersistentProperty(KbProjectFactory.NATURE_MOCK, null);
- } catch (CoreException ex) {
- JspEditorPlugin.getPluginLog().logError(ex);
- }
- }
- }
- return;
- }
-
- // Find existing KBNATURE problem marker and install it if doesn't exist
- IMarker[] markers = getOwnedMarkers(project);
-
- if (markers == null || markers.length == 0) {
- try {
- IMarker m = createOrUpdateKbProblemMarker(null, project, !kbNatureFound, !kbBuilderFound);
- } catch (CoreException ex) {
- JspEditorPlugin.getPluginLog().logError(ex);
- }
- } else {
- for (IMarker m : markers) {
- try {
- m = createOrUpdateKbProblemMarker(m, project, !kbNatureFound, !kbBuilderFound);
- } catch (CoreException ex) {
- JspEditorPlugin.getPluginLog().logError(ex);
- }
- }
- }
- return;
-
- }
-
- public static final String KB_PROBLEM_MARKER_TYPE = "org.jboss.tools.jst.jsp.kbproblemmarker"; //$NON-NLS-1$
-
- private IMarker createOrUpdateKbProblemMarker(IMarker m, IResource r, boolean kbNatureIsAbsent, boolean kbBuilderIsAbsent) throws CoreException {
- ArrayList<String> args = new ArrayList<String>();
- args.add(kbNatureIsAbsent ? JstUIMessages.KBNATURE_NOT_FOUND : ""); //$NON-NLS-1$
- args.add(kbBuilderIsAbsent ? JstUIMessages.KBBUILDER_NOT_FOUND : ""); //$NON-NLS-1$
-
- String message = MessageFormat.format(JstUIMessages.KBPROBLEM, args.toArray());
- if (m == null) {
- m = r.createMarker(KB_PROBLEM_MARKER_TYPE);
- r.setPersistentProperty(KbProjectFactory.NATURE_MOCK, "true");
- KbProjectFactory.getKbProject(r.getProject(), true);
- }
- m.setAttribute(IMarker.MESSAGE, message);
- m.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
- m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
- return m;
- }
-
- private IMarker[] getOwnedMarkers(IResource r) {
- ArrayList<IMarker> l = null;
- try {
- IMarker[] ms = r.findMarkers(null, false, 1);
- if(ms != null) {
- for (int i = 0; i < ms.length; i++) {
- if(ms[i] == null) continue;
-
- String _type = ms[i].getType();
- if(_type == null) continue;
- if(!_type.equals(KB_PROBLEM_MARKER_TYPE)) continue;
- if(!ms[i].isSubtypeOf(IMarker.PROBLEM)) continue;
-
- if(l == null)
- l = new ArrayList<IMarker>();
-
- l.add(ms[i]);
- }
- }
- } catch (CoreException e) {
- //ignore
- }
- return (l == null) ? null : l.toArray(new IMarker[0]);
- }
-
/**
* The reason of overriding is that the method returns wrong region in case of incomplete tag (a tag with no '>'-closing char)
* In this case we have to return that previous incomplete tag instead of the current tag)
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -115,8 +115,4 @@
public static String JSPDialogContentProposalProvider_NewELExpression;
public static String PROPERTY_NAME_COLUMN;
public static String PROPERTY_VALUE_COLUMN;
- public static String KBNATURE_NOT_FOUND;
- public static String KBBUILDER_NOT_FOUND;
- public static String KBPROBLEM;
- public static String ENABLE_KB;
-}
+}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-10-15 15:36:36 UTC (rev 18113)
@@ -91,9 +91,4 @@
JSPDialogContentProposalProvider_NewELExpression=New EL Expression
PROPERTY_NAME_COLUMN=Attribute
-PROPERTY_VALUE_COLUMN=Value
-
-KBNATURE_NOT_FOUND=KB Nature is not installed.
-KBBUILDER_NOT_FOUND=KB Builder is not installed.
-KBPROBLEM=KB Problem: {0} {1} Use Quick Fix to allow JSF Content Assistant.
-ENABLE_KB=Enable JSF CA on this project
+PROPERTY_VALUE_COLUMN=Value
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-15 15:36:36 UTC (rev 18113)
@@ -12,14 +12,16 @@
org.jboss.tools.common.el.core,
org.eclipse.jface.text,
org.eclipse.wst.sse.core,
- org.eclipse.wst.xml.ui;bundle-version="1.1.0",
- org.eclipse.jdt.ui;bundle-version="3.5.0",
- org.eclipse.wst.validation;bundle-version="1.2.102",
- org.eclipse.ui.editors;bundle-version="3.5.0"
+ org.eclipse.wst.xml.ui,
+ org.eclipse.jdt.ui,
+ org.eclipse.wst.validation,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Export-Package: org.jboss.tools.jst.web.kb,
+ org.jboss.tools.jst.web.kb.action,
org.jboss.tools.jst.web.kb.el,
org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.internal.scanner,
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.properties 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.properties 2009-10-15 15:36:36 UTC (rev 18113)
@@ -1,4 +1,6 @@
providerName=JBoss by Red Hat
# START NON-TRANSLATABLE
Bundle-Name.0 = Web KB
-# END NON-TRANSLATABLE
\ No newline at end of file
+# END NON-TRANSLATABLE
+
+KBProblemName=KB Problem
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-15 15:36:36 UTC (rev 18113)
@@ -70,4 +70,17 @@
location="taglibs/componentExtension.xml"/>
</extension>
-</plugin>
+ <extension id="kbproblemmarker" name="%KBProblemName" point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <persistent value="true">
+ </persistent>
+ </extension>
+
+ <extension point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.jboss.tools.jst.web.kb.kbproblemmarker"
+ class="org.jboss.tools.jst.web.kb.action.KBProblemMarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+</plugin>
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -24,4 +24,8 @@
public static String VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL;
public static String VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL;
+ public static String KBNATURE_NOT_FOUND;
+ public static String KBBUILDER_NOT_FOUND;
+ public static String KBPROBLEM;
+ public static String ENABLE_KB;
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbMessages.properties 2009-10-15 15:36:36 UTC (rev 18113)
@@ -1,2 +1,7 @@
VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL=Linked resource path must not be null\!
-VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL=Variable name must not be null\!
\ No newline at end of file
+VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL=Variable name must not be null\!
+
+KBNATURE_NOT_FOUND=KB Nature is not installed.
+KBBUILDER_NOT_FOUND=KB Builder is not installed.
+KBPROBLEM=KB Problem: {0} {1} Use Quick Fix to allow JSF Content Assistant and Validation.
+ENABLE_KB=Enable JSF CA and validation on this project
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.kb.action;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IMarkerResolution;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbMessages;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.internal.KbProject;
+
+/**
+ * The Marker Resolution that enables the KB Nature on the project
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public class EnableKBOnProject implements IMarkerResolution{
+
+ public String getLabel() {
+ return KbMessages.ENABLE_KB;
+ }
+
+ public void run(IMarker marker) {
+ IResource resource = marker.getResource();
+ IProject project = resource instanceof IProject ? (IProject)resource :
+ resource != null ? resource.getProject() : null;
+
+ if (project == null)
+ return;
+
+ try {
+ EclipseResourceUtil.addNatureToProject(project, IKbProject.NATURE_ID);
+ // Find existing KBNATURE problem marker and kill it if exists
+ project.deleteMarkers(KbProject.KB_PROBLEM_MARKER_TYPE, true, IResource.DEPTH_ONE);
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/KBProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/KBProblemMarkerResolutionGenerator.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/KBProblemMarkerResolutionGenerator.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.kb.action;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator;
+
+/**
+ * Shows the Marker Resolutions for KB Problem Marker
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public class KBProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator {
+ public IMarkerResolution[] getResolutions(IMarker marker) {
+ return new IMarkerResolution[] {
+ new EnableKBOnProject()
+ };
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/KBProblemMarkerResolutionGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-10-15 15:08:25 UTC (rev 18112)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-10-15 15:36:36 UTC (rev 18113)
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -24,6 +25,7 @@
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -37,6 +39,7 @@
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jst.web.WebModelPlugin;
import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbMessages;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.internal.scanner.ClassPathMonitor;
@@ -848,4 +851,111 @@
}
}
+ /**
+ * Check if KB builder is installed and add a warning with quick fix to the project if it is not.
+ * @param resource
+ */
+ public static boolean checkKBBuilderInstalled(IResource resource) {
+ IProject project = resource == null ? null : resource.getProject();
+ if (project == null)
+ return false; // Cannot check anything
+
+ boolean kbNatureFound = false;
+ boolean kbBuilderFound = false;
+ try {
+ kbNatureFound = (project.getNature(IKbProject.NATURE_ID) != null);
+
+ IProjectDescription description = project.getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(KbBuilder.BUILDER_ID)) {
+ kbBuilderFound = true;
+ break;
+ }
+ }
+ } catch (CoreException ex) {
+ WebKbPlugin.getDefault().logError(ex);
+ }
+
+ if (kbNatureFound && kbBuilderFound) {
+ // Find existing KBNATURE problem marker and kill it if exists
+ IMarker[] markers = getOwnedMarkers(project);
+ if (markers != null && markers.length > 0) {
+ for (IMarker m : markers) {
+ try {
+ project.deleteMarkers(KB_PROBLEM_MARKER_TYPE, true, IResource.DEPTH_ONE);
+ project.setPersistentProperty(KbProjectFactory.NATURE_MOCK, null);
+ } catch (CoreException ex) {
+ WebKbPlugin.getDefault().logError(ex);
+ }
+ }
+ }
+ return true;
+ }
+
+ // Find existing KBNATURE problem marker and install it if doesn't exist
+ IMarker[] markers = getOwnedMarkers(project);
+
+ if (markers == null || markers.length == 0) {
+ try {
+ IMarker m = createOrUpdateKbProblemMarker(null, project, !kbNatureFound, !kbBuilderFound);
+ } catch (CoreException ex) {
+ WebKbPlugin.getDefault().logError(ex);
+ }
+ } else {
+ for (IMarker m : markers) {
+ try {
+ m = createOrUpdateKbProblemMarker(m, project, !kbNatureFound, !kbBuilderFound);
+ } catch (CoreException ex) {
+ WebKbPlugin.getDefault().logError(ex);
+ }
+ }
+ }
+ return false;
+ }
+
+ public static final String KB_PROBLEM_MARKER_TYPE = "org.jboss.tools.jst.web.kb.kbproblemmarker"; //$NON-NLS-1$
+
+ private static IMarker[] getOwnedMarkers(IResource r) {
+ ArrayList<IMarker> l = null;
+ try {
+ IMarker[] ms = r.findMarkers(null, false, 1);
+ if(ms != null) {
+ for (int i = 0; i < ms.length; i++) {
+ if(ms[i] == null) continue;
+
+ String _type = ms[i].getType();
+ if(_type == null) continue;
+ if(!_type.equals(KB_PROBLEM_MARKER_TYPE)) continue;
+ if(!ms[i].isSubtypeOf(IMarker.PROBLEM)) continue;
+
+ if(l == null)
+ l = new ArrayList<IMarker>();
+
+ l.add(ms[i]);
+ }
+ }
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ return (l == null) ? null : l.toArray(new IMarker[0]);
+ }
+
+ private static IMarker createOrUpdateKbProblemMarker(IMarker m, IResource r, boolean kbNatureIsAbsent, boolean kbBuilderIsAbsent) throws CoreException {
+ ArrayList<String> args = new ArrayList<String>();
+ args.add(kbNatureIsAbsent ? KbMessages.KBNATURE_NOT_FOUND : ""); //$NON-NLS-1$
+ args.add(kbBuilderIsAbsent ? KbMessages.KBBUILDER_NOT_FOUND : ""); //$NON-NLS-1$
+
+ String message = MessageFormat.format(KbMessages.KBPROBLEM, args.toArray());
+ if (m == null) {
+ m = r.createMarker(KB_PROBLEM_MARKER_TYPE);
+ r.setPersistentProperty(KbProjectFactory.NATURE_MOCK, "true"); //$NON-NLS-1$
+ KbProjectFactory.getKbProject(r.getProject(), true);
+ }
+ m.setAttribute(IMarker.MESSAGE, message);
+ m.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
+ return m;
+ }
}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r18112 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/2550.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-10-15 11:08:25 -0400 (Thu, 15 Oct 2009)
New Revision: 18112
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/2550/jbide2550.xhtml.xml
Log:
Fixing junits.
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/2550/jbide2550.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/2550/jbide2550.xhtml.xml 2009-10-15 14:59:43 UTC (rev 18111)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/2550/jbide2550.xhtml.xml 2009-10-15 15:08:25 UTC (rev 18112)
@@ -97,7 +97,7 @@
</LABEL>
</TD>
<TD>
-<IMG SRC="/.*jsf2test/WebContent/resources/us/img/img.gif/" STYLE="-moz-user-modify: read-write;"/>
+<IMG SRC="/.*jsf2test.WebContent.resources.us.img.img.gif/" STYLE="-moz-user-modify: read-write;"/>
</TD>
</TR>
@@ -108,7 +108,7 @@
</LABEL>
</TD>
<TD>
-<IMG SRC="/.*metadata/.plugins/org.jboss.tools.vpe/img.*.gif/" STYLE="-moz-user-modify: read-write;"/>
+<IMG SRC="/.*metadata..plugins.org.jboss.tools.vpe.img.*.gif/" STYLE="-moz-user-modify: read-write;"/>
</TD>
</TR>
14 years, 8 months
JBoss Tools SVN: r18111 - trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-10-15 10:59:43 -0400 (Thu, 15 Oct 2009)
New Revision: 18111
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/SiteDialog.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5023 Project Examples import a local copy of the settings file does not work.
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/SiteDialog.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/SiteDialog.java 2009-10-15 14:04:22 UTC (rev 18110)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/SiteDialog.java 2009-10-15 14:59:43 UTC (rev 18111)
@@ -1,5 +1,6 @@
package org.jboss.tools.project.examples.preferences;
+import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
@@ -128,8 +129,6 @@
browse.addSelectionListener(new SelectionListener(){
public void widgetSelected(SelectionEvent e) {
-
-
FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE);
dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$;
@@ -137,7 +136,12 @@
if (result == null || result.trim().length() == 0) {
return;
}
- urlText.setText("file:/" + result); //$NON-NLS-1$
+ try {
+ String urlString = new File(result).toURL().toString();
+ urlText.setText(urlString);
+ } catch (MalformedURLException e1) {
+ urlText.setText("file:///" + result); //$NON-NLS-1$
+ }
}
public void widgetDefaultSelected(SelectionEvent e) {
14 years, 8 months
JBoss Tools SVN: r18109 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2009-10-15 10:02:14 -0400 (Thu, 15 Oct 2009)
New Revision: 18109
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/WEB-INF/lib/jbide2550.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2550Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java
Log:
Jsf2.0 costom camponent support has been added to VPE, https://jira.jboss.org/jira/browse/JBIDE-5015
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jsf.vpe.jsf.template;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IStorage;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeCustomTemplate;
+import org.jboss.tools.vpe.editor.template.custom.CustomTLDReference;
+import org.jboss.tools.vpe.editor.util.XmlUtil;
+import org.w3c.dom.Node;
+
+/**
+ * Class implements support for custom jsf 2.0 components
+ *
+ * @author mareshkau
+ *
+ */
+public class Jsf2CustomComponentTemplate extends VpeCustomTemplate{
+
+ @Override
+ protected IStorage getCustomTemplateStorage(VpePageContext pageContext, Node sourceNode){
+ String sourcePrefix = sourceNode.getPrefix();
+
+ List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(sourceNode,pageContext);
+
+ TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourcePrefix, taglibs);
+
+ if(sourceNodeTaglib == null) {
+ return null;
+ }
+
+ String sourceNodeUri = sourceNodeTaglib.getUri();
+
+ return CustomTLDReference.getJsf2CustomComponentStorage(pageContext, sourceNodeUri, sourceNode.getLocalName());
+ }
+}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2009-10-15 14:02:14 UTC (rev 18109)
@@ -4,6 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<vpe:template-taglib uri="http://java.sun.com/jsf/html" prefix="h" />
<vpe:template-taglib uri="http://java.sun.com/jsf/core" prefix="f" />
+ <vpe:template-taglib uri="http://java.sun.com/jsf/composite" prefix="composite" />
<vpe:tag name="f:loadBundle" case-sensitive="yes">
<vpe:template children="no" modify="no">
@@ -178,7 +179,6 @@
</vpe:template>
</vpe:tag>
- <!-- Проблема с адресацией от приложения (30 of 4) -->
<vpe:tag name="h:commandButton" case-sensitive="yes">
<!-- This is a very big if-statement.
Its goal is to add support of 'disabled property'
@@ -905,9 +905,37 @@
</vpe:if>
</vpe:tag>
<!-- End of JSF 2.0 Tags -->
+
+ <!-- Jsf 2.0 composite tags -->
+ <vpe:tag name="composite:implementation" case-sensitive="yes">
+ <vpe:if test="tld_version('min=2.0')">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.facelets.template.VpeCompositionTemplate"
+ namespaceIdentifier="org.jboss.tools.jsf.vpe.facelets">
+ </vpe:template>
+ </vpe:if>
+ </vpe:tag>
+ <vpe:tag name="composite:interface" case-sensitive="yes">
+ <vpe:if test="tld_version('min=2.0')">
+ <vpe:template children="yes" modify="no"/>
+ </vpe:if>
+ </vpe:tag>
+
+ <vpe:tag name="composite:actionSource" case-sensitive="yes">
+ <vpe:if test="tld_version('min=2.0')">
+ <vpe:template children="no" modify="no"/>
+ </vpe:if>
+ </vpe:tag>
+
+ <vpe:tag name="vpejsf2customTemplate" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.jsf.template.Jsf2CustomComponentTemplate">
+ </vpe:template>
+ </vpe:tag>
<!-- Default template -->
<vpe:template children="yes" modify="no">
<vpe:any value="{name()}" title="{tagstring()}"/>
</vpe:template>
-</vpe:templates>
\ No newline at end of file
+
+</vpe:templates>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/WEB-INF/lib/jbide2550.jar
===================================================================
(Binary files differ)
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml 2009-10-15 14:02:14 UTC (rev 18109)
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"
+ xmlns:jar="http://java.sun.com/jsf/composite/jarPage">
+<h:head>
+ <title>A simple example of EZComp</title>
+</h:head>
+<h:body>
+ <h:form id="jbide5015">
+ <jar:echo echo="Hello, Custom Jsf 2.O Components" />
+ <ez:loginPanel id="loginPanel">
+ <f:actionListener for="loginEvent"
+ binding="#{bean.loginEventListener}" />
+ </ez:loginPanel>
+ </h:form>
+</h:body>
+</html>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml 2009-10-15 14:02:14 UTC (rev 18109)
@@ -0,0 +1,56 @@
+<tests>
+<test id="jbide5015">
+<FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;" >
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify: read-only;" >
+<DIV STYLE="-moz-user-modify: read-only;">
+<DIV STYLE="display: none; -moz-user-modify: read-only;">
+<H1 STYLE="-moz-user-modify: read-only;">
+Not present in rendered output
+</H1>
+</DIV>
+<DIV STYLE="-moz-user-modify: read-only;"><BR VPE:PSEUDO-ELEMENT="yes" STYLE="font-style: italic; color: green; -moz-user-modify: read-only;"/>
+
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify: read-only;">
+<H1 STYLE="-moz-user-modify: read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+Hello, Custom Jsf 2.O Components
+</SPAN>
+</H1>
+</DIV>
+</DIV>
+</DIV>
+</DIV>
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify: read-only;">
+<DIV STYLE="-moz-user-modify: read-only;">
+<DIV STYLE="display: none; -moz-user-modify: read-only;">
+<H1 STYLE="-moz-user-modify: read-only;">
+Not present in rendered output
+</H1>
+</DIV>
+<DIV STYLE="-moz-user-modify: read-only;">
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify: read-only;">
+<P STYLE="-moz-user-modify: read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+Username:
+</SPAN>
+<INPUT STYLE="-moz-user-modify: read-only;"/>
+
+</P>
+<P STYLE="-moz-user-modify: read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+Password:
+</SPAN>
+<INPUT TYPE="password" STYLE="-moz-user-modify: read-only;"/>
+
+</P>
+<P STYLE="-moz-user-modify: read-only;">
+<INPUT TYPE="button" VALUE="login" STYLE="-moz-user-modify: read-only;"/>
+
+</P>
+</DIV>
+</DIV>
+</DIV>
+</DIV>
+</FORM>
+</test>
+</tests>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2550Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2550Test.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2550Test.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -31,6 +31,9 @@
performContentTest("JBIDE/4954/inputUserName.jsp"); //$NON-NLS-1$
}
+ public void testForJSF2CustomTags() throws Throwable{
+ performContentTest("JBIDE/5015/login.xhtml"); //$NON-NLS-1$
+ }
@Override
protected String getTestProjectName() {
return JsfAllTests.IMPORT_JSF_20_PROJECT_NAME;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -45,9 +45,8 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- IStorage sourceFileStorage = CustomTLDReference
- .getCustomElementPath(sourceNode, pageContext);
-
+ IStorage sourceFileStorage = getCustomTemplateStorage(pageContext, sourceNode);
+
if (sourceFileStorage instanceof IFile) {
//add attributes to EL list
IFile file =(IFile) sourceFileStorage;
@@ -157,4 +156,14 @@
offset+=sourceNode.getPrefix().length()+1+1;
return new Region(offset, 0);
}
+ /**
+ * Culculate and returns storage to custom file
+ * @author mareshkau
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ protected IStorage getCustomTemplateStorage(VpePageContext pageContext, Node sourceNode){
+ return CustomTLDReference.getCustomElementStorage(sourceNode, pageContext);
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -270,6 +270,8 @@
//mareshkau, contains a name of custom template
private static final String CUSTOM_TEMPLATE_NAME="vpeCustomTemplate"; //$NON-NLS-1$
+ private static final String JSF2_CUSTOM_TEMPLATE="vpejsf2customTemplate"; //$NON-NLS-1$
+
/**
* added by Max Areshkau, JBIDE-1494
* Contains default text formating data
@@ -393,9 +395,14 @@
return templateTaglibPrefix + ":" + sourceNode.getLocalName(); //$NON-NLS-1$
}
- if(sourceNodeUri!=null && CustomTLDReference.isExistInCustomTlds(pageContext,sourceNodeUri)){
+ if(sourceNodeUri!=null
+ && CustomTLDReference.isExistInCustomTlds(pageContext,sourceNodeUri)) {
return VpeTemplateManager.CUSTOM_TEMPLATE_NAME;
}
+ if(sourceNodeUri!=null
+ &&CustomTLDReference.isExistInJsf2CustomComponenets(pageContext,sourceNodeUri,sourceNode.getLocalName()) ) {
+ return VpeTemplateManager.JSF2_CUSTOM_TEMPLATE;
+ }
return null;
default :
return null;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.custom;
-
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -28,7 +32,9 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.w3c.dom.Node;
@@ -40,6 +46,8 @@
*/
public class CustomTLDReference {
+ private static final String JSF2_CUSTOM_COMPONENT_URI = "http://java.sun.com/jsf/composite/"; //$NON-NLS-1$
+
/**
* Returns absolute path to custom template file, if such exist or null
* otherwise
@@ -47,17 +55,17 @@
* @param sourceNode
* @return full path to custom template if exist or null if not exist
*/
- public static IStorage getCustomElementPath(Node sourceNode,
+ public static IStorage getCustomElementStorage(Node sourceNode,
VpePageContext pageContext) {
List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(sourceNode,
pageContext);
TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourceNode
.getPrefix(), taglibs);
String uri = sourceNodeTaglib.getUri();
- XModelObject xmodel = getCustomTaglibObject(pageContext,uri);
+ XModelObject xmodel = getCustomTaglibObject(pageContext, uri);
XModelObject o = xmodel.getChildByPath(sourceNode.getLocalName()
- +XModelObjectConstants.SEPARATOR +"declaration"); //$NON-NLS-1$
+ + XModelObjectConstants.SEPARATOR + "declaration"); //$NON-NLS-1$
String sourceAttributeValue = null;
if (o != null) {
sourceAttributeValue = o.getAttributeValue("source"); //$NON-NLS-1$
@@ -68,14 +76,18 @@
}
if (xmodel instanceof SimpleFileImpl) {
IFile iFile = ((SimpleFileImpl) xmodel).getFile();
- if(iFile==null) {
- //possibly it's a jar file
+ if (iFile == null) {
+ // possibly it's a jar file
- XModelObject sourceFile = xmodel.getParent().getParent().getChildByPath(sourceAttributeValue.substring(1));
- if(sourceFile instanceof RecognizedFileImpl) {
- String content = ((RecognizedFileImpl)sourceFile).getAsText();
- String name =((RecognizedFileImpl)sourceFile).getPresentationString();
- IStorage customStorage = new VpeCustomStringStorage(content, name);
+ XModelObject sourceFile = xmodel.getParent().getParent()
+ .getChildByPath(sourceAttributeValue.substring(1));
+ if (sourceFile instanceof RecognizedFileImpl) {
+ String content = ((RecognizedFileImpl) sourceFile)
+ .getAsText();
+ String name = ((RecognizedFileImpl) sourceFile)
+ .getPresentationString();
+ IStorage customStorage = new VpeCustomStringStorage(
+ content, name);
return customStorage;
}
return null;
@@ -94,8 +106,104 @@
}
/**
+ * Checks is resource exist in custom jsf 2 tags
*
+ * @author mareshkau
* @param pageContext
+ * @param sourceNodeUri
+ * @param sourceNodeName
+ * @return
+ */
+
+ public static boolean isExistInJsf2CustomComponenets(
+ VpePageContext pageContext, String sourceNodeUri,
+ String sourceNodeName) {
+ boolean result = false;
+ // check uri if it jsf 2.0 URI
+ sourceNodeUri = sourceNodeUri.trim();
+ if (sourceNodeUri != null
+ && sourceNodeUri.startsWith(JSF2_CUSTOM_COMPONENT_URI)) {
+ // calculating resource path string
+ String jsfComponentResourcePath = sourceNodeUri.substring(
+ JSF2_CUSTOM_COMPONENT_URI.length(), sourceNodeUri.length());
+ String fileName = pageContext.getEditPart().getEditorInput()
+ .getName();
+ String jsfComponentExtension = ".xhtml"; //$NON-NLS-1$
+ if (fileName != null && fileName.lastIndexOf('.') != -1) {
+ String fileExtension = fileName.substring(fileName
+ .lastIndexOf('.'), fileName.length());
+ if (fileExtension != null && fileExtension.length() > 0) {
+ jsfComponentExtension = fileExtension;
+ }
+ jsfComponentResourcePath = jsfComponentResourcePath + '/'
+ + sourceNodeName + jsfComponentExtension;
+ result = FileUtil.isExistsInJSF2Resources(pageContext,
+ jsfComponentResourcePath);
+ }
+
+ }
+ return result;
+ }
+
+ public static IStorage getJsf2CustomComponentStorage(VpePageContext pageContext, String sourceNodeUri, String sourceNodeName){
+ IStorage result=null;
+ //check uri if it jsf 2.0 URI
+ sourceNodeUri = sourceNodeUri.trim();
+ if(sourceNodeUri!=null && sourceNodeUri.startsWith(JSF2_CUSTOM_COMPONENT_URI)) {
+ //calculating resource path string
+ String jsfComponentResourcePath = sourceNodeUri.substring(JSF2_CUSTOM_COMPONENT_URI.length(),sourceNodeUri.length());
+ String fileName = pageContext.getEditPart().getEditorInput().getName();
+ String jsfComponentExtension = ".xhtml"; //$NON-NLS-1$
+ if(fileName!=null && fileName.lastIndexOf('.')!=-1){
+ String fileExtension = fileName.substring(fileName.lastIndexOf('.'),fileName.length());
+ if(fileExtension!=null && fileExtension.length()>0) {
+ jsfComponentExtension = fileExtension;
+ }
+ jsfComponentResourcePath=jsfComponentResourcePath+'/'+sourceNodeName+jsfComponentExtension;
+ String fullResourcePath = FileUtil.processJSF2Resource(pageContext, jsfComponentResourcePath);
+ result = FileUtil.getFile(pageContext.getEditPart().getEditorInput(), fullResourcePath);
+ if(result!=null) {
+ return result;
+ }
+ File fileToOpen = new File(fullResourcePath);
+ if (fileToOpen.exists() && fileToOpen.isFile()) {
+ StringBuffer fileContent = new StringBuffer();
+ try {
+ BufferedReader input = new BufferedReader(new FileReader(fileToOpen));
+ try {
+ String line = null; //not declared within while loop
+ /*
+ * readLine is a bit quirky :
+ * it returns the content of a line MINUS the newline.
+ * it returns null only for the END of the stream.
+ * it returns an empty String if two newlines appear in a row.
+ */
+ while (( line = input.readLine()) != null){
+ fileContent.append(line);
+
+ }
+
+ } catch (IOException e) {
+ VpePlugin.reportProblem(e);
+ }finally {
+ input.close();
+ }
+
+ } catch (FileNotFoundException e) {
+ VpePlugin.reportProblem(e);
+ }catch (IOException e) {
+ VpePlugin.reportProblem(e);
+ }
+ result = new VpeCustomStringStorage(fileContent.toString(), fileToOpen.getName());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param pageContext
* @param uri
* node namespace uri
* @return true if such template defined in facelets lib or falce if not
@@ -103,7 +211,7 @@
*/
public static boolean isExistInCustomTlds(VpePageContext pageContext,
String uri) {
- return getCustomTaglibObject(pageContext,uri)!=null?true:false;
+ return getCustomTaglibObject(pageContext, uri) != null ? true : false;
}
/**
@@ -124,7 +232,8 @@
xm = mn.getModel();
}
if (xm != null) {
- return WebProject.getInstance(xm).getTaglibMapping().getTaglibObject(uri);
+ return WebProject.getInstance(xm).getTaglibMapping()
+ .getTaglibObject(uri);
}
}
return null;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -53,6 +53,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.w3c.dom.Node;
@@ -272,9 +273,9 @@
Matcher singleCoatMatcher = resourcePatternWithSinglCoat.matcher(resolvedValue);
Matcher doubleCoatMatcher = resourcePatternWithDoableCoat.matcher(resolvedValue);
if(doubleCoatMatcher.find()) {
- resolvedValue = processJSF2Resource(pageContext, doubleCoatMatcher);
+ resolvedValue = FileUtil.processJSF2Resource(pageContext, doubleCoatMatcher.group(1));
}else if(singleCoatMatcher.find()){
- resolvedValue = processJSF2Resource(pageContext, singleCoatMatcher);
+ resolvedValue = FileUtil.processJSF2Resource(pageContext, singleCoatMatcher.group(1));
}
//Fix for JBIDE-3030
@@ -287,85 +288,6 @@
resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
return resolvedValue;
}
- /**
- * See JBIDE-2550
- * @param matcher
- * @return
- */
- private static final String processJSF2Resource(VpePageContext pageContext, Matcher matcher){
- String resulString = matcher.group(1);
- resulString=resulString.replaceAll(":", "/"); //$NON-NLS-1$//$NON-NLS-2$
- resulString = "/resources/"+resulString; //$NON-NLS-1$
- // if file not accessible and try to search in jar files
- if(VpeCreatorUtil.getFile(resulString, pageContext)==null) {
- String tempEntryPath =seachResourceInClassPath(pageContext, "META-INF"+resulString); //$NON-NLS-1$
- if(tempEntryPath!=null) {
- resulString = tempEntryPath;
- }
- }
- return resulString;
- }
- /**
- * Function search into project class path resource, if resource founded in jar file, make a
- * temp copy of this resource and return path to copy.
- * @author mareshkau
- * @param pageContext
- * @param classPathResource
- * @return
- */
- private static String seachResourceInClassPath(VpePageContext pageContext, String classPathResource) {
- String result = null;
- final IFile currentFile = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
- final IProject project = currentFile.getProject();
- IJavaProject javaProject = JavaCore.create(project);
- try {
- for (IPackageFragmentRoot fragmentRoot : javaProject.getAllPackageFragmentRoots()) {
- if(fragmentRoot instanceof JarPackageFragmentRoot) {
- JarPackageFragmentRoot jarPackageFragmentRoot = (JarPackageFragmentRoot) fragmentRoot;
- ZipEntry zipEntry = jarPackageFragmentRoot.getJar().getEntry(classPathResource);
- if(zipEntry!=null){
- InputStream inputStream = jarPackageFragmentRoot.getJar().getInputStream(zipEntry);
- IPath stateLocation = VpePlugin.getDefault().getStateLocation();
-
- String fileName = null;
- String fileExtension = null;
- if(classPathResource.lastIndexOf(".")!=-1) { //$NON-NLS-1$ //added by mareshkau, fix for JBIDE-4954
- fileName = classPathResource.substring(classPathResource.lastIndexOf("/")+1,classPathResource.lastIndexOf(".")); //$NON-NLS-1$ //$NON-NLS-2$
- fileExtension = classPathResource.substring(classPathResource.lastIndexOf("."),classPathResource.length()); //$NON-NLS-1$
- }
- if(fileName!=null && fileName.length()>0
- && fileExtension!=null && fileExtension.length()>0) {
- File temporaryFile =File.createTempFile(
- fileName,
- fileExtension,
- new File(stateLocation.toOSString()));
- temporaryFile.deleteOnExit();
- OutputStream out = new FileOutputStream(temporaryFile,false);
- byte[] buf = new byte[1024];
- int len;
- while ((len = inputStream.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- inputStream.close();
- out.close();
- result = IMG_PREFIX + temporaryFile.getAbsolutePath();
- }
- }
- }
- }
- } catch (JavaModelException e) {
- VpePlugin.reportProblem(e);
- } catch (IllegalStateException e) {
- VpePlugin.reportProblem(e);
- } catch (FileNotFoundException e) {
- VpePlugin.reportProblem(e);
- } catch (CoreException e) {
- VpePlugin.reportProblem(e);
- } catch (IOException e) {
- VpePlugin.reportProblem(e);
- }
- return result;
- }
public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
String pluginPath = VpePlugin.getPluginResourcePath();
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java 2009-10-15 14:01:19 UTC (rev 18108)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java 2009-10-15 14:02:14 UTC (rev 18109)
@@ -11,14 +11,26 @@
package org.jboss.tools.vpe.editor.util;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;
@@ -34,12 +46,110 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
import org.jboss.tools.vpe.resref.core.AbsoluteFolderReferenceList;
import org.jboss.tools.vpe.resref.core.RelativeFolderReferenceList;
public class FileUtil {
+ private static final String JSF2_RESOURCES = "/resources/"; //$NON-NLS-1$
+ /**
+ * See JBIDE-2550
+ * @author mareshkau
+ * @param matcher
+ * @return
+ */
+ public static final String processJSF2Resource(VpePageContext pageContext, String resStr){
+ String resulString = resStr;
+ resulString=resulString.replaceAll(":", "/"); //$NON-NLS-1$//$NON-NLS-2$
+ resulString = "/resources/"+resulString; //$NON-NLS-1$
+ // if file not accessible and try to search in jar files
+ if(VpeCreatorUtil.getFile(resulString, pageContext)==null) {
+ String tempEntryPath =seachResourceInClassPath(pageContext, "META-INF"+resulString); //$NON-NLS-1$
+ if(tempEntryPath!=null) {
+ resulString = tempEntryPath;
+ }
+ }
+ return resulString;
+ }
+
+ public static boolean isExistsInJSF2Resources(VpePageContext pageContext, String resStr) {
+ String resourceString = resStr;
+ resourceString = resourceString.replaceAll(":", "/"); //$NON-NLS-1$//$NON-NLS-2$
+ resourceString = "/resources/"+resourceString; //$NON-NLS-1$
+ if(FileUtil.getFile(pageContext.getEditPart().getEditorInput(), resourceString)!=null ||
+ seachResourceInClassPath(pageContext, "META-INF"+resourceString)!=null) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Function search into project class path resource, if resource founded in jar file, make a
+ * temp copy of this resource and return path to copy.
+ * @author mareshkau
+ * @param pageContext
+ * @param classPathResource
+ * @return path to file
+ */
+ private static String seachResourceInClassPath(VpePageContext pageContext, String classPathResource) {
+ String result = null;
+ final IFile currentFile = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
+ final IProject project = currentFile.getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ for (IPackageFragmentRoot fragmentRoot : javaProject.getAllPackageFragmentRoots()) {
+ if(fragmentRoot instanceof JarPackageFragmentRoot) {
+ JarPackageFragmentRoot jarPackageFragmentRoot = (JarPackageFragmentRoot) fragmentRoot;
+ ZipEntry zipEntry = jarPackageFragmentRoot.getJar().getEntry(classPathResource);
+ if(zipEntry!=null){
+ InputStream inputStream = jarPackageFragmentRoot.getJar().getInputStream(zipEntry);
+ IPath stateLocation = VpePlugin.getDefault().getStateLocation();
+
+ String fileName = null;
+ String fileExtension = null;
+ if(classPathResource.lastIndexOf(".")!=-1) { //$NON-NLS-1$ //added by mareshkau, fix for JBIDE-4954
+ fileName = classPathResource.substring(classPathResource.lastIndexOf("/")+1,classPathResource.lastIndexOf(".")); //$NON-NLS-1$ //$NON-NLS-2$
+ fileExtension = classPathResource.substring(classPathResource.lastIndexOf("."),classPathResource.length()); //$NON-NLS-1$
+ }
+ if(fileName!=null && fileName.length()>0
+ && fileExtension!=null && fileExtension.length()>0) {
+ File temporaryFile =File.createTempFile(
+ fileName,
+ fileExtension,
+ new File(stateLocation.toOSString()));
+ temporaryFile.deleteOnExit();
+ OutputStream out = new FileOutputStream(temporaryFile,false);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = inputStream.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ inputStream.close();
+ out.close();
+ result = temporaryFile.getAbsolutePath();
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ VpePlugin.reportProblem(e);
+ } catch (IllegalStateException e) {
+ VpePlugin.reportProblem(e);
+ } catch (FileNotFoundException e) {
+ VpePlugin.reportProblem(e);
+ } catch (CoreException e) {
+ VpePlugin.reportProblem(e);
+ } catch (IOException e) {
+ VpePlugin.reportProblem(e);
+ }
+ return result;
+ }
+
+
+
public static IFile getFile(IEditorInput input, String value) {
IPath tagPath = new Path(value);
if (tagPath.isEmpty()) return null;
14 years, 8 months