Skip to content

Commit

Permalink
Photon changed 'Yes' button label to 'Delete' in LaunchConfigurationD…
Browse files Browse the repository at this point in the history
…ialog

Signed-off-by: Rastislav Wagner <rawagner@redhat.com>
  • Loading branch information
rawagner authored and odockal committed Jan 29, 2018
1 parent 08a7380 commit a1f3d49
Showing 1 changed file with 65 additions and 32 deletions.
Expand Up @@ -17,9 +17,11 @@
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.condition.WidgetIsFound;
import org.eclipse.reddeer.core.lookup.WidgetLookup;
import org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.swt.api.Button;
import org.eclipse.reddeer.swt.api.MenuItem;
import org.eclipse.reddeer.swt.api.Shell;
import org.eclipse.reddeer.swt.api.TreeItem;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.PushButton;
Expand All @@ -33,7 +35,8 @@
import org.eclipse.swt.widgets.Tree;

/**
* Common ancestor for both the Run Configurations dialog and Debug configurations dialog.
* Common ancestor for both the Run Configurations dialog and Debug
* configurations dialog.
*
* @author Lucia Jelinkova
*
Expand All @@ -43,7 +46,7 @@ public abstract class LaunchConfigurationsDialog {
private static final Logger log = Logger.getLogger(LaunchConfigurationsDialog.class);

/**
* Return the title of the dialog.
* Return the title of the dialog.
*
* @return Title of the dialog
*/
Expand Down Expand Up @@ -71,43 +74,50 @@ public void open() {
/**
* Select the launch configuration.
*
* @param configuration the configuration
* @param configuration
* the configuration
*/
public void select(LaunchConfiguration configuration) {
log.info("Select launch configuration " + configuration.getType());
TreeItem t = new DefaultTreeItem(configuration.getType());
t.select();
}

/**
* Select the launch configuration with the specified name.
*
* @param configuration the configuration
* @param name the name
* @param configuration
* the configuration
* @param name
* the name
*/
public void select(LaunchConfiguration configuration, String name) {
log.info("Select launch configuration " + configuration.getType() + " with name " + name);
TreeItem t = new DefaultTreeItem(configuration.getType(), name);
t.select();

new WaitUntil(new WidgetIsFound(org.eclipse.swt.custom.CLabel.class, new WithTextMatcher(name)), TimePeriod.DEFAULT, false);
new WaitUntil(new WidgetIsFound(org.eclipse.swt.custom.CLabel.class, new WithTextMatcher(name)),
TimePeriod.DEFAULT, false);
}

/**
* Create new configuration with default name.
*
* @param configuration the configuration
* @param configuration
* the configuration
*/
public void create(LaunchConfiguration configuration){
public void create(LaunchConfiguration configuration) {
log.info("Create new launch configuration " + configuration.getType());
create(configuration, null);
}

/**
* Create new configuration with specified name.
*
* @param configuration the configuration
* @param name the name
* @param configuration
* the configuration
* @param name
* the name
*/
public void create(LaunchConfiguration configuration, String name) {
log.info("Create new launch configuration " + configuration.getType() + " with name " + name);
Expand All @@ -126,36 +136,49 @@ public void create(LaunchConfiguration configuration, String name) {
/**
* Delete the configuration with specified name.
*
* @param configuration the configuration
* @param name the name
* @param configuration
* the configuration
* @param name
* the name
*/
public void delete(LaunchConfiguration configuration, String name){
public void delete(LaunchConfiguration configuration, String name) {
log.info("Delete launch configuration " + configuration.getType() + " with name " + name);
TreeItem t = new DefaultTreeItem(configuration.getType(), name);
t.select();

new ContextMenuItem("Delete").select();
new YesButton().click();
Shell deleteShell = new DefaultShell("Confirm Launch Configuration Deletion");
WidgetIsFound deleteButton = new WidgetIsFound(org.eclipse.swt.widgets.Button.class, deleteShell.getSWTWidget(),
new WithMnemonicTextMatcher("Delete"));

Button button;
if (deleteButton.test()) {
button = new PushButton(deleteShell, "Delete"); // photon changed button text
} else {
button = new YesButton(deleteShell);
}
button.click();
new WaitWhile(new ShellIsAvailable(deleteShell));
}

/**
* Run the selected run configuration.
*/
public void run(){
public void run() {
log.info("Run the launch configuration");

String shellText = new DefaultShell().getText();
Button button = new PushButton("Run");
button.click();

new WaitWhile(new ShellIsAvailable(shellText), TimePeriod.VERY_LONG);
new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
}

/**
* Close the dialog.
*/
public void close(){
public void close() {
log.info("Close the launch configuration dialog");

String shellText = new DefaultShell().getText();
Expand All @@ -165,46 +188,56 @@ public void close(){
new WaitWhile(new ShellIsAvailable(shellText));
new WaitWhile(new JobIsRunning());
}
private class TreeIsSelectedAndHasFocus extends AbstractWaitCondition{

private class TreeIsSelectedAndHasFocus extends AbstractWaitCondition {

private TreeItem item;

public TreeIsSelectedAndHasFocus(TreeItem item) {
this.item = item;
}

@Override
public boolean test() {
Control focusControl = WidgetLookup.getInstance().getFocusControl();
if (!(focusControl instanceof Tree)){
if (!(focusControl instanceof Tree)) {
return false;
}
return item.isSelected();
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.reddeer.common.condition.AbstractWaitCondition#description()
*/
@Override
public String description() {
return "Tree has focus and TreeItem "+item.getText()+" is selected";
return "Tree has focus and TreeItem " + item.getText() + " is selected";
}

/* (non-Javadoc)
* @see org.eclipse.reddeer.common.condition.AbstractWaitCondition#errorMessageWhile()
/*
* (non-Javadoc)
*
* @see
* org.eclipse.reddeer.common.condition.AbstractWaitCondition#errorMessageWhile(
* )
*/
@Override
public String errorMessageWhile() {
return "TreeItem '" + item.getText() + "' has focus and is selected ";
}

/* (non-Javadoc)
* @see org.eclipse.reddeer.common.condition.AbstractWaitCondition#errorMessageUntil()

/*
* (non-Javadoc)
*
* @see
* org.eclipse.reddeer.common.condition.AbstractWaitCondition#errorMessageUntil(
* )
*/
@Override
public String errorMessageUntil() {
return "Tree does not has focus or TreeItem '"+item.getText()+"' is not selected";
return "Tree does not has focus or TreeItem '" + item.getText() + "' is not selected";
}
}
}

0 comments on commit a1f3d49

Please sign in to comment.