Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Hardening for handling project import, fixes #2168
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Dockal <[email protected]>
  • Loading branch information
odockal committed May 4, 2022
1 parent 778066a commit 32580d5
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.reddeer.common.logging.Logger;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.core.exception.CoreLayerException;
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.eclipse.exception.EclipseLayerException;
import org.eclipse.reddeer.jface.wizard.WizardPage;
Expand Down Expand Up @@ -113,6 +114,8 @@ public List<ImportProject> getProjects(){
for (TreeItem item : projectsTree.getItems()){
ImportProject project = new ImportProject();
project.isChecked = item.isChecked();
// workaround to force wait for treeItem to get visible
item.expand();
project.name = getProjectLabel(item.getText());
projects.add(project);
}
Expand Down Expand Up @@ -177,7 +180,12 @@ private boolean isFileSystem() {
}

private Tree getProjectsTree() {
return new DefaultTree(this);
DefaultTree tree = new DefaultTree(this);
if (tree.isEnabled() && tree.isFocusControl() && tree.isVisible()) {
return tree;
} else {
return new DefaultTree(this);
}
}

private TreeItem getProjectTreeItem(Tree projectsTree, String projectName) {
Expand All @@ -190,7 +198,17 @@ private TreeItem getProjectTreeItem(Tree projectsTree, String projectName) {
}

private String getProjectLabel(String project){
return project.substring(0, project.indexOf('(')).trim();
// we expect this form of the project string: my.project (/path/to/my.project)
if (project.isBlank()) {
throw new CoreLayerException("Project " + project + " is not available in the imported projects");
}
if (project.indexOf('(') == -1) {
// if there is missing '(' we and project is non empty, return trimmed project string
return project.trim();
} else {
// return trimmed project without its path in brackets
return project.substring(0, project.indexOf('(')).trim();
}
}

private class ProjectIsLoaded extends AbstractWaitCondition {
Expand Down

0 comments on commit 32580d5

Please sign in to comment.