JBoss Tools SVN: r4153 - in trunk/seam/tests/org.jboss.tools.seam.core.test: src/org/jboss/tools/seam/core/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-10-12 09:11:59 -0400 (Fri, 12 Oct 2007)
New Revision: 4153
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/lib/jboss-ejb3-all.jar
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/EXIN-13
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/lib/jboss-ejb3-all.jar
===================================================================
(Binary files differ)
Property changes on: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/lib/jboss-ejb3-all.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2007-10-12 12:19:52 UTC (rev 4152)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2007-10-12 13:11:59 UTC (rev 4153)
@@ -16,9 +16,12 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.internal.decorators.DecoratorManager;
+import org.eclipse.ui.progress.UIJob;
import org.jboss.tools.common.model.XJob;
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.seam.core.ISeamProject;
@@ -28,7 +31,7 @@
public class SeamValidatorsTest extends TestCase {
IProject project = null;
- boolean makeCopy = false;
+ boolean makeCopy = true;
public SeamValidatorsTest() {}
@@ -42,29 +45,12 @@
JUnitUtils.fail("Error in refreshing",e);
}
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
+ refreshProject(project);
}
private ISeamProject getSeamProject(IProject project) {
- try {
- XJob.waitForJob();
- } catch (Exception e) {
- JUnitUtils.fail("Interrupted",e);
- }
- try {
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
+ refreshProject(project);
+
ISeamProject seamProject = null;
try {
seamProject = (ISeamProject)project.getNature(SeamProject.NATURE_ID);
@@ -90,6 +76,15 @@
IFile statefulComponentFile = project.getFile("src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.java");
IFile componentsFile = project.getFile("WebContent/WEB-INF/components.xml");
+ int number = getMarkersNumber(bbcComponentFile);
+ assertTrue("Problem marker was found in BbcComponent.java file", number == 0);
+
+ number = getMarkersNumber(statefulComponentFile);
+ assertTrue("Problem marker was found in StatefulComponent.java file", number == 0);
+
+ number = getMarkersNumber(componentsFile);
+ assertTrue("Problem marker was found in components.xml file", number == 0);
+
// Duplicate component name
System.out.println("Test - Duplicate component name");
@@ -101,25 +96,13 @@
JUnitUtils.fail("Error in changing 'BbcComponent.java' content to " +
"'BbcComponent.2'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
- try{
- IMarker[] markers = bbcComponentFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
- }
- }catch(CoreException ex){
- JUnitUtils.fail("Error in getting problem markers", ex);
- }
+ refreshProject(project);
+
+ String message = getMarkersMessage(bbcComponentFile);
+
+ assertTrue("Problem marker 'Duplicate component name' not found","Duplicate component name: abcComponent".equals(message));
+
// Stateful component does not contain @Remove method
System.out.println("Test - Stateful component does not contain @Remove method");
@@ -131,25 +114,12 @@
JUnitUtils.fail("Error in changing 'StatefulComponent.java' content to " +
"'StatefulComponent.2'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
- try{
- IMarker[] markers = statefulComponentFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
- }
- }catch(CoreException ex){
- JUnitUtils.fail("Error in getting problem markers", ex);
- }
+ refreshProject(project);
+
+ message = getMarkersMessage(statefulComponentFile);
+ assertTrue("Problem marker 'Stateful component does not contain @Remove method' not found", "Stateful component \"statefulComponent\" must have a method marked @Remove".equals(message));
+
// Stateful component does not contain @Destroy method
System.out.println("Test - Stateful component does not contain @Destroy method");
@@ -161,25 +131,12 @@
JUnitUtils.fail("Error in changing 'StatefulComponent.java' content to " +
"'StatefulComponent.3'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
- try{
- IMarker[] markers = statefulComponentFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
- }
- }catch(CoreException ex){
- JUnitUtils.fail("Error in getting problem markers", ex);
- }
+ refreshProject(project);
+
+ message = getMarkersMessage(statefulComponentFile);
+ assertTrue("Problem marker 'Stateful component does not contain @Destroy method' not found", "Stateful component \"statefulComponent\" must have a method marked @Destroy".equals(message));
+
// Stateful component has wrong scope
System.out.println("Test - Stateful component has wrong scope");
@@ -191,29 +148,17 @@
JUnitUtils.fail("Error in changing 'StatefulComponent.java' content to " +
"'StatefulComponent.4'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
- try{
- IMarker[] markers = statefulComponentFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
- }
- }catch(CoreException ex){
- JUnitUtils.fail("Error in getting problem markers", ex);
- }
+ refreshProject(project);
+
+ message = getMarkersMessage(statefulComponentFile);
+ assertTrue("Problem marker 'Stateful component has wrong scope' not found", "Stateful component \"statefulComponent\" should not have org.jboss.seam.ScopeType.PAGE, nor org.jboss.seam.ScopeType.STATELESS".equals(message));
+
// Component class name cannot be resolved to a type
System.out.println("Test - Component class name cannot be resolved to a type");
IFile componentsFile2 = project.getFile("WebContent/WEB-INF/components.2");
+
try{
componentsFile.setContents(componentsFile2.getContents(), true, false, new NullProgressMonitor());
componentsFile.touch(new NullProgressMonitor());
@@ -221,29 +166,27 @@
JUnitUtils.fail("Error in changing 'components.xml' content to " +
"'components.2'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
- }
- try{
- IMarker[] markers = componentsFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
- }
- }catch(CoreException ex){
- JUnitUtils.fail("Error in getting problem markers", ex);
- }
+
+ refreshProject(project);
+
+ message = getMarkersMessage(componentsFile);
+ assertTrue("Problem marker 'Component class name cannot be resolved to a type' not found", "\"org.domain.SeamWebWarTestProject.session.StateComponent\" cannot be resolved to a type".equals(message));
// Component class does not contain setter for property
System.out.println("Test - Component class does not contain setter for property");
+ IFile componentsFile3 = project.getFile("WebContent/WEB-INF/components.3");
+
+ try{
+ componentsFile.setContents(componentsFile3.getContents(), true, false, new NullProgressMonitor());
+ componentsFile.touch(new NullProgressMonitor());
+ }catch(Exception ex){
+ JUnitUtils.fail("Error in changing 'components.xml' content to " +
+ "'components.3'", ex);
+ }
+
IFile statefulComponentFile5 = project.getFile("src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.5");
+
try{
statefulComponentFile.setContents(statefulComponentFile5.getContents(), true, false, new NullProgressMonitor());
statefulComponentFile.touch(new NullProgressMonitor());
@@ -251,25 +194,135 @@
JUnitUtils.fail("Error in changing 'StatefulComponent.java' content to " +
"'StatefulComponent.5'", ex);
}
- try {
- seamProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- JUnitUtils.fail("Cannot build", e);
+
+ refreshProject(project);
+
+ message = getMarkersMessage(componentsFile);
+ assertTrue("Problem marker 'Component class does not contain setter for property' not found", "Class \"StatefulComponent\" of component \"statefulComponent\" does not contain setter for property \"abc\"".equals(message));
+ }
+
+ public void testEntitiesValidator() {
+
+ }
+
+ public void testComponentLifeCycleMethodsValidator() {
+
+ }
+
+ public void testFactoriesValidator() {
+
+ }
+
+ public void testBijectionsValidator() {
+
+ }
+
+ public void testContextVariablesValidator() {
+
+ }
+
+ public void testExpressionLanguageValidator() {
+
+ }
+
+ private int getMarkersNumber(IFile file){
+ try{
+ IMarker[] markers = file.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ return markers.length;
+
+ }catch(CoreException ex){
+ JUnitUtils.fail("Error in getting problem markers", ex);
}
+ return -1;
+ }
+
+ private String getMarkersMessage(IFile file){
+ String message="";
try{
- IMarker[] markers = componentsFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ IMarker[] markers = file.findMarkers(null, true, IResource.DEPTH_INFINITE);
+
for(int i=0;i<markers.length;i++){
- System.out.println("Marker - "+markers[i].getAttribute(IMarker.TEXT, ""));
+ System.out.println("Marker - "+markers[i].getAttribute(IMarker.MESSAGE, ""));
+ message = markers[i].getAttribute(IMarker.MESSAGE, "");
}
}catch(CoreException ex){
JUnitUtils.fail("Error in getting problem markers", ex);
}
-
+ return message;
}
+
+ private void refreshProject(IProject project){
+ long timestamp = project.getModificationStamp();
+ int count = 1;
+ while(true){
+ System.out.println("Refresh project "+count);
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ try {
+ waitForJob();
+ } catch (InterruptedException e) {
+ JUnitUtils.fail(e.getMessage(),e);
+ }
+ } catch (Exception e) {
+ JUnitUtils.fail("Cannot build test Project", e);
+ break;
+ }
+ if(project.getModificationStamp() != timestamp) break;
+ count++;
+ if(count > 1) break;
+ }
+ }
+
+ public static void waitForJob() throws InterruptedException {
+ Object[] o = {
+ XJob.FAMILY_XJOB, ResourcesPlugin.FAMILY_AUTO_REFRESH, ResourcesPlugin.FAMILY_AUTO_BUILD
+ };
+ while(true) {
+ boolean stop = true;
+ for (int i = 0; i < o.length; i++) {
+ Job[] js = Job.getJobManager().find(o[i]);
+ if(js != null && js.length > 0) {
+ Job.getJobManager().join(o[i], new NullProgressMonitor());
+ stop = false;
+ }
+ }
+ if(stop) {
+ Job running = getJobRunning(10);
+ if(running != null) {
+ running.join();
+ stop = false;
+ }
+ }
+ if(stop) break;
+ }
+ }
+
+ public static Job getJobRunning(int iterationLimit) {
+ Job[] js = Job.getJobManager().find(null);
+ Job dm = null;
+ if(js != null) for (int i = 0; i < js.length; i++) {
+ if(js[i].getState() == Job.RUNNING && js[i].getThread() != Thread.currentThread()) {
+ if(js[i] instanceof UIJob) continue;
+ if(js[i].belongsTo(DecoratorManager.FAMILY_DECORATE) || js[i].getName().equals("Task List Saver")) {
+ dm = js[i];
+ continue;
+ }
+ //TODO keep watching
+ System.out.println(js[i].getName());
+ return js[i];
+ }
+ }
+ if(dm != null) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ //ignore
+ }
+ if(iterationLimit > 0)
+ return getJobRunning(iterationLimit - 1);
+ }
+ return null;
+
+ }
}
17 years, 3 months
JBoss Tools SVN: r4152 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: outline and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-10-12 08:19:52 -0400 (Fri, 12 Oct 2007)
New Revision: 4152
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/VpeProperties.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPTextJspKbConnector.java
Log:
JBIDE-525
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2007-10-12 12:18:04 UTC (rev 4151)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2007-10-12 12:19:52 UTC (rev 4152)
@@ -128,6 +128,17 @@
replacementBeginPosition, replacementLength, cursorPosition, SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
proposalsList.add(proposal);
+ } else {
+ StringBuffer replacementStringBuffer = new StringBuffer(kbProposal.getReplacementString());
+ int replacementBeginPosition = 0;
+ int replacementLength = text.length();
+ int cursorPositionDelta = 0;
+ String replacementString = replacementStringBuffer.toString();
+ int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
+ RedHatCustomCompletionProposal proposal = new RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(), replacementString,
+ replacementBeginPosition, replacementLength, cursorPosition, SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
+ kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
+ proposalsList.add(proposal);
}
}
} catch (KbException e) {
@@ -149,15 +160,8 @@
}
void updateFacelets() {
- VpeTaglibManager tldManager = valueHelper.getTaglibManager();
- if(tldManager == null) return;
- List list = tldManager.getTagLibs();
- if(list == null) return;
- isFacelets = false;
- for(int i = 0; i < list.size(); i++) {
- TaglibData data = (TaglibData)list.get(i);
- isFacelets = isFacelets || data.getUri().equals(RedHatHtmlContentAssistProcessor.faceletUri);
- }
+ valueHelper.updateFacelets();
+ isFacelets = valueHelper.isFacetets();
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2007-10-12 12:18:04 UTC (rev 4151)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2007-10-12 12:19:52 UTC (rev 4152)
@@ -21,6 +21,7 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
/**
@@ -57,7 +58,11 @@
if(button == null || button.isDisposed()) return;
String attributeName = "" + context.getProperty("attributeName");
String nodeName = "" + context.getProperty("nodeName");
- String query = "/" + nodeName + "@" + attributeName;
+ String query = "/";
+ if(valueHelper.isFacetets()) {
+ query += RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ }
+ query += nodeName + "@" + attributeName;
RootElement root = (RootElement)valueHelper.getInitalInput(query);
boolean enabled = root != null && root.getChildren().length > 0;
getButtonControl().setVisible(enabled);
@@ -67,7 +72,11 @@
externalEditing = true;
String attributeName = "" + context.getProperty("attributeName");
String nodeName = "" + context.getProperty("nodeName");
- String query = "/" + nodeName + "@" + attributeName;
+ String query = "/";
+ if(valueHelper != null && valueHelper.isFacetets()) {
+ query += RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ }
+ query += nodeName + "@" + attributeName;
context.setProperty("query", query);
context.setProperty("help", query);
context.setProperty("title", "Edit " + WizardKeys.toDisplayName(attributeName));
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2007-10-12 12:18:04 UTC (rev 4151)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2007-10-12 12:19:52 UTC (rev 4152)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.jsp.outline;
import java.util.*;
+
import org.eclipse.core.resources.*;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.jspeditor.*;
@@ -29,6 +30,7 @@
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
+import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResourceFactory;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.ModelElement;
@@ -40,6 +42,7 @@
import org.jboss.tools.common.kb.KbException;
import org.jboss.tools.common.kb.KbTldResource;
import org.jboss.tools.common.kb.TagDescriptor;
+import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -47,12 +50,14 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.jst.jsp.support.kb.WTPTextJspKbConnector;
+import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.TaglibMapping;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
public class ValueHelper {
private IEditorInput editorInput = null;
private WTPTextJspKbConnector wtpTextJspKbConnector = null;
+ private boolean isFacelets = false;
public static IPromptingProvider seamPromptingProvider;
@@ -94,6 +99,10 @@
editorInput = jspEditor.getEditorInput();
wtpTextJspKbConnector = jspEditor.getWTPTextJspKbConnector();
+
+ if(pageContext != null) {
+ updateFacelets();
+ }
return pageContext != null || pageConnector != null;
}
@@ -285,5 +294,28 @@
IWorkbenchWindow window = (workbench == null) ? null : workbench.getActiveWorkbenchWindow();
return (window == null) ? null : window.getActivePage();
}
+
+ public boolean isFacetets() {
+ return isFacelets;
+ }
+ public void updateFacelets() {
+ VpeTaglibManager tldManager = getTaglibManager();
+ if(tldManager == null) return;
+ List<TaglibData> list = tldManager.getTagLibs();
+ if(list == null) return;
+ isFacelets = false;
+ IDocument document = getDocument();
+ JspWtpKbConnector kbConnector = (JspWtpKbConnector)wtpTextJspKbConnector.getConnector();
+ kbConnector.unregisterAllResources(true);
+ for(int i = 0; i < list.size(); i++) {
+ TaglibData data = list.get(i);
+ RedHatHtmlContentAssistProcessor.registerTld(data, kbConnector, document, editorInput);
+ isFacelets = isFacelets || data.getUri().equals(RedHatHtmlContentAssistProcessor.faceletUri);
+ }
+ if(isFacelets) {
+ kbConnector.registerResource(RedHatHtmlContentAssistProcessor.faceletHtmlResource);
+ kbConnector.unregisterJspResource();
+ }
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/VpeProperties.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/VpeProperties.java 2007-10-12 12:18:04 UTC (rev 4151)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/VpeProperties.java 2007-10-12 12:19:52 UTC (rev 4152)
@@ -96,6 +96,10 @@
public String getNodeName() {
return node == null ? "" : node.getNodeName();
}
+
+ public Node getNode() {
+ return node;
+ }
public ExtendedCellEditorProvider createCellEditorProvider() {
return new ExtendedCellEditorProviderImpl();
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPTextJspKbConnector.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPTextJspKbConnector.java 2007-10-12 12:18:04 UTC (rev 4151)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPTextJspKbConnector.java 2007-10-12 12:19:52 UTC (rev 4152)
@@ -168,6 +168,10 @@
public boolean registerResource(KbResource resource) {
return kbConnector.registerResource(resource);
}
+
+ public KbConnector getConnector() {
+ return kbConnector;
+ }
/**
* @see org.jboss.tools.common.kb.KbConnector#unregisterResource(org.jboss.tools.common.kb.KbResource)
17 years, 3 months
JBoss Tools SVN: r4151 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-10-12 08:18:04 -0400 (Fri, 12 Oct 2007)
New Revision: 4151
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedProperties.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java
Log:
JBIDE-525
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedProperties.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedProperties.java 2007-10-12 12:03:36 UTC (rev 4150)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedProperties.java 2007-10-12 12:18:04 UTC (rev 4151)
@@ -10,11 +10,14 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.objecteditor;
+import org.w3c.dom.Node;
+
public interface ExtendedProperties {
public String[] getAttributes();
public String getAttributeValue(String name);
public void setAttributeValue(String name, String value);
public boolean isEditableAttribute(String name);
public String getNodeName();
+ public Node getNode();
public ExtendedCellEditorProvider createCellEditorProvider();
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java 2007-10-12 12:03:36 UTC (rev 4150)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java 2007-10-12 12:18:04 UTC (rev 4151)
@@ -43,6 +43,9 @@
if(attributes != null) {
context.setProperty("nodeName", "" + attributes.getNodeName());
cellEditorProvider = attributes.createCellEditorProvider();
+ if(attributes.getNode() != null) {
+ context.put("node", attributes.getNode());
+ }
}
if(xtable.getTable() == null || xtable.getTable().isDisposed()) return;
xtable.getTable().setSelection(-1);
17 years, 3 months
JBoss Tools SVN: r4150 - branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-12 08:03:36 -0400 (Fri, 12 Oct 2007)
New Revision: 4150
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1070
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-12 11:50:22 UTC (rev 4149)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-12 12:03:36 UTC (rev 4150)
@@ -41,19 +41,7 @@
*/
public VpePlugin() {
super();
-// final String VPE_PLUGIN_RESOURCE_BUNDLE_ID
-// = "org.jboss.tools.vpe.VpePluginResources";
plugin = this;
-// try {
-// resourceBundle
-// = ResourceBundle.getBundle(VPE_PLUGIN_RESOURCE_BUNDLE_ID);
-// } catch (MissingResourceException x) {
-// LogHelper.logError(VpePlugin.PLUGIN_ID,
-// "ResourceBundle " + VPE_PLUGIN_RESOURCE_BUNDLE_ID
-// + " is missing.",
-// x);
-// resourceBundle = null;
-// }
}
/**
@@ -77,28 +65,6 @@
return plugin;
}
-// /**
-// * Returns the string from the plugin's resource bundle,
-// * or 'key' if not found.
-// */
-// public static String getResourceString(String key) {
-// ResourceBundle bundle = VpePlugin.getDefault().getResourceBundle();
-// try {
-// return (bundle != null) ? bundle.getString(key) : key;
-// } catch (MissingResourceException e) {
-// VpePlugin.getPluginLog()
-// .logError("Resource " + key + " is missing.", e);
-// return key;
-// }
-// }
-
-// /**
-// * Returns the plugin's resource bundle,
-// */
-// public ResourceBundle getResourceBundle() {
-// return resourceBundle;
-// }
-
public static void reportProblem(Exception throwable) {
if (VpeDebug.USE_PRINT_STACK_TRACE) {
throwable.printStackTrace();
@@ -129,7 +95,6 @@
return getDefault();
}
- @Override
public void earlyStartup() {
/* init xulrunner path for */
try {
17 years, 3 months
JBoss Tools SVN: r4149 - branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-12 07:50:22 -0400 (Fri, 12 Oct 2007)
New Revision: 4149
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1070
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-10-12 11:50:17 UTC (rev 4148)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-10-12 11:50:22 UTC (rev 4149)
@@ -15,20 +15,17 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
-import java.util.Dictionary;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.XulRunnerException;
-import org.mozilla.interfaces.nsIBaseWindow;
import org.mozilla.interfaces.nsIComponentManager;
import org.mozilla.interfaces.nsIPrefService;
import org.mozilla.interfaces.nsIRequest;
@@ -38,7 +35,6 @@
import org.mozilla.interfaces.nsIURI;
import org.mozilla.interfaces.nsIWebBrowser;
import org.mozilla.interfaces.nsIWebBrowserChrome;
-import org.mozilla.interfaces.nsIWebBrowserFocus;
import org.mozilla.interfaces.nsIWebBrowserSetup;
import org.mozilla.interfaces.nsIWebNavigation;
import org.mozilla.interfaces.nsIWebProgress;
@@ -86,16 +82,8 @@
}
public XulRunnerBrowser(Composite parent) throws XulRunnerException {
- String xulRunnerPath = getXulRunnerPath();
+ initXulRunner();
- Boolean isXulRunnerInitialized = "true".equals(System.getProperty(XULRUNNER_INITIALIZED)); // $NON-NLS-1$
- if (!isXulRunnerInitialized) {
- File file = new File(xulRunnerPath);
- mozilla.initialize(file);
- mozilla.initEmbedding(file, file, new AppFileLocProvider(file));
- System.setProperty(XULRUNNER_INITIALIZED, "true"); // $NON-NLS-1$
- }
-
browser = new Browser(parent, SWT.MOZILLA);
webBrowser = (nsIWebBrowser) browser.getWebBrowser();
@@ -113,6 +101,18 @@
webBrowser.addWebBrowserListener(this, nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
}
+ public synchronized void initXulRunner() throws XulRunnerException {
+ String xulRunnerPath = getXulRunnerPath();
+
+ Boolean isXulRunnerInitialized = "true".equals(System.getProperty(XULRUNNER_INITIALIZED)); // $NON-NLS-1$
+ if (!isXulRunnerInitialized) {
+ File file = new File(xulRunnerPath);
+ mozilla.initialize(file);
+ mozilla.initEmbedding(file, file, new AppFileLocProvider(file));
+ System.setProperty(XULRUNNER_INITIALIZED, "true"); // $NON-NLS-1$
+ }
+ }
+
/**
* Decorate Widget.getDisplay()
*/
@@ -160,7 +160,7 @@
return XULRUNNER_BUNDLE;
}
- private String getXulRunnerPath() throws XulRunnerException {
+ public synchronized static String getXulRunnerPath() throws XulRunnerException {
String xulRunnerPath = System.getProperty(XULRUNNER_PATH);
if (xulRunnerPath == null) {
GREVersionRange[] greRanges = {new GREVersionRange(XULRUNNER_LOWER_VERSION, true, XULRUNNER_HIGHER_VERSION, true)};
@@ -206,15 +206,6 @@
return xulRunnerPath;
}
- /**
- * @return
- */
- private File getXULRunnerPathFromMozilla() {
- File xulRunnerFile = null;
- return xulRunnerFile;
- }
-
-
public nsIServiceManager getServiceManager() {
return mozilla.getServiceManager();
}
17 years, 3 months
JBoss Tools SVN: r4148 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-12 07:50:17 -0400 (Fri, 12 Oct 2007)
New Revision: 4148
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1070
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2007-10-12 11:34:45 UTC (rev 4147)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2007-10-12 11:50:17 UTC (rev 4148)
@@ -3,6 +3,8 @@
<plugin>
<extension-point id="templates" name="Path to xml file with templates definitionj" schema="schema/templates.exsd"/>
+ <extension point="org.eclipse.ui.startup" />
+
<extension point="org.jboss.tools.common.model.meta">
<meta path="meta/vpe.meta"/>
</extension>
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-12 11:34:45 UTC (rev 4147)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-12 11:50:17 UTC (rev 4148)
@@ -15,16 +15,21 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.PlatformUI;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
+import org.jboss.tools.vpe.xulrunner.XulRunnerException;
+import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
* The main plugin class to be used in the desktop.
*/
-public class VpePlugin extends BaseUIPlugin {
+public class VpePlugin extends BaseUIPlugin implements IStartup {
public final static String PLUGIN_ID = "org.jboss.tools.vpe";
//The shared instance.
private static VpePlugin plugin;
@@ -123,4 +128,16 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ @Override
+ public void earlyStartup() {
+ /* init xulrunner path for */
+ try {
+ XulRunnerBrowser.getXulRunnerPath();
+ } catch (Throwable t) {
+ // Ignore this. Will catch it when use Visual Editor
+ }
+ }
+
+
}
17 years, 3 months
JBoss Tools SVN: r4147 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2007-10-12 07:34:45 -0400 (Fri, 12 Oct 2007)
New Revision: 4147
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
Log:
Fix RichFaces treeNodesAdaptor and recursiveTreeNodesAdaptor templates
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-12 10:30:23 UTC (rev 4146)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-12 11:34:45 UTC (rev 4147)
@@ -49,14 +49,17 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
Document visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "recursiveTreeNodesAdaptor");
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
+ "recursiveTreeNodesAdaptor");
Element visualElement = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, RECURSIVE_TREE_NODES_ADAPTOR_NAME);
+ visualElement.setAttribute(ID_ATTR_NAME,
+ RECURSIVE_TREE_NODES_ADAPTOR_NAME);
if (isHasParentAdapter(sourceNode)) {
visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-tree-h-ic-div");
- if (getShowLinesAttr(sourceNode)) {
+ if (getShowLinesAttr(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
String path = RichFacesTemplatesActivator
.getPluginResourcePath()
+ ICON_DIV_LINE;
@@ -153,4 +156,46 @@
}
return showLinesValue;
}
+
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(sourceNode)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-12 10:30:23 UTC (rev 4146)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-12 11:34:45 UTC (rev 4147)
@@ -255,7 +255,7 @@
"background-image: url(file://" + path + "); "
+ NODE_LINES_STYLE);
}
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) && (isAdaptorInTree(sourceNode) == isLastElementAfterAdaptor(sourceNode)))
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) && (isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)) /*&& (isAdaptorInTree(sourceNode) == isLastElementAfterAdaptor(sourceNode))*/)
|| (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
backgroundLinePath = RichFacesTemplatesActivator
.getPluginResourcePath()
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-12 10:30:23 UTC (rev 4146)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-12 11:34:45 UTC (rev 4147)
@@ -55,7 +55,8 @@
if (isHasParentAdapter(sourceNode)) {
visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-tree-h-ic-div");
- if (getShowLinesAttr(sourceNode)) {
+ if (getShowLinesAttr(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
String path = RichFacesTemplatesActivator
.getPluginResourcePath()
+ ICON_DIV_LINE;
@@ -152,4 +153,46 @@
}
return showLinesValue;
}
+
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(sourceNode)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
}
17 years, 3 months
JBoss Tools SVN: r4146 - in trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces: META-INF and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2007-10-12 06:30:23 -0400 (Fri, 12 Oct 2007)
New Revision: 4146
Added:
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
Log:
Add RichFaces JUnit tests
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.test.richfaces</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Richfaces Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.test.richfaces
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.vpe.test.richfaces.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.vpe,
+ org.junit,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
+Eclipse-LazyStart: true
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.test.richfaces;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.vpe.test.richfaces";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static String getPluginResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null : FileLocator.resolve(bundle
+ .getEntry("/resources"));
+ } catch (Exception e) {
+ url = bundle.getEntry("/resources");
+ }
+ return (url == null) ? null : url.getPath();
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.test.richfaces;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+/**
+ * Class for importing project from jar file
+ *
+ * @author dsakharov@exadel.com,amakhtadui(a)exadel.com
+ *
+ */
+public class ImportRichFacesComponents {
+ private static final String PROJECT_NAME = "richFacesTest";
+ private static final String COMPONENTS_PATH = "WebContent/pages";
+
+ @SuppressWarnings("restriction")
+ public static boolean importRichFacesPages(String path) {
+ boolean result = false;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ ZipLeveledStructureProvider zipStructureProvider;
+ try {
+ zipStructureProvider = new ZipLeveledStructureProvider(new ZipFile(
+ path));
+
+ IOverwriteQuery overwrite = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return ALL;
+ }
+ };
+
+ ImportOperation importOp = new ImportOperation(project
+ .getFullPath(), zipStructureProvider.getRoot(),
+ zipStructureProvider, overwrite);
+
+ importOp.setContext(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
+
+ importOp.run(new NullProgressMonitor());
+ result = true;
+
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ public static Collection<IPath> getComponentsPaths() throws CoreException {
+ Collection<IPath> result = null;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ if (project != null) {
+ IFolder folder = project.getFolder(COMPONENTS_PATH);
+ IResource[] resources = folder.members();
+ if (resources != null && resources.length > 0) {
+ result = new ArrayList<IPath>(resources.length);
+ for (IResource res : resources) {
+ result.add(res.getFullPath());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @throws CoreException
+ */
+ public static void removeProject() throws CoreException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.test.richfaces;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Class for testing all RichFaces components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+
+public class RichFacesAllTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for Vpe RichFaces components");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(RichFacesComponentTest.class);
+ // $JUnit-END$
+ return suite;
+
+ }
+
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java 2007-10-12 10:30:23 UTC (rev 4146)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.test.richfaces;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Class for testing all RichFaces components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesComponentTest extends TestCase implements ILogListener {
+
+ private final static String EDITOR_ID = "org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor";
+ private final static String TEST_PROJECT_JAR_PATH = "/richFacesTest.jar";
+
+ // check warning log
+ private final static boolean checkWarning = false;
+ private boolean failureLog;
+ private Collection<IPath> components = null;
+
+ public RichFacesComponentTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (ImportRichFacesComponents.importRichFacesPages(Activator
+ .getPluginResourcePath()
+ + TEST_PROJECT_JAR_PATH)) {
+ components = ImportRichFacesComponents.getComponentsPaths();
+ }
+ failureLog = false;
+ waitForJobs();
+ Platform.addLogListener(this);
+ waitForJobs();
+ delay(5000);
+ }
+
+ /**
+ * Perform post-test cleanup.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ImportRichFacesComponents.removeProject();
+ waitForJobs();
+ Platform.removeLogListener(this);
+ }
+
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ private void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+
+ /**
+ * Wait until all background tasks are complete.
+ */
+ public void waitForJobs() {
+ while (Platform.getJobManager().currentJob() != null)
+ delay(5000);
+ }
+
+ public void testRichFacesComponent() throws PartInitException {
+ waitForJobs();
+
+ for (IPath componentPath : components) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ componentPath);
+ IEditorInput input = new FileEditorInput(file);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().openEditor(input, EDITOR_ID, true);
+
+ waitForJobs();
+ delay(3000);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().closeAllEditors(true);
+ }
+ assertEquals(failureLog, false);
+ }
+
+ public void logging(IStatus status, String plugin) {
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ failureLog = true;
+ break;
+ case IStatus.WARNING:
+ if (checkWarning)
+ failureLog = true;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
___________________________________________________________________
Name: svn:executable
+ *
17 years, 3 months
JBoss Tools SVN: r4145 - trunk/vpe/tests.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2007-10-12 06:23:33 -0400 (Fri, 12 Oct 2007)
New Revision: 4145
Added:
trunk/vpe/tests/org.jboss.tools.vpe.test.richfaces/
Log:
Add RichFaces JUnit tests
17 years, 3 months
JBoss Tools SVN: r4144 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: amakhtadui
Date: 2007-10-12 06:16:38 -0400 (Fri, 12 Oct 2007)
New Revision: 4144
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-847
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2007-10-12 10:03:37 UTC (rev 4143)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2007-10-12 10:16:38 UTC (rev 4144)
@@ -20,56 +20,68 @@
private static final String DEFAULT_PANEL_MENU_GROUP_POINTER = "/panelMenuGroup/pointer.gif";
private static final String DEFAULT_PANEL_MENU_GROUP_POINT = "/panelMenuGroup/point.gif";
-
+
private static final String STYLE_PATH = "/panelMenuGroup/style.css";
-
+
private static final String ICON_WIDTH = "16";
-
+
private static final String ICON_HEIGHT = "16";
-
+
private static final String ICON_VSPACE = "0";
-
+
private static final String ICON_HSPACE = "0";
-
+
private static final String EMPTY_DIV_STYLE = "display: none;";
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- Document visualDocument) {
- Element div = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
- div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, EMPTY_DIV_STYLE);
-
- return new VpeCreationData(div);
- }
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode, Document visualDocument) {
+ Element div = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, EMPTY_DIV_STYLE);
- public static VpeCreationData encode(VpePageContext pageContext, VpeCreationData creationData, Element sourceElement, Document visualDocument, Element parentVisualElement, boolean expanded) {
+ return new VpeCreationData(div);
+ }
+
+ public static VpeCreationData encode(VpePageContext pageContext, VpeCreationData creationData, Element sourceElement, Document visualDocument, Element parentVisualElement, boolean expanded, int activeChildId) {
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "panelMenuGroup");
Element div = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
parentVisualElement.appendChild(div);
-
+
div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-pmenu-top-group-div");
div.setAttribute("vpeSupport", "panelMenuGroup");
+ div.setAttribute("vpe-user-toggle-id", String.valueOf(activeChildId));
buildTable(sourceElement, visualDocument, div);
-
+
List<Node> children = ComponentUtil.getChildren(sourceElement);
if (!children.isEmpty()) {
- VpeChildrenInfo childInfo = new VpeChildrenInfo(div);
+ Element childDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(childDiv);
for (Node child : children) {
- if(!expanded && !child.getNodeName().endsWith(":panelMenuGroup") && !child.getNodeName().endsWith(":panelMenuItem")) {
- childInfo.addSourceChild(child);
+ if (!child.getNodeName().endsWith(":panelMenuGroup") && !child.getNodeName().endsWith(":panelMenuItem")) {
+ if (childrenInfo.getSourceChildren() == null || childrenInfo.getSourceChildren().size() == 0) {
+ div.appendChild(childDiv);
+ }
+ childrenInfo.addSourceChild(child);
} else {
- if(child.getNodeName().endsWith(":panelMenuGroup")) {
- RichFacesPanelMenuGroupTemplate.encode(pageContext, creationData, (Element)child, visualDocument, div, true);
+ if (expanded) {
+ if (child.getNodeName().endsWith(":panelMenuGroup")) {
+ RichFacesPanelMenuGroupTemplate.encode(pageContext, creationData, (Element) child, visualDocument, div, false, -1);
+ } else {
+ RichFacesPanelMenuItemTemplate.encode(pageContext, creationData, (Element) child, visualDocument, div, false);
+ }
}
- if(child.getNodeName().endsWith(":panelMenuItem")){
- RichFacesPanelMenuItemTemplate.encode(pageContext, creationData, (Element)child, visualDocument, div, false);
+
+ if (childrenInfo.getSourceChildren() != null && childrenInfo.getSourceChildren().size() > 0) {
+ creationData.addChildrenInfo(childrenInfo);
+ childDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ childrenInfo = new VpeChildrenInfo(childDiv);
}
- childInfo.addSourceChild(child);
}
}
- creationData.addChildrenInfo(childInfo);
+
+ if(childrenInfo.getSourceChildren() != null && childrenInfo.getSourceChildren().size() > 0) {
+ creationData.addChildrenInfo(childrenInfo);
+ }
}
return creationData;
@@ -116,13 +128,13 @@
if (parent.getNodeName().endsWith(":panelMenu")) {
ComponentUtil.setImg(img1, DEFAULT_PANEL_MENU_GROUP_SPACER);
- ComponentUtil.setImg(img2, DEFAULT_PANEL_MENU_GROUP_POINTER);
+ ComponentUtil.setImg(img2, DEFAULT_PANEL_MENU_GROUP_POINTER);
column2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-pmenu-group-self-label dr-pmenu-selected-item");
table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-pmenu-top-group");
} else {
- ComponentUtil.setImg(img1, DEFAULT_PANEL_MENU_GROUP_POINT);
+ ComponentUtil.setImg(img1, DEFAULT_PANEL_MENU_GROUP_POINT);
img1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "vertical-align: middle");
- ComponentUtil.setImg(img2, DEFAULT_PANEL_MENU_GROUP_SPACER);
+ ComponentUtil.setImg(img2, DEFAULT_PANEL_MENU_GROUP_SPACER);
column2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-pmenu-group rich-pmenu-group");
table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-pmenu-group-self-label rich-pmenu-group-self-label");
}
@@ -138,7 +150,7 @@
parent = parent.getParentNode();
}
}
-
+
return parent;
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2007-10-12 10:03:37 UTC (rev 4143)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2007-10-12 10:16:38 UTC (rev 4144)
@@ -88,17 +88,17 @@
for (Node child : children) {
- boolean active = true; // (i == activeId);
+ boolean expanded = true; // (i == activeId);
if (child.getNodeName().endsWith(PANEL_MENU_GROUP_END)) {
RichFacesPanelMenuGroupTemplate.encode(pageContext,
vpeCreationData, (Element) child, visualDocument, div,
- active);
+ expanded, i);
i++;
} else if (child.getNodeName().endsWith(PANEL_MENU_ITEM_END)) {
RichFacesPanelMenuItemTemplate.encode(pageContext,
vpeCreationData, (Element) child, visualDocument, div,
- active);
+ expanded);
} else {
Element childDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
17 years, 3 months