Author: dazarov
Date: 2007-09-12 13:43:55 -0400 (Wed, 12 Sep 2007)
New Revision: 3591
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestComponentView/WebContent/WEB-INF/components.xml
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
Log:
http://jira.jboss.com/jira/browse/EXIN-337
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestComponentView/WebContent/WEB-INF/components.xml
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestComponentView/WebContent/WEB-INF/components.xml 2007-09-12
15:35:49 UTC (rev 3590)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/TestComponentView/WebContent/WEB-INF/components.xml 2007-09-12
17:43:55 UTC (rev 3591)
@@ -2,7 +2,7 @@
<components
xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-1.2.xsd http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-1.2.xsd">
- <component class="java.lang.Boolean" name="myComponent"
scope="page">
+ <component class="java.lang.Boolean"
name="package1.package2.package3.package4.myComponent"
scope="page">
<property name="property1">value1</property>
<property name="myList">
<value>value1</value>
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2007-09-12
15:35:49 UTC (rev 3590)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2007-09-12
17:43:55 UTC (rev 3591)
@@ -41,6 +41,7 @@
import org.jboss.tools.seam.core.ISeamScope;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.ui.ISeamUiConstants;
+import org.jboss.tools.seam.ui.views.actions.ScopePresentationActionProvider;
import org.jboss.tools.test.util.JUnitUtils;
import org.jboss.tools.test.util.WorkbenchUtils;
@@ -71,6 +72,54 @@
assertTrue("Cannot find components.xml in test project", componentsFile !=
null && componentsFile.exists());
}
+ public void testFlatSeamPackages(){
+ ScopePresentationActionProvider.setPackageStructureFlat(true);
+
+ SeamCorePlugin.getSeamProject(project, true);
+
+ refreshProject(project);
+
+ CommonNavigator navigator = getSeamComponentsView();
+
+ navigator.getCommonViewer().expandAll();
+
+
+ Tree tree = navigator.getCommonViewer().getTree();
+
+ updateTree(tree);
+
+ ISeamPackage seamPackage = findSeamPackage(tree, "package1");
+
+ assertTrue("Unexpected package 'package1' was" +
+ " found",seamPackage==null);
+
+ seamPackage = findSeamPackage(tree, "package1.package2.package3.package4");
+
+ assertTrue("Expected package 'package1.package2.package3.package4' was
not" +
+ " found",seamPackage!=null);
+ }
+
+ public void testHierarchicalSeamPackages(){
+ ScopePresentationActionProvider.setPackageStructureFlat(false);
+
+ SeamCorePlugin.getSeamProject(project, true);
+
+ refreshProject(project);
+
+ CommonNavigator navigator = getSeamComponentsView();
+
+ navigator.getCommonViewer().expandAll();
+
+ Tree tree = navigator.getCommonViewer().getTree();
+
+ updateTree(tree);
+
+ ISeamPackage seamPackage = findSeamPackage(tree, "package1");
+
+ assertTrue("Expected package 'package1' was not" +
+ " found",seamPackage!=null);
+ }
+
public void testAddComponentInXmlFile(){
SeamCorePlugin.getSeamProject(project, true);
@@ -80,6 +129,7 @@
navigator.getCommonViewer().expandAll();
+
Tree tree = navigator.getCommonViewer().getTree();
updateTree(tree);
@@ -323,6 +373,8 @@
}
public void testDeleteComponentInClass(){
+ classFile = project.getFile("JavaSource/demo/Person.java");
+
CommonNavigator navigator = getSeamComponentsView();
navigator.getCommonViewer().expandAll();
@@ -395,25 +447,16 @@
return part;
}
-
-
private void showTreeItem(TreeItem item, int level){
for(int i=0;i<level;i++)
System.out.print("-");
- System.out.print(item.getText());
- System.out.println("Item "+item.getData());
- if(item.getData() instanceof ISeamScope){
- ISeamScope scope = (ISeamScope)item.getData();
- Iterator<ISeamPackage> iter = scope.getAllPackages().iterator();
- while(iter.hasNext())
- showSeamPackage(iter.next(), level+1);
-
-
- List<ISeamComponent> components = scope.getComponents();
- for(int i=0;i<components.size();i++)
- showSeamComponent(components.get(i), level+1);
- }
+ System.out.print("Item "+item.getText());
+ System.out.println(" Data "+item.getData());
+ if(item.getData() instanceof ISeamPackage)
+ showSeamPackage((ISeamPackage)item.getData(),1);
+ else if(item.getData() instanceof ISeamComponent)
+ showSeamComponent((ISeamComponent)item.getData(),1);
for(int i=0;i<item.getItemCount();i++){
showTreeItem(item.getItem(i),level+1);
@@ -421,8 +464,8 @@
}
private void showSeamPackage(ISeamPackage seamPackage, int level){
- for(int i=0;i<level;i++)
- System.out.print("-");
+// for(int i=0;i<level;i++)
+// System.out.print("-");
System.out.println("Package - "+seamPackage.getName()+"
"+seamPackage.getQualifiedName());
@@ -432,8 +475,8 @@
}
private void showSeamComponent(ISeamComponent component, int level){
- for(int i=0;i<level;i++)
- System.out.print("-");
+// for(int i=0;i<level;i++)
+// System.out.print("-");
System.out.println("Component - "+component.getName()+"
"+component.getClassName());
}
@@ -450,17 +493,17 @@
return null;
}
- private ISeamPackage findSeamPackage(ISeamScope seamScope, String name){
- ISeamPackage seamPackage=null;
-
- Iterator<ISeamPackage> iter = seamScope.getAllPackages().iterator();
- while(iter.hasNext()){
- seamPackage = iter.next();
- if(seamPackage.getName().equals(name)) return seamPackage;
- }
-
- return null;
- }
+// private ISeamPackage findSeamPackage(ISeamScope seamScope, String name){
+// ISeamPackage seamPackage=null;
+//
+// Iterator<ISeamPackage> iter = seamScope.getAllPackages().iterator();
+// while(iter.hasNext()){
+// seamPackage = iter.next();
+// if(seamPackage.getName().equals(name)) return seamPackage;
+// }
+//
+// return null;
+// }
private ISeamPackage findSeamPackage(TreeItem item, String name){
ISeamPackage seamPackage=null;
@@ -469,12 +512,15 @@
TreeItem cur = item.getItem(i);
if(cur.getData() instanceof ISeamPackage) {
ISeamPackage pkg =(ISeamPackage)cur.getData();
- if(name.equals(pkg.getName())) {
+ //System.out.println("Searching: "+name+" found:
"+pkg.getQualifiedName());
+ if(name.equals(pkg.getQualifiedName())) {
seamPackage = pkg;
+ //System.out.println("Found!");
break;
}
}else {
seamPackage = findSeamPackage(cur, name);
+ if(seamPackage != null) return seamPackage;
}
}