use of org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement in project tracecompass by tracecompass.
the class XMLAnalysesManagerPreferencePage method refreshProject.
/**
* Refresh the selected project elements. This is useful after XML files
* importing/deletion/enabling/disabling.
*
* @param elements
* the elements to re-open
*/
private static void refreshProject(Collection<TmfCommonProjectElement> elements) {
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
// Get the selection
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPart part = page.getActivePart();
if (part == null) {
return;
}
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
if (selectionProvider == null) {
return;
}
ISelection selection = selectionProvider.getSelection();
if (selection instanceof TreeSelection) {
TreeSelection sel = (TreeSelection) selection;
// There should be only one item selected as per the plugin.xml
Object element = sel.getFirstElement();
if (element instanceof TmfProjectModelElement) {
((TmfProjectModelElement) element).getProject().refresh();
}
}
// Re-open given elements
elements.forEach(TmfOpenTraceHelper::openFromElement);
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement in project tracecompass by tracecompass.
the class TracePackageExportOperation method exportTraceFiles.
private void exportTraceFiles(IProgressMonitor monitor, Node traceNode, TracePackageFilesElement element) throws CoreException {
Document doc = traceNode.getOwnerDocument();
TmfCommonProjectElement traceElement = ((TracePackageTraceElement) element.getParent()).getTraceElement();
IResource resource = traceElement.getResource();
final TmfProjectModelElement tracesFolder = traceElement.getProject().getTracesFolder();
if (tracesFolder == null) {
return;
}
IPath traceFolderPath = tracesFolder.getPath();
// project/Traces/A/B/Kernel -> A/B/Kernel
IPath relativeToExportFolder = resource.getFullPath().makeRelativeTo(traceFolderPath);
// project/.traceExport/A/B
IFolder folder = fExportFolder.getFolder(relativeToExportFolder.removeLastSegments(1));
TraceUtils.createFolder(folder, SubMonitor.convert(monitor));
createExportResource(folder, resource);
Element fileElement = doc.createElement(ITracePackageConstants.TRACE_FILE_ELEMENT);
fileElement.setAttribute(ITracePackageConstants.TRACE_FILE_NAME_ATTRIB, relativeToExportFolder.toString());
traceNode.appendChild(fileElement);
// Always export the top-most folder containing the trace or the
// trace itself
IResource exportedResource = fExportFolder.findMember(relativeToExportFolder.segment(0));
fResources.add(exportedResource);
}
Aggregations