use of org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences 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);
}
use of org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences 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) {
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.eclipse.console.EclipseLaunchConsoleConfigurationPreferences in project jbosstools-hibernate by jbosstools.
the class EclipseLaunchConsoleConfigurationPreferencesTest method testCloseStream.
/**
* test method for eclipseLaunchConsoleConfigurationPreferences.getProperties
* @throws CoreException
*/
public void testCloseStream() throws CoreException {
final ILaunchConfiguration launchConfiguration = context.mock(ILaunchConfiguration.class);
final EclipseLaunchConsoleConfigurationPreferences eclipseLaunchConsoleConfigurationPreferences = new EclipseLaunchConsoleConfigurationPreferences(launchConfiguration);
final String propertiesFilePath = getPropertiesFilePath();
context.checking(new Expectations() {
{
allowing(launchConfiguration).getAttribute(IConsoleConfigurationLaunchConstants.PROPERTY_FILE, (String) null);
will(returnValue(propertiesFilePath));
}
});
Properties properties = eclipseLaunchConsoleConfigurationPreferences.getProperties();
assertNotNull(properties);
assertTrue(properties.size() == 1);
context.assertIsSatisfied();
}
Aggregations