use of org.hibernate.eclipse.console.EclipseConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernateErrorsTest2 method setUp.
@Override
protected void setUp() throws Exception {
this.project = createTestProject();
waitForJobs();
String prjName = getProject().getIProject().getName();
EclipseConsoleConfigurationPreferences preferences = new EclipseConsoleConfigurationPreferences(prjName, ConfigurationMode.JPA, null, prjName, true, null, null, null, new IPath[0], new IPath[0], null, null, null, null);
ccfg = KnownConfigurations.getInstance().addConfiguration(new EclipseConsoleConfiguration(preferences), false);
assertTrue(ProjectUtils.toggleHibernateOnProject(getProject().getIProject(), true, prjName));
ccfg.build();
ccfg.buildSessionFactory();
}
use of org.hibernate.eclipse.console.EclipseConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationWizardPage method initialize.
// END
// ///
/**
* Init launch config parameters from proper selection
*
* @param currentSelection
*/
public static void initialize(ILaunchConfigurationWorkingCopy launchConfig, ISelection currentSelection) throws CoreException {
BestGuessConsoleConfigurationVisitor v = new BestGuessConsoleConfigurationVisitor();
// use selection to build configuration from it...
if (currentSelection != null && currentSelection.isEmpty() == false && currentSelection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) currentSelection;
if (ssel.size() > 1) {
return;
}
Object obj = ssel.getFirstElement();
IContainer container = null;
if (obj instanceof IJavaElement) {
v.setJavaProject(((IJavaElement) obj).getJavaProject());
if (v.getJavaProject() != null) {
container = v.getJavaProject().getProject();
}
}
if (obj instanceof IResource) {
IResource res = (IResource) obj;
if (obj instanceof IContainer) {
container = (IContainer) res;
} else {
container = res.getParent();
}
if (res.getProject() != null) {
IJavaProject project = JavaCore.create(res.getProject());
if (project.exists()) {
v.setJavaProject(project);
}
}
}
if (container != null && v.getJavaProject() == null) {
IProject project = container.getProject();
v.setJavaProject(JavaCore.create(project));
}
if (container != null) {
container.accept(v, IResource.NONE);
if (v.getJavaProject() == null) {
IProject project = container.getProject();
v.setJavaProject(JavaCore.create(project));
}
setProjAttribute(launchConfig, IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, v.getJavaProject());
if (v.getJavaProject() != null) {
ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
String uniqName = lm.generateLaunchConfigurationName(v.getJavaProject().getElementName());
launchConfig.rename(uniqName);
}
setPathAttribute(launchConfig, IConsoleConfigurationLaunchConstants.PROPERTY_FILE, v.getPropertyFile());
setPathAttribute(launchConfig, IConsoleConfigurationLaunchConstants.CFG_XML_FILE, v.getConfigFile());
if (v.getPersistencexml() != null) {
setStrAttribute(launchConfig, IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY, ConfigurationMode.JPA.toString());
} else {
setStrAttribute(launchConfig, IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY, ConfigurationMode.CORE.toString());
}
if (!v.getMappings().isEmpty() && v.getConfigFile() == null && v.getPersistencexml() == null) {
IPath[] mappings = v.getMappings().toArray(new IPath[] {});
List<String> l = new ArrayList<String>();
for (int i = 0; i < mappings.length; i++) {
IPath path = mappings[i];
l.add(path.toPortableString());
}
launchConfig.setAttribute(IConsoleConfigurationLaunchConstants.FILE_MAPPINGS, l);
} else {
launchConfig.setAttribute(IConsoleConfigurationLaunchConstants.FILE_MAPPINGS, (List<String>) null);
}
if (!v.getClasspath().isEmpty()) {
launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
IPath[] custClasspath = v.getClasspath().toArray(new IPath[] {});
List<String> mementos = new ArrayList<String>(custClasspath.length);
for (int i = 0; i < custClasspath.length; i++) {
mementos.add(custClasspath[i].toOSString());
}
launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos);
} else {
launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, (List<String>) null);
}
} else if (obj instanceof EclipseConsoleConfiguration) {
// $NON-NLS-1$
throw new IllegalStateException("This should never happen!");
}
}
}
use of org.hibernate.eclipse.console.EclipseConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HQLQueryValidatorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
String prjName = getProject().getIProject().getName();
EclipseConsoleConfigurationPreferences preferences = new EclipseConsoleConfigurationPreferences(prjName, ConfigurationMode.JPA, "3.5", prjName, true, null, null, null, new IPath[0], new IPath[0], null, null, null, null);
ccfg = KnownConfigurations.getInstance().addConfiguration(new EclipseConsoleConfiguration(preferences), false);
assertTrue(ProjectUtils.toggleHibernateOnProject(getProject().getIProject(), true, prjName));
ccfg.build();
ccfg.buildSessionFactory();
}
Aggregations