本文整理汇总了Java中org.eclipse.core.resources.IResourceChangeEvent.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java IResourceChangeEvent.getResource方法的具体用法?Java IResourceChangeEvent.getResource怎么用?Java IResourceChangeEvent.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IResourceChangeEvent
的用法示例。
在下文中一共展示了IResourceChangeEvent.getResource方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
@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);
}
示例2: handleCloseEvent
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
private void handleCloseEvent(IResourceChangeEvent event) {
if (event.getResource() instanceof IProject) {
IProject project = ((IProject) event.getResource());
for (IDebugTarget target : activeTargets) {
EObject object = (EObject) target.getAdapter(EObject.class);
IFile file = WorkspaceSynchronizer.getFile(object.eResource());
if (project.equals(file.getProject())) {
try {
target.terminate();
} catch (DebugException e) {
e.printStackTrace();
}
}
}
}
}
示例3: resourceChanged
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
public void resourceChanged(IResourceChangeEvent event)
{
/*
* remove elements from the storage if the projects are deleted
*/
IResource resource = event.getResource();
if (resource != null && IResource.PROJECT == resource.getType()
&& IResourceChangeEvent.PRE_DELETE == event.getType())
{
specStorage.remove(resource.getName());
}
}
示例4: resourceChanged
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
@Override
public void resourceChanged(IResourceChangeEvent event) {
try {
IResource resource = event.getResource();
switch (event.getType()) {
case IResourceChangeEvent.PRE_DELETE:
if (resource != null) {
switch (resource.getType()) {
case IResource.PROJECT:
// called when project is deleted.
deleteProject((IProject) resource);
break;
}
}
break;
case IResourceChangeEvent.PRE_CLOSE:
if (resource != null) {
switch (resource.getType()) {
case IResource.PROJECT:
// called when project is closed.
closeProject((IProject) resource);
break;
}
}
break;
case IResourceChangeEvent.POST_CHANGE:
IResourceDelta delta = event.getDelta();
if (delta != null) {
delta.accept(this);
}
break;
}
} catch (Throwable e) {
Trace.trace(Trace.SEVERE, "Error while TypeScript resource changed", e);
}
}
示例5: start
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// make sure the rbe nature and builder are set on java projects
// if that is what the users prefers.
if (MsgEditorPreferences.isBuilderSetupAutomatically()) {
ToggleNatureAction.addOrRemoveNatureOnAllJavaProjects(true);
}
// the unique file change listener
resourceChangeListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
IResource resource = event.getResource();
if (resource != null) {
String fullpath = resource.getFullPath().toString();
Set<AbstractIFileChangeListener> listeners = resourceChangeSubscribers.get(fullpath);
if (listeners != null) {
AbstractIFileChangeListener[] larray = listeners .toArray(new AbstractIFileChangeListener[0]);
for (int i = 0; i < larray.length; i++) {
larray[i].listenedFileChanged(event);
}
}
}
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
try {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Display.getDefault().addFilter(SWT.KeyUp, new UndoKeyListener());
}
});
} catch (NullPointerException e) {
// TODO [RAP] Non UI-Thread, no default display available, in RAP
// multiple clients and displays
}
}
示例6: resourceChanged
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResource resource = event.getResource();
if ((event.getType() == IResourceChangeEvent.PRE_CLOSE
|| event.getType() == IResourceChangeEvent.PRE_DELETE)
&& resource != null && resource.equals(project)) {
dispose();
}
}
示例7: handleResourceDeleteEvent
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
/**
* Handle deletion of resources (does only handle deletion of projects)
* @param event
*/
private void handleResourceDeleteEvent(IResourceChangeEvent event){
IResource resource = event.getResource();
if(!(resource instanceof IProject)){
return;
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IProject[] input = (IProject[]) combo.getInput();
IStructuredSelection selection = combo.getStructuredSelection();
//Deleted project is selected
if(selection.getFirstElement() == resource){
if(input.length > 1){
int currentIndex = combo.getCombo().getSelectionIndex();
Object newItem = combo.getElementAt(currentIndex + 1);
if(newItem != null){
combo.setSelection(new StructuredSelection(newItem));
} else{
newItem = combo.getElementAt(currentIndex - 1);
if(newItem != null){
combo.setSelection(new StructuredSelection(newItem));
}
}
} else if (input.length == 1){
combo.setSelection(StructuredSelection.EMPTY);
}
}
combo.remove(resource);
}
});
}
示例8: resourceChanged
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
@Override
public void resourceChanged(final IResourceChangeEvent event) {
if (event.getType() != IResourceChangeEvent.PRE_CLOSE || !(event.getResource() instanceof IProject)) {
return;
}
final IProject project = (IProject) event.getResource();
if (!project.isOpen()) {
/* Sanity check */
log.error(
MessageFormat.format(
"Project Manager received close notification for project {0} (already closed)", //$NON-NLS-1$
project.getName()));
return;
}
/* Exit if we don't manage this project */
String providerName;
try {
providerName = project.getPersistentProperty(TeamUtils.PROVIDER_PROP_KEY);
} catch (final CoreException e) {
log.warn(
MessageFormat.format(
"Could not query repository manager for project {0} (when handling close notification)", //$NON-NLS-1$
project.getName()),
e);
return;
}
if (providerName == null || !providerName.equals(TFSRepositoryProvider.PROVIDER_ID)) {
return;
}
/*
* If this is the only project for this connection, it will be
* disconnected, thus we need to prompt for unsaved WIT changes.
*/
final TFSRepository repository = projectManager.getRepository(project);
if (repository != null) {
final IProject[] allRepositoryProjects = projectManager.getProjectsForRepository(repository);
if (allRepositoryProjects.length == 1 && allRepositoryProjects[0] == project) {
/*
* Note: we have to ignore the cancel button here, there is no
* way to prevent the close from occurring.
*/
ProjectManagerDataProviderFactory.getDataProvider().promptForDisconnect();
}
}
projectManager.close(project);
}
示例9: start
import org.eclipse.core.resources.IResourceChangeEvent; //导入方法依赖的package包/类
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(
* org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
//make sure the rbe nature and builder are set on java projects
//if that is what the users prefers.
if (MsgEditorPreferences.getInstance().isBuilderSetupAutomatically()) {
ToggleNatureAction.addOrRemoveNatureOnAllJavaProjects(true);
}
//TODO replace deprecated
try {
URL messagesUrl = FileLocator.find(getBundle(),
new Path("$nl$/messages.properties"), null);//$NON-NLS-1$
if(messagesUrl != null) {
resourceBundle = new PropertyResourceBundle(
messagesUrl.openStream());
}
} catch (IOException x) {
resourceBundle = null;
}
//the unique file change listener
resourceChangeListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
IResource resource = event.getResource();
if (resource != null) {
String fullpath = resource.getFullPath().toString();
Set<AbstractIFileChangeListener> listeners = resourceChangeSubscribers.get(fullpath);
if (listeners != null) {
AbstractIFileChangeListener[] larray = listeners.toArray(new AbstractIFileChangeListener[0]);//avoid concurrency issues. kindof.
for (int i = 0; i < larray.length; i++) {
larray[i].listenedFileChanged(event);
}
}
}
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
}