Lines 46-59
Link Here
|
46 |
|
46 |
|
47 |
import java.io.File; |
47 |
import java.io.File; |
48 |
import java.io.IOException; |
48 |
import java.io.IOException; |
|
|
49 |
import java.net.URI; |
49 |
import java.util.ArrayList; |
50 |
import java.util.ArrayList; |
50 |
import java.util.List; |
51 |
import java.util.List; |
51 |
import org.netbeans.api.project.Project; |
52 |
import org.netbeans.api.project.Project; |
52 |
import org.netbeans.spi.project.CopyOperationImplementation; |
53 |
import org.netbeans.spi.project.CopyOperationImplementation2; |
53 |
import org.netbeans.spi.project.DataFilesProviderImplementation; |
54 |
import org.netbeans.spi.project.DataFilesProviderImplementation; |
54 |
import org.netbeans.spi.project.DeleteOperationImplementation; |
55 |
import org.netbeans.spi.project.DeleteOperationImplementation; |
55 |
import org.netbeans.spi.project.MoveOperationImplementation; |
56 |
import org.netbeans.spi.project.MoveOperationImplementation2; |
56 |
import org.netbeans.spi.project.MoveOrRenameOperationImplementation; |
|
|
57 |
import org.openide.filesystems.FileObject; |
57 |
import org.openide.filesystems.FileObject; |
58 |
|
58 |
|
59 |
/** |
59 |
/** |
Lines 146-156
Link Here
|
146 |
/**Test whether the copy operation is supported on the given project. |
146 |
/**Test whether the copy operation is supported on the given project. |
147 |
* |
147 |
* |
148 |
* @param prj project to test |
148 |
* @param prj project to test |
149 |
* @return <code>true</code> if the project has a {@link CopyOperationImplementation}, |
149 |
* @return <code>true</code> if the project has a {@link CopyOperationImplementation2}, |
150 |
* <code>false</code> otherwise |
150 |
* <code>false</code> otherwise |
151 |
*/ |
151 |
*/ |
|
|
152 |
@SuppressWarnings("deprecation") |
152 |
public static boolean isCopyOperationSupported(Project prj) { |
153 |
public static boolean isCopyOperationSupported(Project prj) { |
153 |
return prj.getLookup().lookup(CopyOperationImplementation.class) != null; |
154 |
return prj.getLookup().lookup(CopyOperationImplementation2.class) != null || |
|
|
155 |
prj.getLookup().lookup(org.netbeans.spi.project.CopyOperationImplementation.class) != null; |
154 |
} |
156 |
} |
155 |
|
157 |
|
156 |
/**Notification that the project is about to be copyied. |
158 |
/**Notification that the project is about to be copyied. |
Lines 160-173
Link Here
|
160 |
* |
162 |
* |
161 |
* @param prj project to notify |
163 |
* @param prj project to notify |
162 |
* @throws IOException is some error occurs |
164 |
* @throws IOException is some error occurs |
163 |
* @see CopyOperationImplementation#notifyCopying |
165 |
* @see CopyOperationImplementation2#notifyCopying |
164 |
*/ |
166 |
*/ |
|
|
167 |
@SuppressWarnings("deprecation") |
165 |
public static void notifyCopying(Project prj) throws IOException { |
168 |
public static void notifyCopying(Project prj) throws IOException { |
166 |
for (CopyOperationImplementation i : prj.getLookup().lookupAll(CopyOperationImplementation.class)) { |
169 |
for (CopyOperationImplementation2 i : prj.getLookup().lookupAll(CopyOperationImplementation2.class)) { |
|
|
170 |
i.notifyCopying(); |
171 |
} |
172 |
for (org.netbeans.spi.project.CopyOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { |
167 |
i.notifyCopying(); |
173 |
i.notifyCopying(); |
168 |
} |
174 |
} |
169 |
} |
175 |
} |
170 |
|
176 |
|
|
|
177 |
/** |
178 |
* @deprecated use {@link #notifyCopied(Project, Project, URI, String)} instead |
179 |
*/ |
180 |
@Deprecated |
181 |
public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException { |
182 |
notifyCopied(original, nue, originalPath.toURI(), name); |
183 |
} |
171 |
/**Notification that the project has been copied. |
184 |
/**Notification that the project has been copied. |
172 |
* Should be called immediatelly after the project is copied. |
185 |
* Should be called immediatelly after the project is copied. |
173 |
* |
186 |
* |
Lines 181-215
Link Here
|
181 |
* @param originalPath the project folder of the original project (for consistency with notifyMoved) |
194 |
* @param originalPath the project folder of the original project (for consistency with notifyMoved) |
182 |
* @param name new name of the project |
195 |
* @param name new name of the project |
183 |
* @throws IOException is some error occurs |
196 |
* @throws IOException is some error occurs |
184 |
* @see CopyOperationImplementation#notifyCopied |
197 |
* @see CopyOperationImplementation2#notifyCopied |
|
|
198 |
* @since 1.43 |
185 |
*/ |
199 |
*/ |
186 |
public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException { |
200 |
@SuppressWarnings("deprecation") |
187 |
for (CopyOperationImplementation i : original.getLookup().lookupAll(CopyOperationImplementation.class)) { |
201 |
public static void notifyCopied(Project original, Project nue, URI originalPath, String name) throws IOException { |
|
|
202 |
for (CopyOperationImplementation2 i : original.getLookup().lookupAll(CopyOperationImplementation2.class)) { |
188 |
i.notifyCopied(null, originalPath, name); |
203 |
i.notifyCopied(null, originalPath, name); |
189 |
} |
204 |
} |
190 |
for (CopyOperationImplementation i : nue.getLookup().lookupAll(CopyOperationImplementation.class)) { |
205 |
for (CopyOperationImplementation2 i : nue.getLookup().lookupAll(CopyOperationImplementation2.class)) { |
191 |
i.notifyCopied(original, originalPath, name); |
206 |
i.notifyCopied(original, originalPath, name); |
192 |
} |
207 |
} |
|
|
208 |
if ("file".equals(originalPath.getScheme())) { |
209 |
File f = new File(originalPath); |
210 |
for (org.netbeans.spi.project.CopyOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { |
211 |
i.notifyCopied(null, f, name); |
212 |
} |
213 |
for (org.netbeans.spi.project.CopyOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.CopyOperationImplementation.class)) { |
214 |
i.notifyCopied(original, f, name); |
215 |
} |
216 |
} |
193 |
} |
217 |
} |
194 |
|
218 |
|
195 |
/**Notification that the project is about to be moved. |
219 |
/**Notification that the project is about to be moved. |
196 |
* Should be called immediately before the project is moved. |
220 |
* Should be called immediately before the project is moved. |
197 |
* {@link MoveOrRenameOperationImplementation#notifyRenaming} may be called instead. |
221 |
* {@link MoveOperationImplementation2#notifyRenaming} may be called instead. |
198 |
* The project is supposed to do all required cleanup to allow the project to be moved. |
222 |
* The project is supposed to do all required cleanup to allow the project to be moved. |
199 |
* |
223 |
* |
200 |
* @param prj project to notify |
224 |
* @param prj project to notify |
201 |
* @throws IOException is some error occurs |
225 |
* @throws IOException is some error occurs |
202 |
* @see MoveOperationImplementation#notifyMoving |
226 |
* @see MoveOperationImplementation2#notifyMoving |
203 |
*/ |
227 |
*/ |
|
|
228 |
@SuppressWarnings("deprecation") |
204 |
public static void notifyMoving(Project prj) throws IOException { |
229 |
public static void notifyMoving(Project prj) throws IOException { |
205 |
for (MoveOperationImplementation i : prj.getLookup().lookupAll(MoveOperationImplementation.class)) { |
230 |
for (org.netbeans.spi.project.MoveOperationImplementation i : prj.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { |
206 |
i.notifyMoving(); |
231 |
i.notifyMoving(); |
207 |
} |
232 |
} |
208 |
} |
233 |
} |
209 |
|
234 |
|
|
|
235 |
/** |
236 |
* @deprecated use {@link #notifyMoved(Project, Project, URI, String)} instead |
237 |
*/ |
238 |
@Deprecated |
239 |
public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException { |
240 |
notifyMoved(original, nue, originalPath.toURI(), name); |
241 |
} |
210 |
/**Notification that the project has been moved. |
242 |
/**Notification that the project has been moved. |
211 |
* Should be called immediatelly after the project is moved. |
243 |
* Should be called immediatelly after the project is moved. |
212 |
* {@link MoveOrRenameOperationImplementation#notifyRenamed} may be called instead. |
244 |
* {@link MoveOperationImplementation2#notifyRenamed} may be called instead. |
213 |
* |
245 |
* |
214 |
* The project is supposed to do all necessary fixes to the project's structure to |
246 |
* The project is supposed to do all necessary fixes to the project's structure to |
215 |
* form a valid project. |
247 |
* form a valid project. |
Lines 221-246
Link Here
|
221 |
* @param originalPath the project folder of the original project |
253 |
* @param originalPath the project folder of the original project |
222 |
* @param name new name of the project |
254 |
* @param name new name of the project |
223 |
* @throws IOException is some error occurs |
255 |
* @throws IOException is some error occurs |
224 |
* @see MoveOperationImplementation#notifyMoved |
256 |
* @see MoveOperationImplementation2#notifyMoved |
|
|
257 |
* @since 1.43 |
225 |
*/ |
258 |
*/ |
226 |
public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException { |
259 |
@SuppressWarnings("deprecation") |
227 |
for (MoveOperationImplementation i : original.getLookup().lookupAll(MoveOperationImplementation.class)) { |
260 |
public static void notifyMoved(Project original, Project nue, URI originalPath, String name) throws IOException { |
|
|
261 |
for (MoveOperationImplementation2 i : original.getLookup().lookupAll(MoveOperationImplementation2.class)) { |
228 |
i.notifyMoved(null, originalPath, name); |
262 |
i.notifyMoved(null, originalPath, name); |
229 |
} |
263 |
} |
230 |
for (MoveOperationImplementation i : nue.getLookup().lookupAll(MoveOperationImplementation.class)) { |
264 |
for (MoveOperationImplementation2 i : nue.getLookup().lookupAll(MoveOperationImplementation2.class)) { |
231 |
i.notifyMoved(original, originalPath, name); |
265 |
i.notifyMoved(original, originalPath, name); |
232 |
} |
266 |
} |
|
|
267 |
if ("file".equals(originalPath.getScheme())) { |
268 |
File f = new File(originalPath); |
269 |
for (org.netbeans.spi.project.MoveOperationImplementation i : original.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { |
270 |
i.notifyMoved(null, f, name); |
271 |
} |
272 |
for (org.netbeans.spi.project.MoveOperationImplementation i : nue.getLookup().lookupAll(org.netbeans.spi.project.MoveOperationImplementation.class)) { |
273 |
i.notifyMoved(original, f, name); |
274 |
} |
275 |
} |
233 |
} |
276 |
} |
234 |
|
277 |
|
235 |
/** |
278 |
/** |
236 |
* Tests whether the move or rename operations are supported on the given project. |
279 |
* Tests whether the move or rename operations are supported on the given project. |
237 |
* |
280 |
* |
238 |
* @param prj project to test |
281 |
* @param prj project to test |
239 |
* @return <code>true</code> if the project has a {@link MoveOperationImplementation}, |
282 |
* @return <code>true</code> if the project has a {@link MoveOperationImplementation2}, |
240 |
* <code>false</code> otherwise |
283 |
* <code>false</code> otherwise |
241 |
*/ |
284 |
*/ |
|
|
285 |
@SuppressWarnings("deprecation") |
242 |
public static boolean isMoveOperationSupported(Project prj) { |
286 |
public static boolean isMoveOperationSupported(Project prj) { |
243 |
return prj.getLookup().lookup(MoveOperationImplementation.class) != null; |
287 |
return prj.getLookup().lookup(MoveOperationImplementation2.class) != null || |
|
|
288 |
prj.getLookup().lookup(org.netbeans.spi.project.MoveOperationImplementation.class) != null; |
244 |
} |
289 |
} |
245 |
|
290 |
|
246 |
} |
291 |
} |