Java 类org.eclipse.ui.dialogs.IOverwriteQuery 实例源码

项目:cft    文件:ServerHandler.java   
protected IRuntime createRuntime(IServerType st, IPath path, IProgressMonitor monitor, IOverwriteQuery query)
        throws CoreException {
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime != null) {
        if (!query(query, NLS.bind(Messages.ServerHandler_QUERY_RUNTIME_EXISTS,
                runtimeName))) {
            monitor.worked(1);
            return runtime;
        }
        else {
            runtime.delete();
        }
    }
    IRuntimeWorkingCopy wc = st.getRuntimeType().createRuntime(runtimeName, new SubProgressMonitor(monitor, 1));
    wc.setName(runtimeName);

    if (path != null) {
        wc.setLocation(path);
    }

    runtime = wc.save(true, new SubProgressMonitor(monitor, 1));

    return runtime;
}
项目:cft    文件:ServerHandler.java   
private IServer createServer(IServerType st, IRuntime runtime, IProgressMonitor monitor, IOverwriteQuery query,
        ServerHandlerCallback callback) throws CoreException {
    IServer server = ServerCore.findServer(serverName);
    if (server != null) {
        if (!query(query,
                NLS.bind(Messages.ServerHandler_QUERY_SERVER_EXISTS, serverName))) {
            monitor.worked(1);
            return server;
        }
        else {
            IFolder serverConfiguration = server.getServerConfiguration();
            server.delete();
            if (serverConfiguration != null) {
                serverConfiguration.delete(true, true, monitor);
            }
        }
    }

    IServerWorkingCopy wc = st.createServer(serverName, null, runtime, new SubProgressMonitor(monitor, 1));
    wc.setName(serverName);
    if (callback != null) {
        callback.configureServer(wc);
    }
    server = wc.save(true, new SubProgressMonitor(monitor, 1));
    return server;
}
项目:dockerfoundry    文件:ServerHandler.java   
protected IRuntime createRuntime(IServerType st, IPath path, IProgressMonitor monitor, IOverwriteQuery query)
        throws CoreException {
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime != null) {
        if (!query(query, NLS.bind(Messages.ServerHandler_QUERY_RUNTIME_EXISTS,
                runtimeName))) {
            monitor.worked(1);
            return runtime;
        }
        else {
            runtime.delete();
        }
    }
    IRuntimeWorkingCopy wc = st.getRuntimeType().createRuntime(runtimeName, new SubProgressMonitor(monitor, 1));
    wc.setName(runtimeName);

    if (path != null) {
        wc.setLocation(path);
    }

    runtime = wc.save(true, new SubProgressMonitor(monitor, 1));

    return runtime;
}
项目:dockerfoundry    文件:ServerHandler.java   
private IServer createServer(IServerType st, IRuntime runtime, IProgressMonitor monitor, IOverwriteQuery query,
        ServerHandlerCallback callback) throws CoreException {
    IServer server = ServerCore.findServer(serverName);
    if (server != null) {
        if (!query(query,
                NLS.bind(Messages.ServerHandler_QUERY_SERVER_EXISTS, serverName))) {
            monitor.worked(1);
            return server;
        }
        else {
            IFolder serverConfiguration = server.getServerConfiguration();
            server.delete();
            if (serverConfiguration != null) {
                serverConfiguration.delete(true, true, monitor);
            }
        }
    }

    IServerWorkingCopy wc = st.createServer(serverName, null, runtime, new SubProgressMonitor(monitor, 1));
    wc.setName(serverName);
    if (callback != null) {
        callback.configureServer(wc);
    }
    server = wc.save(true, new SubProgressMonitor(monitor, 1));
    return server;
}
项目:che    文件:ImportOperation.java   
/**
 * Queries the user whether the resource with the specified path should be overwritten by a file
 * system object that is being imported.
 *
 * @param resourcePath the workspace path of the resource that needs to be overwritten
 * @return <code>true</code> to overwrite, <code>false</code> to not overwrite
 * @exception OperationCanceledException if canceled
 */
boolean queryOverwrite(IPath resourcePath) throws OperationCanceledException {
  String overwriteAnswer =
      overwriteCallback.queryOverwrite(resourcePath.makeRelative().toString());

  if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) {
    throw new OperationCanceledException("DataTransferMessages.DataTransfer_emptyString");
  }

  if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
    return false;
  }

  if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
    this.overwriteState = OVERWRITE_NONE;
    return false;
  }

  if (overwriteAnswer.equals(IOverwriteQuery.ALL)) {
    this.overwriteState = OVERWRITE_ALL;
  }

  return true;
}
项目:sadlos2    文件:OwlImportOperation.java   
/**
   * Queries the user whether the resource with the specified path should be
   * overwritten by a file system object that is being imported.
   * 
   * @param resourcePath the workspace path of the resource that needs to be overwritten
   * @return <code>true</code> to overwrite, <code>false</code> to not overwrite
   * @exception OperationCanceledException if canceled
   */
  boolean queryOverwrite(IPath resourcePath)
          throws OperationCanceledException {
      String overwriteAnswer = overwriteCallback.queryOverwrite(resourcePath
              .makeRelative().toString());

      if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) {
    throw new OperationCanceledException(DataTransferMessages.DataTransfer_emptyString);
}

      if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
          return false;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
          this.overwriteState = OVERWRITE_NONE;
          return false;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.ALL)) {
    this.overwriteState = OVERWRITE_ALL;
}

      return true;
  }
项目:Environment    文件:ExampleService.java   
public static IProject unpackResourceProject(IProject project, Example.Resource resource) throws Exception
{
    if (resource.getType() == Type.ENVIRONMENT)
        CloudScaleProjectSupport.addProjectNature(project);

    ZipFile file = new ZipFile(resource.getArchive().getFile());
    ZipFileStructureProvider provider = new ZipFileStructureProvider(file);
    IPath containerPath = project.getFullPath();
    Object source = provider.getRoot();

    IOverwriteQuery query = new IOverwriteQuery()
    {
        @Override
        public String queryOverwrite(String path)
        {
            return IOverwriteQuery.ALL;
        };
    };
    ImportOperation operation = new ImportOperation(containerPath, source, provider, query);
    operation.run(null);

    return project;
}
项目:birt    文件:BirtWizardUtil.java   
/**
 * extract zip file and import files into project
 * 
 * @param srcZipFile
 * @param destPath
 * @param monitor
 * @param query
 * @throws CoreException
 */
private static void importFilesFromZip( ZipFile srcZipFile, IPath destPath,
        IProgressMonitor monitor, IOverwriteQuery query )
        throws CoreException
{
    try
    {
        ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(
                srcZipFile );
        List list = prepareFileList( structureProvider, structureProvider
                .getRoot( ), null );
        ImportOperation op = new ImportOperation( destPath,
                structureProvider.getRoot( ), structureProvider, query,
                list );
        op.run( monitor );
    }
    catch ( Exception e )
    {
        String message = srcZipFile.getName( ) + ": " + e.getMessage( ); //$NON-NLS-1$
        Logger.logException( e );
        throw BirtCoreException.getException( message, e );
    }
}
项目: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;
}
项目:mesfavoris    文件:BundleProjectImportOperation.java   
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    BundleImportStructureProvider bundleImportStructureProvider = new BundleImportStructureProvider(bundle);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IProject project = workspace.getRoot().getProject(projectName);
    IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
        public String queryOverwrite(String file) {
            return ALL;
        }
    };
    ImportOperation importOperation = new ImportOperation(project.getFullPath(), bundleProjectEntryPath,
            bundleImportStructureProvider, overwriteQuery);
    importOperation.setCreateContainerStructure(false);
    importOperation.run(monitor);
}
项目:cft    文件:ServerHandler.java   
public IServer createServer(IProgressMonitor monitor, IOverwriteQuery query, ServerHandlerCallback callback)
        throws CoreException {
    try {
        monitor.beginTask("Creating server configuration", 4); //$NON-NLS-1$

        IServerType st = ServerCore.findServerType(serverType);
        if (st == null) {
            throw new CoreException(CloudFoundryPlugin.getErrorStatus("Could not find server type \"" + serverType //$NON-NLS-1$
                    + "\"")); //$NON-NLS-1$
        }
        IRuntime runtime;
        if (serverPath != null) {
            runtime = createRuntime(st, new Path(serverPath), monitor, query);
        }
        else if (forceCreateRuntime) {
            runtime = createRuntime(st, null, monitor, query);
        }
        else {
            runtime = findRuntime(st, monitor);
        }

        if (serverName != null) {
            return createServer(st, runtime, monitor, query, callback);
        }
        else {
            return findServer(st, runtime, monitor);
        }
    }
    finally {
        monitor.done();
    }
}
项目:yamcs-studio    文件:DefaultYamcsStudioProject.java   
public IProject createProject(URL location, String sourceFolder) throws CoreException {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(sourceFolder);
    try {
        project.create(new NullProgressMonitor());
        project.open(new NullProgressMonitor());
    } catch (CoreException ex) {
        MessageDialog.openError(null, Messages.Error,
                NLS.bind(Messages.CreateProjectErrorFmt, project.getName(), ex.getMessage()));
        return null;
    }

    try {
        File templateRoot = new File(location.getPath(), sourceFolder);
        RelativeFileSystemStructureProvider structureProvider = new RelativeFileSystemStructureProvider(templateRoot);
        ImportOperation operation = new ImportOperation(project.getFullPath(), templateRoot, structureProvider,
                new IOverwriteQuery() {
            @Override
            public String queryOverwrite(String pathString) {
                return ALL;
            }
        }, structureProvider.getChildren(templateRoot));

        operation.setContext(Display.getDefault().getActiveShell());
        operation.run(null);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage()));
    }

    return project;
}
项目:triquetrum    文件:MomlExportOperation.java   
/**
 * Create an instance of this class. Use this constructor if you wish to recursively export a single resource
 */
public MomlExportOperation(IResource res, String destinationPath, IOverwriteQuery overwriteImplementor) {
  super();
  resource = res;
  path = new Path(destinationPath);
  overwriteCallback = overwriteImplementor;
}
项目:dockerfoundry    文件:ServerHandler.java   
public IServer createServer(IProgressMonitor monitor, IOverwriteQuery query, ServerHandlerCallback callback)
        throws CoreException {
    try {
        monitor.beginTask("Creating server configuration", 4); //$NON-NLS-1$

        IServerType st = ServerCore.findServerType(serverType);
        if (st == null) {
            throw new CoreException(DockerFoundryPlugin.getErrorStatus("Could not find server type \"" + serverType //$NON-NLS-1$
                    + "\"")); //$NON-NLS-1$
        }
        IRuntime runtime;
        if (serverPath != null) {
            runtime = createRuntime(st, new Path(serverPath), monitor, query);
        }
        else if (forceCreateRuntime) {
            runtime = createRuntime(st, null, monitor, query);
        }
        else {
            runtime = findRuntime(st, monitor);
        }

        if (serverName != null) {
            return createServer(st, runtime, monitor, query, callback);
        }
        else {
            return findServer(st, runtime, monitor);
        }
    }
    finally {
        monitor.done();
    }
}
项目:OpenSPIFe    文件:EnsembleFileSystemExportOperation.java   
/**
 *  Create an instance of this class.  Use this constructor if you wish to
 *  recursively export a single resource
 */
public EnsembleFileSystemExportOperation(IResource res, String destinationPath,
        IOverwriteQuery overwriteImplementor) {
    super();
    resource = res;
    path = new Path(destinationPath);
    overwriteCallback = overwriteImplementor;
    cancelledOnce = false;
    exporter = getEnsembleFileSystemExporter();
}
项目:OpenSPIFe    文件:EnsembleFileSystemExportOperation.java   
/**
 *  Create an instance of this class.  Use this constructor if you wish to
 *  export specific resources with a common parent resource (affects container
 *  directory creation)
 */
public EnsembleFileSystemExportOperation(IResource res, List resources,
        String destinationPath, IOverwriteQuery overwriteImplementor) {
    this(res, destinationPath, overwriteImplementor);
    resourcesToExport = resources;
    cancelledOnce = false;
}
项目:thym    文件:NativeBinaryExportOperation.java   
public NativeBinaryExportOperation(
        List<AbstractNativeBinaryBuildDelegate> delegates,
        File destination,
        IOverwriteQuery query) {
    this.delegates = delegates;
    this.overwriteQuery = query;
    this.destinationDir = destination;
}
项目:thym    文件:NativeBinaryExportOperation.java   
@Override
protected void execute(IProgressMonitor monitor) throws CoreException,
        InvocationTargetException, InterruptedException {
    SubMonitor sm = SubMonitor.convert(monitor);
    sm.setWorkRemaining(delegates.size()*10);
    for (AbstractNativeBinaryBuildDelegate delegate : delegates) {
        if(monitor.isCanceled()){ 
            break; 
        }
        delegate.setRelease(true);
        delegate.buildNow(sm.newChild(10));
        try {
            File buildArtifact = delegate.getBuildArtifact();
            File destinationFile = new File(destinationDir, buildArtifact.getName());
            if(destinationFile.exists()){
                String callback = overwriteQuery.queryOverwrite(destinationFile.toString());
                if(IOverwriteQuery.NO.equals(callback)){
                    continue;
                }
                if(IOverwriteQuery.CANCEL.equals(callback)){
                    break;
                }
            }
            File artifact = delegate.getBuildArtifact();
            if(artifact.isDirectory()){
                FileUtils.copyDirectoryToDirectory(artifact, destinationDir);
            }else{
                FileUtils.copyFileToDirectory(artifact, destinationDir);
            }
            sm.done();
        } catch (IOException e) {
            HybridCore.log(IStatus.ERROR, "Error on NativeBinaryExportOperation", e);
        }
    }
    monitor.done(); 
}
项目:Environment    文件:ExampleProjectWizard.java   
public static IProject createExampleProject(IProject project, Example.Resource resource)
{
    try
    {

        if (resource.getType() == Type.ENVIRONMENT)
            CloudScaleProjectSupport.addProjectNature(project);

        ZipFile file = new ZipFile(resource.getArchive().getFile());
        ZipFileStructureProvider provider = new ZipFileStructureProvider(file);
        IPath containerPath = project.getFullPath();
        Object source = provider.getRoot();

        IOverwriteQuery query = new IOverwriteQuery()
        {
            @Override
            public String queryOverwrite(String path)
            {
                return IOverwriteQuery.ALL;
            };
        };
        ImportOperation operation = new ImportOperation(containerPath, source, provider, query);
        try
        {
            operation.run(null);
        } catch (Exception ex)
        {
            ex.printStackTrace();
        }
    } catch (Exception e)
    {
        e.printStackTrace();
        project = null;
    }

    return project;
}
项目:birt    文件:WebArtifactUtil.java   
/**
 * Configure the web application general descriptions
 * 
 * @param webApp
 * @param project
 * @param query
 * @param monitor
 * @throws CoreException
 */
public static void configureWebApp( WebAppBean webAppBean,
        IProject project, IOverwriteQuery query, IProgressMonitor monitor )
        throws CoreException
{
    // cancel progress
    if ( monitor.isCanceled( ) )
        return;

    if ( webAppBean == null || project == null )
    {
        return;
    }

    // create WebArtifact
    WebArtifactEdit webEdit = WebArtifactEdit
            .getWebArtifactEditForWrite( project );
    if ( webEdit == null )
        return;

    try
    {
        WebApp webapp = (WebApp) webEdit.getDeploymentDescriptorRoot( );
        webapp.setDescription( webAppBean.getDescription( ) );
        webEdit.saveIfNecessary( monitor );
    }
    finally
    {
        webEdit.dispose( );
    }
}
项目:birt    文件:BirtFacetUtil25.java   
public void configureFilter(Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor) {
    WebApp webApp = getWebApp(map, project, monitor);
    if (webApp == null)
        return;

    // handle filter settings
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        String name = DataUtil.getString(it.next(), false);
        FilterBean bean = (FilterBean) map.get(name);
        if (bean == null)
            continue;
        // if contained this filter
        Object obj = getFilterByName(webApp, name);
        if (obj != null) {
            String ret = query.queryOverwrite("Filter '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
            // check overwrite query result
            if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
                continue;
            }
            if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
                monitor.setCanceled(true);
                return;
            }
            // remove old item
            webApp.getFilters().remove(obj);
        }
        String className = bean.getClassName();
        String description = bean.getDescription();
        // create filter object
        Filter filter = WebFactory.eINSTANCE.createFilter();
        filter.setFilterName(name);
        filter.setFilterClass(className);
        Description descriptionObj = JavaeeFactory.eINSTANCE
                .createDescription();
        descriptionObj.setValue(description);
        webApp.getFilters().add(filter);
    }
}
项目: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();
    }
}
项目:cft    文件:ServerHandler.java   
public String queryOverwrite(String arg0) {
    return IOverwriteQuery.YES;
}
项目:cft    文件:ServerHandler.java   
public String queryOverwrite(String arg0) {
    return IOverwriteQuery.NO;
}
项目:cft    文件:ServerHandler.java   
public IServer createServer(IProgressMonitor monitor, IOverwriteQuery query) throws CoreException {
    return createServer(monitor, query, null);
}
项目:triquetrum    文件:MomlExportOperation.java   
/**
 * Create an instance of this class. Use this constructor if you wish to export specific resources with a common parent resource (affects container directory
 * creation)
 */
public MomlExportOperation(IResource res, List<?> resources, String destinationPath, IOverwriteQuery overwriteImplementor) {
  this(res, destinationPath, overwriteImplementor);
  resourcesToExport = resources;
}
项目:triquetrum    文件:MomlExportOperation.java   
/**
 * Export the passed file to the specified location
 *
 * @param file
 *          org.eclipse.core.resources.IFile
 * @param location
 *          org.eclipse.core.runtime.IPath
 */
protected void exportFile(IFile file, IPath location) throws InterruptedException {
  IPath fullPath = location.append(file.getName()).removeFileExtension().addFileExtension("moml");
  monitor.subTask(file.getFullPath().toString());
  String properPathString = fullPath.toOSString();
  File targetFile = new File(properPathString);

  if (targetFile.exists()) {
    if (!targetFile.canWrite()) {
      errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Cannot overwrite file: {0}", targetFile.getAbsolutePath()), null));
      monitor.worked(1);
      return;
    }

    if (overwriteState == OVERWRITE_NONE) {
      return;
    }

    if (overwriteState != OVERWRITE_ALL) {
      String overwriteAnswer = overwriteCallback.queryOverwrite(properPathString);

      if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) {
        throw new InterruptedException();
      }

      if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
        monitor.worked(1);
        return;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
        monitor.worked(1);
        overwriteState = OVERWRITE_NONE;
        return;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.ALL)) {
        overwriteState = OVERWRITE_ALL;
      }
    }
  }

  try {
    // 1. obtain Diagram for the file
    Diagram diagram = GraphitiUiInternal.getEmfService().getDiagramFromFile(file, new ResourceSetImpl());
    // 2. find root CompositeActor
    CompositeActor toplevel = (CompositeActor) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(diagram);
    // 3. push location info of diagram model elements to the Ptolemy II model elements
    pushLocations(diagram, toplevel);
    // 4. exportMOML to the destination file
    FileUtils.writeStringToFile(new File(fullPath.toOSString()), toplevel.getWrappedObject().exportMoML());
  } catch (IOException e) {
    errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Error exporting {0}: {1}", fullPath, e.getMessage()), e));
  }

  monitor.worked(1);
  ModalContext.checkCanceled(monitor);
}
项目: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();
    }
}
项目:dockerfoundry    文件:ServerHandler.java   
public String queryOverwrite(String arg0) {
    return IOverwriteQuery.YES;
}
项目:dockerfoundry    文件:ServerHandler.java   
public String queryOverwrite(String arg0) {
    return IOverwriteQuery.NO;
}
项目:dockerfoundry    文件:ServerHandler.java   
public IServer createServer(IProgressMonitor monitor, IOverwriteQuery query) throws CoreException {
    return createServer(monitor, query, null);
}
项目:thym    文件:HybridProjectImportPage.java   
@Override
public String queryOverwrite(String pathString) {
    return IOverwriteQuery.ALL;
}
项目:birt    文件:BirtWizardUtil.java   
/**
 * Do import zip file into current project
 * 
 * @param project
 * @param source
 * @param dest
 * @param monitor
 * @param query
 * @throws CoreException
 */
public static void doImports( IProject project, String source,
        IPath destPath, IProgressMonitor monitor, IOverwriteQuery query )
        throws CoreException
{
    IConfigurationElement configElement = BirtWizardUtil.findConfigurationElementById( IBirtWizardConstants.EXAMPLE_WIZARD_EXTENSION_POINT,
            IBirtWizardConstants.BIRTEXAMPLE_WIZARD_ID );

    // if source file is null, try to find it defined extension
    if ( source == null )
    {
        if ( configElement != null )
        {
            // get projectsetup fregment
            IConfigurationElement[] projects = configElement.getChildren( "projectsetup" ); //$NON-NLS-1$
            IConfigurationElement[] imports = null;
            if ( projects != null && projects.length > 0 )
            {
                imports = projects[0].getChildren( "import" ); //$NON-NLS-1$                    
            }

            // get import fregment
            if ( imports != null && imports.length > 0 )
            {
                // get defined zip file name
                source = imports[0].getAttribute( "src" ); //$NON-NLS-1$
            }
        }
    }

    // if source is null, throw exception
    if ( source == null )
    {
        String message = BirtWTPMessages.BIRTErrors_miss_source;
        Logger.log( Logger.ERROR, message );
        throw ChartIntegrationException.getException( message, null );
    }

    // create zip entry from source file
    ZipFile zipFile = getZipFileFromPluginDir( source,
            getContributingPlugin( configElement ) );

    // extract zip file and import files into project
    importFilesFromZip( zipFile, destPath, new SubProgressMonitor( monitor,
            1 ), query );
}
项目:birt    文件:WebArtifactUtil.java   
/**
 * Configure the listener settings
 * 
 * @param map
 * @param project
 * @param query
 * @param monitor
 * @throws CoreException
 */
public static void configureListener( Map map, IProject project,
        IOverwriteQuery query, IProgressMonitor monitor )
        throws CoreException
{
    // cancel progress
    if ( monitor.isCanceled( ) )
        return;

    if ( map == null || project == null )
    {
        return;
    }

    // create WebArtifact
    WebArtifactEdit webEdit = WebArtifactEdit
            .getWebArtifactEditForWrite( project );
    if ( webEdit == null )
        return;

    try
    {
        WebApp webapp = (WebApp) webEdit.getDeploymentDescriptorRoot( );

        // handle listeners settings
        Iterator it = map.keySet( ).iterator( );
        while ( it.hasNext( ) )
        {
            String name = DataUtil.getString( it.next( ), false );
            ListenerBean bean = (ListenerBean) map.get( name );
            if ( bean == null )
                continue;

            String className = bean.getClassName( );
            String description = bean.getDescription( );

            // if listener existed in web.xml, skip it
            Object obj = getListenerByClassName( webapp.getListeners( ),
                    className );
            if ( obj != null )
                continue;

            // create Listener object
            Listener listener = CommonFactory.eINSTANCE.createListener( );
            listener.setListenerClassName( className );
            if ( description != null )
                listener.setDescription( description );

            webapp.getListeners( ).remove( listener );
            webapp.getListeners( ).add( listener );
        }

        webEdit.saveIfNecessary( monitor );
    }
    finally
    {
        webEdit.dispose( );
    }
}
项目:birt    文件:BirtFacetUtil25.java   
public void configureContextParam(Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor) {
    WebApp webApp = getWebApp(map, project, monitor);
    if (webApp == null)
        return;
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        String name = DataUtil.getString(it.next(), false);
        ContextParamBean bean = (ContextParamBean) map.get(name);
        if (bean == null)
            continue;

        // if contained this param
        List list = webApp.getContextParams();

        int index = getContextParamIndexByName(list, name);
        if (index >= 0) {
            String ret = query
                    .queryOverwrite("Context-param '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$

            // check overwrite query result
            if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
                continue;
            }
            if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
                monitor.setCanceled(true);
                return;
            }

            // remove old item
            list.remove(index);
        }

        String value = bean.getValue();
        String description = bean.getDescription();
        ParamValue param = JavaeeFactory.eINSTANCE.createParamValue();
        param.setParamName(name);
        param.setParamValue(value);
        if (description != null) {
            Description descriptionObj = JavaeeFactory.eINSTANCE
                    .createDescription();
            descriptionObj.setValue(description);
            param.getDescriptions().add(descriptionObj);

        }

        // add into list
        webApp.getContextParams().add(param);

    }

}
项目:birt    文件:BirtFacetUtil25.java   
public void configureFilterMapping(Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor) {
    WebApp webApp = getWebApp(map, project, monitor);
    if (webApp == null)
        return;

    // handle filter-mapping settings
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        String key = DataUtil.getString(it.next(), false);
        FilterMappingBean bean = (FilterMappingBean) map.get(key);
        if (bean == null)
            continue;
        // if contained this filter-mapping
        Object obj = getFilterMappingByKey(webApp.getFilterMappings(), key);
        if (obj != null) {
            String ret = query
                    .queryOverwrite("Filter-mapping '" + key + "'"); //$NON-NLS-1$ //$NON-NLS-2$
            // check overwrite query result
            if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
                continue;
            }
            if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
                monitor.setCanceled(true);
                return;
            }
            // remove old item
            webApp.getFilterMappings().remove(obj);
        }
        // filter name
        String name = bean.getName();
        // create FilterMapping object
        FilterMapping mapping = WebFactory.eINSTANCE.createFilterMapping();
        // get filter by name
        Filter filter = (Filter) getFilterByName(webApp, name);
        if (filter != null) {
            mapping.setFilterName(filter.getFilterName());
            if (bean.getUri() != null) {
                UrlPatternType urlPattern = JavaeeFactory.eINSTANCE
                        .createUrlPatternType();
                urlPattern.setValue(bean.getUri());
                mapping.getUrlPatterns().add(urlPattern);
            }
            mapping.getServletNames().add(bean.getServletName());

            // get Servlet object
            Servlet servlet = findServletByName(webApp, bean
                    .getServletName());
            // mapping.setServlet(servlet);
            if (servlet != null || bean.getUri() != null)
                webApp.getFilterMappings().add(mapping);
        }
    }

}
项目:birt    文件:BirtFacetUtil25.java   
public void configureServlet(Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor) {
    WebApp webApp = getWebApp(map, project, monitor);
    if (webApp == null)
        return;
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        String name = DataUtil.getString(it.next(), false);
        ServletBean bean = (ServletBean) map.get(name);
        if (bean == null)
            continue;
        // if contained this servlet
        Object obj = findServletByName(webApp, name);
        // webapp.getServletNamed(name);
        if (obj != null) {
            String ret = query.queryOverwrite("Servlet '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
            // check overwrite query result
            if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
                continue;
            }
            if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
                monitor.setCanceled(true);
                return;
            }
            // remove old item
            webApp.getServlets().remove(obj);
        }
        String className = bean.getClassName();
        String description = bean.getDescription();
        // create Servlet Type object
        Servlet servlet = WebFactory.eINSTANCE.createServlet();
        servlet.setServletName(name);
        servlet.setServletClass(className);
        // FIXME
        // servlet.setDescription(description);
        servlet.setLoadOnStartup(Integer.valueOf(1));
        // Add the servlet to the web application model
        webApp.getServlets().add(servlet);
        // FIXME
        // servlet.setWebApp(webapp);
    }
}
项目:birt    文件:BirtFacetUtil25.java   
public void configureServletMapping(Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor) {
    WebApp webApp = getWebApp(map, project, monitor);
    if (webApp == null)
        return;
    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        String uri = DataUtil.getString(it.next(), false);
        ServletMappingBean bean = (ServletMappingBean) map.get(uri);
        if (bean == null)
            continue;
        // if contained this servlet-mapping
        Object obj = getServletMappingByUri(webApp.getServletMappings(),
                uri);
        if (obj != null) {
            String ret = query
                    .queryOverwrite("Servlet-mapping '" + uri + "'"); //$NON-NLS-1$ //$NON-NLS-2$
            // check overwrite query result
            if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
                continue;
            }
            if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
                monitor.setCanceled(true);
                return;
            }
            // remove old item
            webApp.getServletMappings().remove(obj);
        }
        // servlet name
        String name = bean.getName();
        // create ServletMapping object
        ServletMapping mapping = WebFactory.eINSTANCE
                .createServletMapping();
        // get servlet by name
        Servlet servlet = findServletByName(webApp, name);
        if (servlet != null) {
            mapping.setServletName(servlet.getServletName());
            UrlPatternType urlPattern = JavaeeFactory.eINSTANCE
                    .createUrlPatternType();
            urlPattern.setValue(uri);
            mapping.getUrlPatterns().add(urlPattern);
            webApp.getServletMappings().add(mapping);
            // mapping.setUrlPattern(uri);
            // mapping.setWebApp( webapp );
        }
    }
}
项目:birt    文件:BirtFacetUtil.java   
public void configureFilter( Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor )
{
    WebApp webApp = getWebApp( map, project, monitor );
    if ( webApp == null )
        return;

    // handle filter settings
    Iterator it = map.keySet( ).iterator( );
    while ( it.hasNext( ) )
    {
        String name = DataUtil.getString( it.next( ), false );
        FilterBean bean = (FilterBean) map.get( name );

        if ( bean == null )
            continue;

        // if contained this filter
        Object obj = webApp.getFilterNamed( name );
        if ( obj != null )
        {
            String ret = query.queryOverwrite( "Filter '" + name + "'" ); //$NON-NLS-1$ //$NON-NLS-2$

            // check overwrite query result
            if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) )
            {
                continue;
            }
            if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) )
            {
                monitor.setCanceled( true );
                return;
            }

            // remove old item
            webApp.getFilters( ).remove( obj );
        }

        String className = bean.getClassName( );
        String description = bean.getDescription( );

        // create filter object
        Filter filter = WebapplicationFactory.eINSTANCE.createFilter( );
        filter.setName( name );
        filter.setFilterClassName( className );
        filter.setDescription( description );
        webApp.getFilters( ).add( filter );
    }
}
项目:birt    文件:BirtFacetUtil.java   
public void configureFilterMapping( Map map, IProject project,
        SimpleImportOverwriteQuery query, IProgressMonitor monitor )
{
    WebApp webApp = getWebApp( map, project, monitor );
    if ( webApp == null )
        return;

    // handle filter-mapping settings
    Iterator it = map.keySet( ).iterator( );
    while ( it.hasNext( ) )
    {
        String key = DataUtil.getString( it.next( ), false );
        FilterMappingBean bean = (FilterMappingBean) map.get( key );
        if ( bean == null )
            continue;
        // if contained this filter-mapping
        Object obj = getFilterMappingByKey( webApp.getFilterMappings( ),
                key );
        if ( obj != null )
        {
            String ret = query
                    .queryOverwrite( "Filter-mapping '" + key + "'" ); //$NON-NLS-1$ //$NON-NLS-2$
            // check overwrite query result
            if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) )
            {
                continue;
            }
            if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) )
            {
                monitor.setCanceled( true );
                return;
            }
            // remove old item
            webApp.getFilterMappings( ).remove( obj );
        }
        // filter name
        String name = bean.getName( );
        // create FilterMapping object
        FilterMapping mapping = WebapplicationFactory.eINSTANCE
                .createFilterMapping( );
        // get filter by name
        Filter filter = webApp.getFilterNamed( name );
        if ( filter != null )
        {
            mapping.setFilter( filter );
            mapping.setUrlPattern( bean.getUri( ) );
            mapping.setServletName( bean.getServletName( ) );
            // get Servlet object
            Servlet servlet = webApp
                    .getServletNamed( bean.getServletName( ) );
            mapping.setServlet( servlet );
            if ( bean.getUri( ) != null || servlet != null )
                webApp.getFilterMappings( ).add( mapping );
        }
    }
}