本文整理匯總了Java中org.eclipse.core.resources.IResourceChangeListener類的典型用法代碼示例。如果您正苦於以下問題:Java IResourceChangeListener類的具體用法?Java IResourceChangeListener怎麽用?Java IResourceChangeListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IResourceChangeListener類屬於org.eclipse.core.resources包,在下文中一共展示了IResourceChangeListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的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: createPartControl
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
@Override
public void createPartControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE );
container.setLayout(new FillLayout(SWT.HORIZONTAL));
Group experimentsGroup = new Group(container, SWT.NONE);
experimentsGroup.setText("Experiments");
experimentsGroup.setLayout(new FillLayout());
Group resultsGroup = new Group(container, SWT.BORDER);
resultsGroup.setText("Results");
resultsGroup.setLayout(new FillLayout());
createSuiteViewer( experimentsGroup );
createResultViewer( resultsGroup );
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
enableDisableActions();
util.registerChangeListener( new IResourceChangeListener() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
doHandleChangeEvent( event );
}
});
}
示例3: earlyStartup
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
@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);
}
示例4: getInitialInput
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
@Override
protected Object getInitialInput() {
changeListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getCommonViewer().refresh();
}
});
}
};
ResourcesPlugin.getWorkspace()
.addResourceChangeListener(changeListener);
try {
return ConfigurationFolderProvider.getRootConfigurationFolder()
.getProject();
} catch (Exception e) {
return null;
}
}
示例5: addWorkplaceListener
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
public void addWorkplaceListener(){
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
//刷新項目導航視圖
Display.getDefault().syncExec(new Runnable() {
public void run() {
IViewPart findView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.findView("net.heartsome.cat.common.ui.navigator.view");
if(null == findView){
return ;
}
IAction refreshActionHandler = findView.getViewSite().getActionBars()
.getGlobalActionHandler(ActionFactory.REFRESH.getId());
if(null == refreshActionHandler){
return;
}
refreshActionHandler.run();
}
});
}
});
}
示例6: partClosed
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
@Override
public void partClosed(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(true);
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
if (input instanceof RouteResourceInput) {
Item item = ((RouteResourceInput) input).getItem();
if (item.getProperty().getId()
.equals(editorInput.getItem().getProperty().getId())) {
try {
ProxyRepositoryFactory.getInstance().unlock(item);
page.getWorkbenchWindow().getPartService().removePartListener(this);
IResourceChangeListener l = editorInput.getListener();
if (null != l) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(l);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
示例7: getHierarchicalDataModel
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
/**
* Returns the IHierarchicalDataModel. If one does not exists, this method
* will create one and register a workspace listener.
*
* @return
*/
public static IHierarchicalDataModel getHierarchicalDataModel() {
IHierarchicalDataModelGetFileModel getModel = new GetFileModelFactory();
final HierarchicalDataModel model = new HierarchicalDataModel(getModel);
IResourceChangeListener listener = new IResourceChangeListener() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
if (delta != null) {
try {
delta.accept(new DeltaVisitor(model));
} catch (CoreException e) {
// our visitor does not throw CoreException
}
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(listener);
return model;
}
示例8: start
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
@Override
public void start()
{
super.start();
postChangeListener = new IResourceChangeListener()
{
@Override
public void resourceChanged(IResourceChangeEvent event)
{
List<IFile> changedFiles = EclipseUtils.getAllAffectedResources(
event.getDelta(), IFile.class, IResourceDelta.CHANGED);
for (IFile changedFile : changedFiles)
{
if (isEclipseProjectClasspathFile(changedFile))
{
notifyEclipseClasspathChanged(changedFile);
}
}
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(postChangeListener, IResourceChangeEvent.POST_CHANGE);
}
示例9: connectResourceListener
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
public static void connectResourceListener(IResourceChangeListener listener,
RunnableX<CoreException> initialUpdate, ISchedulingRule opRule, IOwner owner) {
try {
getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
initialUpdate.run();
}
}, opRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException ce) {
EclipseCore.logStatus(ce);
// This really should not happen, but still try to recover by registering the listener.
getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
}
owner.bind(() -> ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener));
}
示例10: ProblemManager
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
private ProblemManager() {
this.resourceChangeListener = new IResourceChangeListener() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
handleResourceChanged(event);
}
};
this.listeners = new CopyOnWriteArrayList<>();
}
示例11: start
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
// Register resource change listener
IResourceChangeListener rcl=new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent evt) {
try {
evt.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) {
boolean ret=true;
IResource res = delta.getResource();
// Determine if the change is relevant
if (isChangeRelevant(res, delta)) {
// Validate the resource
_validator.validateResource(res);
}
return (ret);
}
});
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to process resource change event", e);
}
}
};
// Register the resource change listener
ResourcesPlugin.getWorkspace().addResourceChangeListener(rcl,
IResourceChangeEvent.POST_CHANGE);
}
示例12: addPreResourceChangedListener
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
public synchronized void addPreResourceChangedListener(
IResourceChangeListener listener, int eventMask) {
for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
if (this.preResourceChangeListeners[i] == listener) {
this.preResourceChangeEventMasks[i] |= eventMask;
return;
}
}
// may need to grow, no need to clone, since iterators will have cached original arrays and max
// boundary and we only add to the end.
int length;
if ((length = this.preResourceChangeListeners.length) == this.preResourceChangeListenerCount) {
System.arraycopy(
this.preResourceChangeListeners,
0,
this.preResourceChangeListeners = new IResourceChangeListener[length * 2],
0,
length);
System.arraycopy(
this.preResourceChangeEventMasks,
0,
this.preResourceChangeEventMasks = new int[length * 2],
0,
length);
}
this.preResourceChangeListeners[this.preResourceChangeListenerCount] = listener;
this.preResourceChangeEventMasks[this.preResourceChangeListenerCount] = eventMask;
this.preResourceChangeListenerCount++;
}
示例13: removePreResourceChangedListener
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
public synchronized void removePreResourceChangedListener(IResourceChangeListener listener) {
for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
if (this.preResourceChangeListeners[i] == listener) {
// need to clone defensively since we might be in the middle of listener notifications
// (#fire)
int length = this.preResourceChangeListeners.length;
IResourceChangeListener[] newListeners = new IResourceChangeListener[length];
int[] newEventMasks = new int[length];
System.arraycopy(this.preResourceChangeListeners, 0, newListeners, 0, i);
System.arraycopy(this.preResourceChangeEventMasks, 0, newEventMasks, 0, i);
// copy trailing listeners
int trailingLength = this.preResourceChangeListenerCount - i - 1;
if (trailingLength > 0) {
System.arraycopy(this.preResourceChangeListeners, i + 1, newListeners, i, trailingLength);
System.arraycopy(
this.preResourceChangeEventMasks, i + 1, newEventMasks, i, trailingLength);
}
// update manager listener state (#fire need to iterate over original listeners through a
// local variable to hold onto
// the original ones)
this.preResourceChangeListeners = newListeners;
this.preResourceChangeEventMasks = newEventMasks;
this.preResourceChangeListenerCount--;
return;
}
}
}
示例14: resourceChanged
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的package包/類
public void resourceChanged(final IResourceChangeEvent event) {
for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are
// causing grief
final IResourceChangeListener listener = this.preResourceChangeListeners[i];
if ((this.preResourceChangeEventMasks[i] & event.getType()) != 0)
SafeRunner.run(
new ISafeRunnable() {
public void handleException(Throwable exception) {
Util.log(
exception,
"Exception occurred in listener of pre Java resource change notification"); // $NON-NLS-1$
}
public void run() throws Exception {
listener.resourceChanged(event);
}
});
}
try {
getDeltaProcessor().resourceChanged(event);
} finally {
// TODO (jerome) see 47631, may want to get rid of following so as to reuse delta processor ?
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
this.deltaProcessors.set(null);
} else {
// If we are going to reuse the delta processor of this thread, don't hang on to state
// that isn't meant to be reused. https://bugs.eclipse.org/bugs/show_bug.cgi?id=273385
getDeltaProcessor().overridenEventType = -1;
}
}
}
示例15: start
import org.eclipse.core.resources.IResourceChangeListener; //導入依賴的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
}
}