use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement 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);
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement 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[] {});
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement 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();
}
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement 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);
}
use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement in project tracecompass by tracecompass.
the class TracePackageExportOperation method exportCommon.
private Node exportCommon(IProgressMonitor monitor, Node tmfNode, TracePackageTraceElement tracePackageElement, String elementString) throws InterruptedException, CoreException {
TmfCommonProjectElement commonElement = tracePackageElement.getTraceElement();
Element commonXmlElement = tmfNode.getOwnerDocument().createElement(elementString);
commonXmlElement.setAttribute(ITracePackageConstants.TRACE_NAME_ATTRIB, commonElement.getResource().getName());
commonXmlElement.setAttribute(ITracePackageConstants.TRACE_TYPE_ATTRIB, commonElement.getTraceType());
Node commonNode = tmfNode.appendChild(commonXmlElement);
for (TracePackageElement element : tracePackageElement.getChildren()) {
ModalContext.checkCanceled(monitor);
if (!element.isChecked()) {
continue;
}
if (element instanceof TracePackageSupplFilesElement) {
exportSupplementaryFiles(monitor, commonNode, commonElement, (TracePackageSupplFilesElement) element);
} else if (element instanceof TracePackageBookmarkElement) {
exportBookmarks(monitor, commonNode, (TracePackageBookmarkElement) element);
} else if (element instanceof TracePackageFilesElement && commonElement instanceof TmfTraceElement) {
exportTraceFiles(monitor, commonNode, (TracePackageFilesElement) element);
}
monitor.worked(1);
}
return commonNode;
}
Aggregations