use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class ProjectDefaultConfigurationChange method perform.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
try {
IScopeContext scope = new ProjectScope(project);
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
String oldName = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, null);
node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, true);
node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, newConsoleName);
node.flush();
return new ProjectDefaultConfigurationChange(project, oldName);
} catch (BackingStoreException e) {
HibernateConsolePlugin.openError(new Shell(), Messages.ProjectDefaultConfigurationChange_error_title, e.getLocalizedMessage(), e, HibernateConsolePlugin.PERFORM_SYNC_EXEC);
return new NullChange();
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class HibernateRefactoringUtil method isProjectAffected.
private static boolean isProjectAffected(IProject project, String oldCCName) throws CoreException {
if (project.isOpen() && project.hasNature(HibernateNature.ID)) {
IScopeContext scope = new ProjectScope(project);
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
// $NON-NLS-1$
String defaultConfiguration = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, "");
return defaultConfiguration.equals(oldCCName);
}
return false;
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class HibernateJpaProject method isNamingStrategyEnabled.
public boolean isNamingStrategyEnabled() {
// rebuilding ( == creating new instance) of jpa project we cache it
if (this.cachedNamingStrategyEnable == null) {
IScopeContext scope = new ProjectScope(getProject());
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if (node != null) {
this.cachedNamingStrategyEnable = node.getBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, true);
} else {
this.cachedNamingStrategyEnable = true;
}
}
return this.cachedNamingStrategyEnable;
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class ProjectUtils method toggleHibernateOnProject.
public static boolean toggleHibernateOnProject(IProject project, boolean enable, String defaultConsoleName) {
IScopeContext scope = new ProjectScope(project);
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if (node != null) {
node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, enable);
node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, defaultConsoleName);
try {
node.flush();
} catch (BackingStoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ProjectUtils_could_not_save_changes_to_preferences, e);
return false;
}
} else {
return false;
}
try {
if (enable) {
return ProjectUtils.addProjectNature(project, HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor());
} else {
return ProjectUtils.removeProjectNature(project, HibernatePropertiesConstants.HIBERNATE_NATURE, new NullProgressMonitor());
}
} catch (CoreException ce) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ProjectUtils_could_not_activate_hibernate_nature_on_project + project.getName(), ce);
HibernateConsolePlugin.getDefault().log(ce.getStatus());
return false;
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class HibernatePropertyPage method loadValues.
public void loadValues() {
IProject project = getProject();
IScopeContext scope = new ProjectScope(project);
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if (node != null) {
initEnableHibernate = node.getBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, false);
enableHibernate.setSelection(initEnableHibernate);
String cfg = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, project.getName());
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(cfg);
if (configuration == null) {
selectedConfiguration.select(0);
details.setEnabled(false);
} else {
initConsoleConfiguration = cfg;
selectedConfiguration.setText(cfg);
}
initNamingStrategy = node.getBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, true);
enableNamingStrategy.setSelection(initNamingStrategy);
}
}
Aggregations