@Override public void progress(String progressGroup, String msg, String msgGroup, int workedUnit) { boolean mustLog = false; IProgressMonitor progressMonitor = getProgressMonitor(progressGroup); if(progressMonitor != null){ progressMonitor.subTask(msg); progressMonitor.worked(workedUnit*progressBarScale); } else{ mustLog = true; } // for the moment forward all messages to usual log Kind logLevel; if(mustLog){ logLevel = Kind.UserINFO; } else logLevel = Kind.DevINFO; this.log(logLevel, "["+progressGroup+"]"+ msg+getIntermediateElapsedTime(progressGroup), msgGroup); }
private Collection<File> adaptNPMPackages(final IProgressMonitor monitor, final MultiStatus status, final Collection<String> addedDependencies) { logger.logInfo(LINE_SINGLE); logger.logInfo("Adapting npm package structure to N4JS project structure... [step 3 of 4]"); monitor.setTaskName("Adapting npm package structure to N4JS project structure... [step 3 of 4]"); final Pair<IStatus, Collection<File>> result = npmPackageToProjectAdapter.adaptPackages(addedDependencies); final IStatus adaptionStatus = result.getFirst(); // log possible errors, but proceed with the process // assume that at least some packages were installed correctly and can be adapted if (!adaptionStatus.isOK()) { logger.logError(adaptionStatus); status.merge(adaptionStatus); } final Collection<File> adaptedPackages = result.getSecond(); logger.logInfo("Packages structures has been adapted to N4JS project structure."); monitor.worked(2); logger.logInfo(LINE_SINGLE); return adaptedPackages; }
/** * @param project * @param buildPolicyFile * @param graphFilePath * @param updatedGenerators * @throws IOException * @throws CoreException * @throws InterruptedException */ public static void update(IProject project, IFile buildPolicyFile, String graphFilePath, List<String> updatedGenerators) throws IOException, CoreException, InterruptedException { Job job = new WorkspaceJob("Updating policies") { public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { _update(project, buildPolicyFile, graphFilePath, updatedGenerators, monitor); } catch (FileNotFoundException e) { ResourceManager.logException(e); } return Status.OK_STATUS; } }; job.setRule(buildPolicyFile.getProject()); job.setUser(true); job.schedule(); }
public static void addStringCoupleIfNeeded(IFile classFile, String languageName, String layerName, IProgressMonitor monitor) throws IOException, CoreException { String content = getContent(classFile.getContents(), "UTF8"); final String statement = "res.add(new StringCouple(\"" + languageName + "\", \"" + layerName + "\"));"; if (!content.contains(statement)) { int index = content.lastIndexOf("res.add(new StringCouple("); if (index >= 0) { index = index + "res.add(new StringCouple(".length(); while (content.charAt(index) != ';') { ++index; } String newContent = content.substring(0, index) + "\n\t\t" + statement + "\n" + content.substring(index, content.length()); setContent(classFile.getFullPath().toFile(), "UTF8", newContent); classFile.refreshLocal(1, monitor); } else { // TODO notify : add statement manually } } }
/** * Create a file in a folder with the specified name and content * * @param fullpath * @param filename * @param content * @throws CoreException * @throws InterruptedException */ public static IFile createFileDeleteIfExists(String fullpath, String filename, String content, IProgressMonitor monitor) throws CoreException, InterruptedException { SubMonitor subMonitor = SubMonitor.convert(monitor, 100); subMonitor.setTaskName("Create file delete if it exists " + fullpath); IFile newFile; try { IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot(); IContainer container = (IContainer) wroot.findMember(new Path(fullpath)); newFile = container.getFile(new Path(filename)); if (newFile.exists()) { JDTManager.rename(newFile, new NullProgressMonitor()); newFile.delete(true, new NullProgressMonitor()); } subMonitor.split(30); byte[] source = content.getBytes(Charset.forName("UTF-8")); newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor()); subMonitor.split(70); } finally { subMonitor.done(); } return newFile; }
@Override public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor); if (!prefs.isCompilerEnabled()) { return; } final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context); if (deltas.isEmpty()) { return; } if (progress.isCanceled()) { throw new OperationCanceledException(); } progress.beginTask("Compiling solidity...", deltas.size()); List<URI> uris = deltas.stream().map(delta -> delta.getUri()).collect(Collectors.toList()); compiler.compile(uris, progress); context.getBuiltProject().refreshLocal(IProject.DEPTH_INFINITE, progress); progress.done(); }
@Override public CompletableFuture<ICodeLens> resolveCodeLens(ICodeLensContext context, ICodeLens codeLens, IProgressMonitor monitor) { ITextEditor textEditor = ((IEditorCodeLensContext) context).getTextEditor(); LSPDocumentInfo info = null; Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor( LSPEclipseUtils.getDocument((ITextEditor) textEditor), capabilities -> capabilities.getCodeLensProvider() != null && capabilities.getCodeLensProvider().isResolveProvider()); if (!infos.isEmpty()) { info = infos.iterator().next(); } else { info = null; } if (info != null) { LSPCodeLens lscl = ((LSPCodeLens) codeLens); CodeLens unresolved = lscl.getCl(); return info.getLanguageClient().getTextDocumentService().resolveCodeLens(unresolved).thenApply(resolved -> { lscl.update(resolved); return lscl; }); } return null; }
private void addMarkers(IFile file, Resource resource, CheckMode mode, IProgressMonitor monitor) throws OperationCanceledException { try { List<Issue> list = getValidator(resource).validate(resource, mode, getCancelIndicator(monitor)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } deleteMarkers(file, mode, monitor); if (monitor.isCanceled()) { throw new OperationCanceledException(); } createMarkers(file, list, getMarkerCreator(resource), getMarkerTypeProvider(resource)); } catch (OperationCanceledError error) { throw error.getWrapped(); } catch (CoreException e) { LOGGER.error(e.getMessage(), e); } }
@Override protected void processContext ( final MasterContext masterContext, final IProgressMonitor monitor ) throws Exception { // FIXME: this must be set from external if ( masterContext.getImplementation ().getAeServerInformationPrefix () == null || masterContext.getImplementation ().getAeServerInformationPrefix ().isEmpty () ) { return; } createInternalItem ( masterContext, "ae.server.info.ALERT_ACTIVE", "Alert active" ); createInternalItem ( masterContext, "ae.server.info.ALERT_DISABLED", "Alert disabled" ); createInternalItem ( masterContext, "ae.server.info.OK", "Summarized state OK" ); createInternalItem ( masterContext, "ae.server.info.NOT_OK", "Summarized state NOT_OK_AKN" ); createInternalItem ( masterContext, "ae.server.info.UNSAFE", "Summarized state UNSAFE" ); createInternalItem ( masterContext, "ae.server.info.INACTIVE", "Summarized state INACTIVE" ); createInternalItem ( masterContext, "ae.server.info.INIT", "Summarized state INIT" ); createInternalItem ( masterContext, "ae.server.info.NOT_OK_AKN", "Summarized state NOT_OK_AKN" ); createInternalItem ( masterContext, "ae.server.info.NOT_OK_NOT_AKN", "Summarized state NOT_OK_NOT_AKN" ); createInternalItem ( masterContext, "ae.server.info.NOT_AKN", "Summarized state NOT_OK_AKN" ); }
public void customizeManifest(Element rootElem, IProject project, IProgressMonitor monitor) throws CoreException { if( equella.isLanguageStrings() ) { Element runtime = rootElem.getChild("runtime"); addLibrary(runtime, "resources", "resources/", "resources"); JPFProject.getResourcesFolder(project).create(true, true, monitor); } Element requires = rootElem.getChild("requires"); if( equella.isGuiceModule() ) { addImport(requires, "com.tle.core.guice"); addExtension(rootElem, "com.tle.core.guice", "module", "guiceModules"); } if( equella.isLanguageStrings() ) { addImport(requires, "com.tle.common.i18n"); Element ext = addExtension(rootElem, "com.tle.common.i18n", "bundle", "strings"); addParameter(ext, "file", "lang/i18n.properties"); IFolder langFolder = JPFProject.getResourcesFolder(project).getFolder("lang"); langFolder.create(true, true, monitor); langFolder.getFile("i18n.properties").create(new ByteArrayInputStream("# add your strings".getBytes()), true, monitor); } }
@Override protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { ProjectScope projectScope = new ProjectScope(getProject()); IEclipsePreferences prefs = projectScope.getNode(BUILDER_ID); if (kind == FULL_BUILD) { fullBuild(prefs, monitor); } else { IResourceDelta delta = getDelta(getProject()); if (delta == null) { fullBuild(prefs, monitor); } else { incrementalBuild(delta, prefs, monitor); } } return null; }
/** * make sure that all attachments will be moved to the new project area * @param sourceWorkItem the original work item to which the attachments have belonged to * @param targetWorkItem work item object is it will be available in the target pa after movement * @param workItemCommon common service * @param progressMonitor progress monitor * @throws TeamRepositoryException whenever an attachment can't be moved */ @Override protected void handleAttachments(IWorkItem sourceWorkItem, IWorkItem targetWorkItem, IWorkItemCommon workItemCommon, IProgressMonitor progressMonitor) throws TeamRepositoryException { ILinkServiceLibrary lsl = (ILinkServiceLibrary) this.service.getService(ILinkService.class) .getServiceLibrary(ILinkServiceLibrary.class); IWorkItemReferences references = workItemCommon.resolveWorkItemReferences(sourceWorkItem, monitor); for (IReference attachmentReference : references.getReferences(WorkItemEndPoints.ATTACHMENT)) { if (!attachmentReference.isItemReference()) continue; IAttachmentHandle attachmentHandle = (IAttachmentHandle)((IItemReference)attachmentReference) .getReferencedItem(); IAttachment attachment = workItemCommon.getAuditableCommon() .resolveAuditable(attachmentHandle, IAttachment.SMALL_PROFILE, monitor); if (commitChanges) { this.moveAttachment(targetWorkItem, workItemCommon, attachment); continue; } this.checkAttachmentReferences(attachmentReference, lsl.findLinksBySource(attachmentReference), sourceWorkItem); this.checkAttachmentReferences(attachmentReference, lsl.findLinksByTarget(attachmentReference), sourceWorkItem); } }
static List<AttributeValue> addResolutionsAsValues(IProjectAreaHandle pa, IWorkItemServer workItemServer, IProgressMonitor monitor) throws TeamRepositoryException { List<AttributeValue> values = new ArrayList<AttributeValue>(); ICombinedWorkflowInfos workFlowInfo = workItemServer.findCachedCombinedWorkflowInfos(pa); if (workFlowInfo == null) { workFlowInfo = workItemServer.findCombinedWorkflowInfos(pa, monitor); } Identifier<IResolution>[] arridentifier = workFlowInfo.getAllResolutionIds(); int n = arridentifier.length; int n2 = 0; while (n2 < n) { Identifier<IResolution> resolutionId = arridentifier[n2]; String name = workFlowInfo.getResolutionName(resolutionId); String id = resolutionId.getStringIdentifier(); values.add(new AttributeValue(id, name)); ++n2; } return values; }
public void doSave(IProgressMonitor monitor) { jsEditor.doSave(monitor); try { // Get the jsEditor content and transfer it to the statement object statement.setExpression(IOUtils.toString(file.getContents(), "UTF-8")); } catch (Exception e) { ConvertigoPlugin.logWarning("Error writing statement jscript code '" + eInput.getName() + "' : " + e.getMessage()); } statement.hasChanged = true; // Refresh tree ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView(); if (projectExplorerView != null) { projectExplorerView.updateDatabaseObject(statement); } }
@Override public void process ( final OscarContext ctx, final EquinoxApplication application, final IProgressMonitor monitor ) { try { final Collection<Object> exporters = EcoreUtil.getObjectsByType ( application.getModules (), ModbusPackage.Literals.MODBUS_EXPORTER ); for ( final Object exp : exporters ) { assert exp instanceof ModbusExporter; processExporter ( ctx, application, (ModbusExporter)exp, monitor ); } } finally { monitor.done (); } }
public static Layer getOrCreateDebugLayer( DiagramExtensionDescription descriptionExtension, UserColor instructionColor, String layerName, IProgressMonitor monitor) { final Layer res; Layer existingLayer = null; for (Layer layer : descriptionExtension.getLayers()) { if ("Debug".equals(layer.getName())) { existingLayer = layer; break; } } if (existingLayer != null) { res = existingLayer; } else { res = createLayer(descriptionExtension, instructionColor, layerName, monitor); } return res; }
@Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { ResourcesPlugin.getWorkspace().build(configs, CLEAN_BUILD, true, monitor); return OK_STATUS; } catch (final CoreException e) { final String message = "Error while rebuilding workspace content."; LOGGER.error(message, e); return new Status(ERROR, N4JS_PLUGIN_ID, message, e); } }
/** * Launches the generation. * * @param monitor * This will be used to display progress information to the user. * @throws IOException * Thrown when the output cannot be saved. * @generated */ public void doGenerate(IProgressMonitor monitor) throws IOException { if (!targetFolder.getLocation().toFile().exists()) { targetFolder.getLocation().toFile().mkdirs(); } monitor.subTask("Loading..."); org.eclipse.cmf.occi.core.gen.connector.main.Main gen0 = new org.eclipse.cmf.occi.core.gen.connector.main.Main(modelURI, targetFolder.getLocation().toFile(), arguments); monitor.worked(1); String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("org.eclipse.cmf.occi.core.gen.connector", "org.eclipse.cmf.occi.core.gen.connector.main.Main", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); gen0.setGenerationID(generationID); gen0.doGenerate(BasicMonitor.toMonitor(monitor)); }
protected IRunnableWithProgress createResourceOperation(IFolder folder,InitialBuildPolicies policies) { WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor monitor) { String resource = ""; String targetFile = ""; try { for (int i = 0; i < resources.length; i++) { resource = resources[i]; targetFile = targetFiles[i]; IFile file = create(folder, resource, targetFile, monitor); if (file != null) { createdResources.add(file); policies.setFile(file); policies.run(); BasicNewResourceWizard.selectAndReveal(file, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } } } catch (Exception exception) { ResourceManager.logException(exception, "Unable to create " + resource); } finally { monitor.done(); } } }; return operation; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void doSaveAs ( URI uri, IEditorInput editorInput ) { ( editingDomain.getResourceSet ().getResources ().get ( 0 ) ).setURI ( uri ); setInputWithNotify ( editorInput ); setPartName ( editorInput.getName () ); IProgressMonitor progressMonitor = getActionBars ().getStatusLineManager () != null ? getActionBars ().getStatusLineManager ().getProgressMonitor () : new NullProgressMonitor (); doSave ( progressMonitor ); }
public static UserColorsPalette getOrCreateColotPalette( DiagramExtensionDescription descriptionExtension, String languageName, IProgressMonitor monitor) { final UserColorsPalette res; final String paletteName = languageName + " Palette"; final Group group = (Group) descriptionExtension.eContainer().eContainer(); UserColorsPalette existingPalette = null; for (UserColorsPalette palette : group.getUserColorsPalettes()) { if (paletteName.equals(palette.getName())) { existingPalette = palette; break; } } if (existingPalette != null) { res = existingPalette; } else { res = DescriptionPackage.eINSTANCE.getDescriptionFactory() .createUserColorsPalette(); res.setName(paletteName); group.getUserColorsPalettes().add(res); } return res; }
/** * @param file * @throws InvocationTargetException * @throws CoreException * @throws InterruptedException */ public static void generateDefaultGraphConversion(IWorkbenchWindow ww, IFile file, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, CoreException { AbstractPostConversion converter = getDefaultGraphConversion(file,false); ConversionRunnable runnable = converter.createConversionRunnable(ww); runnable.run(monitor); }
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int totalUnitsOfWork = IProgressMonitor.UNKNOWN; monitor.beginTask("Performing read. Please wait...", totalUnitsOfWork); // This only performs the tasks try { client.setCredentials(Constants.USERNAME, Constants.PASSWORD); System.out.println(getClient().getUser()); issues = loadRequirements(); } catch (IOException e) { e.printStackTrace(); } monitor.done(); }
@Override public void doSave(IProgressMonitor monitor) { try { CompositeNode node = (CompositeNode) root.getModel(); FileEditorInput inp = (FileEditorInput) getEditorInput(); inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getIntFinalAssemblyEditorContent(node)), IFile.FORCE, monitor); getCommandStack().markSaveLocation(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void removeProject(ToBeBuilt toBeBuilt, IProject project, IProgressMonitor monitor) { storageMapper.collectNfarURIs(project, toBeBuilt.getToBeDeleted()); Iterator<Map.Entry<String, Set<URI>>> iterator = knownEntries.entrySet().iterator(); String keyPrefix = project.getName() + "|"; while (iterator.hasNext()) { String key = iterator.next().getKey(); if (key.startsWith(keyPrefix)) { iterator.remove(); } } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void doSaveAs(URI uri, IEditorInput editorInput) { (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); setInputWithNotify(editorInput); setPartName(editorInput.getName()); IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor(); doSave(progressMonitor); }
private void cleanBuildDependencies(final IProgressMonitor monitor, final MultiStatus status, final Iterable<java.net.URI> toBeDeleted, final Collection<File> adaptedPackages, boolean triggerCleanbuild) { logger.logInfo("Registering new projects... [step 4 of 4]"); monitor.setTaskName("Registering new projects... [step 4 of 4]"); // nothing to do in the headless case. TODO inject logic instead? if (Platform.isRunning()) { logger.logInfo("Platform is running."); final Iterable<java.net.URI> toBeUpdated = from(adaptedPackages).transform(file -> file.toURI()); final NpmProjectAdaptionResult adaptionResult = NpmProjectAdaptionResult.newOkResult(toBeUpdated, toBeDeleted); logger.logInfo("Call " + externalLibraryWorkspace + " to register " + toBeUpdated + " and de-register " + toBeDeleted); externalLibraryWorkspace.registerProjects(adaptionResult, monitor, triggerCleanbuild); } else { logger.logInfo("Platform is not running."); } logger.logInfo("Finished registering projects."); if (status.isOK()) logger.logInfo("Successfully finished installing packages."); else logger.logInfo("There were errors during installation, see logs for details."); logger.logInfo(LINE_DOUBLE); }
@Override protected IStatus run(IProgressMonitor monitor) { try { boolean more = false; do { IJavaProject[] projects = null; IClasspathContainer[] containers = null; synchronized( fProjects ) { projects = fProjects.toArray(new IJavaProject[fProjects.size()]); containers = fContainers.toArray(new IClasspathContainer[fContainers.size()]); fProjects.clear(); fContainers.clear(); } JavaCore.setClasspathContainer(JPFClasspathPlugin.CONTAINER_PATH, projects, containers, monitor); synchronized( fProjects ) { more = !fProjects.isEmpty(); } } while( more ); } catch( JavaModelException e ) { return e.getStatus(); } return Status.OK_STATUS; }
@Override protected void doRun(IMarker marker,IProgressMonitor monitor) { try { String key = this.getEntryKey(marker); String value = p.getProperty(key); String pathGenerator = this.getPathGenerator(marker); value = value.replace(pathGenerator, this.getTargetGeneratorPath()); this.setValue(key, value); } catch (Exception e) { ResourceManager.logException(e); } }
@Override protected IStatus run(IProgressMonitor monitor) { while (!terminated) { // wait for new events if (events.isEmpty()) { try { synchronized(this) { wait(); } } catch (InterruptedException e) { // nothing to do here } } if (!monitor.isCanceled()) { IDSLDebugEvent event = null; synchronized(events) { if (!events.isEmpty()) { event = events.remove(0); } } if (event != null) { handleEvent(event); } } else { terminate(); } } return Status.OK_STATUS; }
private List<Location> findImplementations(IType type, IProgressMonitor monitor) throws JavaModelException { IType[] results = type.newTypeHierarchy(monitor).getAllSubtypes(type); final List<Location> result = new ArrayList<>(); for (IType t : results) { ICompilationUnit compilationUnit = (ICompilationUnit) t.getAncestor(IJavaElement.COMPILATION_UNIT); if (compilationUnit == null) { continue; } Location location = null; // JDTUtils.toLocation(t); result.add(location); } return result; }
@Override public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { String newName = getArguments().getNewName(); String newExt = newName.substring(newName.lastIndexOf(".")+1); if("job".equals(modifiedResource.getFileExtension())) { if(!("job".equals(newExt))) { return RefactoringStatus.createFatalErrorStatus("Changing extension of job file is not allowed"); } } else if("job".equals(newExt)) { return RefactoringStatus.createFatalErrorStatus("Changing extension to .job not allowed." + "Please create a new job file."); } else if(CustomMessages.ProjectSupport_JOBS.equals(modifiedResource.getFullPath().segment(1)) && !newExt.matches("job|xml")) { return RefactoringStatus.createFatalErrorStatus("Only .job and .xml files can be stored in this folder" ); } else if(modifiedResource.getFileExtension().matches("xml|properties") || (newExt.matches("xml|properties"))){ if(ResourceChangeUtil.isGeneratedFile(modifiedResource.getName() ,modifiedResource.getProject())) { return RefactoringStatus.createFatalErrorStatus( ".xml or .properties file cannot be renamed. " + "Rename the .job file to rename the xml and properties file"); } else if(ResourceChangeUtil.isGeneratedFile(newName,modifiedResource.getProject())) { return RefactoringStatus.createFatalErrorStatus("Generated file with same name exists.Please choose a different name"); } else if(("properties".equals(modifiedResource.getFileExtension()) || "properties".equals(newExt)) && !modifiedResource.getFullPath().segment(1).equals(CustomMessages.ProjectSupport_PARAM)) { return RefactoringStatus.createFatalErrorStatus("properties file can only be saved in param folder."); } } return new RefactoringStatus(); }
@Override public void processContext ( final MasterContext app, final IProgressMonitor monitor ) throws Exception { final AbstractComponentItemCreator creator = new SummariesItemCreatorImpl ( app, null, this.system ); new TypeWalker<> ( SummaryGroup.class ).walk ( app.getImplementation (), new TypeVisitor<SummaryGroup> () { @Override public void visit ( final SummaryGroup group ) throws Exception { processGroup ( app.getImplementation (), group, creator ); } } ); }
static AttributeValue getCategory(Object t_val, IWorkItemServer workItemServer, TeamRawService service, IProgressMonitor monitor) throws TeamRepositoryException { IRepositoryItemService itemService = service.getService(IRepositoryItemService.class); ICategoryHandle catHandle = (ICategoryHandle)t_val; ICategory category = (ICategory) itemService.fetchItem(catHandle, null); CategoryId id = category.getCategoryId(); String idString = id.getInternalRepresentation(); String fullPathname = workItemServer.resolveHierarchicalName(category, monitor); return new AttributeValue(idString, fullPathname); }
/** * Reloads the external libraries by re-indexing all registered external projects that are do not exist in the * workspace. * * @param refreshNpmDefinitions * if {@code true}, then the type definition files will be reloaded/refreshed for all {@code npm} * packages. * @param monitor * the monitor for the process. * @throws InvocationTargetException * if any unexpected error occurs during the refresh process. */ public void reloadLibraries(final boolean refreshNpmDefinitions, final IProgressMonitor monitor) throws InvocationTargetException { final ISchedulingRule rule = builderHelper.getRule(); try { Job.getJobManager().beginRule(rule, monitor); reloadLibrariesInternal(refreshNpmDefinitions, monitor); } catch (final OperationCanceledException e) { LOGGER.info("User abort."); } finally { Job.getJobManager().endRule(rule); } }
@Override protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { try { //System.out.println("doSaveDocument "); ResourceSet resourceSet = createResourceSet(); XtextResource xtextResource = (XtextResource) resourceSet.createResource(URI.createURI("temp.occi")); InputStream is = new ByteArrayInputStream(document.get().getBytes()); xtextResource.load(is, Collections.EMPTY_MAP); is.close(); URI uri = URI.createPlatformResourceURI( ((org.eclipse.ui.part.FileEditorInput) element).getFile().getFullPath().toString(), true); //resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); //System.out.println("uriii "+uri); Resource xmiResource = resourceSet.getResource(uri, true); ((XMLResource) xmiResource).getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware()); xmiResource.getContents().clear(); xmiResource.getContents().addAll(xtextResource.getContents()); // SUPER IMPORTANT to avoid to have references to temp.occi EcoreUtil.resolveAll(xmiResource); xmiResource.save(Collections.EMPTY_MAP); } catch (IOException e) { throw new CoreException( new Status(IStatus.ERROR, "org.occiware.clouddesigner.occi.xtext.ui", "Failed to save", e)); } }
@Override public void run(IMarker marker) { Job job = new WorkspaceJob("GW4E Fix Job") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { fix(marker, monitor); return Status.OK_STATUS; } }; job.setRule(marker.getResource().getProject()); job.setUser(true); job.schedule(); }