Search in sources :

Example 16 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class CodeGenExternalProcessExecutionTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    this.project = new LaunchConfigTestProject2();
    final String fileNameConsoleConfig = LaunchConfigTestProject2.LAUNCH_CONSOLE_CONFIG_TEST_FILE;
    ILaunchConfiguration launchConfig = loadLaunchConfigFromFile(fileNameConsoleConfig);
    final EclipseLaunchConsoleConfigurationPreferences cfgprefs = new EclipseLaunchConsoleConfigurationPreferences(launchConfig);
    consoleCfg = new ConsoleConfiguration(cfgprefs);
    KnownConfigurations.getInstance().addConfiguration(consoleCfg, true);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) EclipseLaunchConsoleConfigurationPreferences(org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences) LaunchConfigTestProject2(org.hibernate.eclipse.console.test.project.LaunchConfigTestProject2)

Example 17 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class ConsoleConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    cfgXmlFile = new File(temporaryFolder.getRoot(), "hibernate.cfg.xml");
    FileWriter fw = new FileWriter(cfgXmlFile);
    fw.write(HIBERNATE_CFG_XML);
    fw.close();
    TestConsoleConfigurationPreferences cfgprefs = new TestConsoleConfigurationPreferences(cfgXmlFile);
    consoleCfg = new ConsoleConfiguration(cfgprefs);
    service = consoleCfg.getHibernateExtension().getHibernateService();
    typeFactory = service.newTypeFactory();
    KnownConfigurations.getInstance().addConfiguration(consoleCfg, true);
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) FileWriter(java.io.FileWriter) File(java.io.File) TestConsoleConfigurationPreferences(org.jboss.tools.hibernate.orm.test.utils.TestConsoleConfigurationPreferences) Before(org.junit.Before)

Example 18 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class HQLEditorTest method testHQLEditorCodeCompletionWithTabs.

@Test
public void testHQLEditorCodeCompletionWithTabs() throws CoreException, NoSuchFieldException, IllegalAccessException {
    cleanUpProject();
    project = new SimpleTestProjectWithMapping(PROJ_NAME);
    IPackageFragmentRoot sourceFolder = project.createSourceFolder();
    IPackageFragment pf = sourceFolder.createPackageFragment(SimpleTestProject.PACKAGE_NAME, false, null);
    ConsoleConfigUtils.customizeCfgXmlForPack(pf);
    List<IPath> libs = new ArrayList<IPath>();
    project.generateClassPath(libs, sourceFolder);
    project.fullBuild();
    // setup console configuration
    IPath cfgFilePath = new Path(project.getIProject().getName() + File.separator + TestProject.SRC_FOLDER + File.separator + ConsoleConfigUtils.CFG_FILE_NAME);
    ConsoleConfigUtils.createConsoleConfig(PROJ_NAME, cfgFilePath, CONSOLE_NAME);
    ConsoleConfiguration cc = KnownConfigurations.getInstance().find(CONSOLE_NAME);
    // $NON-NLS-1$
    Assert.assertNotNull("Console Configuration not found", cc);
    cc.build();
    // $NON-NLS-1$
    final String codeCompletionPlaceMarker = " from ";
    final String query = // $NON-NLS-1$
    "select\t \tt1." + codeCompletionPlaceMarker + project.getFullyQualifiedTestClassName() + // $NON-NLS-1$
    " t1";
    IEditorPart editorPart = HibernateConsolePlugin.getDefault().openScratchHQLEditor(CONSOLE_NAME, query);
    // $NON-NLS-1$
    Assert.assertTrue("Opened editor is not HQLEditor", editorPart instanceof HQLEditor);
    HQLEditor editor = (HQLEditor) editorPart;
    Assert.assertEquals(editor.getEditorText(), query);
    QueryInputModel model = editor.getQueryInputModel();
    Assert.assertTrue(model.getParameterCount() == 0);
    editor.setConsoleConfigurationName(CONSOLE_NAME);
    IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    HQLCompletionProcessor processor = new HQLCompletionProcessor(editor);
    int position = query.indexOf(codeCompletionPlaceMarker);
    ICompletionProposal[] proposals = processor.computeCompletionProposals(doc, position);
    Assert.assertTrue(proposals.length > 0);
    cc.reset();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) IEditorPart(org.eclipse.ui.IEditorPart) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) QueryInputModel(org.hibernate.console.QueryInputModel) SimpleTestProjectWithMapping(org.jboss.tools.hibernate.orm.test.utils.project.SimpleTestProjectWithMapping) HQLCompletionProcessor(org.hibernate.eclipse.hqleditor.HQLCompletionProcessor) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) HQLEditor(org.hibernate.eclipse.hqleditor.HQLEditor) IDocument(org.eclipse.jface.text.IDocument) Test(org.junit.Test)

Example 19 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class QueryParametersTest method setUp.

@Before
public void setUp() throws Exception {
    cfgXmlFile = new File(temporaryFolder.getRoot(), "hibernate.cfg.xml");
    FileWriter fw = new FileWriter(cfgXmlFile);
    fw.write(HIBERNATE_CFG_XML);
    fw.close();
    TestConsoleConfigurationPreferences cfgprefs = new TestConsoleConfigurationPreferences(cfgXmlFile);
    consoleCfg = new ConsoleConfiguration(cfgprefs);
    KnownConfigurations.getInstance().addConfiguration(consoleCfg, true);
    service = consoleCfg.getHibernateExtension().getHibernateService();
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) FileWriter(java.io.FileWriter) File(java.io.File) TestConsoleConfigurationPreferences(org.jboss.tools.hibernate.orm.test.utils.TestConsoleConfigurationPreferences) Before(org.junit.Before)

Example 20 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class HibernateJpaOrmModelTests method testNamigStrategyMapping.

@Test
public void testNamigStrategyMapping() {
    ConsoleConfiguration cc = KnownConfigurations.getInstance().find(PROJECT_NAME);
    assertNotNull("Console configuration not found for project " + PROJECT_NAME, cc);
    cc.build();
    assertNotNull("Console configuration build problem", cc.getConfiguration());
    assertNotNull("Naming Strategy not found", cc.getConfiguration().getNamingStrategy());
    assertEquals("ns.NamingStrategy", cc.getConfiguration().getNamingStrategy().getStrategyClassName());
    try {
        jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
    } catch (InterruptedException e) {
        fail(e.getMessage());
    }
    assertNotNull(jpaProject);
    JpaContextRoot rootContextNode = jpaProject.getContextRoot();
    Persistence p = rootContextNode.getPersistenceXml().getRoot();
    assertTrue(p.getPersistenceUnits().iterator().hasNext());
    assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
    HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
    List<MappingFileRef> mfrs = IterableTools.list(hpu.getMappingFileRefs());
    assertTrue(mfrs.size() == 1);
    assertTrue(mfrs.get(0).getMappingFile() instanceof GenericOrmXml);
    GenericOrmXml orm = (GenericOrmXml) mfrs.get(0).getMappingFile();
    checkManyToMany1NS(orm.getRoot().getPersistentType("entity.ManyToMany1"));
    checkManyToMany2NS(orm.getRoot().getPersistentType("entity.ManyToMany2"));
    cc.reset();
}
Also used : JpaContextRoot(org.eclipse.jpt.jpa.core.context.JpaContextRoot) Persistence(org.eclipse.jpt.jpa.core.context.persistence.Persistence) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) GenericOrmXml(org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml) HibernatePersistenceUnit(org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit) MappingFileRef(org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef) Test(org.junit.Test)

Aggregations

ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)107 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)19 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)17 CoreException (org.eclipse.core.runtime.CoreException)16 PartInitException (org.eclipse.ui.PartInitException)13 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)12 KnownConfigurations (org.hibernate.console.KnownConfigurations)11 JavaModelException (org.eclipse.jdt.core.JavaModelException)10 TreePath (org.eclipse.jface.viewers.TreePath)10 Test (org.junit.Test)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 FileNotFoundException (java.io.FileNotFoundException)8 IPath (org.eclipse.core.runtime.IPath)8 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 IService (org.jboss.tools.hibernate.runtime.spi.IService)8 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)7 IEditorPart (org.eclipse.ui.IEditorPart)7 ConsoleConfigurationPreferences (org.hibernate.console.preferences.ConsoleConfigurationPreferences)7 GridLayout (org.eclipse.swt.layout.GridLayout)6