当前位置: 首页>>代码示例>>Java>>正文


Java IResourceChangeEvent.getResource方法代码示例

本文整理汇总了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);
}
 
开发者ID:Imhotup,项目名称:LibertyEiffel-Eclipse-Plugin,代码行数:18,代码来源:Activator.java

示例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();
				}
			}
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:17,代码来源:SCTHotModelReplacementManager.java

示例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());
    }

}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:14,代码来源:WorkspaceSpecManager.java

示例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);
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:37,代码来源:ResourcesWatcher.java

示例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
    }
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:43,代码来源:MessagesEditorPlugin.java

示例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();
    }
}
 
开发者ID:iloveeclipse,项目名称:filesync4eclipse,代码行数:10,代码来源:ProjectProperties.java

示例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);
		}
	});
}
 
开发者ID:sebastiangoetz,项目名称:slr-toolkit,代码行数:36,代码来源:BibtexEntryView.java

示例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);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:56,代码来源:ProjectCloseListener.java

示例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);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:45,代码来源:MessagesEditorPlugin.java


注:本文中的org.eclipse.core.resources.IResourceChangeEvent.getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。