From a94410d92f16c8ce3870bb2e1538b93e038e4f78 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Thu, 18 Apr 2013 13:35:48 -0400 Subject: [PATCH] [Tmf][Ctf] Add descriptive fail to import messages. This patch proposes a way of showing more error details. The ctf modifications use reflexion since the parser and lexer are auto-generated. Now with number format exceptions for ints Messages.java now have suppress warnings javadoc Change-Id: I74cbbd4aaff29f458786ffc96e88b5416b49beed Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/11788 --- .../ctf/core/trace/CTFReaderException.java | 91 +++++++++++- .../linuxtools/ctf/core/trace/Metadata.java | 13 +- .../ctf/core/event/metadata/IOStructGen.java | 22 +-- .../metadata/exceptions/ParseException.java | 10 +- .../internal/gdbtrace/core/Activator.java | 140 ++++++++++++++++++ .../gdbtrace/core/trace/GdbTrace.java | 32 ++-- .../gdbtrace/core/trace/Messages.java | 36 +++++ .../gdbtrace/core/trace/messages.properties | 1 + .../kernel/core/trace/CtfKernelTrace.java | 21 ++- .../lttng2/kernel/core/trace/Messages.java | 35 +++++ .../kernel/core/trace/messages.properties | 1 + .../tests/ctfadaptor/CtfTmfTraceTest.java | 6 +- .../tmf/core/tests/trace/TmfTraceTest.java | 2 +- .../tmf/tests/stubs/trace/Messages.java | 34 +++++ .../tmf/tests/stubs/trace/TmfTraceStub.java | 22 ++- .../tmf/tests/stubs/trace/messages.properties | 1 + .../tmf/core/ctfadaptor/CtfTmfTrace.java | 100 +++++++------ .../tmf/core/ctfadaptor/Messages.java | 37 +++++ .../tmf/core/ctfadaptor/messages.properties | 2 + .../linuxtools/tmf/core/trace/ITmfTrace.java | 4 +- .../tmf/core/trace/TmfExperiment.java | 9 +- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 9 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 10 +- .../tmf/ui/parsers/custom/Messages.java | 26 ++++ .../tmf/ui/parsers/custom/messages.properties | 1 + .../tmf/ui/project/handlers/Messages.java | 6 + .../handlers/SelectTraceTypeHandler.java | 57 +++++-- .../ui/project/handlers/messages.properties | 3 + .../wizards/ImportTraceWizardPage.java | 88 +++++++---- .../tmf/ui/project/wizards/Messages.java | 9 +- .../tmf/ui/viewers/statistics/Messages.java | 1 + .../ui/viewers/statistics/model/Messages.java | 1 + .../tmf/ui/views/histogram/Messages.java | 1 + .../tmf/ui/views/statistics/Messages.java | 1 + 34 files changed, 691 insertions(+), 141 deletions(-) create mode 100644 org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/Activator.java create mode 100644 org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/Messages.java create mode 100644 org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/messages.properties create mode 100644 org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Messages.java create mode 100644 org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/messages.properties create mode 100644 org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/Messages.java create mode 100644 org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/messages.properties create mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java create mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/Messages.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/messages.properties diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFReaderException.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFReaderException.java index c3499eaf68..179829d2aa 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFReaderException.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFReaderException.java @@ -7,20 +7,33 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: Alexandre Montplaisir - Initial API and implementation + * Contributors: Matthew Khouzam - Addition to have more descriptive errors *******************************************************************************/ package org.eclipse.linuxtools.ctf.core.trace; +import java.lang.reflect.Field; + +import org.antlr.runtime.MismatchedTokenException; +import org.antlr.runtime.RecognitionException; +import org.eclipse.linuxtools.ctf.parser.CTFLexer; + /** * General exception that is thrown when there is a problem somewhere with the * CTF trace reader. - * + * * @version 1.0 * @author Alexandre Montplaisir */ public class CTFReaderException extends Exception { private static final long serialVersionUID = 2065258365219777672L; + private int fErrorLine = -1; + private String fFile = ""; //$NON-NLS-1$ + private String fExpectingName = ""; //$NON-NLS-1$ + private int fExpectedValue = -1; + private String fActualName = ""; //$NON-NLS-1$ + private int fActualValue = -1; /** * Default constructor with no message. @@ -48,4 +61,80 @@ public class CTFReaderException extends Exception { public CTFReaderException(Exception e) { super(e); } + + /** + * Re-throw the exception but read its data + * + * @param e + * the previous recognition exception (Antlr specific) + * @since 2.0 + */ + public CTFReaderException(RecognitionException e) { + super(e); + this.fErrorLine = e.line; + this.fFile = "metadata"; //$NON-NLS-1$ // we're in CTF, the only thing using antlr is metadata + } + + /** + * Re-throw the exception but read its data + * + * @param e + * the previous recognition exception (Antlr specific) + * @since 2.0 + */ + public CTFReaderException(MismatchedTokenException e){ + super(e); + this.fErrorLine = e.line; + this.fFile = "metadata"; //$NON-NLS-1$ // we're in CTF, the only thing using antlr is metadata + parseMismatchedException(e); + } + + private void parseMismatchedException(MismatchedTokenException m) { + // Iterate through the tokens that are hidden in the CTFLexer + // They are private static final int fields. + for (Field f : CTFLexer.class.getDeclaredFields()) { + f.setAccessible(true); + String name; + int value; + try { + name = f.getName(); + final boolean isInt = (f.getType().isPrimitive()); + if (isInt) { + value = ((Integer) f.get(null)).intValue(); + if (value == m.expecting) { + this.fExpectingName = name; + this.fExpectedValue = value; + } + if (value == m.c) { + this.fActualName = name; + this.fActualValue = value; + } + } + } catch (NullPointerException e1) { + // Pokemon, gotta catch em all! + // actually useful since f may not have a + // value + } catch (IllegalArgumentException e1) { + // Catch these exceptions (reflexion) + } catch (IllegalAccessException e1) { + // Catch these exceptions (reflexion) + } + if (!this.fExpectingName.isEmpty() && !this.fActualName.isEmpty()) { + return; + } + } + } + + @Override + public String getMessage() { + final String message = super.getMessage(); + if (fErrorLine == -1) { + return message; + } + String expected = "" + this.fExpectedValue; //$NON-NLS-1$ + String actual = "" + this.fActualValue; //$NON-NLS-1$ + String newMessage = message.replaceAll(expected, this.fExpectingName); + newMessage = newMessage.replaceAll(actual, this.fActualName); + return newMessage + " at " + fFile + ":" + fErrorLine; //$NON-NLS-1$ //$NON-NLS-2$ + } } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java index 92e0129139..27ca681d63 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java @@ -27,6 +27,7 @@ import java.util.UUID; import org.antlr.runtime.ANTLRReaderStream; import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.MismatchedTokenException; import org.antlr.runtime.RecognitionException; import org.antlr.runtime.tree.CommonTree; import org.eclipse.linuxtools.ctf.parser.CTFLexer; @@ -174,11 +175,9 @@ public class Metadata { tempException = new CTFReaderException(e); } catch (ParseException e) { tempException = new CTFReaderException(e); + } catch (MismatchedTokenException e) { + tempException = new CTFReaderException(e); } catch (RecognitionException e) { - /* - * We don't want to expose this ANTLR-specific exception type to the - * outside.. - */ tempException = new CTFReaderException(e); } @@ -250,8 +249,7 @@ public class Metadata { try { metadataFileChannel.read(magicByteBuffer, 0); } catch (IOException e) { - throw new CTFReaderException( - "Unable to read metadata file channel."); //$NON-NLS-1$ + throw new CTFReaderException("Unable to read metadata file channel."); //$NON-NLS-1$ } /* Get the first int from the file */ @@ -353,8 +351,7 @@ public class Metadata { try { metadataFileChannel.read(payloadByteBuffer); } catch (IOException e) { - throw new CTFReaderException( - "Error reading metadata packet payload."); //$NON-NLS-1$ + throw new CTFReaderException("Error reading metadata packet payload."); //$NON-NLS-1$ } payloadByteBuffer.rewind(); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java index aa5a43fff8..c6a1fb5fa8 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java @@ -35,6 +35,7 @@ import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration; +import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; import org.eclipse.linuxtools.ctf.parser.CTFParser; @@ -2307,23 +2308,26 @@ public class IOStructGen { * @param unaryInteger * An unary integer node. * @return The integer value. + * @throws CTFReaderException */ - private static long parseUnaryInteger(CommonTree unaryInteger) { + private static long parseUnaryInteger(CommonTree unaryInteger) throws ParseException { List children = unaryInteger.getChildren(); CommonTree value = children.get(0); String strval = value.getText(); long intval; - - if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_DEC) { - intval = Long.parseLong(strval, 10); - } else if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_HEX) { - intval = Long.parseLong(strval, 0x10); - } else { /* unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_OCT */ - intval = Long.parseLong(strval, 010); // 010 == 0x08 == 8 + try { + if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_DEC) { + intval = Long.parseLong(strval, 10); + } else if (unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_HEX) { + intval = Long.parseLong(strval, 0x10); + } else { /* unaryInteger.getType() == CTFParser.UNARY_EXPRESSION_OCT */ + intval = Long.parseLong(strval, 010); // 010 == 0x08 == 8 + } + } catch (NumberFormatException e) { + throw new ParseException(e); } - /* The rest of children are sign */ if ((children.size() % 2) == 0) { return -intval; diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java index 242f015143..b365b87ca4 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java @@ -12,6 +12,7 @@ package org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions; + /** * ParseException */ @@ -20,7 +21,7 @@ public class ParseException extends Exception { private static final long serialVersionUID = 7901917601459652080L; /** - * Enoty constructor + * Empty constructor */ public ParseException() { super(); @@ -35,4 +36,11 @@ public class ParseException extends Exception { super(message); } + /** + * Copy constructor + * @param e the exception to throw + */ + public ParseException(Exception e) { + super(e); + } } diff --git a/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/Activator.java b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/Activator.java new file mode 100644 index 0000000000..5052894f89 --- /dev/null +++ b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/Activator.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.internal.gdbtrace.core; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; + +/** + * The activator class controls the plug-in life cycle. No more than one such + * plug-in can exist at any time. + *

+ * It also provides the plug-in's general logging facility and manages the + * internal tracer. + */ +public class Activator extends Plugin { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * The plug-in ID + */ + public static final String PLUGIN_ID = "org.eclipse.linuxtools.gdbtrace.core"; //$NON-NLS-1$ + + /** + * The shared instance + */ + private static Activator fPlugin; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * Constructor + */ + public Activator() { + setDefault(this); + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * Returns the TMF Core plug-in instance. + * + * @return the TMF Core plug-in instance. + */ + public static Activator getDefault() { + return fPlugin; + } + + // Sets plug-in instance + private static void setDefault(Activator plugin) { + fPlugin = plugin; + } + + // ------------------------------------------------------------------------ + // Log INFO + // ------------------------------------------------------------------------ + + /** + * Logs a message with severity INFO in the runtime log of the plug-in. + * + * @param message A message to log + */ + public static void logInfo(String message) { + fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity INFO in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception The corresponding exception + */ + public static void logInfo(String message, Throwable exception) { + fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception)); + } + + // ------------------------------------------------------------------------ + // Log WARNING + // ------------------------------------------------------------------------ + + /** + * Logs a message and exception with severity WARNING in the runtime log of the plug-in. + * + * @param message A message to log + */ + public static void logWarning(String message) { + fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity WARNING in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception The corresponding exception + */ + public static void logWarning(String message, Throwable exception) { + fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception)); + } + + // ------------------------------------------------------------------------ + // Log ERROR + // ------------------------------------------------------------------------ + + /** + * Logs a message and exception with severity ERROR in the runtime log of the plug-in. + * + * @param message A message to log + */ + public static void logError(String message) { + fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); + } + + /** + * Logs a message and exception with severity ERROR in the runtime log of the plug-in. + * + * @param message A message to log + * @param exception The corresponding exception + */ + public static void logError(String message, Throwable exception) { + fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception)); + } + +} diff --git a/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/GdbTrace.java b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/GdbTrace.java index c234cf438d..9def9764df 100644 --- a/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/GdbTrace.java +++ b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/GdbTrace.java @@ -10,6 +10,7 @@ * Marc Dumais - Initial implementation * Francois Chouinard - Initial API and implementation * Patrick Tasse - Updated for TMF 2.0 + * Matthew Khouzam - update validate *******************************************************************************/ package org.eclipse.linuxtools.internal.gdbtrace.core.trace; @@ -17,9 +18,12 @@ package org.eclipse.linuxtools.internal.gdbtrace.core.trace; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.internal.gdbtrace.core.GdbTraceCorePlugin; import org.eclipse.linuxtools.internal.gdbtrace.core.event.GdbTraceEvent; +import org.eclipse.linuxtools.internal.gdbtrace.core.Activator; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; @@ -31,12 +35,14 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; /** - * GDB Tracepoint extension of TmfTrace. This class implements the necessary - * methods and functionalities so that a GDB tracepoint file can be used by - * the TMF framework as a "tracer". + * GDB Tracepoint extension of TmfTrace. This class implements the necessary + * methods and functionalities so that a GDB tracepoint file can be used by the + * TMF framework as a "tracer". *

+ * * @author Marc Dumais * @author Francois Chouinard + * @author Matthew Khouzam */ public class GdbTrace extends TmfTrace implements ITmfEventParser { @@ -73,8 +79,11 @@ public class GdbTrace extends TmfTrace implements ITmfEventParser { } @Override - public boolean validate(IProject project, String path) { - return fileExists(path); + public IStatus validate(IProject project, String path) { + if (fileExists(path)) { + return Status.OK_STATUS; + } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.GdbTrace_FileNotFound + ": " + path); //$NON-NLS-1$ } @Override @@ -104,15 +113,15 @@ public class GdbTrace extends TmfTrace implements ITmfEventParser { /** * @return GDB-DSF session id */ - public String getDsfSessionId () { + public String getDsfSessionId() { return fGdbTpRef.getSessionId(); } /** * @return the number of frames in current tp session */ - public long getNbFrames () { - fNbFrames = fGdbTpRef.getNumberOfFrames(); + public long getNbFrames() { + fNbFrames = fGdbTpRef.getNumberOfFrames(); return fNbFrames; } @@ -150,7 +159,8 @@ public class GdbTrace extends TmfTrace implements ITmfEventParser { if (context.getRank() >= fNbFrames) { return null; } - // work-around to ensure that the select and parse of trace frame will be atomic + // work-around to ensure that the select and parse of trace frame will + // be atomic GdbTraceEvent event = fGdbTpRef.selectAndReadFrame(context.getRank()); fLocation++; return event; @@ -171,7 +181,9 @@ public class GdbTrace extends TmfTrace implements ITmfEventParser { /** * Select a frame and update the visualization - * @param rank the rank + * + * @param rank + * the rank */ public void selectFrame(long rank) { fGdbTpRef.selectDataFrame(rank, true); diff --git a/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/Messages.java b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/Messages.java new file mode 100644 index 0000000000..7de66b67e6 --- /dev/null +++ b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/Messages.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.internal.gdbtrace.core.trace; + +import org.eclipse.osgi.util.NLS; + +/** + * + * @author Matthew Khouzam + * + */ +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.gdbtrace.core.trace.messages"; //$NON-NLS-1$ + /** + * File not found + */ + public static String GdbTrace_FileNotFound; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/messages.properties b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/messages.properties new file mode 100644 index 0000000000..e2917d6cf9 --- /dev/null +++ b/org.eclipse.linuxtools.gdbtrace.core/src/org/eclipse/linuxtools/internal/gdbtrace/core/trace/messages.properties @@ -0,0 +1 @@ +GdbTrace_FileNotFound=File not found diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java index 2ea145c6a8..072eef0ed3 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java @@ -8,6 +8,7 @@ * * Contributors: * Alexandre Montplaisir - Initial API and implementation + * Matthew Khouzam - Improved validation ******************************************************************************/ package org.eclipse.linuxtools.lttng2.kernel.core.trace; @@ -17,8 +18,11 @@ import java.io.File; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; +import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator; import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput; import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; @@ -54,9 +58,13 @@ public class CtfKernelTrace extends CtfTmfTrace { super(); } + /** + * @since 2.0 + */ @Override - public boolean validate(final IProject project, final String path) { + public IStatus validate(final IProject project, final String path) { CTFTrace temp; + IStatus validStatus; /* * Make sure the trace is openable as a CTF trace. We do this here * instead of calling super.validate() to keep the reference to "temp". @@ -64,16 +72,21 @@ public class CtfKernelTrace extends CtfTmfTrace { try { temp = new CTFTrace(path); } catch (CTFReaderException e) { - return false; + validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); + return validStatus; + } catch (NullPointerException e){ + validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); + return validStatus; } /* Make sure the domain is "kernel" in the trace's env vars */ String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ temp.dispose(); if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$ - return true; + return Status.OK_STATUS; } - return false; + validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfKernelTrace_DomainError); + return validStatus; } @Override diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Messages.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Messages.java new file mode 100644 index 0000000000..67346180f7 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Messages.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng2.kernel.core.trace; + +import org.eclipse.osgi.util.NLS; + +/** + * Messages + * + * @author Matthew Khouzam + * @since 2.0 + */ +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng2.kernel.core.trace.messages"; //$NON-NLS-1$ + /** + * The domain is not "kernel" + */ + public static String CtfKernelTrace_DomainError; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/messages.properties b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/messages.properties new file mode 100644 index 0000000000..2faa30e13a --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/messages.properties @@ -0,0 +1 @@ +CtfKernelTrace_DomainError=Domain mismatch, make sure the environment is 'kernel' diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java index 3805bf6ed8..82f8a4fd35 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java @@ -21,6 +21,7 @@ import static org.junit.Assume.assumeTrue; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; @@ -348,12 +349,13 @@ public class CtfTmfTraceTest { /** * Run the boolean validate(IProject,String) method test. + * @throws TmfValidationException */ @Test public void testValidate() { IProject project = null; String path = PATH; - boolean result = fixture.validate(project, path); - assertTrue(result); + IStatus result = fixture.validate(project, path); + assertTrue(result.isOK()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java index 3a1ee1130d..496a6d0b1d 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java @@ -397,7 +397,7 @@ public class TmfTraceTest { // Validate final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); final File testfile = new File(FileLocator.toFileURL(location).toURI()); - assertTrue("validate", trace.validate(null, testfile.getPath())); + assertTrue("validate", trace.validate(null, testfile.getPath()).isOK()); // InitTrace and wait for indexing completion... trace.initTrace(null, testfile.toURI().getPath(), ITmfEvent.class); diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/Messages.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/Messages.java new file mode 100644 index 0000000000..e03ebf7b2c --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/Messages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.tmf.tests.stubs.trace; + +import org.eclipse.osgi.util.NLS; + +/** + * @author Matthew Khouzam + * @since 2.0 + */ +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.tests.stubs.trace.messages"; //$NON-NLS-1$ + /** + * File not found exception + */ + public static String TmfTraceStub_FileNotFound; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java index c2acb599e9..3b762ed413 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java @@ -20,6 +20,9 @@ import java.util.concurrent.locks.ReentrantLock; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.linuxtools.internal.tmf.core.Activator; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; @@ -90,7 +93,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { public TmfTraceStub(final String path, final int cacheSize, final long interval) throws TmfTraceException { super(null, ITmfEvent.class, path, cacheSize, interval, null, null); try { - fTrace = new RandomAccessFile(path, "r"); + fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -124,7 +127,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException { super(null, ITmfEvent.class, path, cacheSize, 0, null, null); try { - fTrace = new RandomAccessFile(path, "r"); + fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -143,7 +146,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException { super(resource, ITmfEvent.class, path, cacheSize, 0, null, null); try { - fTrace = new RandomAccessFile(path, "r"); + fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -161,7 +164,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws TmfTraceException { super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null); try { - fTrace = new RandomAccessFile(path, "r"); + fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -174,7 +177,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException { super(trace); try { - fTrace = new RandomAccessFile(getPath(), "r"); + fTrace = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -188,7 +191,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { @Override public void initTrace(final IResource resource, final String path, final Class type) throws TmfTraceException { try { - fTrace = new RandomAccessFile(path, "r"); + fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$ } catch (FileNotFoundException e) { throw new TmfTraceException(e.getMessage()); } @@ -371,8 +374,11 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) */ @Override - public boolean validate(IProject project, String path) { - return fileExists(path); + public IStatus validate(IProject project, String path) { + if (fileExists(path)) { + return Status.OK_STATUS; + } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TmfTraceStub_FileNotFound + ": " + path); //$NON-NLS-1$ } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/messages.properties b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/messages.properties new file mode 100644 index 0000000000..2e07804066 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/messages.properties @@ -0,0 +1 @@ +TmfTraceStub_FileNotFound=File does not exist diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index d81825d3a3..c4263d0f41 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -15,8 +15,11 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; +import org.eclipse.linuxtools.internal.tmf.core.Activator; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; @@ -34,27 +37,24 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; */ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { - - //------------------------------------------- - // Constants - //------------------------------------------- + // ------------------------------------------- + // Constants + // ------------------------------------------- /** * Default cache size for CTF traces */ protected static final int DEFAULT_CACHE_SIZE = 50000; - //------------------------------------------- - // Fields - //------------------------------------------- + // ------------------------------------------- + // Fields + // ------------------------------------------- /* Reference to the CTF Trace */ private CTFTrace fTrace; - - - //------------------------------------------- - // TmfTrace Overrides - //------------------------------------------- + // ------------------------------------------- + // TmfTrace Overrides + // ------------------------------------------- /** * Method initTrace. * @@ -88,7 +88,7 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { /* Set the start and (current) end times for this trace */ ctx = (CtfTmfContext) seekEvent(0L); CtfTmfEvent event = getNext(ctx); - if((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { + if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { /* Handle the case where the trace is empty */ this.setStartTime(TmfTimestamp.BIG_BANG); } else { @@ -107,7 +107,9 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#dispose() */ @Override @@ -122,26 +124,34 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { /** * Method validate. - * @param project IProject - * @param path String - * @return boolean + * + * @param project + * IProject + * @param path + * String + * @return IStatus IStatus.error or Status.OK_STATUS * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(IProject, String) + * @since 2.0 */ @Override - public boolean validate(final IProject project, final String path) { + public IStatus validate(final IProject project, final String path) { + IStatus validTrace = Status.OK_STATUS; try { final CTFTrace temp = new CTFTrace(path); boolean valid = temp.majortIsSet(); // random test temp.dispose(); - return valid; + if (!valid) { + validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_MajorNotSet); + } } catch (final CTFReaderException e) { - /* Nope, not a CTF trace we can read */ - return false; + validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + e.toString()); //$NON-NLS-1$ } + return validTrace; } /** * Method getCurrentLocation. This is not applicable in CTF + * * @return null, since the trace has no knowledge of the current location * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation() */ @@ -156,7 +166,7 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { final CtfTmfContext context = new CtfTmfContext(this); context.setLocation(curLocation); context.seek(curLocation.getLocationInfo()); - final CtfLocationInfo currentTime = ((CtfLocationInfo)context.getLocation().getLocationInfo()); + final CtfLocationInfo currentTime = ((CtfLocationInfo) context.getLocation().getLocationInfo()); final long startTime = getIterator(this, context).getStartTime(); final long endTime = getIterator(this, context).getEndTime(); return ((double) currentTime.getTimestamp() - startTime) @@ -165,7 +175,9 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { /** * Method seekEvent. - * @param location ITmfLocation + * + * @param location + * ITmfLocation * @return ITmfContext */ @Override @@ -196,13 +208,12 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { currentLocation = new CtfLocation(event.getTimestamp().getValue(), 0); } } - if(context.getRank() != 0) { + if (context.getRank() != 0) { context.setRank(ITmfContext.UNKNOWN_RANK); } return context; } - @Override public synchronized ITmfContext seekEvent(double ratio) { CtfTmfContext context = new CtfTmfContext(this); @@ -222,7 +233,9 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { /** * Method readNextEvent. - * @param context ITmfContext + * + * @param context + * ITmfContext * @return CtfTmfEvent * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNext(ITmfContext) */ @@ -251,16 +264,16 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { /** * gets the CTFtrace that this is wrapping + * * @return the CTF trace */ public CTFTrace getCTFTrace() { return fTrace; } - - //------------------------------------------- - // Environment Parameters - //------------------------------------------- + // ------------------------------------------- + // Environment Parameters + // ------------------------------------------- /** * Method getNbEnvVars. * @@ -291,24 +304,25 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { return this.fTrace.getEnvironment().get(key); } - //------------------------------------------- - // Clocks - //------------------------------------------- + // ------------------------------------------- + // Clocks + // ------------------------------------------- /** * gets the clock offset + * * @return the clock offset in ns */ - public long getOffset(){ - if( fTrace != null ) { + public long getOffset() { + if (fTrace != null) { return fTrace.getOffset(); } return 0; } - //------------------------------------------- - // Parser - //------------------------------------------- + // ------------------------------------------- + // Parser + // ------------------------------------------- @Override public CtfTmfEvent parseEvent(ITmfContext context) { @@ -327,11 +341,11 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { setCacheSize(DEFAULT_CACHE_SIZE); } - //------------------------------------------- - // Helpers - //------------------------------------------- + // ------------------------------------------- + // Helpers + // ------------------------------------------- - private static CtfIterator getIterator(CtfTmfTrace trace, CtfTmfContext context) { + private static CtfIterator getIterator(CtfTmfTrace trace, CtfTmfContext context) { return CtfIteratorManager.getIterator(trace, context); } @@ -341,7 +355,7 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser { * @return an iterator to the trace * @since 2.0 */ - public CtfIterator createIterator(){ + public CtfIterator createIterator() { return new CtfIterator(this); } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java new file mode 100644 index 0000000000..42d3e05a7d --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.tmf.core.ctfadaptor; + +import org.eclipse.osgi.util.NLS; + +/** + * @author Matthew Khouzam + * @since 2.0 + */ +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.ctfadaptor.messages"; //$NON-NLS-1$ + /** + * And error message + */ + public static String CtfTmfTrace_MajorNotSet; + /** + * Read error + */ + public static String CtfTmfTrace_ReadingError; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties new file mode 100644 index 0000000000..f9626a97a8 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties @@ -0,0 +1,2 @@ +CtfTmfTrace_MajorNotSet=Major version number not set +CtfTmfTrace_ReadingError=Reading error diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java index 7badaff553..131317549f 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java @@ -18,6 +18,7 @@ import java.util.Map; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; @@ -149,8 +150,9 @@ public interface ITmfTrace extends ITmfDataProvider { * @param path the trace path * * @return true if trace is valid + * @since 2.0 */ - public boolean validate(IProject project, String path); + public IStatus validate(IProject project, String path); // ------------------------------------------------------------------------ // Basic getters diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java index 0b0bebf039..0b51145884 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java @@ -18,6 +18,8 @@ package org.eclipse.linuxtools.tmf.core.trace; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext; import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation; import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray; @@ -182,9 +184,12 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser { /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) */ + /** + * @since 2.0 + */ @Override - public boolean validate(final IProject project, final String path) { - return true; + public IStatus validate(final IProject project, final String path) { + return Status.OK_STATUS; } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java index 5cdd17fa89..39bf5c3703 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -22,6 +22,8 @@ import java.util.regex.Matcher; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; @@ -390,7 +392,10 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser { * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) */ @Override - public boolean validate(IProject project, String path) { - return fileExists(path); + public IStatus validate(IProject project, String path) { + if( fileExists(path)) { + return Status.OK_STATUS; + } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID ,Messages.CustomTrace_FileNotFound + ": " + path); //$NON-NLS-1$ } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java index a69c0a4246..aa6b63b388 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -19,7 +19,8 @@ import java.io.RandomAccessFile; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; - +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.internal.tmf.ui.Activator; @@ -493,7 +494,10 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEventParser { * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) */ @Override - public boolean validate(IProject project, String path) { - return fileExists(path); + public IStatus validate(IProject project, String path) { + if (fileExists(path)) { + return Status.OK_STATUS; + } + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CustomTrace_FileNotFound + ": " + path); //$NON-NLS-1$ } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/Messages.java new file mode 100644 index 0000000000..c462f42559 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/Messages.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom; + +import org.eclipse.osgi.util.NLS; + +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.messages"; //$NON-NLS-1$ + public static String CustomTrace_FileNotFound; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/messages.properties new file mode 100644 index 0000000000..11172196fb --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/messages.properties @@ -0,0 +1 @@ +CustomTrace_FileNotFound=File not found diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java index 28d4c1e22c..5f9ac1c414 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java @@ -42,7 +42,13 @@ public class Messages extends NLS { public static String DeleteExperimentHandler_Message; public static String DeleteExperimentHandler_Error; + public static String SelectTraceTypeHandler_ErrorSelectingTrace; + public static String SelectTraceTypeHandler_Title; + + public static String SelectTraceTypeHandler_TraceFailedValidation; + + public static String SelectTraceTypeHandler_TracesFailedValidation; public static String SelectTraceTypeHandler_InvalidTraceType; public static String DropAdapterAssistant_RenameTraceTitle; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java index e434c081be..473016d18c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java @@ -13,7 +13,9 @@ package org.eclipse.linuxtools.internal.tmf.ui.project.handlers; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -21,6 +23,10 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.TreeSelection; @@ -31,8 +37,7 @@ import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; @@ -112,7 +117,7 @@ public class SelectTraceTypeHandler extends AbstractHandler { if (window == null) { return null; } - + List statuses = new ArrayList(); boolean ok = true; for (Object element : fSelection.toList()) { TmfTraceElement trace = (TmfTraceElement) element; @@ -124,25 +129,34 @@ public class SelectTraceTypeHandler extends AbstractHandler { String bundleName = event.getParameter(BUNDLE_PARAMETER); String traceType = event.getParameter(TYPE_PARAMETER); String iconUrl = event.getParameter(ICON_PARAMETER); - ok &= propagateProperties(trace, bundleName, traceType, iconUrl); + IStatus status = propagateProperties(trace, bundleName, traceType, iconUrl); + ok &= status.isOK(); + if (!status.isOK()) { + statuses.add(status); + } } catch (CoreException e) { - Activator.getDefault().logError("Error selecting trace type for trace" + trace.getName(), e); //$NON-NLS-1$ + Activator.getDefault().logError(Messages.SelectTraceTypeHandler_ErrorSelectingTrace + trace.getName(), e); } } } ((ITmfProjectModelElement) fSelection.getFirstElement()).getProject().refresh(); if (!ok) { - MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_ERROR); - mb.setText(Messages.SelectTraceTypeHandler_Title); - mb.setMessage(Messages.SelectTraceTypeHandler_InvalidTraceType); - mb.open(); + final Shell shell = window.getShell(); + MultiStatus info = new MultiStatus(Activator.PLUGIN_ID, 1, Messages.SelectTraceTypeHandler_TraceFailedValidation, null); + if (statuses.size() > 1) + { + info = new MultiStatus(Activator.PLUGIN_ID, 1, Messages.SelectTraceTypeHandler_TracesFailedValidation, null); + } + for (IStatus status : statuses) { + info.add(status); + } + ErrorDialog.openError(shell, Messages.SelectTraceTypeHandler_Title, Messages.SelectTraceTypeHandler_InvalidTraceType, info); } - return null; } - private static boolean propagateProperties(TmfTraceElement trace, + private static IStatus propagateProperties(TmfTraceElement trace, String bundleName, String traceType, String iconUrl) throws CoreException { @@ -153,10 +167,11 @@ public class SelectTraceTypeHandler extends AbstractHandler { setProperties(trace.getResource(), bundleName, traceType, iconUrl); trace.refreshTraceType(); - if (!validateTraceType(trace)) { + final IStatus validateTraceType = validateTraceType(trace); + if (!validateTraceType.isOK()) { setProperties(trace.getResource(), svBundleName, svTraceType, svIconUrl); trace.refreshTraceType(); - return false; + return validateTraceType; } trace.refreshTraceType(); @@ -177,7 +192,7 @@ public class SelectTraceTypeHandler extends AbstractHandler { } } - return true; + return Status.OK_STATUS; } private static void setProperties(IResource resource, String bundleName, @@ -187,17 +202,27 @@ public class SelectTraceTypeHandler extends AbstractHandler { resource.setPersistentProperty(TmfCommonConstants.TRACEICON, iconUrl); } - private static boolean validateTraceType(TmfTraceElement trace) { + private static IStatus validateTraceType(TmfTraceElement trace) { IProject project = trace.getProject().getResource(); ITmfTrace tmfTrace = null; + IStatus validate = null; try { tmfTrace = trace.instantiateTrace(); - return (tmfTrace != null && tmfTrace.validate(project, trace.getLocation().getPath())); + if (tmfTrace != null) { + validate = tmfTrace.validate(project, trace.getLocation().getPath()); + } + else{ + validate = new Status(IStatus.ERROR, trace.getName(), "File does not exist : " + trace.getLocation().getPath()); //$NON-NLS-1$ + } } finally { if (tmfTrace != null) { tmfTrace.dispose(); } } + if (validate == null) { + validate = new Status(IStatus.ERROR, "unknown", "unknown"); //$NON-NLS-1$ //$NON-NLS-2$ + } + return validate; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties index 26ec1bfaa9..1b7c8eed0e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties @@ -18,7 +18,10 @@ DeleteExperimentHandler_Message = Are you sure you want to delete this experimen DeleteExperimentHandler_Error = Error deleting experiment # Set Trace Type +SelectTraceTypeHandler_ErrorSelectingTrace=Error selecting trace type for trace SelectTraceTypeHandler_Title = Validation Error +SelectTraceTypeHandler_TraceFailedValidation=A trace has failed validation +SelectTraceTypeHandler_TracesFailedValidation=Several trace files failed validation SelectTraceTypeHandler_InvalidTraceType = Type could not be set for one or more traces # Drag and drop diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java index 697417aedc..91b720a42c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java @@ -90,11 +90,12 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation; * A variant of the standard resource import wizard with the following changes: *

    *
  • A folder/file combined checkbox tree viewer to select traces - *
  • Cherry-picking of traces in the file structure without re-creating the file hierarchy + *
  • Cherry-picking of traces in the file structure without re-creating the + * file hierarchy *
  • A trace types dropbox for optional characterization *
- * For our purpose, a trace can either be a single file or a whole directory sub-tree, whichever is reached first from - * the root directory. + * For our purpose, a trace can either be a single file or a whole directory + * sub-tree, whichever is reached first from the root directory. *

* * @version 1.0 @@ -132,11 +133,12 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { // ------------------------------------------------------------------------ /** - * Constructor. - * Creates the trace wizard page. + * Constructor. Creates the trace wizard page. * - * @param name The name of the page. - * @param selection The current selection + * @param name + * The name of the page. + * @param selection + * The current selection */ protected ImportTraceWizardPage(String name, IStructuredSelection selection) { super(name, selection); @@ -144,8 +146,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /** * Constructor - * @param workbench The workbench reference. - * @param selection The current selection + * + * @param workbench + * The workbench reference. + * @param selection + * The current selection */ public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) { this(IMPORT_WIZARD_PAGE, selection); @@ -183,7 +188,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { // ------------------------------------------------------------------------ /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createControl(org.eclipse.swt.widgets.Composite) + * + * @see + * org.eclipse.ui.dialogs.WizardResourceImportPage#createControl(org.eclipse + * .swt.widgets.Composite) */ @Override public void createControl(Composite parent) { @@ -197,7 +205,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createSourceGroup(org.eclipse.swt.widgets.Composite) + * + * @see + * org.eclipse.ui.dialogs.WizardResourceImportPage#createSourceGroup(org + * .eclipse.swt.widgets.Composite) */ @Override protected void createSourceGroup(Composite parent) { @@ -209,7 +220,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createFileSelectionGroup(org.eclipse.swt.widgets.Composite) + * + * @see + * org.eclipse.ui.dialogs.WizardResourceImportPage#createFileSelectionGroup + * (org.eclipse.swt.widgets.Composite) */ @Override protected void createFileSelectionGroup(Composite parent) { @@ -256,6 +270,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) + * * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFolderProvider() */ @Override @@ -265,6 +280,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) + * * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFileProvider() */ @Override @@ -314,7 +330,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources() + * + * @see + * org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources() */ @Override protected List getSelectedResources() { @@ -344,7 +362,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /** * creates the directory selection group. - * @param parent the parent composite + * + * @param parent + * the parent composite */ protected void createDirectorySelectionGroup(Composite parent) { @@ -421,7 +441,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardResourceImportPage#handleEvent(org.eclipse.swt.widgets.Event) + * + * @see + * org.eclipse.ui.dialogs.WizardResourceImportPage#handleEvent(org.eclipse + * .swt.widgets.Event) */ @Override public void handleEvent(Event event) { @@ -598,7 +621,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { }); } - // The mapping of available trace type IDs to their corresponding configuration element + // The mapping of available trace type IDs to their corresponding + // configuration element private final Map fTraceTypeAttributes = new HashMap(); private final Map fTraceCategories = new HashMap(); private final Map fTraceAttributes = new HashMap(); @@ -662,7 +686,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) - * @see org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroupButtons(org.eclipse.swt.widgets.Group) + * + * @see + * org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroupButtons + * (org.eclipse.swt.widgets.Group) */ @Override protected void createOptionsGroupButtons(Group optionsGroup) { @@ -695,6 +722,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /* * (non-Javadoc) + * * @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateSourceGroup() */ @Override @@ -736,19 +764,23 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { // Perform trace validation String traceTypeName = fTraceTypes.getText(); if (traceTypeName != null && !"".equals(traceTypeName) && //$NON-NLS-1$ - !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) { + !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) { List traces = isolateTraces(); for (File trace : traces) { ITmfTrace tmfTrace = null; + try { IConfigurationElement ce = fTraceAttributes.get(traceTypeName); tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); - if (tmfTrace != null && !tmfTrace.validate(fProject, trace.getAbsolutePath())) { - setMessage(null); - setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed); - tmfTrace.dispose(); - return false; + if (tmfTrace != null) { + IStatus status = tmfTrace.validate(fProject, trace.getAbsolutePath()); + if (!status.isOK()) { + setMessage(null); + setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed); + tmfTrace.dispose(); + return false; + } } } catch (CoreException e) { } finally { @@ -801,6 +833,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { /** * Finish the import. + * * @return true if successful else false */ public boolean finish() { @@ -825,7 +858,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { List selectedResources = getSelectedResources(); Iterator resources = selectedResources.iterator(); - // Use a map to end up with unique resources (getSelectedResources() can return duplicates) + // Use a map to end up with unique resources (getSelectedResources() can + // return duplicates) Map fileSystemObjects = new HashMap(); while (resources.hasNext()) { File file = (File) resources.next().getFileSystemObject(); @@ -934,8 +968,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage { } }); - // Perform a distinct import operation for everything that has the same prefix - // (distinct prefixes correspond to traces - we don't want to re-create parent structures) + // Perform a distinct import operation for everything that has the same + // prefix + // (distinct prefixes correspond to traces - we don't want to re-create + // parent structures) boolean ok = true; boolean isLinked = createLinksInWorkspaceButton.getSelection(); for (int i = 0; i < fileList.size(); i++) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java index 0d31ea439c..e3cd26dfe5 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2011, 2012 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Francois Chouinard - Initial API and implementation *******************************************************************************/ @@ -16,11 +16,12 @@ import org.eclipse.osgi.util.NLS; /** * Message strings for TMF model handling. - * + * * @version 1.0 * @author Francois Chouinard * */ +@SuppressWarnings("javadoc") public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.project.wizards.messages"; //$NON-NLS-1$ @@ -74,7 +75,7 @@ public class Messages extends NLS { */ public static String ImportTraceWizard_InvalidTraceDirectory; /** - * The error message when a trace validation failed (import trace wizard). + * The error message when a trace validation failed (import trace wizard). */ public static String ImportTraceWizard_TraceValidationFailed; /** diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java index 202aa36e92..908c593407 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java @@ -21,6 +21,7 @@ import org.eclipse.osgi.util.NLS; * @since 2.0 * @version 2.0 */ +@SuppressWarnings("javadoc") public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.viewers.statistics.messages"; //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java index 2a50be4554..a784cdd5bd 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java @@ -21,6 +21,7 @@ import org.eclipse.osgi.util.NLS; * @author Mathieu Denis * @since 2.0 */ +@SuppressWarnings("javadoc") public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.messages"; //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Messages.java index 7660923baf..6f29dd7426 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Messages.java @@ -22,6 +22,7 @@ import org.eclipse.osgi.util.NLS; * @version 1.0 * @author Francois Chouinard */ +@SuppressWarnings("javadoc") public class Messages extends NLS { // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java index da24ea62b9..1aa819a0d2 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java @@ -21,6 +21,7 @@ import org.eclipse.osgi.util.NLS; * @author Mathieu Denis * @since 2.0 */ +@SuppressWarnings("javadoc") public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.statistics.messages"; //$NON-NLS-1$ -- 2.34.1