Lines 31-37
Link Here
|
31 |
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; |
31 |
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; |
32 |
import org.netbeans.modules.java.j2seproject.ui.customizer.VisualClassPathItem; |
32 |
import org.netbeans.modules.java.j2seproject.ui.customizer.VisualClassPathItem; |
33 |
import org.netbeans.modules.java.j2seproject.UpdateHelper; |
33 |
import org.netbeans.modules.java.j2seproject.UpdateHelper; |
34 |
import org.netbeans.modules.java.project.ProjectClassPathExtender; |
34 |
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender; |
35 |
|
35 |
|
36 |
|
36 |
|
37 |
|
37 |
|
Lines 51-62
Link Here
|
51 |
this.refHelper = refHelper; |
51 |
this.refHelper = refHelper; |
52 |
} |
52 |
} |
53 |
|
53 |
|
54 |
public boolean addLibrary(final Library library) throws IOException { |
54 |
public boolean addLibrary(final Library[] libraries) throws IOException { |
55 |
return addLibrary(CP_CLASS_PATH, library); |
55 |
return addLibrary(CP_CLASS_PATH, libraries); |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
public boolean addLibrary(final String classPathId, final Library library) throws IOException { |
58 |
public boolean addLibrary(final String classPathId, final Library[] libraries) throws IOException { |
59 |
assert library != null : "Parameter can not be null"; //NOI18N |
59 |
assert libraries != null : "Parameter can not be null"; //NOI18N |
60 |
try { |
60 |
try { |
61 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
61 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
62 |
new Mutex.ExceptionAction () { |
62 |
new Mutex.ExceptionAction () { |
Lines 65-73
Link Here
|
65 |
String raw = props.getProperty(classPathId); |
65 |
String raw = props.getProperty(classPathId); |
66 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
66 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
67 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
67 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
68 |
VisualClassPathItem item = VisualClassPathItem.create (library); |
68 |
boolean changed = false; |
69 |
if (!resources.contains(item)) { |
69 |
for (int i=0; i<libraries.length; i++) { |
70 |
resources.add (item); |
70 |
assert libraries[i] != null : "Parameter can't contain null"; //NOI18N |
|
|
71 |
VisualClassPathItem item = VisualClassPathItem.create (libraries[i]); |
72 |
if (!resources.contains(item)) { |
73 |
resources.add (item); |
74 |
changed = true; |
75 |
} |
76 |
} |
77 |
if (changed) { |
71 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
78 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
72 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //PathParser may change the EditableProperties |
79 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //PathParser may change the EditableProperties |
73 |
String[] items = PropertyUtils.tokenizePath(raw); |
80 |
String[] items = PropertyUtils.tokenizePath(raw); |
Lines 78-84
Link Here
|
78 |
helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); |
85 |
helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); |
79 |
ProjectManager.getDefault().saveProject(project); |
86 |
ProjectManager.getDefault().saveProject(project); |
80 |
return Boolean.TRUE; |
87 |
return Boolean.TRUE; |
81 |
} |
88 |
} |
82 |
return Boolean.FALSE; |
89 |
return Boolean.FALSE; |
83 |
} |
90 |
} |
84 |
} |
91 |
} |
Lines 94-105
Link Here
|
94 |
} |
101 |
} |
95 |
} |
102 |
} |
96 |
|
103 |
|
97 |
public boolean addArchiveFile(final FileObject archiveFile) throws IOException { |
104 |
public boolean addArchiveFile(final FileObject[] archiveFiles) throws IOException { |
98 |
return addArchiveFile(CP_CLASS_PATH,archiveFile); |
105 |
return addArchiveFile(CP_CLASS_PATH,archiveFiles); |
99 |
} |
106 |
} |
100 |
|
107 |
|
101 |
public boolean addArchiveFile(final String classPathId, final FileObject archiveFile) throws IOException { |
108 |
public boolean addArchiveFile(final String classPathId, final FileObject[] archiveFiles) throws IOException { |
102 |
assert archiveFile != null : "Parameter can not be null"; //NOI18N |
109 |
assert archiveFiles != null : "Parameter can not be null"; //NOI18N |
103 |
try { |
110 |
try { |
104 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
111 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
105 |
new Mutex.ExceptionAction () { |
112 |
new Mutex.ExceptionAction () { |
Lines 108-120
Link Here
|
108 |
String raw = props.getProperty(classPathId); |
115 |
String raw = props.getProperty(classPathId); |
109 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
116 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
110 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
117 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
111 |
File f = FileUtil.toFile (archiveFile); |
118 |
boolean changed = false; |
112 |
if (f == null ) { |
119 |
for (int i=0; i< archiveFiles.length; i++) { |
113 |
throw new IllegalArgumentException ("The file must exist on disk"); //NOI18N |
120 |
assert archiveFiles[i] != null : "Parameter can't contain null"; //NOI18N |
|
|
121 |
File f = FileUtil.toFile (archiveFiles[i]); |
122 |
if (f == null ) { |
123 |
throw new IllegalArgumentException ("The file must exist on disk"); //NOI18N |
124 |
} |
125 |
VisualClassPathItem item = VisualClassPathItem.create (f); |
126 |
if (!resources.contains(item)) { |
127 |
resources.add (item); |
128 |
changed = true; |
129 |
} |
114 |
} |
130 |
} |
115 |
VisualClassPathItem item = VisualClassPathItem.create (f); |
131 |
if (changed) { |
116 |
if (!resources.contains(item)) { |
|
|
117 |
resources.add (item); |
118 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
132 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
119 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //PathParser may change the EditableProperties |
133 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //PathParser may change the EditableProperties |
120 |
String[] items = PropertyUtils.tokenizePath(raw); |
134 |
String[] items = PropertyUtils.tokenizePath(raw); |
Lines 141-152
Link Here
|
141 |
} |
155 |
} |
142 |
} |
156 |
} |
143 |
|
157 |
|
144 |
public boolean addAntArtifact(final AntArtifact artifact) throws IOException { |
158 |
public boolean addAntArtifact(final AntArtifact[] artifacts) throws IOException { |
145 |
return addAntArtifact(CP_CLASS_PATH,artifact); |
159 |
return addAntArtifact(CP_CLASS_PATH,artifacts); |
146 |
} |
160 |
} |
147 |
|
161 |
|
148 |
public boolean addAntArtifact(final String classPathId, final AntArtifact artifact) throws IOException { |
162 |
public boolean addAntArtifact(final String classPathId, final AntArtifact[] artifacts) throws IOException { |
149 |
assert artifact != null : "Parameter can not be null"; //NOI18N |
163 |
assert artifacts != null : "Parameter can not be null"; //NOI18N |
150 |
try { |
164 |
try { |
151 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
165 |
return ((Boolean)ProjectManager.mutex().writeAccess( |
152 |
new Mutex.ExceptionAction () { |
166 |
new Mutex.ExceptionAction () { |
Lines 155-163
Link Here
|
155 |
String raw = props.getProperty (classPathId); |
169 |
String raw = props.getProperty (classPathId); |
156 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
170 |
J2SEProjectProperties.PathParser parser = new J2SEProjectProperties.PathParser (); |
157 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
171 |
List resources = (List) parser.decode(raw, project, helper.getAntProjectHelper(), eval, refHelper); |
158 |
VisualClassPathItem item = VisualClassPathItem.create (artifact); |
172 |
boolean changed = false; |
159 |
if (!resources.contains(item)) { |
173 |
for (int i=0; i<artifacts.length; i++) { |
160 |
resources.add (item); |
174 |
assert artifacts[i] != null : "Parameter can not be null"; //NOI18N |
|
|
175 |
VisualClassPathItem item = VisualClassPathItem.create (artifacts[i]); |
176 |
if (!resources.contains(item)) { |
177 |
resources.add (item); |
178 |
changed = true; |
179 |
} |
180 |
} |
181 |
if (changed) { |
161 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
182 |
raw = parser.encode (resources, project, helper.getAntProjectHelper(), refHelper); |
162 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //Reread the properties, PathParser changes them |
183 |
props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH); //Reread the properties, PathParser changes them |
163 |
String[] items = PropertyUtils.tokenizePath(raw); |
184 |
String[] items = PropertyUtils.tokenizePath(raw); |