Author: dazarov
Date: 2007-09-14 06:26:31 -0400 (Fri, 14 Sep 2007)
New Revision: 3625
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java
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/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java 2007-09-14
09:34:15 UTC (rev 3624)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamViewLayoutActionGroup.java 2007-09-14
10:26:31 UTC (rev 3625)
@@ -62,10 +62,11 @@
private String property;
private final boolean value;
- public CommonLayoutAction(String property, boolean value) {
+ public CommonLayoutAction(String property, boolean value, String id) {
super("", AS_RADIO_BUTTON);
this.property = property;
this.value = value;
+ this.setId(id);
}
public void run() {
@@ -87,13 +88,13 @@
IMenuManager viewMenu = actionBars.getMenuManager();
// Create layout sub menu
if (layoutSubMenu == null) {
- layoutSubMenu = new MenuManager("Seam Packages");
+ layoutSubMenu = new MenuManager("Seam Packages", "Seam
Packages");
addLayoutActions(layoutSubMenu);
viewMenu.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new
Separator(LAYOUT_GROUP_NAME));
}
if(scopeSubMenu == null) {
- scopeSubMenu = new MenuManager("Scope Presentation");
+ scopeSubMenu = new MenuManager("Scope Presentation", "Scope
Presentation");
addScopeActions(scopeSubMenu);
}
@@ -145,14 +146,14 @@
}
private void createActions() {
- flatLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE, true);
- hierarchicalLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE, false);
- labelScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION, true);
- nodeScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION, false);
+ flatLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE, true,
"package.flat");
+ hierarchicalLayoutAction = new CommonLayoutAction(PACKAGE_STRUCTURE,
false,"package.hierarchical");
+ labelScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION,
true,"layout.label");
+ nodeScopeAction = new CommonLayoutAction(SCOPE_PRESENTATION,
false,"layout.node");
}
protected void addLayoutActions(IMenuManager viewMenu) {
- viewMenu.add(new ContributionItem() {
+ viewMenu.add(new SeamContributionItem(flatLayoutAction) {
public void fill(Menu menu, int index) {
int style = SWT.RADIO;
MenuItem mi = new MenuItem(menu, style, index);
@@ -179,7 +180,7 @@
}
});
- viewMenu.add(new ContributionItem() {
+ viewMenu.add(new SeamContributionItem(hierarchicalLayoutAction) {
public void fill(Menu menu, int index) {
int style = SWT.RADIO;
MenuItem mi = new MenuItem(menu, style, index);
@@ -209,7 +210,7 @@
}
protected void addScopeActions(IMenuManager viewMenu) {
- viewMenu.add(new ContributionItem() {
+ viewMenu.add(new SeamContributionItem(labelScopeAction) {
public void fill(Menu menu, int index) {
int style = SWT.RADIO;
MenuItem mi = new MenuItem(menu, style, index);
@@ -236,7 +237,7 @@
}
});
- viewMenu.add(new ContributionItem() {
+ viewMenu.add(new SeamContributionItem(nodeScopeAction) {
public void fill(Menu menu, int index) {
int style = SWT.RADIO;
MenuItem mi = new MenuItem(menu, style, index);
@@ -264,5 +265,16 @@
});
}
-
+ public class SeamContributionItem extends ContributionItem{
+ IAction action;
+
+ public SeamContributionItem(IAction action){
+ super(action.getId());
+ this.action = action;
+ }
+
+ public IAction getAction(){
+ return action;
+ }
+ }
}
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-14
09:34:15 UTC (rev 3624)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2007-09-14
10:26:31 UTC (rev 3625)
@@ -22,11 +22,16 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.internal.decorators.DecoratorManager;
import org.eclipse.ui.navigator.CommonNavigator;
@@ -39,6 +44,7 @@
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.seam.ui.views.actions.SeamViewLayoutActionGroup.SeamContributionItem;
import org.jboss.tools.test.util.JUnitUtils;
import org.jboss.tools.test.util.WorkbenchUtils;
@@ -55,7 +61,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- ScopePresentationActionProvider.setPackageStructureFlat(false);
+ //ScopePresentationActionProvider.setPackageStructureFlat(false);
WorkbenchUtils.getWorkbench().showPerspective(
RedHat4WebPerspectiveFactory.PERSPECTIVE_ID,
WorkbenchUtils.getWorkbench().getActiveWorkbenchWindow());
@@ -70,31 +76,6 @@
assertTrue("Cannot find components.xml in test project", componentsFile !=
null && componentsFile.exists());
}
- public void testFlatSeamPackages(){
- 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 testAddComponentInXmlFile(){
SeamCorePlugin.getSeamProject(project, true);
@@ -416,19 +397,54 @@
assertTrue("Created Seam enabled project haven't been deleted from
tree",0==content.getElements(ResourcesPlugin.getWorkspace().getRoot()).length);
}
+ public void testFlatSeamPackages(){
+ SeamCorePlugin.getSeamProject(project, true);
+
+ refreshProject(project);
+ CommonNavigator navigator = getSeamComponentsView();
+
+ IActionBars bars = ((IViewSite)navigator.getSite()).getActionBars();
+ IMenuManager mm = bars.getMenuManager();
+ IContributionItem item = ((MenuManager)mm).find("Seam Packages");
+ SeamContributionItem item2 =
(SeamContributionItem)((MenuManager)item).find("package.flat");
+ item2.getAction().run();
+
+ refreshProject(project);
+
+ 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(){
SeamCorePlugin.getSeamProject(project, true);
refreshProject(project);
CommonNavigator navigator = getSeamComponentsView();
-
+
+ IActionBars bars = ((IViewSite)navigator.getSite()).getActionBars();
+ IMenuManager mm = bars.getMenuManager();
+ IContributionItem item = ((MenuManager)mm).find("Seam Packages");
+ SeamContributionItem item2 =
(SeamContributionItem)((MenuManager)item).find("package.hierarchical");
+ item2.getAction().run();
+
+ refreshProject(project);
+
navigator.getCommonViewer().expandAll();
-// IActionBars bars = ((IViewSite)navigator.getSite()).getActionBars();
-// IMenuManager mm = bars.getMenuManager();
-// IContributionItem item = ((MenuManager)mm).find("Seam Packages");
-// IContributionItem item2 =
((MenuManager)item).find("package.hierarchical");
Tree tree = navigator.getCommonViewer().getTree();