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

📄 pythonmodulewizard.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
package org.python.pydev.ui.wizards.files;

import java.io.ByteArrayInputStream;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.python.pydev.editor.codecompletion.revisited.PythonPathHelper;


/**
 * Python module creation wizard
 * 
 * TODO: Create initial file content from a comment templates
 * 
 * @author Mikko Ohtamaa
 * 
 */
public class PythonModuleWizard extends AbstractPythonWizard {

    public PythonModuleWizard() {
        super("Create a new Python module");
    }

    public static final String WIZARD_ID = "org.python.pydev.ui.wizards.files.PythonModuleWizard";

    @Override
    protected PythonAbstractPathPage createPathPage() {
        return new PythonAbstractPathPage(this.description, selection){

            @Override
            protected boolean shouldCreatePackageSelect() {
                return true;
            }
            
        };
    }

    /**
     * We will create a new module (file) here given the source folder and the package specified (which
     * are currently validated in the page) 
     * @param monitor 
     * @throws CoreException 
     */
    @Override
    protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
        IContainer validatedSourceFolder = filePage.getValidatedSourceFolder();
        if(validatedSourceFolder == null){
            return null;
        }
        IContainer validatedPackage = filePage.getValidatedPackage();
        if(validatedPackage == null){
            return null;
        }
        String validatedName = filePage.getValidatedName()+PythonPathHelper.getDefaultDottedPythonExtension();
        
        IFile file = validatedPackage.getFile(new Path(validatedName));
        if(!file.exists()){
            file.create(new ByteArrayInputStream(new byte[0]), true, monitor);
        }
        
        return file;
    }




}

⌨️ 快捷键说明

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