Search in sources :

Example 11 with ConsoleConfigurationPreferences

use of org.hibernate.console.preferences.ConsoleConfigurationPreferences in project jbosstools-hibernate by jbosstools.

the class GenerateInitWizardPage method createConsoleConfiguration.

private String createConsoleConfiguration() {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String dialect = determineDialect();
    String ccName = launchManager.generateLaunchConfigurationName(HibernateConsoleMessages.AddConfigurationAction_hibernate);
    ConsoleConfigurationPreferences prefs = new EclipseConsoleConfigurationPreferences(ccName, ConfigurationMode.JPA, getHibernateVersion(), jpaProject.getName(), true, null, null, null, new IPath[0], new IPath[0], null, null, getConnectionProfileName(), dialect);
    ConsoleConfiguration cc = new ConsoleConfiguration(prefs);
    KnownConfigurations.getInstance().addConfiguration(cc, false);
    return ccName;
}
Also used : EclipseConsoleConfigurationPreferences(org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) EclipseConsoleConfigurationPreferences(org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 12 with ConsoleConfigurationPreferences

use of org.hibernate.console.preferences.ConsoleConfigurationPreferences in project jbosstools-hibernate by jbosstools.

the class KnownConfigurationsTest method testKnownConfigurations.

@Test
public void testKnownConfigurations() {
    KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
    ConsoleConfiguration[] configurations = knownConfigurations.getConfigurations();
    Assert.assertEquals(0, configurations.length);
    CCListener listener = new CCListener();
    try {
        knownConfigurations.addConsoleConfigurationListener(listener);
        Assert.assertEquals(0, listener.added.size());
        ConsoleConfigurationPreferences preferences = new ConsoleConfigurationPreferences() {

            public void setName(String name) {
            }

            public void readStateFrom(Element element) {
            }

            public void writeStateTo(Element node) {
            }

            public File getPropertyFile() {
                return null;
            }

            public File getConfigXMLFile() {
                return null;
            }

            public Properties getProperties() {
                return null;
            }

            public File[] getMappingFiles() {
                return null;
            }

            public URL[] getCustomClassPathURLS() {
                return null;
            }

            public String getName() {
                return TestConsoleMessages.KnownConfigurationsTest_fake_prefs;
            }

            public String getEntityResolverName() {
                return null;
            }

            public ConfigurationMode getConfigurationMode() {
                return null;
            }

            public String getNamingStrategy() {
                return null;
            }

            public String getPersistenceUnitName() {
                return null;
            }

            public String getConnectionProfileName() {
                return null;
            }

            public String getDialectName() {
                return null;
            }

            public String getHibernateVersion() {
                return null;
            }
        };
        ConsoleConfigurationPreferences preferences2 = new ConsoleConfigurationPreferences() {

            String name = TestConsoleMessages.KnownConfigurationsTest_new_test;

            public void setName(String name) {
                this.name = name;
            }

            public void readStateFrom(Element element) {
            }

            public void writeStateTo(Element node) {
            }

            public File getPropertyFile() {
                return null;
            }

            public File getConfigXMLFile() {
                return null;
            }

            public Properties getProperties() {
                return null;
            }

            public File[] getMappingFiles() {
                return null;
            }

            public URL[] getCustomClassPathURLS() {
                return null;
            }

            public String getName() {
                return name;
            }

            public String getEntityResolverName() {
                return null;
            }

            public ConfigurationMode getConfigurationMode() {
                return null;
            }

            public String getNamingStrategy() {
                return null;
            }

            public String getPersistenceUnitName() {
                return null;
            }

            public String getConnectionProfileName() {
                return null;
            }

            public String getDialectName() {
                return null;
            }

            public String getHibernateVersion() {
                return null;
            }
        };
        ConsoleConfiguration configuration = new ConsoleConfiguration(preferences);
        ConsoleConfiguration configuration2 = new ConsoleConfiguration(preferences2);
        knownConfigurations.addConfiguration(configuration, false);
        knownConfigurations.addConfiguration(configuration2, false);
        configurations = knownConfigurations.getConfigurations();
        Assert.assertEquals(2, configurations.length);
        Assert.assertEquals(listener.added.size(), 0);
        knownConfigurations.addConfiguration(configuration, true);
        knownConfigurations.addConfiguration(configuration2, true);
        configurations = knownConfigurations.getConfigurations();
        Assert.assertEquals(2, configurations.length);
        Assert.assertEquals(listener.added.size(), 2);
        knownConfigurations.removeConfiguration(configuration, false);
        knownConfigurations.removeConfiguration(configuration2, false);
        configurations = knownConfigurations.getConfigurations();
        Assert.assertEquals(0, configurations.length);
        Assert.assertEquals(listener.added.size(), 0);
    } finally {
        KnownConfigurations.getInstance().removeConfigurationListener(listener);
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) Element(org.w3c.dom.Element) KnownConfigurations(org.hibernate.console.KnownConfigurations) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ConsoleConfigurationPreferences (org.hibernate.console.preferences.ConsoleConfigurationPreferences)12 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)7 URL (java.net.URL)5 CoreException (org.eclipse.core.runtime.CoreException)5 Test (org.junit.Test)4 IPath (org.eclipse.core.runtime.IPath)3 ArrayList (java.util.ArrayList)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 ILaunchManager (org.eclipse.debug.core.ILaunchManager)2 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)2 TreePath (org.eclipse.jface.viewers.TreePath)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)2 KnownConfigurations (org.hibernate.console.KnownConfigurations)2 HibernateSearchEnabledPropertyTester (org.jboss.tools.hibernate.search.property.testers.HibernateSearchEnabledPropertyTester)2 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1