/** * TODO merge monitor */ private void generateEMFCode(String genModelPath) throws InvocationTargetException, InterruptedException { /* * Generate model & edit */ List<URI> uris = new ArrayList<URI>(); uris.add(URI.createFileURI(genModelPath)); List<GenModel> genModels = GeneratorUIUtil.loadGenModels(new NullProgressMonitor(), uris, shell); GeneratorUIUtil.GeneratorOperation editOp = new GeneratorUIUtil.GeneratorOperation(shell); editOp.addGeneratorAndArguments(GenModelUtil.createGenerator(genModels.get(0)), genModels.get(0), "org.eclipse.emf.codegen.ecore.genmodel.generator.EditProject", "Edit"); editOp.addGeneratorAndArguments(GenModelUtil.createGenerator(genModels.get(0)), genModels.get(0), "org.eclipse.emf.codegen.ecore.genmodel.generator.ModelProject", "Model"); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.run(true, true, editOp); }
/** Tears down the external libraries. */ protected void tearDownExternalLibraries(boolean tearDownShippedCode) throws Exception { ((TypeDefinitionGitLocationProviderImpl) gitLocationProvider).setGitLocation(PUBLIC_DEFINITION_LOCATION); final URI nodeModulesLocation = locationProvider.getTargetPlatformNodeModulesLocation(); externalLibraryPreferenceStore.remove(nodeModulesLocation); final IStatus result = externalLibraryPreferenceStore.save(new NullProgressMonitor()); assertTrue("Error while saving external library preference changes.", result.isOK()); if (tearDownShippedCode) { shippedCodeInitializeTestHelper.teardowneBuiltIns(); } // cleanup leftovers in the file system File nodeModuleLocationFile = new File(nodeModulesLocation); assertTrue("Provided npm location does not exist.", nodeModuleLocationFile.exists()); assertTrue("Provided npm location is not a folder.", nodeModuleLocationFile.isDirectory()); FileDeleter.delete(nodeModuleLocationFile); assertFalse("Provided npm location should be deleted.", nodeModuleLocationFile.exists()); waitForAutoBuild(); super.tearDown(); }
/** * Loads (and indexes) all the required external libraries. Also imports all the workspace projects. */ @Before public void setupWorkspace() throws Exception { final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); assertTrue("Expected empty workspace. Projects were in workspace: " + Arrays.toString(projects), 0 == projects.length); final URI externalRootLocation = getResourceUri(PROBANDS, EXT_LOC); externalLibraryPreferenceStore.add(externalRootLocation); final IStatus result = externalLibraryPreferenceStore.save(new NullProgressMonitor()); assertTrue("Error while saving external library preference changes.", result.isOK()); waitForAutoBuild(); for (final String projectName : ALL_PROJECT_IDS) { final File projectsRoot = new File(getResourceUri(PROBANDS, WORKSPACE_LOC)); ProjectUtils.importProject(projectsRoot, projectName); } waitForAutoBuild(); }
/***/ @Test public void runClientWithTwoClosedWorkspaceProjectsWithTransitiveDependency() throws CoreException { for (final String libProjectName : newArrayList(PB, PD)) { getProjectByName(libProjectName).close(new NullProgressMonitor()); waitForAutoBuildCheckIndexRigid(); } final ProcessResult result = runClient(); // @formatter:off assertEquals("Unexpected output after running the client module: " + result, "Workspace A<init>" + NL + "External B<init>" + NL + "Workspace C<init>" + NL + "External D<init>" + NL, result.getStdOut()); // @formatter:on }
/***/ @Test public void runClientWithTwoClosedWorkspaceProjectsWithDirectDependency() throws CoreException { for (final String libProjectName : newArrayList(PB, PC)) { getProjectByName(libProjectName).close(new NullProgressMonitor()); waitForAutoBuildCheckIndexRigid(); } final ProcessResult result = runClient(); // @formatter:off assertEquals("Unexpected output after running the client module: " + result, "Workspace A<init>" + NL + "External B<init>" + NL + "External C<init>" + NL + "Workspace D<init>" + NL, result.getStdOut()); // @formatter:on }
/***/ @Test public void runClientWithAllDeletedWorkspaceProjects() throws CoreException { for (final String libProjectName : LIB_PROJECT_IDS) { getProjectByName(libProjectName).delete(true, new NullProgressMonitor()); waitForAutoBuildCheckIndexRigid(); } final ProcessResult result = runClient(); // @formatter:off assertEquals("Unexpected output after running the client module: " + result, "External A<init>" + NL + "External B<init>" + NL + "External C<init>" + NL + "External D<init>" + NL, result.getStdOut()); // @formatter:on }
private void updateMarker(IResource resource, String message, int start, int end, int severity, IMarker marker) { try { marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, severity); if (resource.getType() != IResource.FILE) { return; } IFile file = (IFile) resource; ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); ITextFileBuffer textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); if (textFileBuffer == null) { manager.connect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor()); textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); } IDocument document = textFileBuffer.getDocument(); marker.setAttribute(IMarker.CHAR_START, start); marker.setAttribute(IMarker.CHAR_END, end); marker.setAttribute(IMarker.LINE_NUMBER, document.getLineOfOffset(start) + 1); } catch (CoreException | BadLocationException e) { e.printStackTrace(); } }
public File getModelOutputFile (String outputName) throws CoreException, InterruptedException, FileNotFoundException { IFile file = ResourceManager.toIFile(sourceFileModel); IFolder folder = ResourceManager.ensureFolder(file.getProject(), ".gw4eoutput", new NullProgressMonitor()); IFile outfile = folder.getFile(new Path(outputName)); InputStream source = new ByteArrayInputStream("".getBytes()); if (outfile.exists()) { outfile.setContents(source, IResource.FORCE, new NullProgressMonitor()); } else { outfile.create(source, IResource.FORCE, new NullProgressMonitor()); } outfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); long max = System.currentTimeMillis() + 15 * 1000; while (true) { IFile out = folder.getFile(new Path(outputName)); if (out.exists()) break; if (System.currentTimeMillis() > max) { throw new InterruptedException (out.getFullPath() + " does not exist."); } Thread.sleep(500); } return ResourceManager.toFile(outfile.getFullPath()); }
/** * @param testInterface * @return * @throws JavaModelException */ public static boolean isGraphWalkerExecutionContextClass(ICompilationUnit unit) throws JavaModelException { IType[] types = unit.getAllTypes(); if (types == null || types.length == 0) { ResourceManager.logInfo(unit.getJavaProject().getProject().getName(), "getAllTypes return null" + unit.getPath()); return false; } IType execContextType = unit.getJavaProject().findType(ExecutionContext.class.getName()); for (int i = 0; i < types.length; i++) { IType type = types[i]; String typeNname = type.getFullyQualifiedName(); String compilationUnitName = JDTManager.getJavaFullyQualifiedName(unit); if (typeNname.equals(compilationUnitName)) { try { ITypeHierarchy th = types[0].newTypeHierarchy(new NullProgressMonitor()); return th.contains(execContextType); } catch (Exception e) { ResourceManager.logException(e); } } } return false; }
private void touchProject(IProject project) { if( WorkspacePluginModelManager.isPluginProject(project) ) { try { // set session property on project // to be read and reset in ManifestConsistencyChecker project.setSessionProperty(JPFClasspathPlugin.TOUCH_PROJECT, Boolean.TRUE); // touch project so that ManifestConsistencyChecker#build(..) // gets invoked project.touch(new NullProgressMonitor()); } catch( CoreException e ) { JPFClasspathLog.logError(e); } } }
@Override public void execute() throws CoreException, IOException, MalformedURLException { Logger log = Logger.getLogger(this.getClass().getName()); if(log.isLoggable(Level.FINE)) { log.log(Level.FINE, "executing GetTaskDataCommand for attachment id: {0}", ta.getValue()); // NOI18N } AbstractTaskAttachmentHandler taskAttachmentHandler = repositoryConnector.getTaskAttachmentHandler(); if (!taskAttachmentHandler.canGetContent(taskRepository, task)) { throw new IOException("Cannot get content for attachment with id: " + ta.getValue()); } InputStream is = taskAttachmentHandler.getContent(taskRepository, task, ta, new NullProgressMonitor()); try { byte [] buffer = new byte[4096]; int n; while ((n = is.read(buffer)) != -1) { os.write(buffer, 0, n); } } finally { is.close(); } }
/** * 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; }
/** * @param subJobXMLPath * @param parameterFilePath * @param parameterFile * @param subJobFile * @param importFromPath * @param subjobPath * @return * @throws InstantiationException * @throws IllegalAccessException * @throws InvocationTargetException * @throws NoSuchMethodException * @throws JAXBException * @throws ParserConfigurationException * @throws SAXException * @throws IOException * @throws CoreException * @throws FileNotFoundException */ public static Container createSubjobInSpecifiedFolder(IPath subJobXMLPath, IPath parameterFilePath, IFile parameterFile, IFile subJobFile, IPath importFromPath,String subjobPath) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, JAXBException, ParserConfigurationException, SAXException, IOException, CoreException, FileNotFoundException { UiConverterUtil converterUtil = new UiConverterUtil(); Object[] subJobContainerArray=null; IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(subJobXMLPath); File file = new File(xmlFile.getFullPath().toString()); if (file.exists()) { subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true); } else { IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(parameterFilePath.segment(1)); IFolder iFolder = iProject.getFolder(subjobPath.substring(0, subjobPath.lastIndexOf('/'))); if (!iFolder.exists()) { iFolder.create(true, true, new NullProgressMonitor()); } IFile subjobXmlFile = iProject.getFile(subjobPath); subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true); if (!subjobXmlFile.exists() && subJobContainerArray[1] == null) { subjobXmlFile.create(new FileInputStream(importFromPath.toString()), true, new NullProgressMonitor()); } } return (Container) subJobContainerArray[0]; }
public NbTask createSubtask (NbTask parentTask) throws CoreException { ensureTaskListLoaded(); TaskRepository taskRepository = taskRepositoryManager.getRepository(parentTask.getDelegate().getRepositoryUrl()); if (taskRepository == null || parentTask.isUnsubmittedRepositoryTask()) { throw new IllegalStateException("Task repository: " + parentTask.getDelegate().getRepositoryUrl() + " - parent: " + parentTask.isUnsubmittedRepositoryTask()); } AbstractTask task = createNewTask(taskRepository); AbstractRepositoryConnector repositoryConnector = taskRepositoryManager.getRepositoryConnector(taskRepository.getConnectorKind()); AbstractTaskDataHandler taskDataHandler = repositoryConnector.getTaskDataHandler(); TaskAttributeMapper attributeMapper = repositoryConnector.getTaskDataHandler().getAttributeMapper(taskRepository); TaskData taskData = new TaskData(attributeMapper, repositoryConnector.getConnectorKind(), taskRepository.getRepositoryUrl(), ""); taskDataHandler.initializeSubTaskData(taskRepository, taskData, parentTask.getTaskDataState().getRepositoryData(), new NullProgressMonitor()); initializeTask(repositoryConnector, taskData, task, taskRepository); return MylynSupport.getInstance().toNbTask(task); }
/** * @param container * @param filename * @throws CoreException */ public static void renameFile(IContainer container, String oldName, String newName) throws CoreException { if (oldName.equals(newName)) return; IResource[] members = container.members(); for (IResource member : members) { if (member instanceof IContainer) { renameFile((IContainer) member, oldName, newName); } else if (member instanceof IFile) { IFile file = (IFile) member; if (file.getName().equals(oldName)) { IProgressMonitor monitor = new NullProgressMonitor(); IPath path = file.getFullPath().removeLastSegments(1).append(newName); ResourceManager.logInfo(file.getProject().getName(), "Renaming " + file.getFullPath() + " into " + path); file.copy(path, true, monitor); file.delete(true, monitor); } } } }
@Override public void createPartControl(Composite parent) { if (system==null) { parent.setLayout(new GridLayout(1, false)); final Label msg = new Label(parent, SWT.WRAP); msg.setText("No plotting system found available.\nThere are probably no bundles providing plotting in the run configuration.\nThese may be obtained from dawn p2, for instance:\nhttp://opengda.org/DawnDiamond/2.0/updates/release/\n\nA static image is shown for our enjoyment."); final Label img = new Label(parent, SWT.NONE); img.setImage(XcenActivator.getImageDescriptor("icons/xstall.png").createImage()); return; } super.createPartControl(parent); // TODO Hard coded an x-stall, should come from current data acquisition. try { final File loc = new File(BundleUtils.getBundleLocation(XcenActivator.PLUGIN_ID), "icons/xstall.png"); final IDataset image = service.getDataset(loc.getAbsolutePath(), new IMonitor.Stub()); system.createPlot2D(image, null, new NullProgressMonitor()); } catch (Exception ne) { logger.error("Cannot load dataset!", ne); } }
@Override public void run() { if (GenerationUtils.validate(containerName)) { Shell shell = Display.getDefault().getActiveShell(); boolean confirm = MessageDialog.openQuestion(shell, "Confirm Create", "Existing Files will be cleared. Do you wish to continue?"); if (confirm) { wsRoot = ResourcesPlugin.getWorkspace().getRoot(); names = StringUtils.split(containerName, "/"); wsRootRes = wsRoot.findMember(new Path("/" + names[0])); prj = wsRootRes.getProject(); steps = prj.getFolder("target/Steps"); File root = new File(steps.getLocation().toOSString()); if (root.exists()) { GenerationUtils.clearCreatedFolders(root); } for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { try { project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { } } } } }
/**Refreshes given {@link DRepresentation} in the given {@link TransactionalEditingDomain}. * @param transactionalEditingDomain the {@link TransactionalEditingDomain} * @param representations the {@link List} of {@link DRepresentation} to refresh */ public void refreshRepresentations( final TransactionalEditingDomain transactionalEditingDomain, final List<DRepresentation> representations) { // TODO prevent the editors from getting dirty if (representations.size() != 0) { final RefreshRepresentationsCommand refresh = new RefreshRepresentationsCommand( transactionalEditingDomain, new NullProgressMonitor(), representations); try { CommandExecution.execute(transactionalEditingDomain, refresh); } catch (Exception e){ String repString = representations.stream().map(r -> r.getName()).collect(Collectors.joining(", ")); Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to refresh Sirius representation(s)["+repString+"], we hope to be able to do it later", e)); } } }
@Override protected void setInput ( final IEditorInput input ) { final ConfigurationEditorInput configurationInput = (ConfigurationEditorInput)input; if ( !this.nested ) { configurationInput.performLoad ( new NullProgressMonitor () ); } this.dirtyValue = configurationInput.getDirtyValue (); this.dirtyValue.addValueChangeListener ( new IValueChangeListener () { @Override public void handleValueChange ( final ValueChangeEvent event ) { firePropertyChange ( IEditorPart.PROP_DIRTY ); } } ); super.setInput ( input ); }
private static IProject importProject(File probandsFolder, String projectName, boolean prepareDotProject) throws Exception { File projectSourceFolder = new File(probandsFolder, projectName); if (!projectSourceFolder.exists()) { throw new IllegalArgumentException("proband not found in " + projectSourceFolder); } if (prepareDotProject) { prepareDotProject(projectSourceFolder); } IProgressMonitor monitor = new NullProgressMonitor(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName); IProject project = workspace.getRoot().getProject(projectName); project.create(newProjectDescription, monitor); project.open(monitor); if (!project.getLocation().toFile().exists()) { throw new IllegalArgumentException("test project correctly created in " + project.getLocation()); } IOverwriteQuery overwriteQuery = new IOverwriteQuery() { @Override public String queryOverwrite(String file) { return ALL; } }; ImportOperation importOperation = new ImportOperation(project.getFullPath(), projectSourceFolder, FileSystemStructureProvider.INSTANCE, overwriteQuery); importOperation.setCreateContainerStructure(false); importOperation.run(monitor); return project; }
@Override public void projectPropertyUpdated(String projectName, String property, String[] oldValues, String[] newValues) { if (PreferenceManager.BUILD_POLICIES_FILENAME.equals(property)) { IProject project = ResourceManager.getProject(projectName); String previousCacheName = makeFileCacheName(oldValues.length > 0 ? oldValues[0] : ""); try { ResourceManager.renameFile(project, previousCacheName ,makeFileCacheName(newValues[0])); } catch (CoreException e) { ResourceManager.logException(e); } clean(project, previousCacheName, new NullProgressMonitor()); } }
/** * <!-- 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 IPackageFragmentRoot addFolderToClassPath(IJavaProject jproject, String containerName) throws CoreException { IProject project = jproject.getProject(); IFolder folder = project.getFolder(containerName); if (!folder.exists()) { createFolder(folder, false, true, new NullProgressMonitor()); } IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null); addToClasspath(jproject, cpe); return jproject.getPackageFragmentRoot(folder); }
private void delete (IFile file) { try { file.delete(true, new NullProgressMonitor()); while (file.exists()) { Thread.sleep(1000); } } catch (Exception e) { } }
/** * Tries to make sure the external libraries are cleaned from the Xtext index. */ @After @Override public void tearDown() throws Exception { final URI externalRootLocation = getResourceUri(PROBANDS, EXT_LOC); externalLibraryPreferenceStore.remove(externalRootLocation); final IStatus result = externalLibraryPreferenceStore.save(new NullProgressMonitor()); assertTrue("Error while saving external library preference changes.", result.isOK()); waitForAutoBuild(); super.tearDown(); }
public static IFile createDummyClassWitherror(IJavaProject project) throws CoreException, IOException { String clazz = "import org.graphwalker.core.machine.ExecutionContext ; public class Dummy1 extends org.gw4e.core.machine.ExecutionContext {}"; IFolder folder = project.getProject().getFolder("src/test/java"); IPackageFragmentRoot srcFolder = project.getPackageFragmentRoot(folder); IPackageFragment pkg = srcFolder.getPackageFragment(""); ICompilationUnit cu = pkg.createCompilationUnit("Dummy.java", clazz, false, new NullProgressMonitor()); cu.save(new NullProgressMonitor (), true); return (IFile) cu.getResource(); }
private void addClassPathEntry(IPath tempSrcFolder) throws JavaModelException { IJavaProject javaProject=JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject()); oldClasspathEntry=javaProject.getRawClasspath(); IClasspathEntry[] newClasspathEntry=new IClasspathEntry[oldClasspathEntry.length+1]; for(int index=0;index<newClasspathEntry.length-1;index++){ if(oldClasspathEntry[index].getPath().equals(tempSrcFolder)) return ; newClasspathEntry[index]=javaProject.getRawClasspath()[index]; } newClasspathEntry[newClasspathEntry.length-1]=JavaCore.newSourceEntry(tempSrcFolder); javaProject.setRawClasspath(newClasspathEntry, new NullProgressMonitor()); }
/** * Tries to close the project with the given name. */ private void closeProject(String projectName) { IN4JSEclipseProject n4jsProject = eclipseN4jsCore.findProject(URI.createPlatformResourceURI(projectName, true)) .orNull(); if (null == n4jsProject) { throw new IllegalArgumentException("Could not find project with name '" + projectName + "'"); } try { n4jsProject.getProject().close(new NullProgressMonitor()); } catch (CoreException e) { throw new IllegalArgumentException( "Could not close project with name '" + projectName + "': " + e.getMessage()); } }
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException { if (!folder.exists()) { IContainer parent = folder.getParent(); if (parent instanceof IFolder) { createFolder((IFolder) parent, force, local, new NullProgressMonitor()); } folder.create(force, local, monitor); } }
/** * Enable OCCI Extension viewpoints. * * @param session * Session */ public static void enableViewpoint(final Session session, final String viewpointURI) { if (session != null) { session.getTransactionalEditingDomain().getCommandStack() .execute(new RecordingCommand(session.getTransactionalEditingDomain()) { @Override protected void doExecute() { final ViewpointSelectionCallback selection = new ViewpointSelectionCallback(); selection.selectViewpoint( ViewpointRegistry.getInstance().getViewpoint(URI.createURI(viewpointURI)), session, new NullProgressMonitor()); } }); } }
@Override protected void okPressed() { final WorkingSet[] newItems = Arrays2.filter(tableViewer.getCheckedElements(), WorkingSet.class); final WorkingSet[] newAllItems = from(Arrays.asList(tableViewer.getTable().getItems())) .transform(item -> item.getData()).filter(WorkingSet.class).toArray(WorkingSet.class); diff.set(diffBuilder.build(newItems, newAllItems)); manager.updateState(diff.get()); manager.saveState(new NullProgressMonitor()); super.okPressed(); }
@Override public void reset() { try { getPreferences().clear(); getPreferences().flush(); discardWorkingSetState(); discardWorkingSetCaches(); restoreState(new NullProgressMonitor()); } catch (BackingStoreException e) { LOGGER.error("Error occurred while clearing persisted state.", e); } }
/** * Reloads this working set manager by invalidating its cache and re-triggering the initialization logic. */ protected void reload() { discardWorkingSetCaches(); saveState(new NullProgressMonitor()); if (workingSetManagerBroker.isWorkingSetTopLevel()) { final WorkingSetManager activeManager = workingSetManagerBroker.getActiveManager(); if (activeManager != null) { if (activeManager.getId().equals(getId())) { workingSetManagerBroker.refreshNavigator(); } } } }
public static void create(IProject project, String groupId, String version, String artifactId, String name, String gwversion) throws IOException, CoreException { String newline = System.getProperty("line.separator"); URL url = IOHelper.class.getResource("pom.xml"); InputStream input = url.openStream(); StringBuffer sb = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line).append(newline); } String data = String.format(sb.toString(), groupId, version, artifactId, name, gwversion); IFile pom = project.getFile("pom.xml"); pom.create(new ByteArrayInputStream(data.getBytes()), true, new NullProgressMonitor()); }
/** * Creates a new working set broker instance with the given injector and status helper arguments. The injector is * used to inject members into the available contributions. Also restores its most recent state from the preference * store. * * @param injector * the injector for initializing the contributions. * @param statusHelper * convenient way to create {@link IStatus status} instances. * */ @Inject private WorkingSetManagerBrokerImpl(final Injector injector, final StatusHelper statusHelper) { this.injector = injector; this.statusHelper = statusHelper; this.activeWorkingSetManager = new AtomicReference<>(); this.workingSetTopLevel = new AtomicBoolean(false); this.alreadyQueuedNavigatorRefresh = new AtomicBoolean(false); this.contributions = initContributions(); topLevelElementChangeListeners = newHashSet(); workingSetManagerStateChangeListeners = newHashSet(); restoreState(new NullProgressMonitor()); if (EMFPlugin.IS_ECLIPSE_RUNNING) { final String pluginId = N4JSActivator.getInstance().getBundle().getSymbolicName(); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { workspace.addSaveParticipant(pluginId, new SaveParticipantAdapter() { @Override public void saving(final ISaveContext context) throws CoreException { saveState(new NullProgressMonitor()); } }); } catch (final CoreException e) { LOGGER.error("Error occurred while attaching save participant to workspace.", e); } } }
@Test public void testCreateFileIFileIProgressMonitor() throws Exception { IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true); IFile f = ResourceManager.getIFileFromQualifiedName(project.getProject().getName(), "SimpleImpl"); f.delete(true, new NullProgressMonitor()); assertFalse(f.exists()); ResourceManager.createFile(f, new NullProgressMonitor()); assertTrue(f.exists()); }