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 <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/11788
* 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.
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$
+ }
}
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;
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);
}
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 */
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();
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;
* @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<CommonTree> 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;
package org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions;
+
/**
* <b><u>ParseException</u></b>
*/
private static final long serialVersionUID = 7901917601459652080L;
/**
- * Enoty constructor
+ * Empty constructor
*/
public ParseException() {
super();
super(message);
}
+ /**
+ * Copy constructor
+ * @param e the exception to throw
+ */
+ public ParseException(Exception e) {
+ super(e);
+ }
}
--- /dev/null
+/*******************************************************************************
+ * 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.
+ * <p>
+ * 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));
+ }
+
+}
* 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;
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;
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".
* <p>
+ *
* @author Marc Dumais
* @author Francois Chouinard
+ * @author Matthew Khouzam
*/
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
/**
* @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;
}
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;
/**
* Select a frame and update the visualization
- * @param rank the rank
+ *
+ * @param rank
+ * the rank
*/
public void selectFrame(long rank) {
fGdbTpRef.selectDataFrame(rank, true);
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
--- /dev/null
+GdbTrace_FileNotFound=File not found
*
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
+ * Matthew Khouzam - Improved validation
******************************************************************************/
package org.eclipse.linuxtools.lttng2.kernel.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.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;
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".
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
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
--- /dev/null
+CtfKernelTrace_DomainError=Domain mismatch, make sure the environment is 'kernel'
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;
/**
* 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());
}
}
// 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);
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
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;
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());
}
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());
}
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());
}
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());
}
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());
}
@Override
public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> 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());
}
* @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$
}
}
--- /dev/null
+TmfTraceStub_FileNotFound=File does not exist
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;
*/
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.
*
/* 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 {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#dispose()
*/
@Override
/**
* 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()
*/
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)
/**
* Method seekEvent.
- * @param location ITmfLocation<?>
+ *
+ * @param location
+ * ITmfLocation<?>
* @return ITmfContext
*/
@Override
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);
/**
* Method readNextEvent.
- * @param context ITmfContext
+ *
+ * @param context
+ * ITmfContext
* @return CtfTmfEvent
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNext(ITmfContext)
*/
/**
* gets the CTFtrace that this is wrapping
+ *
* @return the CTF trace
*/
public CTFTrace getCTFTrace() {
return fTrace;
}
-
- //-------------------------------------------
- // Environment Parameters
- //-------------------------------------------
+ // -------------------------------------------
+ // Environment Parameters
+ // -------------------------------------------
/**
* Method getNbEnvVars.
*
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) {
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);
}
* @return an iterator to the trace
* @since 2.0
*/
- public CtfIterator createIterator(){
+ public CtfIterator createIterator() {
return new CtfIterator(this);
}
}
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
--- /dev/null
+CtfTmfTrace_MajorNotSet=Major version number not set
+CtfTmfTrace_ReadingError=Reading error
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;
* @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
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;
/* (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;
}
// ------------------------------------------------------------------------
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;
* @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$
}
}
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;
* @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$
}
}
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
--- /dev/null
+CustomTrace_FileNotFound=File not found
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;
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;
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;
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;
if (window == null) {
return null;
}
-
+ List<IStatus> statuses = new ArrayList<IStatus>();
boolean ok = true;
for (Object element : fSelection.toList()) {
TmfTraceElement trace = (TmfTraceElement) element;
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 {
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();
}
}
- return true;
+ return Status.OK_STATUS;
}
private static void setProperties(IResource resource, String bundleName,
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;
}
}
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
* A variant of the standard resource import wizard with the following changes:
* <ul>
* <li>A folder/file combined checkbox tree viewer to select traces
- * <li>Cherry-picking of traces in the file structure without re-creating the file hierarchy
+ * <li>Cherry-picking of traces in the file structure without re-creating the
+ * file hierarchy
* <li>A trace types dropbox for optional characterization
* </ul>
- * 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.
* <p>
*
* @version 1.0
// ------------------------------------------------------------------------
/**
- * 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);
/**
* 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);
// ------------------------------------------------------------------------
/*
* (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) {
/*
* (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) {
/*
* (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) {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFolderProvider()
*/
@Override
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFileProvider()
*/
@Override
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources()
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources()
*/
@Override
protected List<FileSystemElement> getSelectedResources() {
/**
* creates the directory selection group.
- * @param parent the parent composite
+ *
+ * @param parent
+ * the parent composite
*/
protected void createDirectorySelectionGroup(Composite parent) {
/*
* (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) {
});
}
- // 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<String, IConfigurationElement> fTraceTypeAttributes = new HashMap<String, IConfigurationElement>();
private final Map<String, IConfigurationElement> fTraceCategories = new HashMap<String, IConfigurationElement>();
private final Map<String, IConfigurationElement> fTraceAttributes = new HashMap<String, IConfigurationElement>();
/*
* (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) {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateSourceGroup()
*/
@Override
// 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<File> 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 {
/**
* Finish the import.
+ *
* @return <code>true</code> if successful else false
*/
public boolean finish() {
List<FileSystemElement> selectedResources = getSelectedResources();
Iterator<FileSystemElement> 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<String, File> fileSystemObjects = new HashMap<String, File>();
while (resources.hasNext()) {
File file = (File) resources.next().getFileSystemObject();
}
});
- // 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++) {
/*******************************************************************************
* 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
*******************************************************************************/
/**
* 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$
*/
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;
/**
* @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$
* @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$
* @version 1.0
* @author Francois Chouinard
*/
+@SuppressWarnings("javadoc")
public class Messages extends 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$