Search in sources :

Example 1 with TreeItem

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

the class ConnectionProfileFactory method createConnectionProfile.

/**
 * Creates Connection profile based on DatabaseRequirement configuration
 * @param conf given database requirement configuration
 */
public static void createConnectionProfile(DatabaseConfiguration cfg) {
    DataSourceExplorerView dse = new DataSourceExplorerView();
    dse.open();
    // TODO implement this in explorer
    // TODO fix explorer name
    DefaultTreeItem item = new DefaultTreeItem("Database Connections");
    item.expand(TimePeriod.DEFAULT);
    List<TreeItem> items = item.getItems();
    for (TreeItem i : items) {
        i.select();
        new ContextMenuItem("Delete").select();
        Shell delete = new DefaultShell("Delete confirmation");
        new YesButton(delete).click();
        new WaitWhile(new ShellIsAvailable(delete));
    }
    DatabaseProfile dbProfile = new DatabaseProfile();
    dbProfile.setDatabase(cfg.getProfileName());
    dbProfile.setDriverDefinition(DriverDefinitionFactory.getDriverDefinition(cfg));
    dbProfile.setHostname(cfg.getJdbcString());
    dbProfile.setName(cfg.getProfileName());
    dbProfile.setPassword(cfg.getPassword());
    dbProfile.setUsername(cfg.getUsername());
    dbProfile.setVendor(cfg.getDriverVendor());
    // Driver Definition creation
    NewCPWizard cpw = new NewCPWizard();
    cpw.open();
    cpw.createDatabaseProfile(dbProfile);
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) Shell(org.eclipse.reddeer.swt.api.Shell) DatabaseProfile(org.eclipse.reddeer.eclipse.datatools.ui.DatabaseProfile) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) DataSourceExplorerView(org.eclipse.reddeer.eclipse.datatools.connectivity.ui.dse.views.DataSourceExplorerView) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) NewCPWizard(org.eclipse.reddeer.eclipse.datatools.connectivity.ui.wizards.NewCPWizard) YesButton(org.eclipse.reddeer.swt.impl.button.YesButton)

Example 2 with TreeItem

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

the class ConnectionProfileFactory method deleteAllConnectionProfiles.

/**
 * Method deletes all connection profiles via Data Source Explorer
 */
public static void deleteAllConnectionProfiles() {
    DataSourceExplorerView dse = new DataSourceExplorerView();
    dse.open();
    List<TreeItem> items = new DefaultTreeItem("Database Connections").getItems();
    for (TreeItem i : items) {
        i.select();
        new ContextMenuItem("Delete").select();
        ;
        Shell delete = new DefaultShell("Delete confirmation");
        new YesButton(delete).click();
        new WaitWhile(new ShellIsAvailable(delete));
    }
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) Shell(org.eclipse.reddeer.swt.api.Shell) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) DataSourceExplorerView(org.eclipse.reddeer.eclipse.datatools.connectivity.ui.dse.views.DataSourceExplorerView) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) YesButton(org.eclipse.reddeer.swt.impl.button.YesButton)

Example 3 with TreeItem

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

the class ProjectConfigurationFactory method setProjectFacetForDB.

/**
 * Sets JPA project facets for given database configuration
 * @param prj given project
 * @param cfg given database configuration
 * @param jpaVersion JPA version (2.0 or 2.1 is supported)
 */
public static void setProjectFacetForDB(String prj, DatabaseConfiguration cfg, String jpaVersion) {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    PropertyDialog pd = pe.getProject(prj).openProperties();
    boolean javaFacet = false;
    FacetsPropertyPage pp = new FacetsPropertyPage(pd);
    pd.select(pp);
    for (TreeItem t : getFacets(pd.getShell())) {
        if (t.getText().equals("Java")) {
            javaFacet = true;
            break;
        }
    }
    if (!javaFacet) {
        pp.selectFacet("Java");
        DefaultHyperlink hyperlink = new DefaultHyperlink();
        hyperlink.activate();
        Shell s = new DefaultShell("Modify Faceted Project");
        new OkButton().click();
        new WaitWhile(new ShellIsAvailable(s));
    }
    pp.selectFacet("JPA");
    pp.selectVersion("JPA", jpaVersion);
    addFurtherJPAConfiguration(jpaVersion, !javaFacet);
    closePreferences(pd);
    new WorkbenchShell().setFocus();
    pe.open();
    pe.selectProjects(prj);
    pd.open();
    // TODO Why this takes so long ?
    pd.select("JPA");
    JpaFacetInstallPage jpaPage = new JpaFacetInstallPage(pd);
    jpaPage.setConnectionProfile(cfg.getProfileName());
    jpaPage.setAutoDiscovery(true);
    closePreferences(pd);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
    checkPersistenceXML(prj);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) DefaultHyperlink(org.eclipse.reddeer.uiforms.impl.hyperlink.DefaultHyperlink) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) Shell(org.eclipse.reddeer.swt.api.Shell) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) PropertyDialog(org.eclipse.reddeer.eclipse.ui.dialogs.PropertyDialog) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) FacetsPropertyPage(org.eclipse.reddeer.eclipse.wst.common.project.facet.ui.FacetsPropertyPage) JpaFacetInstallPage(org.jboss.tools.hibernate.reddeer.wizard.JpaFacetInstallPage)

Example 4 with TreeItem

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

the class CriteriaEditorCodeAssistTest method prepareMaven.

private void prepareMaven() {
    prepareMvn(prj, hbVersion);
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    ProjectConfigurationFactory.setProjectFacetForDB(prj, cfg, jpaVersion);
    KnownConfigurationsView v = new KnownConfigurationsView();
    v.open();
    List<TreeItem> confs = v.getConsoleConfigurations();
    if (confs != null) {
        for (TreeItem i : confs) {
            v.deleteConsoleConfiguration(i.getText());
        }
    }
    EditConfigurationShell confShell = v.addConfiguration();
    confShell.setName(prj);
    EditConfigurationMainPage mainPage = confShell.getMainPage();
    mainPage.setProject(prj);
    mainPage.setType("JPA (jdk 1.5+)");
    mainPage.setDatabaseConnection("[JPA Project Configured Connection]");
    mainPage.setHibernateVersion(hbVersion);
    confShell.ok();
}
Also used : DatabaseConfiguration(org.eclipse.reddeer.requirements.db.DatabaseConfiguration) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) EditConfigurationShell(org.jboss.tools.hibernate.reddeer.console.EditConfigurationShell) EditConfigurationMainPage(org.jboss.tools.hibernate.reddeer.console.EditConfigurationMainPage) KnownConfigurationsView(org.jboss.tools.hibernate.reddeer.console.views.KnownConfigurationsView)

Example 5 with TreeItem

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

the class CriteriaEditorTest method prepareMaven.

private void prepareMaven() {
    prepareMvn(prj, hbVersion);
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    ProjectConfigurationFactory.setProjectFacetForDB(prj, cfg, jpaVersion);
    KnownConfigurationsView v = new KnownConfigurationsView();
    v.open();
    List<TreeItem> confs = v.getConsoleConfigurations();
    if (confs != null) {
        for (TreeItem i : confs) {
            v.deleteConsoleConfiguration(i.getText());
        }
    }
    EditConfigurationShell confShell = v.addConfiguration();
    confShell.setName(prj);
    EditConfigurationMainPage mainPage = confShell.getMainPage();
    mainPage.setProject(prj);
    mainPage.setType("JPA (jdk 1.5+)");
    mainPage.setDatabaseConnection("[JPA Project Configured Connection]");
    mainPage.setHibernateVersion(hbVersion);
    confShell.ok();
}
Also used : DatabaseConfiguration(org.eclipse.reddeer.requirements.db.DatabaseConfiguration) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) EditConfigurationShell(org.jboss.tools.hibernate.reddeer.console.EditConfigurationShell) EditConfigurationMainPage(org.jboss.tools.hibernate.reddeer.console.EditConfigurationMainPage) KnownConfigurationsView(org.jboss.tools.hibernate.reddeer.console.views.KnownConfigurationsView)

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