org.eclipse.ui.dialogs.IOverwriteQuery Java Examples
The following examples show how to use
org.eclipse.ui.dialogs.IOverwriteQuery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BirtWizardUtil.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * 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 ); } }
Example #2
Source File: ExampleImporter.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("deprecation") public IProject 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; } 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); return project; } catch (Exception e) { e.printStackTrace(); } return null; }
Example #3
Source File: TraceValidateAndImportOperation.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Extract all file system elements (Tar, Zip elements) to destination * folder (typically workspace/TraceProject/.traceImport or a subfolder of * it) */ private void extractArchiveContent(Iterator<TraceFileSystemElement> fileSystemElementsIter, IFolder tempFolder, IProgressMonitor progressMonitor) throws InterruptedException, InvocationTargetException { List<TraceFileSystemElement> subList = new ArrayList<>(); // Collect all the elements while (fileSystemElementsIter.hasNext()) { ModalContext.checkCanceled(progressMonitor); TraceFileSystemElement element = fileSystemElementsIter.next(); if (element.isDirectory()) { Object[] array = element.getFiles().getChildren(); for (int i = 0; i < array.length; i++) { subList.add((TraceFileSystemElement) array[i]); } } subList.add(element); } if (subList.isEmpty()) { return; } TraceFileSystemElement root = getRootElement(subList.get(0)); ImportProvider fileSystemStructureProvider = new ImportProvider(); IOverwriteQuery myQueryImpl = file -> IOverwriteQuery.NO_ALL; progressMonitor.setTaskName(Messages.ImportTraceWizard_ExtractImportOperationTaskName); IPath containerPath = tempFolder.getFullPath(); ImportOperation operation = new ImportOperation(containerPath, root, fileSystemStructureProvider, myQueryImpl, subList); operation.setContext(fShell); operation.setCreateContainerStructure(true); operation.setOverwriteResources(false); operation.setVirtualFolders(false); operation.run(SubMonitor.convert(progressMonitor).newChild(subList.size())); }
Example #4
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 5 votes |
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); } }
Example #5
Source File: WebArtifactUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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( ); } }
Example #6
Source File: NativeBinaryExportOperation.java From thym with Eclipse Public License 1.0 | 5 votes |
public NativeBinaryExportOperation( List<AbstractNativeBinaryBuildDelegate> delegates, File destination, IOverwriteQuery query) { this.delegates = delegates; this.overwriteQuery = query; this.destinationDir = destination; }
Example #7
Source File: NativeBinaryExportOperation.java From thym with Eclipse Public License 1.0 | 5 votes |
@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(); }
Example #8
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
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); } } }
Example #9
Source File: TracePackageImportOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override public String queryOverwrite(String pathString) { // We always overwrite once we reach this point return IOverwriteQuery.ALL; }
Example #10
Source File: BirtWizardUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * 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 ) { // get zip file name 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 BirtCoreException.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 ); }
Example #11
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureTaglib( Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor ) { WebApp webApp = getWebApp( map, project, monitor ); if ( webApp == null ) return; // handle taglib settings Iterator it = map.keySet( ).iterator( ); while ( it.hasNext( ) ) { String uri = DataUtil.getString( it.next( ), false ); TagLibBean bean = (TagLibBean) map.get( uri ); if ( bean == null ) continue; // if contained this taglib Object obj = getTagLibByUri( webApp, uri ); if ( obj != null ) { String ret = query.queryOverwrite( "Taglib '" + 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 if ( obj instanceof TagLibRefType && webApp.getJspConfig( ) != null ) { webApp.getJspConfig( ).getTagLibs( ).remove( obj ); } else { webApp.getTagLibs( ).remove( obj ); } } String location = bean.getLocation( ); if ( webApp.getVersionID( ) == 23 ) { // create TaglibRef object for servlet 2.3 TagLibRef taglib = WebapplicationFactory.eINSTANCE .createTagLibRef( ); taglib.setTaglibURI( uri ); taglib.setTaglibLocation( location ); webApp.getTagLibs( ).add( taglib ); } else { // for servlet 2.4 JSPConfig jspConfig = JspFactory.eINSTANCE.createJSPConfig( ); TagLibRefType ref = JspFactory.eINSTANCE.createTagLibRefType( ); ref.setTaglibURI( uri ); ref.setTaglibLocation( location ); jspConfig.getTagLibs( ).add( ref ); webApp.setJspConfig( jspConfig ); } } }
Example #12
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
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 = WebArtifactUtil.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 org.eclipse.jst.j2ee.webapplication.ServletMapping mapping = WebapplicationFactory.eINSTANCE .createServletMapping( ); // get servlet by name Servlet servlet = webApp.getServletNamed( name ); if ( servlet != null ) { mapping.setServlet( servlet ); mapping.setUrlPattern( uri ); mapping.setWebApp( webApp ); } } }
Example #13
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureServlet( Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor ) { WebApp webApp = getWebApp( map, project, monitor ); if ( webApp == null ) return; // handle servlet settings 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 = 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 ServletType servletType = WebapplicationFactory.eINSTANCE .createServletType( ); servletType.setClassName( className ); // create Servlet object Servlet servlet = WebapplicationFactory.eINSTANCE.createServlet( ); servlet.setServletName( name ); if ( description != null ) servlet.setDescription( description ); servlet.setWebType( servletType ); servlet.setWebApp( webApp ); } }
Example #14
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); } } }
Example #15
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); } }
Example #16
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); } } }
Example #17
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
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); } }
Example #18
Source File: TraceValidateAndImportOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Imports a trace resource to project. In case of name collision the user * will be asked to confirm overwriting the existing trace, overwriting or * skipping the trace to be imported. * * @param fileSystemElement * trace file system object to import * @param monitor * a progress monitor * @return the imported resource or null if no resource was imported * * @throws InvocationTargetException * if problems during import operation * @throws InterruptedException * if cancelled * @throws CoreException * if problems with workspace */ private IResource importResource(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, CoreException { IPath tracePath = getInitialDestinationPath(fileSystemElement); String newName = fConflictHandler.checkAndHandleNameClash(tracePath, monitor); if (newName == null) { return null; } fileSystemElement.setLabel(newName); List<TraceFileSystemElement> subList = new ArrayList<>(); FileSystemElement parentFolder = fileSystemElement.getParent(); IPath containerPath = fileSystemElement.getDestinationContainerPath(); tracePath = containerPath.addTrailingSeparator().append(fileSystemElement.getLabel()); boolean createLinksInWorkspace = (fImportOptionFlags & ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE) != 0; if (fileSystemElement.isDirectory() && !createLinksInWorkspace) { containerPath = tracePath; Object[] array = fileSystemElement.getFiles().getChildren(); for (int i = 0; i < array.length; i++) { subList.add((TraceFileSystemElement) array[i]); } parentFolder = fileSystemElement; } else { if (!fileSystemElement.isDirectory()) { // File traces IFileInfo info = EFS.getStore(new File(fileSystemElement.getFileSystemObject().getAbsolutePath()).toURI()).fetchInfo(); if (info.getLength() == 0) { // Don't import empty traces return null; } } subList.add(fileSystemElement); } ImportProvider fileSystemStructureProvider = new ImportProvider(); IOverwriteQuery myQueryImpl = file -> IOverwriteQuery.NO_ALL; monitor.setTaskName(Messages.ImportTraceWizard_ImportOperationTaskName + " " + fileSystemElement.getFileSystemObject().getAbsolutePath()); //$NON-NLS-1$ ImportOperation operation = new ImportOperation(containerPath, parentFolder, fileSystemStructureProvider, myQueryImpl, subList); operation.setContext(fShell); operation.setCreateContainerStructure(false); operation.setOverwriteResources(false); operation.setCreateLinks(createLinksInWorkspace); operation.setVirtualFolders(false); operation.run(SubMonitor.convert(monitor).newChild(1)); String sourceLocation = fileSystemElement.getSourceLocation(); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(tracePath); if ((sourceLocation != null) && (resource != null)) { resource.setPersistentProperty(TmfCommonConstants.SOURCE_LOCATION, sourceLocation); } return resource; }
Example #19
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
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); } }
Example #20
Source File: WebArtifactUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Configure the servlet-mapping settings * * @param map * @param project * @param query * @param monitor * @throws CoreException */ public static void configureServletMapping( 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 servlet-mapping settings 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 = WebapplicationFactory.eINSTANCE .createServletMapping( ); // get servlet by name Servlet servlet = webapp.getServletNamed( name ); if ( servlet != null ) { mapping.setServlet( servlet ); mapping.setUrlPattern( uri ); mapping.setWebApp( webapp ); } } webEdit.saveIfNecessary( monitor ); } finally { webEdit.dispose( ); } }
Example #21
Source File: WebArtifactUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Configure the servlet settings * * @param map * @param project * @param query * @param monitor * @throws CoreException */ public static void configureServlet( 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 servlet settings 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 = getServletByName( webapp.getServlets( ), 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 ServletType servletType = WebapplicationFactory.eINSTANCE .createServletType( ); servletType.setClassName( className ); // create Servlet object Servlet servlet = WebapplicationFactory.eINSTANCE .createServlet( ); servlet.setServletName( name ); if ( description != null ) servlet.setDescription( description ); servlet.setWebType( servletType ); servlet.setWebApp( webapp ); } webEdit.saveIfNecessary( monitor ); } finally { webEdit.dispose( ); } }
Example #22
Source File: WebArtifactUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * 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( ); } }
Example #23
Source File: BirtWizardUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * 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 ); }
Example #24
Source File: HybridProjectImportPage.java From thym with Eclipse Public License 1.0 | 4 votes |
@Override public String queryOverwrite(String pathString) { return IOverwriteQuery.ALL; }