use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement 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.TracePackageTraceElement in project tracecompass by tracecompass.
the class TracePackageExportOperation method exportBookmarks.
private static void exportBookmarks(IProgressMonitor monitor, Node commonNode, TracePackageBookmarkElement element) throws CoreException, InterruptedException {
Document doc = commonNode.getOwnerDocument();
IFile bookmarksFile = ((TracePackageTraceElement) element.getParent()).getTraceElement().getBookmarksFile();
if (bookmarksFile != null && bookmarksFile.exists()) {
IMarker[] findMarkers = bookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
if (findMarkers.length > 0) {
Element bookmarksXmlElement = doc.createElement(ITracePackageConstants.BOOKMARKS_ELEMENT);
Node bookmarksNode = commonNode.appendChild(bookmarksXmlElement);
for (IMarker marker : findMarkers) {
ModalContext.checkCanceled(monitor);
Element singleBookmarkXmlElement = doc.createElement(ITracePackageConstants.BOOKMARK_ELEMENT);
for (String key : marker.getAttributes().keySet()) {
singleBookmarkXmlElement.setAttribute(key, marker.getAttribute(key).toString());
}
bookmarksNode.appendChild(singleBookmarkXmlElement);
}
}
}
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.
the class RemoteProfilesPreferencePage method newConnectionNode.
private RemoteImportConnectionNodeElement newConnectionNode(TracePackageElement parent, TracePackageElement previous) {
RemoteImportConnectionNodeElement node = new RemoteImportConnectionNodeElement(null, RemoteMessages.RemoteProfilesPreferencePage_DefaultConnectionNodeName, RemoteMessages.RemoteProfilesPreferencePage_DefaultConnectionNodeURI);
RemoteImportTraceGroupElement traceGroup = new RemoteImportTraceGroupElement(node, DEFAULT_ROOT_IMPORT_PATH);
TracePackageTraceElement trace = new TracePackageTraceElement(traceGroup, DEFAULT_IMPORT_NAME, null);
new TracePackageFilesElement(trace, DEFAULT_FILE_PATTERN);
int index = previous == null ? parent.getChildren().length : parent.indexOf(previous) + 1;
parent.addChild(index, node);
newElementAdded(node);
return node;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.
the class RemoteProfilesPreferencePage method copyElement.
private TracePackageElement copyElement(TracePackageElement parent, TracePackageElement element) {
TracePackageElement copy = null;
if (element instanceof RemoteImportProfileElement) {
RemoteImportProfileElement source = (RemoteImportProfileElement) element;
copy = new RemoteImportProfileElement(parent, source.getProfileName());
} else if (element instanceof RemoteImportConnectionNodeElement) {
RemoteImportConnectionNodeElement source = (RemoteImportConnectionNodeElement) element;
copy = new RemoteImportConnectionNodeElement(parent, source.getName(), source.getURI());
} else if (element instanceof RemoteImportTraceGroupElement) {
RemoteImportTraceGroupElement source = (RemoteImportTraceGroupElement) element;
copy = new RemoteImportTraceGroupElement(parent, source.getRootImportPath());
((RemoteImportTraceGroupElement) copy).setRecursive(source.isRecursive());
} else if (element instanceof TracePackageTraceElement) {
TracePackageTraceElement source = (TracePackageTraceElement) element;
copy = new TracePackageTraceElement(parent, source.getImportName(), source.getTraceType());
} else if (element instanceof TracePackageFilesElement) {
TracePackageFilesElement source = (TracePackageFilesElement) element;
copy = new TracePackageFilesElement(parent, source.getFileName());
}
for (TracePackageElement child : element.getChildren()) {
copyElement(copy, child);
}
return copy;
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.
the class RemoteProfilesPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
composite.setLayoutData(gd);
GridLayout gl = new GridLayout(2, false);
composite.setLayout(gl);
PatternFilter patternFilter = new PatternFilter() {
// show all children of matching profiles or profiles with matching connection node
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
TreeViewer treeViewer = (TreeViewer) viewer;
TracePackageContentProvider contentProvider = (TracePackageContentProvider) treeViewer.getContentProvider();
Object parentElement = element;
while (!(parentElement instanceof RemoteImportProfileElement)) {
parentElement = contentProvider.getParent(parentElement);
if (parentElement instanceof TracePackageTraceElement) {
// don't show children of trace element
return false;
}
}
RemoteImportProfileElement profile = (RemoteImportProfileElement) parentElement;
if (super.isLeafMatch(viewer, profile)) {
return true;
}
for (Object child : contentProvider.getChildren(profile)) {
if ((child instanceof RemoteImportConnectionNodeElement) && (super.isLeafMatch(viewer, child))) {
return true;
}
}
return false;
}
};
final FilteredTree filteredTree = new FilteredTree(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 0;
filteredTree.setLayoutData(gd);
final TreeViewer treeViewer = filteredTree.getViewer();
fTreeViewer = treeViewer;
treeViewer.setContentProvider(new TracePackageContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ArrayList) {
return ((ArrayList<?>) inputElement).toArray();
}
return super.getElements(inputElement);
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof TracePackageTraceElement) {
return false;
}
return super.hasChildren(element);
}
});
treeViewer.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof TracePackageTraceElement) {
for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
if (files instanceof TracePackageFilesElement) {
return ((TracePackageFilesElement) files).getFileName();
}
}
} else if (element instanceof TracePackageElement) {
return ((TracePackageElement) element).getText();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof TracePackageTraceElement) {
for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
return files.getImage();
}
} else if (element instanceof TracePackageElement) {
return ((TracePackageElement) element).getImage();
}
return super.getImage(element);
}
});
treeViewer.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TracePackageElement element = (TracePackageElement) (selection.size() == 1 ? selection.getFirstElement() : null);
fDetailsPanel.refreshDetailsPanel(element);
enableButtons(selection);
fSelectedProfileName = null;
while (element != null) {
if (element instanceof RemoteImportProfileElement) {
fSelectedProfileName = ((RemoteImportProfileElement) element).getProfileName();
}
element = element.getParent();
}
});
createGlobalActions();
createContextMenu();
fProfiles = readProfiles(PROFILE_FILE_PATH, new NullProgressMonitor());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.setInput(fProfiles);
treeViewer.expandAll();
Composite buttonBar = createVerticalButtonBar(composite);
gd = new GridData(SWT.CENTER, SWT.BEGINNING, false, false);
gd.verticalIndent = filteredTree.getFilterControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y + gl.verticalSpacing;
buttonBar.setLayoutData(gd);
enableButtons((IStructuredSelection) treeViewer.getSelection());
Composite details = new Composite(composite, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
details.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginWidth = 0;
details.setLayout(gl);
Label label = new Label(details, SWT.NONE);
label.setText(RemoteMessages.RemoteProfilesPreferencePage_DetailsPanelLabel);
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 2, 1);
label.setLayoutData(gd);
fDetailsPanel = new DetailsPanel(details);
validate();
for (RemoteImportProfileElement profile : fProfiles) {
if (profile.getProfileName().equals(fSelectedProfileName)) {
fTreeViewer.setSelection(new StructuredSelection(profile));
}
}
Dialog.applyDialogFont(composite);
return composite;
}
Aggregations