コード例 #1
1
  private Map promptForOverwrite(List plugins, List locales) {
    Map overwrites = new HashMap();

    if (overwriteWithoutAsking) return overwrites;

    for (Iterator iter = plugins.iterator(); iter.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) iter.next();
      for (Iterator it = locales.iterator(); it.hasNext(); ) {
        Locale locale = (Locale) it.next();
        IProject project = getNLProject(plugin, locale);

        if (project.exists() && !overwrites.containsKey(project.getName())) {
          boolean overwrite =
              MessageDialog.openConfirm(
                  PDEPlugin.getActiveWorkbenchShell(),
                  PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteTitle,
                  NLS.bind(
                      PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteMessage,
                      pluginName(plugin, locale)));
          overwrites.put(project.getName(), overwrite ? OVERWRITE : null);
        }
      }
    }

    return overwrites;
  }
コード例 #2
0
  /**
   * Creates an NL fragment project along with the locale specific properties files.
   *
   * @throws CoreException
   * @throws IOException
   * @throws InvocationTargetException
   * @throws InterruptedException
   */
  private void internationalizePlugins(List plugins, List locales, Map overwrites)
      throws CoreException, IOException, InvocationTargetException, InterruptedException {

    Set created = new HashSet();

    for (Iterator it = plugins.iterator(); it.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) it.next();

      for (Iterator iter = locales.iterator(); iter.hasNext(); ) {
        Locale locale = (Locale) iter.next();

        IProject project = getNLProject(plugin, locale);
        if (created.contains(project)
            || overwriteWithoutAsking
            || !project.exists()
            || OVERWRITE == overwrites.get(project.getName())) {
          if (!created.contains(project) && project.exists()) {
            project.delete(true, getProgressMonitor());
          }

          if (!created.contains(project)) {
            createNLFragment(plugin, project, locale);
            created.add(project);
            project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor());
          }

          project
              .getFolder(RESOURCE_FOLDER_PARENT)
              .getFolder(locale.toString())
              .create(true, true, getProgressMonitor());
          createLocaleSpecificPropertiesFile(project, plugin, locale);
        }
      }
    }
  }
コード例 #3
0
  /**
   * Tries to delete an open project containing an irremovable file. Works only for Linux with
   * natives.
   */
  public void testDeleteOpenProjectLinux() {
    if (!(Platform.getOS().equals(Platform.OS_LINUX) && isReadOnlySupported())) return;

    IProject project = null;
    File projectRoot = null;
    IFolder folder = null;
    try {
      IWorkspace workspace = getWorkspace();
      project = workspace.getRoot().getProject(getUniqueString());
      folder = project.getFolder("a_folder");
      IFile file1 = folder.getFile("file1.txt");
      IFile file2 = project.getFile("file2.txt");

      ensureExistsInWorkspace(new IResource[] {file1, file2}, true);
      projectRoot = project.getLocation().toFile();

      // marks folder as read-only so its files cannot be deleted on Linux
      setReadOnly(folder, true);

      IFile projectFile = project.getFile(".project");
      assertTrue("1.2", projectFile.exists());
      assertTrue("1.3", projectFile.isSynchronized(IResource.DEPTH_INFINITE));

      try {
        project.delete(IResource.FORCE, getMonitor());
        fail("2.0 - should have failed");
      } catch (CoreException ce) {
        // success - a file couldn't be removed
      }
      assertTrue("2.1", project.exists());
      assertTrue("2.2", file1.exists());
      assertTrue("2.3", !file2.exists());
      assertTrue("2.5", folder.exists());
      assertTrue("2.6", projectFile.exists());
      assertTrue("2.7", project.isSynchronized(IResource.DEPTH_INFINITE));

      setReadOnly(folder, false);

      assertTrue("3.5", project.isSynchronized(IResource.DEPTH_INFINITE));
      try {
        project.delete(IResource.FORCE, getMonitor());
      } catch (CoreException ce) {
        ce.printStackTrace();
        fail("4.0", ce);
      }

      assertTrue("5.1", !project.exists());
      assertTrue("5.2", !file1.exists());
      assertTrue("5.3", file1.isSynchronized(IResource.DEPTH_INFINITE));
      assertTrue("5.4", project.isSynchronized(IResource.DEPTH_INFINITE));

      assertTrue("6.0", !projectRoot.exists());
    } finally {
      if (folder != null && folder.exists()) setReadOnly(folder, false);
      if (projectRoot != null) ensureDoesNotExistInFileSystem(projectRoot);
    }
  }
コード例 #4
0
  public IProject createNewProject(IPath newPath, String name, IProgressMonitor monitor) {
    IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    final IProjectDescription description = workspace.newProjectDescription(newProject.getName());
    description.setLocation(newPath);

    // run the new project creation operation
    try {
      boolean doit = false;

      if (!newProject.exists()) {
        // Defect 24558 - Text Importer may result in New Project being created with NO PATH, so
        // check if NULL
        // before
        if (newPath != null && OSPlatformUtil.isWindows()) {
          // check to see if path exists but case is different
          IPath path = new Path(FileUiUtils.INSTANCE.getExistingCaseVariantFileName(newPath));

          newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
          description.setLocation(path);
          doit = !newProject.exists();
        } else {
          doit = true;
        }

        if (doit) {
          createProject(description, newProject, monitor);
        }
      }
    } catch (CoreException e) {
      if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
        MessageDialog.openError(
            getShell(),
            ResourceMessages.NewProject_errorMessage,
            NLS.bind(ResourceMessages.NewProject_caseVariantExistsError, newProject.getName()));
      } else {
        ErrorDialog.openError(
            getShell(),
            ResourceMessages.NewProject_errorMessage,
            null, // no special message
            e.getStatus());
      }

      return null;
    } catch (Exception theException) {
      return null;
    }

    configureProject(newProject);

    return newProject;
  }
コード例 #5
0
ファイル: Core.java プロジェクト: HarinarayanKrishnan/ice
  /**
   * This private operation configures the project area for the Core. It uses the Eclipse Resources
   * Plugin and behaves differently based on the value of the osgi.instance.area system property.
   * <!-- end-UML-doc -->
   *
   * @return True if the setup operation was successful and false otherwise.
   */
  private boolean setupProjectLocation() {

    // Local Declarations
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = null;
    boolean status = true;
    String defaultProjectName = "itemDB";

    // Print some diagnostic information
    if (Platform.getInstanceLocation() != null) {
      logger.info(
          "ICore Message: Default workspace location is "
              + Platform.getInstanceLocation().getURL().toString());
    }
    // Create the project space for the *default* user. This will have to
    // change to something more efficient and better managed when multi-user
    // support is added.
    try {
      // Get the project handle
      project = workspaceRoot.getProject(defaultProjectName);
      // If the project does not exist, create it
      if (!project.exists()) {
        // Create the project description
        IProjectDescription desc =
            ResourcesPlugin.getWorkspace().newProjectDescription(defaultProjectName);
        // Create the project
        project.create(desc, null);
      }

      // Open the project if it is not already open. Note that this is not
      // an "else if" because it always needs to be checked.
      if (project.exists() && !project.isOpen()) {
        project.open(null);
        // Always refresh the project too in case users manipulated the
        // files.
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
      }
      // Add the project to the master table
      projectTable.put("defaultUser", project);
      itemDBProject = project;
    } catch (CoreException e) {
      // Catch for creating the project
      logger.error(getClass().getName() + " Exception!", e);
      status = false;
    }

    // Load any SerializedItems that are stored in the default directory
    if (status) {
      status = loadDefaultAreaItems();
    }
    return status;
  }
コード例 #6
0
 public static final void prepareWorkspace() throws CoreException {
   IWorkspace workspace = ResourcesPlugin.getWorkspace();
   IProject project = workspace.getRoot().getProject(JAVA_EXAMPLE_PROJECT);
   BlockingProgressMonitor monitor = new BlockingProgressMonitor();
   if (!project.exists()) {
     project.create(monitor);
     monitor.blockUntilDone();
   }
   assertThat(project.exists(), is(true));
   if (!project.isOpen()) {
     project.open(monitor);
     monitor.blockUntilDone();
   }
   workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
 }
コード例 #7
0
  private static LiferayDescriptorHelper[] getDescriptorHelpers(
      IProject project, Class<? extends IDescriptorOperation> type) {
    List<LiferayDescriptorHelper> retval = new ArrayList<LiferayDescriptorHelper>();

    project = CoreUtil.getLiferayProject(project);

    if (project == null || !project.exists()) {
      return null;
    }

    final LiferayDescriptorHelper[] allHelpers =
        LiferayDescriptorHelperReader.getInstance().getAllHelpers();

    for (LiferayDescriptorHelper helper : allHelpers) {
      helper.setProject(project);

      final IFile descriptorFile = helper.getDescriptorFile();

      if (descriptorFile != null && descriptorFile.exists()) {
        if (helper.getDescriptorOperation(type) != null) {
          retval.add(helper);
        }
      }
    }

    return retval.toArray(new LiferayDescriptorHelper[0]);
  }
コード例 #8
0
ファイル: LaunchUtils.java プロジェクト: NVIDIA/cdt-nsight
 /**
  * Verify the following things about the project: - is a valid project name given - does the
  * project exist - is the project open - is the project a C/C++ project
  */
 public static ICProject verifyCProject(ILaunchConfiguration configuration) throws CoreException {
   String name = getProjectName(configuration);
   if (name == null) {
     abort(
         LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"),
         null, //$NON-NLS-1$
         ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
     return null;
   }
   ICProject cproject = getCProject(configuration);
   if (cproject == null && name.length() > 0) {
     IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
     if (!proj.exists()) {
       abort(
           LaunchMessages.getFormattedString(
               "AbstractCLaunchDelegate.Project_NAME_does_not_exist", name),
           null, //$NON-NLS-1$
           ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
     } else if (!proj.isOpen()) {
       abort(
           LaunchMessages.getFormattedString(
               "AbstractCLaunchDelegate.Project_NAME_is_closed", name),
           null, //$NON-NLS-1$
           ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
     }
     abort(
         LaunchMessages.getString("AbstractCLaunchDelegate.Not_a_C_CPP_project"),
         null, //$NON-NLS-1$
         ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
   }
   return cproject;
 }
コード例 #9
0
  /**
   * Initializes the resource set using the repository content ; if the repository content is empty,
   * creates all the declared indexes.
   *
   * @throws CoreException it the resourceSet cannot be initialized
   */
  private void initializeResourceSet() throws CoreException {

    // We first get the project on which the repository is defined
    IProject project = workspaceConfig.getProject();
    if (!project.exists()) {
      project.create(null);
    }
    if (!project.isOpen()) {
      project.open(null);
    }
    IFolder folder = project.getFolder(workspaceConfig.getRepositoryRelativePath());
    // We created a WorkspaceRepositoryLoader using the indexPathList
    WorkspaceRepositoryLoader loader =
        new WorkspaceRepositoryLoader(this, this.getWorkspaceConfig().getIndexesPathList());
    // If the repository folder exists
    if (folder.exists()) {
      // We load the resourceSet
      loader.loadResourceSet();
    } else {
      // If the repository folder doesn't exist
      // We create it
      folder.create(IResource.NONE, true, null);
      // And use the RepositoryLoader to initialize the resource set with empty content
      loader.loadResourceSet();
    }
    isResourceSetLoaded = true;
  }
コード例 #10
0
  public void testExpandingResourcePath() throws Exception {
    URL dotProjectResource =
        getClass().getResource("/testData/projects/buckminster.test.build_a/.project"); // $NON-NLS
    assertNotNull("No resource found for .project file", dotProjectResource);
    dotProjectResource = FileLocator.toFileURL(dotProjectResource);
    assertNotNull("Unable to resolve .project resource into a file", dotProjectResource);
    File dotProjectFile = new File(dotProjectResource.toURI());

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject project = workspace.getRoot().getProject("buckminster.test.build_a");
    if (!project.isOpen()) {
      IProgressMonitor monitor = new NullProgressMonitor();
      if (!project.exists()) {
        IProjectDescription projectDesc =
            workspace.loadProjectDescription(Path.fromOSString(dotProjectFile.getAbsolutePath()));
        project.create(projectDesc, monitor);
      }
      project.open(monitor);
    }

    assertTrue("No open project was found after materialization", project.isOpen());
    ExpandingProperties<String> properties = new ExpandingProperties<String>();
    String projectPath = properties.get("workspace_loc:buckminster.test.build_a");
    assertNotNull("workspace_loc:<project name> doesn't resolve existing project", projectPath);
    assertEquals(
        "Unexpected physical project location",
        new File(projectPath),
        dotProjectFile.getParentFile());
  }
コード例 #11
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
  */
 public boolean select(Viewer viewer, Object parent, Object element) {
   // always let through types, we only care about configs
   if (element instanceof ILaunchConfigurationType) {
     return true;
   }
   if (element instanceof ILaunchConfiguration) {
     try {
       ILaunchConfiguration config = (ILaunchConfiguration) element;
       IResource[] resources = config.getMappedResources();
       // if it has no mapping, it might not have migration delegate, so let it pass
       if (resources == null) {
         return true;
       }
       for (int i = 0; i < resources.length; i++) {
         IProject project = resources[i].getProject();
         // we don't want overlap with the deleted projects filter, so we need to allow projects
         // that don't exist through
         if (project != null && (project.isOpen() || !project.exists())) {
           return true;
         }
       }
     } catch (CoreException e) {
     }
   }
   return false;
 }
コード例 #12
0
 /**
  * Replies if the project name is valid.
  *
  * <p>Copied from JDT.
  *
  * @return the validity state.
  */
 protected boolean isValidProjectName() {
   final String name = this.fProjText.getText();
   if (Strings.isNullOrEmpty(name)) {
     setErrorMessage(Messages.MainLaunchConfigurationTab_3);
     return false;
   }
   final IWorkspace workspace = ResourcesPlugin.getWorkspace();
   final IStatus status = workspace.validateName(name, IResource.PROJECT);
   if (status.isOK()) {
     final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
     if (!project.exists()) {
       setErrorMessage(MessageFormat.format(Messages.MainLaunchConfigurationTab_4, name));
       return false;
     }
     if (!project.isOpen()) {
       setErrorMessage(MessageFormat.format(Messages.MainLaunchConfigurationTab_5, name));
       return false;
     }
   } else {
     setErrorMessage(
         MessageFormat.format(Messages.MainLaunchConfigurationTab_6, status.getMessage()));
     return false;
   }
   return true;
 }
コード例 #13
0
 /**
  * Return the project with the given root directory, loading it if it is not already loaded. This
  * method assumes that there is no conflict with project names.
  *
  * @param projectRootDirectory the root directory of the project
  * @return the project with the given root directory
  * @throws CoreException
  * @throws FileNotFoundException if a required file or directory does not exist
  * @throws IOException if a required file cannot be accessed
  * @throws SAXException if the .project file is not valid
  */
 public static DartProject loadDartProject(final IPath projectRootDirectory)
     throws CoreException, FileNotFoundException, IOException, SAXException {
   final String projectName = getProjectName(projectRootDirectory);
   final IWorkspace workspace = ResourcesPlugin.getWorkspace();
   final IProject project = workspace.getRoot().getProject(projectName);
   if (!project.exists()) {
     ResourcesPlugin.getWorkspace()
         .run(
             new IWorkspaceRunnable() {
               @Override
               public void run(IProgressMonitor monitor) throws CoreException {
                 IProjectDescription description = workspace.newProjectDescription(projectName);
                 if (!workspace.getRoot().getLocation().isPrefixOf(projectRootDirectory)) {
                   description.setLocation(projectRootDirectory);
                 }
                 project.create(description, null);
                 project.open(null);
               }
             },
             null);
   }
   DartProject dartProject = DartCore.create(project);
   // waitForJobs();
   return dartProject;
 }
コード例 #14
0
  /**
   * This is run once before all of the tests
   *
   * @see junit.extensions.TestSetup#setUp()
   */
  public final void setUp() throws Exception {
    // setup properties
    String noninteractive = System.getProperty(WTP_AUTOTEST_NONINTERACTIVE);
    if (noninteractive != null) {
      fPreviousWTPAutoTestNonInteractivePropValue = noninteractive;
    } else {
      fPreviousWTPAutoTestNonInteractivePropValue = "false";
    }
    System.setProperty(WTP_AUTOTEST_NONINTERACTIVE, "true");

    // get project
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    fProject = root.getProject(this.fProjectName);

    // setup project if it is not yet setup
    if (fProject == null || !fProject.exists()) {
      fProject = ProjectUtil.createProject(this.fProjectName, null, null);
      ProjectUtil.copyBundleEntriesIntoWorkspace(
          TESTING_RESOURCES_DIR + IPath.SEPARATOR + this.fProjectName,
          IPath.SEPARATOR + this.fProjectName);
    }

    // run any additional test setup
    this.additionalSetUp();

    // give the workspace a second to settle before running tests
    Thread.sleep(1000);
    waitForIndexManager();
  }
コード例 #15
0
  private IStatus validateProject() {
    hostPageProject = null;

    String str = projectField.getText().trim();
    if (str.length() == 0) {
      return Util.newErrorStatus("Enter the project name");
    }

    IPath path = new Path(str);
    if (path.segmentCount() != 1) {
      return Util.newErrorStatus("Invalid project path");
    }

    IProject project = Util.getWorkspaceRoot().getProject(str);
    if (!project.exists()) {
      return Util.newErrorStatus("Project does not exist");
    }

    if (!project.isOpen()) {
      return Util.newErrorStatus("Project is not open");
    }

    if (!GWTNature.isGWTProject(project)) {
      return Util.newErrorStatus("Project is not a GWT project");
    }

    hostPageProject = project;
    return Status.OK_STATUS;
  }
コード例 #16
0
  public static IFile LinkFile(String path) {
    IWorkspace ws = ResourcesPlugin.getWorkspace();
    IProject project = ws.getRoot().getProject("tmp");
    if (!project.exists())
      try {
        project.create(null);
      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    if (!project.isOpen())
      try {
        project.open(null);
      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    IPath location = new Path(path);
    IFile file = project.getFile(location.lastSegment());

    try {
      file.delete(true, null);
    } catch (CoreException e1) {
    }

    try {
      file.createLink(location, IResource.NONE, null);
    } catch (CoreException e) {
    }
    return file;
  }
コード例 #17
0
  @BeforeClass
  public static void beforeTests() {

    // Local Declarations
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = null;
    String separator = System.getProperty("file.separator");
    String userDir =
        System.getProperty("user.home")
            + separator
            + "ICETests"
            + separator
            + "caebatTesterWorkspace";
    // Enable Debugging
    System.setProperty("DebugICE", "");

    // Setup the project
    try {
      // Get the project handle
      IPath projectPath = new Path(userDir + separator + ".project");
      // Create the project description
      IProjectDescription desc = ResourcesPlugin.getWorkspace().loadProjectDescription(projectPath);
      // Get the project handle and create it
      project = workspaceRoot.getProject(desc.getName());
      // Get the project handle and create it
      project = workspaceRoot.getProject(desc.getName());
      // Create the project if it doesn't exist
      if (!project.exists()) {
        project.create(desc, new NullProgressMonitor());
      }
      // Open the project if it is not already open
      if (project.exists() && !project.isOpen()) {
        project.open(new NullProgressMonitor());
      }
      // Refresh the workspace
      project.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
      // Catch exception for creating the project
      e.printStackTrace();
      fail();
    }

    // Set the global project reference.
    projectSpace = project;

    return;
  }
コード例 #18
0
 boolean exists() {
   IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   final String projectName = getProjectName();
   IPath wsPath = root.getLocation();
   IPath localProjectPath = wsPath.append(projectName);
   IProject project = root.getProject(projectName);
   return project.exists() || localProjectPath.toFile().exists();
 }
コード例 #19
0
 @BeforeClass
 public static void createProfileApplicationProject() throws CoreException {
   IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
   IProject project = workspaceRoot.getProject(TRACING_PA_PROJECT);
   if (!project.exists()) {
     project.create(null);
     project.open(null);
   }
 }
コード例 #20
0
 /**
  * Check project.
  *
  * @param project the project
  * @return true, if successful
  */
 private static boolean checkProject(IProject project) {
   boolean result = true;
   if (project != null) {
     result = result && project.exists();
   } else {
     result = false;
   }
   return result;
 }
コード例 #21
0
 protected IProject getNamedTestProject(String name) throws CoreException {
   IProject target = getWorkspace().getRoot().getProject(name);
   if (!target.exists()) {
     target.create(null);
     target.open(null);
   }
   assertExistsInFileSystem(target);
   return target;
 }
コード例 #22
0
 /** @throws java.lang.Exception */
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   final IProject project = root.getProject("TestEcoreHelperProjectResources");
   // create resources to register and unregister
   if (!project.exists()) {
     installResourcesProject();
   }
 }
コード例 #23
0
ファイル: ToscaFileService.java プロジェクト: CELAR/c-Eclipse
  public static IFile getDataFileForInput(final IEditorInput input) {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    if (input instanceof ToscaDiagramEditorInput) {
      final ToscaDiagramEditorInput tdei = (ToscaDiagramEditorInput) input;

      return tdei.getToscaFile();
    } else if (input instanceof DiagramEditorInput) {
      final DiagramEditorInput dei = (DiagramEditorInput) input;

      IPath path = new Path(dei.getUri().trimFragment().toPlatformString(true));

      return recreateDataFile(path);
    } else if (input instanceof FileEditorInput) {
      final FileEditorInput fei = (FileEditorInput) input;

      return fei.getFile();
    } else if (input instanceof IURIEditorInput) {
      // opened externally to Eclipse
      final IURIEditorInput uei = (IURIEditorInput) input;
      final java.net.URI uri = uei.getURI();
      final String path = uri.getPath();

      try {
        final IProject importProject = root.getProject("import"); // $NON-NLS-1$
        if (!importProject.exists()) {
          importProject.create(null);
        }

        importProject.open(null);

        final InputStream is = new FileInputStream(path);

        final String fileName;
        if (path.contains("/")) { // $NON-NLS-1$
          fileName = path.substring(path.lastIndexOf("/") + 1); // $NON-NLS-1$
        } else {
          fileName = path.substring(path.lastIndexOf("\\") + 1); // $NON-NLS-1$
        }

        IFile importFile = importProject.getFile(fileName);
        if (importFile.exists()) {
          importFile.delete(true, null);
        }

        importFile.create(is, true, null);

        return importProject.getFile(fileName);
      } catch (CoreException exception) {
        exception.printStackTrace();
      } catch (FileNotFoundException exception) {
        exception.printStackTrace();
      }
    }

    return null;
  }
コード例 #24
0
ファイル: RunTestView.java プロジェクト: JinxingLi/idecore
  /**
   * Get a ForceProject from an IProject.
   *
   * @param project
   * @return ForceProject
   */
  public ForceProject materializeForceProject(IProject project) {
    if (Utils.isEmpty(project) || !project.exists()) return null;

    ForceProject forceProject =
        ContainerDelegate.getInstance()
            .getServiceLocator()
            .getProjectService()
            .getForceProject(project);
    return forceProject;
  }
コード例 #25
0
  @Override
  public List<Object> getChildren() {
    List<Object> out = new ArrayList<Object>();

    IProject extractedProject = alternative.getExtractedProject();
    if (extractedProject == null || !extractedProject.exists()) return out;

    out.add(alternative.getExtractedProject());
    return out;
  }
コード例 #26
0
  String findUnsusedProjectName(IWorkspace workspace) {
    String projectName = "Album " + (++counter);
    IProject project = workspace.getRoot().getProject(projectName);

    while (project.exists()) {
      projectName = "Album " + (++counter);
      project = workspace.getRoot().getProject(projectName);
    }
    return projectName;
  }
コード例 #27
0
  private Preferences getProjectNode(ICProjectDescription projDes) {
    if (projDes == null) return null;
    IProject project = projDes.getProject();
    if (!project.exists()) return null;

    Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
    if (prefNode == null) return null;

    return prefNode.node(NODENAME);
  }
コード例 #28
0
 /** Creates a pydev_unit_test_project to be used in the tests */
 protected IProject createProject(IProgressMonitor monitor, String projectName)
     throws CoreException {
   IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
   if (project.exists()) {
     project.delete(true, monitor);
   }
   project.create(monitor);
   project.open(monitor);
   return project;
 }
コード例 #29
0
ファイル: ResourceHelper.java プロジェクト: NVIDIA/cdt-nsight
  /**
   * Create a plain Eclipse project.
   *
   * @param projectName
   * @return the project handle
   * @throws CoreException if project could not be created
   */
  public static IProject createProject(String projectName) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(projectName);
    if (!project.exists()) project.create(NULL_MONITOR);
    else project.refreshLocal(IResource.DEPTH_INFINITE, null);

    if (!project.isOpen()) project.open(NULL_MONITOR);

    resourcesCreated.add(project);
    return project;
  }
コード例 #30
0
 public IProject createExternalSourceArchivesProject(IProgressMonitor monitor)
     throws CoreException {
   IProject project = getExternalSourceArchivesProject();
   if (!project.isAccessible()) {
     if (!project.exists()) {
       createExternalSourceArchivesProject(project, monitor);
     }
     openExternalSourceArchivesProject(project, monitor);
   }
   return project;
 }