Java Code Examples for org.eclipse.core.resources.IFolder#refreshLocal()
The following examples show how to use
org.eclipse.core.resources.IFolder#refreshLocal() .
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: ExternalFoldersManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected IStatus run(IProgressMonitor pm) { try { if (this.externalFolders == null) return Status.OK_STATUS; IPath externalPath = null; for (int index = 0; index < this.externalFolders.size(); index++ ) { if ((externalPath = (IPath)this.externalFolders.get(index)) != null) { IFolder folder = getFolder(externalPath); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=321358 if (folder != null) folder.refreshLocal(IResource.DEPTH_INFINITE, pm); } // Set the processed ones to null instead of removing the element altogether, // so that they will not be considered as duplicates. // This will also avoid elements being shifted to the left every time an element // is removed. However, there is a risk of Collection size to be increased more often. this.externalFolders.setElementAt(null, index); } } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; }
Example 2
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IServer createServer(final IProgressMonitor monitor, final IProject confProject, final IRuntime runtime) throws CoreException { final IServerType sType = ServerCore.findServerType(TOMCAT_SERVER_TYPE); final IFile file = confProject.getFile("bonitaTomcatServerSerialization"); final IFolder configurationFolder = confProject .getFolder("tomcat_conf"); final File sourceFolder = new File(tomcatInstanceLocation, "conf"); PlatformUtil.copyResource(configurationFolder.getLocation().toFile(), sourceFolder, Repository.NULL_PROGRESS_MONITOR); configurationFolder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR); final IServer server = configureServer(runtime, sType, file, configurationFolder, monitor); portConfigurator = newPortConfigurator(server); portConfigurator.configureServerPort(Repository.NULL_PROGRESS_MONITOR); return server; }
Example 3
Source File: BuildscriptGenerator.java From cmake4eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Recursively creates the folder hierarchy needed for the build output, if * necessary. If the folder is created, its derived bit is set to true so the * CM system ignores the contents. If the resource exists, respect the * existing derived setting. * * @param folder * a folder, somewhere below the project root */ private void createFolder(IFolder folder) throws CoreException { if (!folder.exists()) { // Make sure that parent folders exist IContainer parent = folder.getParent(); if (parent instanceof IFolder && !parent.exists()) { createFolder((IFolder) parent); } // Now make the requested folder try { folder.create(IResource.DERIVED, true, monitor); } catch (CoreException e) { if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) folder.refreshLocal(IResource.DEPTH_ZERO, monitor); else throw e; } } }
Example 4
Source File: BuildBundleHandler.java From tesb-studio-se with Apache License 2.0 | 6 votes |
@Override public IFile getJobTargetFile() { if (talendProcessJavaProject == null) { return null; } Property jobProperty = processItem.getProperty(); boolean needLauncher = exportChoice.get(ExportChoice.needLauncher) != null; boolean needAssembly = exportChoice.get(ExportChoice.needAssembly) != null; String jobName = JavaResourcesHelper.getJobJarName(jobProperty.getLabel(), jobProperty.getVersion()) + ((needLauncher && needAssembly) ? ".zip" : ".kar"); IFolder targetFolder = talendProcessJavaProject.getTargetFolder(); try { targetFolder.refreshLocal(IResource.DEPTH_ONE, null); } catch (CoreException e) { ExceptionHandler.process(e); } IFile jobFile = targetFolder.getFile(jobName); return jobFile; }
Example 5
Source File: WarPublisherTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testPublishExploded() throws CoreException { IProject project = projectCreator.withFacets(WebFacetUtils.WEB_25).getProject(); IFolder exploded = project.getFolder("exploded-war"); IPath tempDirectory = project.getFolder("temp").getLocation(); IStatus[] result = WarPublisher.publishExploded(project, exploded.getLocation(), tempDirectory, monitor); assertEquals(0, result.length); exploded.refreshLocal(IResource.DEPTH_INFINITE, monitor); assertTrue(exploded.getFile("META-INF/MANIFEST.MF").exists()); assertTrue(exploded.getFile("WEB-INF/web.xml").exists()); }
Example 6
Source File: ExternalFoldersManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IFolder createLinkFolder(IPath externalFolderPath, boolean refreshIfExistAlready, IProject externalFoldersProject, IProgressMonitor monitor) throws CoreException { IFolder result = addFolder(externalFolderPath, externalFoldersProject, false); if (!result.exists()) result.createLink(externalFolderPath, IResource.ALLOW_MISSING_LOCAL, monitor); else if (refreshIfExistAlready) result.refreshLocal(IResource.DEPTH_INFINITE, monitor); return result; }
Example 7
Source File: TmfCommonProjectElement.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Refreshes the element specific supplementary folder information. It creates * the folder if not exists. It sets the persistence property of the trace * resource * * @param monitor * the progress monitor * @since 4.0 */ public void refreshSupplementaryFolder(IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, 2); IFolder supplFolder = createSupplementaryFolder(subMonitor.split(1)); try { supplFolder.refreshLocal(IResource.DEPTH_INFINITE, subMonitor.split(1)); } catch (CoreException e) { Activator.getDefault().logError("Error refreshing supplementary folder " + supplFolder, e); //$NON-NLS-1$ } }
Example 8
Source File: Model.java From tlaplus with MIT License | 5 votes |
public void createModelOutputLogFile(InputStream is, IProgressMonitor monitor) throws CoreException { IFolder targetFolder = getTargetDirectory(); // Create targetFolder which might be missing if the model has never // been checked but the user wants to load TLC output anyway. // This happens with distributed TLC, where the model is executed // remotely and the log is send to the user afterwards. if (targetFolder == null || !targetFolder.exists()) { String modelName = getName(); targetFolder = getSpec().getProject().getFolder(modelName); targetFolder.create(true, true, monitor); } if (targetFolder != null && targetFolder.exists()) { // Always refresh the folder in case it has to override an existing // file that is out-of-sync with the Eclipse foundation layer. targetFolder.refreshLocal(IFolder.DEPTH_INFINITE, monitor); // Import MC.out IFile mcOutFile = targetFolder.getFile(TLAConstants.Files.MODEL_CHECK_OUTPUT_FILE); if (mcOutFile.exists()) { mcOutFile.delete(true, monitor); } mcOutFile.create(is, true, monitor); // create closes the InputStream is. // Import MC_TE.out by copying the MC.out file to MC_TE.out. // The reason why there are two identical files (MC.out and // MC_TE.out) has been lost in history. IFile mcTEOutfile = targetFolder.getFile(ModelHelper.TE_TRACE_SOURCE); if (mcTEOutfile.exists()) { mcTEOutfile.delete(true, monitor); } mcOutFile.copy(mcTEOutfile.getFullPath(), true, monitor); } }
Example 9
Source File: WebUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static void extractWAR(IFolder folder, File webappTemplateArchive) throws IOException, CoreException { ProjectUtils.createFolder(folder); ArchiveManipulator archiveManipulator = new ArchiveManipulator(); archiveManipulator.extract(webappTemplateArchive, folder.getLocation().toFile()); folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); }
Example 10
Source File: AbstractBuilderParticipantTest.java From n4js with Eclipse Public License 1.0 | 5 votes |
/***/ protected void replaceFileContentAndWaitForRefresh(IFolder folder, IFile file, String newContent, long newTimestamp) throws CoreException, IOException { File fileInFilesystem = file.getLocation().toFile(); FileWriter fileWriter = new FileWriter(fileInFilesystem); fileWriter.write(newContent); fileWriter.close(); // We need to update the time of the file since out-of-sync is detected by timestamp on (most) OS fileInFilesystem.setLastModified(newTimestamp * 1000); folder.refreshLocal(IResource.DEPTH_INFINITE, monitor()); waitForAutoBuild(); }
Example 11
Source File: EquinoxApplicationProcessor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void processLocal ( final IFolder output, final IProgressMonitor parentMonitor ) throws Exception { final IProgressMonitor monitor = new SubProgressMonitor ( parentMonitor, 13 ); // create context final OscarContext ctx = createContext (); // generate common content new SecurityProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new JdbcUserServiceModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventStoragePostgresModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventStorageJdbcModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventInjectorJdbcProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventInjectorPostgresProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new ConnectionProcessor ( this.app, ctx ).process (); new ExporterProcessor ( this.app, ctx ).process (); // generate based on processors final Collection<OscarProcessor> processors = createProcessors (); monitor.worked ( 1 ); // COUNT:1 { final SubProgressMonitor subMonitor = new SubProgressMonitor ( monitor, 1 ); // COUNT:1 subMonitor.beginTask ( "Process application modules", processors.size () ); for ( final OscarProcessor processor : processors ) { processor.process ( ctx, this.app, subMonitor ); subMonitor.worked ( 1 ); } subMonitor.done (); } // generate custom content processForContext ( ctx, output, monitor ); // write out oscar context final OscarWriter writer = new OscarWriter ( ctx.getData (), ctx.getIgnoreFields () ); monitor.worked ( 1 ); // COUNT:1 final IFile file = output.getFile ( "configuration.oscar" ); //$NON-NLS-1$ try ( FileOutputStream fos = new FileOutputStream ( file.getRawLocation ().toOSString () ) ) { writer.write ( fos ); } monitor.worked ( 1 ); // COUNT:1 final IFile jsonFile = output.getFile ( "data.json" ); //$NON-NLS-1$ try ( final FileOutputStream fos = new FileOutputStream ( jsonFile.getRawLocation ().toOSString () ) ) { OscarWriter.writeData ( ctx.getData (), fos ); } monitor.worked ( 1 ); // COUNT:1 // write out profile new P2ProfileProcessor ( this.app ).process ( output.getLocation ().toFile (), monitor ); monitor.worked ( 1 ); // COUNT:1 // refresh output.refreshLocal ( IResource.DEPTH_INFINITE, monitor ); monitor.done (); }
Example 12
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Creates a folder resource given the folder handle. * * @param folderHandle * the folder handle to create a folder resource for * @param monitor * the progress monitor to show visual progress with * @exception CoreException * if the operation fails * @exception OperationCanceledException * if the operation is canceled */ public static void createFolder( IFolder folderHandle, IProgressMonitor monitor ) throws CoreException { try { // Create the folder resource in the workspace // Update: Recursive to create any folders which do not exist // already if ( !folderHandle.exists( ) ) { IPath path = folderHandle.getFullPath( ); IWorkspaceRoot root = ResourcesPlugin.getWorkspace( ).getRoot( ); int numSegments = path.segmentCount( ); if ( numSegments > 2 && !root.getFolder( path.removeLastSegments( 1 ) ) .exists( ) ) { // If the direct parent of the path doesn't exist, try // to create the // necessary directories. for ( int i = numSegments - 2; i > 0; i-- ) { IFolder folder = root.getFolder( path.removeLastSegments( i ) ); if ( !folder.exists( ) ) { folder.create( false, true, monitor ); } } } folderHandle.create( false, true, monitor ); } } catch ( CoreException e ) { // If the folder already existed locally, just refresh to get // contents if ( e.getStatus( ).getCode( ) == IResourceStatus.PATH_OCCUPIED ) folderHandle.refreshLocal( IResource.DEPTH_INFINITE, new SubProgressMonitor( monitor, 500 ) ); else throw e; } if ( monitor.isCanceled( ) ) throw new OperationCanceledException( ); }
Example 13
Source File: CompPlugin.java From junion with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void doFinish(IJavaProject project) { if(project != null ) { try { ProjectData data = cache.get(project); if(data == null) { log("Unexpected error: project data is null"); Thread.dumpStack(); return; } String genFolder = data.properties.getProperty(GEN_FOLDER).trim(); String projectName = project.getProject().getName(); char SEP = IPath.SEPARATOR; String genFolderPathRelative = SEP+projectName+SEP+genFolder; data.paths.clear(); PerProjectInfo info = ((JavaProject)project).getPerProjectInfo(); IClasspathEntry raw[] = info.rawClasspath; if(raw != null) { for(IClasspathEntry entry : raw) { if(entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { String srcPath = entry.getPath().toString(); if(srcPath.equals(genFolderPathRelative)) { setPaths(entry, ALL_PATHS); } else { setPaths(entry, NONE_PATHS); } } } } IFolder file = project.getProject().getFolder(genFolder); file.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (Exception e) { e.printStackTrace(); } } }
Example 14
Source File: RedhatHandler.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override protected void handleProcess ( final IFolder nodeDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception { final File packageFolder = getPackageFolder ( nodeDir ); final String packageName = getPackageName (); final File tempDir = new File ( packageFolder, "src" ); final RedhatDeploymentContext context = new RedhatDeploymentContext ( tempDir, packageName ); setDeploymentContext ( context ); // process super super.handleProcess ( nodeDir, monitor, properties ); // handle self final Path outputDir = nodeDir.getLocation ().toFile ().toPath (); Files.createDirectories ( outputDir ); final String version = makeVersion ( this.deploy.getChanges () ); final String qualifier = makeRelease (); final String nodeName = this.applicationNode.getName () == null ? this.applicationNode.getHostName () : this.applicationNode.getName (); try ( RpmBuilder builder = new RpmBuilder ( packageName, version, qualifier, outputDir ) ) { final PackageInformation pinfo = builder.getInformation (); pinfo.setLicense ( this.deploy.getLicense () ); pinfo.setSummary ( String.format ( "Eclipse NeoSCADA Configuration for \"%s\"", nodeName ) ); pinfo.setDescription ( String.format ( "This is the configuration package for node \"%s\".", nodeName ) ); pinfo.setPackager ( String.format ( "%s <%s>", this.deploy.getMaintainer ().getName (), this.deploy.getMaintainer ().getEmail () ) ); pinfo.setGroup ( "Application/System" ); // create content final Map<String, String> replacements = new HashMap<> (); replacements.put ( "packageName", packageName ); //$NON-NLS-1$ replacements.put ( "authorName", this.deploy.getMaintainer ().getName () ); //$NON-NLS-1$ replacements.put ( "authorEmail", this.deploy.getMaintainer ().getEmail () ); //$NON-NLS-1$ replacements.put ( "nodeName", nodeName ); //$NON-NLS-1$ replacements.put ( "version", version ); //$NON-NLS-1$ replacements.put ( "qualifier", qualifier ); //$NON-NLS-1$ replacements.put ( "changeLog", makeChangeLog ( this.deploy.getChanges () ) ); //$NON-NLS-1$ createDrivers ( nodeDir, monitor, packageFolder, replacements ); createEquinox ( nodeDir.getLocation ().toFile (), packageFolder, replacements, monitor ); // create spec file - all content must be known final ScriptMaker sm = new ScriptMaker ( getStartupHandler () ); builder.setPreInstallationScript ( createStopApps () + context.getPreInstallationString () + sm.makePreInst () ); builder.setPostInstallationScript ( context.getPostInstallationString () + sm.makePostInst () + makeMultiScreenScript () + makeCreate ( this.deploy ) + createStartApps () ); builder.setPreRemoveScript ( createStopApps () + context.getPreRemovalString () + sm.makePreRem () ); builder.setPostRemoveScript ( context.getPostRemovalString () + sm.makePostRem () ); for ( final String dep : makeDependencies ( context.getDependencies () ) ) { builder.addRequirement ( dep, null ); } final BuilderContext ctx = builder.newContext (); for ( final Map.Entry<String, FileInformation> dir : new TreeMap<> ( context.getDirectories () ).entrySet () /* Sorted */ ) { ctx.addDirectory ( dir.getKey (), BuilderContext.simpleDirectoryProvider ().customize ( fi -> applyFileInformation ( fi, dir.getValue (), true ) ) ); } final Path base = tempDir.toPath (); Files.walkFileTree ( base, new SimpleFileVisitor<Path> () { @Override public FileVisitResult visitFile ( final Path file, final BasicFileAttributes attrs ) throws IOException { final Path localPath = Paths.get ( "/" ).resolve ( base.relativize ( file ) ).normalize (); final String targetName = localPath.toString ().replace ( File.separator, "/" ); final FileInformation i = context.getFiles ().get ( targetName ); ctx.addFile ( targetName, file, BuilderContext.simpleFileProvider ().customize ( fi -> applyFileInformation ( fi, i, true ) ) ); return FileVisitResult.CONTINUE; } } ); builder.build (); } nodeDir.refreshLocal ( IResource.DEPTH_INFINITE, monitor ); }
Example 15
Source File: Model.java From tlaplus with MIT License | 4 votes |
/** * Checks whether the checkpoint files exist for a given model * If doRefresh is set to true, this method will refresh the model directory, * and if a checkpoint folder is found, it will refresh the contents of that folder. * This means that the eclipse workspace representation of that directory will * synch with the file system. This is a long running job, so this method should not * be called within the running of another job unless the scheduling rule for * refreshing the model directory is included in the scheduling rule of the job which * is calling this method. This scheduling rule can be found by calling * * Note: Because the Toolbox deletes any existing checkpoint when running TLC, * there should be at most one checkpoint. Therefore, this method should return an array * of length 0 or 1. * * {@link IResourceRuleFactory#refreshRule(IResource)} * @param config * @param doRefresh whether the model directory's contents and any checkpoint * folders contents should be refreshed * @return the array of checkpoint directories, sorted from last to first */ public IResource[] getCheckpoints(boolean doRefresh) throws CoreException { // yy-MM-dd-HH-mm-ss Pattern pattern = Pattern.compile("[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}"); Vector<IResource> checkpoints = new Vector<IResource>(); IFolder directory = getTargetDirectory(); if (directory != null && directory.exists()) { // refreshing is necessary because TLC creates // the checkpoint folders, but they may not have // been incorporated into the toolbox workspace // yet // the depth is one to find any checkpoint folders if (doRefresh) { directory.refreshLocal(IResource.DEPTH_ONE, null); } IResource[] members = directory.members(); for (int i = 0; i < members.length; i++) { if (members[i].getType() == IResource.FOLDER) { Matcher matcher = pattern.matcher(members[i].getName()); if (matcher.matches()) { // if there is a checkpoint folder, it is necessary // to refresh its contents because they may not // be part of the workspace yet if (doRefresh) { members[i].refreshLocal(IResource.DEPTH_ONE, null); } if (((IFolder) members[i]).findMember(CHECKPOINT_QUEUE) != null && ((IFolder) members[i]).findMember(CHECKPOINT_VARS) != null && ((IFolder) members[i]).findMember(CHECKPOINT_STATES) != null) { checkpoints.add(members[i]); } } } } } IResource[] result = (IResource[]) checkpoints.toArray(new IResource[checkpoints.size()]); // sort the result Arrays.sort(result, new Comparator<IResource>() { public int compare(IResource arg0, IResource arg1) { return arg0.getName().compareTo(arg1.getName()); } }); return result; }
Example 16
Source File: DebianHandler.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override protected void handleProcess ( final IFolder nodeDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception { final File packageFolder = getPackageFolder ( nodeDir ); final String packageName = getPackageName (); final DebianDeploymentContext context = new DebianDeploymentContext ( packageName ); setDeploymentContext ( context ); // call super super.handleProcess ( nodeDir, monitor, properties ); // process self final String version = findVersion (); final BinaryPackageControlFile packageControlFile = new BinaryPackageControlFile (); packageControlFile.setPackage ( packageName ); packageControlFile.setArchitecture ( "all" ); //$NON-NLS-1$ packageControlFile.setVersion ( version ); packageControlFile.setPriority ( "required" ); //$NON-NLS-1$ packageControlFile.setSection ( "misc" ); //$NON-NLS-1$ packageControlFile.setMaintainer ( String.format ( "%s <%s>", this.deploy.getMaintainer ().getName (), this.deploy.getMaintainer ().getEmail () ) ); //$NON-NLS-1$ // packageControlFile.setDescription ( String.format ( "Configuration package for %s", Nodes.makeName ( this.applicationNode ) ), "This is an automatically generated configuration package" ); // FIXME: use multiline option again at some point, but has to be implemented in package drone first packageControlFile.setDescription ( String.format ( "Configuration package for %s", Nodes.makeName ( this.applicationNode ) ) + "\n\nThis is an automatically generated configuration package" ); packageControlFile.set ( BinaryPackageControlFile.Fields.CONFLICTS, "org.openscada.drivers.common, org.openscada" ); //$NON-NLS-1$ final Map<String, String> replacements = new HashMap<> (); replacements.put ( "packageName", packageName ); //$NON-NLS-1$ replacements.put ( "authorName", this.deploy.getMaintainer ().getName () ); //$NON-NLS-1$ replacements.put ( "authorEmail", this.deploy.getMaintainer ().getEmail () ); //$NON-NLS-1$ replacements.put ( "nodeName", this.applicationNode.getName () == null ? this.applicationNode.getHostName () : this.applicationNode.getName () ); //$NON-NLS-1$ replacements.put ( "stop.apps", createStopApps () ); //$NON-NLS-1$ replacements.put ( "start.apps", createStartApps () ); //$NON-NLS-1$ replacements.put ( "create.apps", makeCreate ( this.deploy ) ); //$NON-NLS-1$ replacements.put ( "multiuserScreen", this.deploy.isMultiUserScreen () ? "1" : "0" ); createDrivers ( nodeDir, monitor, packageFolder, replacements ); createEquinox ( nodeDir.getLocation ().toFile (), packageFolder, replacements, monitor ); try { // scoop up "src" files final Path src = new File ( packageFolder, "src" ).toPath (); //$NON-NLS-1$ if ( src.toFile ().isDirectory () ) { final ScoopFilesVisitor scoop = new ScoopFilesVisitor ( src, context, null ); scoop.getIgnorePrefix ().add ( CONTROL_SCRIPTS_DIR ); Files.walkFileTree ( src, scoop ); } packageControlFile.set ( BinaryPackageControlFile.Fields.PRE_DEPENDS, makePreDependencies ( Collections.<String> emptyList () ) ); packageControlFile.set ( BinaryPackageControlFile.Fields.DEPENDS, makeDependencies ( context.getDependencies () ) ); final File outputFile = new File ( nodeDir.getLocation ().toFile (), packageControlFile.makeFileName () ); outputFile.getParentFile ().mkdirs (); try ( DebianPackageWriter deb = new DebianPackageWriter ( new FileOutputStream ( outputFile ), packageControlFile ) ) { final ScriptMaker sm = new ScriptMaker ( getStartupHandler () ); replacements.put ( "postinst.scripts", context.getPostInstallationString () + NL + createUserScriptCallbacks ( packageFolder, "postinst" ) + sm.makePostInst () ); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put ( "preinst.scripts", context.getPreInstallationString () + NL + createUserScriptCallbacks ( packageFolder, "preinst" + sm.makePreInst () ) ); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put ( "prerm.scripts", context.getPreRemovalString () + NL + createUserScriptCallbacks ( packageFolder, "prerm" ) + sm.makePreRem () ); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put ( "postrm.scripts", context.getPostRemovalString () + NL + createUserScriptCallbacks ( packageFolder, "postrm" + sm.makePostRem () ) ); //$NON-NLS-1$ //$NON-NLS-2$ deb.setPostinstScript ( Contents.createContent ( CommonHandler.class.getResourceAsStream ( "templates/deb/postinst" ), replacements ) ); //$NON-NLS-1$ deb.setPostrmScript ( Contents.createContent ( CommonHandler.class.getResourceAsStream ( "templates/deb/postrm" ), replacements ) ); //$NON-NLS-1$ deb.setPrermScript ( Contents.createContent ( CommonHandler.class.getResourceAsStream ( "templates/deb/prerm" ), replacements ) ); //$NON-NLS-1$ deb.setPreinstScript ( Contents.createContent ( CommonHandler.class.getResourceAsStream ( "templates/deb/preinst" ), replacements ) ); //$NON-NLS-1$ context.scoopFiles ( deb ); } } finally { nodeDir.refreshLocal ( IResource.DEPTH_INFINITE, monitor ); } }
Example 17
Source File: BuilderParticipantPluginUITest.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * * 01. Class0 uses Class1 in require statement and in isa function * 02. Class1 is deleted * 05. Class0 should get error marker at require statement and at isa function * 06. recreate Class1 file * 07. Class0 should have no error markers * */ //@formatter:on @Test public void testSuperClassDeleted() throws Exception { logger.info("BuilderParticipantPluginUITest.testSuperClassDeleted"); // create project and test files final IProject project = createJSProject("testSuperClassDeleted"); IFolder folder = configureProjectWithXtext(project); IFolder moduleFolder = createFolder(folder, InheritanceTestFiles.inheritanceModule()); IFile parentFile = createTestFile(moduleFolder, "Parent", InheritanceTestFiles.Parent()); assertMarkers("Parent file should have no errors", parentFile, 0); IFile childFile = createTestFile(moduleFolder, "Child", InheritanceTestFiles.Child()); assertMarkers("Child file should have no errors", childFile, 0); // open editors of test files IWorkbenchPage page = EclipseUIUtils.getActivePage(); XtextEditor parentFileXtextEditor = openAndGetXtextEditor(parentFile, page); List<Resource.Diagnostic> errors = getEditorErrors(parentFileXtextEditor); assertEquals("Editor of parent should have no errors", 0, errors.size()); XtextEditor childFileXtextEditor = openAndGetXtextEditor(childFile, page); errors = getEditorErrors(childFileXtextEditor); assertEquals("Editor of child should have no errors", 0, errors.size()); parentFileXtextEditor.close(true); parentFile.delete(true, true, monitor()); moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor()); waitForAutoBuild(); waitForUpdateEditorJob(); assertFalse("Parent.n4js doesn't exist anymore", moduleFolder.getFile(new Path("Parent" + "." + N4JSGlobals.N4JS_FILE_EXTENSION)).exists()); errors = getEditorErrors(childFileXtextEditor); assertEquals("Editor of child should have error markers", Sets.newHashSet( "line 1: Cannot resolve plain module specifier (without project name as first segment): no matching module found.", "line 2: Couldn't resolve reference to Type 'ParentObjectLiteral'."), toSetOfStrings(errors)); IFile recreatedParentFile = createTestFile(moduleFolder, "Parent", InheritanceTestFiles.Parent()); assertMarkers("File1 should have no errors", recreatedParentFile, 0); waitForUpdateEditorJob(); errors = getEditorErrors(childFileXtextEditor); assertEquals("Editor of child should have no errors", 0, errors.size()); }
Example 18
Source File: RemoteImportTracesOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
private IResource downloadDirectoryTrace(IFileStore trace, IFolder traceFolder, IProgressMonitor monitor) throws CoreException, IOException, InterruptedException { IFileStore[] sources = trace.childStores(EFS.NONE, monitor); // Don't import just the metadata file if (sources.length > 1) { String traceName = trace.getName(); traceName = TmfTraceCoreUtils.validateName(traceName); IFolder folder = traceFolder.getFolder(traceName); String newName = fConflictHandler.checkAndHandleNameClash(folder.getFullPath(), monitor); if (newName == null) { return null; } folder = traceFolder.getFolder(newName); folder.create(true, true, null); SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length); subMonitor.beginTask(RemoteMessages.RemoteImportTracesOperation_DownloadTask, sources.length); for (IFileStore source : sources) { if (subMonitor.isCanceled()) { throw new InterruptedException(); } IPath destination = folder.getLocation().addTrailingSeparator().append(source.getName()); IFileInfo info = source.fetchInfo(); // TODO allow for downloading index directory and files if (!info.isDirectory()) { SubMonitor childMonitor = subMonitor.newChild(1); childMonitor.setTaskName(RemoteMessages.RemoteImportTracesOperation_DownloadTask + ' ' + trace.getName() + '/' + source.getName()); try (InputStream in = source.openInputStream(EFS.NONE, new NullProgressMonitor())) { copy(in, folder, destination, childMonitor, info.getLength()); } } } folder.refreshLocal(IResource.DEPTH_INFINITE, null); return folder; } return null; }
Example 19
Source File: BuilderParticipantPluginUITest.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * * 01. Class0 * 02. Class1.field0 * 03. Class0 -> Class1.field0 * 04. delete Class1 * 05. Class0 -> Class1 import and Class1.field0 should get error marker * 06. recreate Class1 file * 07. Class0 should have no error markers */ //@formatter:on @Test public void testReferenceDeleted() throws Exception { logger.info("BuilderParticipantPluginUITest.testReferenceDeleted"); // create project and test files final IProject project = createJSProject("testReferenceBrokenToOtherClassesMethod"); IFolder folder = configureProjectWithXtext(project); IFolder moduleFolder = createFolder(folder, TestFiles.moduleFolder()); IFile file2 = createTestFile(moduleFolder, "Class1", TestFiles.class1()); assertMarkers("File2 should have no errors", file2, 0); IFile file1 = createTestFile(moduleFolder, "Class0", TestFiles.class0()); assertMarkers("File1 should have no errors", file1, 0); // open editors of test files IWorkbenchPage page = EclipseUIUtils.getActivePage(); XtextEditor file1XtextEditor = openAndGetXtextEditor(file1, page); List<Resource.Diagnostic> errors = getEditorErrors(file1XtextEditor); assertEquals("Editor of Class0 should have no errors", 0, errors.size()); XtextEditor file2XtextEditor = openAndGetXtextEditor(file2, page); errors = getEditorErrors(file2XtextEditor); assertEquals("Editor of Class1 should have no errors", 0, errors.size()); file2.delete(true, monitor()); moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor()); waitForAutoBuild(); waitForUpdateEditorJob(); // check if editor 1 contain error markers errors = getEditorErrors(file1XtextEditor); // Consequential errors are omitted, so there is no error reported for unknown field, as the receiver is of // unknown type assertEquals("Content of editor 1 should be broken, because now linking to missing resource", Sets.newHashSet( "line 4: Cannot resolve plain module specifier (without project name as first segment): no matching module found.", "line 7: Couldn't resolve reference to Type 'Class1'."), toSetOfStrings(errors)); file2 = createTestFile(folder, "Class1", TestFiles.class1()); assertMarkers("File2 should have no errors", file2, 0); // editor 1 should not contain any error markers anymore file2 = createTestFile(moduleFolder, "Class1", TestFiles.class1()); waitForAutoBuild(); waitForUpdateEditorJob(); errors = getEditorErrors(file1XtextEditor); assertEquals( "Content of editor 1 should be valid again, as Class1 in editor has got the field with name 'field0' again", 0, errors.size()); }
Example 20
Source File: ResourceUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
/** * Deletes from the folder tree any file present in filesToRemoveList. * * @throws CoreException */ public static void deleteFiles(IFolder folder, List<String> filesToRemoveList) throws CoreException { deleteFiles(folder.getLocation().toFile(), filesToRemoveList); folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); }