Author: mdryakhlenkov
Date: 2007-07-05 07:58:57 -0400 (Thu, 05 Jul 2007)
New Revision: 2305
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/EditorActionContributor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/Messages.java
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/messages.properties
Log:
JBIDE-559: Hibernate diagram editor cleanup
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/EditorActionContributor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/EditorActionContributor.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/EditorActionContributor.java 2007-07-05
11:58:57 UTC (rev 2305)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors;
+
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+
+public class EditorActionContributor extends ActionBarContributor {
+
+ protected void buildActions() {
+ IWorkbenchAction workbenchAction =
ActionFactory.REFRESH.create(getPage().getWorkbenchWindow());
+ workbenchAction.setImageDescriptor(ViewPlugin.getImageDescriptor(ViewPlugin.BUNDLE_IMAGE.getString("Explorer.refreshOrmGef")));
//$NON-NLS-1$
+ workbenchAction.setToolTipText(Messages.EditorActionContributor_Refresh_Visual_Mapping);
+ addAction(workbenchAction);
+ }
+
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(getAction(ActionFactory.REFRESH.getId()));
+ }
+
+ protected void declareGlobalActionKeys() {
+ }
+}
\ No newline at end of file
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/Messages.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/Messages.java 2007-07-05
11:58:57 UTC (rev 2305)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.hibernate.ui.veditor.editors.messages";
+
+ private Messages() {
+ }
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ public static String EditorActionContributor_Refresh_Visual_Mapping;
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-07-05
11:58:57 UTC (rev 2305)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.dnd.TemplateTransferDropTargetListener;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.gef.requests.SimpleFactory;
+import org.eclipse.gef.ui.actions.WorkbenchPartAction;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
+import org.eclipse.jface.util.TransferDropTargetListener;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.veditor.editors.parts.OrmEditPartFactory;
+import org.jboss.tools.hibernate.ui.view.views.ObjectEditorInput;
+
+public class VisualEditor extends GraphicalEditor {
+
+ private OrmDiagram ormDiagram = null;
+
+ public VisualEditor() {
+ setEditDomain(new DefaultEditDomain(this));
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ ormDiagram.save();
+ ormDiagram.setDirty(false);
+ }
+
+ public void doSaveAs() {
+ }
+
+ protected void initializeGraphicalViewer() {
+ final GraphicalViewer viewer = getGraphicalViewer();
+ viewer.setEditPartFactory(new OrmEditPartFactory());
+ viewer.setRootEditPart(new ScalableFreeformRootEditPart());
+ viewer.addDropTargetListener(createTransferDropTargetListener());
+ viewer.setContents(ormDiagram);
+ }
+
+ protected void createActions() {
+ getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(),new
WorkbenchPartAction(this){
+
+ protected boolean calculateEnabled() {
+ return true;
+ }
+ public void run() {
+ ormDiagram.refresh();
+ }
+ });
+ super.createActions();
+ }
+
+ private TransferDropTargetListener createTransferDropTargetListener() {
+ return new TemplateTransferDropTargetListener(getGraphicalViewer()) {
+ protected CreationFactory getFactory(Object template) {
+ return new SimpleFactory((Class) template);
+ }
+ };
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public boolean isSaveOnCloseNeeded() {
+ return true;
+ }
+
+ public void refreshDirty() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+
+ public boolean isDirty() {
+ return ormDiagram.isDirty();
+ }
+
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
+ ObjectEditorInput objectEditorInput = (ObjectEditorInput)input;
+ Configuration configuration = objectEditorInput.getConfiguration();
+ RootClass rootClass = (RootClass)(objectEditorInput).getObject();
+ setPartName("Diagram for " + rootClass.getClassName());
+ ormDiagram = new OrmDiagram(configuration, rootClass);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/messages.properties
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/messages.properties 2007-07-05
11:58:57 UTC (rev 2305)
@@ -0,0 +1 @@
+EditorActionContributor_Refresh_Visual_Mapping=Refresh Visual Mapping