Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IProject


  public static WGADesign fromSelection(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection structSelection = (IStructuredSelection) selection;
      Object selectedElement = structSelection.getFirstElement();
      if (selectedElement instanceof IProject) {
        IProject project = (IProject) selectedElement;
        try {
          return (WGADesign) project.getNature(WGADesignerPlugin.NATURE_WGA_DESIGN);
        } catch (Exception e) {
        }
      }
    }
    return null;
View Full Code Here


  public static WGARuntime fromSelection(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection structSelection = (IStructuredSelection) selection;
      Object selectedElement = structSelection.getFirstElement();
      IProject project = null;
      if (selectedElement instanceof IProject) {
        project = (IProject) selectedElement;
      } else if (selectedElement instanceof IResource) {
        project = ((IResource) selectedElement).getProject();
      }

      try {
        if (project != null && project.hasNature(WGADesignerPlugin.NATURE_WGA_RUNTIME)) {
          return (WGARuntime) project.getNature(WGADesignerPlugin.NATURE_WGA_RUNTIME);
        }
      } catch (Exception e) {
      }

    }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {   
    IProject project = getProject();
    if (project != null && project.isAccessible()) {
      IMarker[] markers = project.findMarkers(ResourceIDs.MARKER_TML_REFERENCES, false, IResource.DEPTH_INFINITE);
      for (IMarker marker : markers) {
        if (marker.getResource() != null && marker.getResource() instanceof IFile) {
          TMLFileValidator.validateTMLFile((IFile)marker.getResource());
        }
      }
View Full Code Here

      throw new IllegalArgumentException("Wizard with id '" + id + "' not found.");
    }
  } 
 
   public static void addBuilder(IProject project, String id) throws CoreException {
       final IProject fProject = project;
       final String fId = id;
       IWorkspaceRunnable operation = new IWorkspaceRunnable() {
          public void run(IProgressMonitor monitor) throws CoreException {                       
            if (fProject.isAccessible()) {
              ResourceAttributes attribs = fProject.getResourceAttributes();
              if (attribs != null && attribs.isReadOnly()) {
                attribs.setReadOnly(false);
                fProject.setResourceAttributes(attribs);
              }
             
              IProjectDescription desc = fProject.getDescription();
              ICommand[] commands = desc.getBuildSpec();           
              for (int i = 0; i < commands.length; ++i) {
                 if (commands[i].getBuilderName().equals(fId))
                    return;
              }
              //add builder to project
              ICommand command = desc.newCommand();
              command.setBuilderName(fId);
              ICommand[] nc = new ICommand[commands.length + 1];
              // Add it after all other builders.
              System.arraycopy(commands, 0, nc, 0, commands.length);
              nc[commands.length] = command;
              desc.setBuildSpec(nc);
              fProject.setDescription(desc, null);
             
            }
          }
       };
       ResourcesPlugin.getWorkspace().run(operation, null);
View Full Code Here

       };
       ResourcesPlugin.getWorkspace().run(operation, null);
     }
  
   public static void removeBuilder(IProject project, String id) throws CoreException {
       final IProject fProject = project;
       final String fId = id;
       IWorkspaceRunnable operation = new IWorkspaceRunnable() {
          public void run(IProgressMonitor monitor) throws CoreException {                       
            if (fProject.isAccessible()) {
              ResourceAttributes attribs = fProject.getResourceAttributes();
              if (attribs != null && attribs.isReadOnly()) {
                attribs.setReadOnly(false);
                fProject.setResourceAttributes(attribs);
              }
              IProjectDescription desc = fProject.getDescription();
              ICommand[] commands = desc.getBuildSpec();
              List<ICommand> newCommands = new ArrayList<ICommand>();
              for (int i = 0; i < commands.length; ++i) {                 
                 if (!commands[i].getBuilderName().equals(fId)) {
                   newCommands.add(commands[i]);
                 }
              }
              desc.setBuildSpec(newCommands.toArray(new ICommand[0]));
              fProject.setDescription(desc, null);             
            }
          }
       };
       ResourcesPlugin.getWorkspace().run(operation, null);
     }
View Full Code Here

 
 
  @SuppressWarnings("unchecked")
  @Override
  protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {   
    IProject project = getProject();
    if (project != null && project.isAccessible()) {
      IMarker[] tmlmarkers = project.findMarkers(ResourceIDs.MARKER_TML_REFERENCES, false, IResource.DEPTH_INFINITE);
      for (IMarker marker : tmlmarkers) {
        if (marker.getResource() != null && marker.getResource() instanceof IFile) {
          TMLFileValidator.validateTMLFile((IFile)marker.getResource());
        }
      } 
      project.accept(new IResourceVisitor() {
       
        public boolean visit(IResource resource) throws CoreException {         
          if(resource instanceof IContainer){   
            WGADesignResourceValidator.validate((IContainer)resource);
            return true;
View Full Code Here

    }

  }

  public Set<String> getMediumKeys(IFile file) {
    IProject project = file.getProject();
    Set<String> resources = new HashSet<String>();
    IContainer design = new WGADesignStructureHelper(file).getDesignRoot();
    String expression = "SELECT distinct Medium FROM references WHERE Project = ? AND Path Like ?";
   
    PreparedStatement st = null;
    ResultSet rs = null;
    try {
      st = _conn.prepareStatement(expression);
      st.setString(1, project.getName());
      st.setString(2, "designs/" + design.getName() + "/tml/%");

      rs = st.executeQuery();

      while (rs.next()) {
        if (!rs.getString("Medium").equals("") && !rs.getString("Medium").startsWith(".")) {
          resources.add(rs.getString("Medium"));
        }

      }
    } catch (SQLException e) {
      Plugin.getDefault().logError("Unable to lookup medium keys for project '" + project.getName() + "' and designRoot '" + design.getLocation().toString() + "'.", e);
    } finally {
      cleanupSQLResources(st, rs);
    }
    return resources;
  }
View Full Code Here

    return resources;
  }

  public Set<String> getScriptPaths(IContainer designRoot, String scriptType) {
    Set<String> resources = new HashSet<String>();
    IProject project = designRoot.getProject();
    PreparedStatement st = null;
    ResultSet rs = null;
    try {     
      String expression = "SELECT Path, File FROM references WHERE Project = ? AND FileType = ? AND Path Like ?";
      st = _conn.prepareStatement(expression);
      st.setString(1, project.getName());
      st.setString(2, scriptType);
     
     
      designRoot.getProjectRelativePath().append("scripts").append(scriptType);
     
      st.setString(3, designRoot.getProjectRelativePath().append("scripts").append(scriptType).toString() + "%");
 
      rs = st.executeQuery();
 
      while (rs.next()) {
        String resource = rs.getString("Path");
        if (!resource.endsWith("/")) {
          resource += "/";
        }
        resource += rs.getString("File");
        resources.add(resource);
      }
    } catch (SQLException e) {
      Plugin.getDefault().logError("Unable to lookup script paths for project '" + project.getName() + "' and designRoot '" + designRoot.getLocation().toString() + "'.", e);
    } finally {
      cleanupSQLResources(st, rs);
    }
    return resources;
  }
View Full Code Here

      if (delta != null) {
        try {
          delta.accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
              if (delta.getResource() instanceof IProject) {
                IProject project = (IProject) delta.getResource();
                if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
                  _projectsAddedOrChanged.add(project);
                }
              }
              return true;
View Full Code Here

  }

  public static Map<String, WGARuntime> getAllRuntimes() {

    Map<String, WGARuntime> allWGARuntimes = new HashMap<String, WGARuntime>();
    IProject tmp[] = null;
    tmp = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < tmp.length; i++) {
      try {
        if (tmp[i].isAccessible() && tmp[i].hasNature(NATURE_WGA_RUNTIME)) {
          allWGARuntimes.put(tmp[i].getName(), (WGARuntime) tmp[i].getNature(NATURE_WGA_RUNTIME));
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IProject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.