Java 类org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider 实例源码

项目:n4js    文件:ProjectUtils.java   
private static IProject importProject(File probandsFolder, String projectName, boolean prepareDotProject)
        throws Exception {
    File projectSourceFolder = new File(probandsFolder, projectName);
    if (!projectSourceFolder.exists()) {
        throw new IllegalArgumentException("proband not found in " + projectSourceFolder);
    }

    if (prepareDotProject) {
        prepareDotProject(projectSourceFolder);
    }

    IProgressMonitor monitor = new NullProgressMonitor();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
    IProject project = workspace.getRoot().getProject(projectName);
    project.create(newProjectDescription, monitor);
    project.open(monitor);
    if (!project.getLocation().toFile().exists()) {
        throw new IllegalArgumentException("test project correctly created in " + project.getLocation());
    }

    IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
        @Override
        public String queryOverwrite(String file) {
            return ALL;
        }
    };
    ImportOperation importOperation = new ImportOperation(project.getFullPath(), projectSourceFolder,
            FileSystemStructureProvider.INSTANCE, overwriteQuery);
    importOperation.setCreateContainerStructure(false);
    importOperation.run(monitor);

    return project;
}
项目:thym    文件:HybridProjectImportPage.java   
private IProject doCreateProject(ProjectCandidate pc, IProgressMonitor monitor) throws CoreException, InterruptedException {
    HybridProjectCreator projectCreator = new HybridProjectCreator();
    Widget w = pc.getWidget();
    String projectName = pc.getProjectName();
    URI location = null;
    if(!copyFiles){
        location = pc.wwwLocation.getParentFile().toURI();
    }
    IProject project = projectCreator.createProject(projectName, location, w.getName(), w.getId(), null, monitor);
    if(copyFiles){
        ImportOperation operation = new ImportOperation(project
                .getFullPath(), pc.wwwLocation.getParentFile(), FileSystemStructureProvider.INSTANCE
                , this);
        operation.setContext(getShell());
        operation.setOverwriteResources(true); 
        operation.setCreateContainerStructure(false);

        try {
            operation.run(monitor);
        } catch (InvocationTargetException e) {
            if(e.getCause() != null  && e.getCause() instanceof CoreException){
                CoreException corex = (CoreException) e.getCause();
                throw corex;
            }
        }
        IStatus status = operation.getStatus();
        if (!status.isOK())
            throw new CoreException(status);
    }
    return project;

}
项目:gw4e.project    文件:ProjectImport.java   
@Override
public void run(String[] params, ICheatSheetManager manager) {

    if (params == null || params[0] == null) {
        return;
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    String projectName = params[0];
    String zipName = params[1];
    IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
    IProject newProject = workspace.getRoot().getProject(projectName);
    try {
        newProject.create(newProjectDescription, null);
        newProject.open(null);

        URL url = this.getClass().getClassLoader().getResource(zipName);
        File f = new File(FileLocator.toFileURL(url).getPath());

        IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
            public String queryOverwrite(String file) {
                System.out.println(file);
                return ALL;
            }
        };

        FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;

        File root = createTempDirectory();

        unzip(f.getAbsolutePath(), root.getAbsolutePath());

        List<File> files = readFiles(root.getAbsolutePath());
        ImportOperation importOperation = new ImportOperation(newProject.getFullPath(), root, provider,
                overwriteQuery, files);
        importOperation.setCreateContainerStructure(false);
        importOperation.run(new NullProgressMonitor());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:statecharts    文件:GitRepositoryExampleService.java   
@Override
public void importExample(ExampleData edata, IProgressMonitor monitor) {
    try {
        IProjectDescription original = ResourcesPlugin.getWorkspace()
                .loadProjectDescription(new Path(edata.getProjectDir().getAbsolutePath()).append("/.project"));
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(edata.getProjectDir().getName());

        IProjectDescription clone = ResourcesPlugin.getWorkspace()
                .newProjectDescription(original.getName());
        clone.setBuildSpec(original.getBuildSpec());
        clone.setComment(original.getComment());
        clone.setDynamicReferences(original
                .getDynamicReferences());
        clone.setNatureIds(original.getNatureIds());
        clone.setReferencedProjects(original
                .getReferencedProjects());
        if(project.exists()){
            return;
        }
        project.create(clone, monitor);
        project.open(monitor);

        @SuppressWarnings("unchecked")
        List<IFile> filesToImport = FileSystemStructureProvider.INSTANCE.getChildren(edata.getProjectDir());
        ImportOperation io = new ImportOperation(project.getFullPath(), edata.getProjectDir(),
                FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {

                    @Override
                    public String queryOverwrite(String pathString) {
                        return IOverwriteQuery.ALL;
                    }

                }, filesToImport);
        io.setOverwriteResources(true);
        io.setCreateContainerStructure(false);
        io.run(monitor);
        project.refreshLocal(IProject.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        e.printStackTrace();
    }
}