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

The following are top voted examples for showing how to use org.eclipse.core.resources.IResourceChangeEvent. 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: NfarStorageMapper.java   Source Code and License 6 votes vote down vote up
@Override
public void initializeCache() {
	Optional<? extends IN4JSEclipseProject> projectOpt = null;
	IN4JSEclipseProject n4jsProject = null;
	for (IProject project : workspace.getRoot().getProjects()) {
		projectOpt = eclipseCore.create(project);
		if (projectOpt.isPresent()) {
			n4jsProject = projectOpt.get();
			if (n4jsProject.exists()) {
				updateCache(n4jsProject);
			}
		}
	}
	Listener listener = new Listener();
	workspace.addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
}
 
Example 2
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 3
Project: neoscada   File: PreviewEditorImpl.java   Source Code and License 6 votes vote down vote up
public PreviewEditorImpl ()
{
    this.adapterFactory = new ComposedAdapterFactory ( ComposedAdapterFactory.Descriptor.Registry.INSTANCE );
    this.adapterFactory.addAdapterFactory ( new ResourceItemProviderAdapterFactory () );
    this.adapterFactory.addAdapterFactory ( new ReflectiveItemProviderAdapterFactory () );

    final BasicCommandStack commandStack = new BasicCommandStack ();

    this.editingDomain = new AdapterFactoryEditingDomain ( this.adapterFactory, commandStack, new HashMap<Resource, Boolean> () );

    this.factoryContext = new FactoryContext () {

        @Override
        public void loadedResource ( final URI uri )
        {
            handleLoadedResource ( uri );
        }
    };

    ResourcesPlugin.getWorkspace ().addResourceChangeListener ( this.resourceChangeListener, IResourceChangeEvent.POST_CHANGE );
}
 
Example 4
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 5
Project: Open_Source_ECOA_Toolset_AS5   File: TypesEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 6
Project: Open_Source_ECOA_Toolset_AS5   File: CompDefEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 7
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 8
Project: Open_Source_ECOA_Toolset_AS5   File: IntLogicalSysEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 9
Project: Open_Source_ECOA_Toolset_AS5   File: IntFinalAssemblyEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 10
Project: Open_Source_ECOA_Toolset_AS5   File: IntDeploymentEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 11
Project: Open_Source_ECOA_Toolset_AS5   File: CompImplEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 12
Project: Open_Source_ECOA_Toolset_AS5   File: InitAssemblyEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 13
Project: Equella   File: JPFPluginRebuilder.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event)
{
	if( event.getType() == IResourceChangeEvent.PRE_BUILD )
	{
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		if( fTouchWorkspace )
		{
			IProject[] projects = root.getProjects();
			for( int i = 0; i < projects.length; i++ )
			{
				touchProject(projects[i]);
			}
		}
		else
		{
			Iterator<String> iter = fProjectNames.iterator();
			while( iter.hasNext() )
			{
				touchProject(root.getProject(iter.next()));
			}
		}
		fTouchWorkspace = false;
		fProjectNames.clear();
	}
}
 
Example 14
Project: pgcodekeeper   File: PgDbParser.java   Source Code and License 6 votes vote down vote up
/**
 * @param buildType single element array; element may be altered to indicate
 *                  actual required build type
 */
public static PgDbParser getParserForBuilder(IProject proj, int[] buildType) {
    PgDbParser pnew = new PgDbParser();
    PgDbParser p = PROJ_PARSERS.putIfAbsent(proj, pnew);
    if (p == null) {
        p = pnew;
        // prepare newly created parser
        ResourcesPlugin.getWorkspace().addResourceChangeListener(p,
                IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);

        if (buildType == null) {
            // not a builder call, start builder
            startBuildJob(proj);
        } else {
            // builder call, change build type to FULL for new parsers
            buildType[0] = IncrementalProjectBuilder.FULL_BUILD;
        }
    }
    return p;
}
 
Example 15
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 16
Project: bdf2   File: PropEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject()
							.equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 17
Project: dawn-marketplace-server   File: SolutionEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					// if(((FileEditorInput)editor.getEditorInput()).getFile().getProject().equals(event.getResource())){
					// IEditorPart editorPart =
					// pages[i].findEditor(editor.getEditorInput());
					// pages[i].closeEditor(editorPart,true);
					// }
				}
			}
		});
	}
}
 
Example 18
Project: jason-eclipse-plugin   File: NavigatorContentProvider.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	
	
	/*
       IResource res = event.getResource();
       
       switch (event.getType()) {
       	case IResourceChangeEvent.POST_CHANGE:
			try {
				event.getDelta().accept(this);
			} catch (CoreException e) {
				e.printStackTrace();
			}
       		if (event.getDelta().getKind() == IResourceDelta.CHANGED && event.getDelta().getFlags() == (IResourceDelta.ADDED | IResourceDelta.REMOVED)) {
       			System.out.println("Resources have RENAMED.");
       		} else {
       			System.out.println("Resources have RENAMED." + event.getDelta().getKind() + " = " + event.getDelta().getFlags());
       		}
       	default:
       }*/
}
 
Example 19
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 20
Project: LibertyEiffel-Eclipse-Plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
		
		@Override
		public void resourceChanged(IResourceChangeEvent event) {
			IResource resource = event.getResource();
			if (resource.getFileExtension().equals("e")) {
				//TODO:
				//Run compiler
			}
		}
	};
	ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
}
 
Example 21
Project: gemfirexd-oss   File: DerbyServerUtils.java   Source Code and License 6 votes vote down vote up
public void resourceChanged(IResourceChangeEvent event){
   if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
   	try{
   		if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
   			if(getRunning(event.getResource().getProject())){
   				stopDerbyServer(event.getResource().getProject());
   			}
   		}
   	}catch(SWTException swe){
   		//The SWTException is thrown during the Shell creation
   		//Logger.log("Exception shutting down "+swe,IStatus.ERROR);
   		//e.printStackTrace();
   	}catch(Exception e){
   		Logger.log("Exception shutting down "+e,IStatus.ERROR);
   	}
   }
}
 
Example 22
Project: team-explorer-everywhere   File: TFSEclipseClientUIPlugin.java   Source Code and License 6 votes vote down vote up
@Override
public void start(final BundleContext context) throws Exception {
    super.start(context);

    ResourcesPlugin.getWorkspace().addResourceChangeListener(
        ignoreFileResourceChangeListener,
        IResourceChangeEvent.POST_CHANGE);

    ResourcesPlugin.getWorkspace().addResourceChangeListener(
        projectCreationListener,
        IResourceChangeEvent.POST_CHANGE);

    getRepositoryManager().addListener(repositoryListener);

    registerProtocolHandler();
}
 
Example 23
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 24
Project: team-explorer-everywhere   File: BuildPolicyUI.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(final PendingCheckin pendingCheckin, final PolicyContext context) {
    super.initialize(pendingCheckin, context);

    if (context.getProperty(PolicyContextKeys.RUNNING_PRODUCT_ECLIPSE_PLUGIN) == null) {
        return;
    } else {
        runningInEclipse = true;
    }

    if (resourceChangeListener == null) {
        resourceChangeListener = new BuildPolicyResourceChangedListener(this);
        ResourcesPlugin.getWorkspace().addResourceChangeListener(
            resourceChangeListener,
            IResourceChangeEvent.POST_BUILD);
    }
}
 
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: arduino_sct_tools   File: SGenMultiPageEditor.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
 */
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {

			/**
			 * @see java.lang.Runnable#run()
			 */
			@Override
			public void run() {
				final IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (final IWorkbenchPage page : pages) {
					if (((FileEditorInput) SGenMultiPageEditor.this.xtextEditor.getEditorInput()).getFile()
							.getProject().equals(event.getResource())) {
						final IEditorPart editorPart = page
								.findEditor(SGenMultiPageEditor.this.xtextEditor.getEditorInput());
						page.closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 27
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 28
Project: hybris-commerce-eclipse-plugin   File: ImpexPageEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject()
					                .equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 29
Project: tlaplus   File: ToolboxExplorerResourceListener.java   Source Code and License 6 votes vote down vote up
public void resourceChanged(final IResourceChangeEvent event) {
	UIHelper.runUIAsync(new Runnable() {
		public void run() {
			ToolboxExplorer.refresh();
			// Expand the current spec and all its children
			final CommonViewer viewer = ToolboxExplorer.getViewer();
			// Event is only null when this Ctor calls us causing the
			// initial expanded state of a spec to be fully expanded.
			// Afterwards, the users expanded states is preserved.
			if (event == null && viewer != null) { // viewer might already be disposed which happens when the Toolbox shuts down.
				final Spec specLoaded = Activator.getSpecManager().getSpecLoaded();
				viewer.expandToLevel(specLoaded, ToolboxExplorer.DEFAULT_EXPAND_LEVEL);
			}
		}
	});
}
 
Example 30
Project: ncl30-eclipse   File: NCLMultiPageEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow()
						.getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput())
							.getFile().getProject().equals(
									event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor
								.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 31
Project: fluentmark   File: PageRoot.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getSource() instanceof IWorkspace) {
		switch (event.getType()) {
			case IResourceChangeEvent.POST_CHANGE:
				try {
					if (event.getDelta() != null && editor.isActiveOn(event.getResource())) {
						editor.getPageModel();
					}
				} catch (Exception e) {
					Log.error("Failed handing post_change of resource", e);
				}
				break;
		}
	}
}
 
Example 32
Project: synergyview   File: MediaRootNode.java   Source Code and License 6 votes vote down vote up
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);
}
   }
 
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: cmake-eclipse-helper   File: CMakeProjectResourceChangeListener.java   Source Code and License 6 votes vote down vote up
@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();
	}
}
 
Example 35
Project: gemfirexd-oss   File: DerbyServerUtils.java   Source Code and License 6 votes vote down vote up
public void resourceChanged(IResourceChangeEvent event){
   if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
   	try{
   		if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
   			if(getRunning(event.getResource().getProject())){
   				stopDerbyServer(event.getResource().getProject());
   			}
   		}
   	}catch(SWTException swe){
   		//The SWTException is thrown during the Shell creation
   		//Logger.log("Exception shutting down "+swe,IStatus.ERROR);
   		//e.printStackTrace();
   	}catch(Exception e){
   		Logger.log("Exception shutting down "+e,IStatus.ERROR);
   	}
   }
}
 
Example 36
Project: statecharts   File: DefaultResourceChangeToIssueProcessor.java   Source Code and License 6 votes vote down vote up
@Override
public ResourceDeltaToIssueResult process(IResourceChangeEvent event, Resource connectedResource,
		Multimap<String, SCTIssue> visibleIssues) {
	final IFile file = WorkspaceSynchronizer.getFile(connectedResource);
	final IResourceDelta deltaForFile = getDeltaForFile(event, file);
	if (deltaForFile == null) {
		return null;
	}
	currentIssues = HashMultimap.create(visibleIssues);
	changedIssuesElementIDs = Sets.newHashSet();
	
	if ((IResourceDelta.CHANGED == deltaForFile.getKind()) && ((deltaForFile.getFlags() & IResourceDelta.MARKERS) != 0)) {
		processMarkerDelta(deltaForFile);
	}
	return new ResourceDeltaToIssueResult(currentIssues,changedIssuesElementIDs);
}
 
Example 37
Project: ecle   File: MBDEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
Example 38
Project: uefi_edk2_wizards_plugin   File: SetResourceChangeListenerStartup.java   Source Code and License 6 votes vote down vote up
@Override
public void earlyStartup() {
	Edk2ModuleObservablesManager.init();
	
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject[] currentProjects = root.getProjects();
	
	for(IProject project : currentProjects) {
		ProjectStructureUpdater.setResourceChangeListeners(project);
	}
	
	ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
		@Override
		public void resourceChanged(IResourceChangeEvent event) {
			for(IResourceDelta projectDelta: event.getDelta().getAffectedChildren()) {
				Edk2ModuleObservablesManager.notifyResourceChanged(projectDelta);
			}
		}
	}, IResourceChangeEvent.POST_CHANGE);
}
 
Example 39
Project: traceability-assistant-eclipse-plugins   File: DXMIEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Closes all project files on project close.
 *
 * @param event the event
 */
public void resourceChanged(final IResourceChangeEvent event){
	if(event.getType() == IResourceChangeEvent.PRE_CLOSE){
		Display.getDefault().asyncExec(new Runnable(){
			public void run(){
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i<pages.length; i++){
					if(((FileEditorInput)editor.getEditorInput()).getFile().getProject().equals(event.getResource())){
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart,true);
					}
				}
			}            
		});
	}
}
 
Example 40
Project: hssd   File: MultiPageEditorWithTextPage.java   Source Code and License 6 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    /**
     * Closes all project files on project close.
     */
	if(event.getType() != IResourceChangeEvent.PRE_CLOSE){
	    return;
	}
	Display.getDefault().asyncExec(new Runnable(){
		public void run(){
			final IWorkbenchPage[] pages = 
			        getSite().getWorkbenchWindow().getPages();
			final FileEditorInput input = 
			        (FileEditorInput)editor.getEditorInput();
			final IProject proj = input.getFile().getProject();
			for (int i = 0; i<pages.length; i++){
				if(proj.equals(event.getResource())){
					final IEditorPart editorPart = 
					        pages[i].findEditor(editor.getEditorInput());
					pages[i].closeEditor(editorPart, true);
				}
			}
		}            
	});
}