use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OpenMappingAction method run.
public void run() {
DiagramEditorInput objectEditorInput = (DiagramEditorInput) ((DiagramViewer) getWorkbenchPart()).getEditorInput();
ConsoleConfiguration consoleConfig = objectEditorInput.getConsoleConfig();
DiagramViewer part = (DiagramViewer) getWorkbenchPart();
Set<Shape> selectedElements = part.getSelectedElements();
IEditorPart editorPart = null;
Iterator<Shape> iterator = selectedElements.iterator();
// open only first editor - no sense to open all of them
while (iterator.hasNext() && editorPart == null) {
Shape shape = iterator.next();
Object selection = shape.getOrmElement();
if (selection instanceof IProperty && ((IProperty) selection).getPersistentClass().isInstanceOfSpecialRootClass()) {
IProperty compositSel = ((IProperty) selection);
IProperty parentProperty = ((IPersistentClass) compositSel.getPersistentClass()).getProperty();
try {
editorPart = org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig, compositSel, parentProperty);
} catch (CoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_canot_find_or_open_mapping_file, e);
} catch (FileNotFoundException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_canot_find_or_open_mapping_file, e);
}
continue;
}
if (selection instanceof IPersistentClass && ((IPersistentClass) selection).isInstanceOfSpecialRootClass()) {
selection = ((IPersistentClass) selection).getProperty();
}
Shape shapeParent = null;
Object selectionParent = null;
if (selection instanceof IColumn) {
shapeParent = (Shape) shape.getParent();
selectionParent = shapeParent.getOrmElement();
}
try {
editorPart = org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig, selection, selectionParent);
} catch (CoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_open_mapping_file, e);
} catch (FileNotFoundException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_open_mapping_file, e);
}
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OpenSourceAction method run.
public void run() {
DiagramEditorInput objectEditorInput = (DiagramEditorInput) ((DiagramViewer) getWorkbenchPart()).getEditorInput();
ConsoleConfiguration consoleConfig = objectEditorInput.getConsoleConfig();
DiagramViewer part = (DiagramViewer) getWorkbenchPart();
Set<Shape> selectedElements = part.getSelectedElements();
IEditorPart editorPart = null;
Iterator<Shape> iterator = selectedElements.iterator();
// open only first editor - no sense to open all of them
while (iterator.hasNext() && editorPart == null) {
Shape shape = iterator.next();
Object selection = shape.getOrmElement();
if (selection instanceof IColumn || selection instanceof ITable) {
Iterator<Connection> targetConnections = shape.getTargetConnections().iterator();
while (targetConnections.hasNext()) {
Connection connection = targetConnections.next();
Shape sh1 = connection.getSource();
Shape sh2 = connection.getTarget();
if (shape == sh1 && sh2 != null) {
shape = sh2;
break;
} else if (shape == sh2 && sh1 != null) {
shape = sh1;
break;
}
}
selection = shape.getOrmElement();
}
IPersistentClass rootClass = null;
if (selection instanceof IPersistentClass) {
rootClass = (IPersistentClass) selection;
} else if (selection instanceof IProperty) {
rootClass = ((IProperty) selection).getPersistentClass();
} else {
continue;
}
// HibernateUtils.getPersistentClassName(rootClass);
String fullyQualifiedName = rootClass.getClassName();
/*if (fullyQualifiedName.indexOf("$") > 0) {
fullyQualifiedName = fullyQualifiedName.substring(0, fullyQualifiedName.indexOf("$"));
}*/
try {
editorPart = org.hibernate.eclipse.console.actions.OpenSourceAction.run(consoleConfig, selection, fullyQualifiedName);
} catch (CoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenSourceAction_canot_open_source_file, e);
} catch (FileNotFoundException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenSourceAction_canot_find_source_file, e);
}
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method getConsoleConfig.
public ConsoleConfiguration getConsoleConfig() {
final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
return consoleConfig;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmDiagram method getConfig.
protected IConfiguration getConfig(StringBuilder error) {
if (error != null) {
error.delete(0, error.length());
}
final ConsoleConfiguration consoleConfig = getConsoleConfig();
if (consoleConfig != null) {
if (!consoleConfig.hasConfiguration()) {
try {
consoleConfig.build();
consoleConfig.buildMappings();
} catch (Exception he) {
// here just ignore this
if (error != null) {
error.append(consoleConfigName);
// $NON-NLS-1$
error.append(": ");
error.append(he.getMessage());
if (error.length() == 0) {
error.append(he.getCause());
}
}
}
}
return consoleConfig.getConfiguration();
}
if (error != null && consoleConfigName != null && consoleConfigName.length() > 0) {
error.append(consoleConfigName);
// $NON-NLS-1$
error.append(": ");
error.append(DiagramViewerMessages.Diagram_incorrect_state);
}
return null;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmDiagram method loadFromProperties.
@Override
protected void loadFromProperties(Properties properties) {
super.loadFromProperties(properties);
// $NON-NLS-1$ //$NON-NLS-2$
consoleConfigName = getPrValue(properties, "consoleConfig_name", "");
@SuppressWarnings("unused") ConsoleConfiguration consoleConfig = getConsoleConfig();
labelProvider.setConsoleConfigName(consoleConfigName);
// $NON-NLS-1$
int size = getPrValue(properties, "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(properties, "entityNames_" + Integer.toString(i), ""));
}
// $NON-NLS-1$
rulersVisibility = getPrValue(properties, "rulersVisibility", false);
// $NON-NLS-1$
snapToGeometry = getPrValue(properties, "snapToGeometry", false);
// $NON-NLS-1$
gridEnabled = getPrValue(properties, "gridEnabled", false);
// $NON-NLS-1$
zoom = getPrValue(properties, "zoom", 1.0);
// $NON-NLS-1$
deepIntoSort = getPrValue(properties, "deepIntoSort", false);
// $NON-NLS-1$
flagManhattanConnectionRouter = getPrValue(properties, "flagManhattanConnectionRouter", true);
// $NON-NLS-1$
connectionsVisibilityAssociation = getPrValue(properties, "connectionsVisibilityAssociation", true);
// $NON-NLS-1$
connectionsVisibilityClassMapping = getPrValue(properties, "connectionsVisibilityClassMapping", true);
// $NON-NLS-1$
connectionsVisibilityForeignKeyConstraint = getPrValue(properties, "connectionsVisibilityForeignKeyConstraint", true);
// $NON-NLS-1$
connectionsVisibilityPropertyMapping = getPrValue(properties, "connectionsVisibilityPropertyMapping", true);
refreshRootsFromNames();
}
Aggregations