本文整理匯總了Java中org.eclipse.core.resources.IResourceDeltaVisitor類的典型用法代碼示例。如果您正苦於以下問題:Java IResourceDeltaVisitor類的具體用法?Java IResourceDeltaVisitor怎麽用?Java IResourceDeltaVisitor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IResourceDeltaVisitor類屬於org.eclipse.core.resources包,在下文中一共展示了IResourceDeltaVisitor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
@Override
public void resourceChanged(final IResourceChangeEvent event) {
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(final IResourceDelta delta) throws CoreException {
if (delta.getKind() == IResourceDelta.ADDED) {
final IResource resource = delta.getResource();
if (resource.getType() == IResource.PROJECT) {
newProject = (IProject) resource;
} else if (resource.getType() == IResource.FILE
&& PluginResourceFilters.STANDARD_FILTER.filter(
resource) == ResourceFilterResult.ACCEPT) {
filepaths.add(resource.getLocation().toOSString());
}
}
return true;
}
});
} catch (final CoreException e) {
throw new RuntimeException(e);
}
}
示例2: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
public void resourceChanged(IResourceChangeEvent event) {
flushCache = false;
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (resource.getType()==IResource.PROJECT) {
IProject project = (IProject)resource;
if (!project.isAccessible()) {
return false; // i.e., closed project
}
if (SVNWorkspaceRoot.isManagedBySubclipse(project)) {
flushCache = true;
}
return false; // No need to check deeper than project.
}
return true;
}
});
} catch (CoreException e) {
SVNProviderPlugin.log(e.getStatus());
}
if (flushCache) {
statusCache.flushPendingStatuses();
}
}
示例3: workspaceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
void workspaceChanged(IResourceChangeEvent event) {
try {
if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
if (Platform.isPlatformProject((IProject)event.getResource())) {
clear();
}
}
else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
event.getDelta().accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getKind() == IResourceDelta.ADDED
&& delta.getResource().getType() == IResource.PROJECT) {
projectAdded((IProject) delta.getResource());
}
return delta.getResource().getType() == IResource.ROOT;
}
});
}
} catch (CoreException e) {
log.log(new Status(Status.ERROR, log.getBundle().getSymbolicName(), "Error when handling IResourceChangedEvent", e));
}
}
示例4: getRootResources
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
private IResource[] getRootResources(IResourceDelta root) {
final ChangeDescription changeDescription = new ChangeDescription();
try {
root.accept(
new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) {
return changeDescription.recordChange(delta);
}
});
} catch (CoreException e) {
// Shouldn't happen since the ProposedResourceDelta accept doesn't throw an
// exception and our visitor doesn't either
Policy.log(IStatus.ERROR, "Internal error", e); // $NON-NLS-1$
}
return changeDescription.getRootResources();
}
示例5: getChangedFiles
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
IFile[] getChangedFiles() throws CoreException {
IResourceDelta root = fDeltaFactory.getDelta();
final List result = new ArrayList();
root.accept(
new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
final IResource resource = delta.getResource();
if (resource.getType() == IResource.FILE) {
final int kind = delta.getKind();
if (isSet(kind, IResourceDelta.CHANGED)) {
result.add(resource);
} else if (isSet(kind, IResourceDelta.ADDED)
&& isSet(delta.getFlags(), IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM)) {
final IFile movedFrom =
resource.getWorkspace().getRoot().getFile(delta.getMovedFromPath());
result.add(movedFrom);
}
}
return true;
}
});
return (IFile[]) result.toArray(new IFile[result.size()]);
}
示例6: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
public void resourceChanged(IResourceChangeEvent event) {
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
if ((delta.getKind() == IResourceDelta.ADDED) && (delta.getResource() instanceof IFile)) {
IFile mediaFile = (IFile) delta.getResource();
IFolder resource = MediaRootNode.this.getResource();
if (mediaFile.getParent().getFullPath().toString().compareTo(resource.getFullPath().toString()) == 0) {
addNewMedia(mediaFile);
}
} else if ((delta.getKind() == IResourceDelta.REMOVED) && (delta.getResource() == MediaRootNode.this.getResource())) {
MediaRootNode.this.getParent().deleteChildren(new INode[] { MediaRootNode.this });
}
return true;
}
});
} catch (CoreException ex) {
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
logger.log(status);
}
}
示例7: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
public void resourceChanged(IResourceChangeEvent event) {
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
// IResource affectedResource = delta.getResource();
// if (delta.getKind() == IResourceDelta.REMOVED &&
// affectedResource instanceof IFile) {
// if
// (affectedResource.getFullPath().toString().compareTo(MediaNode.this.resource.getFullPath().toString())==0)
// {
// MediaNode.this.getParent().deleteChildren(new INode[]
// {MediaNode.this});
// }
// }
return true;
}
});
} catch (CoreException ex) {
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
logger.log(status);
}
}
示例8: getAddedProjects
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
/**
* Returns a list of newly added projects.
* @param resourceDelta
* @return List of newly added projects.
*/
private List<IProject> getAddedProjects(IResourceDelta resourceDelta){
final List<IProject> projects = new ArrayList<IProject>();
try {
resourceDelta.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getKind() == IResourceDelta.ADDED && delta.getResource().getType() == IResource.PROJECT) {
IProject project = (IProject) delta.getResource();
projects.add(project);
return false;
}
return delta.getResource().getType() == IResource.ROOT;
}
});
} catch (CoreException e) {
e.printStackTrace();
}
return projects;
}
示例9: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
@Override
public void resourceChanged(IResourceChangeEvent event) {
try {
IResourceDelta delta = event.getDelta();
CMakeTouchDeltaVisitor touchVisitor = new CMakeTouchDeltaVisitor();
delta.accept(touchVisitor);
touchVisitor.postProcess();
for(IResourceDeltaVisitor visitor : reusableVisitors) {
delta.accept(visitor);
}
} catch (CoreException e) {
e.printStackTrace();
}
}
開發者ID:USESystemEngineeringBV,項目名稱:cmake-eclipse-helper,代碼行數:18,代碼來源:CMakeProjectResourceChangeListener.java
示例10: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
@Override
public void resourceChanged(@Nullable IResourceChangeEvent event) {
Preconditions.checkNotNull(event);
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta delta = event.getDelta();
IResourceDeltaVisitor visitor = delta1 -> {
resources.add(delta1.getResource());
return true;
};
try {
synchronized (this) {
visitor.visit(delta);
}
} catch (CoreException e) {
e.printStackTrace();
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
fireLabelChangedEvent();
}
});
}
}
示例11: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
@Override
public void resourceChanged(IResourceChangeEvent event) {
if (event == null || event.getDelta() == null) {
return;
}
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(final IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if ((resource.getType() & IResource.PROJECT) != 0) {
IProject project = (IProject) resource;
if (project.isOpen()) {
projectChanged(project);
return false;
}
}
return true;
}
});
} catch (Throwable t) {
RoboVMPlugin.log(t);
}
}
示例12: handleDelta
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
private void handleDelta(IResourceDelta d) {
try {
d.accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
switch (delta.getKind()) {
case IResourceDelta.ADDED:
return false;
case IResourceDelta.REMOVED:
IResource res = delta.getResource();
if (res instanceof IFile) {
Match[] matches = fResult.getMatches(res);
fResult.removeMatches(matches);
}
break;
case IResourceDelta.CHANGED:
// handle changed resource (remove existing matches and redo search in file).
break;
}
return true;
}
});
} catch (CoreException e) {
Log.log(e);
}
}
示例13: handleDelta
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
private void handleDelta(IResourceDelta d) {
try {
d.accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
switch (delta.getKind()) {
case IResourceDelta.ADDED:
return false;
case IResourceDelta.REMOVED:
IResource res = delta.getResource();
if (res instanceof IFile) {
Match[] matches = fResult.getMatches(res);
fResult.removeMatches(matches);
}
break;
case IResourceDelta.CHANGED:
// handle changed resource
break;
}
return true;
}
});
} catch (CoreException e) {
Log.log(e);
}
}
示例14: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
public void resourceChanged(final IResourceChangeEvent event) {
try {
// under special circumstances (e.g. renaming a project) the
// event.getDelta() can be null. Avoid NPE.
if (event.getDelta() == null)
return;
// collect changed projects. only ecore files and jars in the
// classpath are relevant
final Set<IProject> changedProjects = new HashSet<IProject>();
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(final IResourceDelta delta) throws CoreException {
if ((isEcoreFile(delta.getResource()) || isJarFile(delta.getResource()))
&& JavaCore.create(delta.getResource().getProject()).isOnClasspath(delta.getResource())) {
changedProjects.add(delta.getResource().getProject());
}
return true;
}
});
analyzeAndRebuildProjects(changedProjects);
}
catch (final CoreException e) {
EmfToolsLog.logError(e);
}
}
示例15: resourceChanged
import org.eclipse.core.resources.IResourceDeltaVisitor; //導入依賴的package包/類
public void resourceChanged(IResourceChangeEvent event) {
IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) {
IResource affected = delta.getResource();
if (affected.getType() != IResource.PROJECT) {
return true;
}
if ((delta.getKind() == IResourceDelta.OPEN)|(delta.getKind() == IResourceDelta.REMOVED)) {
IProject project = (IProject) affected;
models.remove(project.getName());
}
return true;
}
};
try {
event.getDelta().accept(visitor);
} catch (CoreException e) {
e.printStackTrace();
}
}