[Pydev-cvs] org.python.pydev/src/org/python/pydev/ui/pythonpathconf InterpreterPreferencesPage.java,
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-05-24 19:11:42
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27362/src/org/python/pydev/ui/pythonpathconf Modified Files: InterpreterEditor.java InterpreterInfo.java Added Files: InterpreterPreferencesPage.java Log Message: Tests running / changing pythonpath model Index: InterpreterInfo.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf/InterpreterInfo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InterpreterInfo.java 23 May 2005 17:54:28 -0000 1.3 --- InterpreterInfo.java 24 May 2005 19:11:33 -0000 1.4 *************** *** 17,21 **** --- 17,23 ---- import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.core.runtime.NullProgressMonitor; import org.python.pydev.editor.codecompletion.revisited.PythonPathHelper; + import org.python.pydev.editor.codecompletion.revisited.SystemModulesManager; import org.python.pydev.plugin.PydevPlugin; *************** *** 26,29 **** --- 28,32 ---- public java.util.List dllLibs = new ArrayList(); //.pyd, .dll, etc. public Set forcedLibs = new HashSet(); //__builtin__, os, math + public SystemModulesManager modulesManager = new SystemModulesManager(); public InterpreterInfo(String exe, Collection c, Collection dlls){ *************** *** 196,198 **** --- 199,221 ---- forcedLibs.add("datetime"); } + + /** + * @param path + */ + public void restorePythonpath(String path) { + modulesManager.changePythonPath(path, null, new NullProgressMonitor()); + } + + /** + * @param path + */ + public void restorePythonpath() { + StringBuffer buffer = new StringBuffer(); + for (Iterator iter = libs.iterator(); iter.hasNext();) { + String folder = (String) iter.next(); + buffer.append(folder); + buffer.append("|"); + } + modulesManager.changePythonPath(buffer.toString(), null, new NullProgressMonitor()); + } } \ No newline at end of file --- NEW FILE: InterpreterPreferencesPage.java --- /* * Created on May 23, 2005 * * @author Fabio Zadrozny */ package org.python.pydev.ui.pythonpathconf; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.ui.IInterpreterManager; /** * @author Fabio Zadrozny */ public class InterpreterPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{ private String initialInterpreterPath; /** * Initializer sets the preference store */ public InterpreterPreferencesPage() { super("Python Interpreters", GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); initialInterpreterPath = getInterpreterPath(); } private boolean hasChanged(){ String currentInterpreterPath = getInterpreterPath(); if(initialInterpreterPath.equals(currentInterpreterPath)){ return false; }else{ initialInterpreterPath = currentInterpreterPath; return true; } } /** * @return */ private String getInterpreterPath() { return getPreferenceStore().getString(IInterpreterManager.INTERPRETER_PATH); } public void init(IWorkbench workbench) { } /** * Creates the editors */ protected void createFieldEditors() { Composite p = getFieldEditorParent(); InterpreterEditor pathEditor = new InterpreterEditor ("Python interpreters (e.g.: python.exe)", p, PydevPlugin.getInterpreterManager()); addField(pathEditor); } /** * @see org.eclipse.jface.preference.PreferencePage#performApply() */ protected void performApply() { super.performApply(); if(hasChanged()){ restoreModules(); } } /** * */ private void restoreModules() { IInterpreterManager iMan = PydevPlugin.getInterpreterManager(); String interpreter = iMan.getDefaultInterpreter(); iMan.getInterpreterInfo(interpreter, new NullProgressMonitor()); } /** * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { boolean ok = super.performOk(); if(hasChanged()){ restoreModules(); } return ok; } } Index: InterpreterEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf/InterpreterEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InterpreterEditor.java 23 May 2005 17:54:28 -0000 1.1 --- InterpreterEditor.java 24 May 2005 19:11:33 -0000 1.2 *************** *** 475,477 **** --- 475,485 ---- } + + /** + * @see org.python.copiedfromeclipsesrc.PythonListEditor#doLoadDefault() + */ + protected void doLoadDefault() { + super.doLoadDefault(); + updateTree(); + } } |