use of org.eclipse.core.resources.ProjectScope 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.resources.ProjectScope 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.resources.ProjectScope 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.resources.ProjectScope 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);
}
}
use of org.eclipse.core.resources.ProjectScope in project jbosstools-hibernate by jbosstools.
the class HibernatePropertyPage method saveNamigStrategyChanges.
protected boolean saveNamigStrategyChanges() {
if (initNamingStrategy == enableNamingStrategy.getSelection())
return true;
IScopeContext scope = new ProjectScope(getProject());
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if (node != null) {
node.putBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, enableNamingStrategy.getSelection());
try {
node.flush();
return true;
} catch (BackingStoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ProjectUtils_could_not_save_changes_to_preferences, e);
}
}
return false;
}
Aggregations