tmf: Bug 495054: Importing or exporting custom parsers fails silently
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 31 May 2016 17:58:10 +0000 (13:58 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 31 May 2016 20:09:03 +0000 (16:09 -0400)
When importing custom parsers from a file that does not contain any
custom parser definition, a message dialog is shown to the user.

When exporting a custom parser to an existing file that is not a valid
custom parser definition file, a message is logged to the Error Log.

Change-Id: I2f0bb781d9d43d8bbaf05da2b7ec06c2a65d47d3
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/74094
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties

index 087c5bd20c7f4b35273d75aa2d1ecfd90d505440..2de73280a88ea9618a503b777b9a35b37cd71bb3 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 Ericsson
+ * Copyright (c) 2010, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -34,7 +34,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerFactoryConfigurationError;
@@ -494,6 +493,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
             if (file.canRead()) {
                 doc = db.parse(file);
                 if (!doc.getDocumentElement().getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                    Activator.logError(String.format("Error saving CustomTxtTraceDefinition: path=%s is not a valid custom parser file", path)); //$NON-NLS-1$
                     return;
                 }
             } else {
@@ -546,17 +546,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
 
             TmfTraceType.addCustomTraceType(CustomTxtTrace.class, categoryName, definitionName);
 
-        } catch (ParserConfigurationException e) {
-            Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
-        } catch (TransformerConfigurationException e) {
-            Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
-        } catch (TransformerFactoryConfigurationError e) {
-            Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
-        } catch (TransformerException e) {
-            Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
-        } catch (IOException e) {
-            Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
-        } catch (SAXException e) {
+        } catch (ParserConfigurationException | TransformerFactoryConfigurationError | TransformerException | IOException | SAXException e) {
             Activator.logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
         }
     }
index 19263f4ffd2db30e80db0cca2db2eb0f2d60465e..d95783237a1d47292522d6816116190df932b28e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 Ericsson
+ * Copyright (c) 2010, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -169,6 +169,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition {
             if (file.canRead()) {
                 doc = db.parse(file);
                 if (!doc.getDocumentElement().getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                    Activator.logError(String.format("Error saving CustomXmlTraceDefinition: path=%s is not a valid custom parser file", path)); //$NON-NLS-1$
                     return;
                 }
             } else {
index 62bda33b17fb4d99e45fc9186729948ccc612fcb..1151ab56aeb127390983201953d6a5bb8fb053d5 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson
+ * Copyright (c) 2012, 2016 Ericsson
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -35,6 +35,8 @@ public class Messages extends NLS {
     public static String ManageCustomParsersDialog_ExportParserSelection;
     public static String ManageCustomParsersDialog_ImportButtonLabel;
     public static String ManageCustomParsersDialog_ImportParserSelection;
+    public static String ManageCustomParsersDialog_ImportFailureTitle;
+    public static String ManageCustomParsersDialog_ImportFailureMessage;
     public static String ManageCustomParsersDialog_NewButtonLabel;
     public static String ManageCustomParsersDialog_TextButtonLabel;
 
index a69b77ff82e578b1b69216094044f45dd248c93e..d7c38d44f6c1198a727328f5e2b8518cb2f42920 100644 (file)
@@ -262,6 +262,10 @@ public class ManageCustomParsersDialog extends Dialog {
                             }
                         }
                         fillParserList();
+                    } else {
+                        MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
+                                Messages.ManageCustomParsersDialog_ImportFailureTitle,
+                                Messages.ManageCustomParsersDialog_ImportFailureMessage);
                     }
                 }
             }
index e07a4779ba516aa567365a72b0fc98eb839b02bc..6fd59177cf82a70d17ef8bd76a914994b1ca04f9 100644 (file)
@@ -27,6 +27,8 @@ ManageCustomParsersDialog_ExportButtonLabel=Export...
 ManageCustomParsersDialog_ExportParserSelection=Select file to export {0}
 ManageCustomParsersDialog_ImportButtonLabel=Import...
 ManageCustomParsersDialog_ImportParserSelection=Select custom parser file to import
+ManageCustomParsersDialog_ImportFailureTitle=Import failure
+ManageCustomParsersDialog_ImportFailureMessage=Selected file did not contain any valid custom parser.
 ManageCustomParsersDialog_NewButtonLabel=New...
 ManageCustomParsersDialog_TextButtonLabel=Text
 
This page took 0.027185 seconds and 5 git commands to generate.