org.eclipse.core.resources.ResourcesPlugin Java Examples
The following examples show how to use
org.eclipse.core.resources.ResourcesPlugin.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BluemixUtil.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
public static DominoDesignerProject getDesignerProjectFromWorkspace(String nsfName) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (root != null) { IProject[] projects = root.getProjects(); for (int i = 0; i < projects.length; i++) { try { DominoDesignerProject ddp = (DominoDesignerProject)DominoResourcesPlugin.getDominoDesignerProject(projects[i]); if (ddp != null) { String path = ddp.getNsfPath(); if (StringUtil.equalsIgnoreCase(path, nsfName)) { return ddp; } } } catch (NsfException e) { if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(BluemixUtil.class, "getDesignerProjectFromWorkspace", e, "Failed to get Domino Designer Project"); // $NON-NLS-1$ $NLE-BluemixUtil.FailedtogetDominoDesignerProject-2$ } } } } return null; }
Example #2
Source File: ProjectLocationAwareWorkingSetManager.java From n4js with Eclipse Public License 1.0 | 6 votes |
private Multimap<String, IProject> initProjectLocation() { final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IProject[] projects = root.getProjects(); final Multimap<String, IProject> locations = HashMultimap.create(); // initialize the repository paths repositoryPaths = repositoriesProvider.getWorkspaceRepositories().stream() .map(r -> r.getDirectory().getParentFile().toPath()).collect(Collectors.toSet()); for (final IProject project : projects) { if (isRemoteEditNature(project)) { continue; } final String pair = getWorkingSetId(project); locations.put(pair, project); } return locations; }
Example #3
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 6 votes |
@Override public void unconfigure(IProject project, IProgressMonitor monitor) throws CoreException { try { final SubMonitor mon = SubMonitor.convert(monitor, 4); final IProjectDescription description = project.getDescription(); final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds())); natures.remove(SARLEclipseConfig.XTEXT_NATURE_ID); natures.remove(SARLEclipseConfig.NATURE_ID); final String[] newNatures = natures.toArray(new String[natures.size()]); mon.worked(1); final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures); mon.worked(1); if (status.getCode() == IStatus.OK) { description.setNatureIds(newNatures); project.setDescription(description, mon.newChild(1)); safeRefresh(project, mon.newChild(1)); } else { throw new CoreException(status); } } finally { monitor.done(); } }
Example #4
Source File: FileProcessOutputSink.java From tlaplus with MIT License | 6 votes |
public synchronized void appendText(final String text) { try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { // System.out.print(Thread.currentThread().getId() + " : " + message); outFile.appendContents(new ByteArrayInputStream(text.getBytes()), IResource.FORCE, monitor); } }, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); // if the console output is active, print to it } catch (CoreException e) { TLCActivator.logError("Error writing the TLC process output file for " + model.getName(), e); } }
Example #5
Source File: ItemEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This also changes the editor's input. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void doSaveAs () { SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () ); saveAsDialog.open (); IPath path = saveAsDialog.getResult (); if ( path != null ) { IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path ); if ( file != null ) { doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) ); } } }
Example #6
Source File: AbstractRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected T doImportIResource(final String fileName, final IResource resource) { try { if (resource instanceof IFile) { return importInputStream(fileName, ((IFile) resource).getContents()); } else if (resource instanceof IFolder) { final IPath path = getResource().getFullPath().append(fileName); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IFolder targetFolder = root.getFolder(path); if (targetFolder.exists()) { if (FileActionDialog.overwriteQuestion(fileName)) { targetFolder.delete(true, Repository.NULL_PROGRESS_MONITOR); } else { return createRepositoryFileStore(fileName); } } resource.copy(getResource().getFullPath().append(fileName), true, Repository.NULL_PROGRESS_MONITOR); } } catch (final Exception e) { BonitaStudioLog.error(e); } return createRepositoryFileStore(fileName); }
Example #7
Source File: SWTBotUtils.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Creates an experiment * * @param bot * a given workbench bot * @param projectName * the name of the project, creates the project if needed * @param expName * the experiment name */ public static void createExperiment(SWTWorkbenchBot bot, String projectName, final @NonNull String expName) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true); TmfExperimentFolder expFolder = tmfProject.getExperimentsFolder(); assertNotNull(expFolder); NewExperimentOperation operation = new NewExperimentOperation(expFolder, expName); operation.run(new NullProgressMonitor()); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { TmfExperimentElement experiment = expFolder.getExperiment(expName); return experiment != null; } @Override public String getFailureMessage() { return "Experiment (" + expName + ") couldn't be created"; } }); }
Example #8
Source File: ProjectUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public static void importProject(String projectName, IPath directory) throws CoreException { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName); if (!project.exists()) { IPath path = directory.append(IProjectDescription.DESCRIPTION_FILE_NAME); IProjectDescription projectFile = ResourcesPlugin.getWorkspace().loadProjectDescription( path); IProjectDescription projectDescription = ResourcesPlugin.getWorkspace().newProjectDescription( projectName); projectDescription.setLocation(path); project.create(projectFile, null); } project.open(null); JobsUtilities.waitForIdle(); }
Example #9
Source File: JavadocContentAccess2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException { String encoding= ResourcesPlugin.getEncoding(); IClasspathEntry entry= root.getRawClasspathEntry(); if (entry != null) { int kind= entry.getEntryKind(); if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) { IClasspathAttribute[] extraAttributes= entry.getExtraAttributes(); for (int i= 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib= extraAttributes[i]; if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) { return attrib.getValue(); } } } } return encoding; }
Example #10
Source File: TestHTML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testHTMLFile() throws Exception { final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testHTMLFile" + System.currentTimeMillis()); project.create(null); project.open(null); final IFile file = project.getFile("blah.html"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<style\n<html><"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #11
Source File: AbstractJavaElementRenameChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException { try { pm.beginTask(RefactoringCoreMessages.AbstractRenameChange_Renaming, 1); IResource resource= getResource(); IPath newPath= createNewPath(); Change result= createUndoChange(resource.getModificationStamp()); doRename(new SubProgressMonitor(pm, 1)); if (fStampToRestore != IResource.NULL_STAMP) { IResource newResource= ResourcesPlugin.getWorkspace().getRoot().findMember(newPath); newResource.revertModificationStamp(fStampToRestore); } return result; } finally { pm.done(); } }
Example #12
Source File: WizardFileSystemResourceExportPage2.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Returns the name of a container with a location that encompasses targetDirectory. Returns null if there is no * conflict. * @param targetDirectory * the path of the directory to check. * @return the conflicting container name or <code>null</code> */ protected String getConflictingContainerNameFor(String targetDirectory) { IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath testPath = new Path(targetDirectory); // cannot export into workspace root if (testPath.equals(rootPath)) return rootPath.lastSegment(); // Are they the same? if (testPath.matchingFirstSegments(rootPath) == rootPath.segmentCount()) { String firstSegment = testPath.removeFirstSegments(rootPath.segmentCount()).segment(0); if (!Character.isLetterOrDigit(firstSegment.charAt(0))) return firstSegment; } return null; }
Example #13
Source File: FetchRemoteTracesTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test 8.9: Run Profile "TestAllRecursive" (Skip next page) */ @Test public void test_8_09() { SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); projectExplorerBot.show(); SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); fBot.comboBox().setSelection("TestAllRecursive"); fBot.button("Finish").click(); fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT); WaitUtils.waitForJobs(); TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true); fBot.waitUntil(new TraceCountCondition(project, 3)); final TmfTraceFolder tracesFolder = project.getTracesFolder(); assertNotNull(tracesFolder); List<TmfTraceElement> traces = tracesFolder.getTraces(); assertEquals(3, traces.size()); testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL); testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG); testTrace(traces.get(2), CONNECTION_NODE1_NAME + "/resources/unrecognized", null); }
Example #14
Source File: ResourceUIValidatorExtension.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void deleteMarkersRecursively(FileURI location) { if (location == null) { return; } IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IContainer[] containers = root.findContainersForLocationURI(URI.create(location.toString())); if (containers == null || containers.length == 0) { return; } try { for (IContainer container : containers) { if (container.isAccessible()) { container.deleteMarkers(null, true, IResource.DEPTH_INFINITE); } } } catch (CoreException e) { e.printStackTrace(); } }
Example #15
Source File: BslValidator.java From ru.capralow.dt.bslls.validator with BSD 3-Clause "New" or "Revised" License | 5 votes |
public BslValidator() { super(); projectsContext = new HashMap<>(); for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { ProjectContext projectContext = new ProjectContext(project); projectsContext.put(project, projectContext); } }
Example #16
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public boolean clearWorkspace() throws RemoteException { boolean error = false; for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { try { log.trace("deleting project: " + project.getName()); project.delete(true, true, null); } catch (CoreException e) { error = true; log.error("unable to delete project '" + project.getName() + "' :" + e.getMessage(), e); } } return !error; }
Example #17
Source File: ImportProjectWizardPage2.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void initData() { root = ResourcesPlugin.getWorkspace().getRoot(); page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); projectImg = Activator.getImageDescriptor("images/prj_open.png").createImage(); folderImg = Activator.getImageDescriptor("images/folder.png").createImage(); hsXLiffImg = Activator.getImageDescriptor("images/hsxliff.png").createImage(); htmlImg = Activator.getImageDescriptor("images/html.png").createImage(); defaultImg = Activator.getImageDescriptor("images/file_obj.png").createImage(); imgMap = new HashMap<String, Image>(); }
Example #18
Source File: RadlNewWizardPage.java From RADL with Apache License 2.0 | 5 votes |
public RadlNewWizardPage(ISelection selection) { super("wizardPage"); setTitle("New RESTful API"); setDescription("Create a new RESTful API Description Language (RADL) document"); this.selection = selection; root = ResourcesPlugin.getWorkspace().getRoot(); }
Example #19
Source File: YangPageFile.java From yang-design-studio with Eclipse Public License 1.0 | 5 votes |
/** * Ensures that both text fields are set. */ private void dialogChanged() { IResource container = ResourcesPlugin.getWorkspace().getRoot() .findMember(new Path(getContainerName())); String fileName = getFileName(); if (getContainerName().length() == 0) { updateStatus("File container must be specified"); return; } if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { updateStatus("File container must exist"); return; } if (!container.isAccessible()) { updateStatus("Project must be writable"); return; } if (fileName.length() == 0) { updateStatus("File name must be specified"); return; } if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { updateStatus("File name must be valid"); return; } int dotLoc = fileName.lastIndexOf('.'); if (dotLoc != -1) { String ext = fileName.substring(dotLoc + 1); if (ext.equalsIgnoreCase("yang") == false) { updateStatus("File extension must be \"yang\""); return; } } updateStatus(null); }
Example #20
Source File: CustomConnectorViewerFilter.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { if (element instanceof ConnectorDefinition) { final Resource eResource = ((ConnectorDefinition) element).eResource(); if (eResource != null) { final IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); return rootPath.isPrefixOf(Path.fromOSString(eResource.getURI().toFileString())); } } return false; }
Example #21
Source File: ExportFilterStoreConfiger.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 检查配置文件存放目录.如果不存在则创建 * @param cfgDirName * 需要检查目录的名称 * @return ; */ private String checkConfigDirectory(String cfgDirName) { String workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); workspacePath = workspacePath + System.getProperty("file.separator") + cfgDirName; File dbListFolder = new File(workspacePath); if (!dbListFolder.exists() || dbListFolder.isFile()) { dbListFolder.mkdirs(); } return workspacePath; }
Example #22
Source File: CodewindEclipseApplication.java From codewind-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void resetValidation() { // Delete all Codewind markers for a project IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (project != null && project.isAccessible()) { try { project.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE); } catch (CoreException e) { Logger.logError("Failed to delete existing markers for the " + name + " project.", e); //$NON-NLS-1$ } } }
Example #23
Source File: AppraisePluginUtils.java From git-appraise-eclipse with Eclipse Public License 1.0 | 5 votes |
/** * Gets the Eclipse project (if any) for the given task repository. */ public static IProject getProjectForRepository(TaskRepository repo) { for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (repo.getUrl().endsWith(project.getName())) { return project; } } return null; }
Example #24
Source File: ProcessDiagramEditorUtil.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ public static boolean openDiagram(Resource diagram) throws PartInitException { String path = diagram.getURI().toPlatformString(true); IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path)); if (workspaceResource instanceof IFile) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); return null != page.openEditor(new FileEditorInput((IFile) workspaceResource), ProcessDiagramEditor.ID); } return false; }
Example #25
Source File: CoreEditor.java From ifml-editor with MIT License | 5 votes |
/** * This also changes the editor's input. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void doSaveAs() { SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); saveAsDialog.open(); IPath path = saveAsDialog.getResult(); if (path != null) { IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file != null) { doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); } } }
Example #26
Source File: BaseDocumentLifeCycleHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private ISchedulingRule getRule(Set<ICompilationUnit> units) { ISchedulingRule result = null; IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); for (ICompilationUnit unit : units) { if (unit.getResource() != null) { ISchedulingRule rule = ruleFactory.createRule(unit.getResource()); result = MultiRule.combine(rule, result); } } return result; }
Example #27
Source File: SarlExampleInstallerWizard.java From sarl with Apache License 2.0 | 5 votes |
/** Replies the file into the project. * * @return the file or {@code null} if the file cannot be found. */ @SuppressWarnings("checkstyle:nestedifdepth") public IFile findProjectFile() { if (this.projectFile == null) { final IProject prj = this.project.get(); if (prj != null) { // 3 cases for location: // * prj / src folder / source path // * src folder / source path // * source path final IPath path0 = Path.fromPortableString(getLocation()); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path0); if (file != null && file.exists()) { this.projectFile = file; } else { file = prj.getFile(path0); if (file != null && file.exists()) { this.projectFile = file; } else { final IPath srcFolder = Path.fromOSString(SARLConfig.FOLDER_SOURCE_SARL); final IPath path1 = srcFolder.append(path0); file = prj.getFile(path1); if (file != null && file.exists()) { this.projectFile = file; } } } } } return this.projectFile; }
Example #28
Source File: ControlViewTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static TmfProjectElement verifyRemoteProject() { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(ControlViewSwtBotUtil.DEFAULT_REMOTE_PROJECT); // verify that project was created assertTrue(project.exists()); TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true); return tmfProject; }
Example #29
Source File: GwtSdk.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private IPath computeInstallPathFromProjectOrSourceClasspathEntry(IClasspathEntry classpathEntry) throws JavaModelException { IPath installPath; IPath entryPath = classpathEntry.getPath(); // First segment should be project name String projectName = entryPath.segment(0); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IJavaProject jProject = JavaCore.create(project); installPath = computeInstallPathFromProject(jProject); return installPath; }
Example #30
Source File: VisualInterfaceEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void dispose () { updateProblemIndication = false; ResourcesPlugin.getWorkspace ().removeResourceChangeListener ( resourceChangeListener ); getSite ().getPage ().removePartListener ( partListener ); adapterFactory.dispose (); if ( getActionBarContributor ().getActiveEditor () == this ) { getActionBarContributor ().setActiveEditor ( null ); } for ( PropertySheetPage propertySheetPage : propertySheetPages ) { propertySheetPage.dispose (); } if ( contentOutlinePage != null ) { contentOutlinePage.dispose (); } super.dispose (); }