List of usage examples for org.eclipse.jface.operation ModalContext checkCanceled
public static void checkCanceled(IProgressMonitor monitor) throws InterruptedException
InterruptedException
if it has been canceled. From source file:gov.nasa.ensemble.common.ui.operations.EnsembleFileSystemExportOperation.java
License:Open Source License
/** * Export the passed file to the specified location * * @param file org.eclipse.core.resources.IFile * @param location org.eclipse.core.runtime.IPath */// w w w . j a v a 2s .co m protected void exportFile(IFile file, IPath location) throws InterruptedException { if (!isAcceptableFileType(file)) { return; } monitor.subTask(file.getFullPath().toString()); IPath fullPath = location.append(file.getName()); String properPathString = getProperPathString(file, location); File targetFile = new File(properPathString); if (targetFile.exists()) { if (!targetFile.canWrite()) { errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Cannot overwrite file: {0}", targetFile.getAbsolutePath()), null)); monitor.worked(1); return; } if (overwriteState == OVERWRITE_NONE) { monitor.worked(1); return; } if (overwriteState != OVERWRITE_ALL) { String overwriteAnswer = overwriteCallback.queryOverwrite(properPathString); if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) { throw new InterruptedException(); } if (overwriteAnswer.equals(IOverwriteQuery.NO)) { ModalContext.checkCanceled(monitor); monitor.worked(1); return; } if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) { monitor.worked(1); overwriteState = OVERWRITE_NONE; return; } if (overwriteAnswer.equals(IOverwriteQuery.ALL)) { overwriteState = OVERWRITE_ALL; } } } try { exporter.write(file, fullPath, monitor); } catch (IOException e) { errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Error exporting {0}: {1}", fullPath, e.getMessage()), e)); } catch (CoreException e) { errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Error exporting {0}: {1}", fullPath, e.getMessage()), e)); } monitor.worked(1); ModalContext.checkCanceled(monitor); }
From source file:lost.tok.export.SourceExportOperation.java
License:Open Source License
/** * Write file to zip.//from w ww. jav a2s . c o m * * @param exportResource * the export resource * @param leadupDepth * the leadup depth * * @throws InterruptedException * the interrupted exception */ private void writeFileToZip(IResource exportResource, int leadupDepth) throws InterruptedException { String destinationName; IPath fullPath = exportResource.getFullPath(); if (createLeadupStructure) { destinationName = fullPath.makeRelative().toString(); } else { destinationName = fullPath.removeFirstSegments(fullPath.segmentCount() - leadupDepth).toString(); } monitor.subTask(destinationName); // Collect the names for fetching the links to the sources later try { exporter.write((IFile) exportResource, destinationName); } catch (IOException e) { addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath().makeRelative(), e.getMessage()), e); } catch (CoreException e) { addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath().makeRelative(), e.getMessage()), e); } monitor.worked(1); ModalContext.checkCanceled(monitor); }
From source file:org.eclipse.ajdt.internal.ui.wizards.exports.AJJarFileExportOperation.java
License:Open Source License
/** * Exports the passed resource to the JAR file * * @param element the resource or JavaElement to export *///from w w w . j a v a 2s. c o m protected void exportElement(Object element, IProgressMonitor progressMonitor) throws InterruptedException { // AspectJ Change Begin if (!AspectJPlugin.USING_CU_PROVIDER) { // Don't export AJCompilationUnits because they are duplicates of files that we also export. if (element instanceof AJCompilationUnit) { return; } } // AspectJ Change End int leadSegmentsToRemove = 1; IPackageFragmentRoot pkgRoot = null; boolean isInJavaProject = false; IResource resource = null; IJavaProject jProject = null; if (element instanceof IJavaElement) { isInJavaProject = true; IJavaElement je = (IJavaElement) element; int type = je.getElementType(); if (type != IJavaElement.CLASS_FILE && type != IJavaElement.COMPILATION_UNIT) { exportJavaElement(progressMonitor, je); return; } try { resource = je.getUnderlyingResource(); } catch (JavaModelException ex) { addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_resourceNotFound, je.getElementName()), ex); return; } jProject = je.getJavaProject(); pkgRoot = JavaModelUtil.getPackageFragmentRoot(je); } else resource = (IResource) element; if (!resource.isAccessible()) { addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_resourceNotFound, resource.getFullPath()), null); return; } if (resource.getType() == IResource.FILE) { if (!isInJavaProject) { // check if it's a Java resource try { isInJavaProject = resource.getProject().hasNature(JavaCore.NATURE_ID); } catch (CoreException ex) { addWarning( Messages.format(JarPackagerMessages.JarFileExportOperation_projectNatureNotDeterminable, resource.getFullPath()), ex); return; } if (isInJavaProject) { jProject = JavaCore.create(resource.getProject()); try { IPackageFragment pkgFragment = jProject .findPackageFragment(resource.getFullPath().removeLastSegments(1)); if (pkgFragment != null) pkgRoot = JavaModelUtil.getPackageFragmentRoot(pkgFragment); else pkgRoot = findPackageFragmentRoot(jProject, resource.getFullPath().removeLastSegments(1)); } catch (JavaModelException ex) { addWarning(Messages.format( JarPackagerMessages.JarFileExportOperation_javaPackageNotDeterminable, resource.getFullPath()), ex); return; } } } if (pkgRoot != null && jProject != null) { leadSegmentsToRemove = pkgRoot.getPath().segmentCount(); boolean isOnBuildPath; isOnBuildPath = jProject.isOnClasspath(resource); if (!isOnBuildPath || (mustUseSourceFolderHierarchy() && !pkgRoot.getElementName().equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH))) leadSegmentsToRemove--; } IPath destinationPath = resource.getFullPath().removeFirstSegments(leadSegmentsToRemove); boolean isInOutputFolder = false; if (isInJavaProject && jProject != null) { try { isInOutputFolder = jProject.getOutputLocation().isPrefixOf(resource.getFullPath()); } catch (JavaModelException ex) { isInOutputFolder = false; } } exportClassFiles(progressMonitor, pkgRoot, resource, jProject, destinationPath); exportResource(progressMonitor, pkgRoot, isInJavaProject, resource, destinationPath, isInOutputFolder); progressMonitor.worked(1); ModalContext.checkCanceled(progressMonitor); } else exportContainer(progressMonitor, (IContainer) resource); }
From source file:org.eclipse.ajdt.internal.ui.wizards.exports.AJJarFileExportOperation.java
License:Open Source License
private void exportResource(IProgressMonitor progressMonitor, IResource resource, int leadingSegmentsToRemove) throws InterruptedException { if (resource instanceof IContainer) { IContainer container = (IContainer) resource; IResource[] children;//from w w w. j ava 2 s.co m try { children = container.members(); } catch (CoreException e) { // this should never happen because an #isAccessible check is done before #members is invoked addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringExport, container.getFullPath()), e); return; } for (int i = 0; i < children.length; i++) exportResource(progressMonitor, children[i], leadingSegmentsToRemove); } else if (resource instanceof IFile) { try { IPath destinationPath = resource.getFullPath().removeFirstSegments(leadingSegmentsToRemove); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, destinationPath.toString())); fJarWriter.write((IFile) resource, destinationPath); } catch (CoreException ex) { Throwable realEx = ex.getStatus().getException(); if (realEx instanceof ZipException && realEx.getMessage() != null && realEx.getMessage().startsWith("duplicate entry:")) //$NON-NLS-1$ addWarning(ex.getMessage(), realEx); else addToStatus(ex); } finally { progressMonitor.worked(1); ModalContext.checkCanceled(progressMonitor); } } }
From source file:org.eclipse.cdt.launch.remote.direct.DirectDebugRemoteFileExportOperation.java
License:Open Source License
/** * Export the passed file to the specified location * * @param file org.eclipse.core.resources.IFile * @param location org.eclipse.core.runtime.IPath *///from ww w . j av a 2 s.c o m protected void exportFile(IFile file, IPath location) throws InterruptedException { IPath fullPath = location.append(file.getName()); String destination = fullPath.toString(); // flag to indicate whether export is required boolean exportRequired = false; monitor.subTask(file.getFullPath().toString()); String properPathString = fullPath.toOSString(); File targetFile = null; if (conn == null) { targetFile = new File(properPathString); } else { try { targetFile = new DirectDebugUniFilePlus(Utilities.getIRemoteFile(conn, fullPath.toString())); } catch (NullPointerException e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, RemoteImportExportResources.MSG_IMPORT_EXPORT_UNABLE_TO_USE_CONNECTION); // Assume that communication has failed. errorTable.add(new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, msg, e)); throw e; } } if (targetFile.exists()) { exportRequired = isExportRequired(file, destination); // if export is not required, no need to do anything if (!exportRequired) { return; } if (!targetFile.canWrite()) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_NOT_WRITABLE, targetFile.getAbsolutePath()); errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, msg, null)); monitor.worked(1); return; } if (overwriteState == OVERWRITE_NONE) { return; } else if (overwriteState != OVERWRITE_ALL) { String overwriteAnswer = overwriteCallback.queryOverwrite(properPathString); if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) { throw new InterruptedException(); } else if (overwriteAnswer.equals(IOverwriteQuery.NO)) { monitor.worked(1); return; } else if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) { monitor.worked(1); overwriteState = OVERWRITE_NONE; return; } else if (overwriteAnswer.equals(IOverwriteQuery.ALL)) { overwriteState = OVERWRITE_ALL; } } } else if (!targetFile.exists()) { // need to do an export if target file does not exist, even if the local // file has not changed. This is for the scenario where a file may have been // exported, and the server copy was later deleted. The next export should put // the local copy back on the server, even if the local file was not changed. exportRequired = true; } try { exporter.write(file, fullPath); // if there are no exceptions, we should be here and the export should have completed fine // so we update the modification time at the time of export SystemIFileProperties props = new SystemIFileProperties(file); long modTime = file.getModificationStamp(); props.setModificationStampAtExport(conn.getHostName(), destination, modTime); } catch (IOException e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, e.getLocalizedMessage()); errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, msg, e)); } catch (CoreException e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, e.getLocalizedMessage()); errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, msg, e)); } catch (RemoteFileIOException e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, e.getLocalizedMessage()); errorTable.add(new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, msg, e)); } catch (RemoteFileSecurityException e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, e.getLocalizedMessage()); errorTable.add(new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, msg, e)); } catch (Exception e) { String msg = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_ERROR, fullPath, e.getLocalizedMessage()); errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, msg, e)); } monitor.worked(1); ModalContext.checkCanceled(monitor); }
From source file:org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.TracePackageExportOperation.java
License:Open Source License
/** * Run the operation. The status (result) of the operation can be obtained * with {@link #getStatus}/*from w w w . j av a2 s .c o m*/ * * @param progressMonitor * the progress monitor to use to display progress and receive * requests for cancellation */ @Override public void run(IProgressMonitor progressMonitor) { try { int totalWork = getNbCheckedElements(fTraceExportElements) * 2; progressMonitor.beginTask(Messages.TracePackageExportOperation_GeneratingPackage, totalWork); fExportFolder = createExportFolder(progressMonitor); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element createElement = doc.createElement(ITracePackageConstants.TMF_EXPORT_ELEMENT); Node tmfNode = doc.appendChild(createElement); for (TracePackageTraceElement tracePackageElement : fTraceExportElements) { if (!isFilesChecked(tracePackageElement)) { continue; } exportTrace(progressMonitor, tmfNode, tracePackageElement); } Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$ DOMSource source = new DOMSource(doc); StringWriter buffer = new StringWriter(); StreamResult result = new StreamResult(buffer); transformer.transform(source, result); String content = buffer.getBuffer().toString(); ModalContext.checkCanceled(progressMonitor); exportManifest(content); setStatus(exportToArchive(progressMonitor, totalWork)); fExportFolder.delete(true, new SubProgressMonitor(progressMonitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); progressMonitor.done(); } catch (Exception e) { if (e instanceof InterruptedException) { setStatus(Status.CANCEL_STATUS); } else { setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.Messages.TracePackage_ErrorOperation, e)); } } }
From source file:org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteGenerateManifestOperation.java
License:Open Source License
@Override public void run(IProgressMonitor monitor) { try {/*from ww w .j a v a 2s . c om*/ monitor.worked(1); String root = null; List<TracePackageElement> resultElementList = new ArrayList<>(); SubMonitor subMonitor = SubMonitor.convert(monitor, fProfile.getChildren().length * 2); List<RemoteImportConnectionNodeElement> connectionNodes = fProfile.getConnectionNodeElements(); for (RemoteImportConnectionNodeElement connectionNode : connectionNodes) { RemoteSystemProxy proxy = connectionNode.getRemoteSystemProxy(); // create new element to decouple from input element RemoteImportConnectionNodeElement outputConnectionNode = new RemoteImportConnectionNodeElement(null, connectionNode.getName(), connectionNode.getURI()); resultElementList.add(outputConnectionNode); for (TracePackageElement element : connectionNode.getChildren()) { if (element instanceof RemoteImportTraceGroupElement) { ModalContext.checkCanceled(monitor); RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) element; root = traceGroup.getRootImportPath(); TracePackageElement[] traceElements = traceGroup.getChildren(); fTemplatePatternsToTraceElements = generatePatterns(traceElements); IRemoteFileService fs = proxy.getRemoteConnection().getService(IRemoteFileService.class); if (fs == null) { continue; } final IFileStore remoteFolder = fs.getResource(root); // make sure that remote directory is read and not cached int recursionLevel = 0; // create new element to decouple from input element RemoteImportTraceGroupElement outputTraceGroup = new RemoteImportTraceGroupElement( outputConnectionNode, traceGroup.getRootImportPath()); outputTraceGroup.setRecursive(traceGroup.isRecursive()); generateElementsFromArchive(outputTraceGroup, outputTraceGroup, remoteFolder, recursionLevel, subMonitor.newChild(1)); filterElements(outputTraceGroup); } } } setResultElements(resultElementList.toArray(new TracePackageElement[0])); setStatus(Status.OK_STATUS); } catch (InterruptedException e) { setStatus(Status.CANCEL_STATUS); } catch (Exception e) { setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind( RemoteMessages.RemoteGenerateManifest_GenerateProfileManifestError, fProfile.getText()), e)); } }
From source file:org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteGenerateManifestOperation.java
License:Open Source License
/** * Scan traceFolder for files that match the patterns specified in the * template file. When there is a match, the trace package element is used * to determine the trace name and trace type. * * @param traceGroup//from w w w. java2 s. co m * The parent trace group element * @param parentElement * The immediate parent trace group or folder element * @param traceFolder * The folder to scan * @param recursionLevel * The recursion level (needed to find directory traces under the traceFolder * @param monitor * The progress monitor * @throws CoreException * Thrown by the file system implementation * @throws InterruptedException * Thrown if operation was cancelled */ private void generateElementsFromArchive(final RemoteImportTraceGroupElement traceGroup, final TracePackageElement parentElement, final IFileStore traceFolder, final int recursionLevel, IProgressMonitor monitor) throws CoreException, InterruptedException { int localRecursionLevel = recursionLevel + 1; IFileStore[] sources = traceFolder.childStores(EFS.NONE, monitor); for (int i = 0; i < sources.length; i++) { ModalContext.checkCanceled(monitor); SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length); IFileStore fileStore = sources[i]; IPath fullArchivePath = TmfTraceCoreUtils.newSafePath(fileStore.toURI().getPath()); IFileInfo sourceInfo = fileStore.fetchInfo(); if (!sourceInfo.isDirectory()) { String rootPathString = traceGroup.getRootImportPath(); IPath rootPath = TmfTraceCoreUtils.newSafePath(rootPathString); IPath relativeTracePath = Path.EMPTY; if (rootPath.isPrefixOf(fullArchivePath)) { relativeTracePath = fullArchivePath.makeRelativeTo(rootPath); } Entry<Pattern, TracePackageTraceElement> matchingTemplateEntry = getMatchingTemplateElement( relativeTracePath); if (matchingTemplateEntry != null) { TracePackageTraceElement matchingTemplateElement = matchingTemplateEntry.getValue(); String traceType = matchingTemplateElement.getTraceType(); // If a single file is part of a directory trace, use the parent directory instead TracePackageElement parent = parentElement; if (matchesDirectoryTrace(relativeTracePath, matchingTemplateEntry)) { fullArchivePath = fullArchivePath.removeLastSegments(1); fDirectoryTraces.add(fullArchivePath); fileStore = fileStore.getParent(); parent = parentElement.getParent(); // Let the auto-detection choose the best trace type traceType = null; } else if ((localRecursionLevel > 1) && (!traceGroup.isRecursive())) { // Don't consider file traces on level 2 if it's not recursive continue; } String traceName = fullArchivePath.lastSegment(); String fileName = fileStore.getName(); // create new elements to decouple from input elements TracePackageTraceElement traceElement = new TracePackageTraceElement(parent, traceName, traceType); RemoteImportTraceFilesElement tracePackageFilesElement = new RemoteImportTraceFilesElement( traceElement, fileName, fileStore); tracePackageFilesElement.setVisible(false); } } else { if (traceGroup.isRecursive() || localRecursionLevel < 2) { RemoteImportFolderElement folder = new RemoteImportFolderElement(parentElement, fileStore.getName()); generateElementsFromArchive(traceGroup, folder, fileStore, localRecursionLevel, subMonitor); } } } }
From source file:org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTracesOperation.java
License:Open Source License
private void doRun(IProgressMonitor monitor) throws ExecutionException, CoreException, IOException, InterruptedException { IFolder destinationFolder = fDestination.getResource(); if (!destinationFolder.exists()) { throw new ExecutionException( RemoteMessages.RemoteImportTracesOperation_ImportDialogInvalidTracingProject + " (" //$NON-NLS-1$ + TmfTracesFolder.TRACES_FOLDER_NAME + ")"); //$NON-NLS-1$ }/*from ww w .j a va 2s . c o m*/ SubMonitor subMonitor = SubMonitor.convert(monitor, fTraceElements.length * 4); subMonitor.beginTask(RemoteMessages.RemoteImportTracesOperation_DownloadTask, fTraceElements.length * 4); for (Object packageElement : fTraceElements) { if (!(packageElement instanceof TracePackageTraceElement)) { continue; } TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement; TracePackageElement parentElement = traceElement.getParent(); while (parentElement != null) { if (parentElement instanceof RemoteImportTraceGroupElement) { break; } parentElement = parentElement.getParent(); } if (parentElement == null) { continue; } RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) parentElement; String rootPath = traceGroup.getRootImportPath(); // Create folder with node name in destination folder RemoteImportConnectionNodeElement nodeElement = (RemoteImportConnectionNodeElement) traceGroup .getParent(); String nodeName = nodeElement.getName(); IFolder nodeFolder = destinationFolder.getFolder(nodeName); TracePackageElement[] children = traceElement.getChildren(); SubMonitor childMonitor = subMonitor.newChild(1); TraceUtils.createFolder(nodeFolder, childMonitor); for (TracePackageElement element : children) { ModalContext.checkCanceled(monitor); if (element instanceof RemoteImportTraceFilesElement) { RemoteImportTraceFilesElement traceFilesElement = (RemoteImportTraceFilesElement) element; IFileStore remoteFile = traceFilesElement.getRemoteFile(); // Preserve folder structure IPath sessionParentPath = TmfTraceCoreUtils.newSafePath(rootPath); IPath traceParentPath = TmfTraceCoreUtils.newSafePath(remoteFile.getParent().toURI().getPath()); IPath relativeTracePath = Path.EMPTY; if (sessionParentPath.isPrefixOf(traceParentPath)) { relativeTracePath = traceParentPath.makeRelativeTo(sessionParentPath); } String[] segments = relativeTracePath.segments(); for (int i = 0; i < segments.length; i++) { String segment = TmfTraceCoreUtils .validateName(TmfTraceCoreUtils.safePathToString(segments[i])); if (i == 0) { relativeTracePath = new Path(segment); } else { relativeTracePath = relativeTracePath.append(segment); } } IFolder traceFolder = nodeFolder.getFolder(new Path(relativeTracePath.toOSString())); childMonitor = subMonitor.newChild(1); TraceUtils.createFolder(traceFolder, childMonitor); childMonitor.done(); // Import trace IResource traceRes = null; IFileInfo info = remoteFile.fetchInfo(); if (info.isDirectory()) { traceRes = downloadDirectoryTrace(remoteFile, traceFolder, subMonitor.newChild(1)); } else { traceRes = downloadFileTrace(remoteFile, traceFolder, subMonitor.newChild(1)); } String traceName = traceElement.getText(); if (traceRes == null || !traceRes.exists()) { continue; } // Select trace type TraceTypeHelper traceTypeHelper = null; String traceTypeStr = traceElement.getTraceType(); if (traceTypeStr != null) { traceTypeHelper = TmfTraceType.getTraceType(traceTypeStr); } // no specific trace type found if (traceTypeHelper == null) { try { // Try to auto-detect the trace typ childMonitor = subMonitor.newChild(1); childMonitor.setTaskName(NLS.bind( RemoteMessages.RemoteImportTracesOperation_DetectingTraceType, traceName)); childMonitor.done(); traceTypeHelper = TmfTraceTypeUIUtils .selectTraceType(traceRes.getLocation().toOSString(), null, null); } catch (TmfTraceImportException e) { //Could not figure out the type } } if (traceTypeHelper != null) { TmfTraceTypeUIUtils.setTraceType(traceRes, traceTypeHelper); } // Set source location URI uri = remoteFile.toURI(); String sourceLocation = URIUtil.toUnencodedString(uri); traceRes.setPersistentProperty(TmfCommonConstants.SOURCE_LOCATION, sourceLocation); } } } }
From source file:org.eclipse.tracecompass.internal.tmf.ui.project.operations.NewExperimentOperation.java
License:Open Source License
@Override public void run(IProgressMonitor monitor) { final IFolder experimentFolder = createExperiment(fExperimentName); try {/*from w ww. j av a 2 s .co m*/ monitor.beginTask("", 1000); //$NON-NLS-1$ ModalContext.checkCanceled(monitor); experimentFolder.create(false, true, monitor); /* * Experiments can be set to the default experiment type. No * need to force user to select an experiment type */ IConfigurationElement ce = TmfTraceType.getTraceAttributes(TmfTraceType.DEFAULT_EXPERIMENT_TYPE); if (ce != null) { experimentFolder.setPersistentProperty(TmfCommonConstants.TRACETYPE, ce.getAttribute(TmfTraceType.ID_ATTR)); } fExperimentFolder = experimentFolder; setStatus(Status.OK_STATUS); } catch (InterruptedException e) { setStatus(Status.CANCEL_STATUS); } catch (InvalidRegistryObjectException | CoreException e) { String msg = NLS.bind(Messages.NewExperimentOperation_CreationError, fExperimentName); Activator.getDefault().logError(msg, e); setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, msg, e)); } }