Search in sources :

Example 16 with TracePackageTraceElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.

the class RemoteProfilesPreferencePage method newTrace.

private TracePackageTraceElement newTrace(TracePackageElement parent, TracePackageElement previous) {
    TracePackageTraceElement trace = new TracePackageTraceElement(null, DEFAULT_IMPORT_NAME, null);
    new TracePackageFilesElement(trace, DEFAULT_FILE_PATTERN);
    int index = previous == null ? parent.getChildren().length : parent.indexOf(previous) + 1;
    parent.addChild(index, trace);
    newElementAdded(trace);
    return trace;
}
Also used : TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)

Example 17 with TracePackageTraceElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.

the class RemoteProfilesPreferencePage method validate.

private void validate() {
    setValid(false);
    Set<String> profileNames = new HashSet<>();
    for (RemoteImportProfileElement profile : fProfiles) {
        if (profile.getProfileName().length() == 0) {
            setErrorMessage(RemoteMessages.RemoteProfilesPreferencePage_EmptyProfileNameError);
            return;
        }
        // $NON-NLS-1$
        String prefix = profile.getProfileName() + ": ";
        if (!profileNames.add(profile.getProfileName())) {
            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_DuplicateProfileNameError);
            return;
        }
        Set<String> nodeNames = new HashSet<>();
        int nodeCount = 0;
        for (TracePackageElement profileChild : profile.getChildren()) {
            if (profileChild instanceof RemoteImportConnectionNodeElement) {
                nodeCount++;
                RemoteImportConnectionNodeElement node = (RemoteImportConnectionNodeElement) profileChild;
                if (node.getName().length() == 0) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_EmptyNodeNameError);
                    return;
                }
                // validate node name against the OS since the name will be used as folder name at the destination
                if (!ResourcesPlugin.getWorkspace().validateName(node.getName(), IResource.FOLDER).isOK()) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_InvalidNodeName);
                    return;
                }
                if (!nodeNames.add(node.getName())) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_DuplicateConnectionNodeNameError);
                    return;
                }
                if (node.getURI().length() == 0) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_EmptyNodeURIError);
                    return;
                }
                try {
                    URI uri = URIUtil.fromString(node.getURI());
                    IRemoteServicesManager manager = TmfRemoteConnectionFactory.getService(IRemoteServicesManager.class);
                    if (manager == null || manager.getConnectionType(uri) == null) {
                        setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_UnsupportedURISchemeError);
                        return;
                    }
                    if (uri.getScheme().equals(SSH_SCHEME)) {
                        if (uri.getHost() == null) {
                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_InvalidHostOrPortError);
                            return;
                        }
                        if (uri.getUserInfo() == null) {
                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_MissingUserInfoError);
                            return;
                        }
                    }
                } catch (URISyntaxException e) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_InvalidNodeURIError);
                    return;
                }
                int traceGroupCount = 0;
                for (TracePackageElement nodeChild : node.getChildren()) {
                    if (nodeChild instanceof RemoteImportTraceGroupElement) {
                        traceGroupCount++;
                        RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) nodeChild;
                        if (traceGroup.getRootImportPath().length() == 0) {
                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_EmptyRootPathError);
                            return;
                        }
                        int traceCount = 0;
                        for (TracePackageElement traceGroupChild : traceGroup.getChildren()) {
                            if (traceGroupChild instanceof TracePackageTraceElement) {
                                traceCount++;
                                TracePackageTraceElement trace = (TracePackageTraceElement) traceGroupChild;
                                for (TracePackageElement traceChild : trace.getChildren()) {
                                    if (traceChild instanceof TracePackageFilesElement) {
                                        TracePackageFilesElement files = (TracePackageFilesElement) traceChild;
                                        if (files.getFileName().length() == 0) {
                                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_EmptyFilePatternError);
                                            return;
                                        }
                                        try {
                                            Pattern.compile(files.getFileName());
                                        } catch (PatternSyntaxException e) {
                                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_InvalidFilePatternError);
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                        if (traceCount == 0) {
                            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_MissingTraceError);
                            return;
                        }
                    }
                }
                if (traceGroupCount == 0) {
                    setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_MissingTraceGroupError);
                    return;
                }
            }
        }
        if (nodeCount == 0) {
            setErrorMessage(prefix + RemoteMessages.RemoteProfilesPreferencePage_MissingConnectionNodeError);
            return;
        }
    }
    setValid(true);
    setErrorMessage(null);
}
Also used : RemoteImportConnectionNodeElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager) URISyntaxException(java.net.URISyntaxException) RemoteImportTraceGroupElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement) RemoteImportProfileElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement) URI(java.net.URI) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) HashSet(java.util.HashSet) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 18 with TracePackageTraceElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.

the class TracePackageExtractManifestOperation method generateElementsFromArchive.

private TracePackageElement[] generateElementsFromArchive() {
    ArchiveFile archiveFile = getSpecifiedArchiveFile();
    Enumeration<@NonNull ?> entries = archiveFile.entries();
    Set<String> traceFileNames = new HashSet<>();
    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<>();
    for (String traceFileName : traceFileNames) {
        TracePackageTraceElement traceElement = new TracePackageTraceElement(null, traceFileName, null);
        new TracePackageFilesElement(traceElement, traceFileName);
        packageElements.add(traceElement);
    }
    return packageElements.toArray(new TracePackageElement[] {});
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) ArrayList(java.util.ArrayList) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) HashSet(java.util.HashSet)

Example 19 with TracePackageTraceElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement in project tracecompass by tracecompass.

the class TracePackageImportOperation method doRun.

private void doRun(IProgressMonitor progressMonitor) {
    try {
        setStatus(deleteExistingTraces(progressMonitor));
        if (!getStatus().isOK()) {
            return;
        }
        List<TracePackageExperimentElement> experimentPackageElements = new ArrayList<>();
        for (TracePackageElement packageElement : fImportTraceElements) {
            TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
            if (!isFilesChecked(packageElement)) {
                continue;
            }
            if (packageElement instanceof TracePackageExperimentElement) {
                experimentPackageElements.add((TracePackageExperimentElement) packageElement);
                continue;
            }
            TracePackageElement[] children = traceElement.getChildren();
            for (TracePackageElement element : children) {
                ModalContext.checkCanceled(progressMonitor);
                if (element instanceof TracePackageFilesElement) {
                    TracePackageFilesElement traceFilesElement = (TracePackageFilesElement) element;
                    setStatus(importTraceFiles(traceFilesElement, traceElement, progressMonitor));
                }
                if (!getStatus().isOK()) {
                    return;
                }
            }
            setStatus(importSupplFiles(traceElement, progressMonitor));
            if (!getStatus().isOK()) {
                return;
            }
        }
        for (TracePackageExperimentElement experimentPackageElement : experimentPackageElements) {
            ModalContext.checkCanceled(progressMonitor);
            importExperiment(experimentPackageElement, progressMonitor);
            if (!getStatus().isOK()) {
                return;
            }
        }
    } catch (InterruptedException e) {
        setStatus(Status.CANCEL_STATUS);
        Thread.currentThread().interrupt();
    }
}
Also used : TracePackageExperimentElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageExperimentElement) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) ArrayList(java.util.ArrayList) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)

Example 20 with TracePackageTraceElement

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement 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

TracePackageTraceElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)32 TracePackageElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)23 TracePackageFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement)22 RemoteImportConnectionNodeElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement)9 RemoteImportTraceGroupElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement)9 TracePackageExperimentElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageExperimentElement)9 ArrayList (java.util.ArrayList)8 RemoteImportProfileElement (org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement)8 Element (org.w3c.dom.Element)7 IPath (org.eclipse.core.runtime.IPath)6 TracePackageBookmarkElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement)6 TracePackageSupplFileElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFileElement)6 TracePackageSupplFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageSupplFilesElement)6 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)6 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)6 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)6 Path (org.eclipse.core.runtime.Path)4 Node (org.w3c.dom.Node)4 URI (java.net.URI)3 HashMap (java.util.HashMap)3