Search in sources :

Example 1 with TmfProjectModelElement

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);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TreeSelection(org.eclipse.jface.viewers.TreeSelection) TmfOpenTraceHelper(org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper) ISelection(org.eclipse.jface.viewers.ISelection) TmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 2 with TmfProjectModelElement

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);
}
Also used : IPath(org.eclipse.core.runtime.IPath) TmfCommonProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) TracePackageSupplFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFilesElement) TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfExperimentElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement) TracePackageSupplFileElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFileElement) Element(org.w3c.dom.Element) TracePackageExperimentElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageExperimentElement) TracePackageBookmarkElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement) TmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement) TmfCommonProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) Document(org.w3c.dom.Document) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

TmfProjectModelElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement)2 IFolder (org.eclipse.core.resources.IFolder)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TracePackageBookmarkElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement)1 TracePackageElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)1 TracePackageExperimentElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageExperimentElement)1 TracePackageFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement)1 TracePackageSupplFileElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFileElement)1 TracePackageSupplFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFilesElement)1 TracePackageTraceElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)1 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)1 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)1 TmfOpenTraceHelper (org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper)1 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1