Lines 49-54
Link Here
|
49 |
import java.beans.PropertyChangeEvent; |
49 |
import java.beans.PropertyChangeEvent; |
50 |
import java.beans.PropertyChangeListener; |
50 |
import java.beans.PropertyChangeListener; |
51 |
import java.io.ByteArrayOutputStream; |
51 |
import java.io.ByteArrayOutputStream; |
|
|
52 |
import java.io.File; |
53 |
import java.io.IOException; |
52 |
import java.io.Serializable; |
54 |
import java.io.Serializable; |
53 |
import java.util.Arrays; |
55 |
import java.util.Arrays; |
54 |
import java.util.Collection; |
56 |
import java.util.Collection; |
Lines 260-266
Link Here
|
260 |
+ "import org.netbeans.core.spi.multiview.MultiViewElement;\n" |
262 |
+ "import org.netbeans.core.spi.multiview.MultiViewElement;\n" |
261 |
+ "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" |
263 |
+ "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" |
262 |
+ "@MultiViewElement.Registration(displayName = \"Testing\"," |
264 |
+ "@MultiViewElement.Registration(displayName = \"Testing\"," |
263 |
+ "iconBase = \"none\"," |
265 |
+ "iconBase = \"one.png\"," |
|
|
266 |
+ "mimeType = \"text/ble\"," |
267 |
+ "persistenceType = 0," |
268 |
+ "preferredID = \"bleple\")" |
269 |
+ " public static MultiViewElement create() {\n" |
270 |
+ " return new Test();\n" |
271 |
+ " }\n" |
272 |
+ "}\n"; |
273 |
generateIcon("one.png"); |
274 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); |
275 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
276 |
boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
277 |
assertTrue("Compilation should succeed:\n" + os.toString(), res); |
278 |
} |
279 |
|
280 |
public void testCompileInAptFullPath() throws Exception { |
281 |
clearWorkDir(); |
282 |
String src = "\n" |
283 |
+ "import org.netbeans.core.spi.multiview.MultiViewElement;\n" |
284 |
+ "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" |
285 |
+ "@MultiViewElement.Registration(displayName = \"Testing\"," |
286 |
+ "iconBase = \"/pkg/one.png\"," |
287 |
+ "mimeType = \"text/ble\"," |
288 |
+ "persistenceType = 0," |
289 |
+ "preferredID = \"bleple\")" |
290 |
+ " public static MultiViewElement create() {\n" |
291 |
+ " return new Test();\n" |
292 |
+ " }\n" |
293 |
+ "}\n"; |
294 |
generateIcon("one.png"); |
295 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); |
296 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
297 |
boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
298 |
assertTrue("Compilation should succeed:\n" + os.toString(), res); |
299 |
} |
300 |
|
301 |
private void generateIcon(String icon) throws IOException { |
302 |
File pkg = new File(getWorkDir(), "pkg"); |
303 |
pkg.mkdirs(); |
304 |
File f = new File(pkg, icon); |
305 |
f.createNewFile(); |
306 |
} |
307 |
|
308 |
public void testFailsWithoutAnIcon() throws Exception { |
309 |
clearWorkDir(); |
310 |
String src = "\n" |
311 |
+ "import org.netbeans.core.spi.multiview.MultiViewElement;\n" |
312 |
+ "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" |
313 |
+ "@MultiViewElement.Registration(displayName = \"Testing\"," |
314 |
+ "iconBase = \"none-existing.png\"," |
264 |
+ "mimeType = \"text/ble\"," |
315 |
+ "mimeType = \"text/ble\"," |
265 |
+ "persistenceType = 0," |
316 |
+ "persistenceType = 0," |
266 |
+ "preferredID = \"bleple\")" |
317 |
+ "preferredID = \"bleple\")" |
Lines 271-277
Link Here
|
271 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); |
322 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); |
272 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
323 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
273 |
boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
324 |
boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
274 |
assertTrue("Compilation should succeed:\n" + os.toString(), res); |
325 |
assertFalse("Compilation should fail:\n" + os.toString(), res); |
|
|
326 |
assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("iconBase")); |
327 |
assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("Cannot find resource pkg/none-existing.png")); |
275 |
} |
328 |
} |
276 |
|
329 |
|
277 |
public void testIsSourceView() { |
330 |
public void testIsSourceView() { |
Lines 369-375
Link Here
|
369 |
|
422 |
|
370 |
@MultiViewElement.Registration( |
423 |
@MultiViewElement.Registration( |
371 |
displayName="org.netbeans.core.multiview.TestBundle#FIGARO", |
424 |
displayName="org.netbeans.core.multiview.TestBundle#FIGARO", |
372 |
iconBase="none", |
425 |
iconBase="empty.png", |
373 |
mimeType="text/figaro", |
426 |
mimeType="text/figaro", |
374 |
persistenceType=TopComponent.PERSISTENCE_NEVER, |
427 |
persistenceType=TopComponent.PERSISTENCE_NEVER, |
375 |
preferredID="figaro" |
428 |
preferredID="figaro" |
Lines 446-452
Link Here
|
446 |
|
499 |
|
447 |
@MultiViewElement.Registration( |
500 |
@MultiViewElement.Registration( |
448 |
displayName="Contextual", |
501 |
displayName="Contextual", |
449 |
iconBase="none", |
502 |
iconBase="empty.png", |
450 |
mimeType="text/context", |
503 |
mimeType="text/context", |
451 |
persistenceType=TopComponent.PERSISTENCE_ALWAYS, |
504 |
persistenceType=TopComponent.PERSISTENCE_ALWAYS, |
452 |
preferredID="context" |
505 |
preferredID="context" |
Lines 470-476
Link Here
|
470 |
|
523 |
|
471 |
@MultiViewElement.Registration( |
524 |
@MultiViewElement.Registration( |
472 |
displayName="Source", |
525 |
displayName="Source", |
473 |
iconBase="none", |
526 |
iconBase="empty.png", |
474 |
mimeType="text/plaintest", |
527 |
mimeType="text/plaintest", |
475 |
persistenceType=TopComponent.PERSISTENCE_NEVER, |
528 |
persistenceType=TopComponent.PERSISTENCE_NEVER, |
476 |
preferredID="source" |
529 |
preferredID="source" |