Commit ab6b4d49 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ warnings when translation fails

parent e065e060
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
@@ -22,6 +23,7 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.ide.dialogs.InternalErrorDialog;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
@@ -136,6 +138,20 @@ public class TranslationHandler extends AbstractHandler {
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						MessageDialog errorDialog = new MessageDialog(
								Display.getDefault().getActiveShell(), 
								"Translation error...", 
								null, 
								"An error occurred during the translation. "
								+ "It may be due to problems occurring while processing the input, "
								+ "e.g if the input could not be processed. "
								+ "See details for a more technical description:\n\n"
								+ e.getMessage()
								,		
								MessageDialog.ERROR, 
								0, 
								new String[] {"OK"});
						errorDialog.open();
					}
				}
				if (type.contains("yaml")) {
@@ -147,6 +163,20 @@ public class TranslationHandler extends AbstractHandler {
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						MessageDialog errorDialog = new MessageDialog(
								Display.getDefault().getActiveShell(), 
								"Translation error...", 
								null, 
								"An error occurred during the translation. "
								+ "It may be due to problems occurring while processing the input, "
								+ "e.g if the input could not be processed. "
								+ "See details for a more technical description:\n\n"
								+ e.getMessage()
								,		
								MessageDialog.ERROR, 
								0, 
								new String[] {"OK"});
						errorDialog.open();
					}
					
				}				
@@ -165,9 +195,23 @@ public class TranslationHandler extends AbstractHandler {
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		}
					MessageDialog errorDialog = new MessageDialog(
							Display.getDefault().getActiveShell(), 
							"Translation error...", 
							null, 
							"An error occurred during the translation. "
							+ "It may be due to problems occurring while storing the output. "
							+ "See details for a more technical description and consider usind a different target format:\n\n"
							+ e1.getMessage()
							,		
							MessageDialog.ERROR, 
							0, 
							new String[] {"OK"});
					errorDialog.open();
				}
			}
		}
		//TODO: throw proper execution exceptions?
		return null;
	}