use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement in project tracecompass by tracecompass.
the class ImportTracePackageWizardPage method finish.
/**
* Finish the wizard page
*
* @return true on success
*/
public boolean finish() {
if (!checkForConflict()) {
return false;
}
saveWidgetValues();
Object input = getElementViewer().getInput();
TracePackageElement[] traceElements = (TracePackageElement[]) input;
final TracePackageImportOperation importOperation = new TracePackageImportOperation(fValidatedFilePath, traceElements, fTmfTraceFolder);
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
importOperation.run(monitor);
}
});
IStatus status = importOperation.getStatus();
if (status.getSeverity() == IStatus.ERROR) {
handleErrorStatus(status);
}
} catch (InvocationTargetException e) {
handleError(Messages.ImportTracePackageWizardPage_ErrorOperation, e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return importOperation.getStatus().getSeverity() == IStatus.OK;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement in project tracecompass by tracecompass.
the class ImportTracePackageWizardPage method createElementViewerInput.
@Override
protected Object createElementViewerInput() {
final AbstractTracePackageOperation op = createExtractManifestOperation(getFilePathValue());
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.ImportTracePackageWizardPage_ReadingPackage, 10);
op.run(monitor);
monitor.done();
}
});
IStatus status = op.getStatus();
if (status.getSeverity() == IStatus.ERROR) {
handleErrorStatus(status);
}
} catch (InvocationTargetException e1) {
handleError(Messages.TracePackageExtractManifestOperation_ErrorReadingManifest, e1);
} catch (InterruptedException e1) {
// Canceled
}
TracePackageElement[] resultElements = op.getResultElements();
if (resultElements == null || resultElements.length == 0) {
return null;
}
return resultElements;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement in project tracecompass by tracecompass.
the class ImportTracePackageWizardPage method checkForConflict.
private boolean checkForConflict() {
TracePackageElement[] packageElements = (TracePackageElement[]) getElementViewer().getInput();
List<TracePackageExperimentElement> experimentElements = new ArrayList<>();
List<TracePackageTraceElement> traceElements = new ArrayList<>();
Map<TracePackageExperimentElement, List<TracePackageTraceElement>> experimentTracesMap = new HashMap<>();
// List of experiment to rename
List<TracePackageExperimentElement> experimentToRename = new ArrayList<>();
// Conflict traces that are not in an experiment
List<TracePackageTraceElement> unhandledTraces = new ArrayList<>();
// Process package element to separate experiments and traces
for (TracePackageElement packageElement : packageElements) {
TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
if (AbstractTracePackageOperation.isFilesChecked(traceElement)) {
if (traceElement instanceof TracePackageExperimentElement) {
TracePackageExperimentElement experimentElement = (TracePackageExperimentElement) traceElement;
experimentElements.add(experimentElement);
if (experimentExists(experimentElement)) {
experimentToRename.add(experimentElement);
}
} else {
traceElements.add(traceElement);
}
}
}
for (TracePackageTraceElement traceElement : traceElements) {
processTrace(experimentElements, traceElement, experimentTracesMap, unhandledTraces);
}
boolean result = true;
if (!experimentTracesMap.isEmpty() || !experimentToRename.isEmpty()) {
result &= handleExperimentConflict(experimentTracesMap, experimentToRename);
}
if (!unhandledTraces.isEmpty()) {
result &= handleTracesConflict(unhandledTraces);
}
return result;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement in project tracecompass by tracecompass.
the class ManifestReader method loadTracesFomNodeList.
private static void loadTracesFomNodeList(List<TracePackageElement> packageElements, NodeList traceElements) {
for (int i = 0; i < traceElements.getLength(); i++) {
Node traceNode = traceElements.item(i);
if (traceNode.getNodeType() == Node.ELEMENT_NODE) {
Element traceElement = (Element) traceNode;
String traceName = traceElement.getAttribute(ITracePackageConstants.TRACE_NAME_ATTRIB);
String traceType = traceElement.getAttribute(ITracePackageConstants.TRACE_TYPE_ATTRIB);
TracePackageElement element;
if (traceNode.getNodeName().equals(ITracePackageConstants.EXPERIMENT_ELEMENT)) {
element = new TracePackageExperimentElement(null, traceName, traceType);
// $NON-NLS-1$
new TracePackageFilesElement(element, "");
NodeList expTraces = traceElement.getElementsByTagName(ITracePackageConstants.EXP_TRACE_ELEMENT);
for (int j = 0; j < expTraces.getLength(); j++) {
Node expTraceNode = expTraces.item(j);
if (expTraceNode.getNodeType() == Node.ELEMENT_NODE) {
Element expTraceElement = (Element) expTraceNode;
String expTrace = expTraceElement.getAttribute(ITracePackageConstants.TRACE_NAME_ATTRIB);
((TracePackageExperimentElement) element).addExpTrace(expTrace);
}
}
} else {
element = new TracePackageTraceElement(null, traceName, traceType);
NodeList fileElements = traceElement.getElementsByTagName(ITracePackageConstants.TRACE_FILE_ELEMENT);
for (int j = 0; j < fileElements.getLength(); j++) {
Node fileNode = fileElements.item(j);
if (fileNode.getNodeType() == Node.ELEMENT_NODE) {
Element fileElement = (Element) fileNode;
String fileName = fileElement.getAttribute(ITracePackageConstants.TRACE_FILE_NAME_ATTRIB);
new TracePackageFilesElement(element, fileName);
}
}
}
// Supplementary files
NodeList suppFilesElements = traceElement.getElementsByTagName(ITracePackageConstants.SUPPLEMENTARY_FILE_ELEMENT);
if (suppFilesElements.getLength() > 0) {
TracePackageSupplFilesElement supplFilesElement = new TracePackageSupplFilesElement(element);
for (int j = 0; j < suppFilesElements.getLength(); j++) {
Node suppFileNode = suppFilesElements.item(j);
if (suppFileNode.getNodeType() == Node.ELEMENT_NODE) {
Element suppFileElement = (Element) suppFileNode;
String fileName = suppFileElement.getAttribute(ITracePackageConstants.SUPPLEMENTARY_FILE_NAME_ATTRIB);
new TracePackageSupplFileElement(fileName, supplFilesElement);
}
}
}
// bookmarks
List<Map<String, String>> bookmarkAttribs = new ArrayList<>();
NodeList bookmarksElements = traceElement.getElementsByTagName(ITracePackageConstants.BOOKMARKS_ELEMENT);
for (int j = 0; j < bookmarksElements.getLength(); j++) {
Node bookmarksNode = bookmarksElements.item(j);
if (bookmarksNode.getNodeType() == Node.ELEMENT_NODE) {
NodeList bookmarkElements = traceElement.getElementsByTagName(ITracePackageConstants.BOOKMARK_ELEMENT);
for (int k = 0; k < bookmarkElements.getLength(); k++) {
Node bookmarkNode = bookmarkElements.item(k);
if (bookmarkNode.getNodeType() == Node.ELEMENT_NODE) {
Element bookmarkElement = (Element) bookmarkNode;
NamedNodeMap attributesMap = bookmarkElement.getAttributes();
Map<String, String> attribs = new HashMap<>();
for (int l = 0; l < attributesMap.getLength(); l++) {
Node item = attributesMap.item(l);
attribs.put(item.getNodeName(), item.getNodeValue());
}
bookmarkAttribs.add(attribs);
}
}
}
}
if (!bookmarkAttribs.isEmpty()) {
new TracePackageBookmarkElement(element, bookmarkAttribs);
}
packageElements.add(element);
}
}
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement in project tracecompass by tracecompass.
the class TracePackageExportOperation method exportSupplementaryFiles.
private void exportSupplementaryFiles(IProgressMonitor monitor, Node commonNode, TmfCommonProjectElement commonElement, TracePackageSupplFilesElement element) throws InterruptedException, CoreException {
Document doc = commonNode.getOwnerDocument();
if (element.getChildren().length > 0) {
IPath projectPath = commonElement.getProject().getPath();
for (TracePackageElement child : element.getChildren()) {
TracePackageSupplFileElement supplFile = (TracePackageSupplFileElement) child;
ModalContext.checkCanceled(monitor);
IResource res = supplFile.getResource();
// project/.tracing/A/B/statistics.ht -> .tracing/A/B/statistics.ht
IPath relativeToExportFolder = res.getFullPath().makeRelativeTo(projectPath);
// project/.traceExport/.tracing/A/B
IFolder folder = fExportFolder.getFolder(relativeToExportFolder.removeLastSegments(1));
TraceUtils.createFolder(folder, SubMonitor.convert(monitor));
res.refreshLocal(0, SubMonitor.convert(monitor));
createExportResource(folder, res);
Element suppFileElement = doc.createElement(ITracePackageConstants.SUPPLEMENTARY_FILE_ELEMENT);
suppFileElement.setAttribute(ITracePackageConstants.SUPPLEMENTARY_FILE_NAME_ATTRIB, relativeToExportFolder.toString());
commonNode.appendChild(suppFileElement);
}
IFolder suppFilesFolder = fExportFolder.getFolder(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER_NAME);
fResources.add(suppFilesFolder);
}
}
Aggregations