use of org.eclipse.core.resources.IResourceDelta in project ow by vtst.
the class ClosureBuilder method build.
/* (non-Javadoc)
* @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
IProject project = getProject();
OwJsDev.log("Start build: %s", project.getName());
monitor.beginTask(messages.format("build_closure", project.getName()), 2);
if (kind == FULL_BUILD) {
fullBuild(monitor, project);
} else {
IResourceDelta delta = getDelta(project);
if (delta == null) {
fullBuild(monitor, project);
} else {
incrementalBuild(monitor, project, delta);
}
}
monitor.done();
OwJsDev.log("End build: %s", project.getName());
return ResourceProperties.getTransitivelyReferencedProjects(project);
}
use of org.eclipse.core.resources.IResourceDelta in project azure-tools-for-java by Microsoft.
the class AIResourceChangeListener method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta resourcedelta = event.getDelta();
IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
IProject project = delta.getResource().getProject();
// Check if project is of required nature
if (project != null && project.isOpen() && WebPropertyTester.isWebProj(project)) {
handleResourceChange(delta);
}
return true;
}
};
try {
resourcedelta.accept(visitor);
WorkspaceJob job = new WorkspaceJob(Messages.refreshJobName) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
return Status.OK_STATUS;
}
};
job.schedule();
} catch (CoreException e) {
Activator.getDefault().log(Messages.resChangeErr, e);
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class OSGiRunLaunchDelegate method registerLaunchPropertiesRegenerator.
/**
* Registers a resource listener with the project model file to update the launcher when the model or any of the
* run-bundles changes. The resource listener is automatically unregistered when the launched process terminates.
*
* @param project
* @param launch
* @throws CoreException
*/
private void registerLaunchPropertiesRegenerator(final Project project, final ILaunch launch) throws CoreException {
final IResource targetResource = LaunchUtils.getTargetResource(launch.getLaunchConfiguration());
if (targetResource == null)
return;
final IPath bndbndPath;
try {
bndbndPath = Central.toPath(project.getPropertiesFile());
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error querying bnd.bnd file location", e));
}
try {
Central.toPath(project.getTarget());
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error querying project output folder", e));
}
final IResourceChangeListener resourceListener = new IResourceChangeListener() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
try {
final AtomicBoolean update = new AtomicBoolean(false);
// Was the properties file (bnd.bnd or *.bndrun) included in
// the delta?
IResourceDelta propsDelta = event.getDelta().findMember(bndbndPath);
if (propsDelta == null && targetResource.getType() == IResource.FILE)
propsDelta = event.getDelta().findMember(targetResource.getFullPath());
if (propsDelta != null) {
if (propsDelta.getKind() == IResourceDelta.CHANGED) {
update.set(true);
}
}
// list
if (!update.get()) {
final Set<String> runBundleSet = new HashSet<String>();
for (String bundlePath : bndLauncher.getRunBundles()) {
runBundleSet.add(new org.eclipse.core.runtime.Path(bundlePath).toPortableString());
}
event.getDelta().accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
// match
if (update.get())
return false;
IResource resource = delta.getResource();
if (resource.getType() == IResource.FILE) {
IPath location = resource.getLocation();
boolean isRunBundle = location != null ? runBundleSet.contains(location.toPortableString()) : false;
update.compareAndSet(false, isRunBundle);
return false;
}
// Recurse into containers
return true;
}
});
}
if (update.get()) {
project.forceRefresh();
project.setChanged();
bndLauncher.update();
}
} catch (Exception e) {
logger.logError("Error updating launch properties file.", e);
}
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener);
// Register a listener for termination of the launched process
Runnable onTerminate = new Runnable() {
@Override
public void run() {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceListener);
display.asyncExec(new Runnable() {
@Override
public void run() {
if (dialog != null && dialog.getShell() != null) {
dialog.getShell().dispose();
}
}
});
}
};
DebugPlugin.getDefault().addDebugEventListener(new TerminationListener(launch, onTerminate));
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class JAREditor method resourceChanged.
@Override
public void resourceChanged(final IResourceChangeEvent event) {
IResource myResource = ResourceUtil.getResource(getEditorInput());
IResourceDelta delta = event.getDelta();
if (delta == null) {
return;
}
IPath fullPath = myResource.getFullPath();
delta = delta.findMember(fullPath);
if (delta == null) {
return;
}
if (delta.getKind() == IResourceDelta.REMOVED) {
close(false);
} else if (delta.getKind() == IResourceDelta.CHANGED) {
updateContent(getEditorInput());
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class BndEditor method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResource myResource = ResourceUtil.getResource(getEditorInput());
IResourceDelta delta = event.getDelta();
if (delta == null)
return;
IPath fullPath = myResource.getFullPath();
delta = delta.findMember(fullPath);
if (delta == null)
return;
// Delegate to any interested pages
for (Object page : pages) {
if (page instanceof IResourceChangeListener) {
((IResourceChangeListener) page).resourceChanged(event);
}
}
// Close editor if file removed or switch to new location if file moved
if (delta.getKind() == IResourceDelta.REMOVED) {
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getMovedToPath());
final FileEditorInput newInput = new FileEditorInput(file);
setInput(newInput);
Display display = getEditorSite().getShell().getDisplay();
if (display != null) {
SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {
@Override
public void run() {
setPartNameForInput(newInput);
sourcePage.setInput(newInput);
}
});
}
} else {
close(false);
}
} else // File content updated externally => reload all pages
if ((delta.getKind() & IResourceDelta.CHANGED) > 0 && (delta.getFlags() & IResourceDelta.CONTENT) > 0) {
if (!saving.get()) {
final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
// #1625: Ensure the IDocumentProvider is not null.
if (docProvider != null) {
final IDocument document = docProvider.getDocument(getEditorInput());
SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {
@Override
public void run() {
try {
model.loadFrom(new IDocumentWrapper(document));
updateIncludedPages();
} catch (IOException e) {
logger.logError("Failed to reload document", e);
}
}
});
}
}
}
}
Aggregations