Java 类org.eclipse.core.resources.IFolder 实例源码

项目:gw4e.project    文件:GW4EModelWizard.java   
@Override
public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    Object selected = selection.getFirstElement();
    if (selected instanceof TemplateProvider) {
        provider = (TemplateProvider) selected;
    }
    if (selected instanceof IFolder) {
        targetFolder    = ((IFolder) selected);
        project         = targetFolder.getProject();
    }
    if (selected instanceof InitialBuildPolicies) {
        policies    = ((InitialBuildPolicies) selected);
    }
    if (selected instanceof String) {
        filename    = ((String) selected);
    }       
    fExtraPage.validatePage();
}
项目:convertigo-eclipse    文件:ProjectLoadingJob.java   
protected void loadResource(TreeParent parentTreeObject, Object folderObject, IResource[] members) throws CoreException {
    ResourceFolderTreeObject resourceFolderTreeObject;
    if (folderObject instanceof String) resourceFolderTreeObject = new ResourceFolderTreeObject(viewer, (String) folderObject);
    else resourceFolderTreeObject = new ResourceFolderTreeObject(viewer, (IFolder) folderObject);
    parentTreeObject.addChild(resourceFolderTreeObject);

    ResourceTreeObject resourceTreeObject;
    for (int i = 0; i < members.length; i++) {
        IResource resource = members[i];
        String name = resource.getName();
        if (resource instanceof IFolder) {
            if (name.equals("_data")) continue;
            if (name.equals("_lib")) continue;
            if (name.equals("_private")) continue;
            loadResource(resourceFolderTreeObject, ((IFolder) resource), ((IFolder) resource).members());
        }
        else {
            if (name.equals(".project")) continue;
            if (name.endsWith(".etr")) continue;
            resourceTreeObject = new ResourceTreeObject(viewer, (IFile) resource);
            resourceFolderTreeObject.addChild(resourceTreeObject);
        }
    }
}
项目:Hydrograph    文件:BuildExpressionEditorDataSturcture.java   
private void loadClassesFromSettingsFolder() {
    Properties properties = new Properties();
    IFolder folder=getCurrentProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
    IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
    try {
        LOGGER.debug("Loading property file");
        if (file.getLocation().toFile().exists()) {
            FileInputStream inStream = new FileInputStream(file.getLocation().toString());
            properties.load(inStream);

            for(Object key:properties.keySet()){
                String packageName=StringUtils.remove((String)key,Constants.DOT+Constants.ASTERISK);
                if(StringUtils.isNotBlank(properties.getProperty((String)key)) && StringUtils.isNotBlank(packageName)){
                    loadUserDefinedClassesInClassRepo(properties.getProperty((String)key),packageName);
                }
            }
        }
    } catch (IOException |RuntimeException exception) {
        LOGGER.error("Exception occurred while loading jar files from projects setting folder",exception);
    }
}
项目:n4js    文件:BuilderParticipantPluginTest.java   
/**
 * <ol>
 * <li>create Class1 file with having Class1.field0 -> should have no errors</li>
 * <li>create Class0 file with referencing Class1.field0 -> should have no errors as Class1 already created</li>
 * </ol>
 */
//@formatter:on
@Test
public void testNoErrorMarkersWhenReferencedFileIsCreatedBeforeReferencingFile() throws Exception {
    // create project and test files
    final IProject project = createJSProject("testNoErrorMarkersWhenReferencedFileIsCreatedBeforeReferencingFile");
    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());

    // The value of the local variable dummy is not used
    assertMarkers("File1 should have no errors", file1, 1);
}
项目:Hydrograph    文件:CategoriesDialogTargetComposite.java   
public void loadPackagesFromPropertyFileSettingFolder() {
    Properties properties = new Properties();
    IFolder folder = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getFolder(
            PathConstant.PROJECT_RESOURCES_FOLDER);
    IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
    try {
        LOGGER.debug("Loading property file");
        targetList.removeAll();
        if (file.getLocation().toFile().exists()) {
            FileInputStream inStream = new FileInputStream(file.getLocation().toString());
            properties.load(inStream);
            for (Object key : properties.keySet()) {
                String jarFileName = StringUtils.trim(StringUtils.substringAfter((String) key, Constants.DASH));
                if (BuildExpressionEditorDataSturcture.INSTANCE.getIPackageFragment(jarFileName) != null) {
                    targetList.add((String) key+SWT.SPACE+Constants.DASH+SWT.SPACE+properties.getProperty((String)key));
                }
            }
        }
    } catch (IOException | RuntimeException exception) {
        LOGGER.error("Exception occurred while loading jar files from projects setting folder", exception);
    }

}
项目:n4js    文件:BuilderParticipantPluginTest.java   
/**
 *
 * 01. MyClassOne import MyVariableTwo, calls in chain
 * 01a. method of variable type (MyClassTwo),
 * 01b. method of type of this variable type method (MyRoleThree),
 * 01c. MyRoleThree method (typed with MyInterfaceFour)
 * 01d. finally a MyInterfaceFour's method
 * 02. Creating files in an order that there are initial error markers as required files are not created yet
 * 03. When all files have been created no file should have error markers
 *
 * @throws Exception when creating resources fails
 */
//@formatter:on
@Test
public void testMethodChainingWithCreatingFilesInReverseOrder() throws Exception {
    final IProject project = createJSProject("testMethodChainingWithCreatingFilesInReverseOrder");
    IFolder folder = configureProjectWithXtext(project);
    IFolder moduleFolder = createFolder(folder, MemberTestFiles.moduleFolder());

    IFile fileMyClassOne = createTestFile(moduleFolder, "MyClassOne", MemberTestFiles.myClassOne());
    IFile fileMyVariableTwo = createTestFile(moduleFolder, "MyVariableTwo", MemberTestFiles.myVariableTwo());
    IFile fileMyClassTwo = createTestFile(moduleFolder, "MyClassTwo", MemberTestFiles.myClassTwo());
    IFile fileRoleThree = createTestFile(moduleFolder, "MyRoleThree", MemberTestFiles.myRoleThree());
    IFile fileMyInterfaceFour = createTestFile(moduleFolder, "MyInterfaceFour", MemberTestFiles.myInterfaceFour());
    waitForAutoBuild();

    assertMarkers("File MyInterfaceFour should have no errors", fileMyInterfaceFour, 0);
    assertMarkers("File MyRoleThree should have no errors", fileRoleThree, 0);
    assertMarkers("File MyClassTwo should have no errors", fileMyClassTwo, 0);
    assertMarkers("File MyVariableTwo should have no errors", fileMyVariableTwo, 0);
    assertMarkers("File MyClassOne should have no errors", fileMyClassOne, 0);
}
项目:Tarski    文件:WizardTreeViewLabelProvider.java   
@Override
public Image getImage(final Object element) {
  if (element instanceof IProject) {
    if (((IProject) element).isOpen()) {
      return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
    } else {
      return PlatformUI.getWorkbench().getSharedImages()
          .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
    }
  } else if (element instanceof IFolder) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  } else if (element instanceof IFile) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
  } else if (element instanceof IMarker) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OPEN_MARKER);
  }

  return null;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param projectname
 * @param folder
 * @param filename
 * @return whether the file exists in the specified project & folder
 * @throws CoreException
 */
public static File getFile(String projectname, String folder, String pkg, String filename) throws CoreException {
    IProject project = getProject(projectname);
    IFolder destFolder = project.getFolder(new Path(folder));
    IFolder container = destFolder;
    if (pkg != null) {
        StringTokenizer st = new StringTokenizer(pkg, "/");
        while (st.hasMoreTokens()) {
            String dir = st.nextToken();
            IFolder f = container.getFolder(new Path(dir));
            if (!f.exists()) {
                f.create(true, true, null);
            }
            container = f;
        }
    }
    IFile file = container.getFile(new Path(filename));
    return file.getRawLocation().makeAbsolute().toFile();
}
项目:n4js    文件:ExternalPackagesPluginTest.java   
/**
 * Check if index is populated only with workspace project content when the external location with single project is
 * registered and workspace contains project with the same name. External library is registered before project is
 * created in the workspace.
 */
public void testWorkspaceProjectHidingExternalProject_after() throws Exception {

    IProject createJSProject = ProjectUtils.createJSProject("LibFoo");
    IFolder src = configureProjectWithXtext(createJSProject);
    IFile manifest = createJSProject.getProject().getFile("manifest.n4mf");
    assertMarkers("manifest of first project should have no errors", manifest, 0);

    createTestFile(src, "Foo", "console.log('hi')");
    createTestFile(src, "AAAA", "console.log('hi')");
    createTestFile(src, "BBB", "console.log('hi')");
    waitForAutoBuild();

    copyProjectsToLocation(externalLibrariesRoot, "LibFoo");
    setExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);

    Collection<String> expectedWorkspace = collectIndexableFiles(ResourcesPlugin.getWorkspace());

    assertResourceDescriptions(expectedWorkspace, BuilderUtil.getAllResourceDescriptions());

    removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);

}
项目:Hydrograph    文件:JobCopyParticipant.java   
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {

    copyToPath=getArguments().getDestination().toString();
    IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
    IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
    previousJobFiles=new ArrayList<>();
    for (IResource iResource : jobFolder.members()) {
        if (!(iResource instanceof IFolder)) {
            IFile iFile = (IFile) iResource;
             if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
                 previousJobFiles.add(iFile);
             }
        }
    }
    copiedFileList.add(modifiedResource);
    return null;
}
项目:Tarski    文件:CreatingAtomWizardLabelProvider.java   
@Override
public Image getImage(Object element) {
  if (element instanceof IProject) {
    if (((IProject) element).isOpen()) {
      return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
    } else {
      return PlatformUI.getWorkbench().getSharedImages()
          .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
    }
  } else if (element instanceof IFolder) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  } else if (element instanceof IFile) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
  } else if (element instanceof IMarker) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OPEN_MARKER);
  }

  return null;
}
项目:Hydrograph    文件:JobDeleteParticipant.java   
private boolean deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile(IProject iProject) {
    if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0),
            CustomMessages.ProjectSupport_JOBS)) {
        IFile propertyFileName = null;
        IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
        IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);

        if (jobsFolder != null) {
            jobIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.JOB_EXTENSION_FOR_IPATH));
        }
        if (propertiesFolder != null) {
            propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
                    .addFileExtension(Constants.PROPERTIES).toFile().getName());
        }
        String message = getErrorMessageIfUserDeleteXmlRelatedFiles(jobIFile, propertyFileName);
        showErrorMessage(jobIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
    } else {
        flag = true;
    }
    return flag;
}
项目:Equella    文件:NewJPFPluginWizardPageOne.java   
public void customizeManifest(Element rootElem, IProject project, IProgressMonitor monitor) throws CoreException
{
    if( equella.isLanguageStrings() )
    {
        Element runtime = rootElem.getChild("runtime");
        addLibrary(runtime, "resources", "resources/", "resources");
        JPFProject.getResourcesFolder(project).create(true, true, monitor);
    }
    Element requires = rootElem.getChild("requires");
    if( equella.isGuiceModule() )
    {
        addImport(requires, "com.tle.core.guice");
        addExtension(rootElem, "com.tle.core.guice", "module", "guiceModules");
    }
    if( equella.isLanguageStrings() )
    {
        addImport(requires, "com.tle.common.i18n");
        Element ext = addExtension(rootElem, "com.tle.common.i18n", "bundle", "strings");
        addParameter(ext, "file", "lang/i18n.properties");
        IFolder langFolder = JPFProject.getResourcesFolder(project).getFolder("lang");
        langFolder.create(true, true, monitor);
        langFolder.getFile("i18n.properties").create(new ByteArrayInputStream("# add your strings".getBytes()),
            true, monitor);
    }

}
项目:gw4e.project    文件:EditorHelper.java   
public static File getEditedFileFolder() {
    IWorkbenchPage page = null;
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
        if (windows[i] != null) {
            IWorkbenchWindow window = windows[i];
            page = windows[i].getActivePage();
            if (page != null)
                break;
        }
    }
    IEditorPart part = page.getActiveEditor();
    FileEditorInput editor = (FileEditorInput) part.getEditorInput();
    IFile file = editor.getFile();
    IFolder folder = (IFolder) file.getParent();
    File f = null;
    try {
        f = ResourceManager.toFile(folder.getFullPath());
    } catch (FileNotFoundException e) {
        ResourceManager.logException(e);
    }
    return f;
}
项目:gw4e.project    文件:MoveCompilationUnitChange.java   
private IFolder computeCompilationUnitDestination() throws CoreException {
    IPath pkg = null;
    switch (type) {
    case TEST_INTERFACE:
        IProject project = graphFile.getProject();
        boolean isMain = PreferenceManager.isInMainPath(getDestination().getFile(graphFile.getName()).getFullPath());
        pkg = ResourceManager.getPathWithinPackageFragment(getDestination().getFile("foo.txt")).removeLastSegments(1);
        IPath pathFolderForTestInterface = project.getFullPath()
                .append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), isMain))
                .append(pkg);
        ResourceManager.ensureFolderPath(pathFolderForTestInterface);
        return (IFolder) ResourceManager.getResource(pathFolderForTestInterface.toString());

    case TEST_IMPLEMENTATION:
        IPath path = PreferenceManager.getTargetFolderForGeneratedTests(getDestination().getFile(graphFile.getName()));
        pkg = ResourceManager.getPathWithinPackageFragment(getDestination().getFile("foo.txt")).removeLastSegments(1);
        IPath newpath = path.append(pkg);
        ResourceManager.ensureFolderPath(newpath);
        return (IFolder) ResourceManager.getResource(newpath.toString());
    }

    throw new IllegalStateException("Unknown type " + type);
}
项目:gw4e.project    文件:BuildPolicyManager.java   
public static IFile getBuildPoliciesForGraph(IFile file, boolean create)
        throws CoreException, FileNotFoundException {
    String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName());
    IFolder folder = (IFolder) file.getParent();
    IFile policiesFile = folder.getFile(name);
    if (policiesFile == null || !policiesFile.exists()) {
        if (create) {
            byte[] bytes = getDefaultBuildFileComment().getBytes();
            InputStream source = new ByteArrayInputStream(bytes);
            policiesFile.create(source, IResource.NONE, null);
            policiesFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        } else {
            throw new FileNotFoundException(folder.getFullPath().append(name).toString());
        }
    }
    return policiesFile;
}
项目:gw4e.project    文件:RenameGraphParticipant.java   
private boolean process(Object element, RenameArguments arguments) {
    if (element instanceof IFile) {
        originalFile = (IFile) element;
        newName =   arguments.getNewName();
        if (!acceptFile(originalFile))
            return false;
        RenameChange operation = new RenameGraphFileChange(originalFile.getProject(),originalFile.getFullPath(), newName);
        renameOperations.add(operation);
        return true;
    }
    if (element instanceof IFolder) {
        IFolder folder = (IFolder) element;
        MoveGraphParticipant mgp = new MoveGraphParticipant();
        moveOperations.addAll(mgp.create(folder,(folder.getParent().getFolder(new Path(arguments.getNewName())))));
        return moveOperations.size()>0;
    }
    return false;
}
项目:Tarski    文件:SigTypeLabelProvider.java   
@Override
public Image getImage(Object element) {
  if (element instanceof IProject) {
    if (((IProject) element).isOpen()) {
      return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
    } else {
      return PlatformUI.getWorkbench().getSharedImages()
          .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
    }
  } else if (element instanceof IFolder) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  } else if (element instanceof IFile) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
  } else if (element instanceof IMarker) {
    return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OPEN_MARKER);
  }

  return null;
}
项目:pgcodekeeper    文件:IPgObjectPage.java   
static IFolder createSchema(String name, boolean open, IProject project) throws CoreException {
    IFolder projectFolder = project.getFolder(DbObjType.SCHEMA.name());
    if (!projectFolder.exists()) {
        projectFolder.create(false, true, null);
    }
    IFolder schemaFolder = projectFolder.getFolder(name);
    if (!schemaFolder.exists()) {
        schemaFolder.create(false, true, null);
    }
    IFile file = projectFolder.getFile(name + POSTFIX);
    if (!file.exists()) {
        StringBuilder sb = new StringBuilder();
        sb.append(MessageFormat.format(PATTERN, DbObjType.SCHEMA, name));
        sb.append(MessageFormat.format(OWNER_TO, DbObjType.SCHEMA, name));
        file.create(new ByteArrayInputStream(sb.toString().getBytes()), false, null);
    }
    if (open) {
        openFileInEditor(file);
    }
    return schemaFolder;
}
项目:neoscada    文件:CommonHandler.java   
@Override
public void process ( final String phase, final IFolder nodeDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
{
    if ( phase != null && !"package".equals ( phase ) )
    {
        return;
    }

    if ( Boolean.parseBoolean ( properties.get ( "skipDeployment" ) ) )
    {
        return;
    }

    handleProcess ( nodeDir, monitor, properties );
    monitor.done ();
}
项目:gw4e.project    文件:TestConvertor.java   
private void findOldGraphFile(IProgressMonitor monitor) throws JavaModelException, FileNotFoundException {
    AnnotationParsing ap = JDTManager.findAnnotationParsingInModelAnnotation(testInterface, "file");
    this.model = ap.getValue("file");
    IPackageFragmentRoot[] roots = testInterface.getJavaProject().getPackageFragmentRoots();
    for (int j = 0; j < roots.length; j++) {
        IPackageFragmentRoot root = roots[j];
        IFolder resource = (IFolder) root.getResource();
        if (resource==null) throw new FileNotFoundException (model);
        IFile graphFile = resource.getFile(model);
        if (graphFile.exists()) {
            oldGraphFile = graphFile;
            break;
        }
    }
}
项目:n4js    文件:ProjectUtils.java   
/** Applies the Xtext nature to the project and creates (if necessary) and returns the source folder. */
public static IFolder configureProjectWithXtext(IProject project, String sourceFolder) throws CoreException {
    addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFolder folder = project.getProject().getFolder(sourceFolder);
    if (!folder.exists()) {
        folder.create(true, true, null);
    }
    return folder;
}
项目:n4js    文件:AbstractBuilderParticipantTest.java   
/***/
protected IFolder createFolder(IProject project, String path) throws CoreException {
    IFolder folder = project.getFolder(path);
    if (!folder.exists()) {
        createParentFolder(folder);
        folder.create(true, true, null);
    }
    return folder;
}
项目:gw4e.project    文件:TestConvertor.java   
private void setNewGraphFile(IProgressMonitor monitor) throws CoreException {
    String extension = oldGraphFile.getFileExtension();
    int pos  = oldGraphFile.getName().indexOf(extension);
    String name = oldGraphFile.getName().substring(0,pos);
    IPath path = oldGraphFile.getFullPath().removeLastSegments(1);
    IFolder f  =  (IFolder) ResourceManager.getResource(path.toString());
    newGraphFile = f.getFile(name + "json");
}
项目:n4js    文件:AbstractBuilderParticipantTest.java   
/***/
protected void replaceFileContentAndWaitForRefresh(IFolder folder, IFile file, String newContent)
        throws IOException, CoreException {
    File fileInFilesystem = file.getLocation().toFile();
    FileWriter fileWriter = new FileWriter(fileInFilesystem);
    fileWriter.write(newContent);
    fileWriter.close();
    folder.refreshLocal(IResource.DEPTH_INFINITE, monitor());
    waitForAutoBuild();
}
项目:visuflow-plugin    文件:JimpleBuilder.java   
protected void fullBuild(IProgressMonitor monitor) throws CoreException{
    Visuflow.getDefault().getLogger().info("Build Start");
    String targetFolder = "sootOutput";
    IJavaProject project = JavaCore.create(getProject());
    IResourceDelta delta = getDelta(project.getProject());
    if (delta == null || !delta.getAffectedChildren()[0].getProjectRelativePath().toString().equals(targetFolder)) {
        classpath = getSootCP(project);
        String location = GlobalSettings.get("Target_Path");
        IFolder folder = project.getProject().getFolder(targetFolder);

        // at this point, no resources have been created
        if (!folder.exists()) {
            // Changed to force because of bug id vis-119
            folder.create(IResource.FORCE, true, monitor);

        } else {
            for (IResource resource : folder.members()) {
                resource.delete(IResource.FORCE, monitor);
            }
        }
        classpath = location + classpath;
        String[] sootString = new String[] { "-cp", classpath, "-exclude", "javax", "-allow-phantom-refs", "-no-bodies-for-excluded", "-process-dir",
                location, "-src-prec", "only-class", "-w", "-output-format", "J", "-keep-line-number", "-output-dir",
                folder.getLocation().toOSString()/* , "tag.ln","on" */ };
        ICFGStructure icfg = new ICFGStructure();
        JimpleModelAnalysis analysis = new JimpleModelAnalysis();
        analysis.setSootString(sootString);
        List<VFClass> jimpleClasses = new ArrayList<>();
        try {
            analysis.createICFG(icfg, jimpleClasses);
            fillDataModel(icfg, jimpleClasses);
        } catch(Exception e) {
            logger.error("Couldn't execute analysis", e);
        }

        folder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    }
}
项目:gw4e.project    文件:ResourceManagerTest.java   
@Test
public void testEnsureFolderIProjectStringIProgressMonitor() throws Exception {
    IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
    ResourceManager.ensureFolder(project.getProject(), "src/test/main", new NullProgressMonitor());
    IFolder f = project.getProject().getFolder("src/test/main");
    assertTrue(f.exists());
}
项目:Hydrograph    文件:ResourceChangeUtil.java   
public static void addMembersToList(List<IResource> memberList, IFolder folder) {
    try {
        for(IResource resource: folder.members()) {
            if(resource instanceof IFile) {
                memberList.add(resource);
            }
            else {
                addMembersToList(memberList, (IFolder)resource);
            }
        }
    } catch (CoreException e) {
        logger.debug("Unable to add members to list " , e);
    }
}
项目:Hydrograph    文件:ValidateExpressionToolButton.java   
private static String getPropertyFilePath(IJavaProject project) {
    LOGGER.debug("Adding UserFunctions.propertis file URL to build-path");
    IFolder settingFolder=project.getProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
    if(settingFolder.exists()){
        IFile file=settingFolder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
        if(file.exists()){
            return file.getLocation().toString();
        }
    }
    return Constants.EMPTY_STRING;
}
项目:n4js    文件:EclipseBasedProjectModelSetup.java   
private void createArchive(String projectName) throws CoreException, IOException {
    IProject project = workspace.getProject(projectName);
    IFolder libFolder = project.getFolder(LIB_FOLDER_NAME);
    libFolder.create(false, true, null);

    IFile archiveFile = libFolder.getFile(host.archiveProjectId + ".nfar");
    ByteArrayOutputStream byteArrayOutputSteam = new ByteArrayOutputStream();
    final ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputSteam);
    zipOutputStream.putNextEntry(new ZipEntry("src/A.js"));
    zipOutputStream.putNextEntry(new ZipEntry("src/B.js"));
    zipOutputStream.putNextEntry(new ZipEntry("src/sub/B.js"));
    zipOutputStream.putNextEntry(new ZipEntry("src/sub/C.js"));
    zipOutputStream.putNextEntry(new ZipEntry("src/sub/leaf/D.js"));

    zipOutputStream.putNextEntry(new ZipEntry(IN4JSProject.N4MF_MANIFEST));
    // this will close the stream
    CharStreams.write("ProjectId: " + host.archiveProjectId + "\n" +
            "ProjectType: library\n" +
            "ProjectVersion: 0.0.1-SNAPSHOT\n" +
            "VendorId: org.eclipse.n4js\n" +
            "VendorName: \"Eclipse N4JS Project\"\n" +
            "Libraries { \"" + LIB_FOLDER_NAME + "\"\n }\n" +
            "Output: \"src-gen\"" +
            "Sources {\n" +
            "   source { " +
            "       \"src\"\n" +
            "   }\n" +
            "}\n", CharStreams.newWriterSupplier(new OutputSupplier<ZipOutputStream>() {
                @Override
                public ZipOutputStream getOutput() throws IOException {
                    return zipOutputStream;
                }
            }, Charsets.UTF_8));

    archiveFile.create(new ByteArrayInputStream(byteArrayOutputSteam.toByteArray()), false, null);

    host.setArchiveFileURI(URI.createPlatformResourceURI(archiveFile.getFullPath().toString(), true));
}
项目:gemoc-studio    文件:IFileUtils.java   
public static void writeInFile(IFile file, String contents, IProgressMonitor monitor) throws CoreException, IOException{
    InputStream stream =  new ByteArrayInputStream(contents.getBytes(("UTF-8")));
    if (file.exists()) {
        file.setContents(stream, true, true, monitor);
    } else {
        if(file.getParent() instanceof IFolder && !file.getParent().exists()){
            IFolderUtils.create((IFolder) file.getParent(), true, true, monitor);
        }
        file.create(stream, true, monitor);
    }
    stream.close();
}
项目:n4js    文件:ExternalProject.java   
@Override
public IFolder getFolder(String name) {
    final File folderCandidate = getFullPath().append(name).toFile();
    // Shortcut to avoid visiting members with infinite depth
    if (folderCandidate.isDirectory()) {
        return new ExternalFolder(this, this, folderCandidate);
    }

    IFolder resource = getResource(name, IFolder.class);
    if (resource != null)
        return resource;

    return new ExternalFolder(this, this, folderCandidate);
}
项目:n4js    文件:ModuleSpecifierSelectionDialog.java   
/**
 * Creates all non-existing segments of the given path.
 *
 * @param path
 *            The path to create
 * @param parent
 *            The container in which the path should be created in
 * @param monitor
 *            A progress monitor. May be {@code null}
 *
 * @return The folder specified by the path
 */
private IContainer createFolderPath(IPath path, IContainer parent, IProgressMonitor monitor) {
    IContainer activeContainer = parent;

    if (null != monitor) {
        monitor.beginTask("Creating folders", path.segmentCount());
    }

    for (String segment : path.segments()) {
        IFolder folderToCreate = activeContainer.getFolder(new Path(segment));
        try {
            if (!folderToCreate.exists()) {
                createFolder(segment, activeContainer, monitor);
            }
            if (null != monitor) {
                monitor.worked(1);
            }
            activeContainer = folderToCreate;
        } catch (CoreException e) {
            LOGGER.error("Failed to create module folders.", e);
            MessageDialog.open(MessageDialog.ERROR, getShell(),
                    FAILED_TO_CREATE_FOLDER_TITLE, String.format(FAILED_TO_CREATE_FOLDER_MESSAGE,
                            folderToCreate.getFullPath().toString(), e.getMessage()),
                    SWT.NONE);
            break;
        }
    }
    return activeContainer;
}
项目:n4js    文件:NfarStorageMapper.java   
@Override
public boolean isRejected(IFolder folder) {
    if (isLibraryFolder(folder)) {
        return false;
    }
    Optional<? extends IN4JSSourceContainer> sourceContainerOpt = eclipseCore.create(folder);
    return !sourceContainerOpt.isPresent();
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * Return the passed parameters (a file) as an IFolder
 * 
 * @param file
 * @return
 */
public static IFolder toIFolder(File file) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IPath location = Path.fromOSString(file.getAbsolutePath());
    IFile ifile = workspace.getRoot().getFileForLocation(location);
    return workspace.getRoot().getFolder(ifile.getFullPath());
}
项目:n4js    文件:N4JSEclipseCore.java   
@Override
public Optional<? extends IN4JSSourceContainer> create(IFolder eclipseFolder) {
    if (eclipseFolder == null) {
        return Optional.absent();
    }
    return model.getN4JSSourceContainer(eclipseFolder);
}
项目:n4js    文件:EclipseExternalLibraryWorkspace.java   
@Override
public URI findArtifactInFolder(URI folderLocation, String folderRelativePath) {
    ensureInitialized();
    final IResource folder = getResource(folderLocation);
    if (folder instanceof IFolder) {
        final IFile file = ((IFolder) folder).getFile(folderRelativePath);
        if (file instanceof IExternalResource) {
            final File externalResource = ((IExternalResource) file).getExternalResource();
            return URI.createFileURI(externalResource.getAbsolutePath());
        }
    }

    return null;
}
项目:Tarski    文件:MarkAllInWsLabelProvider.java   
@Override
public Image getImage(Object element) {
  if (element instanceof IProject)
    if (((IProject) element).isOpen())
      return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
    else
      return PlatformUI.getWorkbench().getSharedImages()
          .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
  else if (element instanceof IFolder)
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  else if (element instanceof IFile)
    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
  return null;
}
项目:gw4e.project    文件:ResourceManagerTest.java   
@Test
public void testCreateFolder() throws Exception {
    IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
    IFolder folder = project.getProject().getFolder("src/test");
    ResourceManager.createFolder(folder.getFullPath().toString(), "kawa");
    folder = project.getProject().getFolder("src/test/kawa");
    assertTrue(folder.exists());
}
项目:Hydrograph    文件:LaunchExpressionEditor.java   
private IPath createTemprarySourceFolder(){
    IPath tempSrcFolder=new Path(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
    IFolder  folder=BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getFolder(tempSrcFolder);
    try {
    if(!folder.exists()){
            folder.create(true, true,null);
        }
    } catch (CoreException e) {
        LOGGER.error("CoreException occurred while creating temporary source folder",e);
        return null;
    }
    LOGGER.debug("Created temporary build path at "+PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
    return folder.getFullPath();
}