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);
}
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));
}
}
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);
}
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();
}
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();
}
Aggregations