當前位置: 首頁>>代碼示例>>Java>>正文


Java IResourceChangeListener類代碼示例

本文整理匯總了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);
}
 
開發者ID:Imhotup,項目名稱:LibertyEiffel-Eclipse-Plugin,代碼行數:18,代碼來源:Activator.java

示例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 );
		}
	});
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:26,代碼來源:SimulationView.java

示例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);
}
 
開發者ID:ffmmjj,項目名稱:uefi_edk2_wizards_plugin,代碼行數:21,代碼來源:SetResourceChangeListenerStartup.java

示例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;
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:22,代碼來源:ConfigNavigator.java

示例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();
				}
			});
		}
	});
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:25,代碼來源:ApplicationWorkbenchWindowAdvisor.java

示例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);
				}
			}
		}
	}
}
 
開發者ID:Talend,項目名稱:tesb-studio-se,代碼行數:25,代碼來源:ResourceEditorListener.java

示例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;
}
 
開發者ID:eclipse,項目名稱:dawnsci,代碼行數:30,代碼來源:HierarchicalDataWorkspaceModelFactory.java

示例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);
}
 
開發者ID:anjlab,項目名稱:eclipse-tapestry5-plugin,代碼行數:26,代碼來源:EclipseClasspathWatchdog.java

示例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));
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:19,代碼來源:ResourceUtils.java

示例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<>();
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:11,代碼來源:ProblemManager.java

示例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);        
}
 
開發者ID:scribble,項目名稱:scribble-eclipse,代碼行數:34,代碼來源:Activator.java

示例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++;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:30,代碼來源:DeltaProcessingState.java

示例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;
      }
    }
  }
 
開發者ID:eclipse,項目名稱:che,代碼行數:33,代碼來源:DeltaProcessingState.java

示例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;
    }
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:33,代碼來源:DeltaProcessingState.java

示例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
    }
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:43,代碼來源:MessagesEditorPlugin.java


注:本文中的org.eclipse.core.resources.IResourceChangeListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。