Author: mdryakhlenkov
Date: 2007-09-26 08:46:51 -0400 (Wed, 26 Sep 2007)
New Revision: 3809
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.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/autolayout/impl/Items.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
Log:
Dependencies from plugins org.jboss.tools.common and org.jboss.common.gef removed.
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-09-26
12:46:51 UTC (rev 3809)
@@ -14,10 +14,8 @@
org.eclipse.ui.editors,
org.eclipse.core.resources,
org.hibernate.eclipse,
- org.jboss.tools.common,
org.eclipse.jdt.core,
- org.jboss.tools.hibernate.ui.view,
- org.jboss.tools.common.gef
+ org.jboss.tools.hibernate.ui.view
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.hibernate.ui.veditor,
org.jboss.tools.hibernate.ui.veditor.editors,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -12,9 +12,8 @@
import org.eclipse.ui.plugin.*;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.view.BaseUIPlugin;
import org.osgi.framework.BundleContext;
-import org.jboss.tools.common.log.BaseUIPlugin;
-import org.jboss.tools.common.log.IPluginLog;
public class VisualEditorPlugin extends BaseUIPlugin {
@@ -43,9 +42,4 @@
public static ImageDescriptor getImageDescriptor(String path) {
return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
}
-
- public static IPluginLog getPluginLog() {
- return getDefault();
- }
-
}
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-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -27,8 +27,8 @@
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.RootClass;
-import org.jboss.tools.common.gef.edit.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.veditor.editors.parts.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.parts.OrmEditPartFactory;
import org.jboss.tools.hibernate.ui.view.views.ObjectEditorInput;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -39,7 +39,7 @@
public void setProcess(IDiagramInfo process) {
this.process = process;
- try { load(); } catch (Exception e) {
VisualEditorPlugin.getPluginLog().logError(e); }
+ try { load(); } catch (Exception e) {
VisualEditorPlugin.getDefault().logError(e); }
}
private void load() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -607,7 +607,7 @@
FileOutputStream fos = new FileOutputStream(file);
properties.store(fos, "");
} catch (IOException e) {
- VisualEditorPlugin.getPluginLog().logError("Can't save layout of
mapping.", e);
+ VisualEditorPlugin.getDefault().logError("Can't save layout of
mapping.", e);
}
}
@@ -624,7 +624,7 @@
file.create(source, true, null);
}
} catch (CoreException e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
}
return file;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -50,7 +50,7 @@
}
getChildren().add(bodyOrmShape);
} catch (Exception e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -30,7 +30,6 @@
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
-import org.jboss.tools.common.gef.edit.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.figures.RoundPolylineConnection;
import org.jboss.tools.hibernate.ui.veditor.editors.model.Connection;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ModelElement;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -110,7 +110,7 @@
ormShape.setLocation(new Point(Integer
.parseInt(xy[0]), Integer.parseInt(xy[1])));
} catch (NumberFormatException e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
if (xy.length > 2)
if ((new Boolean(xy[2])).booleanValue())
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.parts;
+
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+//import org.eclipse.gef.LayerConstants;
+
+public class GEFRootEditPart extends ScalableFreeformRootEditPart{
+
+ public GEFRootEditPart() {
+ super();
+ }
+
+ public void setToFront(AbstractConnectionEditPart editpart){
+ ConnectionLayer layer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER);
+ IFigure fig = editpart.getFigure();
+
+ List children = layer.getChildren();
+
+ children.remove(fig);
+ children.add(fig);
+ }
+
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF 2007-09-26
12:46:51 UTC (rev 3809)
@@ -20,7 +20,6 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.ui.editors,
org.eclipse.jface.text,
- org.jboss.tools.common,
org.hibernate.eclipse,
org.hibernate.eclipse.console,
org.eclipse.debug.core
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-26
11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-26
12:46:51 UTC (rev 3809)
@@ -20,5 +20,14 @@
class="org.jboss.tools.hibernate.ui.view.views.OpenMappingActionDelegate">
</action>
</objectContribution>
+ <objectContribution id="sourceEditorAction"
objectClass="org.hibernate.mapping.RootClass">
+ <menu id="org.jboss.tools.hibernate.ui.view.openSource"
label="Open Source File" path="sourceEditorAction"/>
+ <action
+ id="org.jboss.tools.hibernate.ui.view.openSourceAction"
+ label="Open Source File"
+ icon="icons/runOpenSource.gif"
+
class="org.jboss.tools.hibernate.ui.view.views.OpenSourceActionDelegate">
+ </action>
+ </objectContribution>
</extension>
</plugin>
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Provides an easy way to log status of events.
+ *
+ * NOTE: It is useful to make the static method getPluginLog()
+ * which provides the interface IPluginLog for using it in your code
+ * in future
+ *
+ * @author Sergey Vasilyev
+ *
+ */
+
+public class BaseUIPlugin extends AbstractUIPlugin {
+
+ public void logError(String message, Throwable t) {
+ LogHelper.logError(this, message, t);
+ }
+
+ public void logError(String message) {
+ LogHelper.logError(this, message);
+ }
+
+ public void logError(Throwable t) {
+ LogHelper.logError(this, t);
+ }
+
+ public void logInfo(String message, Throwable t) {
+ LogHelper.logInfo(this, message, t);
+ }
+
+ public void logInfo(String message) {
+ LogHelper.logInfo(this, message);
+ }
+
+ public void logWarning(String message, Throwable t) {
+ LogHelper.logWarning(this, message, t);
+ }
+
+ public void logWarning(String message) {
+ LogHelper.logWarning(this, message);
+ }
+
+ public void logWarning(Throwable t) {
+ LogHelper.logWarning(this, t);
+ }
+
+ public void showError(String message, Throwable t) {
+ logError(message, t);
+ Shell shell = Display.getDefault().getActiveShell();
+ IStatus s = StatusFactory.getInstance(IStatus.ERROR,
this.getBundle().getSymbolicName(), message, t);
+ ErrorDialog.openError(shell, "Hibernate Console", message, s);
+ }
+}
\ No newline at end of file
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.Bundle;
+
+public class LogHelper {
+ public static void logError(Plugin plugin, Throwable t) {
+ logError(plugin, null, t);
+ }
+
+ public static void logError(Plugin plugin, String message) {
+ logError(plugin, message, null);
+ }
+
+ public static void logError(Plugin plugin, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+ public static void logError(String pluginId, Throwable t) {
+ logError(pluginId, null, t);
+ }
+
+ public static void logError(String pluginId, String message) {
+ logError(pluginId, message, null);
+ }
+
+ public static void logError(String pluginId, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logWarning(Plugin plugin, Throwable t) {
+ logWarning(plugin, null, t);
+ }
+
+ public static void logWarning(Plugin plugin, String message) {
+ logWarning(plugin, message, null);
+ }
+
+
+ public static void logWarning(Plugin plugin, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.WARNING,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+ public static void logWarning(String pluginId, Throwable t) {
+ logWarning(pluginId, null, t);
+ }
+
+ public static void logWarning(String pluginId, String message) {
+ logWarning(pluginId, message, null);
+ }
+
+
+ public static void logWarning(String pluginId, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.WARNING, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logInfo(Plugin plugin, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+
+ public static void logInfo(Plugin plugin, String message) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO,
+ plugin.getBundle().getSymbolicName(), message);
+ logStatus(plugin, status);
+ }
+
+ public static void logInfo(String pluginId, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logInfo(String pluginId, String message) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId,
+ message);
+ logStatus(pluginId, status);
+ }
+
+ public static void log(int severity, String pluginId, int code,
+ String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(severity, pluginId, code,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logStatus(Plugin plugin, IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static void logStatus(String pluginId, IStatus status) {
+ Bundle bundle = Platform.getBundle(pluginId);
+ logStatus(bundle, status);
+ }
+
+ public static void logStatus(Bundle bundle, IStatus status) {
+ ILog log = Platform.getLog(bundle);
+ log.log(status);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class StatusFactory {
+ public final static int UNDEFINED_ERROR = 0;
+ public final static String UNSPECIFIED_MESSAGE = null;
+ public final static String EMPTY_MESSAGE = "";
+ public final static String EMPTY_PLUGIN = "";
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, String message, Throwable t) {
+ return new Status(severity, pluginId == null ? EMPTY_PLUGIN : pluginId,
+ code, checkMessage(message, t) , t);
+ }
+
+ public static IStatus getInstance(int severity, int code, String message,
+ Throwable t) {
+ return getInstance(severity, EMPTY_PLUGIN, code, message, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ String message, Throwable t) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, message, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ String message) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, message, null);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ Throwable t) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, EMPTY_MESSAGE, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, Throwable t) {
+ return getInstance(severity, pluginId, code, EMPTY_MESSAGE, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, String message) {
+ return getInstance(severity, pluginId, code, message, null);
+ }
+
+ private static String checkMessage(String message, Throwable t) {
+ if (message == UNSPECIFIED_MESSAGE) {
+ if (t != null && t.getMessage() != null) {
+ return t.getMessage();
+ }
+
+ return EMPTY_MESSAGE;
+ }
+
+ return message;
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -26,7 +26,6 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.log.BaseUIPlugin;
import org.osgi.framework.BundleContext;
/**
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.view.views;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+
+public abstract class OpenActionDelegate implements IObjectActionDelegate {
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ protected IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
+ IJavaProject proj = null;
+ if (consoleConfiguration != null) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfiguration[] launchConfigurations;
+ try {
+ launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType
);
+ for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there
is no look up by name API
+ ILaunchConfiguration launchConfiguration = launchConfigurations[i];
+ if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
+ proj =
ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME,
""));
+ }
+ }
+ } catch (CoreException e1) {
+ ViewPlugin.getDefault().logError("Can't find java project.", e1);
+ }
+ }
+ return proj;
+ }
+// protected IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
+// IJavaProject proj = null;
+// if (consoleConfiguration != null) {
+// ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+//
+// ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+// ILaunchConfiguration[] launchConfigurations = null;
+// try {
+// launchConfigurations =
launchManager.getLaunchConfigurations(launchConfigurationType);
+// } catch (Exception e) {
+// }
+// for (int i = 0; i < launchConfigurations.length; i++) {
+//
+// }
+//
+// String projectName =
((EclipseConsoleConfigurationPreferences)consoleConfiguration.getPreferences()).getProjectName();
+// if (projectName != null) {
+// proj = ProjectUtils.findJavaProject(projectName);
+// }
+// }
+// return proj;
+// }
+
+}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -32,11 +32,8 @@
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.jboss.tools.hibernate.ui.view.ViewPlugin;
-public class OpenDiagramActionDelegate implements IObjectActionDelegate {
+public class OpenDiagramActionDelegate extends OpenActionDelegate {
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
public void run(IAction action) {
HashMap hashMap = new HashMap();
ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
@@ -44,24 +41,8 @@
ObjectEditorInput input = (ObjectEditorInput)hashMap.get(rootClass);
ConsoleConfiguration consoleConfiguration =
(ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
- ILaunchConfiguration[] launchConfigurations;
- IJavaProject proj = null;
- try {
- launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType
);
- for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there
is no look up by name API
- ILaunchConfiguration launchConfiguration = launchConfigurations[i];
- if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
- proj =
ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME,
""));
- }
- }
- } catch (CoreException e1) {
- ViewPlugin.getDefault().logError("Can't find java project.", e1);
- }
+ IJavaProject proj = findJavaProject(consoleConfiguration);
-
if(input == null) {
input = new ObjectEditorInput(consoleConfiguration, rootClass, proj);
hashMap.put(rootClass, input);
@@ -72,7 +53,4 @@
ViewPlugin.getDefault().logError("Can't open mapping view.", e);
}
}
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-09-26
11:56:43 UTC (rev 3808)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -34,6 +34,7 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
@@ -47,6 +48,7 @@
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.mapping.RootClass;
@@ -54,13 +56,10 @@
import org.jboss.tools.hibernate.ui.view.ViewPlugin;
import org.xml.sax.InputSource;
-public class OpenMappingActionDelegate implements IObjectActionDelegate {
+public class OpenMappingActionDelegate extends OpenActionDelegate {
private static XMLHelper helper = new XMLHelper();
private HashMap map = new HashMap();
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
public void run(IAction action) {
ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
RootClass rootClass =
(RootClass)((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
@@ -70,11 +69,20 @@
Document doc = getDocument(consoleConfiguration, configXMLFile);
IResource resource = getResource(consoleConfiguration, proj, doc, configXMLFile,
rootClass);
- if (resource instanceof IFile){
+ if (resource == null) {
+ String fullyQualifiedName = rootClass.getClassName();
+ try {
+ resource = proj.findType(fullyQualifiedName).getResource();
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ if (resource != null && resource instanceof IFile){
try {
IDE.openEditor(ViewPlugin.getPage(), (IFile) resource);
} catch (PartInitException e) {
- ViewPlugin.getDefault().logError("Can't open mapping file.", e);
+ ViewPlugin.getDefault().logError("Can't open mapping or source
file.", e);
}
}
}
@@ -136,7 +144,6 @@
java.io.File file = files[i];
if (file != null) {
resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new
Path(file.getPath()));
-// resource = proj.getProject().getFile(new
Path(file.getPath()).removeFirstSegments(1));
if (classInResource(consoleConfiguration, resource, rootClass)) return resource;
}
}
@@ -176,28 +183,4 @@
}
return doc;
}
-
- private IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
- IJavaProject proj = null;
- if (consoleConfiguration != null) {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
- ILaunchConfiguration[] launchConfigurations;
- try {
- launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType
);
- for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there
is no look up by name API
- ILaunchConfiguration launchConfiguration = launchConfigurations[i];
- if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
- proj =
ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME,
""));
- }
- }
- } catch (CoreException e1) {
- ViewPlugin.getDefault().logError("Can't find java project.", e1);
- }
- }
- return proj;
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
}
\ No newline at end of file
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java 2007-09-26
12:46:51 UTC (rev 3809)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.view.views;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.util.XMLHelper;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+import org.xml.sax.InputSource;
+
+public class OpenSourceActionDelegate extends OpenActionDelegate {
+
+ public void run(IAction action) {
+ ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
+ RootClass rootClass =
(RootClass)((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
+ ConsoleConfiguration consoleConfiguration =
(ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
+ IJavaProject proj = findJavaProject(consoleConfiguration);
+
+ IResource resource = null;
+ String fullyQualifiedName = rootClass.getClassName();
+ try {
+ resource = proj.findType(fullyQualifiedName).getResource();
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+
+ if (resource instanceof IFile){
+ try {
+ IDE.openEditor(ViewPlugin.getPage(), (IFile) resource);
+ } catch (PartInitException e) {
+ ViewPlugin.getDefault().logError("Can't open source file.", e);
+ }
+ }
+ }
+}
\ No newline at end of file