Skip to content

Commit

Permalink
Issue #1936 Upgrade JavaProjectWizard parts
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <odockal@redhat.com>

	modified:   plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/m2e/core/ui/wizard/MavenProjectWizardArtifactPage.java
  • Loading branch information
odockal committed Aug 15, 2018
1 parent 42cd36d commit a7fb4d9
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 11 deletions.
Expand Up @@ -11,7 +11,16 @@
*******************************************************************************/
package org.eclipse.reddeer.eclipse.jdt.ui.wizards;

import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.eclipse.selectionwizard.NewMenuWizard;
import org.eclipse.reddeer.jface.condition.WindowIsAvailable;
import org.eclipse.reddeer.swt.api.Button;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.FinishButton;
import org.eclipse.reddeer.swt.impl.shell.DefaultShell;
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;

/**
* Wizard dialog for creating new Java project.
Expand All @@ -25,4 +34,45 @@ public JavaProjectWizard() {
super("New Java Project", "Java", "Java Project");
}

@Override
public void finish(TimePeriod timeout) {
finish(timeout, false, "");
}

public void finish(boolean createModule, String moduleName) {
finish(TimePeriod.LONG, createModule, moduleName);
}

/**
* Click the finish button in wizard dialog and deal with module-info.java file dialog
* @param timeout
* @param createModule
* @param moduleName
*/
public void finish(TimePeriod timeout, boolean createModule, String moduleName) {
checkShell();
log.info("Finish wizard");

Button button = new FinishButton(this);
button.click();

ShellIsAvailable moduleShell = new ShellIsAvailable("New module-info.java");
new WaitUntil(moduleShell, TimePeriod.MEDIUM, false);
if (moduleShell.getResult() != null) {
NewModuleInfoDialog moduleDialog = new NewModuleInfoDialog(new DefaultShell(moduleShell.getResult()));
if (createModule) {
if (moduleName != null && !moduleName.isEmpty()) {
moduleDialog.setModuleName(moduleName);
}
moduleDialog.create();
} else {
moduleDialog.dontCreate();
}
new WaitWhile(moduleShell, TimePeriod.DEFAULT);
}

new WaitWhile(new WindowIsAvailable(this), timeout);
new WaitWhile(new JobIsRunning(), timeout);
}

}
Expand Up @@ -14,6 +14,8 @@
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.wizard.WizardPage;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.combo.DefaultCombo;
import org.eclipse.reddeer.swt.impl.text.LabeledText;

/**
Expand Down Expand Up @@ -45,7 +47,7 @@ public NewJavaProjectWizardPageOne setProjectName(String projectName) {
* Sets whether to use default location.
*
* @param check
* Indicates whether to use dafualt location
* Indicates whether to use default location
*/
public NewJavaProjectWizardPageOne useDefaultLocation(boolean check) {
CheckBox box = new CheckBox(this, "Use default location");
Expand All @@ -66,5 +68,35 @@ public NewJavaProjectWizardPageOne setLocation(String location) {
text.setText(location);
return this;
}

/**
* Sets whether to use project specific JRE
* @param env
* String representation of specific JRE to use
* @return
* this page object
*/
public NewJavaProjectWizardPageOne useProjectSpecificJRE(String env) {
log.debug("Setting active button 'Use a project specific JRE'");
new RadioButton(referencedComposite, "Use a project specific JRE: ").toggle(true);
log.debug("Selecting '" + env + "'");
new DefaultCombo(referencedComposite, 0).setSelection(env);
return this;
}

/**
* Sets whether to use execution JRE environment
* @param env
* String representation of specific JRE to use
* @return
* this page object
*/
public NewJavaProjectWizardPageOne useExecutionEnvironmentJRE(String env) {
log.debug("Setting active button 'Use an execution environment JRE'");
new RadioButton(referencedComposite, "Use an execution environment JRE:").toggle(true);
log.debug("Selecting '" + env + "'");
new DefaultCombo(referencedComposite, 0).setSelection(env);
return this;
}

}
@@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2018 Red Hat, Inc and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.eclipse.jdt.ui.wizards;

import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.wizard.WizardPage;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.text.LabeledText;

/**
* New Java Project wizard page number two
* @author odockal
*
*/
public class NewJavaProjectWizardPageTwo extends WizardPage {

public NewJavaProjectWizardPageTwo(ReferencedComposite referencedComposite) {
super(referencedComposite);
}

/**
* Sets whether to create module-info.java file
* @param check
* Indicates whether to create module-info.java file
* @return
*/
public NewJavaProjectWizardPageTwo createModuleInfoFile(boolean check) {
CheckBox box = new CheckBox(this, "Create module-info.java file");
log.debug("Setting 'Create module-info.java file' to " + check);
box.toggle(check);
return this;
}

/**
* Sets whether to allow output folder for source folders
* @param check
* Indicates whether to allow output folder for source folders
* @return
* this object
*/
public NewJavaProjectWizardPageTwo allowOutputFoldersForSourceFolders(boolean check) {
CheckBox box = new CheckBox(this, "Allow output folders for source folders");
log.debug("Setting 'Allow output folders for source folders' to " + check);
box.toggle(check);
return this;
}

/**
* Sets default output folder location
* @param location
* Default output folder location
* @return
* this object
*/
public NewJavaProjectWizardPageTwo setDefaultOutputFolder(String location) {
log.debug("Setting 'Default output folder' to '" + location + "'");
LabeledText text = new LabeledText(this, "Default output folder:");
text.setText(location);
return this;
}

}
@@ -0,0 +1,42 @@
package org.eclipse.reddeer.eclipse.jdt.ui.wizards;

import org.eclipse.reddeer.jface.dialogs.TitleAreaDialog;
import org.eclipse.reddeer.swt.api.Shell;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.text.LabeledText;
import org.hamcrest.Matcher;

/**
* New Module info java file dialog
* @author odockal
*
*/
public class NewModuleInfoDialog extends TitleAreaDialog {

public NewModuleInfoDialog(Shell shell) {
super(shell);
}

public NewModuleInfoDialog(String text) {
super(text);
}

public NewModuleInfoDialog(Matcher<?>... matchers) {
super(matchers);
}

public void setModuleName(String name) {
log.debug("Setting module name to '" + name + "'");
new LabeledText("Module name:").setText(name);
}

public void dontCreate() {
log.debug("Don't create module-info.java file");
new PushButton("Don't Create").click();
}

public void create() {
log.debug("Creating module-info.java file");
new PushButton("Create").click();
}
}
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.core.IsEqual;

/**
* Class represents Maven preference page
Expand Down
Expand Up @@ -12,7 +12,6 @@
package org.eclipse.reddeer.eclipse.m2e.core.ui.wizard;

import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.wizard.WizardDialog;
import org.eclipse.reddeer.jface.wizard.WizardPage;
import org.eclipse.reddeer.swt.impl.combo.LabeledCombo;
import org.eclipse.reddeer.swt.impl.group.DefaultGroup;
Expand Down
Expand Up @@ -12,7 +12,6 @@
package org.eclipse.reddeer.eclipse.rse.ui.wizards.newconnection;

import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.wizard.WizardDialog;
import org.eclipse.reddeer.jface.wizard.WizardPage;
import org.eclipse.reddeer.swt.impl.tree.DefaultTree;
import org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem;
Expand Down
Expand Up @@ -35,7 +35,7 @@
* @since 0.6
*
*/
public class WizardDialog extends TitleAreaDialog{
public class WizardDialog extends TitleAreaDialog {

protected final Logger log = Logger.getLogger(this.getClass());

Expand Down
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizard;
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizardArchetypeParametersPage;
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizardPage;
import org.eclipse.reddeer.eclipse.test.debug.core.DebuggerTest;
import org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.eclipse.reddeer.swt.api.TreeItem;
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewClassCreationWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
import org.eclipse.reddeer.eclipse.ui.console.ConsoleView;
import org.eclipse.reddeer.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.reddeer.eclipse.ui.navigator.resources.AbstractExplorer;
import org.eclipse.reddeer.eclipse.ui.perspectives.JavaPerspective;
Expand Down
Expand Up @@ -9,7 +9,7 @@
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.eclipse.test.jdt;
package org.eclipse.reddeer.eclipse.test.jdt.ui.wizards;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down

0 comments on commit a7fb4d9

Please sign in to comment.