Author: ljelinko
Date: 2012-01-24 09:40:32 -0500 (Tue, 24 Jan 2012)
New Revision: 38095
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/ImportingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/project/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/project/ExistingProjectImportTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/project/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/project/ExistingProjectWizardPageFillingTask.java
Log:
Created task for import
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/ImportingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/ImportingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/ImportingTask.java 2012-01-24
14:40:32 UTC (rev 38095)
@@ -0,0 +1,54 @@
+package org.jboss.tools.portlet.ui.bot.task.importing;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.tools.portlet.ui.bot.task.AbstractSWTTask;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.gen.IImport;
+
+/**
+ * Imports the specified object under the specified category.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ImportingTask extends AbstractSWTTask {
+
+ private String category;
+
+ private String name;
+
+ public ImportingTask(String name) {
+ super();
+ this.name = name;
+ }
+
+ public ImportingTask(String category, String name) {
+ super();
+ this.category = category;
+ this.name = name;
+ }
+
+ @Override
+ public void perform() {
+ IImport importPath = new IImport() {
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ if (category == null){
+ return Collections.emptyList();
+ }
+
+ return Arrays.asList(category.split("/"));
+ }
+ };
+ SWTBotFactory.getOpen().newImport(importPath);
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/project/ExistingProjectImportTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/project/ExistingProjectImportTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/importing/project/ExistingProjectImportTask.java 2012-01-24
14:40:32 UTC (rev 38095)
@@ -0,0 +1,17 @@
+package org.jboss.tools.portlet.ui.bot.task.importing.project;
+
+import org.jboss.tools.portlet.ui.bot.task.importing.ImportingTask;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+/**
+ * Loads dialog for importing existing project into the workspace.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ExistingProjectImportTask extends ImportingTask {
+
+ public ExistingProjectImportTask() {
+ super(ActionItem.Import.GeneralExistingProjectsintoWorkspace.LABEL.getGroupPath().get(0),
ActionItem.Import.GeneralExistingProjectsintoWorkspace.LABEL.getName());
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/project/ExistingProjectWizardPageFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/project/ExistingProjectWizardPageFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/wizard/importing/project/ExistingProjectWizardPageFillingTask.java 2012-01-24
14:40:32 UTC (rev 38095)
@@ -0,0 +1,112 @@
+package org.jboss.tools.portlet.ui.bot.task.wizard.importing.project;
+
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.portlet.ui.bot.task.AbstractSWTTask;
+import org.jboss.tools.portlet.ui.bot.task.wizard.WizardPageFillingTask;
+
+/**
+ * Fills the wizard page for importing existing projects into workspace.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ExistingProjectWizardPageFillingTask extends AbstractSWTTask implements
WizardPageFillingTask {
+
+ private String[] projectNames;
+
+ private String projectPath;
+
+ private String zipFilePath;
+
+ private boolean copyProjectsIntoWorkspace;
+
+ public ExistingProjectWizardPageFillingTask() {
+ super();
+ }
+
+ @Override
+ public void perform() {
+ loadProjects();
+ selectProjects();
+ }
+
+ private void loadProjects() {
+ if (projectPath != null && zipFilePath != null){
+ throw new IllegalArgumentException("You have to choose between folder and ZIP
path");
+ }
+
+ if (projectPath != null){
+ loadProjectsFromFolder();
+ return;
+ }
+
+ if (zipFilePath != null){
+ loadProjectsFromZIP();
+ return;
+ }
+
+ throw new IllegalArgumentException("You have to provide either folder or ZIP
path");
+ }
+
+ private void loadProjectsFromFolder() {
+ getBot().text(0).setText(projectPath);
+ KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.TAB);
+ }
+
+ private void loadProjectsFromZIP() {
+ getBot().radio("Select archive file:").click();
+ getBot().text(1).setText(zipFilePath);
+ KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.TAB);
+ }
+
+ private void selectProjects() {
+ selectCopyProjectsIntoWorkspace();
+ getBot().button("Deselect All").click();
+ SWTBotTree projectsTree = getBot().treeWithLabel("Projects:");
+ for (String projectName : projectNames){
+ SWTBotTreeItem projectItem = projectsTree.getTreeItem(getProjectLabel(projectName));
+ projectItem.check();
+ }
+ }
+
+ private void selectCopyProjectsIntoWorkspace() {
+ if (isFileSystem()){
+ if (copyProjectsIntoWorkspace){
+ getBot().checkBox("Copy projects into workspace").select();
+ } else {
+ getBot().checkBox("Copy projects into workspace").deselect();
+ }
+ }
+ }
+
+ private String getProjectLabel(String project){
+ if (isFileSystem()){
+ return project + " (" + projectPath + "/" + project +
")";
+ } else {
+ return project + " (" + project + ")";
+ }
+ }
+
+ private boolean isFileSystem(){
+ return projectPath != null;
+ }
+
+ public void setProjectNames(String... projectNames) {
+ this.projectNames = projectNames;
+ }
+
+ public void setProjectPath(String projectPath) {
+ this.projectPath = projectPath;
+ }
+
+ public void setZipFilePath(String zipFilePath) {
+ this.zipFilePath = zipFilePath;
+ }
+
+ public void setCopyProjectsIntoWorkspace(boolean copyProjectsIntoWorkspace) {
+ this.copyProjectsIntoWorkspace = copyProjectsIntoWorkspace;
+ }
+}
Show replies by date