Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-11-18 20:23:49 -0500
committerMarc-Andre Laperle2013-12-09 15:10:10 -0500
commit09788592d6c8c8d035fc0470f471dc4ed3f64db9 (patch)
treec30a81c2fd996d42b283af4970774454060aa1e0
parent1bf44920f3697717aabb76b9ae85971ef7da4404 (diff)
downloadorg.eclipse.linuxtools-09788592d6c8c8d035fc0470f471dc4ed3f64db9.tar.gz
org.eclipse.linuxtools-09788592d6c8c8d035fc0470f471dc4ed3f64db9.tar.xz
org.eclipse.linuxtools-09788592d6c8c8d035fc0470f471dc4ed3f64db9.zip
tmf: Import trace package without manifest
Change-Id: I4e97dcc25734b6a5a91ffb35bfa38a94246b4b85 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/18591 Reviewed-on: https://git.eclipse.org/r/19533
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/Messages.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java22
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java32
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java56
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java3
6 files changed, 92 insertions, 27 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/Messages.java
index 051423a5dd..f8a6f0bf4e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/Messages.java
@@ -188,6 +188,11 @@ public class Messages extends NLS {
public static String TracePackageImportOperation_ErrorCreatingBookmark;
/**
+ * Text for the detecting trace type job
+ */
+ public static String TracePackageImportOperation_DetectingTraceType;
+
+ /**
* Text when error occurs creating a bookmark file
*/
public static String TracePackageImportOperation_ErrorCreatingBookmarkFile;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
index f9168ae212..23f053e789 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
@@ -31,6 +31,7 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -195,9 +196,13 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
ModalContext.checkCanceled(monitor);
IResource res = supplFile.getResource();
res.refreshLocal(0, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- createExportResource(traceSuppFilesFolder, res);
+ IResource link = createExportResource(traceSuppFilesFolder, res);
Element suppFileElement = doc.createElement(ITracePackageConstants.SUPPLEMENTARY_FILE_ELEMENT);
- suppFileElement.setAttribute(ITracePackageConstants.SUPPLEMENTARY_FILE_NAME_ATTRIB, res.getName());
+
+ // project/.traceExport/.tracing/kernel/statistics.ht -> .tracing/kernel/statistics.ht
+ IPath archiveRelativePath = link.getFullPath().makeRelativeTo(fExportFolder.getFullPath());
+
+ suppFileElement.setAttribute(ITracePackageConstants.SUPPLEMENTARY_FILE_NAME_ATTRIB, archiveRelativePath.toString());
traceNode.appendChild(suppFileElement);
}
@@ -213,9 +218,11 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
folder.create(IResource.FORCE, true, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
- createExportResource(folder, resource);
+ IResource link = createExportResource(folder, resource);
Element fileElement = doc.createElement(ITracePackageConstants.TRACE_FILE_ELEMENT);
- fileElement.setAttribute(ITracePackageConstants.TRACE_FILE_NAME_ATTRIB, resource.getName());
+ // project/.traceExport/Traces/kernel -> Traces/kernel
+ IPath archiveRelativePath = link.getFullPath().makeRelativeTo(fExportFolder.getFullPath());
+ fileElement.setAttribute(ITracePackageConstants.TRACE_FILE_NAME_ATTRIB, archiveRelativePath.toString());
traceNode.appendChild(fileElement);
fResources.add(folder);
}
@@ -226,16 +233,21 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
* @param exportFolder the folder that will contain the linked resource
* @param res the resource to export
* @throws CoreException when createLink fails
+ * @return the created linked resource
*/
- private static void createExportResource(IFolder exportFolder, IResource res) throws CoreException {
+ private static IResource createExportResource(IFolder exportFolder, IResource res) throws CoreException {
+ IResource ret = null;
// Note: The resources cannot be HIDDEN or else they are ignored by ArchiveFileExportOperation
if (res instanceof IFolder) {
IFolder folder = exportFolder.getFolder(res.getName());
folder.createLink(res.getLocationURI(), IResource.NONE, null);
+ ret = folder;
} else if (res instanceof IFile) {
IFile file = exportFolder.getFile(res.getName());
file.createLink(res.getLocationURI(), IResource.NONE, null);
+ ret = file;
}
+ return ret;
}
private static void exportBookmarks(IProgressMonitor monitor, Node traceNode, TracePackageBookmarkElement element) throws CoreException, InterruptedException {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
index 1d67e1dc0e..d4648cef3e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
@@ -19,8 +19,10 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -125,7 +127,12 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
setStatus(Status.OK_STATUS);
}
else {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.TracePackageExtractManifestOperation_ErrorManifestNotFound, ITracePackageConstants.MANIFEST_FILENAME)));
+ elements = generateElementsFromArchive();
+ if (elements.length > 0) {
+ setStatus(Status.OK_STATUS);
+ } else {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.TracePackageExtractManifestOperation_ErrorManifestNotFound, ITracePackageConstants.MANIFEST_FILENAME)));
+ }
}
fResultElements = elements;
@@ -137,6 +144,29 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
}
}
+ private TracePackageElement[] generateElementsFromArchive() {
+ ArchiveFile archiveFile = getSpecifiedArchiveFile();
+ Enumeration<?> entries = archiveFile.entries();
+ Set<String> traceFileNames = new HashSet<String>();
+ while (entries.hasMoreElements()) {
+ ArchiveEntry entry = (ArchiveEntry) entries.nextElement();
+ String entryName = entry.getName();
+ IPath fullArchivePath = new Path(entryName);
+ if (!fullArchivePath.hasTrailingSeparator() && fullArchivePath.segmentCount() > 0) {
+ traceFileNames.add(fullArchivePath.segment(0));
+ }
+ }
+
+ List<TracePackageElement> packageElements = new ArrayList<TracePackageElement>();
+ for (String traceFileName : traceFileNames) {
+ TracePackageTraceElement traceElement = new TracePackageTraceElement(null, traceFileName, null);
+ traceElement.setChildren(new TracePackageElement[] { new TracePackageFilesElement(traceElement, traceFileName) });
+ packageElements.add(traceElement);
+ }
+
+ return packageElements.toArray(new TracePackageElement[] {});
+ }
+
/**
* Get the resulting element from extracting the manifest from the archive
*
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
index 871b7a3cc9..ec3710b641 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.ModalContext;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfTraceImportException;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.AbstractTracePackageOperation;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
@@ -40,7 +41,6 @@ import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePack
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFileElement;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFilesElement;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement;
-import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
@@ -209,16 +209,29 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
return;
}
- TraceTypeHelper traceType = TmfTraceType.getInstance().getTraceType(traceElement.getTraceType());
- if (traceType == null) {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName)));
- return;
+ TraceTypeHelper traceType = null;
+ String traceTypeStr = traceElement.getTraceType();
+ if (traceTypeStr != null) {
+ traceType = TmfTraceType.getInstance().getTraceType(traceTypeStr);
+ if (traceType == null) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName)));
+ return;
+ }
+ } else {
+ try {
+ progressMonitor.subTask(MessageFormat.format(Messages.TracePackageImportOperation_DetectingTraceType, traceName));
+ traceType = TmfTraceType.getInstance().selectTraceType(traceRes.getLocation().toOSString(), null, null);
+ } catch (TmfTraceImportException e) {
+ // Could not figure out the type
+ }
}
- try {
- TmfTraceType.setTraceType(traceRes.getFullPath(), traceType);
- } catch (CoreException e) {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName), e));
+ if (traceType != null) {
+ try {
+ TmfTraceType.setTraceType(traceRes.getFullPath(), traceType);
+ } catch (CoreException e) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName), e));
+ }
}
importBookmarks(traceRes, traceElement, progressMonitor);
@@ -330,10 +343,9 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
private IStatus importTraceFiles(TracePackageFilesElement traceFilesElement, IProgressMonitor monitor) {
List<String> fileNames = new ArrayList<String>();
- IPath prefix = new Path(TmfTraceFolder.TRACE_FOLDER_NAME);
fileNames.add(traceFilesElement.getFileName());
IPath containerPath = fTmfTraceFolder.getPath();
- IStatus status = importFiles(getSpecifiedArchiveFile(), fileNames, prefix, containerPath, monitor);
+ IStatus status = importFiles(getSpecifiedArchiveFile(), fileNames, containerPath, monitor);
if (status.isOK()) {
new TmfNavigatorContentProvider().getChildren(fTmfTraceFolder);
}
@@ -363,16 +375,14 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
String traceName = tmfTraceElement.getResource().getName();
// Project/.tracing/tracename
IPath destinationContainerPath = tmfTraceElement.getTraceSupplementaryFolder(traceName).getFullPath();
- // .tracing/tracename
- IPath pathInArchive = new Path(TmfCommonConstants.TRACE_SUPPLEMENATARY_FOLDER_NAME).append(traceName);
- return importFiles(archiveFile, fileNames, pathInArchive, destinationContainerPath, monitor);
+ return importFiles(archiveFile, fileNames, destinationContainerPath, monitor);
}
}
return Status.OK_STATUS;
}
- private IStatus importFiles(ArchiveFile archiveFile, List<String> fileNames, IPath pathInArchive, IPath destinationContainerPath, IProgressMonitor monitor) {
+ private IStatus importFiles(ArchiveFile archiveFile, List<String> fileNames, IPath destinationContainerPath, IProgressMonitor monitor) {
List<ArchiveProviderElement> objects = new ArrayList<ArchiveProviderElement>();
Enumeration<?> entries = archiveFile.entries();
while (entries.hasMoreElements()) {
@@ -385,13 +395,19 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
}
for (String fileName : fileNames) {
+
+ // Examples: Traces/kernel/ .tracing/testtexttrace.txt/statistics.ht
+ IPath searchedArchivePath = new Path(fileName);
+
// Check if this archive entry matches the searched file name at this archive location
- IPath searchedArchivePath = pathInArchive.append(fileName);
if (fileNameMatches(searchedArchivePath.toString(), entryName)) {
- // Traces/kernel/metadata
- // kernel/metadata, the ImportOperation will take care of creating the kernel folder
- IPath destinationPath = fullArchivePath.removeFirstSegments(pathInArchive.segmentCount());
- // metadata
+ // Traces/ .tracing/testtexttrace.txt/
+ IPath searchedArchivePathContainer = searchedArchivePath.removeLastSegments(1);
+
+ // Traces/kernel/metadata -> kernel/metadata .tracing/testtexttrace.txt/statistics.ht -> statistics.ht
+ // Note: The ImportOperation will take care of creating the kernel folder
+ IPath destinationPath = fullArchivePath.makeRelativeTo(searchedArchivePathContainer);
+ // metadata statistics.ht
String resourceLabel = fullArchivePath.lastSegment();
ArchiveProviderElement pe = new ArchiveProviderElement(destinationPath.toString(), resourceLabel, archiveFile, entry);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
index 09d6b18e72..a5fc3ed167 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
@@ -50,3 +50,4 @@ TracePackageExtractManifestOperation_SchemaFileNotFound=The schema file {0} coul
TracePackageImportOperation_ErrorCreatingBookmark=Error creating bookmark for the trace {0}
TracePackageImportOperation_ErrorCreatingBookmarkFile=Error creating bookmark file for the trace {0}
TracePackageImportOperation_ImportingPackage=Importing package
+TracePackageImportOperation_DetectingTraceType=Detecting trace type for ''{0}''
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java
index c3dfb185d4..09fb06ea99 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java
@@ -634,8 +634,9 @@ public final class TmfTraceType {
* @throws TmfTraceImportException
* if the traces don't match or there are errors in the trace
* file
+ * @since 2.2
*/
- TraceTypeHelper selectTraceType(String path, Shell shell, String traceTypeHint) throws TmfTraceImportException {
+ public TraceTypeHelper selectTraceType(String path, Shell shell, String traceTypeHint) throws TmfTraceImportException {
List<TraceTypeHelper> validCandidates = new ArrayList<TraceTypeHelper>();
getCustomTraceTypes();
final Set<String> traceTypes = fTraceTypes.keySet();

Back to the top