--- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/Bundle.properties +++ a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/Bundle.properties @@ -74,6 +74,8 @@ ERR_Icon_Invalid=Cannot find icon. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. +ERR_IconNeededForMultiView=Icon is necessary when using multiview! +ERR_IconDoesNotExistsForMultiview=Icon {0} does not seem to exist! ACS_NameAndLocationPanel=Name, Icon and Location Panel ACS_CTL_PackageName=Package Name --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NameAndLocationPanel.java +++ a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NameAndLocationPanel.java @@ -77,6 +77,7 @@ putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle")); DocumentListener dListener = new UIUtil.DocumentAdapter() { + @Override public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); @@ -100,6 +101,7 @@ } } + @Override protected void storeToDataModel() { updateData(); } @@ -122,6 +124,7 @@ } } + @Override protected void readFromDataModel() { if (data.getPackageName() != null) { comPackageName.setSelectedItem(data.getPackageName()); @@ -132,6 +135,7 @@ checkValidity(); } + @Override protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } @@ -162,15 +166,16 @@ File icon = (path.length() == 0) ? null : new File(path); if (icon == null || !icon.exists()) { - setWarning(WizardUtils.getNoIconSelectedWarning(16,16)); + setWarning(WizardUtils.getNoIconSelectedWarning(16,16), !useMultiView.isSelected()); } else if (!WizardUtils.isValidIcon(icon,16,16)) { - setWarning(WizardUtils.getIconDimensionWarning(icon,16,16)); - } else { + setWarning(WizardUtils.getIconDimensionWarning(icon,16,16), !useMultiView.isSelected()); + } else { markValid(); } return true; } + @Override protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } @@ -345,6 +350,11 @@ add(lblIcon2, gridBagConstraints); org.openide.awt.Mnemonics.setLocalizedText(useMultiView, "&Use MultiView"); + useMultiView.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + useMultiViewActionPerformed(evt); + } + }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; @@ -361,6 +371,10 @@ txtIcon.setText(file.getAbsolutePath()); } }//GEN-LAST:event_btnIconActionPerformed + + private void useMultiViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useMultiViewActionPerformed + checkValidity(); + }//GEN-LAST:event_useMultiViewActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnIcon; --- a/core.multiview/src/org/netbeans/core/multiview/MultiViewProcessor.java +++ a/core.multiview/src/org/netbeans/core/multiview/MultiViewProcessor.java @@ -104,12 +104,15 @@ fileBaseName += "-" + binAndMethodNames[1]; } for (String type : mvr.mimeType()) { - LayerBuilder.File f = layer(e).file("Editors/" + (type.equals("") ? "" : type + '/') + "MultiView/" + fileBaseName + ".instance"); + final LayerBuilder builder = layer(e); + LayerBuilder.File f = builder.file("Editors/" + (type.equals("") ? "" : type + '/') + "MultiView/" + fileBaseName + ".instance"); f.methodvalue("instanceCreate", MultiViewFactory.class.getName(), "createMultiViewDescription"); f.stringvalue("instanceClass", ContextAwareDescription.class.getName()); f.stringvalue("class", binAndMethodNames[0]); f.bundlevalue("displayName", mvr.displayName(), mvr, "displayName"); - f.stringvalue("iconBase", mvr.iconBase()); + String fullIconPath = LayerBuilder.absolutizeResource(e, mvr.iconBase()); + builder.validateResource(fullIconPath, e, mvr, "iconBase", true); + f.stringvalue("iconBase", fullIconPath); f.stringvalue("preferredID", mvr.preferredID()); f.intvalue("persistenceType", mvr.persistenceType()); f.position(mvr.position()); --- a/core.multiview/test/unit/src/org/netbeans/core/multiview/MultiViewProcessorTest.java +++ a/core.multiview/test/unit/src/org/netbeans/core/multiview/MultiViewProcessorTest.java @@ -49,6 +49,8 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; @@ -260,7 +262,56 @@ + "import org.netbeans.core.spi.multiview.MultiViewElement;\n" + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" + "@MultiViewElement.Registration(displayName = \"Testing\"," - + "iconBase = \"none\"," + + "iconBase = \"one.png\"," + + "mimeType = \"text/ble\"," + + "persistenceType = 0," + + "preferredID = \"bleple\")" + + " public static MultiViewElement create() {\n" + + " return new Test();\n" + + " }\n" + + "}\n"; + generateIcon("one.png"); + AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); + assertTrue("Compilation should succeed:\n" + os.toString(), res); + } + + public void testCompileInAptFullPath() throws Exception { + clearWorkDir(); + String src = "\n" + + "import org.netbeans.core.spi.multiview.MultiViewElement;\n" + + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" + + "@MultiViewElement.Registration(displayName = \"Testing\"," + + "iconBase = \"/pkg/one.png\"," + + "mimeType = \"text/ble\"," + + "persistenceType = 0," + + "preferredID = \"bleple\")" + + " public static MultiViewElement create() {\n" + + " return new Test();\n" + + " }\n" + + "}\n"; + generateIcon("one.png"); + AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); + assertTrue("Compilation should succeed:\n" + os.toString(), res); + } + + private void generateIcon(String icon) throws IOException { + File pkg = new File(getWorkDir(), "pkg"); + pkg.mkdirs(); + File f = new File(pkg, icon); + f.createNewFile(); + } + + public void testFailsWithoutAnIcon() throws Exception { + clearWorkDir(); + String src = "\n" + + "import org.netbeans.core.spi.multiview.MultiViewElement;\n" + + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n" + + "@MultiViewElement.Registration(displayName = \"Testing\"," + + "iconBase = \"none-existing.png\"," + "mimeType = \"text/ble\"," + "persistenceType = 0," + "preferredID = \"bleple\")" @@ -271,7 +322,9 @@ AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src); ByteArrayOutputStream os = new ByteArrayOutputStream(); boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); - assertTrue("Compilation should succeed:\n" + os.toString(), res); + assertFalse("Compilation should fail:\n" + os.toString(), res); + assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("iconBase")); + assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("Cannot find resource pkg/none-existing.png")); } public void testIsSourceView() { @@ -369,7 +422,7 @@ @MultiViewElement.Registration( displayName="org.netbeans.core.multiview.TestBundle#FIGARO", - iconBase="none", + iconBase="empty.png", mimeType="text/figaro", persistenceType=TopComponent.PERSISTENCE_NEVER, preferredID="figaro" @@ -446,7 +499,7 @@ @MultiViewElement.Registration( displayName="Contextual", - iconBase="none", + iconBase="empty.png", mimeType="text/context", persistenceType=TopComponent.PERSISTENCE_ALWAYS, preferredID="context" @@ -470,7 +523,7 @@ @MultiViewElement.Registration( displayName="Source", - iconBase="none", + iconBase="empty.png", mimeType="text/plaintest", persistenceType=TopComponent.PERSISTENCE_NEVER, preferredID="source"