use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class NewJavaFilesListener method cleanup.
private void cleanup(Job job) {
job.removeJobChangeListener(jobChangeListener);
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(temporaryConfigurationName);
if (configuration != null) {
KnownConfigurations.getInstance().removeConfiguration(configuration, false);
}
temporaryConfigurationName = null;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method getConfig.
public IConfiguration getConfig() {
IConfiguration config = null;
final ConsoleConfiguration consoleConfig = getConsoleConfig();
if (consoleConfig != null) {
config = consoleConfig.getConfiguration();
}
return config;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmDiagram method loadState.
@Override
public void loadState(IMemento memento) {
super.loadState(memento);
// $NON-NLS-1$ //$NON-NLS-2$
consoleConfigName = getPrValue(memento, "consoleConfig_name", "");
@SuppressWarnings("unused") ConsoleConfiguration consoleConfig = getConsoleConfig();
labelProvider.setConsoleConfigName(consoleConfigName);
// $NON-NLS-1$
int size = getPrValue(memento, "entityNames_size", 0);
roots.clear();
entityNames.clear();
for (int i = 0; i < size; i++) {
roots.add(null);
// $NON-NLS-1$ //$NON-NLS-2$
entityNames.add(getPrValue(memento, "entityNames_" + Integer.toString(i), ""));
}
// $NON-NLS-1$
rulersVisibility = getPrValue(memento, "rulersVisibility", false);
// $NON-NLS-1$
snapToGeometry = getPrValue(memento, "snapToGeometry", false);
// $NON-NLS-1$
gridEnabled = getPrValue(memento, "gridEnabled", false);
// $NON-NLS-1$
zoom = getPrValue(memento, "zoom", 1.0);
// $NON-NLS-1$
deepIntoSort = getPrValue(memento, "deepIntoSort", false);
// $NON-NLS-1$
flagManhattanConnectionRouter = getPrValue(memento, "flagManhattanConnectionRouter", true);
// $NON-NLS-1$
connectionsVisibilityAssociation = getPrValue(memento, "connectionsVisibilityAssociation", true);
// $NON-NLS-1$
connectionsVisibilityClassMapping = getPrValue(memento, "connectionsVisibilityClassMapping", true);
// $NON-NLS-1$
connectionsVisibilityForeignKeyConstraint = getPrValue(memento, "connectionsVisibilityForeignKeyConstraint", true);
// $NON-NLS-1$
connectionsVisibilityPropertyMapping = getPrValue(memento, "connectionsVisibilityPropertyMapping", true);
refreshRootsFromNames();
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OpenDiagramActionDelegate method run.
public void run(IAction action) {
ObjectPluginAction objectPluginAction = (ObjectPluginAction) action;
Map<ConsoleConfiguration, Set<IPersistentClass>> mapCC_PCs = new HashMap<ConsoleConfiguration, Set<IPersistentClass>>();
TreePath[] paths = ((TreeSelection) objectPluginAction.getSelection()).getPaths();
for (int i = 0; i < paths.length; i++) {
final Object firstSegment = paths[i].getFirstSegment();
if (!(firstSegment instanceof ConsoleConfiguration)) {
continue;
}
final ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (firstSegment);
Set<IPersistentClass> setPC = mapCC_PCs.get(consoleConfig);
if (null == setPC) {
setPC = new HashSet<IPersistentClass>();
mapCC_PCs.put(consoleConfig, setPC);
}
Object last_el = paths[i].getLastSegment();
if (last_el instanceof IPersistentClass) {
IPersistentClass persClass = (IPersistentClass) last_el;
setPC.add(persClass);
} else if (last_el instanceof IConfiguration) {
IConfiguration config = (IConfiguration) last_el;
Iterator<IPersistentClass> it = config.getClassMappings();
while (it.hasNext()) {
setPC.add(it.next());
}
} else if (last_el instanceof ConsoleConfiguration) {
IConfiguration config = consoleConfig.getConfiguration();
if (config == null) {
try {
consoleConfig.build();
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(HibernateConsolePlugin.getShell(), DiagramViewerMessages.OpenDiagramActionDelegate_could_not_load_configuration + ' ' + consoleConfig.getName(), he);
}
if (consoleConfig.hasConfiguration()) {
consoleConfig.buildMappings();
}
config = consoleConfig.getConfiguration();
}
if (config != null) {
Iterator<IPersistentClass> it = config.getClassMappings();
while (it.hasNext()) {
setPC.add(it.next());
}
}
}
}
for (Iterator<ConsoleConfiguration> it = mapCC_PCs.keySet().iterator(); it.hasNext(); ) {
ConsoleConfiguration consoleConfiguration = it.next();
Set<IPersistentClass> setPC = mapCC_PCs.get(consoleConfiguration);
try {
openEditor(setPC, consoleConfiguration);
} catch (PartInitException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't open mapping view.", e);
}
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmLabelProvider method setConsoleConfigName.
public void setConsoleConfigName(String consoleConfigName) {
if (this.consoleConfigName == consoleConfigName) {
return;
}
this.consoleConfigName = consoleConfigName;
final ConsoleConfiguration consoleConfig = getConsoleConfig();
// TODO verify if/how this can be done differently
if (consoleConfig != null && "4.3".equals(consoleConfig.getHibernateExtension().getHibernateVersion())) {
getConsoleConfig().execute(new ExecutionContext.Command() {
@Override
public Object execute() {
return getConfig().buildSessionFactory();
}
});
}
}
Aggregations