/** @see MultiOperation */ protected void verify(IJavaElement element) throws JavaModelException { if (element == null || !element.exists()) error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element); if (element.isReadOnly() && (isRename() || isMove())) error(IJavaModelStatusConstants.READ_ONLY, element); IResource resource = ((JavaElement) element).resource(); if (resource instanceof IFolder) { if (resource.isLinked()) { error(IJavaModelStatusConstants.INVALID_RESOURCE, element); } } int elementType = element.getElementType(); if (elementType == IJavaElement.COMPILATION_UNIT) { org.eclipse.jdt.internal.core.CompilationUnit compilationUnit = (org.eclipse.jdt.internal.core.CompilationUnit) element; if (isMove() && compilationUnit.isWorkingCopy() && !compilationUnit.isPrimary()) error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); } else if (elementType != IJavaElement.PACKAGE_FRAGMENT) { error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); } JavaElement dest = (JavaElement) getDestinationParent(element); verifyDestination(element, dest); if (this.renamings != null) { verifyRenaming(element); } }
protected boolean checkForClassFileChanges( IResourceDelta binaryDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException { IResource resource = binaryDelta.getResource(); // remember that if inclusion & exclusion patterns change then a full build is done boolean isExcluded = (md.exclusionPatterns != null || md.inclusionPatterns != null) && Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns); switch (resource.getType()) { case IResource.FOLDER: if (isExcluded && md.inclusionPatterns == null) return true; // no need to go further with this delta since its children cannot be // included IResourceDelta[] children = binaryDelta.getAffectedChildren(); for (int i = 0, l = children.length; i < l; i++) if (!checkForClassFileChanges(children[i], md, segmentCount)) return false; return true; case IResource.FILE: if (!isExcluded && org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(resource.getName())) { // perform full build if a managed class file has been changed IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension(); if (this.newState.isKnownType(typePath.toString())) { if (JavaBuilder.DEBUG) System.out.println( "MUST DO FULL BUILD. Found change to class file " + typePath); // $NON-NLS-1$ return false; } return true; } } return true; }
private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot) { // Determine if any of the roots of the compare are affected List removals = new ArrayList(resources.length); for (int j = 0; j < resources.length; j++) { IResource root = resources[j]; if (removedRoot.getFullPath().isPrefixOf(root.getFullPath())) { // The root is no longer managed by CVS removals.add(root); try { tree.flushVariants(root, IResource.DEPTH_INFINITE); } catch (TeamException e) { CVSProviderPlugin.log(e); } } } if (removals.isEmpty()) { return new SubscriberChangeEvent[0]; } // Adjust the roots of the subscriber List newRoots = new ArrayList(resources.length); newRoots.addAll(Arrays.asList(resources)); newRoots.removeAll(removals); resources = (IResource[]) newRoots.toArray(new IResource[newRoots.size()]); // Create the deltas for the removals SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()]; for (int i = 0; i < deltas.length; i++) { deltas[i] = new SubscriberChangeEvent( this, ISubscriberChangeEvent.ROOT_REMOVED, (IResource) removals.get(i)); } return deltas; }
/** * 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; }
// Called after a resource is removed (DROP KEYSPACE, DROP TABLE, etc.). public void revokeAll(IResource droppedResource) { UntypedResultSet rows; try { // TODO: switch to secondary index on 'resource' once // https://issues.apache.org/jira/browse/CASSANDRA-5125 is resolved. rows = process( String.format( "SELECT username FROM %s.%s WHERE resource = '%s' ALLOW FILTERING", Auth.AUTH_KS, PERMISSIONS_CF, escape(droppedResource.getName()))); } catch (Throwable e) { logger.warn( "CassandraAuthorizer failed to revoke all permissions on {}: {}", droppedResource, e); return; } for (UntypedResultSet.Row row : rows) { try { process( String.format( "DELETE FROM %s.%s WHERE username = '******' AND resource = '%s'", Auth.AUTH_KS, PERMISSIONS_CF, escape(row.getString(USERNAME)), escape(droppedResource.getName()))); } catch (Throwable e) { logger.warn( "CassandraAuthorizer failed to revoke all permissions on {}: {}", droppedResource, e); } } }
ISourceContainer[] getSourceContainers(String location, String id) throws CoreException { ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location); if (containers != null) { return containers; } ArrayList result = new ArrayList(); ModelEntry entry = MonitorRegistry.findEntry(id); boolean match = false; IMonitorModelBase[] models = entry.getWorkspaceModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { IResource resource = models[i].getUnderlyingResource(); // if the plug-in matches a workspace model, // add the project and any libraries not coming via a container // to the list of source containers, in that order if (resource != null) { addProjectSourceContainers(resource.getProject(), result); } match = true; break; } } if (!match) { File file = new File(location); if (file.isFile()) { // in case of linked plug-in projects that map to an external JARd plug-in, // use source container that maps to the library in the linked project. ISourceContainer container = getArchiveSourceContainer(location); if (container != null) { containers = new ISourceContainer[] {container}; fSourceContainerMap.put(location, containers); return containers; } } models = entry.getExternalModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { // try all source zips found in the source code locations IClasspathEntry[] entries = MDEClasspathContainer.getExternalEntries(models[i]); for (int j = 0; j < entries.length; j++) { IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]); if (rte != null) result.add(rte); } break; } } } IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]); containers = JavaRuntime.getSourceContainers(entries); fSourceContainerMap.put(location, containers); return containers; }
public void addSelectedFilesToTargetList() { ISelection selection = sourceFileViewer.getSelection(); if (isValidSourceFileViewerSelection(selection)) { java.util.List list = null; if (selection instanceof IStructuredSelection) { list = ((IStructuredSelection) selection).toList(); if (list != null) { list = ((IStructuredSelection) selection).toList(); for (Iterator i = list.iterator(); i.hasNext(); ) { IResource resource = (IResource) i.next(); if (resource instanceof IFile) { // Check if its in the list. Don't add it if it is. String resourceName = resource.getFullPath().toString(); if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName); } } setFiles(selectedListBox.getItems()); } setAddButtonEnabled(false); if (selectedListBox.getItemCount() > 0) { removeAllButton.setEnabled(true); if (isFileMandatory) setPageComplete(true); if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true); else setRemoveButtonEnabled(false); } } } }
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]; }
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 } }
private void removeBuildPath(IResource resource, IProject project) { IScriptProject projrct = DLTKCore.create(project); IPath filePath = resource.getFullPath(); oldBuildEntries = Arrays.asList(projrct.readRawBuildpath()); newBuildEntries = new ArrayList<IBuildpathEntry>(); newBuildEntries.addAll(oldBuildEntries); for (int i = 0; i < oldBuildEntries.size(); i++) { IBuildpathEntry fEntryToChange = oldBuildEntries.get(i); IPath entryPath = fEntryToChange.getPath(); int mattchedPath = entryPath.matchingFirstSegments(filePath); if (mattchedPath == filePath.segmentCount()) { newBuildEntries.remove(fEntryToChange); } else { IBuildpathEntry newEntry = RefactoringUtility.createNewBuildpathEntry( fEntryToChange, fEntryToChange.getPath(), filePath, ""); // $NON-NLS-1$ newBuildEntries.remove(fEntryToChange); newBuildEntries.add(newEntry); } } oldIncludePath = new ArrayList<IBuildpathEntry>(); newIncludePathEntries = new ArrayList<IBuildpathEntry>(); List<IncludePath> includePathEntries = Arrays.asList(IncludePathManager.getInstance().getIncludePaths(project)); for (IncludePath entry : includePathEntries) { Object includePathEntry = entry.getEntry(); IResource includeResource = null; if (!(includePathEntry instanceof IBuildpathEntry)) { includeResource = (IResource) includePathEntry; IPath entryPath = includeResource.getFullPath(); IBuildpathEntry oldEntry = RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath); oldIncludePath.add((IBuildpathEntry) oldEntry); if (filePath.isPrefixOf(entryPath) || entryPath.equals(filePath)) { } else { IBuildpathEntry newEntry = RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath); newIncludePathEntries.add(newEntry); } } else { newIncludePathEntries.add((IBuildpathEntry) includePathEntry); oldIncludePath.add((IBuildpathEntry) includePathEntry); } } }
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]; }
protected IResource findOriginalResource(IPath partialPath) { for (int i = 0, l = this.sourceLocations.length; i < l; i++) { ClasspathMultiDirectory sourceLocation = this.sourceLocations[i]; if (sourceLocation.hasIndependentOutputFolder) { IResource originalResource = sourceLocation.sourceFolder.getFile(partialPath); if (originalResource.exists()) return originalResource; } } return null; }
private void ensureResourceCovered(IResource resource, List list) { IPath path = resource.getFullPath(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { IResource root = (IResource) iter.next(); if (root.getFullPath().isPrefixOf(path)) { return; } } list.add(resource); }
private IResource createSourceResource(IResourceDelta delta) { IPath sourcePath = delta.getMovedFromPath(); IResource resource = delta.getResource(); IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); switch (resource.getType()) { case IResource.PROJECT: return wsRoot.getProject(sourcePath.segment(0)); case IResource.FOLDER: return wsRoot.getFolder(sourcePath); case IResource.FILE: return wsRoot.getFile(sourcePath); } return null; }
private void createRunConfigurationChange( IResource[] sourceResources, CompositeChange rootChange) { IResource[] uniqueSourceResources = removeDuplicateResources(sourceResources); for (IResource element : uniqueSourceResources) { RenameConfigurationChange configPointchanges = new RenameConfigurationChange( element.getFullPath().removeLastSegments(1), fMainDestinationPath, element.getName(), element.getName()); rootChange.add(configPointchanges); } }
// Returns every permission on the resource granted to the user. public Set<Permission> authorize(AuthenticatedUser user, IResource resource) { if (user.isSuper()) return Permission.ALL; UntypedResultSet result; try { ResultMessage.Rows rows = authorizeStatement.execute( QueryState.forInternalCalls(), new QueryOptions( ConsistencyLevel.ONE, Lists.newArrayList( ByteBufferUtil.bytes(user.getName()), ByteBufferUtil.bytes(resource.getName())))); result = UntypedResultSet.create(rows.result); } catch (RequestValidationException e) { throw new AssertionError(e); // not supposed to happen } catch (RequestExecutionException e) { logger.warn("CassandraAuthorizer failed to authorize {} for {}", user, resource); return Permission.NONE; } if (result.isEmpty() || !result.one().has(PERMISSIONS)) return Permission.NONE; Set<Permission> permissions = EnumSet.noneOf(Permission.class); for (String perm : result.one().getSet(PERMISSIONS, UTF8Type.instance)) permissions.add(Permission.valueOf(perm)); return permissions; }
private void createRenameLibraryFolderChange( IResource[] sourceResources, CompositeChange rootChange) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); LibraryFolderManager lfm = LibraryFolderManager.getInstance(); for (IResource resource : sourceResources) { if (resource.getType() == IResource.FOLDER && lfm.isInLibraryFolder(resource)) { IPath newPath = fMainDestinationPath.append(resource.getName()); IFolder newFolder = root.getFolder(newPath); RenameLibraryFolderChange change = new RenameLibraryFolderChange((IFolder) resource, newFolder); rootChange.add(change); } } }
/* (non-Javadoc) * @see org.eclipse.team.core.subscribers.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource) */ public boolean isSupervised(IResource resource) throws TeamException { if (super.isSupervised(resource)) { if (!resource.exists() && !getRemoteTree().hasResourceVariant(resource)) { // Exclude conflicting deletions return false; } if (this.resources != null) { for (int i = 0; i < resources.length; i++) { IResource root = resources[i]; if (root.getFullPath().isPrefixOf(resource.getFullPath())) { return true; } } } } return false; }
boolean filterExtraResource(IResource resource) { if (this.extraResourceFileFilters != null) { char[] name = resource.getName().toCharArray(); for (int i = 0, l = this.extraResourceFileFilters.length; i < l; i++) if (CharOperation.match(this.extraResourceFileFilters[i], name, true)) return true; } if (this.extraResourceFolderFilters != null) { IPath path = resource.getProjectRelativePath(); String pathName = path.toString(); int count = path.segmentCount(); if (resource.getType() == IResource.FILE) count--; for (int i = 0, l = this.extraResourceFolderFilters.length; i < l; i++) if (pathName.indexOf(this.extraResourceFolderFilters[i]) != -1) for (int j = 0; j < count; j++) if (this.extraResourceFolderFilters[i].equals(path.segment(j))) return true; } return false; }
public static void removeProblemsFor(IResource resource) { try { if (resource != null && resource.exists()) { resource.deleteMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); // delete managed markers Set markerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes(); if (markerTypes.size() == 0) return; Iterator iterator = markerTypes.iterator(); while (iterator.hasNext()) resource.deleteMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE); } } catch (CoreException e) { // assume there were no problems } }
public boolean include(Object object) { if (object instanceof IResource) { IResource resource = (IResource) object; IPath path = IResource.FILE == resource.getType() ? resource.getFullPath() : resource.getFullPath().addTrailingSeparator(); object = path.toPortableString(); } for (Iterator iter = filters.iterator(); iter.hasNext(); ) { Filter filter = (Filter) iter.next(); if (filter.matches(object)) { return filter.inclusive(); } } return default_; }
/* Return the list of projects for which it requires a resource delta. This builder's project * is implicitly included and need not be specified. Builders must re-specify the list * of interesting projects every time they are run as this is not carried forward * beyond the next build. Missing projects should be specified but will be ignored until * they are added to the workspace. */ private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) { if (this.javaProject == null || this.workspaceRoot == null) return new IProject[0]; ArrayList projects = new ArrayList(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); try { IClasspathEntry[] entries = this.javaProject.getExpandedClasspath(); for (int i = 0, l = entries.length; i < l; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); IProject p = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT: p = this.workspaceRoot.getProject( path.lastSegment()); // missing projects are considered too if (((ClasspathEntry) entry).isOptional() && !JavaProject.hasJavaNature(p)) // except if entry is optional p = null; break; case IClasspathEntry.CPE_LIBRARY: if (includeBinaryPrerequisites && path.segmentCount() > 0) { // some binary resources on the class path can come from projects that are not // included in the project references IResource resource = this.workspaceRoot.findMember(path.segment(0)); if (resource instanceof IProject) { p = (IProject) resource; } else { resource = externalFoldersManager.getFolder(path); if (resource != null) p = resource.getProject(); } } } if (p != null && !projects.contains(p)) projects.add(p); } } catch (JavaModelException e) { return new IProject[0]; } IProject[] result = new IProject[projects.size()]; projects.toArray(result); return result; }
private void createBreakPointChange(IResource[] sourceResources, CompositeChange rootChange) throws CoreException { IResource[] uniqueSourceResources = removeDuplicateResources(sourceResources); for (IResource element : uniqueSourceResources) { collectBrakePoint(element); RenameBreackpointChange breakePointchanges = new RenameBreackpointChange( element.getFullPath().removeLastSegments(1), fMainDestinationPath, element.getName(), element.getName(), fBreakpoints, fBreakpointAttributes); if (fBreakpoints.getKeys().size() > 0) { rootChange.add(breakePointchanges); } } }
// Adds or removes permissions from user's 'permissions' set (adds if op is "+", removes if op is // "-") private void modify(Set<Permission> permissions, IResource resource, String user, String op) throws RequestExecutionException { process( String.format( "UPDATE %s.%s SET permissions = permissions %s {%s} WHERE username = '******' AND resource = '%s'", Auth.AUTH_KS, PERMISSIONS_CF, op, "'" + StringUtils.join(permissions, "','") + "'", escape(user), escape(resource.getName()))); }
private boolean moveSettingsIfDerivedChanged( IResourceDelta parent, IProject currentProject, Preferences projectPrefs, String[] affectedResources) { boolean resourceChanges = false; if ((parent.getFlags() & IResourceDelta.DERIVED_CHANGED) != 0) { // if derived changed, move encoding to correct preferences IPath parentPath = parent.getResource().getProjectRelativePath(); for (int i = 0; i < affectedResources.length; i++) { IPath affectedPath = new Path(affectedResources[i]); // if parentPath is an ancestor of affectedPath if (parentPath.isPrefixOf(affectedPath)) { IResource member = currentProject.findMember(affectedPath); if (member != null) { Preferences targetPrefs = getPreferences(currentProject, true, member.isDerived(IResource.CHECK_ANCESTORS)); // if new preferences are different than current if (!projectPrefs.absolutePath().equals(targetPrefs.absolutePath())) { // remove encoding from old preferences and save in correct preferences String currentValue = projectPrefs.get(affectedResources[i], null); projectPrefs.remove(affectedResources[i]); targetPrefs.put(affectedResources[i], currentValue); resourceChanges = true; } } } } } IResourceDelta[] children = parent.getAffectedChildren(); for (int i = 0; i < children.length; i++) { resourceChanges = moveSettingsIfDerivedChanged( children[i], currentProject, projectPrefs, affectedResources) || resourceChanges; } return resourceChanges; }
private ISchedulingRule getSchedulingRule(IJavaElement element) { if (element == null) return null; IResource sourceResource = getResource(element); IResource destContainer = getResource(getDestinationParent(element)); if (!(destContainer instanceof IContainer)) { return null; } String newName; try { newName = getNewNameFor(element); } catch (JavaModelException e) { return null; } if (newName == null) newName = element.getElementName(); IResource destResource; String sourceEncoding = null; if (sourceResource.getType() == IResource.FILE) { destResource = ((IContainer) destContainer).getFile(new Path(newName)); try { sourceEncoding = ((IFile) sourceResource).getCharset(false); } catch (CoreException ce) { // use default encoding } } else { destResource = ((IContainer) destContainer).getFolder(new Path(newName)); } IResourceRuleFactory factory = ResourcesPlugin.getWorkspace().getRuleFactory(); ISchedulingRule rule; if (isMove()) { rule = factory.moveRule(sourceResource, destResource); } else { rule = factory.copyRule(sourceResource, destResource); } if (sourceEncoding != null) { rule = new MultiRule(new ISchedulingRule[] {rule, factory.charsetRule(destResource)}); } return rule; }
public void setCharsetFor(IPath resourcePath, String newCharset) throws CoreException { // for the workspace root we just set a preference in the instance scope if (resourcePath.segmentCount() == 0) { IEclipsePreferences resourcesPreferences = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES); if (newCharset != null) resourcesPreferences.put(ResourcesPlugin.PREF_ENCODING, newCharset); else resourcesPreferences.remove(ResourcesPlugin.PREF_ENCODING); try { resourcesPreferences.flush(); } catch (BackingStoreException e) { IProject project = workspace.getRoot().getProject(resourcePath.segment(0)); String message = Messages.resources_savingEncoding; throw new ResourceException( IResourceStatus.FAILED_SETTING_CHARSET, project.getFullPath(), message, e); } return; } // for all other cases, we set a property in the corresponding project IResource resource = workspace.getRoot().findMember(resourcePath); if (resource != null) { try { // disable the listener so we don't react to changes made by ourselves Preferences encodingSettings = getPreferences( resource.getProject(), true, resource.isDerived(IResource.CHECK_ANCESTORS)); if (newCharset == null || newCharset.trim().length() == 0) encodingSettings.remove(getKeyFor(resourcePath)); else encodingSettings.put(getKeyFor(resourcePath), newCharset); flushPreferences(encodingSettings, true); } catch (BackingStoreException e) { IProject project = workspace.getRoot().getProject(resourcePath.segment(0)); String message = Messages.resources_savingEncoding; throw new ResourceException( IResourceStatus.FAILED_SETTING_CHARSET, project.getFullPath(), message, e); } } }
protected void splitEncodingPreferences(IProject project) { Preferences projectRegularPrefs = getPreferences(project, false, false, false); Preferences projectDerivedPrefs = null; if (projectRegularPrefs == null) return; try { boolean prefsChanged = false; String[] affectedResources; affectedResources = projectRegularPrefs.keys(); for (int i = 0; i < affectedResources.length; i++) { String path = affectedResources[i]; IResource resource = project.findMember(path); if (resource != null) { if (resource.isDerived(IResource.CHECK_ANCESTORS)) { String value = projectRegularPrefs.get(path, null); projectRegularPrefs.remove(path); // lazy creation of derived preferences if (projectDerivedPrefs == null) projectDerivedPrefs = getPreferences(project, true, true, true); projectDerivedPrefs.put(path, value); prefsChanged = true; } } } if (prefsChanged) { Map<IProject, Boolean> projectsToSave = new HashMap<>(); // this is internal change so do not notify charset delta job projectsToSave.put(project, Boolean.TRUE); job.addChanges(projectsToSave); } } catch (BackingStoreException e) { // problems with the project scope... we will miss the changes (but will log) String message = Messages.resources_readingEncoding; Policy.log( new ResourceStatus( IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e)); } }
protected void collectBrakePoint(IResource resource) throws CoreException { fBreakpoints = new BucketMap<IResource, IBreakpoint>(6); fBreakpointAttributes = new HashMap<IBreakpoint, Map<String, Object>>(6); final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); IMarker[] markers = resource.findMarkers(IBreakpoint.LINE_BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE); for (IMarker marker : markers) { IResource markerResource = marker.getResource(); IBreakpoint breakpoint = breakpointManager.getBreakpoint(marker); if (breakpoint != null) { fBreakpoints.add(markerResource, breakpoint); fBreakpointAttributes.put(breakpoint, breakpoint.getMarker().getAttributes()); } } }
/** * Translates new-style authorize() method call to the old-style (including permissions and the * hierarchy). */ @Override public Set<Permission> authorize(AuthenticatedUser user, IResource resource) { if (!(resource instanceof DataResource)) throw new IllegalArgumentException( String.format("%s resource is not supported by LegacyAuthorizer", resource.getName())); DataResource dr = (DataResource) resource; List<Object> legacyResource = new ArrayList<Object>(); legacyResource.add(Resources.ROOT); legacyResource.add(Resources.KEYSPACES); if (!dr.isRootLevel()) legacyResource.add(dr.getKeyspace()); if (dr.isColumnFamilyLevel()) legacyResource.add(dr.getColumnFamily()); Set<Permission> permissions = authorize(user, legacyResource); if (permissions.contains(Permission.READ)) permissions.add(Permission.SELECT); if (permissions.contains(Permission.WRITE)) permissions.addAll( EnumSet.of(Permission.CREATE, Permission.ALTER, Permission.DROP, Permission.MODIFY)); return permissions; }