use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newJoinedSubclass.
@Override
public IPersistentClass newJoinedSubclass(IPersistentClass persistentClass) {
assert persistentClass instanceof IFacade;
IPersistentClass result = facadeFactory.createPersistentClass(new JoinedSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), null));
((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
return result;
}
use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass in project jbosstools-hibernate by jbosstools.
the class AbstractSpecialRootClassFacade method generate.
protected void generate() {
if (property == null) {
return;
}
IValue propVal = property.getValue();
IValue component = null;
if (propVal != null && propVal.isCollection()) {
IValue collection = propVal;
component = collection.getElement();
} else if (propVal != null && propVal.isComponent()) {
component = propVal;
}
if (component != null) {
setClassName(component.getComponentClassName());
setEntityName(component.getComponentClassName());
IPersistentClass ownerClass = component.getOwner();
if (component.getParentProperty() != null) {
Object newProperty = Util.getInstance(getPropertyClassName(), getFacadeFactoryClassLoader());
parentProperty = getFacadeFactory().createProperty(newProperty);
parentProperty.setName(component.getParentProperty());
parentProperty.setPersistentClass(ownerClass);
}
Iterator<IProperty> iterator = component.getPropertyIterator();
while (iterator.hasNext()) {
IProperty property = iterator.next();
if (property != null) {
addProperty(property);
}
}
}
}
use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass 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.jboss.tools.hibernate.runtime.spi.IPersistentClass 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.jboss.tools.hibernate.runtime.spi.IPersistentClass in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newJoinedSubclass.
@Override
public IPersistentClass newJoinedSubclass(IPersistentClass persistentClass) {
assert persistentClass instanceof IFacade;
IPersistentClass result = facadeFactory.createPersistentClass(new JoinedSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), null));
((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
return result;
}
Aggregations