⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pythonnaturelistenersmanager.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
/*
 * Created on Oct 29, 2006
 * @author Fabio
 */
package org.python.pydev.plugin.nature;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.python.pydev.plugin.PydevPlugin;

/**
 * This class is used to pass notifications about the python nature around for 
 * those interested.
 * 
 * @author Fabio
 */
public class PythonNatureListenersManager {
    private static List<WeakReference<IPythonNatureListener>> pythonNatureListeners = new ArrayList<WeakReference<IPythonNatureListener>>();
    
    public static void addPythonNatureListener(IPythonNatureListener listener){
        pythonNatureListeners.add(new WeakReference<IPythonNatureListener>(listener));
    }
    
    public static void removePythonNatureListener(IPythonNatureListener provider) {
        for(Iterator<WeakReference<IPythonNatureListener>> it = pythonNatureListeners.iterator();it.hasNext();){
            WeakReference<IPythonNatureListener> ref = it.next();
            if(ref.get() == provider){
                it.remove();
            }
        }
    }
    
    
    /**
     * Notification that the pythonpath has been rebuilt.
     * 
     * @param project is the project that had the pythonpath rebuilt
     * @param projectPythonpath the project pythonpath used when rebuilding
     */
    public static void notifyPythonPathRebuilt(IProject project, List<String> projectPythonpath){
        for(Iterator<WeakReference<IPythonNatureListener>> it = pythonNatureListeners.iterator();it.hasNext();){
            WeakReference<IPythonNatureListener> ref = it.next();
            try{
                IPythonNatureListener listener = ref.get();
                if(listener == null){
                    it.remove();
                }else{
                    listener.notifyPythonPathRebuilt(project, projectPythonpath);
                }
            }catch(Throwable e){
                PydevPlugin.log(e);
            }
        }
    }

    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -