Author: dgeraskov
Date: 2007-12-12 09:32:09 -0500 (Wed, 12 Dec 2007)
New Revision: 5259
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1412
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-12-12
14:32:04 UTC (rev 5258)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-12-12
14:32:09 UTC (rev 5259)
@@ -32,6 +32,7 @@
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.mapping.Column;
import org.hibernate.mapping.RootClass;
import org.jboss.tools.hibernate.ui.veditor.editors.actions.OpenMappingAction;
import org.jboss.tools.hibernate.ui.veditor.editors.actions.OpenSourceAction;
@@ -145,8 +146,8 @@
return super.getAdapter(type);
}
-
- public Set getSelectedElements() {
+
+ public Set getSelectedElements_old() {
Set ret = new HashSet();
List selectedEditParts = getGraphicalViewer().getSelectedEditParts();
Iterator iterator = selectedEditParts.iterator();
@@ -164,6 +165,24 @@
return ret;
}
+ public Set getSelectedElements() {
+ Set ret = new HashSet();
+ List selectedEditParts = getGraphicalViewer().getSelectedEditParts();
+ Iterator iterator = selectedEditParts.iterator();
+ while (iterator.hasNext()) {
+ Object elem = iterator.next();
+ if (elem instanceof OrmEditPart) {
+ Shape shape = (Shape)((OrmEditPart)elem).getModel();
+ Object ormElement = shape.getOrmElement();
+ if (ormElement instanceof Column){
+ shape = (Shape) shape.getParent();
+ }
+ ret.add(shape.getOrmElement());
+ }
+ }
+ return ret;
+ }
+
public OrmDiagram getViewerContents() {
return ormDiagram;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2007-12-12
14:32:04 UTC (rev 5258)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2007-12-12
14:32:09 UTC (rev 5259)
@@ -3,25 +3,20 @@
import java.util.Iterator;
import java.util.Set;
-import org.eclipse.core.resources.IResource;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.eclipse.console.actions.OpenFileActionUtils;
-import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Subclass;
-import org.hibernate.mapping.Table;
-import org.jboss.tools.hibernate.ui.veditor.VisualEditorPlugin;
+import org.hibernate.mapping.Property;
import org.jboss.tools.hibernate.ui.veditor.editors.VisualEditor;
import org.jboss.tools.hibernate.ui.veditor.editors.model.SpecialRootClass;
-import org.jboss.tools.hibernate.ui.view.views.HibernateUtils;
import org.jboss.tools.hibernate.ui.view.views.ObjectEditorInput;
+/**
+ * @author Dmitry Geraskov
+ *
+ */
public class OpenMappingAction extends SelectionAction {
public static String ACTION_ID =
"org.jboss.tools.hibernate.ui.veditor.editors.actions.open.mapping";
@@ -34,17 +29,30 @@
public void run() {
ObjectEditorInput objectEditorInput =
(ObjectEditorInput)((VisualEditor)getWorkbenchPart()).getEditorInput();
ConsoleConfiguration consoleConfiguration = objectEditorInput.getConfiguration();
- java.io.File configXMLFile = consoleConfiguration.getPreferences().getConfigXMLFile();
- IJavaProject proj = objectEditorInput.getJavaProject();
+ //java.io.File configXMLFile =
consoleConfiguration.getPreferences().getConfigXMLFile();
+ //IJavaProject proj = objectEditorInput.getJavaProject();
VisualEditor part = (VisualEditor)getWorkbenchPart();
Set selectedElements = part.getSelectedElements();
Iterator iterator = selectedElements.iterator();
while (iterator.hasNext()) {
- Object selectedElement = iterator.next();
-
- IResource resource = null;
+ Object selection = iterator.next();
+ if (selection instanceof Property
+ && ((Property)selection).getPersistentClass() instanceof SpecialRootClass){
+ Property compositSel = ((Property)selection);
+ Property parentProperty =
((SpecialRootClass)((Property)selection).getPersistentClass()).getProperty();
+ org.hibernate.eclipse.console.actions.OpenMappingAction.run(compositSel,
parentProperty, consoleConfiguration);
+ continue;
+ }
+ if (selection instanceof SpecialRootClass) {
+ selection = ((SpecialRootClass)selection).getProperty();
+ }
+ org.hibernate.eclipse.console.actions.OpenMappingAction.run(selection,
consoleConfiguration);
+
+
+ /*IResource resource = null;
+ Object selectedElement = selection;
if (selectedElement instanceof RootClass) {
RootClass rootClass = (RootClass)selectedElement;
@@ -105,11 +113,16 @@
if (resource != null) {
try {
- OpenFileActionUtils.openEditor(VisualEditorPlugin.getPage(), resource);
- } catch (PartInitException e) {
+ IEditorPart editorPart =
OpenFileActionUtils.openEditor(VisualEditorPlugin.getPage(), resource);
+ if (selectedElement instanceof PersistentClass
+ || (selectedElement instanceof Property
+ && ((Property)selectedElement).getPersistentClass() != null)){
+ org.hibernate.eclipse.console.actions.OpenMappingAction.applySelectionToEditor(selectedElement,
editorPart);
+ }
+ } catch (PartInitException e) {
VisualEditorPlugin.getDefault().logInfo("Can't open mapping file",
e);
}
- }
+ }*/
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2007-12-12
14:32:04 UTC (rev 5258)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2007-12-12
14:32:09 UTC (rev 5259)
@@ -3,27 +3,21 @@
import java.util.Iterator;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.eclipse.console.actions.OpenFileActionUtils;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
-import org.jboss.tools.hibernate.ui.veditor.VisualEditorPlugin;
+import org.hibernate.mapping.Property;
import org.jboss.tools.hibernate.ui.veditor.editors.VisualEditor;
-import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmDiagram;
-import org.jboss.tools.hibernate.ui.view.ViewPlugin;
import org.jboss.tools.hibernate.ui.view.views.HibernateUtils;
import org.jboss.tools.hibernate.ui.view.views.ObjectEditorInput;
-import org.hibernate.eclipse.console.actions.OpenFileActionUtils;
+/**
+ * @author Dmitry Geraskov
+ *
+ */
public class OpenSourceAction extends SelectionAction {
public static String ACTION_ID =
"org.jboss.tools.hibernate.ui.veditor.editors.actions.open.source";
@@ -43,30 +37,21 @@
Iterator iterator = selectedElements.iterator();
while (iterator.hasNext()) {
- PersistentClass rootClass = (PersistentClass) iterator.next();
-
+ //PersistentClass rootClass = (PersistentClass) iterator.next();
+ Object selection = iterator.next();
+ PersistentClass rootClass = null;
+ if (selection instanceof PersistentClass) {
+ rootClass = (PersistentClass) selection;
+ } else if (selection instanceof Property) {
+ rootClass = ((Property) selection).getPersistentClass();
+ } else continue;
+
IResource resource = null;
String fullyQualifiedName = HibernateUtils.getPersistentClassName(rootClass);
if (fullyQualifiedName.indexOf("$") > 0) {
fullyQualifiedName = fullyQualifiedName.substring(0,
fullyQualifiedName.indexOf("$"));
}
- try {
- IType type = proj.findType(fullyQualifiedName);
- if (type != null) resource = type.getResource();
- } catch (JavaModelException e) {
- VisualEditorPlugin.getDefault().logError("Can't find source file.",
e);
- }
-
- if (resource instanceof IFile){
- try {
- OpenFileActionUtils.openEditor(ViewPlugin.getPage(), (IFile) resource);
- } catch (PartInitException e) {
- VisualEditorPlugin.getDefault().logError("Can't open source
file.", e);
- }
- }
- if (resource == null) {
- MessageDialog.openInformation(VisualEditorPlugin.getShell(), "Open Source
File", "Source file for class '" + fullyQualifiedName + "' not
found.");
- }
+ new org.hibernate.eclipse.console.actions.OpenSourceAction().run(selection, proj,
fullyQualifiedName);
}
}
@@ -76,7 +61,8 @@
Iterator iterator = selectedElements.iterator();
while (iterator.hasNext()) {
Object elem = iterator.next();
- if (elem instanceof PersistentClass) return true;
+ if (elem instanceof PersistentClass
+ || elem instanceof Property) return true;
}
return false;
}