1 package com.bull.eclipse.jonas.editors; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import org.eclipse.core.resources.IProject; 7 import org.eclipse.core.resources.IWorkspaceRoot; 8 import org.eclipse.core.resources.ResourcesPlugin; 9 10 public class ProjectListElement { 11 12 IProject project; 13 14 public ProjectListElement(IProject project) { 15 super(); 16 this.project = project; 17 } 18 19 public ProjectListElement(String name) { 20 super(); 21 } 23 24 25 26 27 public String toString() { 28 return getID(project); 29 } 30 31 public String getID() { 32 return getID(project); 33 } 34 35 static protected String getID(IProject project) { 36 return project.getName(); 37 } 38 39 static public List stringsToProjectsList(List projectIdList) { 40 IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); 41 IProject[] projects = root.getProjects(); 42 43 List selectedProjects = new ArrayList (); 44 for(int i=0; i<projects.length; i++) { 45 if(projectIdList.contains(getID(projects[i]))) { 46 selectedProjects.add(new ProjectListElement(projects[i])); 47 } 48 } 49 50 return selectedProjects; 51 } 52 53 56 public boolean equals(Object obj) { 57 if(obj instanceof ProjectListElement) 58 return this.getID().equals(((ProjectListElement)obj).getID()); 59 60 return false; 61 } 62 63 66 public int hashCode() { 67 return this.getID().hashCode(); 68 } 69 70 74 public IProject getProject() { 75 return project; 76 } 77 78 79 } 80 | Popular Tags |