Search in sources :

Example 11 with TreeItem

use of org.eclipse.reddeer.swt.api.TreeItem in project jbosstools-openshift by jbosstools.

the class LinkToCreateNewProjectTest method createOpenShiftProjectViaLinkInExplorer.

@Test
public void createOpenShiftProjectViaLinkInExplorer() {
    OpenShiftExplorerView explorer = new OpenShiftExplorerView();
    OpenShiftUtils.deleteAllProjects(connectionReq.getConnection());
    TreeItem connectionItem = explorer.getOpenShift3Connection(connectionReq.getConnection()).getTreeItem();
    TreeItem newProjectLinkItem = null;
    try {
        newProjectLinkItem = connectionItem.getItem("No projects are available. Click here to create a new project...");
    } catch (RedDeerException ex) {
        fail("There is no link to create a new project even connection does not have any project.");
    }
    TreeItemHandler.getInstance().click(newProjectLinkItem.getSWTWidget());
    try {
        new DefaultShell(OpenShiftLabel.Shell.CREATE_OS_PROJECT);
    } catch (RedDeerException ex) {
        fail("Create new OpenShift project shell has not been opened.");
    }
    new LabeledText(OpenShiftLabel.TextLabels.PROJECT_NAME).setText(projectName);
    new WaitUntil(new ControlIsEnabled(new FinishButton()));
    new FinishButton().click();
    projectCreated = true;
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.CREATE_OS_PROJECT), TimePeriod.LONG);
    assertTrue("OpenShift project is not visible in OpenShift Explorer under the connection" + " although it should have been created successfully and visible.", explorer.getOpenShift3Connection(connectionReq.getConnection()).projectExists(projectName));
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) FinishButton(org.eclipse.reddeer.swt.impl.button.FinishButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) LabeledText(org.eclipse.reddeer.swt.impl.text.LabeledText) ControlIsEnabled(org.eclipse.reddeer.swt.condition.ControlIsEnabled) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 12 with TreeItem

use of org.eclipse.reddeer.swt.api.TreeItem in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerView method getConnectionItem.

private TreeItem getConnectionItem(String server, String username) {
    open();
    if (username == null) {
        username = TreeViewerHandler.getInstance().getNonStyledText(new DefaultTree().getItems().get(0));
    }
    TreeItem connectionItem = treeViewerHandler.getTreeItem(new DefaultTree(), username);
    if (server != null && DatastoreOS3.AUTH_METHOD.equals(AuthenticationMethod.OAUTH)) {
        if (treeViewerHandler.getStyledTexts(connectionItem)[0].equals(server)) {
            return connectionItem;
        } else {
            throw new OpenShiftToolsException("There is no connection with specified server " + server + " and username " + username);
        }
    } else {
        return connectionItem;
    }
}
Also used : DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) OpenShiftToolsException(org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException)

Example 13 with TreeItem

use of org.eclipse.reddeer.swt.api.TreeItem in project jbosstools-openshift by jbosstools.

the class Service method getPod.

/**
 * Gets first pod matching a specified matcher.
 *
 * @param nameMatcher name matcher of a pod
 * @return Pod belonging to an OpenShift service if there is any matching
 * 	a specified matcher; null otherwise.
 */
@SuppressWarnings("unchecked")
public Pod getPod(Matcher<String>... matchers) {
    for (TreeItem treeItem : item.getItems()) {
        if (!treeItem.isDisposed()) {
            String treeItemText = treeItem.getText();
            boolean matches = true;
            for (Matcher<String> matcher : matchers) {
                if (!matcher.matches(treeItemText)) {
                    matches = false;
                    break;
                }
            }
            if (matches) {
                return new Pod(treeItem);
            }
        }
    }
    return null;
}
Also used : TreeItem(org.eclipse.reddeer.swt.api.TreeItem)

Example 14 with TreeItem

use of org.eclipse.reddeer.swt.api.TreeItem in project jbosstools-openshift by jbosstools.

the class OpenShift3Connection method getAllProjects.

/**
 * Gets all projects existing on a connection.
 *
 * @return list of all projects for a connection.
 */
public List<OpenShiftProject> getAllProjects() {
    List<OpenShiftProject> projects = new ArrayList<OpenShiftProject>();
    activateOpenShiftExplorerView();
    item.select();
    item.expand();
    for (TreeItem treeItem : item.getItems()) {
        projects.add(new OpenShiftProject(treeItem));
    }
    return projects;
}
Also used : TreeItem(org.eclipse.reddeer.swt.api.TreeItem) ArrayList(java.util.ArrayList)

Example 15 with TreeItem

use of org.eclipse.reddeer.swt.api.TreeItem in project linuxtools by eclipse.

the class DockerExplorerView method getDockerConnectionNames.

/**
 * Gets names of all docker connections present in docker explorer.
 *
 * @return list of docker connections names
 */
public List<String> getDockerConnectionNames() {
    activate();
    List<String> connectionsNames = new ArrayList<String>();
    try {
        List<TreeItem> connections = new DefaultTree().getItems();
        for (TreeItem item : connections) {
            connectionsNames.add(getName(item));
        }
    } catch (CoreLayerException ex) {
    // no connections in view
    }
    return connectionsNames;
}
Also used : DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) ArrayList(java.util.ArrayList) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException)

Aggregations

TreeItem (org.eclipse.reddeer.swt.api.TreeItem)27 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)10 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)9 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)9 DefaultTreeItem (org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem)8 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)7 DefaultTree (org.eclipse.reddeer.swt.impl.tree.DefaultTree)7 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)6 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)6 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)6 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)5 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)5 ArrayList (java.util.ArrayList)4 ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)4 Shell (org.eclipse.reddeer.swt.api.Shell)4 Test (org.junit.Test)4 LaunchView (org.eclipse.reddeer.eclipse.debug.ui.views.launch.LaunchView)3 CaptureScreenshotException (org.eclipse.reddeer.junit.screenshot.CaptureScreenshotException)3 PushButton (org.eclipse.reddeer.swt.impl.button.PushButton)3 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)3