/** * Creates new symbolic file system link from file or folder on project root to another file * system file. The filename can include relative path as a part of the name but the the path has * to be present on disk. * * @param project - project where to create the file. * @param linkName - name of the link being created. * @param realPath - file or folder on the file system, the target of the link. * @return file handle. * @throws UnsupportedOperationException on Windows where links are not supported. * @throws IOException... * @throws CoreException... */ public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath) throws IOException, CoreException, UnsupportedOperationException { if (!isSymbolicLinkSupported()) { throw new UnsupportedOperationException("Windows links .lnk are not supported."); } Assert.assertTrue( "Path for symbolic link does not exist: [" + realPath.toOSString() + "]", new File(realPath.toOSString()).exists()); IPath linkedPath = project.getLocation().append(linkName); createSymbolicLink(linkedPath, realPath); IResource resource = project.getFile(linkName); resource.refreshLocal(IResource.DEPTH_ZERO, null); if (!resource.exists()) { resource = project.getFolder(linkName); resource.refreshLocal(IResource.DEPTH_ZERO, null); } Assert.assertTrue("Failed to create resource form symbolic link", resource.exists()); externalFilesCreated.add(linkedPath.toOSString()); ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR); return resource; }
/** @see org.eclipse.jface.action.Action#run() */ @Override public void run() { IResource resource = null; IWorkbench workbench = PlatformUI.getWorkbench(); if ((workbench != null) && !workbench.isClosing()) { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window != null) { if (dbNodeSelected != null) { // db node selected => get parent to retrieve the resource // or the project (if the resource does not exist) if (dbNodeSelected.getParent() instanceof ProjectNode) { ProjectNode pNode = (ProjectNode) dbNodeSelected.getParent(); resource = ResourcesPlugin.getWorkspace() .getRoot() .getProject(pNode.getName()) .getFile(ProjectNode.DB_FOLDER + IPath.SEPARATOR + dbNodeSelected.getName()); if (!resource.exists()) { resource = resource.getProject(); } } } else if (dbProjectNodeSelected != null) { ProjectNode pNode = dbProjectNodeSelected; resource = ResourcesPlugin.getWorkspace() .getRoot() .getProject(pNode.getName()) .getFile( ProjectNode.DB_FOLDER + IPath.SEPARATOR + dbProjectNodeSelected.getName()); if (!resource.exists()) { resource = resource.getProject(); } } else { // db node not selected on tree => try to get resource based // on selection from package explorer Object selectionElement = getSelectionElement(window); if (selectionElement == null) { // the wizard was requested to open from Andmore menu - // open wizard without selecting project or .db file resource = null; } else { // there is an item selected, get the resource // associated resource = getResourceFromSelection(selectionElement); } } openDialogBasedOnResourceSelected(resource, window); } } }
// find current ClassFile's corresponding eclipse file from source folder public IFile getFileInSourceFolder() { String[] eglSourceFolders = org.eclipse.edt.ide.core.internal.model.util.Util.getEGLSourceFolders( new File(this.getEGLProject().getProject().getLocation().toString())); for (String eglSourceFolder : eglSourceFolders) { IResource sourceFolder = this.getEGLProject().getProject().findMember(eglSourceFolder); if (sourceFolder != null && sourceFolder.exists() && sourceFolder.getType() == IResource.FOLDER) { // source folder exists String pkgPath = ""; IResource fullPkgFolder = null; try { ClassFileElementInfo elementInfo = ((ClassFileElementInfo) this.getElementInfo()); String[] pkgs = elementInfo.getCaseSensitivePackageName(); if (pkgs != null && pkgs.length > 0) { for (int i = 0; i < pkgs.length - 1; i++) { pkgPath += pkgs[i]; pkgPath += File.separator; } pkgPath += pkgs[pkgs.length - 1]; fullPkgFolder = ((IFolder) sourceFolder).findMember(pkgPath); } else { fullPkgFolder = sourceFolder; } if (fullPkgFolder != null && fullPkgFolder.exists() && fullPkgFolder.getType() == IResource.FOLDER) { // package matches String srcName = elementInfo .getEglFileName(); // srcName should represent the source file name eliminating // package name int index = srcName.lastIndexOf("/"); if (index != -1) { srcName = srcName.substring(index); } IResource sourceFile = ((IFolder) fullPkgFolder).findMember(srcName); if (sourceFile != null && sourceFile.exists() && sourceFile.getType() == IResource.FILE) { // egl source matches return (IFile) sourceFile; } } } catch (EGLModelException e) { e.printStackTrace(); } } } return null; }
public static IMarker[] getProblemsFor(IResource resource) { try { if (resource != null && resource.exists()) { IMarker[] markers = resource.findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); Set markerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes(); if (markerTypes.isEmpty()) return markers; ArrayList markerList = new ArrayList(5); for (int i = 0, length = markers.length; i < length; i++) { markerList.add(markers[i]); } Iterator iterator = markerTypes.iterator(); while (iterator.hasNext()) { markers = resource.findMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE); for (int i = 0, length = markers.length; i < length; i++) { markerList.add(markers[i]); } } IMarker[] result; markerList.toArray(result = new IMarker[markerList.size()]); return result; } } catch (CoreException e) { // assume there are no problems } return new IMarker[0]; }
/** * Final check before the actual refactoring * * @return status * @throws OperationCanceledException */ public RefactoringStatus checkFinalConditions() throws OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); IContainer destination = fProcessor.getDestination(); IProject sourceProject = fProcessor.getSourceSelection()[0].getProject(); IProject destinationProject = destination.getProject(); if (sourceProject != destinationProject) status.merge(MoveUtils.checkMove(phpFiles, sourceProject, destination)); // Checks if one of the resources already exists with the same name in // the destination IPath dest = fProcessor.getDestination().getFullPath(); IResource[] sourceResources = fProcessor.getSourceSelection(); for (IResource element : sourceResources) { String newFilePath = dest.toOSString() + File.separatorChar + element.getName(); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(newFilePath)); if (resource != null && resource.exists()) { status.merge( RefactoringStatus.createFatalErrorStatus( NLS.bind( PhpRefactoringCoreMessages.getString("MoveDelegate.6"), element.getName(), dest.toOSString()))); // $NON-NLS-1$ } } return status; }
public void testBug148055() throws Exception { IProject project = createPredefinedProject("project.with.aop-ajc.xml.file"); // $NON-NLS-1$ IResource xml = project.findMember("src/META-INF/aop-ajc.xml"); // $NON-NLS-1$ assertNotNull("Couldn't find aop-ajc.xml file in project", xml); // $NON-NLS-1$ assertTrue("aop-ajc.xml file doesn't exist: " + xml, xml.exists()); // $NON-NLS-1$ File file = xml.getRawLocation().toFile(); assertNotNull("Couldn't find aop-ajc.xml as a java.io.File", file); // $NON-NLS-1$ assertTrue("aop-ajc.xml file doesn't exist: " + file, file.exists()); // $NON-NLS-1$ boolean deleted = file.delete(); assertTrue("Delete failed for file: " + file, deleted); // $NON-NLS-1$ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); assertTrue( "Regression of bug 148055: Should be no errors, but got " //$NON-NLS-1$ + ((UIMessageHandler) AspectJPlugin.getDefault() .getCompilerFactory() .getCompilerForProject(project) .getMessageHandler()) .getErrors(), ((UIMessageHandler) AspectJPlugin.getDefault() .getCompilerFactory() .getCompilerForProject(project) .getMessageHandler()) .getErrors() .size() == 0); }
@Override public void deleteMarkers(IResource resource, boolean includeSubtypes, String type) throws CoreException { if (resource != null && resource.exists()) { resource.deleteMarkers(type, includeSubtypes, IResource.DEPTH_INFINITE); } }
/** * The worker method. It will find the container, create the file if missing or just replace its * contents, and open the editor on the newly created file. */ private void doFinish( String containerName, String fileName, String name, String description, IProgressMonitor monitor) throws CoreException { // create a sample file monitor.beginTask("Creating " + fileName, 2); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(containerName)); if (!resource.exists() || !(resource instanceof IContainer)) { throwCoreException("Container \"" + containerName + "\" does not exist."); } IContainer container = (IContainer) resource; final IFile file = container.getFile(new Path(fileName)); try { Test emptyTest = createEmptyTest(name, description); String xml = new CubicTestXStream().toXML(emptyTest); FileUtils.writeStringToFile(file.getLocation().toFile(), xml, "ISO-8859-1"); file.getParent().refreshLocal(IResource.DEPTH_INFINITE, null); } catch (IOException e) { ErrorHandler.logAndRethrow(e); } monitor.worked(1); if (openCreatedTestOnFinish) { openFileForEditing(monitor, file); } }
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (!(resource instanceof IFile) || !resource.getName().endsWith(".java") || !resource.exists()) { return true; } monitor.subTask(resource.getName()); switch (delta.getKind()) { case IResourceDelta.ADDED: check(resource, architecture, true); monitor.worked(1); break; case IResourceDelta.REMOVED: delete(resource); monitor.worked(1); break; case IResourceDelta.CHANGED: check(resource, architecture, true); monitor.worked(1); break; } /* return true to continue visiting children */ return true; }
@Override public StyledString getStyledText(Object element) { if (element instanceof TreeNode) { element = ((TreeNode<?>) element).data; } if (element instanceof ICustomLineElement) { return getLineElementLabel((ICustomLineElement) element); } if (!(element instanceof IResource)) { IResource resource = null; if (element instanceof IAdaptable) { IAdaptable iAdaptable = (IAdaptable) element; resource = iAdaptable.getAdapter(IResource.class); if (resource != null) { if (element instanceof ICustomModule) { return getColoredLabelWithCounts(resource, new StyledString(element.toString())); } element = resource; } } if (!(element instanceof IResource)) { return new StyledString(element.toString()); } } IResource resource = (IResource) element; if (!resource.exists()) { new StyledString("<removed resource>"); } String name = BasicElementLabels.getResourceName(resource); return getColoredLabelWithCounts(resource, new StyledString(name)); }
private void addLayoutFileChanges(IProject project, CompositeChange result) { try { // Update references in XML resource files IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES); IResource[] folders = resFolder.members(); for (IResource folder : folders) { String folderName = folder.getName(); ResourceFolderType folderType = ResourceFolderType.getFolderType(folderName); if (folderType != ResourceFolderType.LAYOUT) { continue; } if (!(folder instanceof IFolder)) { continue; } IResource[] files = ((IFolder) folder).members(); for (int i = 0; i < files.length; i++) { IResource member = files[i]; if ((member instanceof IFile) && member.exists()) { IFile file = (IFile) member; String fileName = member.getName(); if (SdkUtils.endsWith(fileName, DOT_XML)) { addXmlFileChanges(file, result, false); } } } } } catch (CoreException e) { RefactoringUtil.log(e); } }
public static void deleteResource(IResource resource) throws CoreException { if (resource == null || !resource.exists()) { return; } resource.delete(true, null); }
public void decorate(Object element, IDecoration decoration) { if (!(element instanceof IResource)) return; IResource resource = (IResource) element; if (!resource.exists()) return; IProject project = resource.getProject(); if (project == null) { Log.error( Messages.getString("ErrorDecorator.PROJECT_FOR") + resource.getName() + Messages.getString("ErrorDecorator.IS_NULL"), new Throwable()); //$NON-NLS-1$ //$NON-NLS-2$ return; } try { if (!project.isOpen()) return; project.open(null); if (project.hasNature(LSLProjectNature.ID)) { LSLProjectNature nature = (LSLProjectNature) project.getNature(LSLProjectNature.ID); if (nature == null) return; IMarker[] m = resource.findMarkers("lslforge.problem", true, IResource.DEPTH_INFINITE); // $NON-NLS-1$ if (m == null || m.length == 0) return; } else { return; } } catch (CoreException e) { Log.error("exception caught trying to determine project nature!", e); // $NON-NLS-1$ return; } decoration.addOverlay(descriptor, IDecoration.BOTTOM_LEFT); }
/** * Returns a status for this library describing any error states * * @return */ IStatus validate() { if (!getSystemLibraryPath().toFile().exists()) { return new Status( IStatus.ERROR, IJavaDebugUIConstants.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR, "System library does not exist: " + getSystemLibraryPath().toOSString(), null); //$NON-NLS-1$ } IPath path = getSystemLibrarySourcePath(); if (!path.isEmpty()) { if (!path.toFile().exists()) { // check for workspace resource IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); if (resource == null || !resource.exists()) { return new Status( IStatus.ERROR, IJavaDebugUIConstants.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR, "Source attachment does not exist: " + path.toOSString(), null); //$NON-NLS-1$ } } } return Status.OK_STATUS; }
public String getText(Object element) { if (!(element instanceof IResource)) return null; IResource resource = (IResource) element; String text = null; if (!resource.exists()) text = SearchMessages.FileLabelProvider_removed_resource_label; else { IPath path = resource.getFullPath().removeLastSegments(1); if (path.getDevice() == null) path = path.makeRelative(); if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) { text = fLabelProvider.getText(resource); if (path != null && fOrder == SHOW_LABEL_PATH) { fArgs[0] = text; fArgs[1] = path.toString(); text = MessageFormat.format(fgSeparatorFormat, fArgs); } } else { if (path != null) text = path.toString(); else text = ""; // $NON-NLS-1$ if (fOrder == SHOW_PATH_LABEL) { fArgs[0] = text; fArgs[1] = fLabelProvider.getText(resource); text = MessageFormat.format(fgSeparatorFormat, fArgs); } } } int matchCount = 0; AbstractTextSearchResult result = fPage.getInput(); if (result != null) matchCount = result.getMatchCount(element); if (matchCount <= 1) return text; String format = SearchMessages.FileLabelProvider_count_format; return MessageFormat.format(format, new Object[] {text, new Integer(matchCount)}); }
@Override public String getSourceLocation() { IResource sourceResource; String sourceLocation = null; if (fFileSystemObject.isDirectory()) { sourceResource = ResourcesPlugin.getWorkspace() .getRoot() .getContainerForLocation(Path.fromOSString(fFileSystemObject.getAbsolutePath())); } else { sourceResource = ResourcesPlugin.getWorkspace() .getRoot() .getFileForLocation(Path.fromOSString(fFileSystemObject.getAbsolutePath())); } if (sourceResource != null && sourceResource.exists()) { try { sourceLocation = sourceResource.getPersistentProperty(TmfCommonConstants.SOURCE_LOCATION); } catch (CoreException e) { // Something went wrong with the already existing resource. // This is not a problem, we'll assign a new location below. } } if (sourceLocation == null) { try { sourceLocation = URIUtil.toUnencodedString(fFileSystemObject.getCanonicalFile().toURI()); } catch (IOException e) { // Something went wrong canonicalizing the file. We can still // use the URI but there might be extra ../ in it. sourceLocation = URIUtil.toUnencodedString(fFileSystemObject.toURI()); } } return sourceLocation; }
/** * Returns a VDB editor given a vdb resource if editor is open * * @param vdb the vdb * @return the vdb editor */ public static VdbEditor getVdbEditorForFile(IResource vdb) { if (vdb != null && vdb.exists()) { IWorkbenchWindow window = UiPlugin.getDefault().getCurrentWorkbenchWindow(); if (window != null) { final IWorkbenchPage page = window.getActivePage(); if (page != null) { // look through the open editors and see if there is one available for this model file. IEditorReference[] editors = page.getEditorReferences(); for (int i = 0; i < editors.length; ++i) { IEditorPart editor = editors[i].getEditor(false); if (editor != null) { IEditorInput input = editor.getEditorInput(); if (input instanceof IFileEditorInput) { if (vdb.equals(((IFileEditorInput) input).getFile()) || vdb.getFullPath() .equals(((IFileEditorInput) input).getFile().getFullPath())) { // found it; if (ModelUtil.isVdbArchiveFile(vdb)) { return (VdbEditor) editor; } break; } } } } } } } return null; }
public String getStyledText(Object element) { if (element instanceof LineElement) return getLineElementLabel((LineElement) element); if (!(element instanceof IResource)) return new String(); IResource resource = (IResource) element; if (!resource.exists()) new String(SearchMessages.FileLabelProvider_removed_resource_label); String name = BasicElementLabels.getResourceName(resource); if (fOrder == SHOW_LABEL) { return getColoredLabelWithCounts(resource, new String(name)); } String pathString = BasicElementLabels.getPathLabel(resource.getParent().getFullPath(), false); if (fOrder == SHOW_LABEL_PATH) { String str = new String(name); String decorated = Messages.format(fgSeparatorFormat, new String[] {str, pathString}); // decorateColoredString(str, decorated, String.QUALIFIER_STYLER); return getColoredLabelWithCounts(resource, str); } String str = new String(Messages.format(fgSeparatorFormat, new String[] {pathString, name})); return getColoredLabelWithCounts(resource, str); }
/* (non-Javadoc) * @see com.hundsun.ares.devtool.v2.internal.core.Openable#validateExistence(org.eclipse.core.resources.IResource) */ @Override protected IStatus validateExistence(IResource underlyingResource) { if (!underlyingResource.exists()) { return newDoesNotExistStatus(); } return ARESModelStatus.VERIFIED_OK; }
@Override public Image getImage(Object element) { if (element instanceof CPElement) { CPElement cpentry = (CPElement) element; ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry); if (imageDescriptor != null) { switch (cpentry.getStatus().getSeverity()) { case IStatus.WARNING: imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE); break; case IStatus.ERROR: imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE); break; } if (cpentry.getInherited() != null) { imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE); } return fRegistry.get(imageDescriptor); } } else if (element instanceof CPElementAttribute) { String key = ((CPElementAttribute) element).getKey(); if (key.equals(CPElement.SOURCEATTACHMENT)) { return fRegistry.get( CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ATTACH_ATTRIB)); } else if (key.equals(CPElement.EXCLUSION)) { return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB); } } else if (element instanceof IPathEntry) { return getImage(CPElement.createFromExisting((IPathEntry) element, null)); } else if (element instanceof CPElementGroup) { switch (((CPElementGroup) element).getEntryKind()) { case IPathEntry.CDT_INCLUDE: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER); case IPathEntry.CDT_MACRO: return fRegistry.get(fMacroIcon); case IPathEntry.CDT_INCLUDE_FILE: case IPathEntry.CDT_MACRO_FILE: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE); case IPathEntry.CDT_LIBRARY: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY); case -1: IResource res = ((CPElementGroup) element).getResource(); IWorkbenchAdapter adapter = (IWorkbenchAdapter) res.getAdapter(IWorkbenchAdapter.class); ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res); if (!res.exists()) { imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE); } return fRegistry.get(imageDescriptor); } } return null; }
public Map<String, IStatus> validate(Object value, Object context) { if (value == null || "".equals(value)) { // $NON-NLS-1$ return createErrormessage( new Status( IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, SeamCoreMessages.VALIDATOR_FACTORY_PRJ_NOT_SELECTED)); } IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(value.toString()); if (project == null || !(project instanceof IProject) || !project.exists()) { return createErrormessage( new Status( IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS.bind(SeamCoreMessages.VALIDATOR_FACTORY_PROJECT_DOES_NOT_EXIST, value))); } else { IProject selection = (IProject) project; try { if (!selection.hasNature(ISeamProject.NATURE_ID) || SeamCorePlugin.getSeamPreferences(selection) == null // || // selection.getAdapter(IFacetedProject.class)==null // || !((IFacetedProject)selection.getAdapter( // IFacetedProject // .class)).hasProjectFacet(ProjectFacetsManager // .getProjectFacet("jst.web")) || "" .equals( SeamCorePlugin.getSeamPreferences(selection) .get( ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ""))) { //$NON-NLS-1$ return createErrormessage( new Status( IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS.bind( SeamCoreMessages .VALIDATOR_FACTORY_SELECTED_PROJECT_IS_NOT_A_SEAM_WEB_PROJECT, project.getName()))); } else { // TODO validate project(s) structure } } catch (CoreException e) { // it might happen only if project is closed and project // name typed by hand return createErrormessage( new Status( IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, NLS.bind( SeamCoreMessages.VALIDATOR_FACTORY_SELECTED_PRJ_IS_CLOSED, project.getName()))); } } return NO_ERRORS; }
protected String checkValidPackage(String text) { validatedPackage = null; packageText = null; // there is a chance that the package is the default project, so, the validation below may not // be valid. // if(text == null || text.trim().length() == 0 ){ // } String initialText = text; if (text.indexOf('/') != -1) { labelWarningImageWillCreate.setVisible(false); labelWarningWillCreate.setVisible(false); labelWarningWillCreate.getParent().layout(); return "The package name must not contain '/'."; } if (text.indexOf('\\') != -1) { labelWarningImageWillCreate.setVisible(false); labelWarningWillCreate.setVisible(false); labelWarningWillCreate.getParent().layout(); return "The package name must not contain '\\'."; } if (text.endsWith(".")) { labelWarningImageWillCreate.setVisible(false); labelWarningWillCreate.setVisible(false); labelWarningWillCreate.getParent().layout(); return "The package may not end with a dot"; } text = text.replace('.', '/'); if (validatedSourceFolder == null) { labelWarningImageWillCreate.setVisible(false); labelWarningWillCreate.setVisible(false); labelWarningWillCreate.getParent().layout(); return "The source folder was not correctly validated."; } IPath path = validatedSourceFolder.getFullPath().append(text); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(path); if (resource == null) { packageText = initialText; labelWarningImageWillCreate.setVisible(true); labelWarningWillCreate.setVisible(true); labelWarningWillCreate.getParent().layout(); return null; } labelWarningImageWillCreate.setVisible(false); labelWarningWillCreate.setVisible(false); labelWarningWillCreate.getParent().layout(); if (!(resource instanceof IContainer)) { return "The resource found for the package is not a valid container."; } if (!resource.exists()) { return "The package selected does not exist in the filesystem."; } validatedPackage = (IContainer) resource; return null; }
public static void removeTasksFor(IResource resource) { try { if (resource != null && resource.exists()) resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); } catch (CoreException e) { // assume there were no problems } }
/** {@inheritDoc} */ public long getTimeStamp() { IResource resource = root.getResource(); if (resource != null && resource.exists()) { return resource.getLocalTimeStamp(); } else { return IResource.NULL_STAMP; } }
/** @generated */ private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) { if (toCreateOrModify.exists()) return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify); IResource parent = toCreateOrModify; do { /* * XXX This is a workaround for * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601 * IResourceRuleFactory.createRule should iterate the hierarchy * itself. */ toCreateOrModify = parent; parent = toCreateOrModify.getParent(); } while (parent != null && !parent.exists()); return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify); }
/** * Deletes all markers on this resource of the given type. * * @param resource An IResource for which this markers must be removed * @param type the type of the marker to create */ public static void removeMarkerFor(IResource resource, String type) { try { if (resource != null && resource.exists()) { resource.deleteMarkers(type, false, IResource.DEPTH_ZERO); } } catch (final CoreException e) { DslCommonPlugin.getDefault().getLog().log(e.getStatus()); } }
protected ISchedulingRule getSchedulingRule() { IResource resource = getSourceModule().getResource(); IWorkspace workspace = resource.getWorkspace(); if (resource.exists()) { return workspace.getRuleFactory().modifyRule(resource); } else { return workspace.getRuleFactory().createRule(resource); } }
public static IMarker[] getTasksFor(IResource resource) { try { if (resource != null && resource.exists()) return resource.findMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); } catch (CoreException e) { // assume there are no tasks } return new IMarker[0]; }
private static void removeMarkerFor(final IResource resource, final String type) { try { if (resource != null && resource.exists()) { resource.deleteMarkers(type, false, IResource.DEPTH_INFINITE); } } catch (final CoreException e) { // assume there were no problems } }
private IFile getFileForPathImpl(IPath path, IProject project) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (path.isAbsolute()) { IFile c = root.getFileForLocation(path); return c; } if (project != null && project.exists()) { ICProject cproject = CoreModel.getDefault().create(project); if (cproject != null) { try { ISourceRoot[] roots = cproject.getAllSourceRoots(); for (ISourceRoot sourceRoot : roots) { IResource r = sourceRoot.getResource(); if (r instanceof IContainer) { IContainer parent = (IContainer) r; IResource res = parent.findMember(path); if (res != null && res.exists() && res instanceof IFile) { IFile file = (IFile) res; return file; } } } IOutputEntry entries[] = cproject.getOutputEntries(); for (IOutputEntry pathEntry : entries) { IPath p = pathEntry.getPath(); IResource r = root.findMember(p); if (r instanceof IContainer) { IContainer parent = (IContainer) r; IResource res = parent.findMember(path); if (res != null && res.exists() && res instanceof IFile) { IFile file = (IFile) res; return file; } } } } catch (CModelException _) { Activator.getDefault().getLog().log(_.getStatus()); } } } return null; }