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;
}
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);
}
}
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class CodeGenerationLaunchDelegate method runExporters.
private IArtifactCollector runExporters(final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor) throws CoreException {
monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
if (monitor.isCanceled())
return null;
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
if (attributes.isReverseEngineer()) {
monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
}
final IConfiguration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
monitor.worked(1);
if (monitor.isCanceled())
return null;
final IService service = cc.getHibernateExtension().getHibernateService();
return (IArtifactCollector) cc.execute(new Command() {
public Object execute() {
IArtifactCollector artifactCollector = service.newArtifactCollector();
// Global properties
Properties props = new Properties();
// $NON-NLS-1$
props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled());
// $NON-NLS-1$
props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled());
for (int i = 0; i < exporterFactories.length; i++) {
monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
Properties globalProperties = new Properties();
globalProperties.putAll(props);
IExporter exporter;
try {
exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector, service);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
}
try {
exporter.start();
} catch (HibernateException he) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
}
monitor.worked(1);
}
return artifactCollector;
}
});
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationJavaClasspathTab method isValid.
public boolean isValid(ILaunchConfiguration launchConfig) {
if (!super.isValid(launchConfig)) {
return false;
}
if (lastValidatedLaunchConfig != null && lastValidatedLaunchConfig.contentsEqual(launchConfig)) {
setErrorMessage(lastErrorMessage);
return lastRes;
}
setErrorMessage(null);
setMessage(null);
boolean resUserClasses = false, resExistArchive = true;
IRuntimeClasspathEntry[] entries;
try {
entries = JavaRuntime.computeUnresolvedRuntimeClasspath(launchConfig);
for (int i = 0; i < entries.length; i++) {
IRuntimeClasspathEntry entry = entries[i];
if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES || (entry.getClasspathProperty() == IRuntimeClasspathEntry.MODULE_PATH && entry.getType() == IRuntimeClasspathEntry.PROJECT) || entry.getClasspathProperty() == IRuntimeClasspathEntry.CLASS_PATH) {
resUserClasses = true;
if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) {
if (!entry.getPath().toFile().exists()) {
resExistArchive = false;
String out = NLS.bind(HibernateConsoleMessages.ConsoleConfigurationTabGroup_archive_classpath_entry_does_not_exist, entry.getPath().toString());
setErrorMessage(out);
}
}
}
}
} catch (CoreException e) {
// Ignore as the exception occurs if the selected project is not java project
// We'll show warning to the user later
}
if (!resUserClasses) {
setErrorMessage(HibernateConsoleMessages.ConsoleConfigurationTabGroup_classpath_must_be_set_or_restored_to_default);
}
if (resUserClasses && resExistArchive) {
boolean flagTryToBuild = true;
final ConsoleConfiguration ccTest = new ConsoleConfiguration(new EclipseLaunchConsoleConfigurationPreferences(launchConfig));
if (configurationFileWillBeCreated) {
// exception to resolve the file
try {
ccTest.getConfigXMLFile();
} catch (HibernateConsoleRuntimeException ex) {
flagTryToBuild = false;
}
}
if (flagTryToBuild) {
try {
ccTest.buildWith(null, false);
} catch (Exception ex) {
resUserClasses = false;
setErrorMessage(ex.getMessage());
}
// accurate reset for ccTest after buildWith, should avoid possible "leaks"
try {
ccTest.reset();
} catch (Exception ex) {
if (resUserClasses) {
resUserClasses = false;
setErrorMessage(ex.getMessage());
}
}
try {
lastValidatedLaunchConfig = launchConfig.getWorkingCopy();
} catch (CoreException e1) {
lastValidatedLaunchConfig = null;
}
}
}
final boolean res = resUserClasses && resExistArchive;
if (lastValidatedLaunchConfig != null) {
lastErrorMessage = getErrorMessage();
lastRes = res;
}
return res;
}
use of org.hibernate.console.HibernateConsoleRuntimeException in project jbosstools-hibernate by jbosstools.
the class ConsoleExtension method runExporters.
private IArtifactCollector runExporters(final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor) throws CoreException {
monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
if (monitor.isCanceled())
return null;
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
if (attributes.isReverseEngineer()) {
monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
}
final IConfiguration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
monitor.worked(1);
if (monitor.isCanceled())
return null;
return (IArtifactCollector) cc.execute(new Command() {
public Object execute() {
IArtifactCollector artifactCollector = hibernateExtension.getHibernateService().newArtifactCollector();
// Global properties
Properties props = new Properties();
props.put(CodeGenerationStrings.EJB3, // $NON-NLS-1$
"" + attributes.isEJB3Enabled());
props.put(CodeGenerationStrings.JDK5, // $NON-NLS-1$
"" + attributes.isJDK5Enabled());
for (int i = 0; i < exporterFactories.length; i++) {
monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
Properties globalProperties = new Properties();
globalProperties.putAll(props);
IExporter exporter;
try {
exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector, hibernateExtension.getHibernateService());
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
}
try {
exporter.start();
} catch (HibernateException he) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
}
monitor.worked(1);
}
return artifactCollector;
}
});
}
Aggregations