Search in sources :

Example 21 with HibernateConsoleRuntimeException

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

the class EclipseLaunchConsoleConfigurationPreferences method getProperties.

public Properties getProperties() {
    File propFile = getPropertyFile();
    if (propFile == null)
        return getProjectOverrides();
    Properties fileProp = new Properties();
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(propFile);
        fileProp.load(fis);
    } catch (IOException io) {
        throw new HibernateConsoleRuntimeException(NLS.bind(HibernateConsoleMessages.EclipseLaunchConsoleConfigurationPreferences_could_not_load_property_file, propFile), io);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
            // ignore
            }
        }
    }
    // which properties are main?
    Properties p = getProjectOverrides();
    if (p != null) {
        p.putAll(fileProp);
        return p;
    }
    return fileProp;
}
Also used : IOException(java.io.IOException) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 22 with HibernateConsoleRuntimeException

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

the class HibernateConsolePlugin method readStateFrom.

void readStateFrom(File f) {
    try {
        EclipseConsoleConfigurationPreferences[] preferences = EclipseConsoleConfigurationPreferences.readStateFrom(f);
        for (int i = 0; i < preferences.length; i++) {
            ConsoleConfigurationPreferences prefs = preferences[i];
            // TODO: do we need to broadcast every time when reading state ?
            KnownConfigurations.getInstance().addConfiguration(new EclipseConsoleConfiguration(prefs), false);
        }
    } catch (HibernateConsoleRuntimeException hcr) {
        logErrorMessage(HibernateConsoleMessages.HibernateConsolePlugin_error_while_reading_console_config, hcr);
    }
}
Also used : ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException)

Example 23 with HibernateConsoleRuntimeException

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

the class ReloadConfigurationAction method doRun.

protected void doRun() {
    for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
        try {
            Object node = i.next();
            if (node instanceof ConsoleConfiguration) {
                ConsoleConfiguration config = (ConsoleConfiguration) node;
                config.reset();
                updateState(config);
                viewer.refresh(node);
            }
        } catch (HibernateConsoleRuntimeException he) {
            HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.ReloadConfigurationAction_exception_while_start_hibernate, he);
        } catch (UnsupportedClassVersionError ucve) {
            HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.ReloadConfigurationAction_starting_hibernate_resulted_exception, ucve);
        }
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException)

Example 24 with HibernateConsoleRuntimeException

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

the class ClassLoaderHelper method getRawLocationFile.

private static File getRawLocationFile(IPath simplePath) {
    IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(simplePath);
    File file = null;
    if (member != null) {
        IPath rawLocation = member.getRawLocation();
        if (rawLocation == null) {
            rawLocation = member.getLocation();
            if (rawLocation == null) {
                throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.ClassLoaderHelper_could_not_determine_physical_location_for + simplePath);
            }
        }
        file = rawLocation.toFile();
    } else {
        file = simplePath.toFile();
    }
    return file;
}
Also used : IPath(org.eclipse.core.runtime.IPath) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) File(java.io.File) IResource(org.eclipse.core.resources.IResource)

Example 25 with HibernateConsoleRuntimeException

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

the class StandAloneConsoleConfigurationPreferences method readStateFrom.

public static StandAloneConsoleConfigurationPreferences[] readStateFrom(File f) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;
    try {
        parser = factory.newDocumentBuilder();
        Document doc = parser.parse(f);
        Element root = doc.getDocumentElement();
        NodeList elementsByTagName = root.getElementsByTagName(CONFIGURATION_TAG);
        StandAloneConsoleConfigurationPreferences[] result = new StandAloneConsoleConfigurationPreferences[elementsByTagName.getLength()];
        for (int i = 0; i < elementsByTagName.getLength(); i++) {
            result[i] = new StandAloneConsoleConfigurationPreferences();
            result[i].readStateFrom((Element) elementsByTagName.item(i));
        }
        return result;
    } catch (SAXException sa) {
        throw new HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing + f, sa);
    } catch (ParserConfigurationException e) {
        throw new HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing + f, e);
    } catch (IOException e) {
        throw new HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing + f, e);
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Aggregations

HibernateConsoleRuntimeException (org.hibernate.console.HibernateConsoleRuntimeException)34 SQLException (java.sql.SQLException)10 File (java.io.File)8 CoreException (org.eclipse.core.runtime.CoreException)7 PersistentClass (org.hibernate.mapping.PersistentClass)7 RootClass (org.hibernate.mapping.RootClass)7 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)7 Properties (java.util.Properties)5 MetaDataDialect (org.hibernate.cfg.reveng.dialect.MetaDataDialect)5 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)5 Dialect (org.hibernate.dialect.Dialect)5 DatabaseMetaDataDialectResolutionInfoAdapter (org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter)5 DialectFactory (org.hibernate.engine.jdbc.dialect.spi.DialectFactory)5 DialectResolutionInfo (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)5 DialectResolutionInfoSource (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource)5 ServiceRegistry (org.hibernate.service.ServiceRegistry)5 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)5 IOException (java.io.IOException)4 Configuration (org.hibernate.cfg.Configuration)3 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)3