Search in sources :

Example 1 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class EntityGenerationFactory method generateJPAEntities.

/**
 * Creates JPA entities from database by using Hibernate JPA entity generation facility
 * @param cfg database configuration
 * @param prj project
 * @param pkg package where entities will be located
 * @param hbVersion hibernate version
 */
public static void generateJPAEntities(DatabaseConfiguration cfg, String prj, String pkg, String hbVersion, boolean useConsole) {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(prj);
    GenerateEntitiesWizard w = new GenerateEntitiesWizard();
    w.open();
    GenerateEntitiesWizardPage p = new GenerateEntitiesWizardPage(w);
    p.setUseConsole(useConsole);
    p.setPackage(pkg);
    if (!useConsole) {
        p.setHibernateVersion(hbVersion);
        p.setDatabaseConnection(cfg.getProfileName());
    }
    w.finish();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) GenerateEntitiesWizard(org.jboss.tools.hibernate.reddeer.jpt.ui.wizard.GenerateEntitiesWizard) GenerateEntitiesWizardPage(org.jboss.tools.hibernate.reddeer.jpt.ui.wizard.GenerateEntitiesWizardPage)

Example 2 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer 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 3 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class CodeGenerationConfigurationTest method createRevengFile.

private void createRevengFile() {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(prj);
    NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
    wizard.open();
    wizard.next();
    TableFilterWizardPage page = new TableFilterWizardPage(wizard);
    page.setConsoleConfiguration(prj);
    page.refreshDatabaseSchema();
    page.pressInclude();
    wizard.finish();
    EditorHandler.getInstance().closeAll(false);
    pe.open();
    pe.getProject(prj).getProjectItem("hibernate.reveng.xml").open();
    new DefaultEditor("Hibernate Reverse Engineering Editor").activate();
    ReverseEngineeringEditor re = new ReverseEngineeringEditor();
    re.activateDesignTab();
    re.activateOverviewTab();
    re.activateTableFiltersTab();
    re.activateTypeMappingsTab();
    re.activateTableAndColumnsTab();
    try {
        re.selectAllTables("SAKILA.PUBLIC");
    } catch (WaitTimeoutExpiredException e) {
        fail("Cannot add tables - known issue(s) - JBIDE-19443");
    }
    re.activateSourceTab();
    re.save();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) ReverseEngineeringEditor(org.jboss.tools.hibernate.reddeer.mapper.editors.ReverseEngineeringEditor) NewReverseEngineeringFileWizard(org.jboss.tools.hibernate.reddeer.console.wizards.NewReverseEngineeringFileWizard) TableFilterWizardPage(org.jboss.tools.hibernate.reddeer.console.wizards.TableFilterWizardPage) DefaultEditor(org.eclipse.reddeer.workbench.impl.editor.DefaultEditor)

Example 4 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class CodeGenerationKeyWordsTest method createRevengFile.

private void createRevengFile() {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(prj);
    NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
    wizard.open();
    wizard.next();
    TableFilterWizardPage page = new TableFilterWizardPage(wizard);
    page.setConsoleConfiguration(prj);
    page.refreshDatabaseSchema();
    page.pressInclude();
    wizard.finish();
    ReverseEngineeringEditor re = new ReverseEngineeringEditor();
    re.activateSourceTab();
    DefaultStyledText ds = new DefaultStyledText();
    ds.selectPosition(ds.getPositionOfText("</hibernate-reverse-engineering>"));
    ds.insertText("<table catalog=\"SAKILA\" schema=\"PUBLIC\" name=\"ACTOR\">" + "<column name=\"FIRST_NAME\" property=\"implements\" type=\"string\" /></table>");
    re.save();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) DefaultStyledText(org.eclipse.reddeer.swt.impl.styledtext.DefaultStyledText) ReverseEngineeringEditor(org.jboss.tools.hibernate.reddeer.mapper.editors.ReverseEngineeringEditor) NewReverseEngineeringFileWizard(org.jboss.tools.hibernate.reddeer.console.wizards.NewReverseEngineeringFileWizard) TableFilterWizardPage(org.jboss.tools.hibernate.reddeer.console.wizards.TableFilterWizardPage)

Example 5 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class JpaAnnotationGenerationTest method prepare.

@Before
public void prepare() {
    importMavenProject(prj);
    try {
        Path dogLocation = new File("resources/classes/Dog.java").toPath();
        Path ownerLocation = new File("resources/classes/Owner.java").toPath();
        new File("target/" + prj + "/src/main/java/org/test").mkdirs();
        Files.copy(dogLocation, new FileOutputStream("target/" + prj + "/src/main/java/org/test/Dog.java"));
        Files.copy(ownerLocation, new FileOutputStream("target/" + prj + "/src/main/java/org/test/Owner.java"));
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unable to find pom " + prj);
    }
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.getProject(prj).refresh();
}
Also used : Path(java.nio.file.Path) ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) Before(org.junit.Before)

Aggregations

ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)41 Test (org.junit.Test)12 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)10 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)8 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)8 File (java.io.File)6 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)6 PropertyDialog (org.eclipse.reddeer.eclipse.ui.dialogs.PropertyDialog)5 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)5 IOException (java.io.IOException)4 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)4 OpenShiftExplorerView (org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView)4 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)4 TreeItem (org.eclipse.reddeer.swt.api.TreeItem)3 FinishButton (org.eclipse.reddeer.swt.impl.button.FinishButton)3 NextButton (org.eclipse.reddeer.swt.impl.button.NextButton)3 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)3 TextEditor (org.eclipse.reddeer.workbench.impl.editor.TextEditor)3 AfterClass (org.junit.AfterClass)3 Before (org.junit.Before)3