JBoss Tools SVN: r18239 - trunk/vpe/plugins/org.jboss.tools.vpe/ve.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2009-10-22 11:30:15 -0400 (Thu, 22 Oct 2009)
New Revision: 18239
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/ve/EditorOverride.css
Log:
https://jira.jboss.org/jira/browse/JBIDE-4993, changed default vpe style for input element, so now we can select element
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/ve/EditorOverride.css
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/ve/EditorOverride.css 2009-10-22 14:26:19 UTC (rev 18238)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/ve/EditorOverride.css 2009-10-22 15:30:15 UTC (rev 18239)
@@ -60,7 +60,7 @@
color: -moz-hyperlinktext;
}
-input, button, textarea {
+button, textarea {
-moz-user-select: all !important;
-moz-user-input: auto !important;
-moz-user-focus: none !important;
14 years, 8 months
JBoss Tools SVN: r18238 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ssh: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2009-10-22 10:26:19 -0400 (Thu, 22 Oct 2009)
New Revision: 18238
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/build.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
Log:
tweak build config files; "JBoss Stuff" not a valid provider name, rawblem!
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF 2009-10-22 13:18:51 UTC (rev 18237)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/META-INF/MANIFEST.MF 2009-10-22 14:26:19 UTC (rev 18238)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Ssh
+Bundle-Name: JBoss SSH Server Plugin
Bundle-SymbolicName: org.jboss.ide.eclipse.as.ssh;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.jboss.ide.eclipse.as.ssh.SSHDeploymentPlugin
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/build.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/build.properties 2009-10-22 13:18:51 UTC (rev 18237)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/build.properties 2009-10-22 14:26:19 UTC (rev 18238)
@@ -1,5 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
+ icons/,\
.,\
plugin.xml
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-22 13:18:51 UTC (rev 18237)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2009-10-22 14:26:19 UTC (rev 18238)
@@ -24,7 +24,7 @@
<extension
point="org.eclipse.wst.server.core.runtimeTypes">
<runtimeType
- vendor="JBoss Stuff"
+ vendor="JBoss by Red Hat"
class="org.jboss.ide.eclipse.as.ssh.server.SSHServerRuntime"
description="A runtime to allow SSH servers to support every module type. "
name="SSH Runtime"
14 years, 8 months
JBoss Tools SVN: r18237 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui: diagram/editors and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-10-22 09:18:51 -0400 (Thu, 22 Oct 2009)
New Revision: 18237
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5054 - fix: enhance exceptions handle
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -58,4 +58,7 @@
public static String ToggleAssociationAction_associations;
public static String ToggleForeignKeyConstraintAction_foreign_key_constraints;
public static String MessageShape_warning;
+ public static String Diagram_incorrect_state;
+ public static String Diagram_no_items_or_incorrect_state;
+ public static String OpenDiagramActionDelegate_could_not_load_configuration;
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-10-22 13:18:51 UTC (rev 18237)
@@ -33,4 +33,7 @@
TogglePropertyMappingAction_property_mappings=Property Mappings
ToggleAssociationAction_associations=Associations
ToggleForeignKeyConstraintAction_foreign_key_constraints=Foreign key constraints
-MessageShape_warning=Hibernate Console Configuration is not loaded cause Hibernate plugins are not active. To activate Open Hibernate Configurations view and press refresh button.
\ No newline at end of file
+MessageShape_warning=Hibernate Console Configuration is not loaded cause Hibernate plugins are not active. To activate Open Hibernate Configurations view and press refresh button.
+Diagram_incorrect_state=incorrect Hibernate Console Configuration state.
+Diagram_no_items_or_incorrect_state=no items or incorrect Hibernate Console Configuration state.
+OpenDiagramActionDelegate_could_not_load_configuration=Could not load configuration
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -18,8 +18,6 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.PositionConstants;
@@ -118,14 +116,12 @@
return;
}
saveProperties();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IPath pathTmp = workspace.getRoot().getFullPath().append(pathSave);
- pathTmp = workspace.getRoot().getLocation().append(pathTmp);
+ IPath pathTmp = pathSave;
String ext = pathSave.getFileExtension();
if (ext == null) {
pathTmp = pathTmp.addFileExtension("hibernate"); //$NON-NLS-1$
}
- getOrmDiagram().saveInFile(pathTmp, true);
+ getOrmDiagram().saveInWorkspaceFile(pathTmp, true);
getOrmDiagram().setDirty(false);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -10,16 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.model;
-import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
-
/**
*
* author: Vitali Yemialyanchyk
*/
public class MessageShape extends OrmShape {
- protected MessageShape() {
- super(DiagramViewerMessages.MessageShape_warning);
+ protected MessageShape(String error) {
+ super(error);
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -11,6 +11,8 @@
package org.jboss.tools.hibernate.ui.diagram.editors.model;
import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -18,6 +20,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.io.StringWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@@ -41,6 +44,7 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.XMLMemento;
+import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
@@ -48,6 +52,7 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection.ConnectionType;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler;
@@ -169,8 +174,10 @@
deleteChildren();
elements.clear();
connections.clear();
+ StringBuilder errorMessage = new StringBuilder();
+ Configuration config = getConfig(errorMessage);
final ElementsFactory factory = new ElementsFactory(
- getConfig(), elements, connections);
+ config, elements, connections);
for (int i = 0; i < roots.size(); i++) {
RootClass rc = roots.get(i);
if (rc != null) {
@@ -181,7 +188,18 @@
factory.createChildren(this);
updateChildrenList();
if (getChildrenNumber() == 0) {
- addChild(new MessageShape());
+ String error = DiagramViewerMessages.MessageShape_warning;
+ if (config != null) {
+ if (consoleConfigName != null && consoleConfigName.length() > 0) {
+ error = consoleConfigName;
+ error += ": "; //$NON-NLS-1$
+ error += DiagramViewerMessages.Diagram_no_items_or_incorrect_state;
+ }
+ }
+ if (errorMessage.length() > 0) {
+ error = errorMessage.toString();
+ }
+ addChild(new MessageShape(error));
}
}
@@ -557,6 +575,44 @@
super.saveInProperties(properties);
}
+ public void saveInWorkspaceFile(IPath path, boolean format) {
+ final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file.exists()) {
+ try {
+ file.delete(true, null);
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't delete file.", e); //$NON-NLS-1$
+ }
+ }
+ if (file.exists()) {
+ return;
+ }
+ byte[] arrSave = new byte[0];
+ try {
+ if (format) {
+ XMLMemento memento = XMLMemento.createWriteRoot("OrmDiagram"); //$NON-NLS-1$
+ saveState(memento);
+ StringWriter strWriter = new StringWriter();
+ memento.save(strWriter);
+ arrSave = strWriter.toString().getBytes();
+ } else {
+ Properties properties = new Properties();
+ saveInProperties(properties);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ properties.store(baos, ""); //$NON-NLS-1$
+ arrSave = baos.toByteArray();
+ }
+ } catch (IOException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't save layout of mapping.", e); //$NON-NLS-1$
+ }
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(arrSave);
+ try {
+ file.create(inputStream, true, null);
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't save layout of mapping.", e); //$NON-NLS-1$
+ }
+ }
+
public void saveInFile(IPath path, boolean format) {
FileOutputStream fos = null;
try {
@@ -677,11 +733,30 @@
}
protected Configuration getConfig() {
+ return getConfig(null);
+ }
+
+ protected Configuration getConfig(StringBuilder error) {
+ if (error != null) {
+ error.delete(0, error.length());
+ }
final ConsoleConfiguration consoleConfig = getConsoleConfig();
if (consoleConfig != null) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ // here just ignore this
+ if (error != null) {
+ error.append(consoleConfigName);
+ error.append(": "); //$NON-NLS-1$
+ error.append(he.getMessage());
+ if (error.length() == 0) {
+ error.append(he.getCause());
+ }
+ }
+ }
consoleConfig.execute(new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
@@ -694,6 +769,11 @@
}
return config;
}
+ if (error != null && consoleConfigName != null && consoleConfigName.length() > 0) {
+ error.append(consoleConfigName);
+ error.append(": "); //$NON-NLS-1$
+ error.append(DiagramViewerMessages.Diagram_incorrect_state);
+ }
return null;
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -26,12 +26,14 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
@SuppressWarnings("restriction")
@@ -75,7 +77,14 @@
} else if (last_el instanceof ConsoleConfiguration) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ HibernateConsolePlugin.getDefault().showError(
+ HibernateConsolePlugin.getShell(),
+ DiagramViewerMessages.OpenDiagramActionDelegate_could_not_load_configuration +
+ ' ' + consoleConfig.getName(), he);
+ }
consoleConfig.execute( new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
@@ -86,9 +95,11 @@
} );
config = consoleConfig.getConfiguration();
}
- Iterator<PersistentClass> it = (Iterator<PersistentClass>)(config.getClassMappings());
- while (it.hasNext()) {
- setPC.add(it.next());
+ if (config != null) {
+ Iterator<PersistentClass> it = (Iterator<PersistentClass>)(config.getClassMappings());
+ while (it.hasNext()) {
+ setPC.add(it.next());
+ }
}
}
}
@@ -111,9 +122,6 @@
public IEditorPart openEditor(Set<PersistentClass> setPC, ConsoleConfiguration consoleConfig) throws PartInitException {
- if (setPC.size() <= 0) {
- return null;
- }
RootClass[] rcArr = new RootClass[setPC.size()];
PersistentClass persClass = null;
int i = 0;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-10-22 13:18:41 UTC (rev 18236)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-10-22 13:18:51 UTC (rev 18237)
@@ -23,6 +23,7 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -69,7 +70,11 @@
if (consoleConfig != null) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ // here just ignore this
+ }
consoleConfig.execute(new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
14 years, 8 months
JBoss Tools SVN: r18236 - in branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui: diagram/editors and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-10-22 09:18:41 -0400 (Thu, 22 Oct 2009)
New Revision: 18236
Modified:
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5054 - fix: enhance exceptions handle
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -58,4 +58,7 @@
public static String ToggleAssociationAction_associations;
public static String ToggleForeignKeyConstraintAction_foreign_key_constraints;
public static String MessageShape_warning;
+ public static String Diagram_incorrect_state;
+ public static String Diagram_no_items_or_incorrect_state;
+ public static String OpenDiagramActionDelegate_could_not_load_configuration;
}
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-10-22 13:18:41 UTC (rev 18236)
@@ -33,4 +33,7 @@
TogglePropertyMappingAction_property_mappings=Property Mappings
ToggleAssociationAction_associations=Associations
ToggleForeignKeyConstraintAction_foreign_key_constraints=Foreign key constraints
-MessageShape_warning=Hibernate Console Configuration is not loaded cause Hibernate plugins are not active. To activate Open Hibernate Configurations view and press refresh button.
\ No newline at end of file
+MessageShape_warning=Hibernate Console Configuration is not loaded cause Hibernate plugins are not active. To activate Open Hibernate Configurations view and press refresh button.
+Diagram_incorrect_state=incorrect Hibernate Console Configuration state.
+Diagram_no_items_or_incorrect_state=no items or incorrect Hibernate Console Configuration state.
+OpenDiagramActionDelegate_could_not_load_configuration=Could not load configuration
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -18,8 +18,6 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.PositionConstants;
@@ -118,14 +116,12 @@
return;
}
saveProperties();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IPath pathTmp = workspace.getRoot().getFullPath().append(pathSave);
- pathTmp = workspace.getRoot().getLocation().append(pathTmp);
+ IPath pathTmp = pathSave;
String ext = pathSave.getFileExtension();
if (ext == null) {
pathTmp = pathTmp.addFileExtension("hibernate"); //$NON-NLS-1$
}
- getOrmDiagram().saveInFile(pathTmp, true);
+ getOrmDiagram().saveInWorkspaceFile(pathTmp, true);
getOrmDiagram().setDirty(false);
}
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -10,16 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.model;
-import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
-
/**
*
* author: Vitali Yemialyanchyk
*/
public class MessageShape extends OrmShape {
- protected MessageShape() {
- super(DiagramViewerMessages.MessageShape_warning);
+ protected MessageShape(String error) {
+ super(error);
}
@Override
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -11,6 +11,8 @@
package org.jboss.tools.hibernate.ui.diagram.editors.model;
import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -18,6 +20,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.io.StringWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@@ -41,6 +44,7 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.XMLMemento;
+import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
@@ -48,6 +52,7 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection.ConnectionType;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler;
@@ -169,8 +174,10 @@
deleteChildren();
elements.clear();
connections.clear();
+ StringBuilder errorMessage = new StringBuilder();
+ Configuration config = getConfig(errorMessage);
final ElementsFactory factory = new ElementsFactory(
- getConfig(), elements, connections);
+ config, elements, connections);
for (int i = 0; i < roots.size(); i++) {
RootClass rc = roots.get(i);
if (rc != null) {
@@ -181,7 +188,18 @@
factory.createChildren(this);
updateChildrenList();
if (getChildrenNumber() == 0) {
- addChild(new MessageShape());
+ String error = DiagramViewerMessages.MessageShape_warning;
+ if (config != null) {
+ if (consoleConfigName != null && consoleConfigName.length() > 0) {
+ error = consoleConfigName;
+ error += ": "; //$NON-NLS-1$
+ error += DiagramViewerMessages.Diagram_no_items_or_incorrect_state;
+ }
+ }
+ if (errorMessage.length() > 0) {
+ error = errorMessage.toString();
+ }
+ addChild(new MessageShape(error));
}
}
@@ -557,6 +575,44 @@
super.saveInProperties(properties);
}
+ public void saveInWorkspaceFile(IPath path, boolean format) {
+ final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file.exists()) {
+ try {
+ file.delete(true, null);
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't delete file.", e); //$NON-NLS-1$
+ }
+ }
+ if (file.exists()) {
+ return;
+ }
+ byte[] arrSave = new byte[0];
+ try {
+ if (format) {
+ XMLMemento memento = XMLMemento.createWriteRoot("OrmDiagram"); //$NON-NLS-1$
+ saveState(memento);
+ StringWriter strWriter = new StringWriter();
+ memento.save(strWriter);
+ arrSave = strWriter.toString().getBytes();
+ } else {
+ Properties properties = new Properties();
+ saveInProperties(properties);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ properties.store(baos, ""); //$NON-NLS-1$
+ arrSave = baos.toByteArray();
+ }
+ } catch (IOException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't save layout of mapping.", e); //$NON-NLS-1$
+ }
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(arrSave);
+ try {
+ file.create(inputStream, true, null);
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't save layout of mapping.", e); //$NON-NLS-1$
+ }
+ }
+
public void saveInFile(IPath path, boolean format) {
FileOutputStream fos = null;
try {
@@ -677,11 +733,30 @@
}
protected Configuration getConfig() {
+ return getConfig(null);
+ }
+
+ protected Configuration getConfig(StringBuilder error) {
+ if (error != null) {
+ error.delete(0, error.length());
+ }
final ConsoleConfiguration consoleConfig = getConsoleConfig();
if (consoleConfig != null) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ // here just ignore this
+ if (error != null) {
+ error.append(consoleConfigName);
+ error.append(": "); //$NON-NLS-1$
+ error.append(he.getMessage());
+ if (error.length() == 0) {
+ error.append(he.getCause());
+ }
+ }
+ }
consoleConfig.execute(new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
@@ -694,6 +769,11 @@
}
return config;
}
+ if (error != null && consoleConfigName != null && consoleConfigName.length() > 0) {
+ error.append(consoleConfigName);
+ error.append(": "); //$NON-NLS-1$
+ error.append(DiagramViewerMessages.Diagram_incorrect_state);
+ }
return null;
}
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -26,12 +26,14 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
@SuppressWarnings("restriction")
@@ -75,7 +77,14 @@
} else if (last_el instanceof ConsoleConfiguration) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ HibernateConsolePlugin.getDefault().showError(
+ HibernateConsolePlugin.getShell(),
+ DiagramViewerMessages.OpenDiagramActionDelegate_could_not_load_configuration +
+ ' ' + consoleConfig.getName(), he);
+ }
consoleConfig.execute( new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
@@ -86,9 +95,11 @@
} );
config = consoleConfig.getConfiguration();
}
- Iterator<PersistentClass> it = (Iterator<PersistentClass>)(config.getClassMappings());
- while (it.hasNext()) {
- setPC.add(it.next());
+ if (config != null) {
+ Iterator<PersistentClass> it = (Iterator<PersistentClass>)(config.getClassMappings());
+ while (it.hasNext()) {
+ setPC.add(it.next());
+ }
}
}
}
@@ -111,9 +122,6 @@
public IEditorPart openEditor(Set<PersistentClass> setPC, ConsoleConfiguration consoleConfig) throws PartInitException {
- if (setPC.size() <= 0) {
- return null;
- }
RootClass[] rcArr = new RootClass[setPC.size()];
PersistentClass persClass = null;
int i = 0;
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-10-22 13:05:37 UTC (rev 18235)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-10-22 13:18:41 UTC (rev 18236)
@@ -23,6 +23,7 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -69,7 +70,11 @@
if (consoleConfig != null) {
Configuration config = consoleConfig.getConfiguration();
if (config == null) {
- consoleConfig.build();
+ try {
+ consoleConfig.build();
+ } catch (HibernateException he) {
+ // here just ignore this
+ }
consoleConfig.execute(new ExecutionContext.Command() {
public Object execute() {
if (consoleConfig.hasConfiguration()) {
14 years, 8 months
JBoss Tools SVN: r18235 - in branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor: form and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-10-22 09:05:37 -0400 (Thu, 22 Oct 2009)
New Revision: 18235
Modified:
branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java
branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java
branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5058
Modified: branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
===================================================================
--- branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2009-10-22 12:55:04 UTC (rev 18234)
+++ branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2009-10-22 13:05:37 UTC (rev 18235)
@@ -107,7 +107,7 @@
errorForm.setVisible(Boolean.FALSE.booleanValue());
errorForm.setLayout(layout);
- treeForm = new SampleTreeForm();
+ treeForm = new SampleTreeForm(this);
treeForm.setSelectionNotifier(selectionNotifier);
rightFormContainer = new RightFormContainer();
rightFormContainer.setSelectionChangedListener(selectionNotifier);
Modified: branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java
===================================================================
--- branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java 2009-10-22 12:55:04 UTC (rev 18234)
+++ branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java 2009-10-22 13:05:37 UTC (rev 18235)
@@ -32,7 +32,7 @@
control = sash;
control.setLayoutData(new GridData(GridData.FILL_BOTH));
- component = new XModelObjectTreeViewComponent();
+ component = new XModelObjectTreeViewComponent(this);
component.setModelObject(object);
component.setCache(new XModelObjectCache(object));
for (int i = 0; i < filters.length; i++) component.addFilter(filters[i]);
Modified: branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java
===================================================================
--- branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java 2009-10-22 12:55:04 UTC (rev 18234)
+++ branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java 2009-10-22 13:05:37 UTC (rev 18235)
@@ -25,6 +25,7 @@
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.IEditorPart;
import org.jboss.tools.common.model.*;
public class XModelObjectTreeViewComponent {
@@ -38,16 +39,18 @@
private TreeDragDropProvider dndProvider = new TreeDragDropProvider();
private ControlDragDrop dnd = new ControlDragDrop();
TreeViewer treeViewer = null;
+ IEditorPart part;
- public XModelObjectTreeViewComponent() {
- this(new TreeViewerModelListenerImpl());
+ public XModelObjectTreeViewComponent(IEditorPart part) {
+ this(part, new TreeViewerModelListenerImpl());
}
public void setMenuInvoker(TreeViewerMenuInvoker menu) {
// this.menu = menu;
}
- protected XModelObjectTreeViewComponent(TreeViewerModelListenerImpl listener) {
+ protected XModelObjectTreeViewComponent(IEditorPart part, TreeViewerModelListenerImpl listener) {
+ this.part = part;
this.listener = listener;
syncListener = new XModelTreeListenerSWTASync(listener);
}
@@ -128,15 +131,9 @@
final TreeViewer treeViewer = getViewer();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
treeViewer.getTree().setMenu(menu);
-// Display.getDefault().asyncExec(new Runnable() {
-// public void run() {
-// ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow()
-// .getActivePage().getActiveEditor().getSite()
-// .registerContextMenu(menuMgr, treeViewer);
-// }
-// });
-
+ part.getSite().registerContextMenu(menuMgr, treeViewer);
}
+
protected void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection =
(IStructuredSelection) getViewer().getSelection();
@@ -171,6 +168,7 @@
label.dispose();
label = null;
}
+ part = null;
}
// private void connect() {
Modified: branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
===================================================================
--- branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2009-10-22 12:55:04 UTC (rev 18234)
+++ branches/jbosstools-3.1.0.M4/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2009-10-22 13:05:37 UTC (rev 18235)
@@ -27,6 +27,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.jboss.tools.common.meta.action.XAction;
@@ -45,8 +46,8 @@
private XFilteredTreeConstraint[] filters = new XFilteredTreeConstraint[0];
private SelectionNotifier notifier;
- public SampleTreeForm() {
- tree = new XModelObjectTreeViewComponent();
+ public SampleTreeForm(IEditorPart part) {
+ tree = new XModelObjectTreeViewComponent(part);
headingText = "Tree Form";
setCollapsable(Boolean.FALSE.booleanValue());
createActionMapping();
14 years, 8 months
JBoss Tools SVN: r18234 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor: form and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-10-22 08:55:04 -0400 (Thu, 22 Oct 2009)
New Revision: 18234
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5058
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2009-10-22 12:01:48 UTC (rev 18233)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2009-10-22 12:55:04 UTC (rev 18234)
@@ -107,7 +107,7 @@
errorForm.setVisible(Boolean.FALSE.booleanValue());
errorForm.setLayout(layout);
- treeForm = new SampleTreeForm();
+ treeForm = new SampleTreeForm(this);
treeForm.setSelectionNotifier(selectionNotifier);
rightFormContainer = new RightFormContainer();
rightFormContainer.setSelectionChangedListener(selectionNotifier);
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java 2009-10-22 12:01:48 UTC (rev 18233)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeGuiEditor.java 2009-10-22 12:55:04 UTC (rev 18234)
@@ -32,7 +32,7 @@
control = sash;
control.setLayoutData(new GridData(GridData.FILL_BOTH));
- component = new XModelObjectTreeViewComponent();
+ component = new XModelObjectTreeViewComponent(this);
component.setModelObject(object);
component.setCache(new XModelObjectCache(object));
for (int i = 0; i < filters.length; i++) component.addFilter(filters[i]);
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java 2009-10-22 12:01:48 UTC (rev 18233)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XModelObjectTreeViewComponent.java 2009-10-22 12:55:04 UTC (rev 18234)
@@ -25,6 +25,7 @@
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.IEditorPart;
import org.jboss.tools.common.model.*;
public class XModelObjectTreeViewComponent {
@@ -38,16 +39,18 @@
private TreeDragDropProvider dndProvider = new TreeDragDropProvider();
private ControlDragDrop dnd = new ControlDragDrop();
TreeViewer treeViewer = null;
+ IEditorPart part;
- public XModelObjectTreeViewComponent() {
- this(new TreeViewerModelListenerImpl());
+ public XModelObjectTreeViewComponent(IEditorPart part) {
+ this(part, new TreeViewerModelListenerImpl());
}
public void setMenuInvoker(TreeViewerMenuInvoker menu) {
// this.menu = menu;
}
- protected XModelObjectTreeViewComponent(TreeViewerModelListenerImpl listener) {
+ protected XModelObjectTreeViewComponent(IEditorPart part, TreeViewerModelListenerImpl listener) {
+ this.part = part;
this.listener = listener;
syncListener = new XModelTreeListenerSWTASync(listener);
}
@@ -127,16 +130,10 @@
});
final TreeViewer treeViewer = getViewer();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
- treeViewer.getTree().setMenu(menu);
-// Display.getDefault().asyncExec(new Runnable() {
-// public void run() {
-// ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow()
-// .getActivePage().getActiveEditor().getSite()
-// .registerContextMenu(menuMgr, treeViewer);
-// }
-// });
-
+ treeViewer.getTree().setMenu(menu);
+ part.getSite().registerContextMenu(menuMgr, treeViewer);
}
+
protected void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection =
(IStructuredSelection) getViewer().getSelection();
@@ -171,6 +168,7 @@
label.dispose();
label = null;
}
+ part = null;
}
// private void connect() {
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2009-10-22 12:01:48 UTC (rev 18233)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2009-10-22 12:55:04 UTC (rev 18234)
@@ -27,6 +27,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.jboss.tools.common.meta.action.XAction;
@@ -45,8 +46,8 @@
private XFilteredTreeConstraint[] filters = new XFilteredTreeConstraint[0];
private SelectionNotifier notifier;
- public SampleTreeForm() {
- tree = new XModelObjectTreeViewComponent();
+ public SampleTreeForm(IEditorPart part) {
+ tree = new XModelObjectTreeViewComponent(part);
headingText = "Tree Form";
setCollapsable(Boolean.FALSE.booleanValue());
createActionMapping();
14 years, 8 months
JBoss Tools SVN: r18233 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-10-22 08:01:48 -0400 (Thu, 22 Oct 2009)
New Revision: 18233
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java
Log:
removed unused imports
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java 2009-10-22 11:45:00 UTC (rev 18232)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java 2009-10-22 12:01:48 UTC (rev 18233)
@@ -26,7 +26,6 @@
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
@@ -40,7 +39,6 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
14 years, 8 months
JBoss Tools SVN: r18232 - in branches/jbosstools-3.1.0.M4/hibernatetools: plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-10-22 07:45:00 -0400 (Thu, 22 Oct 2009)
New Revision: 18232
Modified:
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java
branches/jbosstools-3.1.0.M4/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5076 - fix
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 11:42:58 UTC (rev 18231)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 11:45:00 UTC (rev 18232)
@@ -111,7 +111,7 @@
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
- saveAsDialog.setOriginalName(getDiagramName());
+ saveAsDialog.setOriginalName(getStoreFileName());
saveAsDialog.open();
final IPath pathSave = saveAsDialog.getResult();
if (pathSave == null) {
@@ -313,14 +313,21 @@
}
public String getDiagramName() {
- IEditorInput input = getEditorInput();
- if (input instanceof DiagramEditorInput) {
- DiagramEditorInput objectEditorInput = (DiagramEditorInput)input;
- return objectEditorInput.getName();
+ DiagramEditorInput diagramInput = getDiagramInput();
+ if (diagramInput != null) {
+ return diagramInput.getName();
}
return ""; //$NON-NLS-1$
}
+ public String getStoreFileName() {
+ DiagramEditorInput diagramInput = getDiagramInput();
+ if (diagramInput != null) {
+ return diagramInput.getStoreFileName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
public void refresh() {
getOrmDiagram().refresh();
setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + " " + getDiagramInput().getName()); //$NON-NLS-1$
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-10-22 11:42:58 UTC (rev 18231)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-10-22 11:45:00 UTC (rev 18232)
@@ -10,13 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.Graphics;
@@ -81,18 +82,17 @@
saveDialog = new SaveAsDialog(getDiagramViewer().getSite().getWorkbenchWindow().getShell());
createdSaveDialog = true;
}
- saveDialog.setOriginalName(getDiagramViewer().getDiagramName());
+ saveDialog.setOriginalName(getDiagramViewer().getStoreFileName());
saveDialog.open();
- final IPath pathSave = saveDialog.getResult();
+ final IPath pathSave = saveDialog.getResult();
+ saveDialog = null;
if (pathSave == null) {
return;
}
-
final IFigure fig = ((ScalableFreeformRootEditPart) getDiagramViewer()
.getEditPartViewer().getRootEditPart())
.getLayer(LayerConstants.PRINTABLE_LAYERS);
int imageTypeTmp = SWT.IMAGE_BMP;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
String ext = pathSave.getFileExtension();
if (ext != null) {
ext = ext.toLowerCase();
@@ -106,23 +106,31 @@
imageTypeTmp = SWT.IMAGE_BMP;
}
}
- IPath pathTmp = workspace.getRoot().getFullPath().append(pathSave);
- pathTmp = workspace.getRoot().getLocation().append(pathTmp);
+ IPath pathTmp = pathSave;
if (ext == null) {
pathTmp = pathTmp.addFileExtension("bmp"); //$NON-NLS-1$
}
final IPath path = pathTmp;
final int imageType = imageTypeTmp;
+
+ final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
public void execute(final IProgressMonitor monitor) {
- FileOutputStream outStream = null;
+ ByteArrayInputStream inputStream = null;
try {
- byte[] imageData = createImage(fig, imageType);
- outStream = new FileOutputStream(path.toString());
- outStream.write(imageData);
- outStream.flush();
- } catch (IOException e) {
+ if (file != null) {
+ byte[] imageData = createImage(fig, imageType);
+ if (file.exists()) {
+ file.delete(true, null);
+ }
+ if (!file.exists()) {
+ inputStream = new ByteArrayInputStream(imageData);
+ file.create(inputStream, true, null);
+ }
+ }
+
+ } catch (CoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage("ExportImageAction", e); //$NON-NLS-1$
if (showErrDialog) {
MessageDialog.openInformation(getDiagramViewer().getSite().getShell(),
@@ -130,9 +138,9 @@
}
}
finally {
- if (outStream != null) {
+ if (inputStream != null) {
try {
- outStream.close();
+ inputStream.close();
} catch (IOException e) {
// ignore
}
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java 2009-10-22 11:42:58 UTC (rev 18231)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java 2009-10-22 11:45:00 UTC (rev 18232)
@@ -91,6 +91,10 @@
return ormDiagram.getDiagramName();
}
+ public String getStoreFileName() {
+ return ormDiagram.getStoreFileName();
+ }
+
public IPersistableElement getPersistable() {
return this;
}
Modified: branches/jbosstools-3.1.0.M4/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
===================================================================
--- branches/jbosstools-3.1.0.M4/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java 2009-10-22 11:42:58 UTC (rev 18231)
+++ branches/jbosstools-3.1.0.M4/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java 2009-10-22 11:45:00 UTC (rev 18232)
@@ -25,6 +25,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.hibernate.eclipse.console.test.project.TestProject;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jmock.Expectations;
@@ -39,7 +40,20 @@
* @author Vitali Yemialyanchyk
*/
public class ExportImageActionTest extends TestCase {
+
+ public static final String PROJECT_NAME = "TestProject"; //$NON-NLS-1$
+ protected TestProject project = null;
+
+ protected void setUp() throws Exception {
+ project = new TestProject(PROJECT_NAME);
+ }
+
+ protected void tearDown() throws Exception {
+ project.deleteIProject();
+ project = null;
+ }
+
public Mockery context = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
@@ -56,12 +70,12 @@
final Control control = context.mock(Control.class);
final Display display = context.mock(Display.class);
final Rectangle rectangle = new Rectangle(0, 0, 20, 10);
- final String filePath = "test.jpg"; //$NON-NLS-1$
+ final String filePath = PROJECT_NAME + File.separator + "test.jpg"; //$NON-NLS-1$
final IPath resPath = new Path(filePath);
context.checking(new Expectations() {
{
- allowing(editor).getDiagramName();
+ allowing(editor).getStoreFileName();
will(returnValue(filePath));
allowing(saveDialog).setOriginalName(filePath);
@@ -120,7 +134,6 @@
// GENERAL TEST:
// check for all expectations
context.assertIsSatisfied();
-
}
14 years, 8 months
JBoss Tools SVN: r18231 - trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-10-22 07:42:58 -0400 (Thu, 22 Oct 2009)
New Revision: 18231
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5076 - fix
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java 2009-10-22 11:42:04 UTC (rev 18230)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java 2009-10-22 11:42:58 UTC (rev 18231)
@@ -25,6 +25,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.hibernate.eclipse.console.test.project.TestProject;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
import org.jmock.Expectations;
@@ -39,7 +40,20 @@
* @author Vitali Yemialyanchyk
*/
public class ExportImageActionTest extends TestCase {
+
+ public static final String PROJECT_NAME = "TestProject"; //$NON-NLS-1$
+ protected TestProject project = null;
+
+ protected void setUp() throws Exception {
+ project = new TestProject(PROJECT_NAME);
+ }
+
+ protected void tearDown() throws Exception {
+ project.deleteIProject();
+ project = null;
+ }
+
public Mockery context = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
@@ -56,12 +70,12 @@
final Control control = context.mock(Control.class);
final Display display = context.mock(Display.class);
final Rectangle rectangle = new Rectangle(0, 0, 20, 10);
- final String filePath = "test.jpg"; //$NON-NLS-1$
+ final String filePath = PROJECT_NAME + File.separator + "test.jpg"; //$NON-NLS-1$
final IPath resPath = new Path(filePath);
context.checking(new Expectations() {
{
- allowing(editor).getDiagramName();
+ allowing(editor).getStoreFileName();
will(returnValue(filePath));
allowing(saveDialog).setOriginalName(filePath);
@@ -120,7 +134,6 @@
// GENERAL TEST:
// check for all expectations
context.assertIsSatisfied();
-
}
14 years, 8 months
JBoss Tools SVN: r18230 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui: diagram/editors/actions and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-10-22 07:42:04 -0400 (Thu, 22 Oct 2009)
New Revision: 18230
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5076 - fix
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 10:22:30 UTC (rev 18229)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-10-22 11:42:04 UTC (rev 18230)
@@ -111,7 +111,7 @@
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
- saveAsDialog.setOriginalName(getDiagramName());
+ saveAsDialog.setOriginalName(getStoreFileName());
saveAsDialog.open();
final IPath pathSave = saveAsDialog.getResult();
if (pathSave == null) {
@@ -313,14 +313,21 @@
}
public String getDiagramName() {
- IEditorInput input = getEditorInput();
- if (input instanceof DiagramEditorInput) {
- DiagramEditorInput objectEditorInput = (DiagramEditorInput)input;
- return objectEditorInput.getName();
+ DiagramEditorInput diagramInput = getDiagramInput();
+ if (diagramInput != null) {
+ return diagramInput.getName();
}
return ""; //$NON-NLS-1$
}
+ public String getStoreFileName() {
+ DiagramEditorInput diagramInput = getDiagramInput();
+ if (diagramInput != null) {
+ return diagramInput.getStoreFileName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
public void refresh() {
getOrmDiagram().refresh();
setPartName(DiagramViewerMessages.DiagramViewer_diagram_for + " " + getDiagramInput().getName()); //$NON-NLS-1$
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-10-22 10:22:30 UTC (rev 18229)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-10-22 11:42:04 UTC (rev 18230)
@@ -10,13 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.Graphics;
@@ -81,18 +82,17 @@
saveDialog = new SaveAsDialog(getDiagramViewer().getSite().getWorkbenchWindow().getShell());
createdSaveDialog = true;
}
- saveDialog.setOriginalName(getDiagramViewer().getDiagramName());
+ saveDialog.setOriginalName(getDiagramViewer().getStoreFileName());
saveDialog.open();
- final IPath pathSave = saveDialog.getResult();
+ final IPath pathSave = saveDialog.getResult();
+ saveDialog = null;
if (pathSave == null) {
return;
}
-
final IFigure fig = ((ScalableFreeformRootEditPart) getDiagramViewer()
.getEditPartViewer().getRootEditPart())
.getLayer(LayerConstants.PRINTABLE_LAYERS);
int imageTypeTmp = SWT.IMAGE_BMP;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
String ext = pathSave.getFileExtension();
if (ext != null) {
ext = ext.toLowerCase();
@@ -106,23 +106,31 @@
imageTypeTmp = SWT.IMAGE_BMP;
}
}
- IPath pathTmp = workspace.getRoot().getFullPath().append(pathSave);
- pathTmp = workspace.getRoot().getLocation().append(pathTmp);
+ IPath pathTmp = pathSave;
if (ext == null) {
pathTmp = pathTmp.addFileExtension("bmp"); //$NON-NLS-1$
}
final IPath path = pathTmp;
final int imageType = imageTypeTmp;
+
+ final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
public void execute(final IProgressMonitor monitor) {
- FileOutputStream outStream = null;
+ ByteArrayInputStream inputStream = null;
try {
- byte[] imageData = createImage(fig, imageType);
- outStream = new FileOutputStream(path.toString());
- outStream.write(imageData);
- outStream.flush();
- } catch (IOException e) {
+ if (file != null) {
+ byte[] imageData = createImage(fig, imageType);
+ if (file.exists()) {
+ file.delete(true, null);
+ }
+ if (!file.exists()) {
+ inputStream = new ByteArrayInputStream(imageData);
+ file.create(inputStream, true, null);
+ }
+ }
+
+ } catch (CoreException e) {
HibernateConsolePlugin.getDefault().logErrorMessage("ExportImageAction", e); //$NON-NLS-1$
if (showErrDialog) {
MessageDialog.openInformation(getDiagramViewer().getSite().getShell(),
@@ -130,9 +138,9 @@
}
}
finally {
- if (outStream != null) {
+ if (inputStream != null) {
try {
- outStream.close();
+ inputStream.close();
} catch (IOException e) {
// ignore
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java 2009-10-22 10:22:30 UTC (rev 18229)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/DiagramEditorInput.java 2009-10-22 11:42:04 UTC (rev 18230)
@@ -91,6 +91,10 @@
return ormDiagram.getDiagramName();
}
+ public String getStoreFileName() {
+ return ormDiagram.getStoreFileName();
+ }
+
public IPersistableElement getPersistable() {
return this;
}
14 years, 8 months