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

📄 pyeditscripting.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
/*
 * Created on Mar 19, 2006
 */
package org.python.pydev.editor.scripting;

import java.util.HashMap;
import java.util.ListResourceBundle;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.IDocument;
import org.python.pydev.editor.IPyEditListener;
import org.python.pydev.editor.PyEdit;
import org.python.pydev.jython.IPythonInterpreter;
import org.python.pydev.jython.JythonPlugin;

/**
 * This class is used for scripting in Pydev.
 * It listens to the PyEdit actions and passes what is needed for the interpreter.
 * 
 * A new PyEditScripting is created for each editor. Therefore, we have one interpreter for each editor.
 * 
 * @author Fabio
 */
public class PyEditScripting implements IPyEditListener {

    private IPythonInterpreter interpreter;

    public PyEditScripting(){
        interpreter = JythonPlugin.newPythonInterpreter();
    }
    

	private void doExec(HashMap<String, Object> locals) {
		JythonPlugin.execAll(locals, "pyedit", interpreter); //execute all the files that start with 'pyedit' that are located beneath
        													 //the org.python.pydev.jython/jysrc directory and some user specified dir (if any).
	}

	public void onSave(PyEdit edit, IProgressMonitor monitor) {
    	HashMap<String, Object> locals = new HashMap<String, Object>();
    	locals.put("cmd", "onSave");
    	locals.put("editor", edit);
    	doExec(locals); 
    }

    public void onCreateActions(ListResourceBundle resources, PyEdit edit, IProgressMonitor monitor) {
        HashMap<String, Object> locals = new HashMap<String, Object>();
        locals.put("cmd", "onCreateActions");
        locals.put("editor", edit);
        doExec(locals);
    }

    public void onDispose(PyEdit edit, IProgressMonitor monitor) {
    	HashMap<String, Object> locals = new HashMap<String, Object>();
    	locals.put("cmd", "onDispose");
    	locals.put("editor", edit);
    	doExec(locals);
    	
    	interpreter.cleanup();
        interpreter = null;
    }

    public void onSetDocument(IDocument document, PyEdit edit, IProgressMonitor monitor) {
    	HashMap<String, Object> locals = new HashMap<String, Object>();
    	locals.put("cmd", "onSetDocument");
    	locals.put("document", document);
    	locals.put("editor", edit);
    	doExec(locals);
    }

}

⌨️ 快捷键说明

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