Skip to content

Commit

Permalink
Adjust TitleAreaDialog and MavenPreferencePage, fixes #2097
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed Oct 20, 2020
1 parent 2ba594b commit a619509
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.dialogs.TitleAreaDialog;
import org.eclipse.reddeer.jface.preference.PreferencePage;
import org.eclipse.reddeer.swt.api.Shell;
import org.eclipse.reddeer.swt.api.Table;
import org.eclipse.reddeer.swt.api.TableItem;
import org.eclipse.reddeer.swt.api.Text;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.OkButton;
import org.eclipse.reddeer.swt.impl.button.PushButton;
Expand Down Expand Up @@ -108,15 +108,15 @@ public String addRemoteCatalog(String catalogFileURL, String description) {
public String addRemoteCatalog(String catalogFileURL, String description, boolean verify) {
String verificationResult = "";
new PushButton(this, ADD_REMOTE_CATALOG).click();
Shell remoteCatalogShell = new DefaultShell(REMOTE_CATALOG_SHELL);
TitleAreaDialog remoteCatalogShell = new TitleAreaDialog(REMOTE_CATALOG_SHELL);
new DefaultCombo(remoteCatalogShell).setText(catalogFileURL);
new LabeledText(remoteCatalogShell, CATALOG_DESCRIPTION).setText(description);
if (verify) {
verificationResult = verifyURL(remoteCatalogShell);
}
log.info(verificationResult);
new OkButton(remoteCatalogShell).click();
new WaitWhile(new ShellIsAvailable(remoteCatalogShell));
new WaitWhile(new ShellIsAvailable(remoteCatalogShell.getShell()));
return verificationResult;
}

Expand Down Expand Up @@ -226,15 +226,15 @@ private String editCatalog(String catalogName, String catalogFile, String descri
String verificationResult = "";
selectCatalog(catalogName);
new PushButton(this, EDIT_CATALOG).click();
Shell editShell = new DefaultShell(new WithTextMatcher(new RegexMatcher(".* Archetype Catalog")));
TitleAreaDialog editShell = new TitleAreaDialog(new WithTextMatcher(new RegexMatcher(".* Archetype Catalog")));
new DefaultCombo(editShell).setText(catalogFile);
new LabeledText(editShell, CATALOG_DESCRIPTION).setText(description);
if (verify) {
verificationResult = verifyURL(editShell);
}
log.info(verificationResult);
new OkButton(editShell).click();
new WaitWhile(new ShellIsAvailable(editShell));
new WaitWhile(new ShellIsAvailable(editShell.getShell()));
return verificationResult;
}

Expand Down Expand Up @@ -273,11 +273,10 @@ public MavenArchetypesPreferencePage selectCatalog(String catalogName) {
*
* @return result of verification
*/
protected String verifyURL(ReferencedComposite composite) {
protected String verifyURL(TitleAreaDialog composite) {
new PushButton(composite, VERIFY_BUTTON).click();
new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
Text labeledText = new LabeledText(composite, REMOTE_CATALOG_SHELL);
String text = labeledText.getText();
String text = composite.getMessage();
return text;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ public String getTitle() {
*/
public String getMessage() {
checkShell();
String message = getMessageLabel().getText();
// Page Message is 5th Text within first Composite of TitleAreaDialog and is inactive
Control textControl = handler.getChildren(getShellComposite())[4];
String message = "";
if (textControl instanceof org.eclipse.swt.widgets.Label) {
message = getMessageLabel(textControl).getText();
} else {
message = getMessageText(textControl).getText();
}
if(getMessageImage() != null){ //if image is shown TitleAreaDialog adds whitespace before message
message = message.substring(1);
}
Expand Down Expand Up @@ -133,10 +140,12 @@ public Image getTitleImage(){
return new DefaultLabel((Label)imageControl).getImage();
}

protected org.eclipse.reddeer.swt.api.Text getMessageLabel(){
// Page Message is 5th Text within first Composite of TitleAreaDialog and is inactive
Control textControl = handler.getChildren(getShellComposite())[4];
return new DefaultText((Text)textControl);
protected org.eclipse.reddeer.swt.api.Label getMessageLabel(Control control){
return new DefaultLabel((Label)control);
}

protected org.eclipse.reddeer.swt.api.Text getMessageText(Control control){
return new DefaultText((Text)control);
}

protected Composite getShellComposite(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class MavenArchetypesPreferencePageTest {

private static final String LOCAL_CATALOG_DESCRIPTION = "Local Test Catalog";
private static final String REMOTE_CATALOG_FILE = "http://repo1.maven.org/maven2/archetype-catalog.xml";
private static final String REMOTE_CATALOG_FILE = "https://repo1.maven.org/maven2/archetype-catalog.xml";
private static final String REMOTE_CATALOG_DESCRIPTION = "Remote Test Catalog";
private static final String EMPTY_CATALOG_MESSAGE = "Remote catalog is empty";

Expand Down

0 comments on commit a619509

Please sign in to comment.