Java 类org.eclipse.core.resources.IResourceChangeListener 实例源码

项目:LibertyEiffel-Eclipse-Plugin    文件:Activator.java   
@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);
}
项目:CARMA    文件:SimulationView.java   
@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 );
        }
    });
}
项目:uefi_edk2_wizards_plugin    文件:SetResourceChangeListenerStartup.java   
@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);
}
项目:openhab-hdl    文件:ConfigNavigator.java   
@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;
    }
}
项目:translationstudio8    文件:ApplicationWorkbenchWindowAdvisor.java   
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();
                }
            });
        }
    });
}
项目:tesb-studio-se    文件:ResourceEditorListener.java   
@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);
                }
            }
        }
    }
}
项目:dawnsci    文件:HierarchicalDataWorkspaceModelFactory.java   
/**
 * 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;
}
项目:eclipse-tapestry5-plugin    文件:EclipseClasspathWatchdog.java   
@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);
}
项目:goclipse    文件:ResourceUtils.java   
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));
}
项目:typescript.java    文件:ProblemManager.java   
private ProblemManager() {
    this.resourceChangeListener = new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            handleResourceChanged(event);
        }
    };

    this.listeners = new CopyOnWriteArrayList<>();
}
项目:scribble-eclipse    文件:Activator.java   
/**
 * {@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);        
}
项目:che    文件:DeltaProcessingState.java   
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++;
}
项目:che    文件:DeltaProcessingState.java   
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;
      }
    }
  }
项目:che    文件:DeltaProcessingState.java   
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;
    }
  }
}
项目:PDFReporter-Studio    文件:MessagesEditorPlugin.java   
/**
 * @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
    }
}
项目:PDFReporter-Studio    文件:PropertiesIFileResource.java   
/**
 * Constructor.
 * 
 * @param locale
 *            the resource locale
 * @param serializer
 *            resource serializer
 * @param deserializer
 *            resource deserializer
 * @param file
 *            the underlying {@link IFile}
 * @param listenerRegistry
 *            It is the MessageEditorPlugin. Or null if we don't care for
 *            file changes. We could replace it by an activator in this
 *            plugin.
 */
public PropertiesIFileResource(Locale locale,
        PropertiesSerializer serializer,
        PropertiesDeserializer deserializer, IFile file,
        IFileChangeListenerRegistry listenerRegistry) {
    super(locale, serializer, deserializer);
    this.file = file;
    this.listenerRegistry = listenerRegistry;

    // [hugues] FIXME: this object is built at the beginning
    // of a build (no message editor)
    // it is disposed of at the end of the build.
    // during a build files are not changed.
    // so it is I believe never called.
    if (this.listenerRegistry != null) {
        IResourceChangeListener rcl = new IResourceChangeListener() {
            public void resourceChanged(IResourceChangeEvent event) {
                // no need to check: it is always the case as this
                // is subscribed for a particular file.
                // if (event.getResource() != null
                // &&
                // PropertiesIFileResource.this.file.equals(event.getResource()))
                // {
                fireResourceChange(PropertiesIFileResource.this);
                // }
            }
        };
        fileListener = AbstractIFileChangeListener
                .wrapResourceChangeListener(rcl, file);
        this.listenerRegistry.subscribe(fileListener);
    } else {
        fileListener = null;
    }
}
项目:CooperateModelingEnvironment    文件:FileResourceChangeObserver.java   
@Override
protected IResourceChangeListener createAndRegisterResourceListener(Resource r) {
    Validate.isTrue(r.getURI().isPlatformResource(), "The resource %s has to be a platform resource.",
            r.getURI().toString());
    Validate.notNull(ResourcesPlugin.getWorkspace(), "We need a workspace instance for observing the resource.");

    String platformString = r.getURI().toPlatformString(true);
    IResource iresource = ResourcesPlugin.getWorkspace().getRoot().findMember(platformString);

    if (iresource == null) {
        return null;
    }

    IResourceChangeListener listener = new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            try {
                if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
                    ChangedResourcesDeltaVisitor visitor = new ChangedResourcesDeltaVisitor();
                    event.getDelta().accept(visitor);
                    if (visitor.getChangedFiles().contains(iresource)) {
                        handleResourceChange();
                    }
                }
            } catch (CoreException e) {
                LOGGER.warn("Could not determine changed files based on resource delta.", e);
            }
        }
    };
    ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
    return listener;
}
项目:APICloud-Studio    文件:MarkerManager.java   
private MarkerManager()
{
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.addResourceChangeListener(new IResourceChangeListener()
    {
        public void resourceChanged(IResourceChangeEvent event)
        {
            handleResourceChanged();
        }
    }, IResourceChangeEvent.PRE_BUILD);
}
项目:mytourbook    文件:PropertiesIFileResource.java   
/**
     * Constructor.
     * @param locale the resource locale
     * @param serializer resource serializer
     * @param deserializer resource deserializer
     * @param file the underlying {@link IFile}
     * @param listenerRegistry It is the MessageEditorPlugin. 
     * Or null if we don't care for file changes.
     * We could replace it by an activator in this plugin.
     */
    public PropertiesIFileResource(
            Locale locale,
            PropertiesSerializer serializer,
            PropertiesDeserializer deserializer,
            IFile file, IFileChangeListenerRegistry listenerRegistry) {
        super(locale, serializer, deserializer);
        this.file = file;
        this.listenerRegistry = listenerRegistry;

        //[hugues] FIXME: this object is built at the beginning
        //of a build (no message editor)
        //it is disposed of at the end of the build.
        //during a build files are not changed.
        //so it is I believe never called.
        if (this.listenerRegistry != null) {
            IResourceChangeListener rcl =
                new IResourceChangeListener() {
                    public void resourceChanged(IResourceChangeEvent event) {
                        //no need to check: it is always the case as this
                        //is subscribed for a particular file.
//                      if (event.getResource() != null
//                              && PropertiesIFileResource.this.file.equals(event.getResource())) {
                            fireResourceChange(PropertiesIFileResource.this);
//                      }
                    }
                };
             fileListener = AbstractIFileChangeListener
                    .wrapResourceChangeListener(rcl, file);
             this.listenerRegistry.subscribe(fileListener);
        } else {
            fileListener = null;
        }
    }
项目:mytourbook    文件:PropertiesIFileResource.java   
/**
     * Constructor.
     * @param locale the resource locale
     * @param serializer resource serializer
     * @param deserializer resource deserializer
     * @param file the underlying {@link IFile}
     * @param listenerRegistry It is the MessageEditorPlugin. 
     * Or null if we don't care for file changes.
     * We could replace it by an activator in this plugin.
     */
    public PropertiesIFileResource(
            Locale locale,
            PropertiesSerializer serializer,
            PropertiesDeserializer deserializer,
            IFile file, IFileChangeListenerRegistry listenerRegistry) {
        super(locale, serializer, deserializer);
        this.file = file;
        this.listenerRegistry = listenerRegistry;

        //[hugues] FIXME: this object is built at the beginning
        //of a build (no message editor)
        //it is disposed of at the end of the build.
        //during a build files are not changed.
        //so it is I believe never called.
        if (this.listenerRegistry != null) {
            IResourceChangeListener rcl =
                new IResourceChangeListener() {
                    public void resourceChanged(IResourceChangeEvent event) {
                        //no need to check: it is always the case as this
                        //is subscribed for a particular file.
//                      if (event.getResource() != null
//                              && PropertiesIFileResource.this.file.equals(event.getResource())) {
                            fireResourceChange(PropertiesIFileResource.this);
//                      }
                    }
                };
             fileListener = AbstractIFileChangeListener
                    .wrapResourceChangeListener(rcl, file);
             this.listenerRegistry.subscribe(fileListener);
        } else {
            fileListener = null;
        }
    }
项目:mytourbook    文件:PropertiesIFileResource.java   
/**
     * Constructor.
     * @param locale the resource locale
     * @param serializer resource serializer
     * @param deserializer resource deserializer
     * @param file the underlying {@link IFile}
     * @param listenerRegistry It is the MessageEditorPlugin. 
     * Or null if we don't care for file changes.
     * We could replace it by an activator in this plugin.
     */
    public PropertiesIFileResource(
            Locale locale,
            PropertiesSerializer serializer,
            PropertiesDeserializer deserializer,
            IFile file, IFileChangeListenerRegistry listenerRegistry) {
        super(locale, serializer, deserializer);
        this.file = file;
        this.listenerRegistry = listenerRegistry;

        //[hugues] FIXME: this object is built at the beginning
        //of a build (no message editor)
        //it is disposed of at the end of the build.
        //during a build files are not changed.
        //so it is I believe never called.
        if (this.listenerRegistry != null) {
            IResourceChangeListener rcl =
                new IResourceChangeListener() {
                    public void resourceChanged(IResourceChangeEvent event) {
                        //no need to check: it is always the case as this
                        //is subscribed for a particular file.
//                      if (event.getResource() != null
//                              && PropertiesIFileResource.this.file.equals(event.getResource())) {
                            fireResourceChange(PropertiesIFileResource.this);
//                      }
                    }
                };
             fileListener = AbstractIFileChangeListener
                    .wrapResourceChangeListener(rcl, file);
             this.listenerRegistry.subscribe(fileListener);
        } else {
            fileListener = null;
        }
    }
项目:OpenSPIFe    文件:MultiPagePlanEditor.java   
/**
 * Listen to check if this editor should be closed. Temporary fix due to
 * an eclipse bug 302791
 * Lazily creates and returns a singleton instance of the ResourceDeletedListener
 * @return the singleton ResourceDeletedListener
 */
private IResourceChangeListener getResourceDeletedListener() {
    if (resourceDeletedListener == null) {
        resourceDeletedListener = new ResourceDeletedListener();
    }
    return resourceDeletedListener;
}
项目:SPLevo    文件:SPLevoProjectWorkspaceObserver.java   
private IResourceChangeListener createProjectOpenCloseListener() {
    return new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
                handleClosedProject((IProject) event.getResource());
                return;
            }

            if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
                try {
                    event.getDelta().accept(new IResourceDeltaVisitor() {
                        @Override
                        public boolean visit(IResourceDelta delta) throws CoreException {
                            if (delta.getResource() instanceof IWorkspaceRoot) {
                                return true;
                            }

                            if ((delta.getFlags() & IResourceDelta.OPEN) != 0
                                    && delta.getResource() instanceof IProject) {
                                IProject project = (IProject) delta.getResource();
                                if (project.isOpen()) {
                                    handleOpenedProject(project);
                                }
                            }

                            return false;
                        }

                    });
                } catch (CoreException e) {
                    LOGGER.warn(
                            "Error processing a resource change. The VPM loading composite might not be up to date anymore.",
                            e);
                }
            }
        }
    };
}
项目:SPLevo    文件:LoadVPMCompositeHandler.java   
private IResourceChangeListener createProjectOpenCloseListener() {
    return new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
                projectClosed((IProject) event.getResource());
            }  

            if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
                projectClosed((IProject) event.getResource());
                try {

                    event.getDelta().accept(new IResourceDeltaVisitor() {
                        @Override
                        public boolean visit(IResourceDelta delta) throws CoreException {
                            if (delta.getResource() instanceof IWorkspaceRoot) {
                                return true;
                            }

                            if ((delta.getFlags() & IResourceDelta.OPEN) != 0
                                    && delta.getResource() instanceof IProject) {
                                projectOpened((IProject) delta.getResource());
                            }

                            return false;
                        }

                    });
                } catch (CoreException e) {
                    LOGGER.warn(
                            "Error processing a resource change. The VPM loading composite might not be up to date anymore.",
                            e);
                }
            }
        }
    };
}
项目:OpsDev    文件:Activator.java   
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener(){

        public void resourceChanged(IResourceChangeEvent event) {
            // TODO Auto-generated method stub
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            iProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
            Map<String, Object> mapEventValue =  new LinkedHashMap<String, Object> ();

            for (IProject iProject :iProjects)
            {
                mapEventValue.put(iProject.getName(), iProject);
            }

            OpsManagerProjectTool.notifyEvent(OpsManagerProjectTool.OPSEVENT.PROJECT_REFRUSH, mapEventValue);

        }});


}
项目:textuml    文件:RepositoryCache.java   
public void start() {
    ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {

        public void resourceChanged(IResourceChangeEvent event) {
            workspaceGeneration++;
        }
    });
}
项目:eclipse-utility    文件:LocalHistoryPage.java   
private void removeAllResourceListener() {
    Object[] listeners = resourceListenerList.getListeners();
    for (int i = 0; i < listeners.length; i++) {
        ResourcesPlugin.getWorkspace().removeResourceChangeListener((IResourceChangeListener) listeners[i]);
    }
    resourceListenerList.clear();
}
项目:2uml    文件:CoreActivator.java   
@Override
public void stop(BundleContext context) throws Exception {
    for (IResourceChangeListener changeListener : changeListeners) {
        ResourcesPlugin.getWorkspace().removeResourceChangeListener(changeListener);
    }
    changeListeners.clear();
    changeListeners = null;
    plugin = null;
    super.stop(context);
}
项目:2uml    文件:CreatorActivator.java   
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    changeListeners = new HashSet<IResourceChangeListener>();
    updateChangeListerners();
}
项目:2uml    文件:CreatorActivator.java   
@Override
public void stop(BundleContext context) throws Exception {
    for (IResourceChangeListener changeListener : changeListeners) {
        ResourcesPlugin.getWorkspace().removeResourceChangeListener(changeListener);
    }
    changeListeners.clear();
    changeListeners = null;
    plugin = null;
    super.stop(context);
}
项目:che    文件:Workspace.java   
@Override
public void addResourceChangeListener(IResourceChangeListener listener) {
  // TODO
  //        throw new UnsupportedOperationException();
}
项目:che    文件:Workspace.java   
@Override
public void addResourceChangeListener(IResourceChangeListener listener, int eventMask) {
  //        throw new UnsupportedOperationException();
  // TODO
}
项目:che    文件:Workspace.java   
@Override
public void removeResourceChangeListener(IResourceChangeListener listener) {
  //        throw new UnsupportedOperationException();
  // TODO
}
项目:gama    文件:ResourceManager.java   
public ResourceManager(final IResourceChangeListener delegate, final CommonViewer navigator) {
    this.viewer = navigator;
    viewer.addSelectionChangedListener(this);
    this.delegate = delegate;
    INSTANCE = this;
}
项目:mytourbook    文件:MessagesEditorPlugin.java   
/**
 * @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);
}
项目:mytourbook    文件:MessagesEditorPlugin.java   
/**
 * @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);
}
项目:mytourbook    文件:MessagesEditorPlugin.java   
/**
 * @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);
}
项目:OpenSPIFe    文件:WorkspaceResourceService.java   
public WorkspaceResourceService() {
     listeners = new ArrayList<IResourceChangeListener>();
}
项目:OpenSPIFe    文件:WorkspaceResourceService.java   
public void addResourceChangeListener(IResourceChangeListener listener) {
    listeners.add(listener);
}
项目:OpenSPIFe    文件:WorkspaceResourceService.java   
public void removeResourceChangeListener(IResourceChangeListener listener) {
    listeners.remove(listener);
}