JBoss Tools SVN: r36702 - in trunk: jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2011-11-28 11:11:30 -0500 (Mon, 28 Nov 2011)
New Revision: 36702
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
Removed:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added test of faces-config.xml file editing within JSF2 project
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -14,6 +14,7 @@
import org.jboss.tools.jsf.ui.bot.test.smoke.CreateNewJSFProjectTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigCodeCompletionTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigEditingTest;
+import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigEditingTestJSF2;
import org.jboss.tools.jsf.ui.bot.test.smoke.MarkersTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.OpenOnTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.WebXmlEditorTest;
@@ -47,6 +48,7 @@
OpenOnTest.class,
CodeCompletionTest.class,
FacesConfigEditingTest.class,
+ FacesConfigEditingTestJSF2.class,
FacesConfigCodeCompletionTest.class,
MarkersTest.class,
WebXmlEditorTest.class,
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -0,0 +1,565 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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.ui.bot.test.smoke;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorBot;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorPartMatcher;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorUtil;
+import org.jboss.tools.ui.bot.ext.Assertions;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+/** Parent test for editing of faces-config.xml file
+ * @author Vladimir Pakan
+ *
+ */
+public abstract class AbstractFacesConfigEditingTest extends JSFAutoTestCase{
+
+ protected static final String FACES_CONFIG_FILE_NAME = "faces-config.xml";
+ private SWTBotEditor facesConfigEditor;
+ private String originalContent;
+ private SWTBotEditorExt facesConfigEditorExt;
+ private SWTBotExt botExt;
+ private SWTBotGefEditPart gefObjectAddedViaViewTool = null;
+ private SWTBotGefEditPart gefObjectAddedViaDnDTool = null;
+ private SWTBotGefViewer gefViewer = null;
+ private String testProjectName = null;
+
+ protected static enum TestProjectType {
+ JSF,
+ JSF2;
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ eclipse.closeAllEditors();
+ intializeTestProject();
+ facesConfigEditor = getFacesConfigEditor();
+ testProjectName = getTestProjectName();
+ originalContent = facesConfigEditor.toTextEditor().getText();
+ facesConfigEditorExt = new SWTBotEditorExt(facesConfigEditor.toTextEditor().getReference(),bot);
+ botExt = new SWTBotExt();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ if (gefViewer != null){
+ if (gefObjectAddedViaViewTool != null){
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ if (gefObjectAddedViaDnDTool != null){
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ }
+ if (facesConfigEditor != null) {
+ facesConfigEditor.toTextEditor().setText(originalContent);
+ facesConfigEditor.saveAndClose();
+ bot.sleep(Timing.time1S());
+ }
+ super.tearDown();
+ }
+ /**
+ * Test Managed Bean editing
+ */
+ public void testManagedBean(){
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
+ SWTBot editorBot = facesConfigEditorExt.bot();
+ SWTBotTree tree = editorBot.tree();
+ final String managedBeanName = "TestBean";
+ final String managedBeanClass = "TestBeanClass";
+ SWTBotTreeItem tiFacesConfigXml = tree.expandNode(AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ SWTBotTreeItem tiManagedbean = tiFacesConfigXml.getNode(IDELabel.FacesConfigEditor.MANAGED_BEANS_NODE);
+ tiManagedbean.select();
+ bot.sleep(Timing.time1S());
+ // Add managed bean
+ editorBot.button(IDELabel.Button.ADD).click();
+ bot.shell(AbstractFacesConfigEditingTest.getAddManagedBeanDialogTitle(getTestProjectType())).activate();
+ bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass);
+ bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_NAME_LABEL)
+ .setText(managedBeanName);
+ bot.button(IDELabel.Button.FINISH).click();
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ final String selectedNode = tree.selection().get(0,0);
+ assertTrue ("Selected node has to have label '" + managedBeanName +"'\n" +
+ "but has '" + selectedNode + "'.",
+ selectedNode.equals(managedBeanName));
+ Assertions.assertFileExistsInWorkspace(managedBeanClass + ".java",
+ testProjectName,"JavaSource");
+ Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<managed-bean><managed-bean-name>" + managedBeanName + "</managed-bean-name>" +
+ "<managed-bean-class>" + managedBeanClass + "</managed-bean-class>" +
+ "<managed-bean-scope>request</managed-bean-scope></managed-bean>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // Modify Managed Bean
+ editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass + "xxqq");
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ if (getCheckForExistingManagedBeanClass()){
+ assertFacesConfigXmlHasErrors(botExt);
+ }
+ editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass);
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ // Delete Managed Bean
+ tiManagedbean.select();
+ editorBot.table().select(managedBeanName);
+ editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.checkBox(IDELabel.FacesConfigEditor.DELETE_JAVA_SOURCE_CHECK_BOX).select();
+ bot.button(IDELabel.Button.OK).click();
+ boolean managedBeanWasDeleted = false;
+ try{
+ editorBot.table().select(managedBeanName);
+ } catch (WidgetNotFoundException wnfe){
+ managedBeanWasDeleted = true;
+ } catch (IllegalArgumentException iae){
+ managedBeanWasDeleted = true;
+ }
+ assertTrue("Managed bean " + managedBeanName + " was not deleted properly.",
+ managedBeanWasDeleted);
+ Assertions.assertFileNotExistsInWorkspace(managedBeanClass + ".java",
+ testProjectName,"JavaSource");
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<managed-bean-name>" + managedBeanName + "</managed-bean-name>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<managed-bean-class>" + managedBeanClass + "</managed-bean-class>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Tests Component editing
+ */
+ public void testComponent (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.COMPONENTS_NODE,
+ IDELabel.Shell.ADD_COMPONENT,
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_TYPE_LABEL,
+ "TestComponentType",
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_CLASS_LABEL,
+ "TestComponentClass",
+ "component",
+ "component-type",
+ "component-class",
+ true);
+ }
+ /**
+ * Tests Converter editing
+ */
+ public void testConverter (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.CONVERTERS_NODE,
+ IDELabel.Shell.ADD_CONVERTER,
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_ID_LABEL,
+ "TestConverterID",
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_CLASS_LABEL,
+ "TestConverterClass",
+ "converter",
+ "converter-id",
+ "converter-class",
+ true);
+ }
+ /**
+ * Tests Referenced Bean editing
+ */
+ public void testReferencedBean (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.REFERENCED_BEAN_NODE,
+ IDELabel.Shell.ADD_REFERENCED_BEAN,
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_NAME_LABEL,
+ "TestReferencedBeanName",
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_CLASS_LABEL,
+ "TestReferencedBeanClass",
+ "referenced-bean",
+ "referenced-bean-name",
+ "referenced-bean-class",
+ true);
+ }
+ /**
+ * Tests Render Kit editing
+ */
+ public void testRenderKit (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.RENDER_KITS_NODE,
+ AbstractFacesConfigEditingTest.getAddRenderKitDialogTitle(getTestProjectType()),
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_ID_LABEL,
+ "TestRenderKitID",
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_CLASS_LABEL,
+ "TestRenderKitClass",
+ "render-kit",
+ "render-kit-id",
+ "render-kit-class",
+ false);
+ }
+ /**
+ * Tests Validator editing
+ */
+ public void testValidator (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.VALIDATOR_NODE,
+ IDELabel.Shell.ADD_VALIDATOR,
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_ID_LABEL,
+ "TestValidatorID",
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_CLASS_LABEL,
+ "TestValidatorClass",
+ "validator",
+ "validator-id",
+ "validator-class",
+ false);
+ }
+ /**
+ * Asserts if faces-config.xml has no errors
+ * @param botExt
+ */
+ protected static void assertFacesConfigXmlHasNoErrors (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null, AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
+ boolean areThereNoErrors = ((errors == null) || (errors.length == 0));
+ assertTrue("There are errors in Problems view: " +
+ (areThereNoErrors ? "" : errors[0].getText()),
+ areThereNoErrors);
+ }
+ /**
+ * Asserts if faces-config.xml has errors
+ * @param botExt
+ */
+ protected static void assertFacesConfigXmlHasErrors (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null, AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
+ boolean areThereErrors = ((errors != null) && (errors.length > 0));
+ assertTrue("There are missing errors in Problems view for " + AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME + " file.",
+ areThereErrors);
+ }
+ /**
+ * Check editing of particular tree node within Face Config Editor Tree
+ * @param treeNodeLabel
+ * @param addWizardTitle
+ * @param nameTextLabel
+ * @param typeTextValue
+ * @param classTextLabel
+ * @param classTextValue
+ * @param xmlNodeName
+ * @param nameXmlNodeName
+ * @param classXmlNodeName
+ * @param checkForValdiationErrors
+ */
+ protected void checkFacesConfigNodeEditing(String treeNodeLabel,
+ String addWizardTitle,
+ String nameTextLabel,
+ String typeTextValue,
+ String classTextLabel,
+ String classTextValue,
+ String xmlNodeName,
+ String nameXmlNodeName,
+ String classXmlNodeName,
+ boolean checkForValdiationErrors){
+
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
+ SWTBot editorBot = facesConfigEditorExt.bot();
+ SWTBotTree tree = editorBot.tree();
+ SWTBotTreeItem tiFacesConfigXml = tree.expandNode(AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ SWTBotTreeItem tiNodeToCheck = tiFacesConfigXml.getNode(treeNodeLabel);
+ tiNodeToCheck.select();
+ bot.sleep(Timing.time1S());
+ // Add Node
+ editorBot.button(IDELabel.Button.ADD).click();
+ bot.shell(addWizardTitle).activate();
+ bot.textWithLabel(nameTextLabel).setText(typeTextValue);
+ bot.textWithLabel(classTextLabel).setText(classTextValue);
+ bot.button(IDELabel.Button.FINISH).click();
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ if (checkForValdiationErrors){
+ assertFacesConfigXmlHasErrors(botExt);
+ }
+ final String selectedNode = tree.selection().get(0,0);
+ assertTrue ("Selected node has to have label '" + typeTextValue +"'\n" +
+ "but has '" + selectedNode + "'.",
+ selectedNode.equals(typeTextValue));
+ Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<" + xmlNodeName + ">" +
+ "<" + nameXmlNodeName + ">" + typeTextValue + "</" + nameXmlNodeName +">" +
+ "<" + classXmlNodeName + ">" + classTextValue + "</" + classXmlNodeName +">" +
+ "</" + xmlNodeName + ">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // Delete Node
+ tiNodeToCheck.select();
+ editorBot.table().select(typeTextValue);
+ editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.button(IDELabel.Button.OK).click();
+ boolean nodeWasDeleted = false;
+ try{
+ editorBot.table().select(typeTextValue);
+ } catch (WidgetNotFoundException wnfe){
+ nodeWasDeleted = true;
+ } catch (IllegalArgumentException iae){
+ nodeWasDeleted = true;
+ }
+ assertTrue(typeTextValue + " was not deleted properly.",
+ nodeWasDeleted);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + nameXmlNodeName + ">" + typeTextValue + "</" + nameXmlNodeName +">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + classXmlNodeName + ">" + classTextValue + "</" + classXmlNodeName +">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Test editing via Diagram tab
+ */
+ public void testDiagramEditing(){
+ final int verticalSpacing = 100;
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.DIAGRAM_TAB_LABEL);
+ final FacesConfigGefEditorBot gefEditorBot = new FacesConfigGefEditorBot(facesConfigEditorExt.getReference());
+ gefViewer = gefEditorBot.getViewer();
+ SWTBotGefEditPart mainPart = gefViewer.mainEditPart();
+ // add View to diagram via pallete tool
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_VIEW_TEMPLATE_TOOL);
+ SWTBotGefEditPart gefObjectPart = mainPart.descendants(
+ new FacesConfigGefEditorPartMatcher(AbstractFacesConfigEditingTest.getInputNamePageName(getTestProjectType()))).get(0);
+ gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).y + verticalSpacing);
+ final String viewAddedViaToolName = "addedViaTool";
+ handleNewViewWizard(viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ bot.sleep(Timing.time3S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ Assertions.assertFileExistsInWorkspace(viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()),
+ getTestProjectName(),
+ "WebContent");
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaViewTool = mainPart.descendants(new FacesConfigGefEditorPartMatcher("/" + viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()))).get(0);
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ Assertions.assertSourceEditorContains(AbstractFacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + viewAddedViaToolName +
+ "</from-outcome><to-view-id>/" + viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()) +
+ "</to-view-id></navigation-case>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // add View to Diagram via D'n'D
+ final String dndPageName = "testDnDPage";
+ createTestPage(dndPageName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ facesConfigEditor.show();
+ facesConfigEditor.setFocus();
+ SWTBotTreeItem tiPage = SWTEclipseExt.selectTreeLocation(open.viewOpen(ActionItem.View.JBossToolsWebWebProjects.LABEL).bot(),
+ getTestProjectName(),
+ "WebContent",
+ "pages",
+ dndPageName + AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ DragAndDropHelper.dnd((TreeItem)tiPage.widget, (FigureCanvas) gefEditorBot.getControl());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaDnDTool = mainPart.descendants(new FacesConfigGefEditorPartMatcher("/pages/" + dndPageName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()))).get(0);
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).y + verticalSpacing);
+ gefViewer.clickContextMenu(IDELabel.Menu.AUTO_LAYOUT);
+ bot.shell(IDELabel.Shell.AUTO_LAYOUT).activate();
+ bot.button(IDELabel.Button.OK).click();
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ Assertions.assertSourceEditorContains(AbstractFacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + dndPageName +
+ "</from-outcome><to-view-id>/pages/" + dndPageName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()) +
+ "</to-view-id></navigation-case>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Handle adding new View
+ * @param fromViewID
+ */
+ protected void handleNewViewWizard(String fromViewID){
+ SWTBot dialogBot = bot.shell(IDELabel.Shell.NEW_VIEW).activate().bot();
+ dialogBot.textWithLabel(IDELabel.NewViewDialog.FROM_VIEW_ID_TEXT_LABEL)
+ .setText(fromViewID);
+ dialogBot.checkBox(IDELabel.NewViewDialog.CREATE_FILE_ON_DISK_CHECKBOX_LABEL)
+ .select();
+ dialogBot.button(IDELabel.Button.FINISH).click();
+
+ }
+ /**
+ * Returns XNL Source striped from spaces, tabs and EOL
+ *
+ * @return String
+ */
+ protected static String stripXMLSourceText(String editorText) {
+ return editorText.replaceAll("\n", "").replaceAll("\t", "")
+ .replaceAll("\b", "").replaceAll(" ", "").replaceAll("\r", "")
+ .replaceAll("\f", "");
+ }
+ /**
+ * Confirm deletion of View from Diagram Editor
+ */
+ protected void confirmViewDelete(){
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.checkBox(IDELabel.FacesConfigEditor.DELETE_FILE_FROM_DISK_CHECK_BOX).select();
+ bot.button(IDELabel.Button.OK).click();
+ }
+ /**
+ * Returns proper Add Managed Bean Dialog Title
+ * @param testProjectType
+ * @return
+ */
+ private static String getAddManagedBeanDialogTitle(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = IDELabel.Shell.NEW_MANAGED_BEAN;
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = IDELabel.Shell.NEW_MANAGED_BEAN_JSF2;
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " + testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Add Render Kit Dialog Title
+ * @param testProjectType
+ * @return
+ */
+ private static String getAddRenderKitDialogTitle(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = IDELabel.Shell.ADD_RENDER_KIT;
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = IDELabel.Shell.ADD_RENDER_KIT_JSF2;
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " + testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Input Name Page Name
+ * @param testProjectType
+ * @return
+ */
+ private static String getInputNamePageName(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = "/pages/inputUserName.jsp";
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = "/pages/inputname.xhtml";
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " + testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Extension for new Web Pages
+ * @param testProjectType
+ * @return
+ */
+ private static String getNewPagesExtension(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = ".jsp";
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = ".xhtml";
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " + testProjectType);
+ }
+
+ return result;
+
+ }
+
+ private void createTestPage (String testPageName){
+ if (testPageName.endsWith(".jsp")){
+ createJspPage(testPageName, getTestProjectName(), "WebContent", "pages");
+ }
+ else if (testPageName.endsWith(".xhtml")){
+ createXhtmlPage(testPageName, getTestProjectName(), "WebContent", "pages");
+ }
+ else {
+ throw new IllegalArgumentException("Not supported Test Page Extension when creating page " + testPageName);
+ }
+ }
+ /**
+ * Returns current SWTBotEditor
+ * @return
+ */
+ protected abstract SWTBotEditor getFacesConfigEditor();
+ /**
+ * Returns Test Project Name
+ * @return
+ */
+ protected abstract String getTestProjectName();
+ /**
+ * Initializes Test Project
+ */
+ protected abstract void intializeTestProject();
+ /**
+ * Returns Test Project Type
+ * @return
+ */
+ protected abstract TestProjectType getTestProjectType();
+ /**
+ * Returns true when test has to check if Managed Class exists
+ * @return
+ */
+ protected abstract boolean getCheckForExistingManagedBeanClass();
+
+}
+
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -200,6 +200,10 @@
IDELabel.Menu.ADD_JSF_CAPABILITIES).click();
}
+ bot.shell("Add JSF Capabilities").activate();
+ bot.button(WidgetVariables.NEXT_BUTTON).click();
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+
delay();
assertTrue("JSF Capabilities were not added to project "
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -10,418 +10,36 @@
******************************************************************************/
package org.jboss.tools.jsf.ui.bot.test.smoke;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorBot;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorPartMatcher;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorUtil;
-import org.jboss.tools.ui.bot.ext.Assertions;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
-import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
-/** Test Editing of faces-config.xml file
+/** Test Editing of faces-config.xml file for JSF 1.2 project
* @author Vladimir Pakan
*
*/
-public class FacesConfigEditingTest extends JSFAutoTestCase{
+public class FacesConfigEditingTest extends AbstractFacesConfigEditingTest{
- private static final String FACES_CONFIG_FILE_NAME = "faces-config.xml";
- private SWTBotEditor facesConfigEditor;
- private String originalContent;
- private SWTBotEditorExt facesConfigEditorExt;
- private SWTBotExt botExt;
- private SWTBotGefEditPart gefObjectAddedViaViewTool = null;
- private SWTBotGefEditPart gefObjectAddedViaDnDTool = null;
- private SWTBotGefViewer gefViewer = null;
-
@Override
- public void setUp() throws Exception {
- super.setUp();
- facesConfigEditor = eclipse.openFile(VPEAutoTestCase.JBT_TEST_PROJECT_NAME,
+ protected SWTBotEditor getFacesConfigEditor() {
+ return eclipse.openFile(getTestProjectName(),
"WebContent",
"WEB-INF",
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- originalContent = facesConfigEditor.toTextEditor().getText();
- facesConfigEditorExt = new SWTBotEditorExt(facesConfigEditor.toTextEditor().getReference(),bot);
- botExt = new SWTBotExt();
}
-
@Override
- public void tearDown() throws Exception {
- if (gefViewer != null){
- if (gefObjectAddedViaViewTool != null){
- gefObjectAddedViaViewTool.click();
- bot.sleep(Timing.time1S());
- gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
- confirmViewDelete();
- bot.sleep(Timing.time1S());
- }
- if (gefObjectAddedViaDnDTool != null){
- gefObjectAddedViaDnDTool.click();
- bot.sleep(Timing.time1S());
- gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
- confirmViewDelete();
- bot.sleep(Timing.time1S());
- }
- }
- if (facesConfigEditor != null) {
- facesConfigEditor.toTextEditor().setText(originalContent);
- facesConfigEditor.saveAndClose();
- bot.sleep(Timing.time1S());
- }
- super.tearDown();
+ protected String getTestProjectName(){
+ return VPEAutoTestCase.JBT_TEST_PROJECT_NAME;
}
- /**
- * Test Managed Bean editing
- */
- public void testManagedBean(){
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
- SWTBot editorBot = facesConfigEditorExt.bot();
- SWTBotTree tree = editorBot.tree();
- final String managedBeanName = "TestBean";
- final String managedBeanClass = "TestBeanClass";
- SWTBotTreeItem tiFacesConfigXml = tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- SWTBotTreeItem tiManagedbean = tiFacesConfigXml.getNode(IDELabel.FacesConfigEditor.MANAGED_BEANS_NODE);
- tiManagedbean.select();
- bot.sleep(Timing.time1S());
- // Add managed bean
- editorBot.button(IDELabel.Button.ADD).click();
- bot.shell(IDELabel.Shell.NEW_MANAGED_BEAN).activate();
- bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass);
- bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_NAME_LABEL)
- .setText(managedBeanName);
- bot.button(IDELabel.Button.FINISH).click();
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- assertFacesConfigXmlHasNoErrors(botExt);
- final String selectedNode = tree.selection().get(0,0);
- assertTrue ("Selected node has to have label '" + managedBeanName +"'\n" +
- "but has '" + selectedNode + "'.",
- selectedNode.equals(managedBeanName));
- Assertions.assertFileExistsInWorkspace(managedBeanClass + ".java",
- JBT_TEST_PROJECT_NAME,"JavaSource");
- Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
- "<managed-bean><managed-bean-name>" + managedBeanName + "</managed-bean-name>" +
- "<managed-bean-class>" + managedBeanClass + "</managed-bean-class>" +
- "<managed-bean-scope>request</managed-bean-scope></managed-bean>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // Modify Managed Bean
- editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass + "xxqq");
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- assertFacesConfigXmlHasErrors(botExt);
- editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass);
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- // Delete Managed Bean
- tiManagedbean.select();
- editorBot.table().select(managedBeanName);
- editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.checkBox(IDELabel.FacesConfigEditor.DELETE_JAVA_SOURCE_CHECK_BOX).select();
- bot.button(IDELabel.Button.OK).click();
- boolean managedBeanWasDeleted = false;
- try{
- editorBot.table().select(managedBeanName);
- } catch (WidgetNotFoundException wnfe){
- managedBeanWasDeleted = true;
- } catch (IllegalArgumentException iae){
- managedBeanWasDeleted = true;
- }
- assertTrue("Managed bean " + managedBeanName + " was not deleted properly.",
- managedBeanWasDeleted);
- Assertions.assertFileNotExistsInWorkspace(managedBeanClass + ".java",
- JBT_TEST_PROJECT_NAME,"JavaSource");
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<managed-bean-name>" + managedBeanName + "</managed-bean-name>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<managed-bean-class>" + managedBeanClass + "</managed-bean-class>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ @Override
+ protected void intializeTestProject() {
+ // This test is using default JSF 1.2 project which is already created
}
- /**
- * Tests Component editing
- */
- public void testComponent (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.COMPONENTS_NODE,
- IDELabel.Shell.ADD_COMPONENT,
- IDELabel.FacesConfigEditor.NEW_COMPONENT_TYPE_LABEL,
- "TestComponentType",
- IDELabel.FacesConfigEditor.NEW_COMPONENT_CLASS_LABEL,
- "TestComponentClass",
- "component",
- "component-type",
- "component-class",
- true);
+ @Override
+ protected TestProjectType getTestProjectType() {
+ return TestProjectType.JSF;
}
- /**
- * Tests Converter editing
- */
- public void testConverter (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.CONVERTERS_NODE,
- IDELabel.Shell.ADD_CONVERTER,
- IDELabel.FacesConfigEditor.NEW_CONVERTER_ID_LABEL,
- "TestConverterID",
- IDELabel.FacesConfigEditor.NEW_CONVERTER_CLASS_LABEL,
- "TestConverterClass",
- "converter",
- "converter-id",
- "converter-class",
- true);
+ @Override
+ protected boolean getCheckForExistingManagedBeanClass() {
+ return true;
}
- /**
- * Tests Referenced Bean editing
- */
- public void testReferencedBean (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.REFERENCED_BEAN_NODE,
- IDELabel.Shell.ADD_REFERENCED_BEAN,
- IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_NAME_LABEL,
- "TestReferencedBeanName",
- IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_CLASS_LABEL,
- "TestReferencedBeanClass",
- "referenced-bean",
- "referenced-bean-name",
- "referenced-bean-class",
- true);
- }
- /**
- * Tests Render Kit editing
- */
- public void testRenderKit (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.RENDER_KITS_NODE,
- IDELabel.Shell.ADD_RENDER_KIT,
- IDELabel.FacesConfigEditor.NEW_RENDER_KIT_ID_LABEL,
- "TestRenderKitID",
- IDELabel.FacesConfigEditor.NEW_RENDER_KIT_CLASS_LABEL,
- "TestRenderKitClass",
- "render-kit",
- "render-kit-id",
- "render-kit-class",
- false);
- }
- /**
- * Tests Validator editing
- */
- public void testValidator (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.VALIDATOR_NODE,
- IDELabel.Shell.ADD_VALIDATOR,
- IDELabel.FacesConfigEditor.NEW_VALIDATOR_ID_LABEL,
- "TestValidatorID",
- IDELabel.FacesConfigEditor.NEW_VALIDATOR_CLASS_LABEL,
- "TestValidatorClass",
- "validator",
- "validator-id",
- "validator-class",
- false);
- }
- /**
- * Asserts if faces-config.xml has no errors
- * @param botExt
- */
- private static void assertFacesConfigXmlHasNoErrors (SWTBotExt botExt){
-
- SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null, FacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
- boolean areThereNoErrors = ((errors == null) || (errors.length == 0));
- assertTrue("There are errors in Problems view: " +
- (areThereNoErrors ? "" : errors[0].getText()),
- areThereNoErrors);
- }
- /**
- * Asserts if faces-config.xml has errors
- * @param botExt
- */
- private static void assertFacesConfigXmlHasErrors (SWTBotExt botExt){
-
- SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null, FacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
- boolean areThereErrors = ((errors != null) && (errors.length > 0));
- assertTrue("There are missing errors in Problems view for " + FacesConfigEditingTest.FACES_CONFIG_FILE_NAME + " file.",
- areThereErrors);
- }
- /**
- * Check editing of particular tree node within Face Config Editor Tree
- * @param treeNodeLabel
- * @param addWizardTitle
- * @param nameTextLabel
- * @param typeTextValue
- * @param classTextLabel
- * @param classTextValue
- * @param xmlNodeName
- * @param nameXmlNodeName
- * @param classXmlNodeName
- * @param checkForValdiationErrors
- */
- private void checkFacesConfigNodeEditing(String treeNodeLabel,
- String addWizardTitle,
- String nameTextLabel,
- String typeTextValue,
- String classTextLabel,
- String classTextValue,
- String xmlNodeName,
- String nameXmlNodeName,
- String classXmlNodeName,
- boolean checkForValdiationErrors){
-
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
- SWTBot editorBot = facesConfigEditorExt.bot();
- SWTBotTree tree = editorBot.tree();
- SWTBotTreeItem tiFacesConfigXml = tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- SWTBotTreeItem tiNodeToCheck = tiFacesConfigXml.getNode(treeNodeLabel);
- tiNodeToCheck.select();
- bot.sleep(Timing.time1S());
- // Add Node
- editorBot.button(IDELabel.Button.ADD).click();
- bot.shell(addWizardTitle).activate();
- bot.textWithLabel(nameTextLabel).setText(typeTextValue);
- bot.textWithLabel(classTextLabel).setText(classTextValue);
- bot.button(IDELabel.Button.FINISH).click();
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- if (checkForValdiationErrors){
- assertFacesConfigXmlHasErrors(botExt);
- }
- final String selectedNode = tree.selection().get(0,0);
- assertTrue ("Selected node has to have label '" + typeTextValue +"'\n" +
- "but has '" + selectedNode + "'.",
- selectedNode.equals(typeTextValue));
- Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
- "<" + xmlNodeName + ">" +
- "<" + nameXmlNodeName + ">" + typeTextValue + "</" + nameXmlNodeName +">" +
- "<" + classXmlNodeName + ">" + classTextValue + "</" + classXmlNodeName +">" +
- "</" + xmlNodeName + ">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // Delete Node
- tiNodeToCheck.select();
- editorBot.table().select(typeTextValue);
- editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.button(IDELabel.Button.OK).click();
- boolean nodeWasDeleted = false;
- try{
- editorBot.table().select(typeTextValue);
- } catch (WidgetNotFoundException wnfe){
- nodeWasDeleted = true;
- } catch (IllegalArgumentException iae){
- nodeWasDeleted = true;
- }
- assertTrue(typeTextValue + " was not deleted properly.",
- nodeWasDeleted);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<" + nameXmlNodeName + ">" + typeTextValue + "</" + nameXmlNodeName +">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<" + classXmlNodeName + ">" + classTextValue + "</" + classXmlNodeName +">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- }
- /**
- * Test editing via Diagram tab
- */
- public void testDiagramEditing(){
- final int verticalSpacing = 100;
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.DIAGRAM_TAB_LABEL);
- final FacesConfigGefEditorBot gefEditorBot = new FacesConfigGefEditorBot(facesConfigEditorExt.getReference());
- gefViewer = gefEditorBot.getViewer();
- SWTBotGefEditPart mainPart = gefViewer.mainEditPart();
- // add View to diagram via pallete tool
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_VIEW_TEMPLATE_TOOL);
- SWTBotGefEditPart gefObjectPart = mainPart.descendants(new FacesConfigGefEditorPartMatcher("/pages/inputUserName.jsp")).get(0);
- gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).x,
- FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).y + verticalSpacing);
- final String viewAddedViaToolName = "addedViaTool";
- handleNewViewWizard(viewAddedViaToolName + ".jsp");
- bot.sleep(Timing.time3S());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- assertFacesConfigXmlHasNoErrors(botExt);
- Assertions.assertFileExistsInWorkspace(viewAddedViaToolName + ".jsp",
- JBT_TEST_PROJECT_NAME,"WebContent");
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
- gefObjectPart.click();
- bot.sleep(Timing.time1S());
- gefObjectAddedViaViewTool = mainPart.descendants(new FacesConfigGefEditorPartMatcher("/" + viewAddedViaToolName + ".jsp")).get(0);
- gefObjectAddedViaViewTool.click();
- bot.sleep(Timing.time1S());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
- "<navigation-case><from-outcome>" + viewAddedViaToolName +
- "</from-outcome><to-view-id>/" + viewAddedViaToolName + ".jsp</to-view-id></navigation-case>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // add View to Diagram via D'n'D
- final String dndPageName = "testDnDPage";
- createJspPage(dndPageName + ".jsp");
- facesConfigEditor.show();
- facesConfigEditor.setFocus();
- SWTBotTreeItem tiPage = SWTEclipseExt.selectTreeLocation(open.viewOpen(ActionItem.View.JBossToolsWebWebProjects.LABEL).bot(),
- VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent","pages",dndPageName + ".jsp");
- DragAndDropHelper.dnd((TreeItem)tiPage.widget, (FigureCanvas) gefEditorBot.getControl());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- assertFacesConfigXmlHasNoErrors(botExt);
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
- gefObjectPart.click();
- bot.sleep(Timing.time1S());
- gefObjectAddedViaDnDTool = mainPart.descendants(new FacesConfigGefEditorPartMatcher("/pages/" + dndPageName + ".jsp")).get(0);
- gefObjectAddedViaDnDTool.click();
- bot.sleep(Timing.time1S());
- gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).x,
- FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).y + verticalSpacing);
- gefViewer.clickContextMenu(IDELabel.Menu.AUTO_LAYOUT);
- bot.shell(IDELabel.Shell.AUTO_LAYOUT).activate();
- bot.button(IDELabel.Button.OK).click();
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
- "<navigation-case><from-outcome>" + dndPageName +
- "</from-outcome><to-view-id>/pages/" + dndPageName + ".jsp</to-view-id></navigation-case>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- }
- /**
- * Handle adding new View
- * @param fromViewID
- */
- private void handleNewViewWizard(String fromViewID){
- SWTBot dialogBot = bot.shell(IDELabel.Shell.NEW_VIEW).activate().bot();
- dialogBot.textWithLabel(IDELabel.NewViewDialog.FROM_VIEW_ID_TEXT_LABEL)
- .setText(fromViewID);
- dialogBot.checkBox(IDELabel.NewViewDialog.CREATE_FILE_ON_DISK_CHECKBOX_LABEL)
- .select();
- dialogBot.button(IDELabel.Button.FINISH).click();
-
- }
- /**
- * Returns XNL Source striped from spaces, tabs and EOL
- *
- * @return String
- */
- protected static String stripXMLSourceText(String editorText) {
- return editorText.replaceAll("\n", "").replaceAll("\t", "")
- .replaceAll("\b", "").replaceAll(" ", "").replaceAll("\r", "")
- .replaceAll("\f", "");
- }
- /**
- * Confirm deletion of View from Diagram Editor
- */
- private void confirmViewDelete(){
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.checkBox(IDELabel.FacesConfigEditor.DELETE_FILE_FROM_DISK_CHECK_BOX).select();
- bot.button(IDELabel.Button.OK).click();
- }
}
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+/** Test Editing of faces-config.xml file for JSF 1.2 project
+ * @author Vladimir Pakan
+ *
+ */
+public class FacesConfigEditingTestJSF2 extends AbstractFacesConfigEditingTest{
+
+ @Override
+ protected SWTBotEditor getFacesConfigEditor() {
+ return eclipse.openFile(getTestProjectName(),
+ "WebContent",
+ "WEB-INF",
+ FacesConfigEditingTestJSF2.FACES_CONFIG_FILE_NAME);
+ }
+ @Override
+ protected String getTestProjectName(){
+ return JSF2_TEST_PROJECT_NAME;
+ }
+ @Override
+ protected void intializeTestProject() {
+ createJSF2Project(getTestProjectName());
+ }
+ @Override
+ protected TestProjectType getTestProjectType() {
+ return TestProjectType.JSF2;
+ }
+ @Override
+ protected boolean getCheckForExistingManagedBeanClass() {
+ return false;
+ }
+}
+
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -45,7 +45,6 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.IEditorReference;
import org.hamcrest.Description;
-import org.jboss.tools.struts.ui.bot.test.utils.DndSupport;
import org.jboss.tools.struts.ui.bot.test.utils.PartMatcher;
import org.jboss.tools.struts.ui.bot.test.utils.StrutsUIEditorBot;
import org.jboss.tools.struts.ui.bot.test.utils.ValidationUIEditorBot;
@@ -58,6 +57,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
import org.jboss.tools.ui.bot.ext.parts.SWTBotBrowserExt;
import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -158,11 +158,11 @@
Widget w1 = s.widget;
s.select();
- DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+ DragAndDropHelper.dnd((TreeItem) w1, (FigureCanvas) c);
s = webRootNode.getNode("pages").getNode("greeting.jsp");
s.select();
w1 = s.widget;
- DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+ DragAndDropHelper.dnd((TreeItem) w1, (FigureCanvas) c);
bot.sleep(500);
ge.clickContextMenu("Auto-Layout");
SWTBotShell sh = bot.activeShell();
@@ -375,7 +375,7 @@
sh.bot().button("Finish").click();
SWTBotTreeItem item = projectNode.getNode("Resource Bundles").getNode("sample.applResources");
nodeContextMenu(tree, item, "New", "Default Error Messages").click();
- DndSupport.dnd(item.widget, config.getNode("resources").widget);
+ DragAndDropHelper.dnd(item.widget, config.getNode("resources").widget);
nodeContextMenu(tree, projectNode.expandNode("Validation").getNode("validation.xml"), "Open").click();
SWTBotEditor editor = bot.activeEditor();
@@ -392,7 +392,7 @@
return config.expandNode("form-beans");
}
}).getNode("GetNameForm").select();
- DndSupport.dnd(item.widget, ti.widget);
+ DragAndDropHelper.dnd(item.widget, ti.widget);
ti = t.expandNode("formset (default)").getNode("GetNameForm").select();
vb.toolbarButton("Create Field").click();
sh = bot.activeShell();
Deleted: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.struts.ui.bot.test.utils;
-
-import java.awt.AWTException;
-import java.awt.Robot;
-import java.awt.event.InputEvent;
-import java.text.MessageFormat;
-
-import org.apache.log4j.Logger;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-
-/**
- * Drag and Drop implementation based on the last patch available
- * at https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271
- *
- * @author jlukas
- * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271#c10">Original Patch</a>
- */
-public class DndSupport {
-
- private static final Logger L = Logger.getLogger(DndSupport.class.getName());
- private static final int robotDelay = Integer.getInteger("org.jboss.tools.struts.ui.bot.test.dndDelay", 150);
-
- public static void dnd(final TreeItem ti, final TreeItem ti2) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti2.getDisplay().map(ti2.getParent(), null,
- ti2.getBounds());
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
- Geometry.centerPoint(r2));
- }
-
- public static void dnd(final TreeItem ti, final FigureCanvas fc) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return fc.getDisplay().map(fc.getParent(), null, fc.getBounds());
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
- Geometry.centerPoint(r2));
- }
-
- public static void dnd(final TreeItem ti, final Control fc, final int x,
- final int y) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Point r2 = UIThreadRunnable.syncExec(new Result<Point>() {
-
- public Point run() {
- L.info("xxx: " + fc.getLocation().x + ":"
- + fc.getLocation().y);
- return fc.getDisplay().map(fc, null, x, y);
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), r2);
- }
-
- /**
- *
- */
- private static void doDragAndDrop(final Point source, final Point dest) {
- L.info(MessageFormat.format(
- "Drag-and-dropping from ({0},{1}) to ({2},{3})", source.x,
- source.y, dest.x, dest.y));
- try {
- final Robot awtRobot = new Robot();
- awtRobot.setAutoDelay(robotDelay);
- // the x+10 motion is needed to let native functions register a drag
- // detect. It did not work under Windows
- // otherwise and has been reported to be required for linux, too.
- // But I could not test that.
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseMove(source.x, source.y);
- awtRobot.mousePress(InputEvent.BUTTON1_MASK);
- awtRobot.mouseMove((source.x + 10), source.y);
- }
- });
-
- // now pause the test until all runnables on the Display thread have
- // run this is necessary for the pick up
- // to register on linux
- waitForIdle(awtRobot);
-
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseMove((dest.x + 10), dest.y);
- awtRobot.mouseMove(dest.x, dest.y);
- }
- });
-
- waitForIdle(awtRobot);
-
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseRelease(InputEvent.BUTTON1_MASK);
- }
- });
- waitForIdle(awtRobot);
- } catch (final AWTException e) {
- L.info(e.getMessage(), e);
- throw new RuntimeException(e);
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- //ignore
- }
- }
-
- private static void waitForIdle(final Robot robot) {
- if (SWT.getPlatform().equals("gtk")) {
- robot.waitForIdle();
- }
- }
-}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-28 15:48:05 UTC (rev 36701)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-28 16:11:30 UTC (rev 36702)
@@ -169,10 +169,12 @@
public static final String SECURE_STORAGE = "Secure Storage";
public static final String ADD_JSF_PROJECT_TEMPLATE = "Add JSF Project Template";
public static final String NEW_MANAGED_BEAN = "New Managed Bean";
+ public static final String NEW_MANAGED_BEAN_JSF2 = "Managed Bean...";
public static final String ADD_COMPONENT = "Add Component";
public static final String ADD_CONVERTER = "Add Converter";
public static final String ADD_REFERENCED_BEAN = "Add Referenced Bean";
public static final String ADD_RENDER_KIT = "Add Render Kit";
+ public static final String ADD_RENDER_KIT_JSF2 = "Render Kit...";
public static final String ADD_VALIDATOR = "Add Validator";
public static final String NEW_VIEW = "New View";
public static final String AUTO_LAYOUT = "Auto Layout";
14 years
JBoss Tools SVN: r36701 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test: src/org/jboss/tools/cdi/bot/test and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-11-28 10:48:05 -0500 (Mon, 28 Nov 2011)
New Revision: 36701
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
Log:
BeansXML completion test added
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi 2011-11-28 15:48:05 UTC (rev 36701)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+ <>
+
+</beans>
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi 2011-11-28 15:48:05 UTC (rev 36701)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+<alternatives>
+ <stereotype>Component</stereotype>
+</alternatives>
+
+</beans>
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
+import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLCompletionTest;
import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLValidationTest;
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
-import org.jboss.tools.cdi.bot.test.jsf.NamedRefactoringTest;
import org.jboss.tools.cdi.bot.test.openon.FindObserverForEventTest;
import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
import org.jboss.tools.cdi.bot.test.quickfix.BeanValidationQuickFixTest;
@@ -49,7 +49,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 22min
+ * Suite duration: aprox. 24min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
@@ -57,23 +57,23 @@
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
// PerspectiveTest.class,
-// ConfigurationPresetTest.class,
-// FacetTest.class,
-// WizardTest.class,
-// BeansEditorTest.class,
- NamedRefactoringTest.class,
-// BeansXMLValidationTest.class,
-// BeansXMLCompletionTest.class,
-// StereotypeValidationQuickFixTest.class,
-// QualifierValidationQuickFixTest.class,
-// ScopeValidationQuickFixTest.class,
-// BeanValidationQuickFixTest.class,
-// InterceptorValidationQuickFixTest.class,
-// DecoratorValidationQuickFixTest.class,
-// IBindingValidationQuickFixTest.class,
-// OpenOnTest.class,
-// FindObserverForEventTest.class,
-// Seam3Test.class
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.class,
+// NamedRefactoringTest.class,
+ BeansXMLValidationTest.class,
+ BeansXMLCompletionTest.class,
+ StereotypeValidationQuickFixTest.class,
+ QualifierValidationQuickFixTest.class,
+ ScopeValidationQuickFixTest.class,
+ BeanValidationQuickFixTest.class,
+ InterceptorValidationQuickFixTest.class,
+ DecoratorValidationQuickFixTest.class,
+ IBindingValidationQuickFixTest.class,
+ OpenOnTest.class,
+ FindObserverForEventTest.class,
+ Seam3Test.class
})
public class CDIAllBotTests extends CDITestBase {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -11,20 +11,23 @@
package org.jboss.tools.cdi.bot.test.beansxml;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
-import org.junit.Ignore;
+import org.jboss.tools.ui.bot.ext.helper.ContentAssistHelper;
+import org.jboss.tools.ui.bot.ext.parts.ContentAssistBot;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -45,6 +48,21 @@
private static final Logger LOGGER = Logger
.getLogger(BeansXMLCompletionTest.class.getName());
+
+ private static final List<String> BEANS_XML_TAGS = Arrays.asList(
+ "alternatives", "decorators", "interceptors");
+ private static final List<String> INTERCEPTOR_NAMES = Arrays.asList(
+ "I1", "I2", "I3");
+ private static final List<String> DECORATORS_NAMES = Arrays.asList(
+ "D1", "D2", "D3");
+ private static final List<String> ALTERNATIVES_NAMES = Arrays.asList(
+ "A1", "A2", "A3");
+ private static final List<String> STEREOTYPES_NAMES = Arrays.asList(
+ "S1", "S2", "S3");
+ private static final String BEANS_XML = "beans.xml";
+ private static final String CLASS_END_TAG = "</class>";
+ private static final String STEREOTYPE_END_TAG = "</stereotype>";
+
@Override
public String getProjectName() {
@@ -53,97 +71,146 @@
@Test
public void testPossibleCompletionInBeansXML() {
- beansHelper.createClearBeansXML(getPackageName());
+ beansHelper.createClearBeansXML(getProjectName());
LOGGER.info("Clear beans.xml was created");
- List<String> autoCompletion = getAutoCompletion(3, 0, "<");
-
- assertTrue("Error: Size of auto completion proposals should be 3 " +
- "instead of " + autoCompletion.size(), autoCompletion.size() == 3);
+ checkAutoCompletion(3, 0, "<>", BEANS_XML, BEANS_XML_TAGS);
}
- @Ignore
+
@Test
public void testInterceptorsCompletion() {
- prepareInterceptors();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.INTERCEPTOR, getPackageName(),
+ INTERCEPTOR_NAMES, null, false);
+ beansHelper.createBeansXMLWithInterceptor(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with interceptors tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String interceptor : INTERCEPTOR_NAMES) {
+ assertTrue(proposalList.contains(interceptor + " - " + getPackageName()));
+ }
}
- @Ignore
+
@Test
public void testDecoratorsCompletion() {
- prepareDecorators();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.DECORATOR, getPackageName(),
+ DECORATORS_NAMES, "java.util.Set", false);
+
+ beansHelper.createBeansXMLWithDecorator(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with decorators tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String decorator : DECORATORS_NAMES) {
+ assertTrue(proposalList.contains(decorator + " - " + getPackageName()));
+ }
}
- @Ignore
+
@Test
- public void testAlternativesCompletion() {
+ public void testStereotypesCompletion() {
- prepareAlternatives();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.STEREOTYPE, getPackageName(),
+ STEREOTYPES_NAMES, "alternative", false);
+
+ beansHelper.createBeansXMLWithStereotype(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with stereotype tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, STEREOTYPE_END_TAG, 0, 0);
+ for (String stereotype : STEREOTYPES_NAMES) {
+ assertTrue(proposalList.contains(stereotype + " - " + getPackageName()));
+ }
}
-
- private void prepareInterceptors() {
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor1",
- getPackageName(), null);
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor2",
- getPackageName(), null);
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor3",
- getPackageName(), null);
-
- }
- private void prepareDecorators() {
-
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator1",
- getPackageName(), "java.util.Set");
+ @Test
+ public void testAlternativesCompletion() {
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator2",
- getPackageName(), "java.util.Set");
+ wizard.createCDIComponents(CDIWizardType.BEAN, getPackageName(),
+ ALTERNATIVES_NAMES, "alternative", false);
+
+ beansHelper.createBeansXMLWithAlternative(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with alternative tag was created");
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator3",
- getPackageName(), "java.util.Set");
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String alternative : ALTERNATIVES_NAMES) {
+ assertTrue(proposalList.contains(alternative + " - " + getPackageName()));
+ }
}
- private void prepareAlternatives() {
+ @Test
+ public void testNonSupportedComponentCompletion() {
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative1",
- getPackageName(), "alternative");
+ String[] components = {"AL1", "Q1", "B1", "IB1", "Sc1"};
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative2",
- getPackageName(), "alternative");
+ wizard.createCDIComponent(CDIWizardType.ANNOTATION_LITERAL, components[0],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, components[1],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.BEAN, components[2],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR_BINDING, components[3],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.SCOPE, components[4],
+ getPackageName(), null);
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative3",
- getPackageName(), "alternative");
+ beansHelper.createClearBeansXMLWithEmptyTag(getProjectName());
+ LOGGER.info("Clear beans.xml with empty tag was created");
+ List<String> proposalList = getProposalList(BEANS_XML, "<>", 1, 0);
+ List<String> nonSupportedComponents = Arrays.asList(components);
+
+ for (String nonSupportedComponent : nonSupportedComponents) {
+ for (String proposalOption : proposalList) {
+ assertFalse((nonSupportedComponent + " - " + getPackageName()).
+ equals(proposalOption));
+ }
+ }
+
}
-
- //not complete yet
- private List<String> getAutoCompletion(int row, int column, String text) {
- List<String> listOfCompletion = new ArrayList<String>();
+
+ /**
+ * Method checks auto completion proposals. First, it
+ * types provided text on location provided by parameters.
+ * Then checks all items in proposal list by
+ * ContentAssistHelper.checkContentAssistContent() method.
+ * At the end, it removes inserted text(due to possible formating error)
+ * @param row
+ * @param column
+ * @param text
+ * @param expectedProposalList
+ */
+ private void checkAutoCompletion(int row, int column, String text, String editorTitle,
+ List<String> expectedProposalList) {
getEd().navigateTo(row, column);
- bot.sleep(Timing.time500MS());
getEd().typeText(text);
- bot.sleep(Timing.time500MS());
- getEd().pressShortcut(Keystrokes.CTRL, Keystrokes.SPACE);
+ ContentAssistHelper.checkContentAssistContent(bot,
+ editorTitle, text, 1, 0, expectedProposalList);
+ editResourceUtil.replaceInEditor(text, "");
+ }
+
+ /**
+ * Method returns proposal list for given text on given position
+ * @param editorTitle
+ * @param textToSelect
+ * @param selectionOffset
+ * @param selectionLength
+ * @return
+ */
+ private List<String> getProposalList(String editorTitle, String textToSelect, int selectionOffset,
+ int selectionLength) {
+ SWTJBTExt.selectTextInSourcePane(bot,
+ editorTitle, textToSelect, selectionOffset, selectionLength,
+ 0);
+
bot.sleep(Timing.time1S());
- for (int i = 0; i < bot.table().rowCount(); i++) {
- listOfCompletion.add(bot.table().getTableItem(i).getText());
- }
- return listOfCompletion;
+
+ SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
+ ContentAssistBot contentAssist = editor.contentAssist();
+ List<String> currentProposalList = contentAssist.getProposalList();
+ return currentProposalList;
}
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -48,7 +48,7 @@
* @author Lukas Jungmann
* @author jjankovi
*/
-@Require(clearProjects = true, perspective = "Java EE",
+@Require(clearProjects = false, perspective = "Java EE",
server = @Server(state = ServerState.NotRunning,
version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -11,28 +11,40 @@
package org.jboss.tools.cdi.bot.test.jsf;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.JSFEnvironment;
import org.jboss.tools.cdi.bot.test.annotations.JSFTemplate;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewJSFProjectWizard;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewXHTMLFileWizard;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.XHTMLDialogWizard;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.junit.Before;
public class JSFTestBase extends CDITestBase {
+ private static final Logger LOGGER = Logger.getLogger(JSFTestBase.class.getName());
+
private JSFEnvironment env = JSFEnvironment.JSF_20;
+ private JSFTemplate template = JSFTemplate.BLANK_LIBS;
+
public JSFEnvironment getEnv() {
return env;
}
+ public JSFTemplate getTemplate() {
+ return template;
+ }
+
@Before
public void checkAndCreateProject() {
if (!projectHelper.projectExists(getProjectName())) {
- createJSFProjectWithCDISupport(getProjectName(), getEnv());
+ createJSFProjectWithCDISupport(getProjectName(), getEnv(), getTemplate());
}
}
@@ -44,20 +56,46 @@
util.waitForNonIgnoredJobs();
setEd(bot.activeEditor().toTextEditor());
}
+
+ protected void contextMenuForTextInEditor(final String text,
+ final String... menu) {
+ assert menu.length > 0;
+ SWTJBTExt.selectTextInSourcePane(bot, getEd().getTitle(),
+ text, 0, text.length());
+ bot.sleep(Timing.time2S());
+
+ getEd().toTextEditor().contextMenu(menu[0]);
+ bot.sleep(Timing.time3S());
+ util.waitForNonIgnoredJobs();
+
+ }
- private void createJSFProjectWithCDISupport(String projectName, JSFEnvironment env) {
+ private void createJSFProjectWithCDISupport(String projectName, JSFEnvironment env,
+ JSFTemplate template) {
- createJSFProject(projectName, env);
+ createJSFProject(projectName, env, template);
projectHelper.addCDISupport(projectName);
}
- private void createJSFProject(String projectName, JSFEnvironment env) {
+ private void createJSFProject(String projectName, JSFEnvironment env,
+ JSFTemplate template) {
new NewJSFProjectWizard().run().
setName(getProjectName()).
setEnvironment(env).
- setJSFTemplate(JSFTemplate.BLANK_LIBS).finish();
- util.waitForNonIgnoredJobs();
+ setJSFTemplate(template).
+ finish();
+ /*
+ * workaround for non Web Perspective, click No button
+ * to not change perspective to Web Perspectives
+ *
+ */
+ try {
+ bot.button("No").click();
+ } catch (WidgetNotFoundException exc) {
+ log.info("There is no dialog to change perspective.");
+ }
+ util.waitForNonIgnoredJobs();
}
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -14,7 +14,6 @@
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
@@ -23,26 +22,26 @@
import org.junit.runners.Suite.SuiteClasses;
/**
- * Test operates on EL named refactoring
+ * Test operates on @Named refactoring
*
* @author Jaroslav Jankovic
*
*/
-@Require(clearProjects = true, perspective = "Web Development",
+@Require(clearProjects = true, perspective = "Java EE",
server = @Server(state = ServerState.NotRunning,
version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
public class NamedRefactoringTest extends JSFTestBase {
-
+
@Override
public String getProjectName() {
return "CDIRefactoring";
}
@Test
- public void testNamedAnnotation() {
+ public void testNamedAnnotationRefactor() {
wizard.createCDIComponent(CDIWizardType.BEAN, "ManagedBean", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(NamedRefactoringTest.class.
@@ -52,8 +51,10 @@
editResourceUtil.replaceClassContentByResource(NamedRefactoringTest.class.
getResourceAsStream("/resources/jsf/index.xhtml.cdi"), false);
+ bot.editorByTitle("ManagedBean.java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ contextMenuForTextInEditor("@Named(\"bean\")", "Open With", "Other...");
-
}
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -19,11 +19,11 @@
public abstract class AbstractValidationProvider implements ValidationErrorProvider {
- protected Map<String, ArrayList<String>> validationErrors = null;
- protected ArrayList<String> warningsForAnnotationType = null;
- protected ArrayList<String> errorsForAnnotationType = null;
- protected ArrayList<CDIAnnotationsType> warningsAnnotation = null;
- protected ArrayList<CDIAnnotationsType> errorsAnnotation = null;
+ protected static Map<String, ArrayList<String>> validationErrors = null;
+ protected static ArrayList<String> warningsForAnnotationType = null;
+ protected static ArrayList<String> errorsForAnnotationType = null;
+ protected static ArrayList<CDIAnnotationsType> warningsAnnotation = null;
+ protected static ArrayList<CDIAnnotationsType> errorsAnnotation = null;
public AbstractValidationProvider() {
validationErrors = new LinkedHashMap<String, ArrayList<String>>();
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -57,4 +57,5 @@
* @return
*/
ArrayList<CDIAnnotationsType> getAllErrorsAnnotation();
+
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -16,6 +16,7 @@
import org.jboss.tools.cdi.bot.test.annotations.BeansXMLValidationErrors;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
+import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
/**
@@ -121,9 +122,20 @@
}
/**
+ * Methods creates beans.xml with empty tag <> for entered project.
+ * @param projectName
+ */
+ public void createClearBeansXMLWithEmptyTag(String projectName) {
+
+ createBeansXMLWithContent(projectName, "/resources/beansXML/" +
+ "beansXmlWithEmptyTag.xml.cdi");
+ }
+
+ /**
* Methods creates beans.xml with interceptor tags in it for entered project.
* Package and interceptor component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -132,15 +144,21 @@
String className) {
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
- "beansXmlWithInterceptor.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ "beansXmlWithInterceptor.xml.cdi");
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ }
}
/**
* Methods creates beans.xml with decorator tags in it for entered project.
* Package and decorator component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -150,13 +168,43 @@
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
"beansXmlWithDecorator.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ }
+
}
/**
+ * Methods creates beans.xml with stereotype tags in it for entered project.
+ * Package and stereotype component name which should be showed in tag is
+ * determined by parameters. If className is null, then Component text will be
+ * removed
+ * @param projectName
+ * @param packageName
+ * @param className
+ */
+ public void createBeansXMLWithStereotype(String projectName, String packageName,
+ String className) {
+
+ createBeansXMLWithContent(projectName, "/resources/beansXML/" +
+ "beansXmlWithStereotype.xml.cdi");
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<stereotype>Component</stereotype>",
+ "<stereotype></stereotype>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ }
+
+ }
+
+ /**
* Methods creates beans.xml with alternative tags in it for entered project.
* Package and alternative bean component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -166,7 +214,12 @@
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
"beansXmlWithAlternative.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." + className);
+ }
}
/**
@@ -195,6 +248,7 @@
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
.getResourceAsStream(path),
false);
+ bot.sleep(Timing.time500MS());
}
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.bot.test.uiutils;
+import java.util.List;
+
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBaseExt;
@@ -69,6 +71,32 @@
}
/**
+ * Method creates larger number("amount") of the same component with using
+ * List of class names
+ * @param component
+ * @param packageBaseName
+ * @param classNames
+ * @param necessaryParam
+ * @param differentPackages
+ */
+ public void createCDIComponents(CDIWizardType component, String packageBaseName,
+ List<String> classNames, String necessaryParam, boolean differentPackages) {
+ if (classNames == null) {
+ throw new IllegalArgumentException("List with class names should not be " +
+ "null");
+ }
+ if (classNames.size() == 0) {
+ throw new IllegalArgumentException("List with class names should not be " +
+ "empty");
+ }
+ for (int i = 0; i < classNames.size(); i++) {
+ String packageName = (differentPackages) ? packageBaseName + i : packageBaseName;
+ createCDIComponent(component, classNames.get(i), packageName, necessaryParam);
+ }
+
+ }
+
+ /**
* Method that actually creates CDI component according to parameter
* @param component
* @param name
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -40,5 +40,5 @@
}
});
}
-
+
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -35,23 +37,24 @@
}
public DynamicWebProjectWizard setCDIFacet() {
- clickButton("Modify...");
- SWTBot bot = bot().shell("Project Facets").bot();
- setCDIFacetInFacets(bot);
+ clickButton("Modify...");
+ setCDIFacetInFacets(bot());
bot().sleep(Timing.time1S());
return this;
}
private void setCDIFacetInFacets(SWTBot bot) {
- SWTBotTree tree= bot.tree();
+ assertTrue(bot.activeShell().getText().equals("Project Facets"));
+ SWTBot facetsBot = bot.activeShell().bot();
+ SWTBotTree tree= facetsBot.tree();
for (SWTBotTreeItem ti: tree.getAllItems()) {
if (ti.cell(0).contains("CDI (Contexts and Dependency Injection)")) {
ti.check();
break;
}
}
- bot.sleep(Timing.time1S());
- bot.button("OK").click();
+ facetsBot.sleep(Timing.time1S());
+ facetsBot.button("OK").click();
}
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -33,7 +33,9 @@
}
public JSFWebProjectWizard setJSFTemplate(JSFTemplate template) {
- setTextInCombobox("Template*", template.getName());
+ if (canCheckInCombobox("Template*", template.getName())) {
+ setTextInCombobox("Template*", template.getName());
+ }
return this;
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-28 15:44:55 UTC (rev 36700)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-28 15:48:05 UTC (rev 36701)
@@ -82,13 +82,22 @@
t.setFocus();
t.setText(text);
}
+
+ protected void setTextInCombobox(String combobox, String text) {
+ bot().comboBoxWithLabel(combobox).setSelection(text);
+ bot().sleep(Timing.time500MS());
+ }
protected boolean canClick(String button) {
return bot().button(button).isEnabled();
}
- protected void setTextInCombobox(String combobox, String text) {
- bot().comboBoxWithLabel(combobox).setSelection(text);
- bot().sleep(Timing.time500MS());
+ protected boolean canCheckInCombobox(String combobox, String text) {
+ for (int i = 0; i < bot().comboBoxWithLabel(combobox).itemCount(); i++) {
+ if (bot().comboBoxWithLabel(combobox).items()[i].equals(text)) {
+ return true;
+ }
+ }
+ return false;
}
}
14 years
JBoss Tools SVN: r36700 - trunk/openshift/plugins/org.jboss.tools.openshift.express.client.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2011-11-28 10:44:55 -0500 (Mon, 28 Nov 2011)
New Revision: 36700
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
Log:
Fixing Openshift wizard cache issues
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
14 years
JBoss Tools SVN: r36699 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2011-11-28 10:40:56 -0500 (Mon, 28 Nov 2011)
New Revision: 36699
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
Log:
Typo
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-11-28 15:04:18 UTC (rev 36698)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-11-28 15:40:56 UTC (rev 36699)
@@ -53,7 +53,7 @@
private CredentialsWizardPageModel model;
public CredentialsWizardPage(IWizard wizard, ImportProjectWizardModel wizardModel) {
- super("Server connetion", "Please provide the credentails of your user account on OpenShift Express",
+ super("Server connection", "Please provide the credentails of your user account on OpenShift Express",
"Server Connection", wizard);
this.model = new CredentialsWizardPageModel(wizardModel);
}
14 years
JBoss Tools SVN: r36698 - in trunk: examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-11-28 10:04:18 -0500 (Mon, 28 Nov 2011)
New Revision: 36698
Added:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/xpl/
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/xpl/MavenProjectWizardArchetypeParametersPage.java
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-9776 : New UI for Maven Archetype Wizard
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -484,15 +484,15 @@
try {
shell = new Shell(PlatformUI.getWorkbench().getDisplay());
new Browser(shell, SWT.NONE);
- isInternalWebBrowserAvailable = new Boolean(true);
+ isInternalWebBrowserAvailable = Boolean.TRUE.booleanValue();
return true;
} catch (Throwable t) {
try {
new Browser(shell, SWT.WEBKIT);
- isInternalWebBrowserAvailable = new Boolean(true);
+ isInternalWebBrowserAvailable = Boolean.TRUE.booleanValue();
return true;
} catch (Throwable e) {
- isInternalWebBrowserAvailable = new Boolean(false);
+ isInternalWebBrowserAvailable = Boolean.FALSE.booleanValue();
return false;
}
} finally {
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -95,4 +95,8 @@
return true;
}
+ @Override
+ public String toString() {
+ return getName();
+ }
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -261,4 +261,8 @@
this.defaultProfiles = defaultProfiles;
}
+ @Override
+ public String toString() {
+ return getName();
+ }
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF 2011-11-28 15:04:18 UTC (rev 36698)
@@ -11,7 +11,11 @@
org.jboss.tools.project.examples,
org.eclipse.ui.ide,
org.eclipse.m2e.archetype.common;bundle-version="[1.0,1.2)",
- org.eclipse.m2e.core.ui;bundle-version="[1.0,1.2)"
+ org.eclipse.m2e.core.ui;bundle-version="[1.0,1.2)",
+ org.eclipse.wst.web.ui;bundle-version="1.1.400",
+ org.eclipse.ui.forms,
+ org.jboss.ide.eclipse.as.core;bundle-version="2.3.0",
+ org.eclipse.wst.server.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,22 @@
+package org.jboss.tools.maven.project.examples;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.maven.project.examples.messages"; //$NON-NLS-1$
+ public static String ArchetypeExamplesWizardFirstPage_Existing_Project;
+ public static String ArchetypeExamplesWizardFirstPage_No_TargetRuntime;
+ public static String ArchetypeExamplesWizardFirstPage_Package_Label;
+ public static String ArchetypeExamplesWizardFirstPage_ProjectName_Cant_Be_Empty;
+ public static String ArchetypeExamplesWizardFirstPage_ProjectName_Label;
+ public static String ArchetypeExamplesWizardFirstPage_Target_Runtime_Label;
+ public static String ArchetypeExamplesWizardFirstPage_Title;
+ public static String ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,8 @@
+ArchetypeExamplesWizardFirstPage_Existing_Project=Project already exists
+ArchetypeExamplesWizardFirstPage_No_TargetRuntime=<none>
+ArchetypeExamplesWizardFirstPage_Package_Label=Package
+ArchetypeExamplesWizardFirstPage_ProjectName_Cant_Be_Empty=The project name can not be empty
+ArchetypeExamplesWizardFirstPage_ProjectName_Label=Project name
+ArchetypeExamplesWizardFirstPage_Target_Runtime_Label=Target Runtime
+ArchetypeExamplesWizardFirstPage_Title=Create a new Java EE project
+ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo=Artifacts needed from JBoss Enterprise Maven repository do not seem to be available.\nThis might cause build problems. Follow this <a href=\"http://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories\">link</a> for more details.
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -12,26 +12,40 @@
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.MavenImages;
+import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkingSet;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.Project;
@@ -44,23 +58,30 @@
public class ArchetypeExamplesWizard extends Wizard implements INewWizard {
private Project projectDescription;
- private File location;
+ //private File location;
private ProjectImportConfiguration configuration;
+ private ArchetypeExamplesWizardFirstPage simplePage;
private ArchetypeExamplesWizardPage wizardPage;
+ protected List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
private String projectName;
private String artifactId;
+
public ArchetypeExamplesWizard(File location, Project projectDescription) {
super();
- setWindowTitle("Project Examples Archetype");
+ setWindowTitle("New JBoss project");
setDefaultPageImageDescriptor(MavenImages.WIZ_NEW_PROJECT);
setNeedsProgressMonitor(true);
- this.location = location;
+ //this.location = location;
this.projectDescription = projectDescription;
}
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
+ IWorkingSet workingSet = SelectionUtil.getSelectedWorkingSet(selection);
+ if(workingSet != null) {
+ this.workingSets.add(workingSet);
+ }
}
@Override
@@ -74,12 +95,24 @@
final Archetype archetype = wizardPage.getArchetype();
projectName = configuration.getProjectName(model);
final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ final IPath location = simplePage.getLocationPath();
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ boolean pomExists = location.append(projectName).append(IMavenConstants.POM_FILE_NAME).toFile().exists();
+ if ( pomExists ) {
+ MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed, projectName), Messages.wizardProjectErrorPomAlreadyExists);
+ return false;
+ }
+
final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+
public void run(final IProgressMonitor monitor)
throws CoreException {
+
MavenPlugin.getProjectConfigurationManager().createArchetypeProject(
- project, new Path(location.getAbsolutePath()), archetype,
+ project, location, archetype,
groupId, artifactId, version, javaPackage, properties,
configuration, monitor);
}
@@ -92,7 +125,6 @@
final IWorkspace ws = ResourcesPlugin.getWorkspace();
ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
- MavenProjectExamplesActivator.log(e);
throw new InvocationTargetException(e);
}
}
@@ -106,7 +138,12 @@
} catch (InvocationTargetException e) {
ProjectExamplesActivator.log(e);
Throwable ex = e.getTargetException();
- MessageDialog.openError(getShell(), "Error", ex.getMessage());
+ String message = ex.getMessage();
+ Throwable rootCause = getRootCause(ex);
+ if (rootCause != null) {
+ message += "\nRoot cause : " + rootCause.getMessage();
+ }
+ MessageDialog.openError(getShell(), "Error", message);
return true;
}
@@ -114,17 +151,58 @@
}
-
+ private Throwable getRootCause(Throwable ex) {
+ if (ex == null) return null;
+ Throwable rootCause = getRootCause(ex.getCause());
+ if (rootCause == null) {
+ rootCause = ex;
+ }
+ return rootCause;
+ }
+
public void addPages() {
configuration = new ProjectImportConfiguration();
String profiles = projectDescription.getDefaultProfiles();
if (profiles != null && profiles.trim().length() > 0) {
configuration.getResolverConfiguration().setActiveProfiles(profiles);
}
+ simplePage = new ArchetypeExamplesWizardFirstPage(configuration, projectDescription, workingSets);
+ addPage(simplePage);
wizardPage = new ArchetypeExamplesWizardPage(configuration, projectDescription);
+ wizardPage.setPageComplete(true);//We want to enable the finish button early
addPage(wizardPage);
+
+ simplePage.setProjectNameModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ wizardPage.setArtifactId(simplePage.getProjectName());
+ }
+ });
+
+ simplePage.setPackageNameModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ String packageName = ((Combo)e.getSource()).getText();
+ wizardPage.setPackageName(packageName);
+ }
+ });
+
+
+ simplePage.setPropertyModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ wizardPage.updateArchetypeProperty("enterprise", Boolean.toString(simplePage.isEnterpriseTargetRuntime()));
+ }
+ });
+
}
-
+ @Override
+ public boolean canFinish() {
+ // TODO Auto-generated method stub
+ return super.canFinish();
+ }
public String getProjectName() {
return projectName;
}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,329 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.project.examples.wizard;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+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.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.core.project.ProjectImportConfiguration;
+import org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardLocationPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.internal.facets.FacetUtil;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.tools.maven.project.examples.Messages;
+import org.jboss.tools.project.examples.model.Project;
+
+/**
+ * Simplified UI for the Maven Archetype Wizard, based off the original m2e MavenProjectWizardLocationPage.
+ *
+ * @author Fred Bricon
+ *
+ */
+public class ArchetypeExamplesWizardFirstPage extends MavenProjectWizardLocationPage {
+
+ private Label projectNameLabel;
+ private Combo projectNameCombo;
+ private Label packageLabel;
+ private Combo packageCombo;
+ private Combo serverTargetCombo;
+ private Map<String, IRuntime> serverRuntimes;
+ private Composite warningLink;
+ private boolean initialized;
+ private Boolean isEnterpriseRepoAvailable;
+ private ModifyListener projectNameModifyListener;
+ private ModifyListener packageNameModifyListener;
+ private ModifyListener propertyModifyListener;
+
+ public ArchetypeExamplesWizardFirstPage(
+ ProjectImportConfiguration configuration,
+ Project projectDescription, List<IWorkingSet> workingSet) {
+ super(configuration, projectDescription.getShortDescription(),Messages.ArchetypeExamplesWizardFirstPage_Title, workingSet);
+ setPageComplete(false);
+ }
+
+ @Override
+ protected void createAdditionalControls(Composite container) {
+
+ GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+ projectNameLabel = new Label(container, SWT.NONE);
+ projectNameLabel.setText(Messages.ArchetypeExamplesWizardFirstPage_ProjectName_Label);
+ projectNameCombo = new Combo(container, SWT.BORDER);
+ projectNameCombo.setLayoutData(gridData);
+ projectNameCombo.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ });
+ if (projectNameModifyListener != null) {
+ projectNameCombo.addModifyListener(projectNameModifyListener);
+ }
+
+ packageLabel = new Label(container, SWT.NONE);
+ packageLabel.setText(Messages.ArchetypeExamplesWizardFirstPage_Package_Label);
+ packageCombo = new Combo(container, SWT.BORDER);
+ packageCombo.setLayoutData(gridData);
+ packageCombo.setData("name", "packageCombo"); //$NON-NLS-1$ //$NON-NLS-2$
+ addFieldWithHistory("packageCombo", packageCombo);//$NON-NLS-1$
+ packageCombo.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ });
+ if (packageNameModifyListener != null) {
+ packageCombo.addModifyListener(packageNameModifyListener);
+ }
+
+ //TODO read facet version from project example metadata
+ IProjectFacetVersion facetVersion;
+ try {
+ facetVersion = ProjectFacetsManager.getProjectFacet(
+ IJ2EEFacetConstants.DYNAMIC_WEB).getLatestVersion();
+ createServerTargetComposite(container, facetVersion);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (propertyModifyListener != null) {
+ serverTargetCombo.addModifyListener(propertyModifyListener);
+ }
+
+
+ Label emptyLabel = new Label(container, SWT.NONE);
+ emptyLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,
+ 3, 1));
+
+ }
+
+ @Override
+ protected void createAdvancedSettings(Composite composite, GridData gridData) {
+ createMissingRepositoriesWarning(composite, gridData);
+ }
+
+ protected void createServerTargetComposite(Composite parent,
+ IProjectFacetVersion facetVersion) {
+ Label serverTargetLabel = new Label(parent, SWT.NONE);
+ serverTargetLabel.setText(Messages.ArchetypeExamplesWizardFirstPage_Target_Runtime_Label);
+
+ GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+ serverTargetCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ serverTargetCombo.setLayoutData(gridData);
+ serverRuntimes = getServerRuntimes(facetVersion);
+ for (String runtimeName : serverRuntimes.keySet()) {
+ serverTargetCombo.add(runtimeName);
+ }
+ serverTargetCombo.add(Messages.ArchetypeExamplesWizardFirstPage_No_TargetRuntime);
+ serverTargetCombo.select(0);
+ serverTargetCombo.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validateEnterpriseRepo();
+ }
+ });
+ }
+
+ protected void validate() {
+ if (!initialized) {
+ return;
+ }
+ //Need to be called first, or error message would be overwritten
+ super.validate();
+
+ String errorMessage = validateInputs();
+ setErrorMessage(errorMessage);
+ setMessage(null);
+ setPageComplete(errorMessage == null);
+
+ validateEnterpriseRepo();
+ }
+
+ private String validateInputs() {
+
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ final String name = getProjectName();
+
+ // check whether the project name field is empty
+ if(name.trim().length() == 0) {
+ return Messages.ArchetypeExamplesWizardFirstPage_ProjectName_Cant_Be_Empty;
+ }
+
+ // check whether the project name is valid
+ final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
+ if(!nameStatus.isOK()) {
+ return nameStatus.getMessage();
+ }
+
+ // check whether project already exists
+ final IProject handle = workspace.getRoot().getProject(name);
+ if(handle.exists()) {
+ return Messages.ArchetypeExamplesWizardFirstPage_Existing_Project;
+ }
+
+ //check if the package is valid
+ String packageName = packageCombo.getText();
+ if(packageName.trim().length() != 0) {
+ if(!Pattern.matches("[A-Za-z_$][A-Za-z_$\\d]*(?:\\.[A-Za-z_$][A-Za-z_$\\d]*)*", packageName)) { //$NON-NLS-1$
+ return "";
+ }
+ }
+
+ return null;
+ }
+
+ public String getProjectName() {
+ return (projectNameCombo == null) ? null : projectNameCombo.getText();
+ }
+
+ protected void validateEnterpriseRepo() {
+ boolean isWarningLinkVisible = (isEnterpriseTargetRuntime() && !assertEnterpriseRepoAccessible());
+ warningLink.setVisible(isWarningLinkVisible);
+ }
+
+
+ public boolean isEnterpriseTargetRuntime() {
+ if (serverTargetCombo == null)
+ return false;
+ String serverId = serverTargetCombo.getText();
+ IRuntime runtime = serverRuntimes.get(serverId);
+ return (runtime != null && RuntimeUtils.isEAP(runtime));
+ }
+
+
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+
+ if (visible) {
+ initialized = true;
+ // validate();
+ }
+ }
+
+ private void createMissingRepositoriesWarning(Composite parent,
+ GridData gridData) {
+ //TODO make that damn component align correctly
+ //warningLink = new MissingRepositoryWarningComponent(parent);
+
+ //TODO delete that code
+ warningLink = new Composite(parent, SWT.NONE);
+
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
+ .applyTo(warningLink);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
+
+ Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
+ warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
+
+ Link link = new Link(warningLink, SWT.NONE);
+ link.setText(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ // Open default external browser
+ PlatformUI.getWorkbench().getBrowserSupport()
+ .getExternalBrowser().openURL(new URL(e.text));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ warningLink.setVisible(false);
+ }
+
+
+
+ private boolean assertEnterpriseRepoAccessible() {
+ if (isEnterpriseRepoAvailable != null) {
+ return isEnterpriseRepoAvailable.booleanValue();
+ }
+
+ isEnterpriseRepoAvailable = MavenArtifactHelper.isEnterpriseRepositoryAvailable();
+ return isEnterpriseRepoAvailable.booleanValue();
+ }
+
+ protected Map<String, IRuntime> getServerRuntimes(
+ IProjectFacetVersion facetVersion) {
+ Set<org.eclipse.wst.common.project.facet.core.runtime.IRuntime> runtimesSet;
+ if (facetVersion == null) {
+ runtimesSet =RuntimeManager.getRuntimes();
+ } else {
+ runtimesSet = RuntimeManager.getRuntimes(Collections.singleton(facetVersion));
+ }
+
+ Map<String, IRuntime> runtimesMap = new LinkedHashMap<String, IRuntime>();
+ for (org.eclipse.wst.common.project.facet.core.runtime.IRuntime r : runtimesSet) {
+ IRuntime serverRuntime = FacetUtil.getRuntime(r);
+ if (serverRuntime != null) {
+ runtimesMap.put(r.getLocalizedName(), serverRuntime);
+ }
+ }
+ return runtimesMap;
+ }
+
+ public ModifyListener getProjectNameModifyListener() {
+ return projectNameModifyListener;
+ }
+
+ public void setProjectNameModifyListener(ModifyListener projectNameModifyListener) {
+ this.projectNameModifyListener = projectNameModifyListener;
+ }
+
+ public ModifyListener getPackageNameModifyListener() {
+ return packageNameModifyListener;
+ }
+
+ public void setPackageNameModifyListener(ModifyListener packageNameModifyListener) {
+ this.packageNameModifyListener = packageNameModifyListener;
+ }
+
+ public ModifyListener getPropertyModifyListener() {
+ return propertyModifyListener;
+ }
+
+ public void setPropertyModifyListener(ModifyListener propertyModifyListener) {
+ this.propertyModifyListener = propertyModifyListener;
+ }
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-11-28 13:49:05 UTC (rev 36697)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -11,6 +11,7 @@
package org.jboss.tools.maven.project.examples.wizard;
import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -27,21 +28,28 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ViewerColumn;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
-import org.eclipse.m2e.core.embedder.IMavenConfiguration;
-import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
-import org.eclipse.m2e.core.internal.Messages;
-import org.eclipse.m2e.core.internal.archetype.ArchetypeManager;
-import org.eclipse.m2e.core.internal.archetype.ArchetypeCatalogFactory.RemoteCatalogFactory;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
-import org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardArchetypeParametersPage;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.PlatformUI;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
+import org.jboss.tools.maven.project.examples.wizard.xpl.MavenProjectWizardArchetypeParametersPage;
import org.jboss.tools.project.examples.model.ArchetypeModel;
import org.jboss.tools.project.examples.model.Project;
@@ -54,16 +62,18 @@
MavenProjectWizardArchetypeParametersPage {
private Project projectDescription;
+ private Composite warningLink;
+ private Boolean isEnterpriseRepoAvailable;
public ArchetypeExamplesWizardPage(
ProjectImportConfiguration configuration, Project projectDescription) {
super(configuration);
+ setTitle(projectDescription.getShortDescription());
this.projectDescription = projectDescription;
}
@Override
public void createControl(Composite parent) {
- long start = System.currentTimeMillis();
super.createControl(parent);
Archetype archetype = new Archetype();
ArchetypeModel archetypeModel = projectDescription.getArchetypeModel();
@@ -101,12 +111,11 @@
// It needs to be called AFTER setArchetype(archetype) !!!
archetypeChanged = false;
- //Use archetype/example name by default
- artifactIdCombo.setText(artifactId);
-
//Check if project already exists
IStatus nameStatus = getImportConfiguration().validateProjectName(getModel());
- if(!nameStatus.isOK()) {
+ if(nameStatus.isOK()) {
+ artifactIdCombo.setText(artifactId);
+ } else {
//Force the user to change the name if the project exists
artifactIdCombo.setText("");//$NON-NLS-1$
}
@@ -114,11 +123,56 @@
groupIdCombo.setText(groupId);
versionCombo.setText(version);
packageCombo.setText(javaPackage);
+ }
+
+ @Override
+ protected void createAdvancedSettings(Composite composite, GridData gridData) {
+ // TODO Auto-generated method stub
+ super.createAdvancedSettings(composite, gridData);
+ createMissingRepositoriesWarning(composite, gridData);
+ }
+
+ private void createMissingRepositoriesWarning(Composite parent,
+ GridData gridData) {
+ //TODO make that damn component align correctly
+ //warningLink = new MissingRepositoryWarningComponent(parent);
- long stop = System.currentTimeMillis();
- System.err.println("Create controls took " + (stop-start) + " ms");
+ //TODO delete that code
+ warningLink = new Composite(parent, SWT.NONE);
+
+// Display display = Display.getCurrent();
+// Color color = display.getSystemColor(SWT.COLOR_BLUE);
+// warningLink.setBackground(color);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
+ .applyTo(warningLink);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
+
+ Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
+ warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
+
+ Link link = new Link(warningLink, SWT.NONE);
+ String message = "Artifacts needed from JBoss Enterprise Maven repository do not seem to be available.\nThis might cause build problems. "
+ + "Follow this <a href=\"http://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories\">link</a> for more details.";
+ link.setText(message);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ // Open default external browser
+ PlatformUI.getWorkbench().getBrowserSupport()
+ .getExternalBrowser().openURL(new URL(e.text));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ //link.setBackground(display.getSystemColor(SWT.COLOR_RED));
+
+ warningLink.setVisible(false);
}
+
+
public Archetype getArchetype() {
return archetype;
}
@@ -164,12 +218,10 @@
}
} catch(UnknownArchetype e) {
MavenProjectExamplesActivator.log(e);
- e.printStackTrace();
//TODO don't swallow exceptions
} catch(CoreException ex) {
//TODO don't swallow exceptions
MavenProjectExamplesActivator.log(ex);
- ex.printStackTrace();
} finally {
monitor.done();
}
@@ -196,7 +248,6 @@
private Artifact downloadArchetype(String groupId, String artifactId,
String version, ArtifactRepository archetypeRepository,
List<ArtifactRepository> repositories) throws CoreException {
- //long start = System.currentTimeMillis();
IMaven maven = MavenPlugin.getMaven();
ArrayList<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
if (archetypeRepository != null) {
@@ -206,9 +257,73 @@
IProgressMonitor nullProgressMonitor = new NullProgressMonitor();
maven.resolve(groupId, artifactId, version, "pom", null, repos, nullProgressMonitor); //$NON-NLS-1$
Artifact a = maven.resolve(groupId, artifactId, version, "jar", null, repos, nullProgressMonitor); //$NON-NLS-1$
- //long stop = System.currentTimeMillis();
- //System.err.println("download took " + (stop-start) + " ms");
return a;
}
+
+ public void updateArchetypeProperty(String key, String value){
+ if (propertiesTable == null) return;
+
+ for(int i = 0; i < propertiesTable.getItemCount(); i++ ) {
+ TableItem item = propertiesTable.getItem(i);
+ if (item.getText(KEY_INDEX).equals(key) && !item.getText(VALUE_INDEX).equals(value)) {
+ item.setText(VALUE_INDEX, value);
+ //don't break, just to be sure
+ }
+ }
+ }
+
+ public void setArtifactId(String projectName) {
+ if (artifactIdCombo != null) {
+ artifactIdCombo.setText(projectName);
+ }
+ }
+
+ public void setPackageName(String packageName) {
+ if (packageCombo != null) {
+ if (!packageCombo.getText().equals(packageName)){
+ packageCombo.setText(packageName);
+ }
+ if (groupIdCombo.getText().equals(packageName)){
+ groupIdCombo.setText(packageName);
+ }
+ }
+ }
+
+ @Override
+ protected void validate() {
+ checkEnterpriseProperty();
+ super.validate();
+ }
+
+ private void checkEnterpriseProperty() {
+ if (warningLink == null) {
+ //Not initialized yet
+ return;
+ }
+ // TODO Auto-generated method stub
+ for(int i = 0; i < propertiesTable.getItemCount(); i++ ) {
+ TableItem item = propertiesTable.getItem(i);
+ String value = item.getText(VALUE_INDEX);
+ if (item.getText(KEY_INDEX).equals("enterprise")
+ && (Boolean.TRUE.toString().equalsIgnoreCase(value)
+ || "y".equalsIgnoreCase(value)
+ || "yes".equalsIgnoreCase(value))
+ && !assertEnterpriseRepoAccessible()) {
+ warningLink.setVisible(true);
+ return;
+ }
+ }
+ warningLink.setVisible(false);
+ }
+
+ private boolean assertEnterpriseRepoAccessible() {
+ if (isEnterpriseRepoAvailable != null) {
+ return isEnterpriseRepoAvailable.booleanValue();
+ }
+
+ isEnterpriseRepoAvailable = MavenArtifactHelper.isEnterpriseRepositoryAvailable();
+ return isEnterpriseRepoAvailable.booleanValue();
+ }
+
}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,60 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.project.examples.wizard;
+
+import java.util.ArrayList;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.eclipse.m2e.core.embedder.IMaven;
+
+public class MavenArtifactHelper {
+
+ /**
+ * Checks if the EAP repository is available
+ *
+ * @return true if org.jboss.spec:jboss-javaee-web-6.0:3.0.0.Beta1-redhat-1 can be resolved
+ */
+ public static boolean isEnterpriseRepositoryAvailable() {
+ String keyString = "org.jboss.spec:jboss-javaee-web-6.0:4.0.0.Beta1-redhat-1::"; //$NON-NLS-1$
+ boolean isRepoAvailable = isArtifactAvailable(keyString, "pom");
+ return isRepoAvailable;
+ }
+
+ /**
+ * Checks is an artifact can be resolved
+ * @param artifactKey
+ * @return true is the artifactKey can be resolved to an artifact.
+ */
+ public static boolean isArtifactAvailable(String artifactKey, String type) {
+ boolean isRepoAvailable = false;
+ try {
+ IMaven maven = MavenPlugin.getMaven();
+ ArrayList<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
+ repos.addAll(maven.getArtifactRepositories());
+ IProgressMonitor nullProgressMonitor = new NullProgressMonitor();
+ ArtifactKey key = ArtifactKey.fromPortableString(artifactKey);
+ Artifact a = MavenPlugin.getMaven().resolve(
+ key.getGroupId(), key.getArtifactId(), key.getVersion(),
+ type, key.getClassifier(), repos, nullProgressMonitor); //$NON-NLS-1$
+ isRepoAvailable = a != null && a.isResolved();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return isRepoAvailable;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,80 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.project.examples.wizard;
+
+import java.net.URL;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.PlatformUI;
+
+public class MissingRepositoryWarningComponent extends Composite {
+
+ private Composite warningLink;
+
+ public MissingRepositoryWarningComponent(Composite parent) {
+ super(parent, SWT.NORMAL);
+
+ warningLink = new Composite(parent, SWT.NONE);
+
+ Display display = Display.getCurrent();
+ Color color = display.getSystemColor(SWT.COLOR_BLUE);
+
+ warningLink.setBackground(color);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
+ .applyTo(warningLink);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
+
+ Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
+ warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
+
+ Link link = new Link(warningLink, SWT.NONE);
+ String message = "Artifacts needed from JBoss Enterprise Maven repository do not seem to be available.\nThis might cause build problems. "
+ + "Follow this <a href=\"http://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories\">link</a> for more details.";
+ link.setText(message);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ // Open default external browser
+ PlatformUI.getWorkbench().getBrowserSupport()
+ .getExternalBrowser().openURL(new URL(e.text));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ link.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ warningLink.setVisible(visible);
+ super.setVisible(visible);
+ }
+
+ @Override
+ public void dispose() {
+ warningLink.dispose();
+ super.dispose();
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/xpl/MavenProjectWizardArchetypeParametersPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/xpl/MavenProjectWizardArchetypeParametersPage.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/xpl/MavenProjectWizardArchetypeParametersPage.java 2011-11-28 15:04:18 UTC (rev 36698)
@@ -0,0 +1,588 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2010 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.maven.project.examples.wizard.xpl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.archetype.common.ArchetypeArtifactManager;
+import org.apache.maven.archetype.exception.UnknownArchetype;
+import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
+import org.apache.maven.archetype.metadata.RequiredProperty;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.eclipse.m2e.core.project.ProjectImportConfiguration;
+import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.components.TextComboBoxCellEditor;
+import org.eclipse.m2e.core.ui.internal.wizards.AbstractMavenWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
+
+
+/**
+ * Wizard page responsible for gathering information about the Maven2 artifact when an archetype is being used to create
+ * a project (thus the class name pun).
+ *
+ * This is a copy of org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardArchetypeParametersPage
+ * as we need to access the Properties list. Changed :
+ * <ul>
+ * <li>Replaced slf4j loggers with MavenProjectExamplesActivator.log</li>
+ * <li>Changed visibility of propertiesTable and propertiesViewer to protected</li>
+ * <li>Changed visibility of validate() to protected</li>
+ * </ul>
+ */
+public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWizardPage {
+
+ public static final String DEFAULT_VERSION = "0.0.1-SNAPSHOT"; //$NON-NLS-1$
+
+ public static final String DEFAULT_PACKAGE = "foo"; //$NON-NLS-1$
+
+ protected Table propertiesTable;
+
+ protected TableViewer propertiesViewer;
+
+ protected TableViewerColumn valueColumn;
+
+ final public static String KEY_PROPERTY = "key"; //$NON-NLS-1$
+
+ final public static int KEY_INDEX = 0;
+
+ final public static String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
+ final public static int VALUE_INDEX = 1;
+
+ /** group id text field */
+ protected Combo groupIdCombo;
+
+ /** artifact id text field */
+ protected Combo artifactIdCombo;
+
+ /** version text field */
+ protected Combo versionCombo;
+
+ /** package text field */
+ protected Combo packageCombo;
+
+ protected Button removeButton;
+
+ private boolean isUsed = true;
+
+ protected Set<String> requiredProperties;
+
+ protected Set<String> optionalProperties;
+
+ protected Archetype archetype;
+
+ protected boolean archetypeChanged = false;
+
+ /** shows if the package has been customized by the user */
+ protected boolean packageCustomized = false;
+
+ /** Creates a new page. */
+ public MavenProjectWizardArchetypeParametersPage(ProjectImportConfiguration projectImportConfiguration) {
+ super("Maven2ProjectWizardArchifactPage", projectImportConfiguration); //$NON-NLS-1$
+
+ setTitle(Messages.wizardProjectPageMaven2Title);
+ setDescription(Messages.wizardProjectPageMaven2ArchetypeParametersDescription);
+ setPageComplete(false);
+
+ requiredProperties = new HashSet<String>();
+ optionalProperties = new HashSet<String>();
+ }
+
+ /** Creates page controls. */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(3, false));
+
+ createArtifactGroup(composite);
+ createPropertiesGroup(composite);
+
+ validate();
+
+ createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
+ resolverConfigurationComponent.setModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ });
+
+ setControl(composite);
+
+ }
+
+ private void createArtifactGroup(Composite parent) {
+// Composite artifactGroup = new Composite(parent, SWT.NONE);
+// GridData gd_artifactGroup = new GridData( SWT.FILL, SWT.FILL, true, false );
+// artifactGroup.setLayoutData(gd_artifactGroup);
+// artifactGroup.setLayout(new GridLayout(2, false));
+
+ Label groupIdlabel = new Label(parent, SWT.NONE);
+ groupIdlabel.setText(Messages.artifactComponentGroupId);
+
+ groupIdCombo = new Combo(parent, SWT.BORDER);
+ groupIdCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ addFieldWithHistory("groupId", groupIdCombo); //$NON-NLS-1$
+ groupIdCombo.setData("name", "groupId"); //$NON-NLS-1$ //$NON-NLS-2$
+ groupIdCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateJavaPackage();
+ validate();
+ }
+ });
+
+ Label artifactIdLabel = new Label(parent, SWT.NONE);
+ artifactIdLabel.setText(Messages.artifactComponentArtifactId);
+
+ artifactIdCombo = new Combo(parent, SWT.BORDER);
+ artifactIdCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
+ addFieldWithHistory("artifactId", artifactIdCombo); //$NON-NLS-1$
+ artifactIdCombo.setData("name", "artifactId"); //$NON-NLS-1$ //$NON-NLS-2$
+ artifactIdCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateJavaPackage();
+ validate();
+ }
+ });
+
+ Label versionLabel = new Label(parent, SWT.NONE);
+ versionLabel.setText(Messages.artifactComponentVersion);
+
+ versionCombo = new Combo(parent, SWT.BORDER);
+ GridData gd_versionCombo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
+ gd_versionCombo.widthHint = 150;
+ versionCombo.setLayoutData(gd_versionCombo);
+ versionCombo.setText(DEFAULT_VERSION);
+ addFieldWithHistory("version", versionCombo); //$NON-NLS-1$
+ versionCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ });
+
+ Label packageLabel = new Label(parent, SWT.NONE);
+ packageLabel.setText(Messages.artifactComponentPackage);
+
+ packageCombo = new Combo(parent, SWT.BORDER);
+ packageCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
+ packageCombo.setData("name", "package"); //$NON-NLS-1$ //$NON-NLS-2$
+ addFieldWithHistory("package", packageCombo); //$NON-NLS-1$
+ packageCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if(!packageCustomized && !packageCombo.getText().equals(getDefaultJavaPackage())) {
+ packageCustomized = true;
+ }
+ validate();
+ }
+ });
+ }
+
+ private void createPropertiesGroup(Composite composite) {
+ Label propertiesLabel = new Label(composite, SWT.NONE);
+ propertiesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ propertiesLabel.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_lblProps);
+
+ propertiesViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
+ propertiesTable = propertiesViewer.getTable();
+ propertiesTable.setLinesVisible(true);
+ propertiesTable.setHeaderVisible(true);
+ propertiesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
+
+ TableColumn propertiesTableNameColumn = new TableColumn(propertiesTable, SWT.NONE);
+ propertiesTableNameColumn.setWidth(130);
+ propertiesTableNameColumn.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_columnName);
+
+ TableColumn propertiesTableValueColumn = new TableColumn(propertiesTable, SWT.NONE);
+ propertiesTableValueColumn.setWidth(230);
+ propertiesTableValueColumn.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_columnValue);
+
+ propertiesViewer.setColumnProperties(new String[] {KEY_PROPERTY, VALUE_PROPERTY});
+
+ propertiesViewer.setCellEditors(new CellEditor[] {new TextCellEditor(propertiesTable, SWT.NONE),
+ new TextCellEditor(propertiesTable, SWT.NONE)});
+ propertiesViewer.setCellModifier(new ICellModifier() {
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ if(element instanceof TableItem) {
+ ((TableItem) element).setText(getTextIndex(property), String.valueOf(value));
+ validate();
+ }
+ }
+
+ public Object getValue(Object element, String property) {
+ if(element instanceof TableItem) {
+ return ((TableItem) element).getText(getTextIndex(property));
+ }
+ return null;
+ }
+ });
+
+ Button addButton = new Button(composite, SWT.NONE);
+ addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+ addButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_btnAdd);
+ addButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ propertiesViewer.editElement(addTableItem("?", "?"), KEY_INDEX); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+
+ removeButton = new Button(composite, SWT.NONE);
+ removeButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ removeButton.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_btnRemove);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if(propertiesTable.getSelectionCount() > 0) {
+ propertiesTable.remove(propertiesTable.getSelectionIndices());
+ removeButton.setEnabled(propertiesTable.getItemCount() > 0);
+ validate();
+ }
+ }
+ });
+ }
+
+ /**
+ * Validates the contents of this wizard page.
+ * <p>
+ * Feedback about the validation is given to the user by displaying error messages or informative messages on the
+ * wizard page. Depending on the provided user input, the wizard page is marked as being complete or not.
+ * <p>
+ * If some error or missing input is detected in the user input, an error message or informative message,
+ * respectively, is displayed to the user. If the user input is complete and correct, the wizard page is marked as
+ * begin complete to allow the wizard to proceed. To that end, the following conditions must be met:
+ * <ul>
+ * <li>The user must have provided a valid group ID.</li>
+ * <li>The user must have provided a valid artifact ID.</li>
+ * <li>The user must have provided a version for the artifact.</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#setMessage(java.lang.String)
+ * @see org.eclipse.jface.wizard.WizardPage#setErrorMessage(java.lang.String)
+ * @see org.eclipse.jface.wizard.WizardPage#setPageComplete(boolean)
+ */
+ protected void validate() {
+ String error = validateInput();
+ setErrorMessage(error);
+ setPageComplete(error == null);
+ }
+
+ private String validateInput() {
+ String error = validateGroupIdInput(groupIdCombo.getText().trim());
+ if(error != null) {
+ return error;
+ }
+
+ error = validateArtifactIdInput(artifactIdCombo.getText().trim());
+ if(error != null) {
+ return error;
+ }
+
+ String versionValue = versionCombo.getText().trim();
+ if(versionValue.length() == 0) {
+ return Messages.wizardProjectPageMaven2ValidatorVersion;
+ }
+ //TODO: check validity of version?
+
+ String packageName = packageCombo.getText();
+ if(packageName.trim().length() != 0) {
+ if(!Pattern.matches("[A-Za-z_$][A-Za-z_$\\d]*(?:\\.[A-Za-z_$][A-Za-z_$\\d]*)*", packageName)) { //$NON-NLS-1$
+ return org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_error_package;
+ }
+ }
+
+ // validate project name
+ IStatus nameStatus = getImportConfiguration().validateProjectName(getModel());
+ if(!nameStatus.isOK()) {
+ return NLS.bind(Messages.wizardProjectPageMaven2ValidatorProjectNameInvalid, nameStatus.getMessage());
+ }
+
+ if(requiredProperties.size() > 0) {
+ Properties properties = getProperties();
+ for(String key : requiredProperties) {
+ String value = properties.getProperty(key);
+ if(value == null || value.length() == 0) {
+ return NLS.bind(Messages.wizardProjectPageMaven2ValidatorRequiredProperty, key);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /** Ends the wizard flow chain. */
+ public IWizardPage getNextPage() {
+ return null;
+ }
+
+ public void setArchetype(Archetype archetype) {
+ if(archetype == null) {
+ propertiesTable.removeAll();
+ archetypeChanged = false;
+ } else if(!archetype.equals(this.archetype)) {
+ this.archetype = archetype;
+ propertiesTable.removeAll();
+ requiredProperties.clear();
+ optionalProperties.clear();
+ archetypeChanged = true;
+
+ Properties properties = archetype.getProperties();
+ if(properties != null) {
+ for(Iterator<Map.Entry<Object, Object>> it = properties.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<?, ?> e = it.next();
+ String key = (String) e.getKey();
+ addTableItem(key, (String) e.getValue());
+ optionalProperties.add(key);
+ }
+ }
+ }
+ }
+
+ void loadArchetypeDescriptor() {
+ final String groupId = archetype.getGroupId();
+ final String artifactId = archetype.getArtifactId();
+ final String version = archetype.getVersion();
+ final String archetypeName = groupId + ":" + artifactId + ":" + version; //$NON-NLS-1$ //$NON-NLS-2$
+
+ try {
+ getContainer().run(false, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(NLS.bind(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_task, archetypeName), IProgressMonitor.UNKNOWN);
+ try {
+ IMaven maven = MavenPlugin.getMaven();
+
+ ArtifactRepository localRepository = maven.getLocalRepository();
+
+ List<ArtifactRepository> repositories = maven.getArtifactRepositories();
+
+ ArchetypeArtifactManager aaMgr = MavenPluginActivator.getDefault().getArchetypeArtifactManager();
+ if(aaMgr.isFileSetArchetype(groupId, artifactId, version, null, localRepository, repositories)) {
+ ArchetypeDescriptor descriptor = aaMgr.getFileSetArchetypeDescriptor(groupId, artifactId, version, null,
+ localRepository, repositories);
+ List<?> properties = descriptor.getRequiredProperties();
+ if(properties != null) {
+ for(Object o : properties) {
+ if(o instanceof RequiredProperty) {
+ RequiredProperty rp = (RequiredProperty) o;
+ requiredProperties.add(rp.getKey());
+ addTableItem(rp.getKey(), rp.getDefaultValue());
+ }
+ }
+ }
+ }
+ } catch(UnknownArchetype e) {
+ MavenProjectExamplesActivator.log(e, NLS.bind("Error downloading archetype {0}",archetypeName));
+ } catch(CoreException ex) {
+ MavenProjectExamplesActivator.log(ex, ex.getMessage());
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch(InterruptedException ex) {
+ // ignore
+ } catch(InvocationTargetException ex) {
+ String msg = NLS.bind(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypeParametersPage_error_download, archetypeName);
+ setErrorMessage(msg + "\n" + ex.toString()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param key
+ * @param value
+ */
+ TableItem addTableItem(String key, String value) {
+ TableItem item = new TableItem(propertiesTable, SWT.NONE);
+ item.setData(item);
+ item.setText(KEY_INDEX, key);
+ item.setText(VALUE_INDEX, value == null ? "" : value); //$NON-NLS-1$
+ return item;
+ }
+
+ /**
+ * Updates the properties when a project name is set on the first page of the wizard.
+ */
+ public void setProjectName(String projectName) {
+ if(artifactIdCombo.getText().equals(groupIdCombo.getText())) {
+ groupIdCombo.setText(projectName);
+ }
+ artifactIdCombo.setText(projectName);
+ packageCombo.setText("org." + projectName.replace('-', '.')); //$NON-NLS-1$
+ validate();
+ }
+
+ /**
+ * Updates the properties when a project name is set on the first page of the wizard.
+ */
+ public void setParentProject(String groupId, String artifactId, String version) {
+ groupIdCombo.setText(groupId);
+ versionCombo.setText(version);
+ validate();
+ }
+
+ /** Enables or disables the artifact id text field. */
+ public void setArtifactIdEnabled(boolean b) {
+ artifactIdCombo.setEnabled(b);
+ }
+
+ /** Returns the package name. */
+ public String getJavaPackage() {
+ if(packageCombo.getText().length() > 0) {
+ return packageCombo.getText();
+ }
+ return getDefaultJavaPackage();
+ }
+
+ /** Updates the package name if the related fields changed. */
+ protected void updateJavaPackage() {
+ if(packageCustomized) {
+ return;
+ }
+
+ String defaultPackageName = getDefaultJavaPackage();
+ packageCombo.setText(defaultPackageName);
+ }
+
+ /** Returns the default package name. */
+ protected String getDefaultJavaPackage() {
+ return MavenProjectWizardArchetypeParametersPage.getDefaultJavaPackage(groupIdCombo.getText().trim(),
+ artifactIdCombo.getText().trim());
+ }
+
+ /** Creates the Model object. */
+ public Model getModel() {
+ Model model = new Model();
+
+ model.setModelVersion("4.0.0"); //$NON-NLS-1$
+ model.setGroupId(groupIdCombo.getText());
+ model.setArtifactId(artifactIdCombo.getText());
+ model.setVersion(versionCombo.getText());
+
+ return model;
+ }
+
+ public void setUsed(boolean isUsed) {
+ this.isUsed = isUsed;
+ }
+
+ public boolean isPageComplete() {
+ return !isUsed || super.isPageComplete();
+ }
+
+ /** Loads the group value when the page is displayed. */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+
+ if(visible) {
+ if(groupIdCombo.getText().length() == 0 && groupIdCombo.getItemCount() > 0) {
+ groupIdCombo.setText(groupIdCombo.getItem(0));
+ packageCombo.setText(getDefaultJavaPackage());
+ packageCustomized = false;
+ }
+
+ if(archetypeChanged && archetype != null) {
+ archetypeChanged = false;
+ loadArchetypeDescriptor();
+ validate();
+ }
+
+ updatePropertyEditors();
+ }
+ }
+
+ public Properties getProperties() {
+ if(propertiesViewer.isCellEditorActive()) {
+ propertiesTable.setFocus();
+ }
+ Properties properties = new Properties();
+ for(int i = 0; i < propertiesTable.getItemCount(); i++ ) {
+ TableItem item = propertiesTable.getItem(i);
+ properties.put(item.getText(KEY_INDEX), item.getText(VALUE_INDEX));
+ }
+ return properties;
+ }
+
+ public int getTextIndex(String property) {
+ return KEY_PROPERTY.equals(property) ? KEY_INDEX : VALUE_INDEX;
+ }
+
+ public void updatePropertyEditors() {
+ CellEditor[] ce = propertiesViewer.getCellEditors();
+
+ int n = requiredProperties.size() + optionalProperties.size();
+ if(n == 0) {
+ if(ce[KEY_INDEX] instanceof TextComboBoxCellEditor) {
+ // if there was a combo editor previously defined, and the current
+ // archetype has no properties, replace it with a plain text editor
+ ce[KEY_INDEX].dispose();
+ ce[KEY_INDEX] = new TextCellEditor(propertiesTable, SWT.FLAT);
+ }
+ } else {
+ TextComboBoxCellEditor comboEditor = null;
+ // if there was a plain text editor previously defined, and the current
+ // archetype has properties, replace it with a combo editor
+ if(ce[KEY_INDEX] instanceof TextComboBoxCellEditor) {
+ comboEditor = (TextComboBoxCellEditor) ce[KEY_INDEX];
+ } else {
+ ce[KEY_INDEX].dispose();
+ comboEditor = new TextComboBoxCellEditor(propertiesTable, SWT.FLAT);
+ ce[KEY_INDEX] = comboEditor;
+ }
+
+ // populate the property name selection
+ List<String> propertyKeys = new ArrayList<String>(n);
+ propertyKeys.addAll(requiredProperties);
+ propertyKeys.addAll(optionalProperties);
+ comboEditor.setItems(propertyKeys.toArray(new String[n]));
+ }
+ }
+
+ public static String getDefaultJavaPackage(String groupId, String artifactId) {
+ return org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardArchetypeParametersPage.getDefaultJavaPackage(groupId, artifactId);
+ }
+}
14 years
JBoss Tools SVN: r36697 - /.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2011-11-28 08:49:05 -0500 (Mon, 28 Nov 2011)
New Revision: 36697
Added:
com.hp.common/
Log:
Initial import.
14 years
JBoss Tools SVN: r36694 - workspace/yradtsevich/browsersim/swt-webkit-browsersim and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-11-28 08:27:44 -0500 (Mon, 28 Nov 2011)
New Revision: 36694
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/
Removed:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.eclipse/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim/
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web apps
- moving plugins to the vpe component, step 1
14 years
JBoss Tools SVN: r36693 - workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser.test.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-11-28 08:20:25 -0500 (Mon, 28 Nov 2011)
New Revision: 36693
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser.test/pom.xml
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web apps
- added build scripts for browsersim test plugin
Added: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser.test/pom.xml
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser.test/pom.xml (rev 0)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.vpe.browsersim.browser.test/pom.xml 2011-11-28 13:20:25 UTC (rev 36693)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.vpe</groupId>
+ <artifactId>tests</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.vpe.browsersim.tests</groupId>
+ <artifactId>org.jboss.tools.vpe.browsersim.browser.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <configuration>
+ <explodedBundles combine.children="append">
+ <bundle>org.jboss.tools.vpe.browsersim.browser.test</bundle>
+ </explodedBundles>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
14 years