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: AbstractRepositoryStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 #2
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: ProjectLocationAwareWorkingSetManager.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
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 #4
Source File: ResourceUIValidatorExtension.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
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 #5
Source File: BluemixUtil.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: WizardFileSystemResourceExportPage2.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #7
Source File: AbstractJavaElementRenameChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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 #8
Source File: SARLProjectConfigurator.java    From sarl with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: FileProcessOutputSink.java    From tlaplus with MIT License 6 votes vote down vote up
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 #10
Source File: JavadocContentAccess2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #11
Source File: ItemEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #12
Source File: ProjectUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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 #13
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #14
Source File: TestHTML.java    From wildwebdeveloper with Eclipse Public License 2.0 6 votes vote down vote up
@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 #15
Source File: ProjectUtils.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Identifies the given project and returns an {@link IJavaProject} instance.
 * 
 * @param projectName - the source project
 * @return An {@link IJavaProject} instance if the given project is a java project.
 * @throws NotFoundException If the project cannot be found, or not a java project.
 */
public static IJavaProject findJavaProject(String projectName) throws NotFoundException {
	IProject project;
	try {
		project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
	} catch (IllegalArgumentException e) {
		project = null;
	}
	if (project == null || !project.exists()) {
		throw new NotFoundException("Cannot find project '" + projectName + "'");
	}
	return JavaCore.create(project);
}
 
Example #16
Source File: AddOrEditSrxConfigDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public AddOrEditSrxConfigDialog(Shell parentShell, String curSrxName, ADXmlHandler handler) {
	super(parentShell);
	this.curSrxName = curSrxName;
	this.handler = handler;
	root = ResourcesPlugin.getWorkspace().getRoot();
	srxLocation = ADConstants.configLocation + ADConstants.AD_SRXConfigFolder + File.separator + curSrxName;
}
 
Example #17
Source File: PropertyAndPreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handle link activation.
 *
 * @param link the link
 */
final void doLinkActivated(Link link) {
	Map<String, Object> data= getData();
	if (data == null)
		data= new HashMap<String, Object>();
	data.put(DATA_NO_LINK, Boolean.TRUE);

	if (isProjectPreferencePage()) {
		openWorkspacePreferences(data);
	} else {
		HashSet<IJavaProject> projectsWithSpecifics= new HashSet<IJavaProject>();
		try {
			IJavaProject[] projects= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
			for (int i= 0; i < projects.length; i++) {
				IJavaProject curr= projects[i];
				if (hasProjectSpecificOptions(curr.getProject())) {
					projectsWithSpecifics.add(curr);
				}
			}
		} catch (JavaModelException e) {
			// ignore
		}
		ProjectSelectionDialog dialog= new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
		if (dialog.open() == Window.OK) {
			IJavaProject res= (IJavaProject) dialog.getFirstResult();
			openProjectProperties(res.getProject(), data);
		}
	}
}
 
Example #18
Source File: GHOLD_129_BrokenAstMustNotCauseBuildFailure_PluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * We expect validation errors which means the build was not broken and interrupted due to broken AST when inferring
 * the types.
 */
@Test
public void checkBrokenAstDoesNotCauseBuildFailure_ExpectValidationErrors() throws CoreException {
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Project '" + PROJECT_NAME + "' does not exist in workspace.", project.isAccessible());

	IResourcesSetupUtil.fullBuild();
	ProjectTestsUtils.waitForAutoBuild();

	// Couldn't resolve reference to IdentifiableElement 'A'.
	// Name missing in type declaration.
	ProjectTestsUtils.assertMarkers("Expected exactly two validation errors.", project, 2);
}
 
Example #19
Source File: WebAppLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the project associated with this launch configuration, or <code>
 * null</code> if there is no project assigned or if the project does not exist.
 */
public static IProject getProject(ILaunchConfiguration configuration) throws CoreException {
  String projectName = LaunchConfigurationUtilities.getProjectName(configuration);
  if (projectName.length() == 0) {
    return null;
  }

  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
  return project.exists() ? project : null;
}
 
Example #20
Source File: InternalImpl.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createProject(String projectName) throws RemoteException {

  log.trace("creating project: " + projectName);
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
  try {
    project.create(null);
    project.open(null);
  } catch (CoreException e) {
    log.error("unable to create project '" + projectName + "' : " + e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
Example #21
Source File: ProjectCreator.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public static IProject createProjectOnLocation(IPath baseDirectory, String projectName) throws CoreException {
	IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
	description.setLocation(baseDirectory);
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
	if (!project.exists()) {
		project.create(description, new NullProgressMonitor());
	}
	return project;
}
 
Example #22
Source File: StreamContentDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String getEncoding(Object element) {
	String encoding = ResourcesPlugin.getEncoding();
	if (element instanceof IEncodedStreamContentAccessor) {
		try {
			String streamEncoding = ((IEncodedStreamContentAccessor) element).getCharset();
			if (!Strings.isNullOrEmpty(streamEncoding)) {
				encoding = streamEncoding;
			}
		} catch (CoreException exception) {
		}
	}
	return encoding;
}
 
Example #23
Source File: MergeXliff.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 获取相对于项目的相对路径
 * @param absolutePath
 * @return
 */
public String getFullPath(String absolutePath) {
	// UNDO 合并后的文件好像不能转换回原文件,这里还需完善。
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IFile iFile = root.getFileForLocation(Path.fromOSString(absolutePath));
	return iFile.getFullPath().toOSString();
}
 
Example #24
Source File: AbstractAllContainersState.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void registerAsListener() {
	ResourcesPlugin.getWorkspace().addResourceChangeListener(this, 
		  IResourceChangeEvent.PRE_DELETE 
		| IResourceChangeEvent.POST_CHANGE 
		| IResourceChangeEvent.PRE_CLOSE
		);
}
 
Example #25
Source File: ResolvingCrossReferenceDuringIndexingTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertNoErrorsInWorkspace() {
  try {
    final IMarker[] findMarkers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      String _message = MarkerUtilities.getMessage(iMarker);
      int _severity = MarkerUtilities.getSeverity(iMarker);
      boolean _equals = (_severity == IMarker.SEVERITY_ERROR);
      Assert.assertFalse(_message, _equals);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #26
Source File: NewFileWizardPrimaryPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void validate() {
	setStatus(null);
	IContainer folder = getFolder();
	if (folder == null || !folder.exists()) {
		setStatus(new Status(IStatus.ERROR, "NewFileWizard", Messages.NewFileWizardPrimaryPage_unexistint_folder_pre //$NON-NLS-1$
				+ folderText.getText() + Messages.NewFileWizardPrimaryPage_unexistent_folder_post));
		return;
	}
	if ("".equals(fileText.getText().trim())) { //$NON-NLS-1$
		setStatus(new Status(IStatus.ERROR, "NewFileWizard", Messages.NewFileWizardPrimaryPage_empty_name)); //$NON-NLS-1$
		return;
	}
	if (parameterComposite != null) {
		parameterComposite.validate();
	}
	if (getErrorMessage() == null) {
		AbstractFileTemplate template = getSelectedTemplate();
		template.setTemplateInfo(getFileInfo());
		PathCollector fileCollector = new PathCollector();
		template.generateFiles(fileCollector);
		for (CharSequence path : fileCollector.getResult()) {
			IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path.toString()));
			if (file.exists()) {
				setStatus(new Status(IStatus.ERROR, "NewFileWizard", Messages.NewFileWizardPrimaryPage_file_already_exist_pre + path //$NON-NLS-1$
						+ Messages.NewFileWizardPrimaryPage_file_already_exist_post));
				return;
			}
		}
	}
}
 
Example #27
Source File: JavaWorkingSetUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) {
	IResource resource= delta.getResource();
	int type= resource.getType();
	int index= result.indexOf(resource);
	int kind= delta.getKind();
	int flags= delta.getFlags();
	if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) {
		if ((flags & IResourceDelta.OPEN) != 0) {
			result.set(index, resource);
		}
	}
	if (index != -1 && kind == IResourceDelta.REMOVED) {
		if ((flags & IResourceDelta.MOVED_TO) != 0) {
			result.set(index,
				ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath()));
		} else {
			result.remove(index);
		}
	}

	// Don't dive into closed or opened projects
	if (projectGotClosedOrOpened(resource, kind, flags))
		return;

	IResourceDelta[] children= delta.getAffectedChildren();
	for (int i= 0; i < children.length; i++) {
		processResourceDelta(result, children[i]);
	}
}
 
Example #28
Source File: BslValidator.java    From ru.capralow.dt.bslls.validator with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public BslValidator()
{
    super();

    projectsContext = new HashMap<>();
    for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects())
    {
        ProjectContext projectContext = new ProjectContext(project);
        projectsContext.put(project, projectContext);
    }
}
 
Example #29
Source File: WidgetModel.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
protected IFile configXMLtoIFile() {
	if (configFile == null) {
		return null;
	}
	final IFile[] configFileCandidates = ResourcesPlugin.getWorkspace().getRoot()
			.findFilesForLocationURI(configFile.toURI());
	if (configFileCandidates == null || configFileCandidates.length == 0) {
		return null;
	}
	// In case of linked resources, there is a chance that this will point to the
	// wrong file.
	// This may happen only if two eclipse projects link the same config.xml.
	return configFileCandidates[0];
}
 
Example #30
Source File: ProblemMarkerManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes a <code>IProblemChangedListener</code>.
 * 
 * @param listener
 *            the listener to remove
 */
public void removeListener(IProblemChangedListener listener)
{
	fListeners.remove(listener);
	if (fListeners.isEmpty())
	{
		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
	}
}