JBoss Tools SVN: r36488 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:41:24 -0500 (Mon, 21 Nov 2011)
New Revision: 36488
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
Log:
added asserts
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-21 13:41:12 UTC (rev 36487)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-21 13:41:24 UTC (rev 36488)
@@ -1,5 +1,9 @@
package org.jboss.tools.portlet.ui.bot.test.create;
+import static org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject.PROJECT_NAME;
+import static org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
+import static org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+
import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.PortletCreationTask;
import org.jboss.tools.portlet.ui.bot.test.testcase.SWTTaskBasedTestCase;
@@ -17,15 +21,22 @@
private static final String PACKAGE_NAME = "org.jboss.tools.tests.ui.portlet";
+ private static final String SOURCE_FILE_NAME = "src";
+
@Test
public void testCreate(){
doPerform(getCreatePortletTask());
+
+ doAssertThat(0, isNumberOfErrors());
+ doAssertThat(SOURCE_FILE_NAME + "/" + PACKAGE_NAME + "/" + CLASS_NAME + ".java", existsInProject(PROJECT_NAME));
+ doAssertThat("WebContent/WEB-INF/default-object.xml", existsInProject(PROJECT_NAME));
+ doAssertThat("WebContent/WEB-INF/portlet-instances.xml", existsInProject(PROJECT_NAME));
System.out.println("");
}
private SWTTask getCreatePortletTask() {
PortletCreationTask task = new PortletCreationTask();
- task.setProject(CreateJavaPortletProject.PROJECT_NAME);
+ task.setProject(PROJECT_NAME);
task.setPackageName(PACKAGE_NAME);
task.setClassName(CLASS_NAME);
return task;
13 years, 1 month
JBoss Tools SVN: r36487 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:41:12 -0500 (Mon, 21 Nov 2011)
New Revision: 36487
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java
Log:
changed the implementation
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java 2011-11-21 13:08:49 UTC (rev 36486)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java 2011-11-21 13:41:12 UTC (rev 36487)
@@ -3,7 +3,6 @@
import org.hamcrest.Description;
import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
/**
@@ -15,7 +14,7 @@
public class ExistingFileMatcher extends AbstractSWTMatcher<String> {
private static final String FILE_SEPARATOR = "/";
-
+
private String project;
public ExistingFileMatcher(String project) {
@@ -25,12 +24,7 @@
@Override
public boolean matchesSafely(String path) {
SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
- try {
- SWTEclipseExt.openFile(SWTBotFactory.getBot(), project, path.split(FILE_SEPARATOR));
- return true;
- } catch (Exception e){
- return false;
- }
+ return SWTBotFactory.getPackageexplorer().isFilePresent(project, path.split(FILE_SEPARATOR));
}
@Override
13 years, 1 month
JBoss Tools SVN: r36486 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task: wizard and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:08:49 -0500 (Mon, 21 Nov 2011)
New Revision: 36486
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java
Log:
refactored setting of inner tasks
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java 2011-11-21 13:08:26 UTC (rev 36485)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java 2011-11-21 13:08:49 UTC (rev 36486)
@@ -36,8 +36,8 @@
// hook up method
}
- public void addTask(T task){
- tasks.add(task);
+ public void setTasks(List<T> tasks) {
+ this.tasks = tasks;
}
public List<T> getTasks() {
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java 2011-11-21 13:08:26 UTC (rev 36485)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java 2011-11-21 13:08:49 UTC (rev 36486)
@@ -1,5 +1,8 @@
package org.jboss.tools.portlet.ui.bot.test.task.wizard;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.tools.portlet.ui.bot.test.task.CompositeSWTTask;
/**
@@ -12,12 +15,24 @@
*/
public class WizardFillingTask extends CompositeSWTTask<WizardPageFillingTask>{
+ private List<WizardPageFillingTask> wizardPages;
+
+ public WizardFillingTask() {
+ super();
+ wizardPages = new ArrayList<WizardPageFillingTask>();
+ }
+
@Override
public void perform() {
+ super.setTasks(wizardPages);
super.perform();
getBot().button("Finish").click();
}
+ public void addWizardPage(WizardPageFillingTask task){
+ wizardPages.add(task);
+ }
+
@Override
protected void beforeTask(WizardPageFillingTask task) {
if (!isFirst(task)){
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java 2011-11-21 13:08:26 UTC (rev 36485)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java 2011-11-21 13:08:49 UTC (rev 36486)
@@ -4,7 +4,6 @@
import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetsSelectionTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardFillingTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardOpeningTask;
-import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageFillingTask;
/**
* Creates a new dynamic web project using the wizard.
@@ -16,26 +15,19 @@
private DynamicWebProjectWizardPageFillingTask firstPage;
- private WizardFillingTask wizardFillingTask;
-
public DynamicWebProjectCreationTask() {
super();
firstPage = new DynamicWebProjectWizardPageFillingTask();
- wizardFillingTask = new WizardFillingTask();
- wizardFillingTask.addTask(firstPage);
+ addWizardPage(firstPage);
}
@Override
public void perform() {
performInnerTask(new WizardOpeningTask("Dynamic Web Project", "Web"));
- performInnerTask(wizardFillingTask);
+ super.perform();
performInnerTask(new AssociatedPerspectiveDialogClosingTask(false));
}
- public void addWizardPage(WizardPageFillingTask page){
- wizardFillingTask.addTask(page);
- }
-
public void setProjectName(String projectName) {
firstPage.setProjectName(projectName);
}
13 years, 1 month
JBoss Tools SVN: r36485 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:08:26 -0500 (Mon, 21 Nov 2011)
New Revision: 36485
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java
Log:
changed code to use SWT bot ext
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java 2011-11-21 13:07:49 UTC (rev 36484)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java 2011-11-21 13:08:26 UTC (rev 36485)
@@ -1,8 +1,12 @@
package org.jboss.tools.portlet.ui.bot.test.task.wizard;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.gen.INewObject;
/**
* Opens a specified wizard.
@@ -11,37 +15,44 @@
*
*/
public class WizardOpeningTask extends AbstractSWTTask {
-
+
private String category;
-
+
private String name;
-
+
public WizardOpeningTask(String name) {
super();
this.name = name;
}
-
- public WizardOpeningTask(String name, String category) {
+
+ /**
+ *
+ * @param name Name of the wizard to open
+ * @param categoryPath path to the wizard (categories separated by '/')
+ */
+ public WizardOpeningTask(String name, String categoryPath) {
this(name);
- this.category = category;
+ this.category = categoryPath;
}
@Override
public void perform() {
- getBot().menu("File").menu("New").menu("Other...").click();
-
- SWTBotTree tree = getBot().tree();
- getTreeItem(tree).select();
-
- getBot().button("Next >").click();
+ INewObject wizardPath = new INewObject() {
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ if (category == null){
+ return Collections.emptyList();
+ }
+
+ return Arrays.asList(category.split("/"));
+ }
+ };
+ SWTBotFactory.getOpen().newObject(wizardPath);
}
-
- private SWTBotTreeItem getTreeItem(SWTBotTree tree){
- if (category == null){
- return tree.getTreeItem(name);
- } else {
- tree.expandNode(category);
- return tree.getTreeItem(category).getNode(name);
- }
- }
}
13 years, 1 month
JBoss Tools SVN: r36484 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test: create and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:07:49 -0500 (Mon, 21 Nov 2011)
New Revision: 36484
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
Log:
created new test
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java 2011-11-21 13:07:26 UTC (rev 36483)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java 2011-11-21 13:07:49 UTC (rev 36484)
@@ -1,12 +1,14 @@
package org.jboss.tools.portlet.ui.bot.test;
+import org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortlet;
import org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(RequirementAwareUsageWindowClosingSuite.class)
@Suite.SuiteClasses({
- CreateJavaPortletProject.class
+ CreateJavaPortletProject.class,
+ CreateJavaPortlet.class
})
public class AllTestsSuite {
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-21 13:07:49 UTC (rev 36484)
@@ -0,0 +1,33 @@
+package org.jboss.tools.portlet.ui.bot.test.create;
+
+import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.PortletCreationTask;
+import org.jboss.tools.portlet.ui.bot.test.testcase.SWTTaskBasedTestCase;
+import org.junit.Test;
+
+/**
+ * Creates a new java portlet.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class CreateJavaPortlet extends SWTTaskBasedTestCase {
+
+ private static final String CLASS_NAME = "UITestingPortlet";
+
+ private static final String PACKAGE_NAME = "org.jboss.tools.tests.ui.portlet";
+
+ @Test
+ public void testCreate(){
+ doPerform(getCreatePortletTask());
+ System.out.println("");
+ }
+
+ private SWTTask getCreatePortletTask() {
+ PortletCreationTask task = new PortletCreationTask();
+ task.setProject(CreateJavaPortletProject.PROJECT_NAME);
+ task.setPackageName(PACKAGE_NAME);
+ task.setClassName(CLASS_NAME);
+ return task;
+ }
+}
13 years, 1 month
JBoss Tools SVN: r36483 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:07:26 -0500 (Mon, 21 Nov 2011)
New Revision: 36483
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
Log:
project name made public
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-21 13:07:04 UTC (rev 36482)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-21 13:07:26 UTC (rev 36483)
@@ -28,7 +28,7 @@
@Require(server=@Server(required=true, state=ServerState.Present, type=ServerType.EPP))
public class CreateJavaPortletProject extends SWTTaskBasedTestCase{
- private static final String PROJECT_NAME = "java-portlet";
+ public static final String PROJECT_NAME = "java-portlet";
private static final String FACET_CATEGORY = "JBoss Portlets";
13 years, 1 month
JBoss Tools SVN: r36482 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2011-11-21 08:07:04 -0500 (Mon, 21 Nov 2011)
New Revision: 36482
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletCreationTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletWizardPageFillingTask.java
Log:
created
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletCreationTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletCreationTask.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletCreationTask.java 2011-11-21 13:07:04 UTC (rev 36482)
@@ -0,0 +1,47 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss;
+
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardFillingTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardOpeningTask;
+
+/**
+ * Creates a new portlet using a JBoss wizard.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class PortletCreationTask extends WizardFillingTask {
+
+ private PortletWizardPageFillingTask firstPage;
+
+ public PortletCreationTask() {
+ super();
+ firstPage = new PortletWizardPageFillingTask();
+ addWizardPage(firstPage);
+ }
+
+ @Override
+ public void perform() {
+ performInnerTask(new WizardOpeningTask("Java Portlet", "JBoss Tools Web/Portlet"));
+ super.perform();
+ }
+
+ public void setProject(String project) {
+ firstPage.setProject(project);
+ }
+
+ public void setSourceFolder(String sourceFolder) {
+ firstPage.setSourceFolder(sourceFolder);
+ }
+
+ public void setPackageName(String packageName) {
+ firstPage.setPackageName(packageName);
+ }
+
+ public void setClassName(String className) {
+ firstPage.setClassName(className);
+ }
+
+ public void setSuperclass(String superclass) {
+ firstPage.setSuperclass(superclass);
+ }
+}
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletWizardPageFillingTask.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletWizardPageFillingTask.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/PortletWizardPageFillingTask.java 2011-11-21 13:07:04 UTC (rev 36482)
@@ -0,0 +1,60 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageFillingTask;
+
+public class PortletWizardPageFillingTask extends AbstractSWTTask implements WizardPageFillingTask {
+
+ private String project;
+
+ private String sourceFolder;
+
+ private String packageName;
+
+ private String className;
+
+ private String superclass;
+
+ @Override
+ public void perform() {
+ if (project != null){
+ getBot().comboBoxWithLabel("Project:").setSelection(project);
+ }
+
+ if (sourceFolder != null){
+ getBot().textWithLabel("Source folder:").setText(sourceFolder);
+ }
+
+ if (packageName != null){
+ getBot().textWithLabel("Java package:").setText(packageName);
+ }
+
+ if (className != null){
+ getBot().textWithLabel("Class name:").setText(className);
+ }
+
+ if (superclass != null){
+ getBot().textWithLabel("Superclass:").setText(superclass);
+ }
+ }
+
+ public void setProject(String project) {
+ this.project = project;
+ }
+
+ public void setSourceFolder(String sourceFolder) {
+ this.sourceFolder = sourceFolder;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void setSuperclass(String superclass) {
+ this.superclass = superclass;
+ }
+}
13 years, 1 month
JBoss Tools SVN: r36481 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-11-21 07:57:31 -0500 (Mon, 21 Nov 2011)
New Revision: 36481
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
Log:
[JBIDE-9927] implementing create application and embed cartridges usecase
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -61,9 +61,13 @@
}
public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
+ log(e.getMessage(), e);
}
+ public static void log(String message, Throwable e) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e));
+ }
+
public static IStatus createErrorStatus(String message, Throwable throwable) {
return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message, throwable);
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -12,18 +12,14 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -31,41 +27,25 @@
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardDialog;
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.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.TaskModel;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
-import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
-import org.eclipse.wst.server.ui.wizard.WizardFragment;
-import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
-import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenShiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -10,19 +10,9 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.core.databinding.observable.Diffs;
-import org.eclipse.core.databinding.observable.list.ListDiff;
-import org.eclipse.core.databinding.observable.list.ListDiffEntry;
-import org.eclipse.core.runtime.Assert;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.ICartridge;
-import org.jboss.tools.openshift.express.client.IEmbeddableCartridge;
import org.jboss.tools.openshift.express.client.IUser;
import org.jboss.tools.openshift.express.client.OpenShiftException;
@@ -37,7 +27,6 @@
private IApplication application;
private String name;
private ICartridge cartridge;
- private List<IEmbeddableCartridge> selectedCartridges;
public ApplicationWizardModel(IUser user) {
this(null, user);
@@ -80,61 +69,4 @@
public IApplication createApplication(String name, ICartridge cartridge) throws OpenShiftException {
return getUser().createApplication(name, cartridge);
}
-
- public void setSelectedCartridges(List<IEmbeddableCartridge> selectedCartridges) {
- this.selectedCartridges = selectedCartridges;
- }
-
- public void embedCartridges() throws OpenShiftException {
- Assert.isNotNull(selectedCartridges);
- List<IEmbeddableCartridge> addedCartridges = new ArrayList<IEmbeddableCartridge>();
- List<IEmbeddableCartridge> removedCartridges = new ArrayList<IEmbeddableCartridge>();
- computeAdditionsAndRemovals(addedCartridges, removedCartridges, selectedCartridges);
- addEmbeddedCartridges(addedCartridges);
- removeEmbeddedCartridges(removedCartridges);
- }
-
- private void removeEmbeddedCartridges(List<IEmbeddableCartridge> removedCartridges) throws OpenShiftException {
- if (removedCartridges.isEmpty()) {
- return;
- }
- Collections.sort(removedCartridges, new CartridgeComparator());
- application.removeEmbbedCartridges(removedCartridges);
- }
-
- private void addEmbeddedCartridges(List<IEmbeddableCartridge> addedCartridges) throws OpenShiftException {
- if (addedCartridges.isEmpty()) {
- return;
- }
- Collections.sort(addedCartridges, new CartridgeComparator());
- application.addEmbbedCartridges(addedCartridges);
- }
-
- private void computeAdditionsAndRemovals(List<IEmbeddableCartridge> addedCartridges,
- List<IEmbeddableCartridge> removedCartridges, List<IEmbeddableCartridge> selectedCartridges)
- throws OpenShiftException {
- ListDiff listDiff = Diffs.computeListDiff(getApplication().getEmbeddedCartridges(), selectedCartridges);
- for (ListDiffEntry entry : listDiff.getDifferences()) {
- if (entry.isAddition()) {
- addedCartridges.add((IEmbeddableCartridge) entry.getElement());
- } else {
- removedCartridges.add((IEmbeddableCartridge) entry.getElement());
- }
- }
- }
-
- private static class CartridgeComparator implements Comparator<IEmbeddableCartridge> {
-
- @Override
- public int compare(IEmbeddableCartridge thisCartridge, IEmbeddableCartridge thatCartridge) {
- // mysql has to be added/removed before phpmyadmin
- if (thisCartridge.equals(IEmbeddableCartridge.MYSQL_51)) {
- return -1;
- } else if (thatCartridge.equals(IEmbeddableCartridge.MYSQL_51)) {
- return 1;
- }
- return 0;
- }
- }
-
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizard.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizard.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -10,20 +10,9 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.IUser;
-import org.jboss.tools.openshift.express.client.OpenShiftException;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
/**
* @author André Dietisheim
@@ -31,6 +20,7 @@
public class EmbedCartridgeWizard extends Wizard {
private ApplicationWizardModel wizardModel;
+ private EmbedCartridgeWizardPage embedCartridgeWizardPage;
public EmbedCartridgeWizard(IApplication application, IUser user) {
this.wizardModel = new ApplicationWizardModel(application, user);
@@ -39,35 +29,12 @@
@Override
public boolean performFinish() {
- final ArrayBlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
- try {
- WizardUtils.runInWizard(
- new Job(NLS.bind("Adding/Removing embedded cartridges for application {0}...",
- wizardModel.getApplication().getName())) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- wizardModel.embedCartridges();
- queue.offer(true);
- } catch (OpenShiftException e) {
- queue.offer(false);
- return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- NLS.bind("Could not embed cartridges to application {0}",
- wizardModel.getApplication().getName()), e);
- }
- return Status.OK_STATUS;
- }
- }, getContainer());
- return queue.poll(10, TimeUnit.SECONDS);
- } catch (Exception e) {
- return false;
- }
+ return embedCartridgeWizardPage.processCartridges();
}
@Override
public void addPages() {
- addPage(new EmbedCartridgeWizardPage(wizardModel, this));
+ addPage(this.embedCartridgeWizardPage = new EmbedCartridgeWizardPage(wizardModel, this));
}
public IApplication getApplication() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -12,6 +12,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -49,6 +51,7 @@
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.IEmbeddableCartridge;
+import org.jboss.tools.openshift.express.client.OpenShiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.common.StringUtils;
@@ -131,27 +134,31 @@
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
- if (event.getChecked()) {
- if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
- addPhpMyAdminCartridge(cartridge);
- } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
- addJenkinsCartridge(cartridge);
+ try {
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
+ if (event.getChecked()) {
+ if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
+ addPhpMyAdminCartridge(cartridge);
+ } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
+ addJenkinsCartridge(cartridge);
+ } else {
+ addCartridge(cartridge);
+ }
} else {
- addCartridge(cartridge);
+ if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
+ removeMySQLCartridge(cartridge);
+ } else {
+ removeCartridge(cartridge);
+ }
}
- } else {
- if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
- removeMySQLCartridge(cartridge);
- } else {
- removeCartridge(cartridge);
- }
+ } catch (OpenShiftException e) {
+ OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
}
}
};
}
- private void addJenkinsCartridge(final IEmbeddableCartridge cartridge) {
+ private void addJenkinsCartridge(final IEmbeddableCartridge cartridge) throws OpenShiftException {
if (model.hasApplication(ICartridge.JENKINS_14)) {
model.getSelectedEmbeddableCartridges().add(cartridge);
} else {
@@ -191,7 +198,7 @@
}
}
- private void addPhpMyAdminCartridge(IEmbeddableCartridge cartridge) {
+ private void addPhpMyAdminCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
if (!viewer.getChecked(IEmbeddableCartridge.MYSQL_51)) {
if (MessageDialog.openQuestion(getShell(), "Embed mysql cartridge",
"To embed phpmyadmin, you'd also have to embed mysql.")) {
@@ -206,11 +213,11 @@
}
}
- private void addCartridge(IEmbeddableCartridge cartridge) {
+ private void addCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
model.getSelectedEmbeddableCartridges().add(cartridge);
}
- private void removeMySQLCartridge(IEmbeddableCartridge cartridge) {
+ private void removeMySQLCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
if (viewer.getChecked(IEmbeddableCartridge.PHPMYADMIN_34)) {
if (MessageDialog.openQuestion(getShell(), "Remove phpmyadmin cartridge",
"If you remove the mysql cartridge, you'd also have to remove phpmyadmin.")) {
@@ -225,7 +232,7 @@
}
}
- private void removeCartridge(IEmbeddableCartridge cartridge) {
+ private void removeCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
model.getSelectedEmbeddableCartridges().remove(cartridge);
}
@@ -235,7 +242,11 @@
@Override
public void widgetSelected(SelectionEvent e) {
viewer.setAllChecked(true);
- addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
+ try {
+ addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
+ } catch (OpenShiftException ex) {
+ OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
+ }
}
};
@@ -261,14 +272,7 @@
protected IStatus run(IProgressMonitor monitor) {
try {
setViewerInput(model.loadEmbeddableCartridges());
- model.initSelectedEmbeddableCartridges();
- getShell().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- viewer.setCheckedElements(model.getSelectedEmbeddableCartridges().toArray());
- }
- });
+ setViewerCheckedElements(model.getSelectedEmbeddableCartridges());
return Status.OK_STATUS;
} catch (Exception e) {
clearViewer();
@@ -286,6 +290,16 @@
setViewerInput(new ArrayList<IEmbeddableCartridge>());
}
+ private void setViewerCheckedElements(final Collection<IEmbeddableCartridge> cartridges) {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ viewer.setCheckedElements(cartridges.toArray());
+ }
+ });
+ }
+
private void setViewerInput(final Collection<IEmbeddableCartridge> cartridges) {
getShell().getDisplay().syncExec(new Runnable() {
@@ -348,4 +362,31 @@
}
+ public boolean processCartridges() {
+ final ArrayBlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
+ try {
+ WizardUtils.runInWizard(
+ new Job(NLS.bind("Adding/Removing embedded cartridges for application {0}...",
+ model.getApplication().getName())) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.embedCartridges();
+ queue.offer(true);
+ } catch (OpenShiftException e) {
+ queue.offer(false);
+ return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
+ NLS.bind("Could not embed cartridges to application {0}",
+ model.getApplication().getName()), e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer());
+ return queue.poll(10, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -11,8 +11,14 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.list.ListDiff;
+import org.eclipse.core.databinding.observable.list.ListDiffEntry;
+import org.eclipse.core.runtime.Assert;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.ICartridge;
@@ -34,21 +40,21 @@
private ApplicationWizardModel wizardModel;
private List<IEmbeddableCartridge> embeddableCartridges = new ArrayList<IEmbeddableCartridge>();
- private List<IEmbeddableCartridge> selectedEmbeddableCartridges = new ArrayList<IEmbeddableCartridge>();
+ private List<IEmbeddableCartridge> selectedCartridges;
public EmbedCartridgeWizardPageModel(ApplicationWizardModel wizardModel) {
this.wizardModel = wizardModel;
- wizardModel.setSelectedCartridges(selectedEmbeddableCartridges);
}
- public void initSelectedEmbeddableCartridges() throws OpenShiftException {
+ public void loadSelectedEmbeddableCartridges() throws OpenShiftException {
+ selectedCartridges = new ArrayList<IEmbeddableCartridge>();
IApplication application = wizardModel.getApplication();
if (application == null
|| application.getEmbeddedCartridges() == null) {
return;
}
List<IEmbeddableCartridge> embeddedCartridges = application.getEmbeddedCartridges();
- getSelectedEmbeddableCartridges().addAll(embeddedCartridges);
+ selectedCartridges.addAll(embeddedCartridges);
}
public List<IEmbeddableCartridge> loadEmbeddableCartridges() throws OpenShiftException {
@@ -66,8 +72,11 @@
return embeddableCartridges;
}
- public List<IEmbeddableCartridge> getSelectedEmbeddableCartridges() {
- return selectedEmbeddableCartridges;
+ public List<IEmbeddableCartridge> getSelectedEmbeddableCartridges() throws OpenShiftException {
+ if (selectedCartridges == null) {
+ loadSelectedEmbeddableCartridges();
+ }
+ return selectedCartridges;
}
public boolean hasApplication(ICartridge cartridge) {
@@ -80,7 +89,66 @@
}
}
+ public IApplication getApplication() {
+ return wizardModel.getApplication();
+ }
+
public void createJenkinsApplication(String name) throws OpenShiftException {
wizardModel.getUser().createApplication(name, ICartridge.JENKINS_14);
}
+
+ public void embedCartridges() throws OpenShiftException {
+ if (selectedCartridges == null) {
+ return;
+ }
+ List<IEmbeddableCartridge> addedCartridges = new ArrayList<IEmbeddableCartridge>();
+ List<IEmbeddableCartridge> removedCartridges = new ArrayList<IEmbeddableCartridge>();
+ computeAdditionsAndRemovals(addedCartridges, removedCartridges, selectedCartridges);
+ addEmbeddedCartridges(addedCartridges);
+ removeEmbeddedCartridges(removedCartridges);
+ }
+
+ private void removeEmbeddedCartridges(List<IEmbeddableCartridge> removedCartridges) throws OpenShiftException {
+ if (removedCartridges.isEmpty()) {
+ return;
+ }
+ Collections.sort(removedCartridges, new CartridgeComparator());
+ getApplication().removeEmbbedCartridges(removedCartridges);
+ }
+
+ private void addEmbeddedCartridges(List<IEmbeddableCartridge> addedCartridges) throws OpenShiftException {
+ if (addedCartridges.isEmpty()) {
+ return;
+ }
+ Collections.sort(addedCartridges, new CartridgeComparator());
+ getApplication().addEmbbedCartridges(addedCartridges);
+ }
+
+ private void computeAdditionsAndRemovals(List<IEmbeddableCartridge> addedCartridges,
+ List<IEmbeddableCartridge> removedCartridges, List<IEmbeddableCartridge> selectedCartridges)
+ throws OpenShiftException {
+ ListDiff listDiff = Diffs.computeListDiff(getApplication().getEmbeddedCartridges(), selectedCartridges);
+ for (ListDiffEntry entry : listDiff.getDifferences()) {
+ if (entry.isAddition()) {
+ addedCartridges.add((IEmbeddableCartridge) entry.getElement());
+ } else {
+ removedCartridges.add((IEmbeddableCartridge) entry.getElement());
+ }
+ }
+ }
+
+ private static class CartridgeComparator implements Comparator<IEmbeddableCartridge> {
+
+ @Override
+ public int compare(IEmbeddableCartridge thisCartridge, IEmbeddableCartridge thatCartridge) {
+ // mysql has to be added/removed before phpmyadmin
+ if (thisCartridge.equals(IEmbeddableCartridge.MYSQL_51)) {
+ return -1;
+ } else if (thatCartridge.equals(IEmbeddableCartridge.MYSQL_51)) {
+ return 1;
+ }
+ return 0;
+ }
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizard.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizard.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -10,20 +10,9 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.IUser;
-import org.jboss.tools.openshift.express.client.OpenShiftException;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
/**
* @author André Dietisheim
@@ -31,6 +20,8 @@
public class NewApplicationWizard extends Wizard {
private ApplicationWizardModel wizardModel;
+ private NewApplicationWizardPage applicationPage;
+ private EmbedCartridgeWizardPage embedCartridgePage;
public NewApplicationWizard(IUser user) {
this.wizardModel = new ApplicationWizardModel(user);
@@ -39,33 +30,20 @@
@Override
public boolean performFinish() {
- final ArrayBlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
- try {
- WizardUtils.runInWizard(new Job(NLS.bind("Creating application \"{0}\"...", wizardModel.getName())) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- wizardModel.createApplication();
- queue.offer(true);
- } catch (OpenShiftException e) {
- queue.offer(false);
- return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- NLS.bind("Could not create application \"{0}\"", wizardModel.getName()), e);
- }
- return Status.OK_STATUS;
- }
- }, getContainer());
- return queue.poll(10, TimeUnit.SECONDS);
- } catch (Exception e) {
- return false;
+ boolean successfull = true;
+ if (wizardModel.getApplication() == null) {
+ successfull = applicationPage.createApplication();
}
+ if (successfull) {
+ successfull = embedCartridgePage.processCartridges();
+ }
+ return successfull;
}
@Override
public void addPages() {
- addPage(new NewApplicationWizardPage(wizardModel, this));
- addPage(new EmbedCartridgeWizardPage(wizardModel, this));
+ addPage(this.applicationPage = new NewApplicationWizardPage(wizardModel, this));
+ addPage(this.embedCartridgePage = new EmbedCartridgeWizardPage(wizardModel, this));
}
public IApplication getApplication() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-11-21 12:44:41 UTC (rev 36480)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-11-21 12:57:31 UTC (rev 36481)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import java.util.concurrent.ArrayBlockingQueue;
+
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
@@ -49,8 +51,8 @@
private ApplicationWizardModel wizardModel;
public NewApplicationWizardPage(ApplicationWizardModel wizardModel, IWizard wizard) {
- super("Create new OpenShift Express application", "Create new OpenShift Express application",
- "Create new OpenShift Express application", wizard);
+ super("New OpenShift Express Application", "Select a name and an type for your new OpenShift Express application",
+ "NewOpenShiftExpressApplication", wizard);
this.wizardModel = wizardModel;
this.model = new NewApplicationWizardPageModel(wizardModel);
}
@@ -151,9 +153,16 @@
}
}
-
@Override
protected void onPageWillGetDeactivated(Direction progress, final PageChangingEvent event, DataBindingContext dbc) {
+ boolean applicationCreated = createApplication();
+ if (!applicationCreated) {
+ event.doit = false;
+ }
+ }
+
+ public boolean createApplication() {
+ final ArrayBlockingQueue<Boolean> applicationCreated = new ArrayBlockingQueue<Boolean>(1);
try {
WizardUtils.runInWizard(new Job(NLS.bind("Creating application \"{0}\"...", wizardModel.getName())) {
@@ -161,16 +170,19 @@
protected IStatus run(IProgressMonitor monitor) {
try {
wizardModel.createApplication();
+ applicationCreated.offer(true);
+ return Status.OK_STATUS;
} catch (OpenShiftException e) {
- event.doit = false;
- return OpenShiftUIActivator.createErrorStatus("Could not create application \"{0}\"", e, wizardModel.getName());
+ applicationCreated.offer(false);
+ return OpenShiftUIActivator.createErrorStatus("Could not create application \"{0}\"", e,
+ wizardModel.getName());
}
- return Status.OK_STATUS;
}
}, getContainer());
} catch (Exception e) {
// ignore
}
+ return applicationCreated.poll();
}
private class ApplicationNameValidator implements IValidator {
13 years, 1 month
JBoss Tools SVN: r36480 - trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-11-21 07:44:41 -0500 (Mon, 21 Nov 2011)
New Revision: 36480
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9975 - Test updates to show correct errors.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-11-21 12:35:30 UTC (rev 36479)
+++ trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-11-21 12:44:41 UTC (rev 36480)
@@ -15,12 +15,12 @@
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.xml.xpath.core.util.XSLTXPathHelper;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.test.util.WorkbenchUtils;
import org.jboss.tools.vpe.editor.VpeController;
@@ -85,13 +85,12 @@
/*
* Get xml test file
*/
- File xmlTestFile = TestUtil.getComponentFileByFullPath(
- elementPagePath + XML_FILE_EXTENSION, getTestProjectName())
- .getLocation().toFile();
+ IResource xmlFile =TestUtil.getComponentFileByFullPath(elementPagePath + XML_FILE_EXTENSION, getTestProjectName());
/*
* Test that XML test file was found and exists
*/
- assertNotNull("Could not find XML component file '"+elementPagePath + XML_FILE_EXTENSION+"'", elementPageFile); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull("Could not find XML component file '"+elementPagePath + XML_FILE_EXTENSION+"'", xmlFile); //$NON-NLS-1$ //$NON-NLS-2$
+ File xmlTestFile = xmlFile.getLocation().toFile();
/*
* Get document
*/
@@ -286,7 +285,7 @@
// find visual element and check if it is not null
visualElement = findElementById(controller, elementId,TestUtil.MAX_IDLE);
- assertNotNull(visualElement);
+ assertNotNull("Cannot find invisible element with id '"+elementId+"' ", visualElement); //$NON-NLS-1$ //$NON-NLS-2$
// generate text for invisible tag
String modelInvisibleTagText = generateInvisibleTagText(sourceELement
13 years, 1 month