[jbosstools-commits] JBoss Tools SVN: r17604 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 15 21:06:57 EDT 2009


Author: dgolovin
Date: 2009-09-15 21:06:57 -0400 (Tue, 15 Sep 2009)
New Revision: 17604

Modified:
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.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/diagram/editors/actions/OpenMappingAction.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java
Log:
exception handling was cleaned up in o.j.t.hibernate.ui.diagram.editors.actions

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java	2009-09-16 01:02:19 UTC (rev 17603)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/DiagramBaseAction.java	2009-09-16 01:06:57 UTC (rev 17604)
@@ -30,22 +30,16 @@
 
 	protected DiagramViewer getDiagramViewer() {
 		DiagramViewer res = editor;
-		if (res == null && PlatformUI.getWorkbench() != null && 
-				PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null &&
-				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null &&
-				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() != null) {
-			IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
-			if (part instanceof DiagramViewer) {
-				res = (DiagramViewer)part;
-			} else if (part instanceof ContentOutline) {
-				ContentOutline co = (ContentOutline)part;
-				if (co.getCurrentPage() instanceof DiagramContentOutlinePage) {
-					DiagramContentOutlinePage dcop = (DiagramContentOutlinePage)co.getCurrentPage();
-					res = dcop.getEditor();
-				}
+		IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+		if (part instanceof DiagramViewer) {
+			res = (DiagramViewer)part;
+		} else if (part instanceof ContentOutline) {
+			ContentOutline co = (ContentOutline)part;
+			if (co.getCurrentPage() instanceof DiagramContentOutlinePage) {
+				DiagramContentOutlinePage dcop = (DiagramContentOutlinePage)co.getCurrentPage();
+				res = dcop.getEditor();
 			}
 		}
 		return res;
 	}
-
 }

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-09-16 01:02:19 UTC (rev 17603)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java	2009-09-16 01:06:57 UTC (rev 17604)
@@ -96,7 +96,7 @@
 			outStream = new FileOutputStream(filePath);
 			outStream.write(imageData);
 			outStream.flush();
-		} catch (Exception e) {
+		} catch (IOException e) {
 			HibernateConsolePlugin.getDefault().logErrorMessage("ExportImageAction", e); //$NON-NLS-1$
 			if (showErrDialog) {
 				MessageDialog.openInformation(getDiagramViewer().getSite().getShell(),
@@ -123,7 +123,7 @@
 	 *          SWT.IMAGE_ICO, SWT.IMAGE_JPEG, or SWT.IMAGE_PNG
 	 * @return the bytes of an encoded image for the specified Figure
 	 */
-	private byte[] createImage(IFigure figure, int format) throws Exception {
+	private byte[] createImage(IFigure figure, int format) {
 
 		Device device = getDiagramViewer().getEditPartViewer().getControl()
 				.getDisplay();
@@ -134,7 +134,6 @@
 		Image image = null;
 		GC gc = null;
 		Graphics g = null;
-		Exception error = null;
 		try {
 			image = new Image(device, r.width, r.height);
 			gc = new GC(image);
@@ -146,8 +145,6 @@
 			ImageLoader imageLoader = new ImageLoader();
 			imageLoader.data = new ImageData[] { image.getImageData() };
 			imageLoader.save(result, format);
-		} catch (Exception ex) {
-			error = ex;
 		} finally {
 			if (g != null) {
 				g.dispose();
@@ -159,9 +156,6 @@
 				image.dispose();
 			}
 		}
-		if (error != null) {
-			throw error;
-		}
 		return result.toByteArray();
 	}
 

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java	2009-09-16 01:02:19 UTC (rev 17603)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenMappingAction.java	2009-09-16 01:06:57 UTC (rev 17604)
@@ -14,6 +14,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.gef.ui.actions.SelectionAction;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -66,10 +67,8 @@
 				Property parentProperty = ((SpecialRootClass)compositSel.getPersistentClass()).getProperty();
 				try {
 					editorPart = org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig, compositSel, parentProperty);
-				} catch (PartInitException e) {
+				} catch (CoreException e) {
 					HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_canot_find_or_open_mapping_file, e);
-				} catch (JavaModelException e) {
-					HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_canot_find_or_open_mapping_file, e);
 				} catch (FileNotFoundException e) {
 					HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_canot_find_or_open_mapping_file, e);
 				}
@@ -86,10 +85,8 @@
 			}
 			try {
 				editorPart = org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig, selection, selectionParent);
-			} catch (PartInitException e) {
+			} catch (CoreException e) {
 				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_open_mapping_file, e);
-			} catch (JavaModelException e) {
-				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_open_mapping_file, e);
 			} catch (FileNotFoundException e) {
 				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenMappingAction_open_mapping_file, e);
 			}

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java	2009-09-16 01:02:19 UTC (rev 17603)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/OpenSourceAction.java	2009-09-16 01:06:57 UTC (rev 17604)
@@ -14,6 +14,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.gef.ui.actions.SelectionAction;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -93,10 +94,8 @@
 			}*/
 			try {
 				editorPart = org.hibernate.eclipse.console.actions.OpenSourceAction.run(consoleConfig, selection, fullyQualifiedName);
-			} catch (PartInitException e) {
+			} catch (CoreException e) {
 				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenSourceAction_canot_open_source_file, e);
-			} catch (JavaModelException e) {
-				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenSourceAction_canot_find_source_file, e);
 			} catch (FileNotFoundException e) {
 				HibernateConsolePlugin.getDefault().logErrorMessage(DiagramViewerMessages.OpenSourceAction_canot_find_source_file, e);
 			}



More information about the jbosstools-commits mailing list