Java Code Examples for org.eclipse.core.resources.IResourceDelta

The following are top voted examples for showing how to use org.eclipse.core.resources.IResourceDelta. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: N4JSAllContainersState.java   Source Code and License 6 votes vote down vote up
private void tryValidateManifest(final IResourceDelta delta) {
	final String fullPath = delta.getFullPath().toString();
	final URI folderUri = URI.createPlatformResourceURI(fullPath, true);
	final IN4JSProject project = core.findProject(folderUri).orNull();
	if (null != project && project.exists()) {
		final URI manifestLocation = project.getManifestLocation().orNull();
		if (null != manifestLocation) {
			final IFile manifest = delta.getResource().getProject().getFile(N4MF_MANIFEST);
			final ResourceSet resourceSet = core.createResourceSet(Optional.of(project));
			final Resource resource = resourceSet.getResource(manifestLocation, true);
			final Job job = Job.create("", monitor -> {
				validatorExtension.updateValidationMarkers(manifest, resource, ALL, monitor);
				return OK_STATUS;
			});
			job.setPriority(INTERACTIVE);
			job.schedule();
		}
	}
}
 
Example 2
Project: n4js   File: N4JSAllContainersState.java   Source Code and License 6 votes vote down vote up
private void tryValidateManifestInEditor(final IResourceDelta delta) {
	if (isWorkbenchRunning()) {
		Display.getDefault().asyncExec(() -> {
			final IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
			if (null != window) {
				final IWorkbenchPage page = window.getActivePage();
				for (final IEditorReference editorRef : page.getEditorReferences()) {
					if (isEditorForResource(editorRef, delta.getResource())) {
						final IWorkbenchPart part = editorRef.getPart(true);
						if (part instanceof XtextEditor) {
							editorCallback.afterSave((XtextEditor) part);
							return;
						}
					}
				}
			}
		});
	}
}
 
Example 3
Project: n4js   File: WorkspaceRepositoriesProvider.java   Source Code and License 6 votes vote down vote up
/**
 * Handles the given resource delta.
 *
 * Fires workspace repository changed event if a project was opened/closed or a project was added/removed.
 */
private boolean handleResourceDelta(IResourceDelta delta) {
	IResource affectedResource = delta.getResource();

	if (affectedResource instanceof IProject) {
		// check if kind is CHANGED
		if ((delta.getKind() & IResourceDelta.CHANGED) == IResourceDelta.CHANGED) {
			// if project was opened/closed
			if ((delta.getFlags() & IResourceDelta.OPEN) == IResourceDelta.OPEN) {
				fireWorkspaceRepositoriesChanged();
				return false;
			}
		}
		// check if kind is ADDED or REMOVED
		else if ((delta.getKind() & IResourceDelta.ADDED | IResourceDelta.REMOVED) != 0) {
			fireWorkspaceRepositoriesChanged();
			return false;
		}
	}
	return true;
}
 
Example 4
Project: EclipseMinifyBuilder   File: MinifyBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args,
		IProgressMonitor monitor) throws CoreException {
	ProjectScope projectScope = new ProjectScope(getProject());
	IEclipsePreferences prefs = projectScope.getNode(BUILDER_ID);
	if (kind == FULL_BUILD) {
		fullBuild(prefs, monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(prefs, monitor);
		} else {
			incrementalBuild(delta, prefs, monitor);
		}
	}
	return null;
}
 
Example 5
Project: gemoc-studio-modeldebugging   File: GemocSequentialLanguageBuilder.java   Source Code and License 6 votes vote down vote up
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		updateProjectPluginConfiguration(resource);
		checkConsistency(resource);
		break;
	case IResourceDelta.REMOVED:
		updateProjectPluginConfiguration(resource);
		checkConsistency(resource);
		break;
	case IResourceDelta.CHANGED:
		updateProjectPluginConfiguration(resource);
		checkConsistency(resource);
		break;
	}
	//return true to continue visiting children.
	return true;
}
 
Example 6
Project: gemoc-studio-modeldebugging   File: DSLDebugTargetAdapter.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint,
 *      org.eclipse.core.resources.IMarkerDelta)
 */
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
	if (supportsBreakpoint(breakpoint)) {
		try {
			final URI uri = ((DSLBreakpoint)breakpoint).getURI();
			final IMarker marker = breakpoint.getMarker();
			for (Entry<String, Object> entry : delta.getAttributes().entrySet()) {
				final Object markerValue = marker.getAttribute(entry.getKey());
				final Object deltaValue = entry.getValue();
				if ((markerValue != null && !markerValue.equals(deltaValue)) || (deltaValue != null
						&& !deltaValue.equals(markerValue))) {
					if (delta.getKind() == IResourceDelta.ADDED) {
						factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
								(Serializable)deltaValue));
					} else {
						factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
								(Serializable)markerValue));
					}
				}
			}
		} catch (CoreException e) {
			Activator.getDefault().error(e);
		}
	}
}
 
Example 7
Project: eclipse-batch-editor   File: BatchEditor.java   Source Code and License 6 votes vote down vote up
private boolean isMarkerChangeForThisEditor(IResourceChangeEvent event) {
	IResource resource = ResourceUtil.getResource(getEditorInput());
	if (resource == null) {
		return false;
	}
	IPath path = resource.getFullPath();
	if (path == null) {
		return false;
	}
	IResourceDelta eventDelta = event.getDelta();
	if (eventDelta == null) {
		return false;
	}
	IResourceDelta delta = eventDelta.findMember(path);
	if (delta == null) {
		return false;
	}
	boolean isMarkerChangeForThisResource = (delta.getFlags() & IResourceDelta.MARKERS) != 0;
	return isMarkerChangeForThisResource;
}
 
Example 8
Project: neoscada   File: PreviewEditorImpl.java   Source Code and License 6 votes vote down vote up
protected boolean handleResource ( final IResourceDelta delta )
{
    if ( delta.getResource ().getType () != IResource.FILE )
    {
        return true;
    }

    if ( delta.getFlags () == IResourceDelta.MARKERS )
    {
        return false;
    }

    final URI uri = URI.createPlatformResourceURI ( delta.getFullPath ().toString (), true );
    if ( !this.loadedUris.contains ( uri ) )
    {
        return true;
    }

    fireResourceChange ();

    return true;
}
 
Example 9
Project: eclipse-bash-editor   File: BashEditor.java   Source Code and License 6 votes vote down vote up
private boolean isMarkerChangeForThisEditor(IResourceChangeEvent event) {
	IResource resource = ResourceUtil.getResource(getEditorInput());
	if (resource == null) {
		return false;
	}
	IPath path = resource.getFullPath();
	if (path == null) {
		return false;
	}
	IResourceDelta eventDelta = event.getDelta();
	if (eventDelta == null) {
		return false;
	}
	IResourceDelta delta = eventDelta.findMember(path);
	if (delta == null) {
		return false;
	}
	boolean isMarkerChangeForThisResource = (delta.getFlags() & IResourceDelta.MARKERS) != 0;
	return isMarkerChangeForThisResource;
}
 
Example 10
Project: Equella   File: WorkspaceJarModelManager.java   Source Code and License 6 votes vote down vote up
@Override
protected void handleFileDelta(IResourceDelta delta)
{
	IFile file = (IFile) delta.getResource();
	JarPluginModelImpl existing = jarModels.get(file);
	if( delta.getKind() == IResourceDelta.REMOVED && existing != null )
	{
		removeJar(existing);
	}
	else if( delta.getKind() == IResourceDelta.ADDED )
	{
		if( isPluginJar(file) )
		{
			addJarModel(fModels.get(file.getProject()), file, true);
		}
	}
	else if( delta.getKind() == IResourceDelta.CHANGED && existing != null )
	{
		existing.reload();
		addChange(existing, IModelProviderEvent.MODELS_CHANGED);
	}
}
 
Example 11
Project: Equella   File: JPFManifestBuilder.java   Source Code and License 6 votes vote down vote up
@Override
public boolean visit(IResourceDelta delta) throws CoreException
{
	IResource resource = delta.getResource();
	if( resource.isDerived() )
	{
		return false;
	}
	if( resource.getType() == IResource.FILE )
	{
		IFile file = (IFile) resource;
		IProject project = resource.getProject();
		if( file.equals(JPFProject.getManifest(project)) )
		{
			manifestChanged = true;
			return false;
		}
	}
	return true;
}
 
Example 12
Project: gw4e.project   File: GW4EBuilder.java   Source Code and License 6 votes vote down vote up
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	if (!PreferenceManager.isBuildEnabled(resource.getProject().getName())) {
		if (resource instanceof IFile) {
			deleteMarkers((IFile)resource);
		}
		return true;
	}
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		checkResource(resource);
		break;
	case IResourceDelta.REMOVED:
		checkRemovedResource(resource);
		break;
	case IResourceDelta.CHANGED:
		checkResource(resource);
		break;
	}
	// return true to continue visiting children.
	return true;
}
 
Example 13
Project: gw4e.project   File: GW4EBuilder.java   Source Code and License 6 votes vote down vote up
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor)
		throws CoreException {
	ResourceManager.logInfo(getProject().getName(), "Build requested " );

	if (kind == FULL_BUILD) {
		fullBuild(monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(monitor);
		} else {
			incrementalBuild(delta, monitor);
		}
	}
	return null;
}
 
Example 14
Project: pgcodekeeper   File: ProjectEditorDiffer.java   Source Code and License 6 votes vote down vote up
private void handleChangeProject(IResourceDelta rootDelta) {
    final boolean[] schemaChanged = new boolean[1];
    try {
        rootDelta.accept(delta -> {
            if (schemaChanged[0]) {
                return false;
            }
            // something other than just markers has changed
            // check that it's our resource
            if (delta.getFlags() != IResourceDelta.MARKERS &&
                    PgUIDumpLoader.isInProject(delta) &&
                    delta.getResource().getType() == IResource.FILE &&
                    delta.getResource().getProject().equals(proj.getProject())) {
                schemaChanged[0] = true;
                return false;
            }
            return true;
        });
    } catch (CoreException ex) {
        Log.log(ex);
    }

    if (schemaChanged[0]) {
        UiSync.exec(parent, this::notifyProjectChanged);
    }
}
 
Example 15
Project: pgcodekeeper   File: ProjectBuilder.java   Source Code and License 6 votes vote down vote up
private void buildIncrement(IResourceDelta delta, PgDbParser parser, IProgressMonitor monitor)
        throws CoreException, InterruptedException, IOException {
    List<IFile> files = new ArrayList<>();
    delta.accept(d -> {
        if (PgUIDumpLoader.isInProject(d)) {
            IResource res = d.getResource();
            if (res.getType() == IResource.FILE) {
                switch (d.getKind()) {
                case IResourceDelta.REMOVED:
                case IResourceDelta.REMOVED_PHANTOM:
                    parser.removePathFromRefs(res.getLocation().toOSString());
                    break;
                default:
                    files.add((IFile) res);
                    break;
                }
            }
        }
        return true;
    });
    parser.getObjFromProjFiles(files, monitor);
}
 
Example 16
Project: ec4e   File: IDEEditorConfigManager.java   Source Code and License 6 votes vote down vote up
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	if (resource == null) {
		return false;
	}
	switch (resource.getType()) {
	case IResource.ROOT:
	case IResource.PROJECT:
	case IResource.FOLDER:
		return true;
	case IResource.FILE:
		IFile file = (IFile) resource;
		if (EditorConfigConstants.EDITORCONFIG.equals(file.getName())
				&& delta.getKind() == IResourceDelta.CHANGED) {
			entries.remove(new FileResource(file));
		}
	}
	return false;
}
 
Example 17
Project: ec4e   File: EditorConfigContentProvider.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if ((event.getDelta().getFlags() ^ IResourceDelta.MARKERS) != 0) {
		try {
			event.getDelta().accept(delta -> {
				if (delta.getResource().equals(this.resource)) {
					viewer.getControl().getDisplay().asyncExec(() -> {
						if (viewer instanceof StructuredViewer) {
							viewer.refresh(true);
						}
					});
				}
				return delta.getResource().getFullPath().isPrefixOf(this.resource.getFullPath());
			});
		} catch (CoreException e) {
			// LanguageServerPlugin.logError(e);
		}
	}
}
 
Example 18
Project: visuflow-plugin   File: JimpleBuilder.java   Source Code and License 6 votes vote down vote up
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	if (resource.getFileExtension() != null){
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		if(resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	case IResourceDelta.REMOVED:
		if(resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	case IResourceDelta.CHANGED:
		if( resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	}
	}
	return true;
}
 
Example 19
Project: visuflow-plugin   File: JimpleBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
	executeBuild = false;
	if(getProject() != null && getProject().getName().equals(GlobalSettings.get("AnalysisProject"))){
		if (kind == FULL_BUILD) {
			fullBuild(monitor);
		} else {
			IResourceDelta delta = getDelta(getProject());
			if (delta == null) {
				fullBuild(monitor);
			} else {
				checkForBuild(delta, monitor);
			}
		}
	}
	return null;
}
 
Example 20
Project: egradle   File: AbstractGroovyBasedEditor.java   Source Code and License 6 votes vote down vote up
private boolean isMarkerChangeForThisEditor(IResourceChangeEvent event) {
	IResource resource = ResourceUtil.getResource(getEditorInput());
	if (resource == null) {
		return false;
	}
	IPath path = resource.getFullPath();
	if (path == null) {
		return false;
	}
	IResourceDelta eventDelta = event.getDelta();
	if (eventDelta == null) {
		return false;
	}
	IResourceDelta delta = eventDelta.findMember(path);
	if (delta == null) {
		return false;
	}
	boolean isMarkerChangeForThisResource = (delta.getFlags() & IResourceDelta.MARKERS) != 0;
	return isMarkerChangeForThisResource;
}
 
Example 21
Project: egradle   File: VirtualRootNewFilesToRealRootProjectBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
	IProject project = getProject();
	if (!project.isOpen()) {
		return null;
	}
	if (!(project.hasNature(VirtualRootProjectNature.NATURE_ID))) {
		return null;
	}
	File projectOnRealFileSystem = project.getLocation().toFile();
	File rootProjectFolder = projectOnRealFileSystem.getParentFile();
	if (kind == FULL_BUILD) {
		fullBuild(rootProjectFolder, monitor);
	} else {

		IResourceDelta delta = getDelta(project);
		if (delta == null) {
			fullBuild(rootProjectFolder, monitor);
		} else {
			incrementalBuild(rootProjectFolder, delta, monitor);
		}
	}
	return null;
}
 
Example 22
Project: eclipse-asciidoctools   File: AsciidocBuildHelper.java   Source Code and License 6 votes vote down vote up
public static void incrementalBuild(IProject project, IResourceDelta delta, IProgressMonitor monitor) throws CoreException, IOException {
	AsciidocConfiguration configuration = AsciidocConfiguration.getConfiguration(project);
	if (delta == null) {
		fullBuild(project, monitor);
		return;
	}

	IFolder resourcesFolder = project.getFolder(new Path(configuration.getResourcesPath()));
	IFolder sourcesFolder = project.getFolder(new Path(configuration.getSourcesPath()));
	IFolder targetFolder = project.getFolder(new Path(configuration.getTargetPath()));

	monitor.subTask("Locating resources to process...");
	AsciidocResourceVisitor visitor = new AsciidocResourceVisitor(sourcesFolder, resourcesFolder);
	delta.accept(visitor);

	copy(resourcesFolder, visitor.getResourceFiles(), targetFolder, monitor);
	generate(sourcesFolder, visitor.getSourceFiles(), targetFolder, configuration, monitor);
	monitor.subTask("Refreshing target folder...");

}
 
Example 23
Project: LibertyEiffel-Eclipse-Plugin   File: EiffelProjectBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
	
	if (kind == IncrementalProjectBuilder.FULL_BUILD) {
		fullBuild(monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(monitor);
		} else {
			incrementalBuild(delta, monitor);
		}
	}
	
	return null;
}
 
Example 24
Project: team-explorer-everywhere   File: ImportLocalPathStrategy.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 25
Project: subclipse   File: StatusCacheManager.java   Source Code and License 6 votes vote down vote up
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();
	}
}
 
Example 26
Project: subclipse   File: SyncFileChangeListener.java   Source Code and License 6 votes vote down vote up
protected void handleSVNDir(IContainer svnDir, int kind) {
	if((kind & IResourceDelta.ALL_WITH_PHANTOMS)!=0) {
		if(kind==IResourceDelta.ADDED) {
			// should this dir be made team-private? If it contains Entries then yes!
			IFile entriesFile = svnDir.getFile(new Path(SVNConstants.SVN_ENTRIES));

			if (entriesFile.exists() &&  !svnDir.isTeamPrivateMember()) {
				try {
					svnDir.setTeamPrivateMember(true);			
					if(Policy.DEBUG_METAFILE_CHANGES) {
						System.out.println("[svn] found a new SVN meta folder, marking as team-private: " + svnDir.getFullPath()); //$NON-NLS-1$
					}
				} catch(CoreException e) {
					SVNProviderPlugin.log(SVNException.wrapException(svnDir, Policy.bind("SyncFileChangeListener.errorSettingTeamPrivateFlag"), e)); //$NON-NLS-1$
				}
			}
		}
	}
}
 
Example 27
Project: Vitruv   File: VitruviusEmfBuilder.java   Source Code and License 6 votes vote down vote up
@Override
public boolean visit(final IResourceDelta delta) throws CoreException {
    final IResource iResource = delta.getResource();
    final String fileExtension = iResource.getFileExtension();
    final boolean isMonitoredResource = VitruviusEmfBuilder.this.getMonitoredFileTypes().contains(fileExtension);
    if (isMonitoredResource) {
        switch (delta.getKind()) {
        case IResourceDelta.ADDED:
            LOGGER.debug("Importing to Vitruvius: " + iResource);
            VitruviusEmfBuilder.this.importToVitruvius(iResource);
            break;
        case IResourceDelta.REMOVED:
            LOGGER.debug("Removing from Vitruvius: " + iResource);
            VitruviusEmfBuilder.this.removeFromVitruvius(iResource);
            break;
        case IResourceDelta.CHANGED:
            // LOGGER.debug("Resource changed: " + iResource);
            VitruviusEmfBuilder.this.triggerSynchronisation(iResource);
            break;
        default:
            LOGGER.debug("No action for change kind: '" + delta.getKind() + "' executed.");
        }
    }
    // return true to continue visiting children.
    return true;
}
 
Example 28
Project: Vitruv   File: VitruviusEmfBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(final int kind, final Map<String, String> args, final IProgressMonitor monitor)
        throws CoreException {
	super.build(kind, args, monitor);
    if (kind == FULL_BUILD) {
        this.fullBuild(monitor);
    } else {
        final IResourceDelta delta = this.resourceDeltaProviding.getDelta(this.projectProviding.getProject());
        if (delta == null) {
            this.fullBuild(monitor);
        } else {
            this.incrementalBuild(delta, monitor);
        }
    }
    return null;
}
 
Example 29
Project: hybris-commerce-eclipse-plugin   File: TsvBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor)
		throws CoreException {
	//TODO find referenced extensions and their eclipse projects and return them
	if (kind == CLEAN_BUILD) {
		clean(monitor);
	}
	else if (kind == FULL_BUILD) {
		fullBuild(monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(monitor);
		} else {
			incrementalBuild(delta, monitor);
		}
	}
	return null;
}
 
Example 30
Project: hybris-commerce-eclipse-plugin   File: PlatformHolder.java   Source Code and License 6 votes vote down vote up
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));
	}
}
 
Example 31
Project: abaplint-eclipse   File: AbaplintBuilder.java   Source Code and License 6 votes vote down vote up
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		checkABAP(resource);
		break;
	case IResourceDelta.REMOVED:
		break;
	case IResourceDelta.CHANGED:
		checkABAP(resource);
		break;
    default: // do nothing
        break;				
	}
	return true;
}
 
Example 32
Project: mytourbook   File: Builder.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
 */
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		// handle added resource
              System.out.println("RBE DELTA added");
		checkBundleResource(resource);
		break;
	case IResourceDelta.REMOVED:
              System.out.println("RBE DELTA Removed"); //$NON-NLS-1$
		// handle removed resource
		break;
	case IResourceDelta.CHANGED:
              System.out.println("RBE DELTA changed");
		// handle changed resource
		checkBundleResource(resource);
		break;
	}
	//return true to continue visiting children.
	return true;
}
 
Example 33
Project: typescript.java   File: ProblemManager.java   Source Code and License 6 votes vote down vote up
private void handleResourceChanged(IResourceChangeEvent event) {
	IResourceDelta delta = event.getDelta();
	if (delta == null) {
		return;
	}

	// Find resourced whose problems changed and report them to listeners
	Set<IResource> changedResources = new HashSet<>();
	try {
		delta.accept(new ProblemMarkerDeltaVisitor(changedResources));
	} catch (CoreException e) {
		TypeScriptCorePlugin.logError(e);
	}
	if (!changedResources.isEmpty()) {
		notifyListeners(Collections.unmodifiableSet(changedResources));
	}
}
 
Example 34
Project: typescript.java   File: TypeScriptBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, Map<String, String> args, final IProgressMonitor monitor)
		throws CoreException {
	IProject project = this.getProject();
	if (!TypeScriptResourceUtil.isTypeScriptProject(project)) {
		return null;
	}

	IIDETypeScriptProject tsProject = TypeScriptResourceUtil.getTypeScriptProject(project);
	if (kind == FULL_BUILD) {
		fullBuild(tsProject, monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(tsProject, monitor);
		} else {
			incrementalBuild(tsProject, delta, monitor);
		}
	}
	return null;
}
 
Example 35
Project: jsbuild-eclipse   File: NavigatorJSBuildFileContentProvider.java   Source Code and License 6 votes vote down vote up
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	if (resource == null) {
		return false;
	}
	switch (resource.getType()) {
	case IResource.ROOT:
	case IResource.PROJECT:
	case IResource.FOLDER:
		return true;
	case IResource.FILE:
		IFile file = (IFile) delta.getResource();
		if (fViewer != null
				&& JSBuildFileFactoryManager.findFactoryId(file) != null) {
			// refresh the tasks for the Build file (Gruntfile.js,
			// gulpfile.js) inside the Project Explorer
			if (!fViewer.isBusy()) {
				fViewer.refresh(file);
			}
		}
		return false;
	}
	return false;

}
 
Example 36
Project: cmake-eclipse-helper   File: DerivedDeltaVisitor.java   Source Code and License 6 votes vote down vote up
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	switch(resource.getType()) {
	case IResource.FOLDER:
	case IResource.ROOT:
		return true;
	case IResource.PROJECT:
		return CMakeNature.isCMakeProject((IProject)resource);
	default:
		break;
	}

	if(delta.getKind() != IResourceDelta.ADDED) {
		return false;
	}
	
	IResource parent = resource.getParent();
	while(parent.getType() != IResource.PROJECT) {
		if(parent.isDerived()) {
			listToDerive.add(resource);
			return false;
		}
	}
	return false;
}
 
Example 37
Project: gama   File: ImageViewer.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	final IResourceDelta delta = event.getDelta().findMember(imageFile.getFullPath());
	if (delta != null) {
		// file deleted -- close the editor
		if (delta.getKind() == IResourceDelta.REMOVED) {
			final Runnable r = () -> getSite().getPage().closeEditor(ImageViewer.this, false);
			getSite().getShell().getDisplay().asyncExec(r);
		}
		// file changed -- reload image
		else if (delta.getKind() == IResourceDelta.CHANGED) {
			final int flags = delta.getFlags();
			if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.LOCAL_CHANGED) != 0) {
				startImageLoad();
			}
		}
	}
}
 
Example 38
Project: APICloud-Studio   File: SyncFileChangeListener.java   Source Code and License 6 votes vote down vote up
protected void handleSVNDir(IContainer svnDir, int kind) {
	if((kind & IResourceDelta.ALL_WITH_PHANTOMS)!=0) {
		if(kind==IResourceDelta.ADDED) {
			// should this dir be made team-private? If it contains Entries then yes!
			IFile entriesFile = svnDir.getFile(new Path(SVNConstants.SVN_ENTRIES));

			if (entriesFile.exists() &&  !svnDir.isTeamPrivateMember()) {
				try {
					svnDir.setTeamPrivateMember(true);			
					if(Policy.DEBUG_METAFILE_CHANGES) {
						System.out.println("[svn] found a new SVN meta folder, marking as team-private: " + svnDir.getFullPath()); //$NON-NLS-1$
					}
				} catch(CoreException e) {
					SVNProviderPlugin.log(SVNException.wrapException(svnDir, Policy.bind("SyncFileChangeListener.errorSettingTeamPrivateFlag"), e)); //$NON-NLS-1$
				}
			}
		}
	}
}
 
Example 39
Project: Source   File: SemanticBaseListener.java   Source Code and License 6 votes vote down vote up
/**
 * Process {@link IResourceDelta} with {@link IResourceDelta#CHANGED changed}
 * {@link IResourceDelta#getKind() kind}.
 * 
 * @param delta
 *            the {@link IResourceDelta} with {@link IResourceDelta#CHANGED changed}
 *            {@link IResourceDelta#getKind() kind}
 */
private void processChangedDelta(IResourceDelta delta) {
	if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
		if (delta.getResource().isAccessible()) {
			register((IFile)delta.getResource());
		} else {
			unregister((IFile)delta.getResource());
		}
	} else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
		// nothing to do here
	} else if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) {
		if (resourceToBase.get(delta.getResource()) == null) {
			register((IFile)delta.getResource());
		}
	}
}
 
Example 40
Project: che   File: ResourceChangeChecker.java   Source Code and License 6 votes vote down vote up
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()]);
}