1.1 --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
1.2 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
1.3 @@ -43,38 +43,6 @@
1.4 <folder name="APISupport">
1.5 <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.Bundle#Templates/Project/APISupport"/>
1.6 <attr name="position" intvalue="900"/>
1.7 - <file name="emptyModule">
1.8 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.Bundle#Templates/Project/APISupport/emptyModule"/>
1.9 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/resources/module.png"/>
1.10 - <attr name="position" intvalue="100"/>
1.11 - <attr name="template" boolvalue="true"/>
1.12 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.NewNbModuleWizardIterator.createModuleIterator"/>
1.13 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/resources/emptyModule.html"/>
1.14 - </file>
1.15 - <file name="emptySuite">
1.16 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.Bundle#Templates/Project/APISupport/emptySuite"/>
1.17 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/suite/resources/suite.png"/>
1.18 - <attr name="position" intvalue="200"/>
1.19 - <attr name="template" boolvalue="true"/>
1.20 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.NewNbModuleWizardIterator.createSuiteIterator"/>
1.21 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/resources/emptySuite.html"/>
1.22 - </file>
1.23 - <file name="libraryModule">
1.24 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.Bundle#Templates/Project/APISupport/libraryModule"/>
1.25 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/resources/module.png"/>
1.26 - <attr name="position" intvalue="300"/>
1.27 - <attr name="template" boolvalue="true"/>
1.28 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.NewNbModuleWizardIterator.createLibraryModuleIterator"/>
1.29 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/resources/libraryModule.html"/>
1.30 - </file>
1.31 - <file name="emptyApplication">
1.32 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.Bundle#Templates/Project/APISupport/emptyApplication"/>
1.33 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/suite/resources/suite.png"/>
1.34 - <attr name="position" intvalue="400"/>
1.35 - <attr name="template" boolvalue="true"/>
1.36 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.NewNbModuleWizardIterator.createApplicationIterator"/>
1.37 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/resources/emptyApplication.html"/>
1.38 - </file>
1.39 </folder>
1.40 </folder>
1.41 </folder>
2.1 --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
2.2 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
2.3 @@ -42,10 +42,6 @@
2.4
2.5 # System file system
2.6 Templates/Project/APISupport=NetBeans Modules
2.7 -Templates/Project/APISupport/emptyModule=Module
2.8 -Templates/Project/APISupport/emptySuite=Module Suite
2.9 -Templates/Project/APISupport/emptyApplication=NetBeans Platform Application
2.10 -Templates/Project/APISupport/libraryModule=Library Wrapper Module
2.11
2.12 # general
2.13 CTL_BrowseButton_o=Br&owse...
3.1 --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java Wed Jul 27 10:33:10 2011 +0200
3.2 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java Wed Jul 27 10:35:25 2011 +0200
3.3 @@ -50,7 +50,6 @@
3.4 import java.util.ArrayList;
3.5 import java.util.HashSet;
3.6 import java.util.List;
3.7 -import java.util.Map;
3.8 import java.util.NoSuchElementException;
3.9 import java.util.Set;
3.10 import javax.swing.JComponent;
3.11 @@ -68,7 +67,9 @@
3.12 import org.openide.WizardDescriptor;
3.13 import org.openide.filesystems.FileObject;
3.14 import org.openide.filesystems.FileUtil;
3.15 +import org.netbeans.api.templates.TemplateRegistration;
3.16 import org.openide.util.NbBundle;
3.17 +import org.openide.util.NbBundle.Messages;
3.18
3.19 /**
3.20 * Wizard to create a new NetBeans Module project.
3.21 @@ -76,6 +77,10 @@
3.22 * @author Martin Krauskopf
3.23 */
3.24 public class NewNbModuleWizardIterator implements WizardDescriptor.AsynchronousInstantiatingIterator<WizardDescriptor> {
3.25 +
3.26 + private static final String FOLDER = "Project/APISupport";
3.27 + private static final String MODULE_ICON = "org/netbeans/modules/apisupport/project/resources/module.png";
3.28 + private static final String SUITE_ICON = "org/netbeans/modules/apisupport/project/suite/resources/suite.png";
3.29
3.30 enum Type {
3.31 /** Either standalone module, suite component or NB.org module. */
3.32 @@ -119,7 +124,9 @@
3.33 * Returns wizard for creating NetBeans module in general - i.e. either
3.34 * standalone module, suite component or NB.org module.
3.35 */
3.36 - public static NewNbModuleWizardIterator createModuleIterator(Map m) {
3.37 + @TemplateRegistration(folder = FOLDER, position = 100, displayName = "#template_module", iconBase = MODULE_ICON, description = "../../resources/emptyModule.html")
3.38 + @Messages("template_module=Module")
3.39 + public static NewNbModuleWizardIterator createModuleIterator() {
3.40 return new NewNbModuleWizardIterator(Type.MODULE);
3.41 }
3.42
3.43 @@ -133,10 +140,14 @@
3.44 return iterator;
3.45 }
3.46
3.47 + @TemplateRegistration(folder = FOLDER, position = 200, displayName = "#template_suite", iconBase = SUITE_ICON, description = "../../resources/emptySuite.html")
3.48 + @Messages("template_suite=Module Suite")
3.49 public static NewNbModuleWizardIterator createSuiteIterator() {
3.50 return new NewNbModuleWizardIterator(Type.SUITE);
3.51 }
3.52
3.53 + @TemplateRegistration(folder = FOLDER, position = 400, displayName = "#template_application", iconBase = SUITE_ICON, description = "../../resources/emptyApplication.html")
3.54 + @Messages("template_application=NetBeans Platform Application")
3.55 public static NewNbModuleWizardIterator createApplicationIterator() {
3.56 return new NewNbModuleWizardIterator(Type.APPLICATION);
3.57 }
3.58 @@ -154,6 +165,8 @@
3.59 return iterator;
3.60 }
3.61
3.62 + @TemplateRegistration(folder = FOLDER, position = 300, displayName = "#template_library_module", iconBase = MODULE_ICON, description = "../../resources/libraryModule.html")
3.63 + @Messages("template_library_module=Library Wrapper Module")
3.64 public static NewNbModuleWizardIterator createLibraryModuleIterator() {
3.65 return new NewNbModuleWizardIterator(Type.LIBRARY_MODULE);
3.66 }
4.1 --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/NewTemplateVisualPanel.java Wed Jul 27 10:33:10 2011 +0200
4.2 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/wizard/NewTemplateVisualPanel.java Wed Jul 27 10:35:25 2011 +0200
4.3 @@ -43,7 +43,7 @@
4.4 package org.netbeans.modules.apisupport.project.ui.wizard;
4.5
4.6 import org.netbeans.modules.apisupport.project.api.BasicVisualPanel;
4.7 -import org.openide.util.NbBundle;
4.8 +import static org.netbeans.modules.apisupport.project.ui.wizard.Bundle.*;
4.9
4.10 abstract class NewTemplateVisualPanel extends BasicVisualPanel {
4.11
4.12 @@ -52,27 +52,27 @@
4.13 NewTemplateVisualPanel(final NewModuleProjectData data) {
4.14 super(data.getSettings());
4.15 this.data = data;
4.16 - String resource;
4.17 + String title;
4.18 switch (data.getWizardType()) {
4.19 case SUITE:
4.20 - resource = "emptySuite"; // NOI18N
4.21 + title = template_suite();
4.22 break;
4.23 case APPLICATION:
4.24 - resource = "emptyApplication"; // NOI18N
4.25 + title = template_application();
4.26 break;
4.27 case MODULE:
4.28 case SUITE_COMPONENT:
4.29 - resource = "emptyModule"; // NOI18N
4.30 + title = template_module();
4.31 break;
4.32 case LIBRARY_MODULE:
4.33 - resource = "libraryModule"; // NOI18N
4.34 + title = template_library_module();
4.35 break;
4.36 default:
4.37 assert false : "Unknown wizard type = " + data.getWizardType();
4.38 - resource = "";
4.39 + title = "";
4.40 }
4.41 data.getSettings().putProperty("NewProjectWizard_Title", // NOI18N
4.42 - NbBundle.getMessage(NewTemplateVisualPanel.class, "Templates/Project/APISupport/" + resource));
4.43 + title);
4.44 }
4.45
4.46 protected NewModuleProjectData getData() {
5.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystem.java Wed Jul 27 10:33:10 2011 +0200
5.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystem.java Wed Jul 27 10:35:25 2011 +0200
5.3 @@ -460,6 +460,7 @@
5.4 if (el == null) {
5.5 throw new FileNotFoundException(name);
5.6 }
5.7 + /* no good for refactoring
5.8 TreeAttribute externalName = el.getAttribute("url"); // NOI18N
5.9 try {
5.10 if (externalName != null && !new URI(externalName.getValue()).isAbsolute()) {
5.11 @@ -473,6 +474,7 @@
5.12 } catch (URISyntaxException x) {
5.13 // #189739: never mind
5.14 }
5.15 + */
5.16 try {
5.17 deleteWithIndent((TreeChild) el);
5.18 } catch (ReadOnlyException e) {
5.19 @@ -609,6 +611,10 @@
5.20 if (el == null) {
5.21 return null;
5.22 }
5.23 + if (attrName.equals("WritableXMLFileSystem.url")) {
5.24 + TreeAttribute urlAttr = el.getAttribute("url"); // NOI18N
5.25 + return urlAttr != null ? urlAttr.getValue() : null;
5.26 + }
5.27 boolean literal = false;
5.28 if (attrName.startsWith("literal:")) { // NOI18N
5.29 attrName = attrName.substring("literal:".length()); // NOI18N
6.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
6.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
6.3 @@ -49,123 +49,6 @@
6.4 <folder name="NetBeansModuleDevelopment">
6.5 <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.common.Bundle#NetBeansModuleDevelopment"/>
6.6 <attr name="position" intvalue="200"/>
6.7 - <file name="newAction">
6.8 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.action.Bundle#Templates/NetBeansModuleDevelopment/newAction"/>
6.9 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newAction.png"/>
6.10 - <attr name="position" intvalue="100"/>
6.11 - <attr boolvalue="true" name="template"/>
6.12 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.action.NewActionIterator.createIterator" name="instantiatingIterator"/>
6.13 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newAction.html"/>
6.14 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.15 - </file>
6.16 - <file name="newWindow">
6.17 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.winsys.Bundle#Templates/NetBeansModuleDevelopment/newWindow"/>
6.18 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newTC.png"/>
6.19 - <attr name="position" intvalue="200"/>
6.20 - <attr name="template" boolvalue="true"/>
6.21 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.winsys.NewTCIterator.createIterator"/>
6.22 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newTC.html"/>
6.23 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.24 - </file>
6.25 - <file name="newWizard">
6.26 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.wizard.Bundle#Templates/NetBeansModuleDevelopment/newWizard"/>
6.27 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newWizard.png"/>
6.28 - <attr name="position" intvalue="300"/>
6.29 - <attr boolvalue="true" name="template"/>
6.30 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.wizard.NewWizardIterator.createIterator" name="instantiatingIterator"/>
6.31 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newWizard.html"/>
6.32 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.33 - </file>
6.34 - <file name="newOptions">
6.35 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.options.Bundle#Templates/NetBeansModuleDevelopment/newOptions"/>
6.36 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newOptions.png"/>
6.37 - <attr name="position" intvalue="400"/>
6.38 - <attr boolvalue="true" name="template"/>
6.39 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.options.NewOptionsIterator.createIterator" name="instantiatingIterator"/>
6.40 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newOptions.html"/>
6.41 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.42 - </file>
6.43 - <file name="newLoader">
6.44 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.loader.Bundle#Templates/NetBeansModuleDevelopment/newLoader"/>
6.45 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newLoader.png"/>
6.46 - <attr name="position" intvalue="500"/>
6.47 - <attr boolvalue="true" name="template"/>
6.48 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.loader.NewLoaderIterator.createIterator" name="instantiatingIterator"/>
6.49 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newLoader.html"/>
6.50 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.51 - </file>
6.52 - <file name="newUpdateCenter">
6.53 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.updatecenter.Bundle#Templates/NetBeansModuleDevelopment/newUpdateCenter"/>
6.54 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newUpdateCenter.png"/>
6.55 - <attr name="position" intvalue="600"/>
6.56 - <attr name="template" boolvalue="true"/>
6.57 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.updatecenter.NewUpdateCenterIterator.createIterator"/>
6.58 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newUpdateCenter.html"/>
6.59 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.60 - </file>
6.61 - <file name="newModuleInstall">
6.62 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.moduleinstall.Bundle#Templates/NetBeansModuleDevelopment/newModuleInstall"/>
6.63 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/resources/module.png"/>
6.64 - <attr name="position" intvalue="700"/>
6.65 - <attr boolvalue="true" name="template"/>
6.66 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.moduleinstall.NewModuleInstallIterator.createIterator" name="instantiatingIterator"/>
6.67 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newModuleInstall.html"/>
6.68 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.69 - </file>
6.70 - <file name="newQuickSearch">
6.71 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.quicksearch.Bundle#Templates/NetBeansModuleDevelopment/newQuickSearch"/>
6.72 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newQuickSearch.png"/>
6.73 - <attr name="position" intvalue="800"/>
6.74 - <attr name="template" boolvalue="true"/>
6.75 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.quicksearch.NewQuickSearchIterator.createIterator"/>
6.76 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newQuickSearch.html"/>
6.77 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.78 - </file>
6.79 - <file name="newJavaHelp">
6.80 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.javahelp.Bundle#Templates/NetBeansModuleDevelopment/newJavaHelp"/>
6.81 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newJavaHelp.png"/>
6.82 - <attr name="position" intvalue="900"/>
6.83 - <attr boolvalue="true" name="template"/>
6.84 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.javahelp.NewJavaHelpIterator.createIterator" name="instantiatingIterator"/>
6.85 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newJavaHelp.html"/>
6.86 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.87 - </file>
6.88 - <file name="newProject">
6.89 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.project.Bundle#Templates/NetBeansModuleDevelopment/newProject"/>
6.90 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newProject.png"/>
6.91 - <attr name="position" intvalue="1000"/>
6.92 - <attr name="template" boolvalue="true"/>
6.93 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.project.NewProjectIterator.createIterator"/>
6.94 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newProject.html"/>
6.95 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.96 - </file>
6.97 - <file name="emptyLibraryDescriptor">
6.98 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.librarydescriptor.Bundle#Templates/NetBeansModuleDevelopment/emptyLibraryDescriptor"/>
6.99 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/libraries.gif"/>
6.100 - <attr name="position" intvalue="1100"/>
6.101 - <attr boolvalue="true" name="template"/>
6.102 - <attr methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.librarydescriptor.NewLibraryDescriptor.createIterator" name="instantiatingIterator"/>
6.103 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/emptyLibraryDescriptor.html"/>
6.104 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.105 - </file>
6.106 - <file name="newCodeGenerator">
6.107 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.codegenerator.Bundle#Templates/NetBeansModuleDevelopment/newCodeGenerator"/>
6.108 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/newCodeGenerator.png"/>
6.109 - <attr name="position" intvalue="1200"/>
6.110 - <attr name="template" boolvalue="true"/>
6.111 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.apisupport.project.ui.wizard.codegenerator.NewCodeGeneratorIterator.createIterator"/>
6.112 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newCodeGenerator.html"/>
6.113 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.114 - </file>
6.115 - <file name="newLayer">
6.116 - <attr name="displayName" bundlevalue="org.netbeans.modules.apisupport.project.ui.wizard.layer.Bundle#template_label"/>
6.117 - <attr name="iconBase" stringvalue="org/netbeans/modules/apisupport/project/ui/resources/layerObject.gif"/>
6.118 - <attr name="position" intvalue="1300"/>
6.119 - <attr name="template" boolvalue="true"/>
6.120 - <attr name="instantiatingIterator" newvalue="org.netbeans.modules.apisupport.project.ui.wizard.layer.NewLayerIterator"/>
6.121 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/apisupport/project/ui/resources/newLayer.html"/>
6.122 - <attr name="templateCategory" stringvalue="nbm-specific"/>
6.123 - </file>
6.124 </folder>
6.125 <folder name="NetBeansModuleDevelopment-files"> <!-- XXX later could be made visible (just need localized labels) -->
6.126 <attr name="position" intvalue="0"/>
7.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/action/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
7.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/action/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
7.3 @@ -41,7 +41,6 @@
7.4 # Version 2 license, then the option applies only if the new code is
7.5 # made subject to such option by the copyright holder.
7.6
7.7 -Templates/NetBeansModuleDevelopment/newAction=Action
7.8 LBL_ActionWizardTitle=Action
7.9
7.10 # Action Type panel (1.step)
8.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/action/NewActionIterator.java Wed Jul 27 10:33:10 2011 +0200
8.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/action/NewActionIterator.java Wed Jul 27 10:35:25 2011 +0200
8.3 @@ -49,22 +49,20 @@
8.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles;
8.5 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
8.6 import org.openide.WizardDescriptor;
8.7 +import org.netbeans.api.templates.TemplateRegistration;
8.8 +import org.openide.util.NbBundle.Messages;
8.9
8.10 /**
8.11 * Wizard for creating new Actions.
8.12 *
8.13 * @author Martin Krauskopf
8.14 */
8.15 -final class NewActionIterator extends BasicWizardIterator {
8.16 +@TemplateRegistration(folder="NetBeansModuleDevelopment", displayName="#template_action", iconBase="org/netbeans/modules/apisupport/project/ui/resources/newAction.png", position=100, description="../../resources/newAction.html", category="nbm-specific")
8.17 +@Messages("template_action=Action")
8.18 +public final class NewActionIterator extends BasicWizardIterator {
8.19
8.20 private DataModel data;
8.21
8.22 - private NewActionIterator() {}
8.23 -
8.24 - public static NewActionIterator createIterator() {
8.25 - return new NewActionIterator();
8.26 - }
8.27 -
8.28 public Set instantiate() throws IOException {
8.29 CreatedModifiedFiles cmf = data.getCreatedModifiedFiles();
8.30 cmf.run();
9.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/codegenerator/NewCodeGeneratorIterator.java Wed Jul 27 10:33:10 2011 +0200
9.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/codegenerator/NewCodeGeneratorIterator.java Wed Jul 27 10:35:25 2011 +0200
9.3 @@ -52,6 +52,7 @@
9.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
9.5 import org.openide.WizardDescriptor;
9.6 import org.openide.filesystems.FileObject;
9.7 +import org.netbeans.api.templates.TemplateRegistration;
9.8
9.9 /**
9.10 * Wiziard for creating ne Code Generators
9.11 @@ -164,6 +165,7 @@
9.12 * layer.xml entrypoint
9.13 * @return instance
9.14 */
9.15 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 1200, displayName = "#Templates/NetBeansModuleDevelopment/newCodeGenerator", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/newCodeGenerator.png", description = "/org/netbeans/modules/apisupport/project/ui/resources/newCodeGenerator.html", category = "nbm-specific")
9.16 public static NewCodeGeneratorIterator createIterator() {
9.17 return new NewCodeGeneratorIterator();
9.18 }
10.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/javahelp/NewJavaHelpIterator.java Wed Jul 27 10:33:10 2011 +0200
10.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/javahelp/NewJavaHelpIterator.java Wed Jul 27 10:35:25 2011 +0200
10.3 @@ -57,6 +57,7 @@
10.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
10.5 import org.openide.WizardDescriptor;
10.6 import org.openide.filesystems.FileObject;
10.7 +import org.netbeans.api.templates.TemplateRegistration;
10.8 import org.openide.modules.SpecificationVersion;
10.9 import org.openide.util.Exceptions;
10.10
10.11 @@ -69,6 +70,7 @@
10.12
10.13 private NewJavaHelpIterator.DataModel data;
10.14
10.15 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 900, displayName = "#Templates/NetBeansModuleDevelopment/newJavaHelp", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/newJavaHelp.png", description = "/org/netbeans/modules/apisupport/project/ui/resources/newJavaHelp.html", category = "nbm-specific")
10.16 public static NewJavaHelpIterator createIterator() {
10.17 return new NewJavaHelpIterator();
10.18 }
11.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/layer/NewLayerIterator.java Wed Jul 27 10:33:10 2011 +0200
11.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/layer/NewLayerIterator.java Wed Jul 27 10:35:25 2011 +0200
11.3 @@ -47,7 +47,9 @@
11.4 import org.openide.WizardDescriptor;
11.5 import org.openide.filesystems.FileObject;
11.6 import org.openide.filesystems.FileSystem;
11.7 +import org.netbeans.api.templates.TemplateRegistration;
11.8
11.9 +@TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 1300, displayName = "#template_label", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/layerObject.gif", description = "/org/netbeans/modules/apisupport/project/ui/resources/newLayer.html", category = "nbm-specific")
11.10 public class NewLayerIterator extends BasicWizardIterator {
11.11
11.12 private BasicDataModel data;
12.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/NewLibraryDescriptor.java Wed Jul 27 10:33:10 2011 +0200
12.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/NewLibraryDescriptor.java Wed Jul 27 10:35:25 2011 +0200
12.3 @@ -55,6 +55,7 @@
12.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
12.5 import org.openide.WizardDescriptor;
12.6 import org.openide.filesystems.FileSystem;
12.7 +import org.netbeans.api.templates.TemplateRegistration;
12.8
12.9 /**
12.10 * Wizard <em>J2SE Library Descriptor</em> for registering
12.11 @@ -66,6 +67,7 @@
12.12
12.13 NewLibraryDescriptor.DataModel data;
12.14
12.15 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 1100, displayName = "#Templates/NetBeansModuleDevelopment/emptyLibraryDescriptor", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/libraries.gif", description = "/org/netbeans/modules/apisupport/project/ui/resources/emptyLibraryDescriptor.html", category = "nbm-specific")
12.16 public static NewLibraryDescriptor createIterator() {
12.17 return new NewLibraryDescriptor();
12.18 }
13.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
13.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
13.3 @@ -42,7 +42,6 @@
13.4
13.5 # Sample ResourceBundle properties file
13.6 LBL_LoaderWizardTitle=File Type
13.7 -Templates/NetBeansModuleDevelopment/newLoader=File Type
13.8
13.9 # FileRecognitionPanel: texts of components
13.10 LBL_FileRecognition_Title=File Recognition
14.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NewLoaderIterator.java Wed Jul 27 10:33:10 2011 +0200
14.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NewLoaderIterator.java Wed Jul 27 10:35:25 2011 +0200
14.3 @@ -69,7 +69,9 @@
14.4 import org.openide.filesystems.FileUtil;
14.5 import org.openide.loaders.DataFolder;
14.6 import org.openide.loaders.DataObject;
14.7 +import org.netbeans.api.templates.TemplateRegistration;
14.8 import org.openide.modules.SpecificationVersion;
14.9 +import org.openide.util.NbBundle.Messages;
14.10 import org.openide.xml.XMLUtil;
14.11
14.12 /**
14.13 @@ -77,16 +79,19 @@
14.14 *
14.15 * @author Milos Kleint
14.16 */
14.17 -final class NewLoaderIterator extends BasicWizardIterator {
14.18 +@TemplateRegistration(
14.19 + folder="NetBeansModuleDevelopment",
14.20 + position=500,
14.21 + displayName="#template_loader",
14.22 + iconBase="org/netbeans/modules/apisupport/project/ui/resources/newLoader.png",
14.23 + description="../../resources/newLoader.html",
14.24 + category="nbm-specific"
14.25 +)
14.26 +@Messages("template_loader=File Type")
14.27 +public final class NewLoaderIterator extends BasicWizardIterator {
14.28
14.29 private NewLoaderIterator.DataModel data;
14.30
14.31 - private NewLoaderIterator() { /* Use factory method. */ };
14.32 -
14.33 - public static NewLoaderIterator createIterator() {
14.34 - return new NewLoaderIterator();
14.35 - }
14.36 -
14.37 public Set instantiate() throws IOException {
14.38 CreatedModifiedFiles cmf = data.getCreatedModifiedFiles();
14.39 cmf.run();
15.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/moduleinstall/NewModuleInstallIterator.java Wed Jul 27 10:33:10 2011 +0200
15.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/moduleinstall/NewModuleInstallIterator.java Wed Jul 27 10:35:25 2011 +0200
15.3 @@ -49,6 +49,7 @@
15.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles;
15.5 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
15.6 import org.openide.WizardDescriptor;
15.7 +import org.netbeans.api.templates.TemplateRegistration;
15.8
15.9 /**
15.10 * Wizard for creating Module Installer.
15.11 @@ -61,6 +62,7 @@
15.12
15.13 private NewModuleInstallIterator() {}
15.14
15.15 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 700, displayName = "#Templates/NetBeansModuleDevelopment/newModuleInstall", iconBase = "org/netbeans/modules/apisupport/project/ui/wizard/moduleinstall/module.png", description = "/org/netbeans/modules/apisupport/project/ui/resources/newModuleInstall.html", category = "nbm-specific")
15.16 public static NewModuleInstallIterator createIterator() {
15.17 return new NewModuleInstallIterator();
15.18 }
16.1 Binary file apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/moduleinstall/module.png has changed
17.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/options/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
17.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/options/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
17.3 @@ -41,7 +41,6 @@
17.4 # made subject to such option by the copyright holder.
17.5
17.6 LBL_OptionsWizardTitle=Options Panel
17.7 -Templates/NetBeansModuleDevelopment/newOptions=Options Panel
17.8
17.9 # NameAndLocationPanel: texts of components
17.10 LBL_OptionsPanel0_Title=Choose Panel Type
18.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/options/NewOptionsIterator.java Wed Jul 27 10:33:10 2011 +0200
18.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/options/NewOptionsIterator.java Wed Jul 27 10:35:25 2011 +0200
18.3 @@ -58,6 +58,8 @@
18.4 import org.netbeans.modules.apisupport.project.api.Util;
18.5 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
18.6 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
18.7 +import org.netbeans.api.templates.TemplateRegistration;
18.8 +import org.openide.util.NbBundle.Messages;
18.9 import org.openide.util.Utilities;
18.10 import org.openide.WizardDescriptor;
18.11 import org.openide.filesystems.FileObject;
18.12 @@ -71,16 +73,21 @@
18.13 * @author Radek Matous
18.14 * @author Max Sauer
18.15 */
18.16 -final class NewOptionsIterator extends BasicWizardIterator {
18.17 +@TemplateRegistration(
18.18 + folder="NetBeansModuleDevelopment",
18.19 + position=400,
18.20 + displayName="#template_options",
18.21 + iconBase="org/netbeans/modules/apisupport/project/ui/resources/newOptions.png",
18.22 + description="../../resources/newOptions.html",
18.23 + category="nbm-specific"
18.24 +)
18.25 +@Messages("template_options=Options Panel")
18.26 +public final class NewOptionsIterator extends BasicWizardIterator {
18.27
18.28 private NewOptionsIterator.DataModel data;
18.29
18.30 private NewOptionsIterator() { /* Use factory method. */ }
18.31
18.32 - public static NewOptionsIterator createIterator() {
18.33 - return new NewOptionsIterator();
18.34 - }
18.35 -
18.36 public Set instantiate() throws IOException {
18.37 CreatedModifiedFiles cmf = data.getCreatedModifiedFiles();
18.38 cmf.run();
19.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/project/NewProjectIterator.java Wed Jul 27 10:33:10 2011 +0200
19.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/project/NewProjectIterator.java Wed Jul 27 10:35:25 2011 +0200
19.3 @@ -73,6 +73,8 @@
19.4 import org.openide.filesystems.FileObject;
19.5 import org.openide.filesystems.FileSystem;
19.6 import org.openide.filesystems.FileUtil;
19.7 +import org.netbeans.api.templates.TemplateRegistration;
19.8 +import org.netbeans.api.templates.TemplateRegistration;
19.9
19.10 /**
19.11 * Wizard for creating new project templates.
19.12 @@ -93,8 +95,7 @@
19.13 "org.openide.awt", // NOI18N
19.14 };
19.15
19.16 - private NewProjectIterator() { /* Use factory method. */ };
19.17 -
19.18 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 1000, displayName = "#Templates/NetBeansModuleDevelopment/newProject", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/newProject.png", description = "/org/netbeans/modules/apisupport/project/ui/resources/newProject.html", category = "nbm-specific")
19.19 public static NewProjectIterator createIterator() {
19.20 return new NewProjectIterator();
19.21 }
20.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/quicksearch/NewQuickSearchIterator.java Wed Jul 27 10:33:10 2011 +0200
20.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/quicksearch/NewQuickSearchIterator.java Wed Jul 27 10:35:25 2011 +0200
20.3 @@ -51,6 +51,7 @@
20.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
20.5 import org.openide.WizardDescriptor;
20.6 import org.openide.filesystems.FileObject;
20.7 +import org.netbeans.api.templates.TemplateRegistration;
20.8
20.9 /**
20.10 * Wizard for creating new providers for QuickSearch SPI
20.11 @@ -80,6 +81,7 @@
20.12 * layer.xml entrypoint
20.13 * @return instance
20.14 */
20.15 + @TemplateRegistration(folder = "NetBeansModuleDevelopment", position = 800, displayName = "#Templates/NetBeansModuleDevelopment/newQuickSearch", iconBase = "org/netbeans/modules/apisupport/project/ui/resources/newQuickSearch.png", description = "/org/netbeans/modules/apisupport/project/ui/resources/newQuickSearch.html", category = "nbm-specific")
20.16 public static NewQuickSearchIterator createIterator() {
20.17 return new NewQuickSearchIterator();
20.18 }
21.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/updatecenter/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
21.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/updatecenter/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
21.3 @@ -40,7 +40,6 @@
21.4 # Version 2 license, then the option applies only if the new code is
21.5 # made subject to such option by the copyright holder.
21.6
21.7 -Templates/NetBeansModuleDevelopment/newUpdateCenter=Update Center
21.8
21.9 LBL_NewUpdateCenterWizardTitle=Update Center
21.10 LBL_UpdateCenterRegistrationPanel_Title=Update Center Declaration
22.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/updatecenter/NewUpdateCenterIterator.java Wed Jul 27 10:33:10 2011 +0200
22.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/updatecenter/NewUpdateCenterIterator.java Wed Jul 27 10:35:25 2011 +0200
22.3 @@ -51,20 +51,27 @@
22.4 import org.netbeans.modules.apisupport.project.api.LayerHandle;
22.5 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
22.6 import org.openide.WizardDescriptor;
22.7 +import org.netbeans.api.templates.TemplateRegistration;
22.8 +import org.openide.util.NbBundle.Messages;
22.9
22.10 /**
22.11 * Wizard for creating new update catalog.
22.12 *
22.13 * @author Jiri Rechtacek
22.14 */
22.15 -final class NewUpdateCenterIterator extends BasicWizardIterator {
22.16 +@TemplateRegistration(
22.17 + folder="NetBeansModuleDevelopment",
22.18 + position=600,
22.19 + displayName="#template_updatecenter",
22.20 + iconBase="org/netbeans/modules/apisupport/project/ui/resources/newUpdateCenter.png",
22.21 + description="../../resources/newUpdateCenter.html",
22.22 + category="nbm-specific"
22.23 +)
22.24 +@Messages("template_updatecenter=Update Center")
22.25 +public final class NewUpdateCenterIterator extends BasicWizardIterator {
22.26
22.27 private DataModel data;
22.28
22.29 - public static NewUpdateCenterIterator createIterator() {
22.30 - return new NewUpdateCenterIterator();
22.31 - }
22.32 -
22.33 public Set instantiate() throws IOException {
22.34 CreatedModifiedFiles cmf = data.refreshCreatedModifiedFiles();
22.35 cmf.run();
23.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
23.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
23.3 @@ -40,8 +40,6 @@
23.4 # Version 2 license, then the option applies only if the new code is
23.5 # made subject to such option by the copyright holder.
23.6
23.7 -# Sample ResourceBundle properties file
23.8 -Templates/NetBeansModuleDevelopment/newWindow=Window
23.9 LBL_TCWizardTitle=Window
23.10
23.11 # NameAndLocationPanel: texts of components
24.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java Wed Jul 27 10:33:10 2011 +0200
24.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java Wed Jul 27 10:35:25 2011 +0200
24.3 @@ -62,7 +62,9 @@
24.4 import org.openide.filesystems.FileObject;
24.5 import org.openide.filesystems.FileSystem;
24.6 import org.openide.filesystems.FileUtil;
24.7 +import org.netbeans.api.templates.TemplateRegistration;
24.8 import org.openide.modules.SpecificationVersion;
24.9 +import org.openide.util.NbBundle.Messages;
24.10 import org.openide.windows.WindowManager;
24.11
24.12 /**
24.13 @@ -70,16 +72,19 @@
24.14 *
24.15 * @author Milos Kleint
24.16 */
24.17 -final class NewTCIterator extends BasicWizardIterator {
24.18 +@TemplateRegistration(
24.19 + folder="NetBeansModuleDevelopment",
24.20 + position=200,
24.21 + displayName="#template_winsys",
24.22 + iconBase="org/netbeans/modules/apisupport/project/ui/resources/newTC.png",
24.23 + description="../../resources/newTC.html",
24.24 + category="nbm-specific"
24.25 +)
24.26 +@Messages("template_winsys=Window")
24.27 +public final class NewTCIterator extends BasicWizardIterator {
24.28
24.29 private NewTCIterator.DataModel data;
24.30
24.31 - private NewTCIterator() { /* Use factory method. */ };
24.32 -
24.33 - public static NewTCIterator createIterator() {
24.34 - return new NewTCIterator();
24.35 - }
24.36 -
24.37 public Set instantiate() throws IOException {
24.38 CreatedModifiedFiles cmf = data.getCreatedModifiedFiles();
24.39 cmf.run();
25.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/wizard/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
25.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/wizard/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
25.3 @@ -40,7 +40,6 @@
25.4 # Version 2 license, then the option applies only if the new code is
25.5 # made subject to such option by the copyright holder.
25.6
25.7 -Templates/NetBeansModuleDevelopment/newWizard=Wizard
25.8 LBL_WizardWizardTitle=Wizard
25.9
25.10 # Wizard Type panel (1.step)
26.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/wizard/NewWizardIterator.java Wed Jul 27 10:33:10 2011 +0200
26.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/wizard/NewWizardIterator.java Wed Jul 27 10:35:25 2011 +0200
26.3 @@ -49,22 +49,27 @@
26.4 import org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles;
26.5 import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
26.6 import org.openide.WizardDescriptor;
26.7 +import org.netbeans.api.templates.TemplateRegistration;
26.8 +import org.openide.util.NbBundle.Messages;
26.9
26.10 /**
26.11 * Wizard for creating new Wizards.
26.12 *
26.13 * @author Martin Krauskopf
26.14 */
26.15 -final class NewWizardIterator extends BasicWizardIterator {
26.16 +@TemplateRegistration(
26.17 + folder="NetBeansModuleDevelopment",
26.18 + position=300,
26.19 + displayName="#template_wizard",
26.20 + iconBase="org/netbeans/modules/apisupport/project/ui/resources/newWizard.png",
26.21 + description="../../resources/newWizard.html",
26.22 + category="nbm-specific"
26.23 +)
26.24 +@Messages("template_wizard=Wizard")
26.25 +public final class NewWizardIterator extends BasicWizardIterator {
26.26
26.27 private DataModel data;
26.28
26.29 - private NewWizardIterator() {}
26.30 -
26.31 - public static NewWizardIterator createIterator() {
26.32 - return new NewWizardIterator();
26.33 - }
26.34 -
26.35 public Set instantiate() throws IOException {
26.36 CreatedModifiedFiles cmf = data.getCreatedModifiedFiles();
26.37 cmf.run();
27.1 --- a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystemTest.java Wed Jul 27 10:33:10 2011 +0200
27.2 +++ b/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystemTest.java Wed Jul 27 10:35:25 2011 +0200
27.3 @@ -114,12 +114,15 @@
27.4 }
27.5
27.6 public void testExternalFileReads() throws Exception {
27.7 - FileSystem fs = new Layer("<file name='x' url='x.txt'/>", Collections.singletonMap("x.txt", "stuff")).read();
27.8 + Layer l = new Layer("<file name='x' url='x.txt'/>", Collections.singletonMap("x.txt", "stuff"));
27.9 + FileSystem fs = l.read();
27.10 FileObject x = fs.findResource("x");
27.11 assertNotNull(x);
27.12 assertTrue(x.isData());
27.13 assertEquals(5L, x.getSize());
27.14 assertEquals("stuff", x.asText("UTF-8"));
27.15 + assertEquals("x.txt", x.getAttribute("WritableXMLFileSystem.url"));
27.16 + assertEquals("[" + l.f.getURL() + "]", Arrays.toString((URL[]) x.getAttribute("layers")));
27.17 fs = new Layer("<file name='x' url='subdir/x.txt'/>", Collections.singletonMap("subdir/x.txt", "more stuff")).read();
27.18 x = fs.findResource("x");
27.19 assertNotNull(x);
27.20 @@ -533,7 +536,7 @@
27.21 " <folder name=\"f\"/>\n" +
27.22 " <file name=\"y\"/>\n",
27.23 l.write());
27.24 - assertEquals("no external files left", Collections.EMPTY_MAP, l.files());
27.25 + assertEquals("kept external file", Collections.singletonMap("x", "stuff"), l.files());
27.26 f.delete();
27.27 assertEquals("one file left",
27.28 " <file name=\"y\"/>\n",
27.29 @@ -547,7 +550,7 @@
27.30 TestUtil.dump(x, "stuff");
27.31 f.delete();
27.32 assertEquals("layer empty again", "", l.write());
27.33 - assertEquals("no external files left even after only implicitly deleting file", Collections.EMPTY_MAP, l.files());
27.34 + assertEquals("kept external files after implicitly deleting file", Collections.singletonMap("x", "stuff"), l.files());
27.35 // XXX should any associated ordering attrs also be deleted? not acc. to spec, but often handy...
27.36 l = new Layer("");
27.37 fs = l.read();
28.1 --- a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/ActionRegistrationHinter.java Wed Jul 27 10:33:10 2011 +0200
28.2 +++ b/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/ActionRegistrationHinter.java Wed Jul 27 10:35:25 2011 +0200
28.3 @@ -178,7 +178,7 @@
28.4 FileObject file = ctx.file();
28.5 params.put("category", file.getParent().getPath().substring("Actions/".length()));
28.6 params.put("id", file.getName().replace('-', '.'));
28.7 - ModifiersTree nue = ctx.addAnnotation(wc, modifiers, "org.openide.awt.ActionID", params);
28.8 + ModifiersTree nue = ctx.addAnnotation(wc, modifiers, "org.openide.awt.ActionID", null, params);
28.9 params.clear();
28.10 String displayName = ctx.bundlevalue(file.getAttribute("literal:displayName"), declaration);
28.11 if (displayName == null) {
28.12 @@ -192,7 +192,7 @@
28.13 params.put("iconInMenu", !((Boolean) noIconInMenu));
28.14 }
28.15 params.put("asynchronous", file.getAttribute("asynchronous"));
28.16 - nue = ctx.addAnnotation(wc, nue, "org.openide.awt.ActionRegistration", params);
28.17 + nue = ctx.addAnnotation(wc, nue, "org.openide.awt.ActionRegistration", null, params);
28.18 ctx.delete(file);
28.19 TreeMaker make = wc.getTreeMaker();
28.20 List<AnnotationTree> anns = new ArrayList<AnnotationTree>();
29.1 --- a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/Hinter.java Wed Jul 27 10:33:10 2011 +0200
29.2 +++ b/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/Hinter.java Wed Jul 27 10:35:25 2011 +0200
29.3 @@ -42,11 +42,16 @@
29.4
29.5 package org.netbeans.modules.apisupport.hints;
29.6
29.7 +import com.sun.source.tree.AnnotationTree;
29.8 +import com.sun.source.tree.AssignmentTree;
29.9 import com.sun.source.tree.ExpressionTree;
29.10 import com.sun.source.tree.ModifiersTree;
29.11 +import com.sun.source.tree.NewArrayTree;
29.12 +import com.sun.source.tree.Tree;
29.13 import java.io.IOException;
29.14 import java.util.ArrayList;
29.15 import java.util.Arrays;
29.16 +import java.util.Collections;
29.17 import java.util.List;
29.18 import java.util.Map;
29.19 import java.util.concurrent.Callable;
29.20 @@ -351,10 +356,12 @@
29.21 * @param wc Java source context
29.22 * @param modifiers the element's modifiers to append to
29.23 * @param type canonical name of the annotation type
29.24 - * @param parameters simple parameters of String or primitive type (null values are skipped)
29.25 + * @param pluralType if not null, canonical name of a plural variant of {@code type}
29.26 + * @param parameters simple parameters of String or primitive type or String[] (null values are skipped)
29.27 * @return the expanded modifiers tree
29.28 */
29.29 - public @CheckReturnValue ModifiersTree addAnnotation(WorkingCopy wc, ModifiersTree modifiers, String type, Map<String,Object> parameters) {
29.30 + // XXX ought to also accept CompilationUnitTree
29.31 + public @CheckReturnValue ModifiersTree addAnnotation(WorkingCopy wc, ModifiersTree modifiers, String type, @NullAllowed String pluralType, Map<String,Object> parameters) {
29.32 TreeMaker make = wc.getTreeMaker();
29.33 TypeElement ann = wc.getElements().getTypeElement(type);
29.34 if (ann == null) {
29.35 @@ -363,11 +370,64 @@
29.36 }
29.37 List<ExpressionTree> arguments = new ArrayList<ExpressionTree>();
29.38 for (Map.Entry<String,Object> entry : parameters.entrySet()) {
29.39 - if (entry.getValue() != null) {
29.40 - arguments.add(make.Assignment(make.Identifier(entry.getKey()), make.Literal(entry.getValue())));
29.41 + Object value = entry.getValue();
29.42 + ExpressionTree valueTree;
29.43 + if (value instanceof Object[]) {
29.44 + Object[] array = (Object[]) value;
29.45 + if (array.length == 1) {
29.46 + valueTree = make.Literal(array[0]);
29.47 + } else {
29.48 + List<ExpressionTree> elements = new ArrayList<ExpressionTree>();
29.49 + for (Object o : array) {
29.50 + elements.add(make.Literal(o));
29.51 + }
29.52 + valueTree = make.NewArray(null, Collections.<ExpressionTree>emptyList(), elements);
29.53 + }
29.54 + } else if (value != null) {
29.55 + valueTree = make.Literal(value);
29.56 + } else {
29.57 + continue;
29.58 + }
29.59 + arguments.add(make.Assignment(make.Identifier(entry.getKey()), valueTree));
29.60 + }
29.61 + AnnotationTree toAdd = make.Annotation(make.QualIdent(ann), arguments);
29.62 + if (pluralType != null) {
29.63 + List<? extends AnnotationTree> existingAnns = modifiers.getAnnotations();
29.64 + for (int i = 0; i < existingAnns.size(); i++) {
29.65 + AnnotationTree existingAnn = existingAnns.get(i);
29.66 + // XXX see UseNbBundleMessages; is there a better way to do this?
29.67 + String existingType = existingAnn.getAnnotationType().toString();
29.68 + // XXX this will not work if type is a nested class
29.69 + if (existingType.equals(type) || existingType.equals(type.replaceFirst(".+[.]", ""))) {
29.70 + return make.insertModifiersAnnotation(make.removeModifiersAnnotation(modifiers, i), i,
29.71 + make.Annotation(make.QualIdent(pluralType),
29.72 + Collections.singletonList(make.Assignment(make.Identifier("value"),
29.73 + make.NewArray(null, Collections.<ExpressionTree>emptyList(), Arrays.asList(existingAnn, toAdd))))));
29.74 + } else if (existingType.equals(pluralType) || existingType.equals(pluralType.replaceFirst(".+[.]", ""))) {
29.75 + List<? extends ExpressionTree> args = existingAnn.getArguments();
29.76 + if (args.size() != 1) {
29.77 + throw new IllegalArgumentException("expecting just one arg for @" + pluralType);
29.78 + }
29.79 + AssignmentTree assign = (AssignmentTree) args.get(0);
29.80 + if (!assign.getVariable().toString().equals("value")) {
29.81 + throw new IllegalArgumentException("expected value=... for @" + pluralType);
29.82 + }
29.83 + ExpressionTree arg = assign.getExpression();
29.84 + NewArrayTree arr;
29.85 + if (arg.getKind() == Tree.Kind.STRING_LITERAL) {
29.86 + arr = make.NewArray(null, Collections.<ExpressionTree>emptyList(), Collections.singletonList(arg));
29.87 + } else if (arg.getKind() == Tree.Kind.NEW_ARRAY) {
29.88 + arr = (NewArrayTree) arg;
29.89 + } else {
29.90 + throw new IllegalArgumentException("unknown arg kind " + arg.getKind() + ": " + arg);
29.91 + }
29.92 + return make.insertModifiersAnnotation(make.removeModifiersAnnotation(modifiers, i), i,
29.93 + make.Annotation(existingAnn.getAnnotationType(),
29.94 + Collections.singletonList(make.Assignment(assign.getVariable(), make.addNewArrayInitializer(arr, toAdd)))));
29.95 + }
29.96 }
29.97 }
29.98 - return make.addModifiersAnnotation(modifiers, make.Annotation(make.QualIdent(ann), arguments));
29.99 + return make.addModifiersAnnotation(modifiers, toAdd);
29.100 }
29.101
29.102 /**
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/TemplateHinter.java Wed Jul 27 10:35:25 2011 +0200
30.3 @@ -0,0 +1,179 @@
30.4 +/*
30.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
30.6 + *
30.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
30.8 + *
30.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
30.10 + * Other names may be trademarks of their respective owners.
30.11 + *
30.12 + * The contents of this file are subject to the terms of either the GNU
30.13 + * General Public License Version 2 only ("GPL") or the Common Development and
30.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
30.15 + * this file except in compliance with the License. You can obtain a copy of
30.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
30.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
30.18 + * governing permissions and limitations under the License. When distributing
30.19 + * the software, include this License Header Notice in each file and include
30.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
30.21 + * particular file as subject to the "Classpath" exception as provided by
30.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
30.23 + * this code. If applicable, add the following below the License Header, with
30.24 + * the fields enclosed by brackets [] replaced by your own identifying
30.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
30.26 + *
30.27 + * If you wish your version of this file to be governed by only the CDDL or
30.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
30.29 + * elects to include this software in this distribution under the [CDDL or GPL
30.30 + * Version 2] license." If you do not indicate a single choice of license, a
30.31 + * recipient has the option to distribute your version of this file under
30.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
30.33 + * licensees as provided above. However, if you add GPL Version 2 code and
30.34 + * therefore, elected the GPL Version 2 license, then the option applies only
30.35 + * if the new code is made subject to such option by the copyright holder.
30.36 + *
30.37 + * Contributor(s):
30.38 + *
30.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
30.40 + */
30.41 +
30.42 +package org.netbeans.modules.apisupport.hints;
30.43 +
30.44 +import org.netbeans.api.templates.TemplateRegistrations;
30.45 +import java.net.URI;
30.46 +import org.netbeans.api.java.classpath.ClassPath;
30.47 +import java.util.LinkedHashMap;
30.48 +import com.sun.source.tree.ModifiersTree;
30.49 +import java.net.URL;
30.50 +import java.util.Map;
30.51 +import java.util.concurrent.Callable;
30.52 +import javax.lang.model.element.Element;
30.53 +import org.netbeans.api.java.source.GeneratorUtilities;
30.54 +import org.netbeans.api.java.source.WorkingCopy;
30.55 +import org.netbeans.api.templates.TemplateRegistration;
30.56 +import org.netbeans.modules.apisupport.hints.Hinter.Context;
30.57 +import org.netbeans.spi.editor.hints.Severity;
30.58 +import org.openide.DialogDisplayer;
30.59 +import org.openide.NotifyDescriptor;
30.60 +import org.openide.filesystems.FileObject;
30.61 +import org.openide.filesystems.FileUtil;
30.62 +import org.openide.filesystems.URLMapper;
30.63 +import org.openide.util.NbBundle.Messages;
30.64 +import org.openide.util.NbCollections;
30.65 +import org.openide.util.lookup.ServiceProvider;
30.66 +import static org.netbeans.modules.apisupport.hints.Bundle.*;
30.67 +
30.68 +@ServiceProvider(service=Hinter.class)
30.69 +public class TemplateHinter implements Hinter {
30.70 +
30.71 + @Messages({
30.72 + "TemplateHinter_content_file=Replace with @Template",
30.73 + "# {0} - file attribute name", "TemplateHinter_unrecognized_attr=Unrecognized template attribute: {0}",
30.74 + "# {0} - current name and extension", "# {1} - inferred name and extension", "TemplateHinter_basename_mismatch=Current url attribute would make template be named {1} rather than {0}"
30.75 + })
30.76 + public @Override void process(final Context ctx) throws Exception {
30.77 + final FileObject file = ctx.file();
30.78 + if (!file.isData()) {
30.79 + return;
30.80 + }
30.81 + Object iterator = file.getAttribute("literal:instantiatingIterator");
30.82 + if (iterator == null) {
30.83 + iterator = file.getAttribute("literal:templateWizardIterator");
30.84 + }
30.85 + if (iterator == null) {
30.86 + if (Boolean.TRUE.equals(file.getAttribute("template"))) {
30.87 + // XXX currently cannot add simple templates to package-info.java
30.88 + ctx.addHint(Severity.WARNING, TemplateHinter_content_file());
30.89 + }
30.90 + return;
30.91 + }
30.92 + final String url = (String) file.getAttribute("WritableXMLFileSystem.url");
30.93 + if (url == null && file.getSize() > 0) {
30.94 + // XXX cannot handle inline content
30.95 + ctx.addHint(Severity.WARNING, TemplateHinter_content_file());
30.96 + return;
30.97 + }
30.98 + if (url != null) {
30.99 + String basename = basename(url);
30.100 + if (!basename.equals(file.getNameExt())) {
30.101 + ctx.addHint(Severity.WARNING, TemplateHinter_basename_mismatch(file.getNameExt(), basename));
30.102 + return;
30.103 + }
30.104 + }
30.105 + for (String attr : NbCollections.iterable(file.getAttributes())) {
30.106 + if (!attr.matches("instantiatingIterator|templateWizardIterator|template|displayName|iconBase|position|instantiatingWizardURL|templateWizardURL|templateCategory|javax[.]script[.]ScriptEngine")) {
30.107 + ctx.addHint(Severity.WARNING, TemplateHinter_unrecognized_attr(attr));
30.108 + return;
30.109 + }
30.110 + }
30.111 + final Object _iterator = iterator;
30.112 + ctx.addStandardAnnotationHint(new Callable<Void>() {
30.113 + public @Override Void call() throws Exception {
30.114 + if (!annotationsAvailable(ctx)) {
30.115 + return null;
30.116 + }
30.117 + ctx.findAndModifyDeclaration(_iterator, new Context.ModifyDeclarationTask() {
30.118 + public @Override void run(WorkingCopy wc, Element declaration, ModifiersTree modifiers) throws Exception {
30.119 + Map<String,Object> params = new LinkedHashMap<String,Object>();
30.120 + FileObject file = ctx.file();
30.121 + params.put("folder", FileUtil.getRelativePath(file.getFileSystem().findResource("Templates"), file.getParent()));
30.122 + params.put("position", file.getAttribute("position"));
30.123 + if (url != null) {
30.124 + URI u = new URI(url);
30.125 + if (!u.isAbsolute()) {
30.126 + URL[] layers = (URL[]) file.getAttribute("layers");
30.127 + assert layers != null && layers.length == 1;
30.128 + FileObject layer = URLMapper.findFileObject(layers[0]);
30.129 + if (layer != null) {
30.130 + ClassPath src = ClassPath.getClassPath(layer, ClassPath.SOURCE);
30.131 + String path = src.getResourceName(layer);
30.132 + if (path != null) {
30.133 + u = new URI("nbres", "/" + path, null).resolve(u);
30.134 + }
30.135 + }
30.136 + }
30.137 + if (u.getScheme() != null && u.getScheme().matches("nbres(loc)?")) {
30.138 + // XXX could relativize it
30.139 + params.put("content", u.getPath());
30.140 + }
30.141 + }
30.142 + params.put("scriptEngine", file.getAttribute("javax.script.ScriptEngine"));
30.143 + params.put("displayName", ctx.bundlevalue(file.getAttribute("literal:displayName"), declaration));
30.144 + params.put("iconBase", file.getAttribute("iconBase"));
30.145 + URL desc = (URL) file.getAttribute("instantiatingWizardURL");
30.146 + if (desc == null) {
30.147 + desc = (URL) file.getAttribute("templateWizardURL");
30.148 + }
30.149 + if (desc != null) {
30.150 + // XXX could relativize it
30.151 + params.put("description", desc.getPath());
30.152 + }
30.153 + String category = (String) file.getAttribute("templateCategory");
30.154 + if (category != null) {
30.155 + params.put("category", category.split(", ?"));
30.156 + }
30.157 + ModifiersTree nue = ctx.addAnnotation(wc, modifiers, TemplateRegistration.class.getName(), TemplateRegistrations.class.getName(), params);
30.158 + ctx.delete(file);
30.159 + wc.rewrite(modifiers, GeneratorUtilities.get(wc).importFQNs(nue));
30.160 + }
30.161 + });
30.162 + return null;
30.163 + }
30.164 + });
30.165 + }
30.166 +
30.167 + @Messages("TemplateHinter.missing_dep=You must add a dependency on org.openide.loaders (7.29+) before using this fix.")
30.168 + private boolean annotationsAvailable(Context ctx) {
30.169 + if (ctx.canAccess(TemplateRegistration.class.getName())) {
30.170 + return true;
30.171 + } else {
30.172 + DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(TemplateHinter_missing_dep(), NotifyDescriptor.WARNING_MESSAGE));
30.173 + return false;
30.174 + }
30.175 + }
30.176 +
30.177 + // copied from TemplateProcessor
30.178 + private static String basename(String relativeResource) {
30.179 + return relativeResource.replaceFirst(".+/", "").replaceFirst("[.]template$", "");
30.180 + }
30.181 +
30.182 +}
31.1 --- a/beans/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
31.2 +++ b/beans/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
31.3 @@ -137,6 +137,15 @@
31.4 </run-dependency>
31.5 </dependency>
31.6 <dependency>
31.7 + <code-name-base>org.netbeans.modules.java.project</code-name-base>
31.8 + <build-prerequisite/>
31.9 + <compile-dependency/>
31.10 + <run-dependency>
31.11 + <release-version>1</release-version>
31.12 + <specification-version>1.40</specification-version>
31.13 + </run-dependency>
31.14 + </dependency>
31.15 + <dependency>
31.16 <code-name-base>org.netbeans.modules.java.source</code-name-base>
31.17 <build-prerequisite/>
31.18 <compile-dependency/>
32.1 --- a/beans/src/org/netbeans/modules/beans/beaninfo/BIDataLoader.java Wed Jul 27 10:33:10 2011 +0200
32.2 +++ b/beans/src/org/netbeans/modules/beans/beaninfo/BIDataLoader.java Wed Jul 27 10:35:25 2011 +0200
32.3 @@ -91,6 +91,9 @@
32.4
32.5 @Override
32.6 protected FileObject findPrimaryFile(FileObject fo) {
32.7 + if (fo.getAttribute("template") != null && fo.getAttribute("javax.script.ScriptEngine") != null) {
32.8 + return null; // as in JavaDataLoader
32.9 + }
32.10 return isBeanInfo(fo)? fo: null;
32.11 }
32.12
33.1 --- a/beans/src/org/netbeans/modules/beans/resources/Bean.html Wed Jul 27 10:33:10 2011 +0200
33.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
33.3 @@ -1,50 +0,0 @@
33.4 -<!--
33.5 - -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33.6 - --
33.7 - -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
33.8 - --
33.9 - -- The contents of this file are subject to the terms of either the GNU
33.10 - -- General Public License Version 2 only ("GPL") or the Common
33.11 - -- Development and Distribution License("CDDL") (collectively, the
33.12 - -- "License"). You may not use this file except in compliance with the
33.13 - -- License. You can obtain a copy of the License at
33.14 - -- http://www.netbeans.org/cddl-gplv2.html
33.15 - -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
33.16 - -- specific language governing permissions and limitations under the
33.17 - -- License. When distributing the software, include this License Header
33.18 - -- Notice in each file and include the License file at
33.19 - -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
33.20 - -- particular file as subject to the "Classpath" exception as provided
33.21 - -- by Sun in the GPL Version 2 section of the License file that
33.22 - -- accompanied this code. If applicable, add the following below the
33.23 - -- License Header, with the fields enclosed by brackets [] replaced by
33.24 - -- your own identifying information:
33.25 - -- "Portions Copyrighted [year] [name of copyright owner]"
33.26 - --
33.27 - -- Contributor(s):
33.28 - --
33.29 - -- The Original Software is NetBeans. The Initial Developer of the Original
33.30 - -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
33.31 - -- Microsystems, Inc. All Rights Reserved.
33.32 - --
33.33 - -- If you wish your version of this file to be governed by only the CDDL
33.34 - -- or only the GPL Version 2, indicate your decision by adding
33.35 - -- "[Contributor] elects to include this software in this distribution
33.36 - -- under the [CDDL or GPL Version 2] license." If you do not indicate a
33.37 - -- single choice of license, a recipient has the option to distribute
33.38 - -- your version of this file under either the CDDL, the GPL Version 2 or
33.39 - -- to extend the choice of license to its licensees as provided above.
33.40 - -- However, if you add GPL Version 2 code and therefore, elected the GPL
33.41 - -- Version 2 license, then the option applies only if the new code is
33.42 - -- made subject to such option by the copyright holder.
33.43 - -->
33.44 -
33.45 -<html>
33.46 -<head>
33.47 - <meta http-equiv="content-type" content="text/html; charset=UTF-8">
33.48 -</head>
33.49 -
33.50 -<BODY>
33.51 -Creates a new JavaBeans component. The created skeleton code contains a
33.52 -sample property and property change support.
33.53 -</BODY></HTML>
34.1 --- a/beans/src/org/netbeans/modules/beans/resources/BeanInfo.html Wed Jul 27 10:33:10 2011 +0200
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,50 +0,0 @@
34.4 -<!--
34.5 - -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
34.6 - --
34.7 - -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
34.8 - --
34.9 - -- The contents of this file are subject to the terms of either the GNU
34.10 - -- General Public License Version 2 only ("GPL") or the Common
34.11 - -- Development and Distribution License("CDDL") (collectively, the
34.12 - -- "License"). You may not use this file except in compliance with the
34.13 - -- License. You can obtain a copy of the License at
34.14 - -- http://www.netbeans.org/cddl-gplv2.html
34.15 - -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
34.16 - -- specific language governing permissions and limitations under the
34.17 - -- License. When distributing the software, include this License Header
34.18 - -- Notice in each file and include the License file at
34.19 - -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
34.20 - -- particular file as subject to the "Classpath" exception as provided
34.21 - -- by Sun in the GPL Version 2 section of the License file that
34.22 - -- accompanied this code. If applicable, add the following below the
34.23 - -- License Header, with the fields enclosed by brackets [] replaced by
34.24 - -- your own identifying information:
34.25 - -- "Portions Copyrighted [year] [name of copyright owner]"
34.26 - --
34.27 - -- Contributor(s):
34.28 - --
34.29 - -- The Original Software is NetBeans. The Initial Developer of the Original
34.30 - -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
34.31 - -- Microsystems, Inc. All Rights Reserved.
34.32 - --
34.33 - -- If you wish your version of this file to be governed by only the CDDL
34.34 - -- or only the GPL Version 2, indicate your decision by adding
34.35 - -- "[Contributor] elects to include this software in this distribution
34.36 - -- under the [CDDL or GPL Version 2] license." If you do not indicate a
34.37 - -- single choice of license, a recipient has the option to distribute
34.38 - -- your version of this file under either the CDDL, the GPL Version 2 or
34.39 - -- to extend the choice of license to its licensees as provided above.
34.40 - -- However, if you add GPL Version 2 code and therefore, elected the GPL
34.41 - -- Version 2 license, then the option applies only if the new code is
34.42 - -- made subject to such option by the copyright holder.
34.43 - -->
34.44 -
34.45 -<html>
34.46 -<head>
34.47 - <meta http-equiv="content-type" content="text/html; charset=UTF-8">
34.48 -</head>
34.49 -<BODY>
34.50 -Creates a new <code>BeanInfo</code> class. The BeanInfo is used as a
34.51 -description of how its associated JavaBeans component should behave and
34.52 -appear.
34.53 -</BODY></HTML>
35.1 --- a/beans/src/org/netbeans/modules/beans/resources/Beans.html Wed Jul 27 10:33:10 2011 +0200
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,48 +0,0 @@
35.4 -<!--
35.5 - -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
35.6 - --
35.7 - -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
35.8 - --
35.9 - -- The contents of this file are subject to the terms of either the GNU
35.10 - -- General Public License Version 2 only ("GPL") or the Common
35.11 - -- Development and Distribution License("CDDL") (collectively, the
35.12 - -- "License"). You may not use this file except in compliance with the
35.13 - -- License. You can obtain a copy of the License at
35.14 - -- http://www.netbeans.org/cddl-gplv2.html
35.15 - -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
35.16 - -- specific language governing permissions and limitations under the
35.17 - -- License. When distributing the software, include this License Header
35.18 - -- Notice in each file and include the License file at
35.19 - -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
35.20 - -- particular file as subject to the "Classpath" exception as provided
35.21 - -- by Sun in the GPL Version 2 section of the License file that
35.22 - -- accompanied this code. If applicable, add the following below the
35.23 - -- License Header, with the fields enclosed by brackets [] replaced by
35.24 - -- your own identifying information:
35.25 - -- "Portions Copyrighted [year] [name of copyright owner]"
35.26 - --
35.27 - -- Contributor(s):
35.28 - --
35.29 - -- The Original Software is NetBeans. The Initial Developer of the Original
35.30 - -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
35.31 - -- Microsystems, Inc. All Rights Reserved.
35.32 - --
35.33 - -- If you wish your version of this file to be governed by only the CDDL
35.34 - -- or only the GPL Version 2, indicate your decision by adding
35.35 - -- "[Contributor] elects to include this software in this distribution
35.36 - -- under the [CDDL or GPL Version 2] license." If you do not indicate a
35.37 - -- single choice of license, a recipient has the option to distribute
35.38 - -- your version of this file under either the CDDL, the GPL Version 2 or
35.39 - -- to extend the choice of license to its licensees as provided above.
35.40 - -- However, if you add GPL Version 2 code and therefore, elected the GPL
35.41 - -- Version 2 license, then the option applies only if the new code is
35.42 - -- made subject to such option by the copyright holder.
35.43 - -->
35.44 -
35.45 -<html>
35.46 -<head>
35.47 - <meta http-equiv="content-type" content="text/html; charset=UTF-8">
35.48 -</head>
35.49 -<BODY>
35.50 -This category includes several types of classes that will help you create JavaBeans components.
35.51 -</BODY></HTML>
36.1 --- a/beans/src/org/netbeans/modules/beans/resources/Customizer.html Wed Jul 27 10:33:10 2011 +0200
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,49 +0,0 @@
36.4 -<!--
36.5 - -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
36.6 - --
36.7 - -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
36.8 - --
36.9 - -- The contents of this file are subject to the terms of either the GNU
36.10 - -- General Public License Version 2 only ("GPL") or the Common
36.11 - -- Development and Distribution License("CDDL") (collectively, the
36.12 - -- "License"). You may not use this file except in compliance with the
36.13 - -- License. You can obtain a copy of the License at
36.14 - -- http://www.netbeans.org/cddl-gplv2.html
36.15 - -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
36.16 - -- specific language governing permissions and limitations under the
36.17 - -- License. When distributing the software, include this License Header
36.18 - -- Notice in each file and include the License file at
36.19 - -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
36.20 - -- particular file as subject to the "Classpath" exception as provided
36.21 - -- by Sun in the GPL Version 2 section of the License file that
36.22 - -- accompanied this code. If applicable, add the following below the
36.23 - -- License Header, with the fields enclosed by brackets [] replaced by
36.24 - -- your own identifying information:
36.25 - -- "Portions Copyrighted [year] [name of copyright owner]"
36.26 - --
36.27 - -- Contributor(s):
36.28 - --
36.29 - -- The Original Software is NetBeans. The Initial Developer of the Original
36.30 - -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
36.31 - -- Microsystems, Inc. All Rights Reserved.
36.32 - --
36.33 - -- If you wish your version of this file to be governed by only the CDDL
36.34 - -- or only the GPL Version 2, indicate your decision by adding
36.35 - -- "[Contributor] elects to include this software in this distribution
36.36 - -- under the [CDDL or GPL Version 2] license." If you do not indicate a
36.37 - -- single choice of license, a recipient has the option to distribute
36.38 - -- your version of this file under either the CDDL, the GPL Version 2 or
36.39 - -- to extend the choice of license to its licensees as provided above.
36.40 - -- However, if you add GPL Version 2 code and therefore, elected the GPL
36.41 - -- Version 2 license, then the option applies only if the new code is
36.42 - -- made subject to such option by the copyright holder.
36.43 - -->
36.44 -
36.45 -<html>
36.46 -<head>
36.47 - <meta http-equiv="content-type" content="text/html; charset=UTF-8">
36.48 -</head>
36.49 -<BODY>
36.50 -Creates a Customizer panel for a JavaBeans component. The customizer can then be
36.51 -used during design time in the IDE to configure the bean.
36.52 -</BODY></HTML>
37.1 --- a/beans/src/org/netbeans/modules/beans/resources/PropertyEditor.html Wed Jul 27 10:33:10 2011 +0200
37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
37.3 @@ -1,49 +0,0 @@
37.4 -<!--
37.5 - -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
37.6 - --
37.7 - -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
37.8 - --
37.9 - -- The contents of this file are subject to the terms of either the GNU
37.10 - -- General Public License Version 2 only ("GPL") or the Common
37.11 - -- Development and Distribution License("CDDL") (collectively, the
37.12 - -- "License"). You may not use this file except in compliance with the
37.13 - -- License. You can obtain a copy of the License at
37.14 - -- http://www.netbeans.org/cddl-gplv2.html
37.15 - -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
37.16 - -- specific language governing permissions and limitations under the
37.17 - -- License. When distributing the software, include this License Header
37.18 - -- Notice in each file and include the License file at
37.19 - -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
37.20 - -- particular file as subject to the "Classpath" exception as provided
37.21 - -- by Sun in the GPL Version 2 section of the License file that
37.22 - -- accompanied this code. If applicable, add the following below the
37.23 - -- License Header, with the fields enclosed by brackets [] replaced by
37.24 - -- your own identifying information:
37.25 - -- "Portions Copyrighted [year] [name of copyright owner]"
37.26 - --
37.27 - -- Contributor(s):
37.28 - --
37.29 - -- The Original Software is NetBeans. The Initial Developer of the Original
37.30 - -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
37.31 - -- Microsystems, Inc. All Rights Reserved.
37.32 - --
37.33 - -- If you wish your version of this file to be governed by only the CDDL
37.34 - -- or only the GPL Version 2, indicate your decision by adding
37.35 - -- "[Contributor] elects to include this software in this distribution
37.36 - -- under the [CDDL or GPL Version 2] license." If you do not indicate a
37.37 - -- single choice of license, a recipient has the option to distribute
37.38 - -- your version of this file under either the CDDL, the GPL Version 2 or
37.39 - -- to extend the choice of license to its licensees as provided above.
37.40 - -- However, if you add GPL Version 2 code and therefore, elected the GPL
37.41 - -- Version 2 license, then the option applies only if the new code is
37.42 - -- made subject to such option by the copyright holder.
37.43 - -->
37.44 -
37.45 -<html>
37.46 -<head>
37.47 - <meta http-equiv="content-type" content="text/html; charset=UTF-8">
37.48 -</head>
37.49 -<BODY>
37.50 -Creates a <code>PropertyEditor</code> class. Property editors are used
37.51 -at design time in IDEs to support editing of the properties of JavaBeans components.
37.52 -</BODY></HTML>
38.1 --- a/beans/src/org/netbeans/modules/beans/resources/mf-layer.xml Wed Jul 27 10:33:10 2011 +0200
38.2 +++ b/beans/src/org/netbeans/modules/beans/resources/mf-layer.xml Wed Jul 27 10:35:25 2011 +0200
38.3 @@ -43,76 +43,19 @@
38.4 Version 2 license, then the option applies only if the new code is
38.5 made subject to such option by the copyright holder.
38.6 -->
38.7 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
38.8 -
38.9 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
38.10 <filesystem>
38.11 - <folder name="Templates">
38.12 - <folder name="Beans">
38.13 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/Beans.html" />
38.14 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.15 - <attr name="position" intvalue="1052"/>
38.16 - <file name="Bean.java" url="templates/Bean.template">
38.17 - <attr name="position" intvalue="100"/>
38.18 - <attr name="template" boolvalue="true" />
38.19 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
38.20 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/Bean.html" />
38.21 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.22 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
38.23 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.24 - <attr name="templateCategory" stringvalue="java-beans"/>
38.25 - </file>
38.26 - <file name="BeanInfo.java" url="templates/BeanInfo.template">
38.27 - <attr name="position" intvalue="200"/>
38.28 - <attr name="template" boolvalue="true" />
38.29 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
38.30 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.31 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
38.32 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/BeanInfo.html" />
38.33 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.34 - <attr name="templateCategory" stringvalue="java-beans"/>
38.35 - </file>
38.36 - <file name="NoIconBeanInfo.java" url="templates/BeanInfoNoIcon.template">
38.37 - <attr name="position" intvalue="300"/>
38.38 - <attr name="template" boolvalue="true" />
38.39 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
38.40 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/BeanInfo.html" />
38.41 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.42 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.43 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
38.44 - <attr name="templateCategory" stringvalue="java-beans"/>
38.45 - </file>
38.46 - <file name="Customizer.java" url="templates/Customizer.template">
38.47 - <attr name="position" intvalue="400"/>
38.48 - <attr name="template" boolvalue="true" />
38.49 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
38.50 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/Customizer.html" />
38.51 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.52 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.53 - <attr name="templateCategory" stringvalue="java-beans"/>
38.54 - </file>
38.55 - <file name="Customizer.form" url="templates/Customizer.form.template">
38.56 - <attr name="position" intvalue="500"/>
38.57 - <attr name="template" boolvalue="true" />
38.58 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/Customizer.html" />
38.59 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.60 - <attr name="templateCategory" stringvalue="java-beans"/>
38.61 - </file>
38.62 - <file name="PropertyEditor.java" url="templates/PropertyEditor.template">
38.63 - <attr name="position" intvalue="600"/>
38.64 - <attr name="template" boolvalue="true" />
38.65 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
38.66 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/PropertyEditor.html" />
38.67 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator" />
38.68 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.beans.Bundle"/>
38.69 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
38.70 - <attr name="templateCategory" stringvalue="java-beans"/>
38.71 - </file>
38.72 - <file name="Package.shadow">
38.73 - <attr name="position" intvalue="700"/>
38.74 - <attr name="originalFile" stringvalue="Templates/Classes/Package"/>
38.75 - </file>
38.76 + <folder name="Templates">
38.77 + <folder name="Beans">
38.78 + <attr name="displayName" bundlevalue="org.netbeans.modules.beans.Bundle#Templates/Beans"/>
38.79 + <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/beans/resources/templates/Beans.html"/>
38.80 + <attr name="position" intvalue="1052"/>
38.81 + <file name="Package.shadow">
38.82 + <attr name="position" intvalue="700"/>
38.83 + <attr name="originalFile" stringvalue="Templates/Classes/Package"/>
38.84 + </file>
38.85 + </folder>
38.86 </folder>
38.87 - </folder>
38.88 <folder name="Navigator">
38.89 <folder name="Panels">
38.90 <folder name="text">
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Bean.html Wed Jul 27 10:35:25 2011 +0200
39.3 @@ -0,0 +1,50 @@
39.4 +<!--
39.5 + -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39.6 + --
39.7 + -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
39.8 + --
39.9 + -- The contents of this file are subject to the terms of either the GNU
39.10 + -- General Public License Version 2 only ("GPL") or the Common
39.11 + -- Development and Distribution License("CDDL") (collectively, the
39.12 + -- "License"). You may not use this file except in compliance with the
39.13 + -- License. You can obtain a copy of the License at
39.14 + -- http://www.netbeans.org/cddl-gplv2.html
39.15 + -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
39.16 + -- specific language governing permissions and limitations under the
39.17 + -- License. When distributing the software, include this License Header
39.18 + -- Notice in each file and include the License file at
39.19 + -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
39.20 + -- particular file as subject to the "Classpath" exception as provided
39.21 + -- by Sun in the GPL Version 2 section of the License file that
39.22 + -- accompanied this code. If applicable, add the following below the
39.23 + -- License Header, with the fields enclosed by brackets [] replaced by
39.24 + -- your own identifying information:
39.25 + -- "Portions Copyrighted [year] [name of copyright owner]"
39.26 + --
39.27 + -- Contributor(s):
39.28 + --
39.29 + -- The Original Software is NetBeans. The Initial Developer of the Original
39.30 + -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
39.31 + -- Microsystems, Inc. All Rights Reserved.
39.32 + --
39.33 + -- If you wish your version of this file to be governed by only the CDDL
39.34 + -- or only the GPL Version 2, indicate your decision by adding
39.35 + -- "[Contributor] elects to include this software in this distribution
39.36 + -- under the [CDDL or GPL Version 2] license." If you do not indicate a
39.37 + -- single choice of license, a recipient has the option to distribute
39.38 + -- your version of this file under either the CDDL, the GPL Version 2 or
39.39 + -- to extend the choice of license to its licensees as provided above.
39.40 + -- However, if you add GPL Version 2 code and therefore, elected the GPL
39.41 + -- Version 2 license, then the option applies only if the new code is
39.42 + -- made subject to such option by the copyright holder.
39.43 + -->
39.44 +
39.45 +<html>
39.46 +<head>
39.47 + <meta http-equiv="content-type" content="text/html; charset=UTF-8">
39.48 +</head>
39.49 +
39.50 +<BODY>
39.51 +Creates a new JavaBeans component. The created skeleton code contains a
39.52 +sample property and property change support.
39.53 +</BODY></HTML>
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Bean.java.template Wed Jul 27 10:35:25 2011 +0200
40.3 @@ -0,0 +1,49 @@
40.4 +<#-- FreeMarker template (see http://freemarker.org/) -->
40.5 +<#assign licenseFirst = "/*">
40.6 +<#assign licensePrefix = " * ">
40.7 +<#assign licenseLast = " */">
40.8 +<#include "../Licenses/license-${project.license}.txt">
40.9 +
40.10 +<#if package?? && package != "">
40.11 +package ${package};
40.12 +
40.13 +</#if>
40.14 +import java.beans.*;
40.15 +import java.io.Serializable;
40.16 +
40.17 +/**
40.18 + *
40.19 + * @author ${user}
40.20 + */
40.21 +public class ${name} implements Serializable {
40.22 +
40.23 + public static final String PROP_SAMPLE_PROPERTY = "sampleProperty";
40.24 +
40.25 + private String sampleProperty;
40.26 +
40.27 + private PropertyChangeSupport propertySupport;
40.28 +
40.29 + public ${name}() {
40.30 + propertySupport = new PropertyChangeSupport(this);
40.31 + }
40.32 +
40.33 + public String getSampleProperty() {
40.34 + return sampleProperty;
40.35 + }
40.36 +
40.37 + public void setSampleProperty(String value) {
40.38 + String oldValue = sampleProperty;
40.39 + sampleProperty = value;
40.40 + propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
40.41 + }
40.42 +
40.43 +
40.44 + public void addPropertyChangeListener(PropertyChangeListener listener) {
40.45 + propertySupport.addPropertyChangeListener(listener);
40.46 + }
40.47 +
40.48 + public void removePropertyChangeListener(PropertyChangeListener listener) {
40.49 + propertySupport.removePropertyChangeListener(listener);
40.50 + }
40.51 +
40.52 +}
41.1 --- a/beans/src/org/netbeans/modules/beans/resources/templates/Bean.template Wed Jul 27 10:33:10 2011 +0200
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,49 +0,0 @@
41.4 -<#-- FreeMarker template (see http://freemarker.org/) -->
41.5 -<#assign licenseFirst = "/*">
41.6 -<#assign licensePrefix = " * ">
41.7 -<#assign licenseLast = " */">
41.8 -<#include "../Licenses/license-${project.license}.txt">
41.9 -
41.10 -<#if package?? && package != "">
41.11 -package ${package};
41.12 -
41.13 -</#if>
41.14 -import java.beans.*;
41.15 -import java.io.Serializable;
41.16 -
41.17 -/**
41.18 - *
41.19 - * @author ${user}
41.20 - */
41.21 -public class ${name} implements Serializable {
41.22 -
41.23 - public static final String PROP_SAMPLE_PROPERTY = "sampleProperty";
41.24 -
41.25 - private String sampleProperty;
41.26 -
41.27 - private PropertyChangeSupport propertySupport;
41.28 -
41.29 - public ${name}() {
41.30 - propertySupport = new PropertyChangeSupport(this);
41.31 - }
41.32 -
41.33 - public String getSampleProperty() {
41.34 - return sampleProperty;
41.35 - }
41.36 -
41.37 - public void setSampleProperty(String value) {
41.38 - String oldValue = sampleProperty;
41.39 - sampleProperty = value;
41.40 - propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
41.41 - }
41.42 -
41.43 -
41.44 - public void addPropertyChangeListener(PropertyChangeListener listener) {
41.45 - propertySupport.addPropertyChangeListener(listener);
41.46 - }
41.47 -
41.48 - public void removePropertyChangeListener(PropertyChangeListener listener) {
41.49 - propertySupport.removePropertyChangeListener(listener);
41.50 - }
41.51 -
41.52 -}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/BeanInfo.html Wed Jul 27 10:35:25 2011 +0200
42.3 @@ -0,0 +1,50 @@
42.4 +<!--
42.5 + -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
42.6 + --
42.7 + -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
42.8 + --
42.9 + -- The contents of this file are subject to the terms of either the GNU
42.10 + -- General Public License Version 2 only ("GPL") or the Common
42.11 + -- Development and Distribution License("CDDL") (collectively, the
42.12 + -- "License"). You may not use this file except in compliance with the
42.13 + -- License. You can obtain a copy of the License at
42.14 + -- http://www.netbeans.org/cddl-gplv2.html
42.15 + -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
42.16 + -- specific language governing permissions and limitations under the
42.17 + -- License. When distributing the software, include this License Header
42.18 + -- Notice in each file and include the License file at
42.19 + -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
42.20 + -- particular file as subject to the "Classpath" exception as provided
42.21 + -- by Sun in the GPL Version 2 section of the License file that
42.22 + -- accompanied this code. If applicable, add the following below the
42.23 + -- License Header, with the fields enclosed by brackets [] replaced by
42.24 + -- your own identifying information:
42.25 + -- "Portions Copyrighted [year] [name of copyright owner]"
42.26 + --
42.27 + -- Contributor(s):
42.28 + --
42.29 + -- The Original Software is NetBeans. The Initial Developer of the Original
42.30 + -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
42.31 + -- Microsystems, Inc. All Rights Reserved.
42.32 + --
42.33 + -- If you wish your version of this file to be governed by only the CDDL
42.34 + -- or only the GPL Version 2, indicate your decision by adding
42.35 + -- "[Contributor] elects to include this software in this distribution
42.36 + -- under the [CDDL or GPL Version 2] license." If you do not indicate a
42.37 + -- single choice of license, a recipient has the option to distribute
42.38 + -- your version of this file under either the CDDL, the GPL Version 2 or
42.39 + -- to extend the choice of license to its licensees as provided above.
42.40 + -- However, if you add GPL Version 2 code and therefore, elected the GPL
42.41 + -- Version 2 license, then the option applies only if the new code is
42.42 + -- made subject to such option by the copyright holder.
42.43 + -->
42.44 +
42.45 +<html>
42.46 +<head>
42.47 + <meta http-equiv="content-type" content="text/html; charset=UTF-8">
42.48 +</head>
42.49 +<BODY>
42.50 +Creates a new <code>BeanInfo</code> class. The BeanInfo is used as a
42.51 +description of how its associated JavaBeans component should behave and
42.52 +appear.
42.53 +</BODY></HTML>
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/BeanInfo.java.template Wed Jul 27 10:35:25 2011 +0200
43.3 @@ -0,0 +1,207 @@
43.4 +<#-- FreeMarker template (see http://freemarker.org/) -->
43.5 +<#assign licenseFirst = "/*">
43.6 +<#assign licensePrefix = " * ">
43.7 +<#assign licenseLast = " */">
43.8 +<#include "../Licenses/license-${project.license}.txt">
43.9 +
43.10 +<#if package?? && package != "">
43.11 +package ${package};
43.12 +
43.13 +</#if>
43.14 +import java.beans.*;
43.15 +
43.16 +/**
43.17 + *
43.18 + * @author ${user}
43.19 + */
43.20 +public class ${name} extends SimpleBeanInfo {
43.21 +
43.22 + // Bean descriptor information will be obtained from introspection.//GEN-FIRST:BeanDescriptor
43.23 + private static BeanDescriptor beanDescriptor = null;
43.24 + private static BeanDescriptor getBdescriptor(){
43.25 + //GEN-HEADEREND:BeanDescriptor
43.26 +
43.27 + // Here you can add code for customizing the BeanDescriptor.
43.28 +
43.29 + return beanDescriptor; } //GEN-LAST:BeanDescriptor
43.30 +
43.31 +
43.32 + // Properties information will be obtained from introspection.//GEN-FIRST:Properties
43.33 + private static PropertyDescriptor[] properties = null;
43.34 + private static PropertyDescriptor[] getPdescriptor(){
43.35 + //GEN-HEADEREND:Properties
43.36 +
43.37 + // Here you can add code for customizing the properties array.
43.38 +
43.39 + return properties; } //GEN-LAST:Properties
43.40 +
43.41 + // Event set information will be obtained from introspection.//GEN-FIRST:Events
43.42 + private static EventSetDescriptor[] eventSets = null;
43.43 + private static EventSetDescriptor[] getEdescriptor(){
43.44 + //GEN-HEADEREND:Events
43.45 +
43.46 + // Here you can add code for customizing the event sets array.
43.47 +
43.48 + return eventSets; } //GEN-LAST:Events
43.49 +
43.50 + // Method information will be obtained from introspection.//GEN-FIRST:Methods
43.51 + private static MethodDescriptor[] methods = null;
43.52 + private static MethodDescriptor[] getMdescriptor(){
43.53 + //GEN-HEADEREND:Methods
43.54 +
43.55 + // Here you can add code for customizing the methods array.
43.56 +
43.57 + return methods; } //GEN-LAST:Methods
43.58 +
43.59 + private static java.awt.Image iconColor16 = null; //GEN-BEGIN:IconsDef
43.60 + private static java.awt.Image iconColor32 = null;
43.61 + private static java.awt.Image iconMono16 = null;
43.62 + private static java.awt.Image iconMono32 = null; //GEN-END:IconsDef
43.63 + private static String iconNameC16 = null; //GEN-BEGIN:Icons
43.64 + private static String iconNameC32 = null;
43.65 + private static String iconNameM16 = null;
43.66 + private static String iconNameM32 = null; //GEN-END:Icons
43.67 +
43.68 + private static int defaultPropertyIndex = -1; //GEN-BEGIN:Idx
43.69 + private static int defaultEventIndex = -1; //GEN-END:Idx
43.70 +
43.71 +
43.72 + //GEN-FIRST:Superclass
43.73 +
43.74 + // Here you can add code for customizing the Superclass BeanInfo.
43.75 +
43.76 + //GEN-LAST:Superclass
43.77 +
43.78 + /**
43.79 + * Gets the bean's <code>BeanDescriptor</code>s.
43.80 + *
43.81 + * @return BeanDescriptor describing the editable
43.82 + * properties of this bean. May return null if the
43.83 + * information should be obtained by automatic analysis.
43.84 + */
43.85 + public BeanDescriptor getBeanDescriptor() {
43.86 + return getBdescriptor();
43.87 + }
43.88 +
43.89 + /**
43.90 + * Gets the bean's <code>PropertyDescriptor</code>s.
43.91 + *
43.92 + * @return An array of PropertyDescriptors describing the editable
43.93 + * properties supported by this bean. May return null if the
43.94 + * information should be obtained by automatic analysis.
43.95 + * <p>
43.96 + * If a property is indexed, then its entry in the result array will
43.97 + * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
43.98 + * A client of getPropertyDescriptors can use "instanceof" to check
43.99 + * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
43.100 + */
43.101 + public PropertyDescriptor[] getPropertyDescriptors() {
43.102 + return getPdescriptor();
43.103 + }
43.104 +
43.105 + /**
43.106 + * Gets the bean's <code>EventSetDescriptor</code>s.
43.107 + *
43.108 + * @return An array of EventSetDescriptors describing the kinds of
43.109 + * events fired by this bean. May return null if the information
43.110 + * should be obtained by automatic analysis.
43.111 + */
43.112 + public EventSetDescriptor[] getEventSetDescriptors() {
43.113 + return getEdescriptor();
43.114 + }
43.115 +
43.116 + /**
43.117 + * Gets the bean's <code>MethodDescriptor</code>s.
43.118 + *
43.119 + * @return An array of MethodDescriptors describing the methods
43.120 + * implemented by this bean. May return null if the information
43.121 + * should be obtained by automatic analysis.
43.122 + */
43.123 + public MethodDescriptor[] getMethodDescriptors() {
43.124 + return getMdescriptor();
43.125 + }
43.126 +
43.127 + /**
43.128 + * A bean may have a "default" property that is the property that will
43.129 + * mostly commonly be initially chosen for update by human's who are
43.130 + * customizing the bean.
43.131 + * @return Index of default property in the PropertyDescriptor array
43.132 + * returned by getPropertyDescriptors.
43.133 + * <P> Returns -1 if there is no default property.
43.134 + */
43.135 + public int getDefaultPropertyIndex() {
43.136 + return defaultPropertyIndex;
43.137 + }
43.138 +
43.139 + /**
43.140 + * A bean may have a "default" event that is the event that will
43.141 + * mostly commonly be used by human's when using the bean.
43.142 + * @return Index of default event in the EventSetDescriptor array
43.143 + * returned by getEventSetDescriptors.
43.144 + * <P> Returns -1 if there is no default event.
43.145 + */
43.146 + public int getDefaultEventIndex() {
43.147 + return defaultEventIndex;
43.148 + }
43.149 +
43.150 + /**
43.151 + * This method returns an image object that can be used to
43.152 + * represent the bean in toolboxes, toolbars, etc. Icon images
43.153 + * will typically be GIFs, but may in future include other formats.
43.154 + * <p>
43.155 + * Beans aren't required to provide icons and may return null from
43.156 + * this method.
43.157 + * <p>
43.158 + * There are four possible flavors of icons (16x16 color,
43.159 + * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
43.160 + * support a single icon we recommend supporting 16x16 color.
43.161 + * <p>
43.162 + * We recommend that icons have a "transparent" background
43.163 + * so they can be rendered onto an existing background.
43.164 + *
43.165 + * @param iconKind The kind of icon requested. This should be
43.166 + * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
43.167 + * ICON_MONO_16x16, or ICON_MONO_32x32.
43.168 + * @return An image object representing the requested icon. May
43.169 + * return null if no suitable icon is available.
43.170 + */
43.171 + public java.awt.Image getIcon(int iconKind) {
43.172 + switch ( iconKind ) {
43.173 + case ICON_COLOR_16x16:
43.174 + if ( iconNameC16 == null )
43.175 + return null;
43.176 + else {
43.177 + if( iconColor16 == null )
43.178 + iconColor16 = loadImage( iconNameC16 );
43.179 + return iconColor16;
43.180 + }
43.181 + case ICON_COLOR_32x32:
43.182 + if ( iconNameC32 == null )
43.183 + return null;
43.184 + else {
43.185 + if( iconColor32 == null )
43.186 + iconColor32 = loadImage( iconNameC32 );
43.187 + return iconColor32;
43.188 + }
43.189 + case ICON_MONO_16x16:
43.190 + if ( iconNameM16 == null )
43.191 + return null;
43.192 + else {
43.193 + if( iconMono16 == null )
43.194 + iconMono16 = loadImage( iconNameM16 );
43.195 + return iconMono16;
43.196 + }
43.197 + case ICON_MONO_32x32:
43.198 + if ( iconNameM32 == null )
43.199 + return null;
43.200 + else {
43.201 + if( iconMono32 == null )
43.202 + iconMono32 = loadImage( iconNameM32 );
43.203 + return iconMono32;
43.204 + }
43.205 + default: return null;
43.206 + }
43.207 + }
43.208 +
43.209 +}
43.210 +
44.1 --- a/beans/src/org/netbeans/modules/beans/resources/templates/BeanInfo.template Wed Jul 27 10:33:10 2011 +0200
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,207 +0,0 @@
44.4 -<#-- FreeMarker template (see http://freemarker.org/) -->
44.5 -<#assign licenseFirst = "/*">
44.6 -<#assign licensePrefix = " * ">
44.7 -<#assign licenseLast = " */">
44.8 -<#include "../Licenses/license-${project.license}.txt">
44.9 -
44.10 -<#if package?? && package != "">
44.11 -package ${package};
44.12 -
44.13 -</#if>
44.14 -import java.beans.*;
44.15 -
44.16 -/**
44.17 - *
44.18 - * @author ${user}
44.19 - */
44.20 -public class ${name} extends SimpleBeanInfo {
44.21 -
44.22 - // Bean descriptor information will be obtained from introspection.//GEN-FIRST:BeanDescriptor
44.23 - private static BeanDescriptor beanDescriptor = null;
44.24 - private static BeanDescriptor getBdescriptor(){
44.25 - //GEN-HEADEREND:BeanDescriptor
44.26 -
44.27 - // Here you can add code for customizing the BeanDescriptor.
44.28 -
44.29 - return beanDescriptor; } //GEN-LAST:BeanDescriptor
44.30 -
44.31 -
44.32 - // Properties information will be obtained from introspection.//GEN-FIRST:Properties
44.33 - private static PropertyDescriptor[] properties = null;
44.34 - private static PropertyDescriptor[] getPdescriptor(){
44.35 - //GEN-HEADEREND:Properties
44.36 -
44.37 - // Here you can add code for customizing the properties array.
44.38 -
44.39 - return properties; } //GEN-LAST:Properties
44.40 -
44.41 - // Event set information will be obtained from introspection.//GEN-FIRST:Events
44.42 - private static EventSetDescriptor[] eventSets = null;
44.43 - private static EventSetDescriptor[] getEdescriptor(){
44.44 - //GEN-HEADEREND:Events
44.45 -
44.46 - // Here you can add code for customizing the event sets array.
44.47 -
44.48 - return eventSets; } //GEN-LAST:Events
44.49 -
44.50 - // Method information will be obtained from introspection.//GEN-FIRST:Methods
44.51 - private static MethodDescriptor[] methods = null;
44.52 - private static MethodDescriptor[] getMdescriptor(){
44.53 - //GEN-HEADEREND:Methods
44.54 -
44.55 - // Here you can add code for customizing the methods array.
44.56 -
44.57 - return methods; } //GEN-LAST:Methods
44.58 -
44.59 - private static java.awt.Image iconColor16 = null; //GEN-BEGIN:IconsDef
44.60 - private static java.awt.Image iconColor32 = null;
44.61 - private static java.awt.Image iconMono16 = null;
44.62 - private static java.awt.Image iconMono32 = null; //GEN-END:IconsDef
44.63 - private static String iconNameC16 = null; //GEN-BEGIN:Icons
44.64 - private static String iconNameC32 = null;
44.65 - private static String iconNameM16 = null;
44.66 - private static String iconNameM32 = null; //GEN-END:Icons
44.67 -
44.68 - private static int defaultPropertyIndex = -1; //GEN-BEGIN:Idx
44.69 - private static int defaultEventIndex = -1; //GEN-END:Idx
44.70 -
44.71 -
44.72 - //GEN-FIRST:Superclass
44.73 -
44.74 - // Here you can add code for customizing the Superclass BeanInfo.
44.75 -
44.76 - //GEN-LAST:Superclass
44.77 -
44.78 - /**
44.79 - * Gets the bean's <code>BeanDescriptor</code>s.
44.80 - *
44.81 - * @return BeanDescriptor describing the editable
44.82 - * properties of this bean. May return null if the
44.83 - * information should be obtained by automatic analysis.
44.84 - */
44.85 - public BeanDescriptor getBeanDescriptor() {
44.86 - return getBdescriptor();
44.87 - }
44.88 -
44.89 - /**
44.90 - * Gets the bean's <code>PropertyDescriptor</code>s.
44.91 - *
44.92 - * @return An array of PropertyDescriptors describing the editable
44.93 - * properties supported by this bean. May return null if the
44.94 - * information should be obtained by automatic analysis.
44.95 - * <p>
44.96 - * If a property is indexed, then its entry in the result array will
44.97 - * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
44.98 - * A client of getPropertyDescriptors can use "instanceof" to check
44.99 - * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
44.100 - */
44.101 - public PropertyDescriptor[] getPropertyDescriptors() {
44.102 - return getPdescriptor();
44.103 - }
44.104 -
44.105 - /**
44.106 - * Gets the bean's <code>EventSetDescriptor</code>s.
44.107 - *
44.108 - * @return An array of EventSetDescriptors describing the kinds of
44.109 - * events fired by this bean. May return null if the information
44.110 - * should be obtained by automatic analysis.
44.111 - */
44.112 - public EventSetDescriptor[] getEventSetDescriptors() {
44.113 - return getEdescriptor();
44.114 - }
44.115 -
44.116 - /**
44.117 - * Gets the bean's <code>MethodDescriptor</code>s.
44.118 - *
44.119 - * @return An array of MethodDescriptors describing the methods
44.120 - * implemented by this bean. May return null if the information
44.121 - * should be obtained by automatic analysis.
44.122 - */
44.123 - public MethodDescriptor[] getMethodDescriptors() {
44.124 - return getMdescriptor();
44.125 - }
44.126 -
44.127 - /**
44.128 - * A bean may have a "default" property that is the property that will
44.129 - * mostly commonly be initially chosen for update by human's who are
44.130 - * customizing the bean.
44.131 - * @return Index of default property in the PropertyDescriptor array
44.132 - * returned by getPropertyDescriptors.
44.133 - * <P> Returns -1 if there is no default property.
44.134 - */
44.135 - public int getDefaultPropertyIndex() {
44.136 - return defaultPropertyIndex;
44.137 - }
44.138 -
44.139 - /**
44.140 - * A bean may have a "default" event that is the event that will
44.141 - * mostly commonly be used by human's when using the bean.
44.142 - * @return Index of default event in the EventSetDescriptor array
44.143 - * returned by getEventSetDescriptors.
44.144 - * <P> Returns -1 if there is no default event.
44.145 - */
44.146 - public int getDefaultEventIndex() {
44.147 - return defaultEventIndex;
44.148 - }
44.149 -
44.150 - /**
44.151 - * This method returns an image object that can be used to
44.152 - * represent the bean in toolboxes, toolbars, etc. Icon images
44.153 - * will typically be GIFs, but may in future include other formats.
44.154 - * <p>
44.155 - * Beans aren't required to provide icons and may return null from
44.156 - * this method.
44.157 - * <p>
44.158 - * There are four possible flavors of icons (16x16 color,
44.159 - * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
44.160 - * support a single icon we recommend supporting 16x16 color.
44.161 - * <p>
44.162 - * We recommend that icons have a "transparent" background
44.163 - * so they can be rendered onto an existing background.
44.164 - *
44.165 - * @param iconKind The kind of icon requested. This should be
44.166 - * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
44.167 - * ICON_MONO_16x16, or ICON_MONO_32x32.
44.168 - * @return An image object representing the requested icon. May
44.169 - * return null if no suitable icon is available.
44.170 - */
44.171 - public java.awt.Image getIcon(int iconKind) {
44.172 - switch ( iconKind ) {
44.173 - case ICON_COLOR_16x16:
44.174 - if ( iconNameC16 == null )
44.175 - return null;
44.176 - else {
44.177 - if( iconColor16 == null )
44.178 - iconColor16 = loadImage( iconNameC16 );
44.179 - return iconColor16;
44.180 - }
44.181 - case ICON_COLOR_32x32:
44.182 - if ( iconNameC32 == null )
44.183 - return null;
44.184 - else {
44.185 - if( iconColor32 == null )
44.186 - iconColor32 = loadImage( iconNameC32 );
44.187 - return iconColor32;
44.188 - }
44.189 - case ICON_MONO_16x16:
44.190 - if ( iconNameM16 == null )
44.191 - return null;
44.192 - else {
44.193 - if( iconMono16 == null )
44.194 - iconMono16 = loadImage( iconNameM16 );
44.195 - return iconMono16;
44.196 - }
44.197 - case ICON_MONO_32x32:
44.198 - if ( iconNameM32 == null )
44.199 - return null;
44.200 - else {
44.201 - if( iconMono32 == null )
44.202 - iconMono32 = loadImage( iconNameM32 );
44.203 - return iconMono32;
44.204 - }
44.205 - default: return null;
44.206 - }
44.207 - }
44.208 -
44.209 -}
44.210 -
45.1 --- a/beans/src/org/netbeans/modules/beans/resources/templates/BeanInfoNoIcon.template Wed Jul 27 10:33:10 2011 +0200
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,139 +0,0 @@
45.4 -<#-- FreeMarker template (see http://freemarker.org/) -->
45.5 -<#assign licenseFirst = "/*">
45.6 -<#assign licensePrefix = " * ">
45.7 -<#assign licenseLast = " */">
45.8 -<#include "../Licenses/license-${project.license}.txt">
45.9 -
45.10 -<#if package?? && package != "">
45.11 -package ${package};
45.12 -
45.13 -</#if>
45.14 -import java.beans.*;
45.15 -
45.16 -/**
45.17 - *
45.18 - * @author ${user}
45.19 - */
45.20 -public class ${name} extends SimpleBeanInfo {
45.21 -
45.22 - // Bean descriptor information will be obtained from introspection.//GEN-FIRST:BeanDescriptor
45.23 - private static BeanDescriptor beanDescriptor = null;
45.24 - private static BeanDescriptor getBdescriptor(){
45.25 - //GEN-HEADEREND:BeanDescriptor
45.26 -
45.27 - // Here you can add code for customizing the BeanDescriptor.
45.28 -
45.29 - return beanDescriptor; } //GEN-LAST:BeanDescriptor
45.30 -
45.31 -
45.32 - // Properties information will be obtained from introspection.//GEN-FIRST:Properties
45.33 - private static PropertyDescriptor[] properties = null;
45.34 - private static PropertyDescriptor[] getPdescriptor(){
45.35 - //GEN-HEADEREND:Properties
45.36 -
45.37 - // Here you can add code for customizing the properties array.
45.38 -
45.39 - return properties; } //GEN-LAST:Properties
45.40 -
45.41 - // Event set information will be obtained from introspection.//GEN-FIRST:Events
45.42 - private static EventSetDescriptor[] eventSets = null;
45.43 - private static EventSetDescriptor[] getEdescriptor(){
45.44 - //GEN-HEADEREND:Events
45.45 -
45.46 - // Here you can add code for customizing the event sets array.
45.47 -
45.48 - return eventSets; } //GEN-LAST:Events
45.49 -
45.50 - // Method information will be obtained from introspection.//GEN-FIRST:Methods
45.51 - private static MethodDescriptor[] methods = null;
45.52 - private static MethodDescriptor[] getMdescriptor(){
45.53 - //GEN-HEADEREND:Methods
45.54 -
45.55 - // Here you can add code for customizing the methods array.
45.56 -
45.57 - return methods; } //GEN-LAST:Methods
45.58 -
45.59 -
45.60 - private static int defaultPropertyIndex = -1; //GEN-BEGIN:Idx
45.61 - private static int defaultEventIndex = -1; //GEN-END:Idx
45.62 -
45.63 -
45.64 - //GEN-FIRST:Superclass
45.65 -
45.66 - // Here you can add code for customizing the Superclass BeanInfo.
45.67 -
45.68 - //GEN-LAST:Superclass
45.69 -
45.70 - /**
45.71 - * Gets the bean's <code>BeanDescriptor</code>s.
45.72 - *
45.73 - * @return BeanDescriptor describing the editable
45.74 - * properties of this bean. May return null if the
45.75 - * information should be obtained by automatic analysis.
45.76 - */
45.77 - public BeanDescriptor getBeanDescriptor() {
45.78 - return getBdescriptor();
45.79 - }
45.80 -
45.81 - /**
45.82 - * Gets the bean's <code>PropertyDescriptor</code>s.
45.83 - *
45.84 - * @return An array of PropertyDescriptors describing the editable
45.85 - * properties supported by this bean. May return null if the
45.86 - * information should be obtained by automatic analysis.
45.87 - * <p>
45.88 - * If a property is indexed, then its entry in the result array will
45.89 - * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
45.90 - * A client of getPropertyDescriptors can use "instanceof" to check
45.91 - * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
45.92 - */
45.93 - public PropertyDescriptor[] getPropertyDescriptors() {
45.94 - return getPdescriptor();
45.95 - }
45.96 -
45.97 - /**
45.98 - * Gets the bean's <code>EventSetDescriptor</code>s.
45.99 - *
45.100 - * @return An array of EventSetDescriptors describing the kinds of
45.101 - * events fired by this bean. May return null if the information
45.102 - * should be obtained by automatic analysis.
45.103 - */
45.104 - public EventSetDescriptor[] getEventSetDescriptors() {
45.105 - return getEdescriptor();
45.106 - }
45.107 -
45.108 - /**
45.109 - * Gets the bean's <code>MethodDescriptor</code>s.
45.110 - *
45.111 - * @return An array of MethodDescriptors describing the methods
45.112 - * implemented by this bean. May return null if the information
45.113 - * should be obtained by automatic analysis.
45.114 - */
45.115 - public MethodDescriptor[] getMethodDescriptors() {
45.116 - return getMdescriptor();
45.117 - }
45.118 -
45.119 - /**
45.120 - * A bean may have a "default" property that is the property that will
45.121 - * mostly commonly be initially chosen for update by human's who are
45.122 - * customizing the bean.
45.123 - * @return Index of default property in the PropertyDescriptor array
45.124 - * returned by getPropertyDescriptors.
45.125 - * <P> Returns -1 if there is no default property.
45.126 - */
45.127 - public int getDefaultPropertyIndex() {
45.128 - return defaultPropertyIndex;
45.129 - }
45.130 -
45.131 - /**
45.132 - * A bean may have a "default" event that is the event that will
45.133 - * mostly commonly be used by human's when using the bean.
45.134 - * @return Index of default event in the EventSetDescriptor array
45.135 - * returned by getEventSetDescriptors.
45.136 - * <P> Returns -1 if there is no default event.
45.137 - */
45.138 - public int getDefaultEventIndex() {
45.139 - return defaultEventIndex;
45.140 - }
45.141 -}
45.142 -
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Beans.html Wed Jul 27 10:35:25 2011 +0200
46.3 @@ -0,0 +1,48 @@
46.4 +<!--
46.5 + -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
46.6 + --
46.7 + -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
46.8 + --
46.9 + -- The contents of this file are subject to the terms of either the GNU
46.10 + -- General Public License Version 2 only ("GPL") or the Common
46.11 + -- Development and Distribution License("CDDL") (collectively, the
46.12 + -- "License"). You may not use this file except in compliance with the
46.13 + -- License. You can obtain a copy of the License at
46.14 + -- http://www.netbeans.org/cddl-gplv2.html
46.15 + -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
46.16 + -- specific language governing permissions and limitations under the
46.17 + -- License. When distributing the software, include this License Header
46.18 + -- Notice in each file and include the License file at
46.19 + -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
46.20 + -- particular file as subject to the "Classpath" exception as provided
46.21 + -- by Sun in the GPL Version 2 section of the License file that
46.22 + -- accompanied this code. If applicable, add the following below the
46.23 + -- License Header, with the fields enclosed by brackets [] replaced by
46.24 + -- your own identifying information:
46.25 + -- "Portions Copyrighted [year] [name of copyright owner]"
46.26 + --
46.27 + -- Contributor(s):
46.28 + --
46.29 + -- The Original Software is NetBeans. The Initial Developer of the Original
46.30 + -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
46.31 + -- Microsystems, Inc. All Rights Reserved.
46.32 + --
46.33 + -- If you wish your version of this file to be governed by only the CDDL
46.34 + -- or only the GPL Version 2, indicate your decision by adding
46.35 + -- "[Contributor] elects to include this software in this distribution
46.36 + -- under the [CDDL or GPL Version 2] license." If you do not indicate a
46.37 + -- single choice of license, a recipient has the option to distribute
46.38 + -- your version of this file under either the CDDL, the GPL Version 2 or
46.39 + -- to extend the choice of license to its licensees as provided above.
46.40 + -- However, if you add GPL Version 2 code and therefore, elected the GPL
46.41 + -- Version 2 license, then the option applies only if the new code is
46.42 + -- made subject to such option by the copyright holder.
46.43 + -->
46.44 +
46.45 +<html>
46.46 +<head>
46.47 + <meta http-equiv="content-type" content="text/html; charset=UTF-8">
46.48 +</head>
46.49 +<BODY>
46.50 +This category includes several types of classes that will help you create JavaBeans components.
46.51 +</BODY></HTML>
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Customizer.html Wed Jul 27 10:35:25 2011 +0200
47.3 @@ -0,0 +1,49 @@
47.4 +<!--
47.5 + -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
47.6 + --
47.7 + -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
47.8 + --
47.9 + -- The contents of this file are subject to the terms of either the GNU
47.10 + -- General Public License Version 2 only ("GPL") or the Common
47.11 + -- Development and Distribution License("CDDL") (collectively, the
47.12 + -- "License"). You may not use this file except in compliance with the
47.13 + -- License. You can obtain a copy of the License at
47.14 + -- http://www.netbeans.org/cddl-gplv2.html
47.15 + -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
47.16 + -- specific language governing permissions and limitations under the
47.17 + -- License. When distributing the software, include this License Header
47.18 + -- Notice in each file and include the License file at
47.19 + -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
47.20 + -- particular file as subject to the "Classpath" exception as provided
47.21 + -- by Sun in the GPL Version 2 section of the License file that
47.22 + -- accompanied this code. If applicable, add the following below the
47.23 + -- License Header, with the fields enclosed by brackets [] replaced by
47.24 + -- your own identifying information:
47.25 + -- "Portions Copyrighted [year] [name of copyright owner]"
47.26 + --
47.27 + -- Contributor(s):
47.28 + --
47.29 + -- The Original Software is NetBeans. The Initial Developer of the Original
47.30 + -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
47.31 + -- Microsystems, Inc. All Rights Reserved.
47.32 + --
47.33 + -- If you wish your version of this file to be governed by only the CDDL
47.34 + -- or only the GPL Version 2, indicate your decision by adding
47.35 + -- "[Contributor] elects to include this software in this distribution
47.36 + -- under the [CDDL or GPL Version 2] license." If you do not indicate a
47.37 + -- single choice of license, a recipient has the option to distribute
47.38 + -- your version of this file under either the CDDL, the GPL Version 2 or
47.39 + -- to extend the choice of license to its licensees as provided above.
47.40 + -- However, if you add GPL Version 2 code and therefore, elected the GPL
47.41 + -- Version 2 license, then the option applies only if the new code is
47.42 + -- made subject to such option by the copyright holder.
47.43 + -->
47.44 +
47.45 +<html>
47.46 +<head>
47.47 + <meta http-equiv="content-type" content="text/html; charset=UTF-8">
47.48 +</head>
47.49 +<BODY>
47.50 +Creates a Customizer panel for a JavaBeans component. The customizer can then be
47.51 +used during design time in the IDE to configure the bean.
47.52 +</BODY></HTML>
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Customizer.java.template Wed Jul 27 10:35:25 2011 +0200
48.3 @@ -0,0 +1,43 @@
48.4 +<#-- FreeMarker template (see http://freemarker.org/) -->
48.5 +<#assign licenseFirst = "/*">
48.6 +<#assign licensePrefix = " * ">
48.7 +<#assign licenseLast = " */">
48.8 +<#include "../Licenses/license-${project.license}.txt">
48.9 +
48.10 +<#if package?? && package != "">
48.11 +package ${package};
48.12 +
48.13 +</#if>
48.14 +
48.15 +/**
48.16 + *
48.17 + * @author ${user}
48.18 + */
48.19 +public class ${name} extends javax.swing.JPanel implements java.beans.Customizer {
48.20 +
48.21 + private Object bean;
48.22 +
48.23 + /** Creates new customizer ${name} */
48.24 + public ${name}() {
48.25 + initComponents();
48.26 + }
48.27 +
48.28 + public void setObject(Object bean) {
48.29 + this.bean = bean;
48.30 + }
48.31 +
48.32 + /** This method is called from within the constructor to
48.33 + * initialize the form.
48.34 + * WARNING: Do NOT modify this code. The content of this method is
48.35 + * always regenerated by the FormEditor.
48.36 + */
48.37 + private void initComponents() {//GEN-BEGIN:initComponents
48.38 + setLayout(new java.awt.BorderLayout());
48.39 +
48.40 + }//GEN-END:initComponents
48.41 +
48.42 +
48.43 + // Variables declaration - do not modify//GEN-BEGIN:variables
48.44 + // End of variables declaration//GEN-END:variables
48.45 +
48.46 +}
49.1 --- a/beans/src/org/netbeans/modules/beans/resources/templates/Customizer.template Wed Jul 27 10:33:10 2011 +0200
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,43 +0,0 @@
49.4 -<#-- FreeMarker template (see http://freemarker.org/) -->
49.5 -<#assign licenseFirst = "/*">
49.6 -<#assign licensePrefix = " * ">
49.7 -<#assign licenseLast = " */">
49.8 -<#include "../Licenses/license-${project.license}.txt">
49.9 -
49.10 -<#if package?? && package != "">
49.11 -package ${package};
49.12 -
49.13 -</#if>
49.14 -
49.15 -/**
49.16 - *
49.17 - * @author ${user}
49.18 - */
49.19 -public class ${name} extends javax.swing.JPanel implements java.beans.Customizer {
49.20 -
49.21 - private Object bean;
49.22 -
49.23 - /** Creates new customizer ${name} */
49.24 - public ${name}() {
49.25 - initComponents();
49.26 - }
49.27 -
49.28 - public void setObject(Object bean) {
49.29 - this.bean = bean;
49.30 - }
49.31 -
49.32 - /** This method is called from within the constructor to
49.33 - * initialize the form.
49.34 - * WARNING: Do NOT modify this code. The content of this method is
49.35 - * always regenerated by the FormEditor.
49.36 - */
49.37 - private void initComponents() {//GEN-BEGIN:initComponents
49.38 - setLayout(new java.awt.BorderLayout());
49.39 -
49.40 - }//GEN-END:initComponents
49.41 -
49.42 -
49.43 - // Variables declaration - do not modify//GEN-BEGIN:variables
49.44 - // End of variables declaration//GEN-END:variables
49.45 -
49.46 -}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/NoIconBeanInfo.java.template Wed Jul 27 10:35:25 2011 +0200
50.3 @@ -0,0 +1,139 @@
50.4 +<#-- FreeMarker template (see http://freemarker.org/) -->
50.5 +<#assign licenseFirst = "/*">
50.6 +<#assign licensePrefix = " * ">
50.7 +<#assign licenseLast = " */">
50.8 +<#include "../Licenses/license-${project.license}.txt">
50.9 +
50.10 +<#if package?? && package != "">
50.11 +package ${package};
50.12 +
50.13 +</#if>
50.14 +import java.beans.*;
50.15 +
50.16 +/**
50.17 + *
50.18 + * @author ${user}
50.19 + */
50.20 +public class ${name} extends SimpleBeanInfo {
50.21 +
50.22 + // Bean descriptor information will be obtained from introspection.//GEN-FIRST:BeanDescriptor
50.23 + private static BeanDescriptor beanDescriptor = null;
50.24 + private static BeanDescriptor getBdescriptor(){
50.25 + //GEN-HEADEREND:BeanDescriptor
50.26 +
50.27 + // Here you can add code for customizing the BeanDescriptor.
50.28 +
50.29 + return beanDescriptor; } //GEN-LAST:BeanDescriptor
50.30 +
50.31 +
50.32 + // Properties information will be obtained from introspection.//GEN-FIRST:Properties
50.33 + private static PropertyDescriptor[] properties = null;
50.34 + private static PropertyDescriptor[] getPdescriptor(){
50.35 + //GEN-HEADEREND:Properties
50.36 +
50.37 + // Here you can add code for customizing the properties array.
50.38 +
50.39 + return properties; } //GEN-LAST:Properties
50.40 +
50.41 + // Event set information will be obtained from introspection.//GEN-FIRST:Events
50.42 + private static EventSetDescriptor[] eventSets = null;
50.43 + private static EventSetDescriptor[] getEdescriptor(){
50.44 + //GEN-HEADEREND:Events
50.45 +
50.46 + // Here you can add code for customizing the event sets array.
50.47 +
50.48 + return eventSets; } //GEN-LAST:Events
50.49 +
50.50 + // Method information will be obtained from introspection.//GEN-FIRST:Methods
50.51 + private static MethodDescriptor[] methods = null;
50.52 + private static MethodDescriptor[] getMdescriptor(){
50.53 + //GEN-HEADEREND:Methods
50.54 +
50.55 + // Here you can add code for customizing the methods array.
50.56 +
50.57 + return methods; } //GEN-LAST:Methods
50.58 +
50.59 +
50.60 + private static int defaultPropertyIndex = -1; //GEN-BEGIN:Idx
50.61 + private static int defaultEventIndex = -1; //GEN-END:Idx
50.62 +
50.63 +
50.64 + //GEN-FIRST:Superclass
50.65 +
50.66 + // Here you can add code for customizing the Superclass BeanInfo.
50.67 +
50.68 + //GEN-LAST:Superclass
50.69 +
50.70 + /**
50.71 + * Gets the bean's <code>BeanDescriptor</code>s.
50.72 + *
50.73 + * @return BeanDescriptor describing the editable
50.74 + * properties of this bean. May return null if the
50.75 + * information should be obtained by automatic analysis.
50.76 + */
50.77 + public BeanDescriptor getBeanDescriptor() {
50.78 + return getBdescriptor();
50.79 + }
50.80 +
50.81 + /**
50.82 + * Gets the bean's <code>PropertyDescriptor</code>s.
50.83 + *
50.84 + * @return An array of PropertyDescriptors describing the editable
50.85 + * properties supported by this bean. May return null if the
50.86 + * information should be obtained by automatic analysis.
50.87 + * <p>
50.88 + * If a property is indexed, then its entry in the result array will
50.89 + * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
50.90 + * A client of getPropertyDescriptors can use "instanceof" to check
50.91 + * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
50.92 + */
50.93 + public PropertyDescriptor[] getPropertyDescriptors() {
50.94 + return getPdescriptor();
50.95 + }
50.96 +
50.97 + /**
50.98 + * Gets the bean's <code>EventSetDescriptor</code>s.
50.99 + *
50.100 + * @return An array of EventSetDescriptors describing the kinds of
50.101 + * events fired by this bean. May return null if the information
50.102 + * should be obtained by automatic analysis.
50.103 + */
50.104 + public EventSetDescriptor[] getEventSetDescriptors() {
50.105 + return getEdescriptor();
50.106 + }
50.107 +
50.108 + /**
50.109 + * Gets the bean's <code>MethodDescriptor</code>s.
50.110 + *
50.111 + * @return An array of MethodDescriptors describing the methods
50.112 + * implemented by this bean. May return null if the information
50.113 + * should be obtained by automatic analysis.
50.114 + */
50.115 + public MethodDescriptor[] getMethodDescriptors() {
50.116 + return getMdescriptor();
50.117 + }
50.118 +
50.119 + /**
50.120 + * A bean may have a "default" property that is the property that will
50.121 + * mostly commonly be initially chosen for update by human's who are
50.122 + * customizing the bean.
50.123 + * @return Index of default property in the PropertyDescriptor array
50.124 + * returned by getPropertyDescriptors.
50.125 + * <P> Returns -1 if there is no default property.
50.126 + */
50.127 + public int getDefaultPropertyIndex() {
50.128 + return defaultPropertyIndex;
50.129 + }
50.130 +
50.131 + /**
50.132 + * A bean may have a "default" event that is the event that will
50.133 + * mostly commonly be used by human's when using the bean.
50.134 + * @return Index of default event in the EventSetDescriptor array
50.135 + * returned by getEventSetDescriptors.
50.136 + * <P> Returns -1 if there is no default event.
50.137 + */
50.138 + public int getDefaultEventIndex() {
50.139 + return defaultEventIndex;
50.140 + }
50.141 +}
50.142 +
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/PropertyEditor.html Wed Jul 27 10:35:25 2011 +0200
51.3 @@ -0,0 +1,49 @@
51.4 +<!--
51.5 + -- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
51.6 + --
51.7 + -- Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
51.8 + --
51.9 + -- The contents of this file are subject to the terms of either the GNU
51.10 + -- General Public License Version 2 only ("GPL") or the Common
51.11 + -- Development and Distribution License("CDDL") (collectively, the
51.12 + -- "License"). You may not use this file except in compliance with the
51.13 + -- License. You can obtain a copy of the License at
51.14 + -- http://www.netbeans.org/cddl-gplv2.html
51.15 + -- or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
51.16 + -- specific language governing permissions and limitations under the
51.17 + -- License. When distributing the software, include this License Header
51.18 + -- Notice in each file and include the License file at
51.19 + -- nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
51.20 + -- particular file as subject to the "Classpath" exception as provided
51.21 + -- by Sun in the GPL Version 2 section of the License file that
51.22 + -- accompanied this code. If applicable, add the following below the
51.23 + -- License Header, with the fields enclosed by brackets [] replaced by
51.24 + -- your own identifying information:
51.25 + -- "Portions Copyrighted [year] [name of copyright owner]"
51.26 + --
51.27 + -- Contributor(s):
51.28 + --
51.29 + -- The Original Software is NetBeans. The Initial Developer of the Original
51.30 + -- Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
51.31 + -- Microsystems, Inc. All Rights Reserved.
51.32 + --
51.33 + -- If you wish your version of this file to be governed by only the CDDL
51.34 + -- or only the GPL Version 2, indicate your decision by adding
51.35 + -- "[Contributor] elects to include this software in this distribution
51.36 + -- under the [CDDL or GPL Version 2] license." If you do not indicate a
51.37 + -- single choice of license, a recipient has the option to distribute
51.38 + -- your version of this file under either the CDDL, the GPL Version 2 or
51.39 + -- to extend the choice of license to its licensees as provided above.
51.40 + -- However, if you add GPL Version 2 code and therefore, elected the GPL
51.41 + -- Version 2 license, then the option applies only if the new code is
51.42 + -- made subject to such option by the copyright holder.
51.43 + -->
51.44 +
51.45 +<html>
51.46 +<head>
51.47 + <meta http-equiv="content-type" content="text/html; charset=UTF-8">
51.48 +</head>
51.49 +<BODY>
51.50 +Creates a <code>PropertyEditor</code> class. Property editors are used
51.51 +at design time in IDEs to support editing of the properties of JavaBeans components.
51.52 +</BODY></HTML>
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/PropertyEditor.java.template Wed Jul 27 10:35:25 2011 +0200
52.3 @@ -0,0 +1,22 @@
52.4 +<#-- FreeMarker template (see http://freemarker.org/) -->
52.5 +<#assign licenseFirst = "/*">
52.6 +<#assign licensePrefix = " * ">
52.7 +<#assign licenseLast = " */">
52.8 +<#include "../Licenses/license-${project.license}.txt">
52.9 +
52.10 +<#if package?? && package != "">
52.11 +package ${package};
52.12 +
52.13 +</#if>
52.14 +import java.beans.*;
52.15 +
52.16 +/**
52.17 + *
52.18 + * @author ${user}
52.19 + */
52.20 +public class ${name} extends PropertyEditorSupport {
52.21 +
52.22 + public ${name}() {
52.23 + }
52.24 +
52.25 +}
53.1 --- a/beans/src/org/netbeans/modules/beans/resources/templates/PropertyEditor.template Wed Jul 27 10:33:10 2011 +0200
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,22 +0,0 @@
53.4 -<#-- FreeMarker template (see http://freemarker.org/) -->
53.5 -<#assign licenseFirst = "/*">
53.6 -<#assign licensePrefix = " * ">
53.7 -<#assign licenseLast = " */">
53.8 -<#include "../Licenses/license-${project.license}.txt">
53.9 -
53.10 -<#if package?? && package != "">
53.11 -package ${package};
53.12 -
53.13 -</#if>
53.14 -import java.beans.*;
53.15 -
53.16 -/**
53.17 - *
53.18 - * @author ${user}
53.19 - */
53.20 -public class ${name} extends PropertyEditorSupport {
53.21 -
53.22 - public ${name}() {
53.23 - }
53.24 -
53.25 -}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/beans/src/org/netbeans/modules/beans/resources/templates/Templates.java Wed Jul 27 10:35:25 2011 +0200
54.3 @@ -0,0 +1,61 @@
54.4 +/*
54.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
54.6 + *
54.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
54.8 + *
54.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
54.10 + * Other names may be trademarks of their respective owners.
54.11 + *
54.12 + * The contents of this file are subject to the terms of either the GNU
54.13 + * General Public License Version 2 only ("GPL") or the Common Development and
54.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
54.15 + * this file except in compliance with the License. You can obtain a copy of
54.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
54.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
54.18 + * governing permissions and limitations under the License. When distributing
54.19 + * the software, include this License Header Notice in each file and include
54.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
54.21 + * particular file as subject to the "Classpath" exception as provided by
54.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
54.23 + * this code. If applicable, add the following below the License Header, with
54.24 + * the fields enclosed by brackets [] replaced by your own identifying
54.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
54.26 + *
54.27 + * If you wish your version of this file to be governed by only the CDDL or
54.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
54.29 + * elects to include this software in this distribution under the [CDDL or GPL
54.30 + * Version 2] license." If you do not indicate a single choice of license, a
54.31 + * recipient has the option to distribute your version of this file under
54.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
54.33 + * licensees as provided above. However, if you add GPL Version 2 code and
54.34 + * therefore, elected the GPL Version 2 license, then the option applies only
54.35 + * if the new code is made subject to such option by the copyright holder.
54.36 + *
54.37 + * Contributor(s):
54.38 + *
54.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
54.40 + */
54.41 +
54.42 +package org.netbeans.modules.beans.resources.templates;
54.43 +
54.44 +import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates;
54.45 +import org.netbeans.api.templates.TemplateRegistration;
54.46 +import org.netbeans.api.templates.TemplateRegistrations;
54.47 +import org.openide.WizardDescriptor;
54.48 +
54.49 +public class Templates {
54.50 +
54.51 + @TemplateRegistrations({
54.52 + @TemplateRegistration(folder="Beans", position=100, content="Bean.java.template", displayName="org.netbeans.modules.beans.Bundle#Templates/Beans/Bean.java", iconBase=JavaTemplates.JAVA_ICON, description="Bean.html", category="java-beans", scriptEngine="freemarker"),
54.53 + @TemplateRegistration(folder="Beans", position=200, content="BeanInfo.java.template", displayName="org.netbeans.modules.beans.Bundle#Templates/Beans/BeanInfo.java", iconBase=JavaTemplates.JAVA_ICON, description="BeanInfo.html", category="java-beans", scriptEngine="freemarker"),
54.54 + @TemplateRegistration(folder="Beans", position=300, content="NoIconBeanInfo.java.template", displayName="org.netbeans.modules.beans.Bundle#Templates/Beans/NoIconBeanInfo.java", iconBase=JavaTemplates.JAVA_ICON, description="BeanInfo.html", category="java-beans", scriptEngine="freemarker"),
54.55 + @TemplateRegistration(folder="Beans", position=400, content={"Customizer.java.template", "Customizer.form.template"}, displayName="org.netbeans.modules.beans.Bundle#Templates/Beans/Customizer.java", description="Customizer.html", category="java-beans", scriptEngine="freemarker"),
54.56 + @TemplateRegistration(folder="Beans", position=600, content="PropertyEditor.java.template", displayName="org.netbeans.modules.beans.Bundle#Templates/Beans/PropertyEditor.java", iconBase=JavaTemplates.JAVA_ICON, description="PropertyEditor.html", category="java-beans", scriptEngine="freemarker")
54.57 + })
54.58 + public static WizardDescriptor.InstantiatingIterator<?> wizard() {
54.59 + return JavaTemplates.createJavaTemplateIterator();
54.60 + }
54.61 +
54.62 + private Templates() {}
54.63 +
54.64 +}
55.1 --- a/bugtracking/manifest.mf Wed Jul 27 10:33:10 2011 +0200
55.2 +++ b/bugtracking/manifest.mf Wed Jul 27 10:35:25 2011 +0200
55.3 @@ -3,5 +3,5 @@
55.4 OpenIDE-Module: org.netbeans.modules.bugtracking
55.5 OpenIDE-Module-Layer: org/netbeans/modules/bugtracking/layer.xml
55.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/bugtracking/Bundle.properties
55.7 -OpenIDE-Module-Specification-Version: 1.14
55.8 +OpenIDE-Module-Specification-Version: 1.15
55.9
56.1 --- a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueTopComponent.form Wed Jul 27 10:33:10 2011 +0200
56.2 +++ b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueTopComponent.form Wed Jul 27 10:35:25 2011 +0200
56.3 @@ -1,4 +1,4 @@
56.4 -<?xml version="1.1" encoding="UTF-8" ?>
56.5 +<?xml version="1.0" encoding="UTF-8" ?>
56.6
56.7 <Form version="1.4" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
56.8 <AuxValues>
56.9 @@ -17,15 +17,15 @@
56.10 <DimensionLayout dim="0">
56.11 <Group type="103" groupAlignment="0" attributes="0">
56.12 <Component id="repoPanel" alignment="0" max="32767" attributes="2"/>
56.13 - <Component id="issuePanel" alignment="0" pref="473" max="32767" attributes="0"/>
56.14 + <Component id="issuePanel" alignment="0" pref="466" max="32767" attributes="0"/>
56.15 </Group>
56.16 </DimensionLayout>
56.17 <DimensionLayout dim="1">
56.18 <Group type="103" groupAlignment="0" attributes="0">
56.19 <Group type="102" alignment="0" attributes="0">
56.20 <Component id="repoPanel" min="-2" max="-2" attributes="0"/>
56.21 - <EmptySpace max="-2" attributes="0"/>
56.22 - <Component id="issuePanel" max="32767" attributes="0"/>
56.23 + <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
56.24 + <Component id="issuePanel" pref="36" max="32767" attributes="0"/>
56.25 </Group>
56.26 </Group>
56.27 </DimensionLayout>
57.1 --- a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueTopComponent.java Wed Jul 27 10:33:10 2011 +0200
57.2 +++ b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueTopComponent.java Wed Jul 27 10:35:25 2011 +0200
57.3 @@ -303,14 +303,14 @@
57.4 layout.setHorizontalGroup(
57.5 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
57.6 .addComponent(repoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
57.7 - .addComponent(issuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
57.8 + .addComponent(issuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
57.9 );
57.10 layout.setVerticalGroup(
57.11 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
57.12 .addGroup(layout.createSequentialGroup()
57.13 .addComponent(repoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
57.14 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
57.15 - .addComponent(issuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
57.16 + .addGap(0, 0, 0)
57.17 + .addComponent(issuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE))
57.18 );
57.19 }// </editor-fold>//GEN-END:initComponents
57.20
58.1 --- a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/PatchContextChooser.java Wed Jul 27 10:33:10 2011 +0200
58.2 +++ b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/PatchContextChooser.java Wed Jul 27 10:35:25 2011 +0200
58.3 @@ -45,6 +45,8 @@
58.4 import java.beans.PropertyChangeEvent;
58.5 import java.beans.PropertyChangeListener;
58.6 import java.io.File;
58.7 +import java.util.Collections;
58.8 +import java.util.Comparator;
58.9 import java.util.LinkedList;
58.10 import java.util.List;
58.11 import javax.swing.tree.TreeSelectionModel;
58.12 @@ -84,6 +86,20 @@
58.13 nodes.add(node);
58.14 }
58.15 }
58.16 + Collections.sort(nodes, new Comparator<Node>() {
58.17 + @Override public int compare(Node n1, Node n2) {
58.18 + if(n1 == null && n2 == null) {
58.19 + return 0;
58.20 + }
58.21 + if(n1 == null) {
58.22 + return -1;
58.23 + }
58.24 + if(n2 == null) {
58.25 + return 1;
58.26 + }
58.27 + return n1.getDisplayName().compareTo(n2.getDisplayName());
58.28 + }
58.29 + });
58.30 Children.Array children = new Children.Array();
58.31 children.add(nodes.toArray(new Node[nodes.size()]));
58.32 AbstractNode root = new AbstractNode(children);
59.1 --- a/bugtracking/src/org/netbeans/modules/bugtracking/util/HyperlinkSupport.java Wed Jul 27 10:33:10 2011 +0200
59.2 +++ b/bugtracking/src/org/netbeans/modules/bugtracking/util/HyperlinkSupport.java Wed Jul 27 10:35:25 2011 +0200
59.3 @@ -70,7 +70,7 @@
59.4 final static String STACKTRACE_ATTRIBUTE = "attribute.stacktrace.link"; // NOI18N
59.5 final static String TYPE_ATTRIBUTE = "attribute.type.link"; // NOI18N
59.6 final static String URL_ATTRIBUTE = "attribute.url.link"; // NOI18N
59.7 - final static String LINK_ATTRIBUTE = "attribute.simple.link"; // NOI18N
59.8 + public final static String LINK_ATTRIBUTE = "attribute.simple.link"; // NOI18N
59.9 private final MotionListener motionListener;
59.10 private final java.awt.event.MouseListener mouseListener;
59.11
60.1 --- a/bugzilla/manifest.mf Wed Jul 27 10:33:10 2011 +0200
60.2 +++ b/bugzilla/manifest.mf Wed Jul 27 10:35:25 2011 +0200
60.3 @@ -4,5 +4,5 @@
60.4 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/bugzilla/Bundle.properties
60.5 OpenIDE-Module-Layer: org/netbeans/modules/bugzilla/layer.xml
60.6 OpenIDE-Module-Install: org/netbeans/modules/bugzilla/ModuleLifecycleManager.class
60.7 -OpenIDE-Module-Specification-Version: 1.11
60.8 +OpenIDE-Module-Specification-Version: 1.13
60.9
61.1 --- a/bugzilla/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
61.2 +++ b/bugzilla/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
61.3 @@ -51,7 +51,7 @@
61.4 <build-prerequisite/>
61.5 <compile-dependency/>
61.6 <run-dependency>
61.7 - <specification-version>1.14</specification-version>
61.8 + <specification-version>1.15</specification-version>
61.9 </run-dependency>
61.10 </dependency>
61.11 <dependency>
62.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/AttachmentsPanel.java Wed Jul 27 10:33:10 2011 +0200
62.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/AttachmentsPanel.java Wed Jul 27 10:35:25 2011 +0200
62.3 @@ -236,7 +236,7 @@
62.4 int groupWidth = 0;
62.5 if (maxMethod != null) {
62.6 try {
62.7 - groupWidth = (Integer)maxMethod.invoke(horizontalGroup, 1);
62.8 + groupWidth = (Integer)maxMethod.invoke(horizontalGroup, 0);
62.9 } catch (Exception ex) {
62.10 Bugzilla.LOG.log(Level.INFO, ex.getMessage(), ex);
62.11 }
62.12 @@ -250,7 +250,7 @@
62.13 .addGap(0, 0, Short.MAX_VALUE));
62.14 verticalGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
62.15 verticalGroup.addComponent(noAttachments ? dummyLabel : createNewButton);
62.16 -
62.17 +
62.18 layout.setHorizontalGroup(horizontalGroup);
62.19 layout.setVerticalGroup(verticalGroup);
62.20 ((CreateNewAction)createNewButton.getAction()).setLayoutGroups(horizontalGroup, newVerticalGroup);
63.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java Wed Jul 27 10:33:10 2011 +0200
63.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java Wed Jul 27 10:35:25 2011 +0200
63.3 @@ -732,6 +732,17 @@
63.4 return true;
63.5 }
63.6 }
63.7 +
63.8 + boolean canAssignToDefault() {
63.9 + BugzillaConfiguration rc = getBugzillaRepository().getConfiguration();
63.10 + final BugzillaVersion installedVersion = rc != null ? rc.getInstalledVersion() : null;
63.11 + boolean oldRepository = installedVersion != null ? installedVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) <= 0 : false;
63.12 + if(oldRepository) {
63.13 + return data.getRoot().getMappedAttribute(BugzillaOperation.reassignbycomponent.getInputId()) != null;
63.14 + } else {
63.15 + return data.getRoot().getAttribute(BugzillaAttribute.SET_DEFAULT_ASSIGNEE.getKey()) != null;
63.16 + }
63.17 + }
63.18
63.19 void reassign(String user) {
63.20 setOperation(BugzillaOperation.reassign);
63.21 @@ -1127,7 +1138,14 @@
63.22 TaskAttribute nameAttr = authorAttr.getMappedAttribute(TaskAttribute.PERSON_NAME);
63.23 authorName = nameAttr != null ? nameAttr.getValue() : null;
63.24 } else {
63.25 - author = authorName = null;
63.26 + authorAttr = data.getRoot().getMappedAttribute(IssueField.REPORTER.getKey());
63.27 + if(authorAttr != null) {
63.28 + author = authorAttr.getValue();
63.29 + TaskAttribute nameAttr = authorAttr.getMappedAttribute(TaskAttribute.PERSON_NAME);
63.30 + authorName = nameAttr != null ? nameAttr.getValue() : null;
63.31 + } else {
63.32 + author = authorName = null;
63.33 + }
63.34 }
63.35 contentType = getMappedValue(ta, TaskAttribute.ATTACHMENT_CONTENT_TYPE);
63.36 isDeprected = getMappedValue(ta, TaskAttribute.ATTACHMENT_IS_DEPRECATED);
64.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/CommentsPanel.java Wed Jul 27 10:33:10 2011 +0200
64.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/CommentsPanel.java Wed Jul 27 10:35:25 2011 +0200
64.3 @@ -82,6 +82,8 @@
64.4 import javax.swing.plaf.basic.BasicTreeUI;
64.5 import javax.swing.text.Caret;
64.6 import javax.swing.text.DefaultCaret;
64.7 +import javax.swing.text.Element;
64.8 +import javax.swing.text.StyledDocument;
64.9 import org.netbeans.modules.bugtracking.spi.Issue;
64.10 import org.netbeans.modules.bugtracking.kenai.spi.KenaiUtil;
64.11 import org.netbeans.modules.bugtracking.ui.issue.cache.IssueSettingsStorage;
64.12 @@ -465,14 +467,18 @@
64.13 public void setVisible(boolean b) {
64.14 if (b) {
64.15 JTextPane pane = (JTextPane) getInvoker();
64.16 - BugzillaIssue.Attachment attachment = getAttachment(pane);
64.17 - if (attachment != null) {
64.18 - add(new JMenuItem(attachment.new DefaultAttachmentAction()));
64.19 - add(new JMenuItem(attachment.new SaveAttachmentAction()));
64.20 - if ("1".equals(attachment.getIsPatch())) { // NOI18N
64.21 - add(attachment.new ApplyPatchAction());
64.22 + StyledDocument doc = pane.getStyledDocument();
64.23 + Element elem = doc.getCharacterElement(pane.viewToModel(clickPoint));
64.24 + if (elem.getAttributes().getAttribute(HyperlinkSupport.LINK_ATTRIBUTE) != null) {
64.25 + BugzillaIssue.Attachment attachment = getAttachment(pane);
64.26 + if (attachment != null) {
64.27 + add(new JMenuItem(attachment.new DefaultAttachmentAction()));
64.28 + add(new JMenuItem(attachment.new SaveAttachmentAction()));
64.29 + if ("1".equals(attachment.getIsPatch())) { // NOI18N
64.30 + add(attachment.new ApplyPatchAction());
64.31 + }
64.32 + super.setVisible(true);
64.33 }
64.34 - super.setVisible(true);
64.35 }
64.36 } else {
64.37 super.setVisible(false);
65.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form Wed Jul 27 10:33:10 2011 +0200
65.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form Wed Jul 27 10:35:25 2011 +0200
65.3 @@ -1,4 +1,4 @@
65.4 -<?xml version="1.1" encoding="UTF-8" ?>
65.5 +<?xml version="1.0" encoding="UTF-8" ?>
65.6
65.7 <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
65.8 <NonVisualComponents>
65.9 @@ -1115,6 +1115,9 @@
65.10 </Component>
65.11 <Component class="javax.swing.JCheckBox" name="assignToDefaultCheckBox">
65.12 <Properties>
65.13 + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
65.14 + <Color blue="ff" green="ff" id="EditorPane.background" palette="3" red="ff" type="palette"/>
65.15 + </Property>
65.16 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
65.17 <ResourceString bundle="org/netbeans/modules/bugzilla/issue/Bundle.properties" key="IssuePanel.assignToDefaultCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
65.18 </Property>
66.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java Wed Jul 27 10:33:10 2011 +0200
66.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java Wed Jul 27 10:35:25 2011 +0200
66.3 @@ -443,7 +443,7 @@
66.4 reportedField.setVisible(!isNew);
66.5 modifiedLabel.setVisible(!isNew);
66.6 modifiedField.setVisible(!isNew);
66.7 - assignToDefaultCheckBox.setVisible(!isNew);
66.8 + assignToDefaultCheckBox.setVisible(!isNew && issue.canAssignToDefault());
66.9 assignToDefaultCheckBox.setSelected(false);
66.10 statusLabel.setVisible(!isNew);
66.11 statusCombo.setVisible(!isNew);
66.12 @@ -1615,6 +1615,7 @@
66.13 org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(IssuePanel.class, "IssuePanel.cancelButton.text")); // NOI18N
66.14 cancelButton.addActionListener(formListener);
66.15
66.16 + assignToDefaultCheckBox.setBackground(javax.swing.UIManager.getDefaults().getColor("EditorPane.background"));
66.17 org.openide.awt.Mnemonics.setLocalizedText(assignToDefaultCheckBox, org.openide.util.NbBundle.getMessage(IssuePanel.class, "IssuePanel.assignToDefaultCheckBox.text")); // NOI18N
66.18
66.19 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
66.20 @@ -1997,6 +1998,9 @@
66.21 else if (evt.getSource() == priorityCombo) {
66.22 IssuePanel.this.priorityComboActionPerformed(evt);
66.23 }
66.24 + else if (evt.getSource() == urlLabel) {
66.25 + IssuePanel.this.urlButtonActionPerformed(evt);
66.26 + }
66.27 else if (evt.getSource() == issueTypeCombo) {
66.28 IssuePanel.this.issueTypeComboActionPerformed(evt);
66.29 }
66.30 @@ -2012,9 +2016,6 @@
66.31 else if (evt.getSource() == assignedCombo) {
66.32 IssuePanel.this.assignedComboActionPerformed(evt);
66.33 }
66.34 - else if (evt.getSource() == urlLabel) {
66.35 - IssuePanel.this.urlButtonActionPerformed(evt);
66.36 - }
66.37 }
66.38 }// </editor-fold>//GEN-END:initComponents
66.39
67.1 --- a/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java Wed Jul 27 10:33:10 2011 +0200
67.2 +++ b/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java Wed Jul 27 10:35:25 2011 +0200
67.3 @@ -691,11 +691,13 @@
67.4 }
67.5
67.6 private void onGotoIssue() {
67.7 - final String id = panel.idTextField.getText().trim();
67.8 - if(id == null || id.trim().equals("") ) { // NOI18N
67.9 + String idText = panel.idTextField.getText().trim();
67.10 + if(idText == null || idText.trim().equals("") ) { // NOI18N
67.11 return;
67.12 }
67.13
67.14 + final String id = idText.replaceAll("\\s", ""); // NOI18N
67.15 +
67.16 final Task[] t = new Task[1];
67.17 Cancellable c = new Cancellable() {
67.18 @Override
68.1 --- a/core.multiview/src/org/netbeans/core/multiview/MultiViewProcessor.java Wed Jul 27 10:33:10 2011 +0200
68.2 +++ b/core.multiview/src/org/netbeans/core/multiview/MultiViewProcessor.java Wed Jul 27 10:35:25 2011 +0200
68.3 @@ -95,10 +95,10 @@
68.4 for (Element e : roundEnv.getElementsAnnotatedWith(MultiViewElement.Registration.class)) {
68.5 MultiViewElement.Registration mvr = e.getAnnotation(MultiViewElement.Registration.class);
68.6 if (mvr.mimeType().length == 0) {
68.7 - throw new LayerGenerationException("You must specify mimeType", e);
68.8 + throw new LayerGenerationException("You must specify mimeType", e, processingEnv, mvr, "mimeType");
68.9 }
68.10 TypeMirror[] exprType = new TypeMirror[1];
68.11 - String[] binAndMethodNames = findDefinition(e, exprType);
68.12 + String[] binAndMethodNames = findDefinition(e, exprType, mvr);
68.13 String fileBaseName = binAndMethodNames[0].replace('.', '-');
68.14 if (binAndMethodNames[1] != null) {
68.15 fileBaseName += "-" + binAndMethodNames[1];
68.16 @@ -108,7 +108,7 @@
68.17 f.methodvalue("instanceCreate", MultiViewFactory.class.getName(), "createMultiViewDescription");
68.18 f.stringvalue("instanceClass", ContextAwareDescription.class.getName());
68.19 f.stringvalue("class", binAndMethodNames[0]);
68.20 - f.bundlevalue("displayName", mvr.displayName());
68.21 + f.bundlevalue("displayName", mvr.displayName(), mvr, "displayName");
68.22 f.stringvalue("iconBase", mvr.iconBase());
68.23 f.stringvalue("preferredID", mvr.preferredID());
68.24 f.intvalue("persistenceType", mvr.persistenceType());
68.25 @@ -125,13 +125,13 @@
68.26 return true;
68.27 }
68.28
68.29 - private String[] findDefinition(Element e, TypeMirror[] type) throws LayerGenerationException {
68.30 + private String[] findDefinition(Element e, TypeMirror[] type, MultiViewElement.Registration mvr) throws LayerGenerationException {
68.31 final TypeMirror lkp = processingEnv.getElementUtils().getTypeElement(Lookup.class.getCanonicalName()).asType();
68.32 final TypeMirror mve = processingEnv.getElementUtils().getTypeElement(MultiViewElement.class.getName()).asType();
68.33 if (e.getKind() == ElementKind.CLASS) {
68.34 TypeElement clazz = (TypeElement) e;
68.35 if (!processingEnv.getTypeUtils().isAssignable(clazz.asType(), mve)) {
68.36 - throw new LayerGenerationException("Not assignable to " + mve, e);
68.37 + throw new LayerGenerationException("Not assignable to " + mve, e, processingEnv, mvr);
68.38 }
68.39 int constructorCount = 0;
68.40 CONSTRUCTOR: for (ExecutableElement constructor : ElementFilter.constructorsIn(clazz.getEnclosedElements())) {
68.41 @@ -149,32 +149,32 @@
68.42 }
68.43 }
68.44 if (!clazz.getModifiers().contains(Modifier.PUBLIC)) {
68.45 - throw new LayerGenerationException("Class must be public", e);
68.46 + throw new LayerGenerationException("Class must be public", e, processingEnv, mvr);
68.47 }
68.48 type[0] = e.asType();
68.49 return new String[] {processingEnv.getElementUtils().getBinaryName(clazz).toString(), null};
68.50 } else {
68.51 ExecutableElement meth = (ExecutableElement) e;
68.52 if (!processingEnv.getTypeUtils().isAssignable(meth.getReturnType(), mve)) {
68.53 - throw new LayerGenerationException("Not assignable to " + mve, e);
68.54 + throw new LayerGenerationException("Not assignable to " + mve, e, processingEnv, mvr);
68.55 }
68.56 if (!meth.getModifiers().contains(Modifier.PUBLIC)) {
68.57 - throw new LayerGenerationException("Method must be public", e);
68.58 + throw new LayerGenerationException("Method must be public", e, processingEnv, mvr);
68.59 }
68.60 if (!meth.getModifiers().contains(Modifier.STATIC)) {
68.61 - throw new LayerGenerationException("Method must be static", e);
68.62 + throw new LayerGenerationException("Method must be static", e, processingEnv, mvr);
68.63 }
68.64 List<? extends VariableElement> params = meth.getParameters();
68.65 if (params.size() > 1) {
68.66 - throw new LayerGenerationException("Method must take at most one parameter", e);
68.67 + throw new LayerGenerationException("Method must take at most one parameter", e, processingEnv, mvr);
68.68 }
68.69 for (VariableElement param : params) {
68.70 if (!param.asType().equals(lkp)) {
68.71 - throw new LayerGenerationException("Method parameters may be either Lookup or Project", e);
68.72 + throw new LayerGenerationException("Method parameters may be either Lookup or Project", e, processingEnv, mvr);
68.73 }
68.74 }
68.75 if (!meth.getEnclosingElement().getModifiers().contains(Modifier.PUBLIC)) {
68.76 - throw new LayerGenerationException("Class must be public", e);
68.77 + throw new LayerGenerationException("Class must be public", e, processingEnv, mvr);
68.78 }
68.79 type[0] = meth.getReturnType();
68.80 return new String[] {
69.1 --- a/core.ui/src/org/netbeans/core/ui/resources/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
69.2 +++ b/core.ui/src/org/netbeans/core/ui/resources/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
69.3 @@ -63,8 +63,6 @@
69.4 Menu/View=&View
69.5 Menu/Window/SelectDocumentNode=Select Docume&nt in
69.6 Services/Browsers=Web Browsers
69.7 -Templates/Privileged=Privileged
69.8 -Templates/Recent=Recent
69.9 Templates/Services/Browsers=Web Browsers
69.10 Toolbars=Toolbars
69.11 Toolbars/Clipboard=Cli&pboard
70.1 --- a/core.ui/src/org/netbeans/core/ui/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
70.2 +++ b/core.ui/src/org/netbeans/core/ui/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
70.3 @@ -450,25 +450,6 @@
70.4 </folder>
70.5
70.6 </folder>
70.7 -
70.8 - <!-- XXX these two should be elsewhere, probably (core/favorites?): -->
70.9 -
70.10 - <!-- folder for all privileged templates -->
70.11 - <folder name="Privileged">
70.12 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.core.ui.resources.Bundle"/>
70.13 - <!-- a value to signal that this folder should not be visible in the simple new from template wizard -->
70.14 - <attr name="simple" boolvalue="false"/>
70.15 - <attr name="position" intvalue="0"/>
70.16 - </folder>
70.17 -
70.18 - <!-- folder for all recent templates -->
70.19 - <folder name="Recent">
70.20 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.core.ui.resources.Bundle"/>
70.21 - <!-- a value to signal that this folder should not be visible in the simple new from template wizard -->
70.22 - <attr name="simple" boolvalue="false"/>
70.23 - <attr name="position" intvalue="0"/>
70.24 - </folder>
70.25 -
70.26 </folder>
70.27
70.28 <folder name="Services">
71.1 --- a/debugger.jpda.ui/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
71.2 +++ b/debugger.jpda.ui/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
71.3 @@ -242,7 +242,10 @@
71.4 </run-dependency>
71.5 </dependency>
71.6 </module-dependencies>
71.7 - <public-packages/>
71.8 + <friend-packages>
71.9 + <friend>org.netbeans.modules.debugger.jpda.visual</friend>
71.10 + <package>org.netbeans.modules.debugger.jpda.ui.options</package>
71.11 + </friend-packages>
71.12 </data>
71.13 </configuration>
71.14 </project>
72.1 --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelFormatters.java Wed Jul 27 10:33:10 2011 +0200
72.2 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelFormatters.java Wed Jul 27 10:35:25 2011 +0200
72.3 @@ -708,7 +708,7 @@
72.4 }*/
72.5
72.6 @Override
72.7 - void load() {
72.8 + public void load() {
72.9 VariablesFormatter[] formatters = VariablesFormatter.loadFormatters();
72.10 DefaultListModel filterClassesModel = (DefaultListModel) formattersList.getModel();
72.11 filterClassesModel.clear();
72.12 @@ -723,7 +723,7 @@
72.13 }
72.14
72.15 @Override
72.16 - void store() {
72.17 + public void store() {
72.18 /*if (selectedVariablesFormatter != null) {
72.19 storeSelectedFormatter(selectedVariablesFormatter);
72.20 }*/
73.1 --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelGeneral.java Wed Jul 27 10:33:10 2011 +0200
73.2 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelGeneral.java Wed Jul 27 10:35:25 2011 +0200
73.3 @@ -151,7 +151,7 @@
73.4 }// </editor-fold>//GEN-END:initComponents
73.5
73.6 @Override
73.7 - void load() {
73.8 + public void load() {
73.9 //Preferences p = NbPreferences.root().node("Debugger/JPDA");
73.10 Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
73.11 applyCodeChangesCheckBox.setSelected(p.getBoolean("ApplyCodeChangesOnSave", false));
73.12 @@ -163,7 +163,7 @@
73.13 }
73.14
73.15 @Override
73.16 - void store() {
73.17 + public void store() {
73.18 //Preferences p = NbPreferences.root().node("Debugger/JPDA");
73.19 Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
73.20 p.setBoolean("ApplyCodeChangesOnSave", applyCodeChangesCheckBox.isSelected());
74.1 --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelStepFilters.java Wed Jul 27 10:33:10 2011 +0200
74.2 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/CategoryPanelStepFilters.java Wed Jul 27 10:35:25 2011 +0200
74.3 @@ -343,7 +343,7 @@
74.4 }//GEN-LAST:event_filtersUncheckAllButtonActionPerformed
74.5
74.6 @Override
74.7 - void load() {
74.8 + public void load() {
74.9 //Preferences p = NbPreferences.root().node("Debugger/JPDA");
74.10 Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
74.11 useStepFiltersCheckBox.setSelected(p.getBoolean("UseStepFilters", true));
74.12 @@ -373,7 +373,7 @@
74.13 }
74.14
74.15 @Override
74.16 - void store() {
74.17 + public void store() {
74.18 Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
74.19 p.setBoolean("UseStepFilters", useStepFiltersCheckBox.isSelected());
74.20 p.setBoolean("FilterSyntheticMethods", filterSyntheticCheckBox.isSelected());
75.1 --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/JavaDebuggerPanel.java Wed Jul 27 10:33:10 2011 +0200
75.2 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/JavaDebuggerPanel.java Wed Jul 27 10:35:25 2011 +0200
75.3 @@ -42,6 +42,10 @@
75.4
75.5 package org.netbeans.modules.debugger.jpda.ui.options;
75.6
75.7 +import java.util.Collection;
75.8 +import org.openide.util.NbBundle;
75.9 +import org.openide.util.lookup.Lookups;
75.10 +
75.11 final class JavaDebuggerPanel extends StorablePanel {
75.12
75.13 private static final String SHOW_FORMATTERS_PROP_NAME = "org.netbeans.modules.debugger.jpda.ui.options.SHOW_FORMATTERS";
75.14 @@ -54,18 +58,23 @@
75.15 JavaDebuggerPanel(JavaDebuggerOptionsPanelController controller) {
75.16 this.controller = controller;
75.17 initComponents();
75.18 - categoryPanels = new StorablePanel[] {
75.19 - new CategoryPanelGeneral(),
75.20 - new CategoryPanelStepFilters(),
75.21 - new CategoryPanelFormatters(),
75.22 - };
75.23 + Collection<? extends Provider> panelProviders = Lookups.forPath("debugger/jpda/options").lookupAll(StorablePanel.Provider.class);
75.24 + categoryPanels = new StorablePanel[3 + panelProviders.size()];
75.25 + final String[] panelNames = new String[3 + panelProviders.size()];
75.26 + int i = 0;
75.27 + categoryPanels[i] = new CategoryPanelGeneral();
75.28 + panelNames[i++] = NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonGeneral.text");
75.29 + categoryPanels[i] = new CategoryPanelStepFilters();
75.30 + panelNames[i++] = NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonStepFilters.text");
75.31 + categoryPanels[i] = new CategoryPanelFormatters();
75.32 + panelNames[i++] = NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonFormatters.text");
75.33 + for (Provider p : panelProviders) {
75.34 + categoryPanels[i] = p.getPanel();
75.35 + panelNames[i++] = p.getPanelName();
75.36 + }
75.37 categoriesList.setModel(new javax.swing.AbstractListModel() {
75.38 - String[] strings = { org.openide.util.NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonGeneral.text"),
75.39 - org.openide.util.NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonStepFilters.text"),
75.40 - org.openide.util.NbBundle.getMessage(JavaDebuggerPanel.class, "JavaDebuggerPanel.categoryRadioButtonFormatters.text")
75.41 - };
75.42 - public int getSize() { return strings.length; }
75.43 - public Object getElementAt(int i) { return strings[i]; }
75.44 + public int getSize() { return panelNames.length; }
75.45 + public Object getElementAt(int i) { return panelNames[i]; }
75.46 });
75.47 String value = System.getProperty(SHOW_FORMATTERS_PROP_NAME);
75.48 int index = value != null && "true".equals(value) ? FORMATTERS_INDEX : 0; // NOI18N
75.49 @@ -163,7 +172,7 @@
75.50 categoryPanel.repaint();
75.51 }
75.52
75.53 - void load() {
75.54 + public void load() {
75.55 for (StorablePanel p : categoryPanels) {
75.56 p.load();
75.57 }
75.58 @@ -182,7 +191,7 @@
75.59 // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
75.60 }
75.61
75.62 - void store() {
75.63 + public void store() {
75.64 for (StorablePanel p : categoryPanels) {
75.65 p.store();
75.66 }
76.1 --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/StorablePanel.java Wed Jul 27 10:33:10 2011 +0200
76.2 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/options/StorablePanel.java Wed Jul 27 10:35:25 2011 +0200
76.3 @@ -46,16 +46,28 @@
76.4 *
76.5 * @author Martin Entlicher
76.6 */
76.7 -abstract class StorablePanel extends javax.swing.JPanel {
76.8 -
76.9 +public abstract class StorablePanel extends javax.swing.JPanel {
76.10 +
76.11 /**
76.12 * Read settings and initialize GUI
76.13 */
76.14 - abstract void load();
76.15 + public abstract void load();
76.16
76.17 /**
76.18 * Store modified settings
76.19 */
76.20 - abstract void store();
76.21 + public abstract void store();
76.22 +
76.23 +
76.24 + public static interface Provider {
76.25 +
76.26 + /**
76.27 + * Provides the display name of the panel.
76.28 + * @return The display name of the panel
76.29 + */
76.30 + public abstract String getPanelName();
76.31 +
76.32 + public StorablePanel getPanel();
76.33 + }
76.34
76.35 }
77.1 --- a/debugger.jpda.visual/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
77.2 +++ b/debugger.jpda.visual/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
77.3 @@ -76,6 +76,15 @@
77.4 </run-dependency>
77.5 </dependency>
77.6 <dependency>
77.7 + <code-name-base>org.netbeans.modules.debugger.jpda.ui</code-name-base>
77.8 + <build-prerequisite/>
77.9 + <compile-dependency/>
77.10 + <run-dependency>
77.11 + <release-version>1</release-version>
77.12 + <specification-version>1.21</specification-version>
77.13 + </run-dependency>
77.14 + </dependency>
77.15 + <dependency>
77.16 <code-name-base>org.netbeans.modules.java.kit</code-name-base>
77.17 <run-dependency>
77.18 <specification-version>1.0</specification-version>
78.1 --- a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java Wed Jul 27 10:33:10 2011 +0200
78.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java Wed Jul 27 10:35:25 2011 +0200
78.3 @@ -64,6 +64,7 @@
78.4 import org.netbeans.api.debugger.DebuggerManagerAdapter;
78.5 import org.netbeans.api.debugger.DebuggerManagerListener;
78.6 import org.netbeans.api.debugger.LazyDebuggerManagerListener;
78.7 +import org.netbeans.api.debugger.Properties;
78.8 import org.netbeans.api.debugger.jpda.JPDADebugger;
78.9 import org.netbeans.api.debugger.jpda.JPDAThread;
78.10 import org.netbeans.api.debugger.jpda.MethodBreakpoint;
78.11 @@ -88,8 +89,10 @@
78.12 public void engineAdded(DebuggerEngine engine) {
78.13 // Create a BP in AWT and when hit, inject the remote service.
78.14 JPDADebugger debugger = engine.lookupFirst(null, JPDADebugger.class);
78.15 - logger.fine("engineAdded("+engine+"), debugger = "+debugger);
78.16 - if (debugger != null) {
78.17 + Properties p = Properties.getDefault().getProperties("debugger.options.JPDA.visual");
78.18 + boolean uploadAgent = p.getBoolean("UploadAgent", true);
78.19 + logger.fine("engineAdded("+engine+"), debugger = "+debugger+", uploadAgent = "+uploadAgent);
78.20 + if (debugger != null && uploadAgent) {
78.21 final MethodBreakpoint mb = MethodBreakpoint.create("java.awt.EventQueue", "getNextEvent");
78.22 mb.setBreakpointType(MethodBreakpoint.TYPE_METHOD_ENTRY);
78.23 mb.setSuspend(MethodBreakpoint.SUSPEND_EVENT_THREAD);
79.1 --- a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/mf-layer.xml Wed Jul 27 10:33:10 2011 +0200
79.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/mf-layer.xml Wed Jul 27 10:35:25 2011 +0200
79.3 @@ -78,5 +78,16 @@
79.4 </folder>
79.5 </folder>
79.6 </folder>
79.7 +
79.8 + <folder name="debugger">
79.9 + <folder name="jpda">
79.10 + <folder name="options">
79.11 + <file name="org-netbeans-modules-debugger-jpda-visual-options-VisualOptionsProvider.instance">
79.12 + <attr name="instanceClass" stringvalue="org.netbeans.modules.debugger.jpda.visual.options.VisualOptionsProvider"/>
79.13 + <attr name="instanceOf" stringvalue="org.netbeans.modules.debugger.jpda.ui.options.StorablePanel$Provider"/>
79.14 + </file>
79.15 + </folder>
79.16 + </folder>
79.17 + </folder>
79.18
79.19 </filesystem>
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/options/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
80.3 @@ -0,0 +1,45 @@
80.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
80.5 +#
80.6 +# Copyright 2011 Oracle and/or its affiliates. All rights reserved.
80.7 +#
80.8 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
80.9 +# Other names may be trademarks of their respective owners.
80.10 +#
80.11 +# The contents of this file are subject to the terms of either the GNU
80.12 +# General Public License Version 2 only ("GPL") or the Common
80.13 +# Development and Distribution License("CDDL") (collectively, the
80.14 +# "License"). You may not use this file except in compliance with the
80.15 +# License. You can obtain a copy of the License at
80.16 +# http://www.netbeans.org/cddl-gplv2.html
80.17 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
80.18 +# specific language governing permissions and limitations under the
80.19 +# License. When distributing the software, include this License Header
80.20 +# Notice in each file and include the License file at
80.21 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
80.22 +# particular file as subject to the "Classpath" exception as provided
80.23 +# by Oracle in the GPL Version 2 section of the License file that
80.24 +# accompanied this code. If applicable, add the following below the
80.25 +# License Header, with the fields enclosed by brackets [] replaced by
80.26 +# your own identifying information:
80.27 +# "Portions Copyrighted [year] [name of copyright owner]"
80.28 +#
80.29 +# If you wish your version of this file to be governed by only the CDDL
80.30 +# or only the GPL Version 2, indicate your decision by adding
80.31 +# "[Contributor] elects to include this software in this distribution
80.32 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
80.33 +# single choice of license, a recipient has the option to distribute
80.34 +# your version of this file under either the CDDL, the GPL Version 2 or
80.35 +# to extend the choice of license to its licensees as provided above.
80.36 +# However, if you add GPL Version 2 code and therefore, elected the GPL
80.37 +# Version 2 license, then the option applies only if the new code is
80.38 +# made subject to such option by the copyright holder.
80.39 +#
80.40 +# Contributor(s):
80.41 +#
80.42 +# Portions Copyrighted 2011 Sun Microsystems, Inc.
80.43 +
80.44 +# Tools Options Java Debugger category
80.45 +LBL_VisualDebugging=Visual Debugging
80.46 +CategoryPanelVisual.AgentCheckBox.text=Upload Visual Debugging agent to the target application
80.47 +CategoryPanelVisual.uploadAgentDescriptionLabel1.text=When this option is on, debugger will always upload an agent that is necessary for visual debugging.
80.48 +CategoryPanelVisual.uploadAgentDescriptionLabel2.text=When turned off, visual debugging will be disabled.
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
81.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/options/CategoryPanelVisual.form Wed Jul 27 10:35:25 2011 +0200
81.3 @@ -0,0 +1,72 @@
81.4 +<?xml version="1.1" encoding="UTF-8" ?>
81.5 +
81.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
81.7 + <AuxValues>
81.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
81.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
81.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
81.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
81.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
81.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
81.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
81.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
81.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
81.17 + </AuxValues>
81.18 +
81.19 + <Layout>
81.20 + <DimensionLayout dim="0">
81.21 + <Group type="103" groupAlignment="0" attributes="0">
81.22 + <Group type="102" alignment="0" attributes="0">
81.23 + <EmptySpace max="-2" attributes="0"/>
81.24 + <Component id="uploadAgentCheckBox" pref="726" max="32767" attributes="0"/>
81.25 + <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
81.26 + </Group>
81.27 + <Group type="102" alignment="1" attributes="0">
81.28 + <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
81.29 + <Component id="uploadAgentDescriptionLabel1" pref="705" max="32767" attributes="0"/>
81.30 + <EmptySpace max="-2" attributes="0"/>
81.31 + </Group>
81.32 + <Group type="102" alignment="1" attributes="0">
81.33 + <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
81.34 + <Component id="uploadAgentDescriptionLabel2" pref="705" max="32767" attributes="0"/>
81.35 + <EmptySpace max="-2" attributes="0"/>
81.36 + </Group>
81.37 + </Group>
81.38 + </DimensionLayout>
81.39 + <DimensionLayout dim="1">
81.40 + <Group type="103" groupAlignment="0" attributes="0">
81.41 + <Group type="102" alignment="0" attributes="0">
81.42 + <Component id="uploadAgentCheckBox" min="-2" max="-2" attributes="0"/>
81.43 + <EmptySpace max="-2" attributes="0"/>
81.44 + <Component id="uploadAgentDescriptionLabel1" min="-2" max="-2" attributes="0"/>
81.45 + <EmptySpace max="-2" attributes="0"/>
81.46 + <Component id="uploadAgentDescriptionLabel2" min="-2" max="-2" attributes="0"/>
81.47 + <EmptySpace pref="239" max="32767" attributes="0"/>
81.48 + </Group>
81.49 + </Group>
81.50 + </DimensionLayout>
81.51 + </Layout>
81.52 + <SubComponents>
81.53 + <Component class="javax.swing.JCheckBox" name="uploadAgentCheckBox">
81.54 + <Properties>
81.55 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81.56 + <ResourceString bundle="org/netbeans/modules/debugger/jpda/visual/options/Bundle.properties" key="CategoryPanelVisual.AgentCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
81.57 + </Property>
81.58 + </Properties>
81.59 + </Component>
81.60 + <Component class="javax.swing.JLabel" name="uploadAgentDescriptionLabel1">
81.61 + <Properties>
81.62 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81.63 + <ResourceString bundle="org/netbeans/modules/debugger/jpda/visual/options/Bundle.properties" key="CategoryPanelVisual.uploadAgentDescriptionLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
81.64 + </Property>
81.65 + </Properties>
81.66 + </Component>
81.67 + <Component class="javax.swing.JLabel" name="uploadAgentDescriptionLabel2">
81.68 + <Properties>
81.69 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81.70 + <ResourceString bundle="org/netbeans/modules/debugger/jpda/visual/options/Bundle.properties" key="CategoryPanelVisual.uploadAgentDescriptionLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
81.71 + </Property>
81.72 + </Properties>
81.73 + </Component>
81.74 + </SubComponents>
81.75 +</Form>
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
82.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/options/CategoryPanelVisual.java Wed Jul 27 10:35:25 2011 +0200
82.3 @@ -0,0 +1,127 @@
82.4 +/*
82.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
82.6 + *
82.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
82.8 + *
82.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
82.10 + * Other names may be trademarks of their respective owners.
82.11 + *
82.12 + * The contents of this file are subject to the terms of either the GNU
82.13 + * General Public License Version 2 only ("GPL") or the Common
82.14 + * Development and Distribution License("CDDL") (collectively, the
82.15 + * "License"). You may not use this file except in compliance with the
82.16 + * License. You can obtain a copy of the License at
82.17 + * http://www.netbeans.org/cddl-gplv2.html
82.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
82.19 + * specific language governing permissions and limitations under the
82.20 + * License. When distributing the software, include this License Header
82.21 + * Notice in each file and include the License file at
82.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
82.23 + * particular file as subject to the "Classpath" exception as provided
82.24 + * by Oracle in the GPL Version 2 section of the License file that
82.25 + * accompanied this code. If applicable, add the following below the
82.26 + * License Header, with the fields enclosed by brackets [] replaced by
82.27 + * your own identifying information:
82.28 + * "Portions Copyrighted [year] [name of copyright owner]"
82.29 + *
82.30 + * If you wish your version of this file to be governed by only the CDDL
82.31 + * or only the GPL Version 2, indicate your decision by adding
82.32 + * "[Contributor] elects to include this software in this distribution
82.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
82.34 + * single choice of license, a recipient has the option to distribute
82.35 + * your version of this file under either the CDDL, the GPL Version 2 or
82.36 + * to extend the choice of license to its licensees as provided above.
82.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
82.38 + * Version 2 license, then the option applies only if the new code is
82.39 + * made subject to such option by the copyright holder.
82.40 + *
82.41 + * Contributor(s):
82.42 + *
82.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
82.44 + */
82.45 +
82.46 +/*
82.47 + * CategoryPanelVisual.java
82.48 + *
82.49 + * Created on Jul 25, 2011, 3:39:52 PM
82.50 + */
82.51 +package org.netbeans.modules.debugger.jpda.visual.options;
82.52 +
82.53 +import org.netbeans.api.debugger.Properties;
82.54 +import org.netbeans.modules.debugger.jpda.ui.options.StorablePanel;
82.55 +
82.56 +/**
82.57 + *
82.58 + * @author martin
82.59 + */
82.60 +public class CategoryPanelVisual extends StorablePanel {
82.61 +
82.62 + /** Creates new form CategoryPanelVisual */
82.63 + public CategoryPanelVisual() {
82.64 + initComponents();
82.65 + }
82.66 +
82.67 + /** This method is called from within the constructor to
82.68 + * initialize the form.
82.69 + * WARNING: Do NOT modify this code. The content of this method is
82.70 + * always regenerated by the Form Editor.
82.71 + */
82.72 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
82.73 + private void initComponents() {
82.74 +
82.75 + uploadAgentCheckBox = new javax.swing.JCheckBox();
82.76 + uploadAgentDescriptionLabel1 = new javax.swing.JLabel();
82.77 + uploadAgentDescriptionLabel2 = new javax.swing.JLabel();
82.78 +
82.79 + uploadAgentCheckBox.setText(org.openide.util.NbBundle.getMessage(CategoryPanelVisual.class, "CategoryPanelVisual.AgentCheckBox.text")); // NOI18N
82.80 +
82.81 + uploadAgentDescriptionLabel1.setText(org.openide.util.NbBundle.getMessage(CategoryPanelVisual.class, "CategoryPanelVisual.uploadAgentDescriptionLabel1.text")); // NOI18N
82.82 +
82.83 + uploadAgentDescriptionLabel2.setText(org.openide.util.NbBundle.getMessage(CategoryPanelVisual.class, "CategoryPanelVisual.uploadAgentDescriptionLabel2.text")); // NOI18N
82.84 +
82.85 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
82.86 + this.setLayout(layout);
82.87 + layout.setHorizontalGroup(
82.88 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
82.89 + .addGroup(layout.createSequentialGroup()
82.90 + .addContainerGap()
82.91 + .addComponent(uploadAgentCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
82.92 + .addGap(12, 12, 12))
82.93 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
82.94 + .addGap(29, 29, 29)
82.95 + .addComponent(uploadAgentDescriptionLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 705, Short.MAX_VALUE)
82.96 + .addContainerGap())
82.97 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
82.98 + .addGap(29, 29, 29)
82.99 + .addComponent(uploadAgentDescriptionLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 705, Short.MAX_VALUE)
82.100 + .addContainerGap())
82.101 + );
82.102 + layout.setVerticalGroup(
82.103 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
82.104 + .addGroup(layout.createSequentialGroup()
82.105 + .addComponent(uploadAgentCheckBox)
82.106 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
82.107 + .addComponent(uploadAgentDescriptionLabel1)
82.108 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
82.109 + .addComponent(uploadAgentDescriptionLabel2)
82.110 + .addContainerGap(239, Short.MAX_VALUE))
82.111 + );
82.112 + }// </editor-fold>//GEN-END:initComponents
82.113 + // Variables declaration - do not modify//GEN-BEGIN:variables
82.114 + private javax.swing.JCheckBox uploadAgentCheckBox;
82.115 + private javax.swing.JLabel uploadAgentDescriptionLabel1;
82.116 + private javax.swing.JLabel uploadAgentDescriptionLabel2;
82.117 + // End of variables declaration//GEN-END:variables
82.118 +
82.119 + @Override
82.120 + public void load() {
82.121 + Properties p = Properties.getDefault().getProperties("debugger.options.JPDA.visual");
82.122 + uploadAgentCheckBox.setSelected(p.getBoolean("UploadAgent", true));
82.123 + }
82.124 +
82.125 + @Override
82.126 + public void store() {
82.127 + Properties p = Properties.getDefault().getProperties("debugger.options.JPDA.visual");
82.128 + p.setBoolean("UploadAgent", uploadAgentCheckBox.isSelected());
82.129 + }
82.130 +}
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
83.2 +++ b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/options/VisualOptionsProvider.java Wed Jul 27 10:35:25 2011 +0200
83.3 @@ -0,0 +1,63 @@
83.4 +/*
83.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
83.6 + *
83.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
83.8 + *
83.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
83.10 + * Other names may be trademarks of their respective owners.
83.11 + *
83.12 + * The contents of this file are subject to the terms of either the GNU
83.13 + * General Public License Version 2 only ("GPL") or the Common
83.14 + * Development and Distribution License("CDDL") (collectively, the
83.15 + * "License"). You may not use this file except in compliance with the
83.16 + * License. You can obtain a copy of the License at
83.17 + * http://www.netbeans.org/cddl-gplv2.html
83.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
83.19 + * specific language governing permissions and limitations under the
83.20 + * License. When distributing the software, include this License Header
83.21 + * Notice in each file and include the License file at
83.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
83.23 + * particular file as subject to the "Classpath" exception as provided
83.24 + * by Oracle in the GPL Version 2 section of the License file that
83.25 + * accompanied this code. If applicable, add the following below the
83.26 + * License Header, with the fields enclosed by brackets [] replaced by
83.27 + * your own identifying information:
83.28 + * "Portions Copyrighted [year] [name of copyright owner]"
83.29 + *
83.30 + * If you wish your version of this file to be governed by only the CDDL
83.31 + * or only the GPL Version 2, indicate your decision by adding
83.32 + * "[Contributor] elects to include this software in this distribution
83.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
83.34 + * single choice of license, a recipient has the option to distribute
83.35 + * your version of this file under either the CDDL, the GPL Version 2 or
83.36 + * to extend the choice of license to its licensees as provided above.
83.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
83.38 + * Version 2 license, then the option applies only if the new code is
83.39 + * made subject to such option by the copyright holder.
83.40 + *
83.41 + * Contributor(s):
83.42 + *
83.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
83.44 + */
83.45 +package org.netbeans.modules.debugger.jpda.visual.options;
83.46 +
83.47 +import org.netbeans.modules.debugger.jpda.ui.options.StorablePanel;
83.48 +import org.openide.util.NbBundle;
83.49 +
83.50 +/**
83.51 + *
83.52 + * @author martin
83.53 + */
83.54 +public class VisualOptionsProvider implements StorablePanel.Provider {
83.55 +
83.56 + @Override
83.57 + public String getPanelName() {
83.58 + return NbBundle.getMessage(VisualOptionsProvider.class, "LBL_VisualDebugging");
83.59 + }
83.60 +
83.61 + @Override
83.62 + public StorablePanel getPanel() {
83.63 + return new CategoryPanelVisual();
83.64 + }
83.65 +
83.66 +}
84.1 --- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointsReader.java Wed Jul 27 10:33:10 2011 +0200
84.2 +++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointsReader.java Wed Jul 27 10:35:25 2011 +0200
84.3 @@ -235,7 +235,7 @@
84.4 b = fb;
84.5 }
84.6 if (typeID.equals (ThreadBreakpoint.class.getName ()) ||
84.7 - typeID.equals (ThreadBreakpoint.class.getName ()+"ThreadBreakpoint$Impl")) {
84.8 + typeID.equals (ThreadBreakpoint.class.getName ()+"$ThreadBreakpointImpl")) {
84.9 ThreadBreakpoint tb = ThreadBreakpoint.create (
84.10 );
84.11 tb.setBreakpointType (
84.12 @@ -246,7 +246,9 @@
84.13 );
84.14 b = tb;
84.15 }
84.16 - assert b != null: "Unknown breakpoint type: \""+typeID+"\"";
84.17 + if (b == null) {
84.18 + throw new IllegalStateException("Unknown breakpoint type: \""+typeID+"\"");
84.19 + }
84.20 b.setPrintText (
84.21 properties.getString (JPDABreakpoint.PROP_PRINT_TEXT, "")
84.22 );
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
85.2 +++ b/form.binding/build.xml Wed Jul 27 10:35:25 2011 +0200
85.3 @@ -0,0 +1,48 @@
85.4 +<?xml version="1.0" encoding="UTF-8"?>
85.5 +<!--
85.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
85.7 +
85.8 +Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
85.9 +
85.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
85.11 +Other names may be trademarks of their respective owners.
85.12 +
85.13 +
85.14 +The contents of this file are subject to the terms of either the GNU
85.15 +General Public License Version 2 only ("GPL") or the Common
85.16 +Development and Distribution License("CDDL") (collectively, the
85.17 +"License"). You may not use this file except in compliance with the
85.18 +License. You can obtain a copy of the License at
85.19 +http://www.netbeans.org/cddl-gplv2.html
85.20 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
85.21 +specific language governing permissions and limitations under the
85.22 +License. When distributing the software, include this License Header
85.23 +Notice in each file and include the License file at
85.24 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
85.25 +particular file as subject to the "Classpath" exception as provided
85.26 +by Oracle in the GPL Version 2 section of the License file that
85.27 +accompanied this code. If applicable, add the following below the
85.28 +License Header, with the fields enclosed by brackets [] replaced by
85.29 +your own identifying information:
85.30 +"Portions Copyrighted [year] [name of copyright owner]"
85.31 +
85.32 +Contributor(s):
85.33 +
85.34 +The Original Software is NetBeans. The Initial Developer of the Original
85.35 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
85.36 +Microsystems, Inc. All Rights Reserved.
85.37 +
85.38 +If you wish your version of this file to be governed by only the CDDL
85.39 +or only the GPL Version 2, indicate your decision by adding
85.40 +"[Contributor] elects to include this software in this distribution
85.41 +under the [CDDL or GPL Version 2] license." If you do not indicate a
85.42 +single choice of license, a recipient has the option to distribute
85.43 +your version of this file under either the CDDL, the GPL Version 2 or
85.44 +to extend the choice of license to its licensees as provided above.
85.45 +However, if you add GPL Version 2 code and therefore, elected the GPL
85.46 +Version 2 license, then the option applies only if the new code is
85.47 +made subject to such option by the copyright holder.
85.48 +-->
85.49 +<project basedir="." default="netbeans" name="form.binding">
85.50 + <import file="../nbbuild/templates/projectized.xml"/>
85.51 +</project>
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
86.2 +++ b/form.binding/manifest.mf Wed Jul 27 10:35:25 2011 +0200
86.3 @@ -0,0 +1,6 @@
86.4 +Manifest-Version: 1.0
86.5 +OpenIDE-Module: org.netbeans.modules.form.binding/0
86.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/form/binding/Bundle.properties
86.7 +OpenIDE-Module-Layer: org/netbeans/modules/form/binding/resources/layer.xml
86.8 +OpenIDE-Module-Implementation-Version: 1
86.9 +AutoUpdate-Show-In-Client: false
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
87.2 +++ b/form.binding/nbproject/project.properties Wed Jul 27 10:35:25 2011 +0200
87.3 @@ -0,0 +1,45 @@
87.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
87.5 +#
87.6 +# Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
87.7 +#
87.8 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
87.9 +# Other names may be trademarks of their respective owners.
87.10 +#
87.11 +# The contents of this file are subject to the terms of either the GNU
87.12 +# General Public License Version 2 only ("GPL") or the Common
87.13 +# Development and Distribution License("CDDL") (collectively, the
87.14 +# "License"). You may not use this file except in compliance with the
87.15 +# License. You can obtain a copy of the License at
87.16 +# http://www.netbeans.org/cddl-gplv2.html
87.17 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
87.18 +# specific language governing permissions and limitations under the
87.19 +# License. When distributing the software, include this License Header
87.20 +# Notice in each file and include the License file at
87.21 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
87.22 +# particular file as subject to the "Classpath" exception as provided
87.23 +# by Oracle in the GPL Version 2 section of the License file that
87.24 +# accompanied this code. If applicable, add the following below the
87.25 +# License Header, with the fields enclosed by brackets [] replaced by
87.26 +# your own identifying information:
87.27 +# "Portions Copyrighted [year] [name of copyright owner]"
87.28 +#
87.29 +# Contributor(s):
87.30 +#
87.31 +# The Original Software is NetBeans. The Initial Developer of the Original
87.32 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
87.33 +# Microsystems, Inc. All Rights Reserved.
87.34 +#
87.35 +# If you wish your version of this file to be governed by only the CDDL
87.36 +# or only the GPL Version 2, indicate your decision by adding
87.37 +# "[Contributor] elects to include this software in this distribution
87.38 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
87.39 +# single choice of license, a recipient has the option to distribute
87.40 +# your version of this file under either the CDDL, the GPL Version 2 or
87.41 +# to extend the choice of license to its licensees as provided above.
87.42 +# However, if you add GPL Version 2 code and therefore, elected the GPL
87.43 +# Version 2 license, then the option applies only if the new code is
87.44 +# made subject to such option by the copyright holder.
87.45 +
87.46 +is.eager=true
87.47 +javac.source=1.6
87.48 +spec.version.base=0.1.0
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
88.2 +++ b/form.binding/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
88.3 @@ -0,0 +1,148 @@
88.4 +<?xml version="1.0" encoding="UTF-8"?>
88.5 +<!--
88.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
88.7 +
88.8 +Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
88.9 +
88.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
88.11 +Other names may be trademarks of their respective owners.
88.12 +
88.13 +
88.14 +The contents of this file are subject to the terms of either the GNU
88.15 +General Public License Version 2 only ("GPL") or the Common
88.16 +Development and Distribution License("CDDL") (collectively, the
88.17 +"License"). You may not use this file except in compliance with the
88.18 +License. You can obtain a copy of the License at
88.19 +http://www.netbeans.org/cddl-gplv2.html
88.20 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
88.21 +specific language governing permissions and limitations under the
88.22 +License. When distributing the software, include this License Header
88.23 +Notice in each file and include the License file at
88.24 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
88.25 +particular file as subject to the "Classpath" exception as provided
88.26 +by Oracle in the GPL Version 2 section of the License file that
88.27 +accompanied this code. If applicable, add the following below the
88.28 +License Header, with the fields enclosed by brackets [] replaced by
88.29 +your own identifying information:
88.30 +"Portions Copyrighted [year] [name of copyright owner]"
88.31 +
88.32 +Contributor(s):
88.33 +
88.34 +The Original Software is NetBeans. The Initial Developer of the Original
88.35 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
88.36 +Microsystems, Inc. All Rights Reserved.
88.37 +
88.38 +If you wish your version of this file to be governed by only the CDDL
88.39 +or only the GPL Version 2, indicate your decision by adding
88.40 +"[Contributor] elects to include this software in this distribution
88.41 +under the [CDDL or GPL Version 2] license." If you do not indicate a
88.42 +single choice of license, a recipient has the option to distribute
88.43 +your version of this file under either the CDDL, the GPL Version 2 or
88.44 +to extend the choice of license to its licensees as provided above.
88.45 +However, if you add GPL Version 2 code and therefore, elected the GPL
88.46 +Version 2 license, then the option applies only if the new code is
88.47 +made subject to such option by the copyright holder.
88.48 +-->
88.49 +<project xmlns="http://www.netbeans.org/ns/project/1">
88.50 + <type>org.netbeans.modules.apisupport.project</type>
88.51 + <configuration>
88.52 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
88.53 + <code-name-base>org.netbeans.modules.form.binding</code-name-base>
88.54 + <module-dependencies>
88.55 + <dependency>
88.56 + <code-name-base>org.jdesktop.beansbinding</code-name-base>
88.57 + <build-prerequisite/>
88.58 + <compile-dependency/>
88.59 + <run-dependency>
88.60 + <release-version>1</release-version>
88.61 + <specification-version>1.12</specification-version>
88.62 + </run-dependency>
88.63 + </dependency>
88.64 + <dependency>
88.65 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
88.66 + <build-prerequisite/>
88.67 + <compile-dependency/>
88.68 + <run-dependency>
88.69 + <release-version>1</release-version>
88.70 + <specification-version>1.30</specification-version>
88.71 + </run-dependency>
88.72 + </dependency>
88.73 + <dependency>
88.74 + <code-name-base>org.netbeans.libs.javacapi</code-name-base>
88.75 + <build-prerequisite/>
88.76 + <compile-dependency/>
88.77 + <run-dependency>
88.78 + <specification-version>7.7</specification-version>
88.79 + </run-dependency>
88.80 + </dependency>
88.81 + <dependency>
88.82 + <code-name-base>org.netbeans.modules.form</code-name-base>
88.83 + <build-prerequisite/>
88.84 + <compile-dependency/>
88.85 + <run-dependency>
88.86 + <release-version>2</release-version>
88.87 + <implementation-version/>
88.88 + </run-dependency>
88.89 + </dependency>
88.90 + <dependency>
88.91 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
88.92 + <build-prerequisite/>
88.93 + <compile-dependency/>
88.94 + <run-dependency>
88.95 + <specification-version>0.83</specification-version>
88.96 + </run-dependency>
88.97 + </dependency>
88.98 + <dependency>
88.99 + <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
88.100 + <build-prerequisite/>
88.101 + <compile-dependency/>
88.102 + <run-dependency>
88.103 + <release-version>1</release-version>
88.104 + <specification-version>1.31</specification-version>
88.105 + </run-dependency>
88.106 + </dependency>
88.107 + <dependency>
88.108 + <code-name-base>org.openide.filesystems</code-name-base>
88.109 + <build-prerequisite/>
88.110 + <compile-dependency/>
88.111 + <run-dependency>
88.112 + <specification-version>7.49</specification-version>
88.113 + </run-dependency>
88.114 + </dependency>
88.115 + <dependency>
88.116 + <code-name-base>org.openide.loaders</code-name-base>
88.117 + <build-prerequisite/>
88.118 + <compile-dependency/>
88.119 + <run-dependency>
88.120 + <specification-version>7.28</specification-version>
88.121 + </run-dependency>
88.122 + </dependency>
88.123 + <dependency>
88.124 + <code-name-base>org.openide.nodes</code-name-base>
88.125 + <build-prerequisite/>
88.126 + <compile-dependency/>
88.127 + <run-dependency>
88.128 + <specification-version>7.23</specification-version>
88.129 + </run-dependency>
88.130 + </dependency>
88.131 + <dependency>
88.132 + <code-name-base>org.openide.util</code-name-base>
88.133 + <build-prerequisite/>
88.134 + <compile-dependency/>
88.135 + <run-dependency>
88.136 + <specification-version>8.16</specification-version>
88.137 + </run-dependency>
88.138 + </dependency>
88.139 + <dependency>
88.140 + <code-name-base>org.openide.util.lookup</code-name-base>
88.141 + <build-prerequisite/>
88.142 + <compile-dependency/>
88.143 + <run-dependency>
88.144 + <specification-version>8.10</specification-version>
88.145 + </run-dependency>
88.146 + </dependency>
88.147 + </module-dependencies>
88.148 + <public-packages/>
88.149 + </data>
88.150 + </configuration>
88.151 +</project>
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
89.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/BindingDesignSupportImpl.java Wed Jul 27 10:35:25 2011 +0200
89.3 @@ -0,0 +1,1549 @@
89.4 +/*
89.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
89.6 + *
89.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
89.8 + *
89.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
89.10 + * Other names may be trademarks of their respective owners.
89.11 + *
89.12 + * The contents of this file are subject to the terms of either the GNU
89.13 + * General Public License Version 2 only ("GPL") or the Common
89.14 + * Development and Distribution License("CDDL") (collectively, the
89.15 + * "License"). You may not use this file except in compliance with the
89.16 + * License. You can obtain a copy of the License at
89.17 + * http://www.netbeans.org/cddl-gplv2.html
89.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
89.19 + * specific language governing permissions and limitations under the
89.20 + * License. When distributing the software, include this License Header
89.21 + * Notice in each file and include the License file at
89.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
89.23 + * particular file as subject to the "Classpath" exception as provided
89.24 + * by Oracle in the GPL Version 2 section of the License file that
89.25 + * accompanied this code. If applicable, add the following below the
89.26 + * License Header, with the fields enclosed by brackets [] replaced by
89.27 + * your own identifying information:
89.28 + * "Portions Copyrighted [year] [name of copyright owner]"
89.29 + *
89.30 + * Contributor(s):
89.31 + *
89.32 + * The Original Software is NetBeans. The Initial Developer of the Original
89.33 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
89.34 + * Microsystems, Inc. All Rights Reserved.
89.35 + *
89.36 + * If you wish your version of this file to be governed by only the CDDL
89.37 + * or only the GPL Version 2, indicate your decision by adding
89.38 + * "[Contributor] elects to include this software in this distribution
89.39 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
89.40 + * single choice of license, a recipient has the option to distribute
89.41 + * your version of this file under either the CDDL, the GPL Version 2 or
89.42 + * to extend the choice of license to its licensees as provided above.
89.43 + * However, if you add GPL Version 2 code and therefore, elected the GPL
89.44 + * Version 2 license, then the option applies only if the new code is
89.45 + * made subject to such option by the copyright holder.
89.46 + */
89.47 +
89.48 +package org.netbeans.modules.form.binding;
89.49 +
89.50 +import com.sun.source.tree.*;
89.51 +import com.sun.source.util.TreePath;
89.52 +import com.sun.source.util.Trees;
89.53 +import java.lang.reflect.*;
89.54 +import java.util.*;
89.55 +import java.beans.*;
89.56 +import java.io.IOException;
89.57 +import java.util.logging.Level;
89.58 +import java.util.logging.Logger;
89.59 +import javax.lang.model.element.Element;
89.60 +import javax.lang.model.element.ElementKind;
89.61 +import javax.lang.model.element.TypeElement;
89.62 +import javax.lang.model.element.TypeParameterElement;
89.63 +import javax.lang.model.type.TypeKind;
89.64 +import javax.swing.JList;
89.65 +import javax.swing.JTable;
89.66 +import javax.swing.JComboBox;
89.67 +import javax.swing.JFormattedTextField;
89.68 +import javax.swing.JSlider;
89.69 +import javax.swing.JSpinner;
89.70 +import javax.swing.text.JTextComponent;
89.71 +import org.jdesktop.beansbinding.*;
89.72 +import org.jdesktop.beansbinding.ext.BeanAdapterFactory;
89.73 +import org.jdesktop.swingbinding.*;
89.74 +import org.netbeans.api.java.classpath.ClassPath;
89.75 +import org.netbeans.api.java.source.CancellableTask;
89.76 +import org.netbeans.api.java.source.CompilationController;
89.77 +import org.netbeans.api.java.source.JavaSource;
89.78 +import org.netbeans.api.java.source.TreeUtilities;
89.79 +import org.netbeans.api.project.libraries.Library;
89.80 +import org.netbeans.api.project.libraries.LibraryManager;
89.81 +import org.netbeans.modules.form.BindingDescriptor;
89.82 +import org.netbeans.modules.form.BindingDesignSupport;
89.83 +import org.netbeans.modules.form.BindingProperty;
89.84 +import org.netbeans.modules.form.ComponentContainer;
89.85 +import org.netbeans.modules.form.FormDesignValue;
89.86 +import org.netbeans.modules.form.FormEditor;
89.87 +import org.netbeans.modules.form.FormModel;
89.88 +import org.netbeans.modules.form.FormModelEvent;
89.89 +import org.netbeans.modules.form.FormModelListener;
89.90 +import org.netbeans.modules.form.FormProperty;
89.91 +import org.netbeans.modules.form.FormUtils;
89.92 +import org.netbeans.modules.form.FormUtils.TypeHelper;
89.93 +import org.netbeans.modules.form.MetaBinding;
89.94 +import org.netbeans.modules.form.RADComponent;
89.95 +import org.netbeans.modules.form.project.ClassPathUtils;
89.96 +import org.netbeans.modules.form.project.ClassSource;
89.97 +import org.openide.ErrorManager;
89.98 +import org.openide.filesystems.FileObject;
89.99 +import org.openide.nodes.Node;
89.100 +import org.openide.util.Utilities;
89.101 +
89.102 +/**
89.103 + * Design support for beans binding.
89.104 + *
89.105 + * @author Jan Stola, Tomas Pavek
89.106 + */
89.107 +public class BindingDesignSupportImpl implements BindingDesignSupport {
89.108 + /** Form model. */
89.109 + private FormModel formModel;
89.110 +
89.111 + /** Realizations of bindings among replicated components. */
89.112 + private Map<MetaBinding, List<Binding>> bindingsMap = new HashMap<MetaBinding, List<Binding>>();
89.113 + /** Realizations of bindings among metacomponents. */
89.114 + private Map<MetaBinding, Binding> modelBindings = new HashMap<MetaBinding, Binding>();
89.115 + /** Binding to BindingGroup mapping. */
89.116 + private Map<Binding, BindingGroup> bindingToGroup = new HashMap<Binding, BindingGroup>();
89.117 + /** Binding group for reference instances in metacomponents. */
89.118 + private BindingGroup bindingGroup;
89.119 +
89.120 + /**
89.121 + * Create binding design support for the given form model.
89.122 + *
89.123 + * @param model form model to create the binding support for.
89.124 + */
89.125 + BindingDesignSupportImpl(FormModel model) {
89.126 + formModel = model;
89.127 +
89.128 + bindingGroup = new BindingGroup();
89.129 + bindingGroup.bind();
89.130 +
89.131 + formModel.addFormModelListener(new ModelListener());
89.132 + }
89.133 +
89.134 + /**
89.135 + * Changes the binding between two components (affects only replicated components).
89.136 + *
89.137 + * @param oldBinding the old definition of the binding.
89.138 + * @param newBinding the new definition of the binding.
89.139 + */
89.140 + private void changeBinding(MetaBinding oldBinding, MetaBinding newBinding) {
89.141 + if (oldBinding != null) {
89.142 + removeBindings(oldBinding);
89.143 + }
89.144 + // non-model bindings are added from VisualReplicator
89.145 + }
89.146 +
89.147 + /**
89.148 + * Changes the binding between two components (affects only reference instances in the model).
89.149 + *
89.150 + * @param oldBinding the old definition of the binding.
89.151 + * @param newBinding the new definition of the binding.
89.152 + */
89.153 + @Override
89.154 + public void changeBindingInModel(MetaBinding oldBinding, MetaBinding newBinding) {
89.155 + if (oldBinding != null) {
89.156 + removeBindingInModel(oldBinding);
89.157 + }
89.158 + if (newBinding != null) {
89.159 + addBindingInModel(newBinding);
89.160 + }
89.161 + }
89.162 +
89.163 + @Override
89.164 + public String elWrap(String path) {
89.165 + return (path == null) ? null : "${" + path + "}"; // NOI18N
89.166 + }
89.167 +
89.168 +
89.169 + @Override
89.170 + public boolean isSimpleExpression(String expression) {
89.171 + return isSimpleExpression0(expression);
89.172 + }
89.173 +
89.174 + private static boolean isSimpleExpression0(String expression) {
89.175 + return (expression.startsWith("${") && expression.endsWith("}")); // NOI18N
89.176 + }
89.177 +
89.178 + @Override
89.179 + public String unwrapSimpleExpression(String expression) {
89.180 + return unwrapSimpleExpression0(expression);
89.181 + }
89.182 +
89.183 + private static String unwrapSimpleExpression0(String expression) {
89.184 + if (isSimpleExpression0(expression)) {
89.185 + expression = expression.substring(2, expression.length()-1);
89.186 + }
89.187 + return expression;
89.188 + }
89.189 +
89.190 + private static boolean hasRelativeType(Class clazz, String property) {
89.191 + // selectedElement(_...), selectedElements(_...)
89.192 + return (("elements".equals(property) || property.startsWith("selectedElement")) // NOI18N
89.193 + && (javax.swing.JTable.class.isAssignableFrom(clazz) || javax.swing.JList.class.isAssignableFrom(clazz)))
89.194 + || (("selectedItem".equals(property)) && javax.swing.JComboBox.class.isAssignableFrom(clazz)); // NOI18N
89.195 + }
89.196 +
89.197 + // Used to determine binding properties only
89.198 + @Override
89.199 + public List<BindingDescriptor>[] getBindingDescriptors(RADComponent component) {
89.200 + BeanDescriptor beanDescriptor = component.getBeanInfo().getBeanDescriptor();
89.201 + List<BindingDescriptor>[] descs = getBindingDescriptors(null, beanDescriptor, false);
89.202 + Class<?> beanClass = component.getBeanClass();
89.203 + if (JTextComponent.class.isAssignableFrom(beanClass)) {
89.204 + // get rid of text_... descriptors
89.205 + descs[0] = filterDescriptors(descs[0], "text_"); // NOI18N
89.206 + } else if (JTable.class.isAssignableFrom(beanClass)
89.207 + || JList.class.isAssignableFrom(beanClass)
89.208 + || JComboBox.class.isAssignableFrom(beanClass)) {
89.209 + // get rid of selectedElement(s)_... descriptors
89.210 + descs[0] = filterDescriptors(descs[0], "selectedElement_"); // NOI18N
89.211 + descs[0] = filterDescriptors(descs[0], "selectedElements_"); // NOI18N
89.212 + // add elements descriptor
89.213 + BindingDescriptor desc = new BindingDescriptor("elements", List.class); // NOI18N
89.214 + descs[0].add(0, desc);
89.215 + } else if (JSlider.class.isAssignableFrom(beanClass)) {
89.216 + // get rid of value_... descriptor
89.217 + descs[0] = filterDescriptors(descs[0], "value_"); // NOI18N
89.218 + }
89.219 + return descs;
89.220 + }
89.221 +
89.222 + private List<BindingDescriptor> filterDescriptors(List<BindingDescriptor> descs, String forbiddenPrefix) {
89.223 + List<BindingDescriptor> filtered = new LinkedList<BindingDescriptor>();
89.224 + for (BindingDescriptor bd : descs) {
89.225 + if (!bd.getPath().startsWith(forbiddenPrefix)) { // NOI18N
89.226 + filtered.add(bd);
89.227 + }
89.228 + }
89.229 + return filtered;
89.230 + }
89.231 +
89.232 + private List<PropertyDescriptor> getSpecialBindingDescriptors(Class clazz) {
89.233 + List<PropertyDescriptor> descs = BeanAdapterFactory.getAdapterPropertyDescriptors(clazz);
89.234 + try {
89.235 + if (JComboBox.class.isAssignableFrom(clazz)) {
89.236 + PropertyDescriptor desc = new PropertyDescriptor("selectedItem", JComboBox.class); // NOI18N
89.237 + descs.add(desc);
89.238 + } else if (JSpinner.class.isAssignableFrom(clazz)) {
89.239 + PropertyDescriptor desc = new PropertyDescriptor("value", JSpinner.class); // NOI18N
89.240 + descs.add(desc);
89.241 + } else if (JFormattedTextField.class.isAssignableFrom(clazz)) {
89.242 + for (PropertyDescriptor pd : descs) {
89.243 + if ("text".equals(pd.getName())) { // NOI18N
89.244 + descs.remove(pd);
89.245 + break;
89.246 + }
89.247 + }
89.248 + PropertyDescriptor desc = new PropertyDescriptor("value", JFormattedTextField.class); // NOI18N
89.249 + descs.add(desc);
89.250 + }
89.251 + } catch (Exception ex) {
89.252 + Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
89.253 + }
89.254 + return descs;
89.255 + }
89.256 +
89.257 + private List<BindingDescriptor>[] getBindingDescriptors(TypeHelper type, BeanDescriptor beanDescriptor, boolean includeReadOnly) {
89.258 + Class<?> beanClass = beanDescriptor.getBeanClass();
89.259 + List<BindingDescriptor> bindingList = new LinkedList<BindingDescriptor>();
89.260 + List<BindingDescriptor> prefList = new LinkedList<BindingDescriptor>();
89.261 + List<BindingDescriptor> observableList = new LinkedList<BindingDescriptor>();
89.262 + List<BindingDescriptor> nonObservableList = new LinkedList<BindingDescriptor>();
89.263 + List<BindingDescriptor> list;
89.264 + Object[] propsCats = FormUtils.getPropertiesCategoryClsf(beanClass, beanDescriptor);
89.265 + PropertyDescriptor[] pds;
89.266 + try {
89.267 + pds = FormUtils.getBeanInfo(beanClass).getPropertyDescriptors();
89.268 + } catch (Exception ex) {
89.269 + Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
89.270 + pds = new PropertyDescriptor[0];
89.271 + }
89.272 + List<PropertyDescriptor> specialPds = getSpecialBindingDescriptors(beanClass);
89.273 + Map<String,PropertyDescriptor> pathToDesc = new HashMap<String,PropertyDescriptor>();
89.274 + if (Utilities.isMac()) {
89.275 + try {
89.276 + for (PropertyDescriptor pd : FormUtils.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO).getPropertyDescriptors()) {
89.277 + pathToDesc.put(pd.getName(), pd);
89.278 + }
89.279 + } catch (IntrospectionException iex) {
89.280 + Logger.getLogger(getClass().getName()).log(Level.INFO, iex.getMessage(), iex);
89.281 + }
89.282 + }
89.283 + for (PropertyDescriptor pd : pds) {
89.284 + pathToDesc.put(pd.getName(), pd);
89.285 + }
89.286 + for (PropertyDescriptor pd : specialPds) {
89.287 + if (pathToDesc.get(pd.getName()) != null) {
89.288 + pathToDesc.remove(pd.getName());
89.289 + }
89.290 + }
89.291 + List<PropertyDescriptor> allPds = new LinkedList<PropertyDescriptor>(specialPds);
89.292 + allPds.addAll(pathToDesc.values());
89.293 + int count = 0;
89.294 + for (PropertyDescriptor pd : allPds) {
89.295 + if (count++<specialPds.size()) {
89.296 + list = bindingList;
89.297 + } else {
89.298 + if (!includeReadOnly && (pd.getWriteMethod() == null)) {
89.299 + continue;
89.300 + }
89.301 + Object propCat = FormUtils.getPropertyCategory(pd, propsCats);
89.302 + if (propCat == FormUtils.PROP_HIDDEN) {
89.303 + // hidden property => hide also the binding property
89.304 + continue;
89.305 + } else {
89.306 + if (pd.isBound()) {
89.307 + // observable property
89.308 + if (propCat == FormUtils.PROP_PREFERRED) {
89.309 + list = prefList;
89.310 + } else {
89.311 + list = observableList;
89.312 + }
89.313 + } else {
89.314 + // non-observable property
89.315 + list = nonObservableList;
89.316 + }
89.317 + }
89.318 + }
89.319 +
89.320 + Method method = pd.getReadMethod();
89.321 + if ((method != null) && ("getClass".equals(method.getName()))) continue; // NOI18N
89.322 + Type retType = (method == null) ? pd.getPropertyType() : method.getGenericReturnType();
89.323 + if (retType == null) continue;
89.324 + BindingDescriptor bd;
89.325 + if (type == null) {
89.326 + bd = new BindingDescriptor(pd.getName(), retType);
89.327 + } else {
89.328 + TypeHelper t = new TypeHelper(retType, type.getActualTypeArgs()).normalize();
89.329 + bd = new BindingDescriptor(pd.getName(), t);
89.330 + }
89.331 + bd.setDisplayName(pd.getDisplayName());
89.332 + bd.setShortDescription(pd.getShortDescription());
89.333 +
89.334 + if (hasRelativeType(beanClass, bd.getPath())) {
89.335 + bd.markTypeAsRelative();
89.336 + }
89.337 +
89.338 + list.add(bd);
89.339 + }
89.340 +
89.341 + if (bindingList.isEmpty()) {
89.342 + bindingList = prefList;
89.343 + } else {
89.344 + observableList.addAll(prefList);
89.345 + }
89.346 + Comparator<BindingDescriptor> bdComparator = new Comparator<BindingDescriptor>() {
89.347 + @Override
89.348 + public int compare(BindingDescriptor o1, BindingDescriptor o2) {
89.349 + String path1 = o1.getPath();
89.350 + String path2 = o2.getPath();
89.351 + return path1.compareToIgnoreCase(path2);
89.352 + }
89.353 + };
89.354 + Collections.sort(bindingList, bdComparator);
89.355 + Collections.sort(observableList, bdComparator);
89.356 + Collections.sort(nonObservableList, bdComparator);
89.357 +
89.358 + return new List[] {bindingList, observableList, nonObservableList};
89.359 + }
89.360 +
89.361 + @Override
89.362 + public List<BindingDescriptor> getAllBindingDescriptors(TypeHelper type) {
89.363 + List<BindingDescriptor>[] descs = getBindingDescriptors(type);
89.364 + List<BindingDescriptor> list = new LinkedList<BindingDescriptor>();
89.365 + for (int i=0; i<descs.length; i++ ){
89.366 + list.addAll(descs[i]);
89.367 + }
89.368 + return list;
89.369 + }
89.370 +
89.371 + /**
89.372 + * Returns possible bindings for the given type.
89.373 + *
89.374 + * @param type type whose possible bindings should be returned.
89.375 + * @return list of <code>BindingDescriptor</code>s describing possible bindings.
89.376 + */
89.377 + @Override
89.378 + @SuppressWarnings("unchecked") // generic array creation NOI18N
89.379 + public List<BindingDescriptor>[] getBindingDescriptors(TypeHelper type) {
89.380 + List<BindingDescriptor> typesFromSource = Collections.emptyList();
89.381 + Class binarySuperClass = null;
89.382 + if (type.getType() == null) {
89.383 + FileObject fileInProject = FormEditor.getFormDataObject(formModel).getPrimaryFile();
89.384 + ClassPath cp = ClassPath.getClassPath(fileInProject, ClassPath.SOURCE);
89.385 + final List<BindingDescriptor> types = new LinkedList<BindingDescriptor>();
89.386 + final String[] superClass = new String[1];
89.387 + superClass[0] = type.getName();
89.388 + do {
89.389 + String typeName = superClass[0];
89.390 + final String resourceName = typeName.replace('.', '/') + ".java"; // NOI18N
89.391 + int lastDot = typeName.lastIndexOf('.');
89.392 + lastDot = (lastDot == -1) ? 0 : lastDot;
89.393 + final String simpleTypeName = typeName.substring(lastDot+1);
89.394 + FileObject fob = cp.findResource(resourceName);
89.395 + if (fob == null) {
89.396 + try {
89.397 + binarySuperClass = ClassPathUtils.loadClass(typeName, fileInProject);
89.398 + } catch (ClassNotFoundException cnfex) {}
89.399 + break;
89.400 + }
89.401 + JavaSource source = JavaSource.forFileObject(fob);
89.402 + try {
89.403 + source.runUserActionTask(new CancellableTask<CompilationController>() {
89.404 + @Override
89.405 + public void run(CompilationController cc) throws Exception {
89.406 + cc.toPhase(JavaSource.Phase.RESOLVED);
89.407 + CompilationUnitTree cu = cc.getCompilationUnit();
89.408 + ClassTree clazz = null;
89.409 + for (Tree typeDecl : cu.getTypeDecls()) {
89.410 + if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) {
89.411 + ClassTree candidate = (ClassTree)typeDecl;
89.412 + if (candidate.getSimpleName().toString().equals(simpleTypeName)) {
89.413 + clazz = candidate;
89.414 + break;
89.415 + }
89.416 + }
89.417 + }
89.418 + if (clazz == null) { // issue 118690
89.419 + // should not happen
89.420 + Logger.getLogger(getClass().getName()).log(Level.INFO, "ClassTree not found in {0}", resourceName); // NOI18N
89.421 + superClass[0] = Object.class.getName();
89.422 + return;
89.423 + }
89.424 + for (Tree clMember : clazz.getMembers()) {
89.425 + if (clMember.getKind() == Tree.Kind.METHOD) {
89.426 + MethodTree method = (MethodTree)clMember;
89.427 + if (!method.getParameters().isEmpty()) continue;
89.428 + Set<javax.lang.model.element.Modifier> modifiers = method.getModifiers().getFlags();
89.429 + if (modifiers.contains(javax.lang.model.element.Modifier.STATIC)
89.430 + || !modifiers.contains(javax.lang.model.element.Modifier.PUBLIC)) {
89.431 + continue;
89.432 + }
89.433 + String methodName = method.getName().toString();
89.434 + Tree returnType = method.getReturnType();
89.435 +
89.436 + String propName;
89.437 + if (methodName.startsWith("get")) { // NOI18N
89.438 + propName = methodName.substring(3);
89.439 + } else if (methodName.startsWith("is")) { // NOI18N
89.440 + if ((returnType.getKind() == Tree.Kind.PRIMITIVE_TYPE)
89.441 + && (((PrimitiveTypeTree)returnType).getPrimitiveTypeKind() == TypeKind.BOOLEAN)) {
89.442 + propName = methodName.substring(2);
89.443 + } else {
89.444 + continue;
89.445 + }
89.446 + } else {
89.447 + continue;
89.448 + }
89.449 + if (propName.length() == 0) continue;
89.450 + if ((propName.length() == 1) || (Character.isLowerCase(propName.charAt(1)))) {
89.451 + propName = Character.toLowerCase(propName.charAt(0)) + propName.substring(1);
89.452 + }
89.453 +
89.454 + TypeHelper type;
89.455 + if (returnType.getKind() == Tree.Kind.PRIMITIVE_TYPE) {
89.456 + PrimitiveTypeTree ptree = (PrimitiveTypeTree)returnType;
89.457 + if (ptree.getPrimitiveTypeKind() == TypeKind.VOID) {
89.458 + continue; // void return type
89.459 + }
89.460 + type = new TypeHelper(ptree.toString());
89.461 + } else {
89.462 + type = treeToType(cc, returnType, formModel);
89.463 + }
89.464 + types.add(0, new BindingDescriptor(propName, type));
89.465 + }
89.466 + }
89.467 + Tree superTree = clazz.getExtendsClause();
89.468 + TypeHelper type = treeToType(cc, superTree, formModel);
89.469 + String typeName = type.getName();
89.470 + superClass[0] = (typeName == null) ? FormUtils.typeToClass(type).getName() : typeName;
89.471 + }
89.472 +
89.473 + @Override
89.474 + public void cancel() {
89.475 + }
89.476 +
89.477 + }, true);
89.478 + } catch (IOException ioex) {
89.479 + Logger.getLogger(getClass().getName()).log(Level.INFO, ioex.getMessage(), ioex);
89.480 + }
89.481 + } while (!Object.class.getName().equals(superClass[0]));
89.482 + typesFromSource = types;
89.483 + }
89.484 + List<BindingDescriptor>[] list = new List[] {Collections.emptyList(), typesFromSource, Collections.emptyList()};
89.485 + Class clazz = (type.getType() == null) ? binarySuperClass : FormUtils.typeToClass(type);
89.486 + if ((clazz != null) && !clazz.getName().startsWith("java.lang.") // NOI18N
89.487 + && !Collection.class.isAssignableFrom(clazz)
89.488 + && !java.util.Date.class.isAssignableFrom(clazz)
89.489 + && !clazz.isArray()) {
89.490 + try {
89.491 + BeanInfo beanInfo = FormUtils.getBeanInfo(clazz);
89.492 + List<BindingDescriptor>[] typesFromBinary = getBindingDescriptors(type, beanInfo.getBeanDescriptor(), true);
89.493 + Map<String,BindingDescriptor>[] maps = new Map[3];
89.494 + for (int i=0; i<3; i++) {
89.495 + maps[i] = listToMap(typesFromBinary[i]);
89.496 + }
89.497 + for (BindingDescriptor descriptor : typesFromSource) {
89.498 + String path = descriptor.getPath();
89.499 + int i;
89.500 + for (i=0; i<3; i++) {
89.501 + if (maps[i].containsKey(path)) break;
89.502 + }
89.503 + if (i == 3) {
89.504 + i = 1; // put into observablle properties by default
89.505 + }
89.506 + maps[i].put(path, descriptor);
89.507 + }
89.508 + for (int i=0; i<3; i++) {
89.509 + list[i] = new LinkedList<BindingDescriptor>(maps[i].values());
89.510 + }
89.511 + } catch (Exception ex) {
89.512 + Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
89.513 + }
89.514 + }
89.515 + return list;
89.516 + }
89.517 +
89.518 + private static TypeHelper treeToType(CompilationController cc, Tree tree, FormModel model) {
89.519 + String typeName = Object.class.getName();
89.520 + Map<String,TypeHelper> map = null;
89.521 + if (tree != null) {
89.522 + CompilationUnitTree cu = cc.getCompilationUnit();
89.523 + Trees trees = cc.getTrees();
89.524 + if (tree.getKind() == Tree.Kind.EXTENDS_WILDCARD) {
89.525 + tree = ((WildcardTree)tree).getBound();
89.526 + }
89.527 + TreePath path = trees.getPath(cu, tree);
89.528 + Element el = trees.getElement(path);
89.529 + if ((el != null) && ((el.getKind() == ElementKind.CLASS) || (el.getKind() == ElementKind.INTERFACE))) {
89.530 + TypeElement tel = (TypeElement) el;
89.531 + typeName = tel.getQualifiedName().toString();
89.532 + if (tree.getKind() == Tree.Kind.PARAMETERIZED_TYPE) {
89.533 + List<? extends Tree> params = ((ParameterizedTypeTree)tree).getTypeArguments();
89.534 + List<? extends TypeParameterElement> elems = tel.getTypeParameters();
89.535 + map = new HashMap<String,TypeHelper>();
89.536 + for (int i=0; i<params.size() && i<elems.size(); i++) {
89.537 + Tree param = params.get(0);
89.538 + TypeHelper paramType = treeToType(cc, param, model);
89.539 + TypeParameterElement elem = elems.get(0);
89.540 + map.put(elem.toString(), paramType);
89.541 + }
89.542 + }
89.543 + }
89.544 + }
89.545 + TypeHelper type = new TypeHelper(typeName, map);
89.546 + if (typeName.indexOf('.') != -1) {
89.547 + try {
89.548 + Class clazz = FormUtils.loadClass(typeName, model);
89.549 + type = new TypeHelper(clazz, map);
89.550 + } catch (ClassNotFoundException cnfex) {
89.551 + // not compiled - use just the name
89.552 + }
89.553 + }
89.554 + return type;
89.555 + }
89.556 +
89.557 + private static Map<String,BindingDescriptor> listToMap(List<BindingDescriptor> list) {
89.558 + Map<String,BindingDescriptor> map = new TreeMap<String,BindingDescriptor>();
89.559 + for (BindingDescriptor descriptor : list) {
89.560 + String path = descriptor.getPath();
89.561 + map.put(path, descriptor);
89.562 + }
89.563 + return map;
89.564 + }
89.565 +
89.566 + @Override
89.567 + public TypeHelper determineType(RADComponent comp) {
89.568 + TypeHelper type;
89.569 + if (comp.getFormModel().getTopRADComponent() == comp) {
89.570 + FileObject fob = FormEditor.getFormDataObject(comp.getFormModel()).getPrimaryFile();
89.571 + ClassPath cp = ClassPath.getClassPath(fob, ClassPath.SOURCE);
89.572 + String className = cp.getResourceName(fob, '.', false);
89.573 + type = new TypeHelper(className);
89.574 + } else {
89.575 + Type t = null;
89.576 + Map<String,TypeHelper> newMap = null;
89.577 + Class clazz = comp.getBeanClass();
89.578 + t = clazz;
89.579 + if (clazz.getTypeParameters().length == 1) {
89.580 + try {
89.581 + TypeHelper elemType = determineTypeParameter(comp);
89.582 + if (elemType != null) {
89.583 + newMap = new HashMap<String,TypeHelper>();
89.584 + newMap.put(clazz.getTypeParameters()[0].getName(), elemType);
89.585 + }
89.586 + } catch (Exception ex) {
89.587 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ex.getMessage(), ex);
89.588 + }
89.589 + }
89.590 + type = new TypeHelper(t, newMap);
89.591 + }
89.592 + return type;
89.593 + }
89.594 +
89.595 + static TypeHelper determineTypeParameter(final RADComponent comp) {
89.596 + FileObject fob = FormEditor.getFormDataObject(comp.getFormModel()).getPrimaryFile();
89.597 + JavaSource source = JavaSource.forFileObject(fob);
89.598 + final String varName = comp.getName();
89.599 + final TypeHelper[] result = new TypeHelper[1];
89.600 + try {
89.601 + source.runUserActionTask(new CancellableTask<CompilationController>() {
89.602 + @Override
89.603 + public void run(CompilationController cc) throws Exception {
89.604 + cc.toPhase(JavaSource.Phase.RESOLVED);
89.605 + CompilationUnitTree cu = cc.getCompilationUnit();
89.606 + ClassTree clazz = null;
89.607 + for (Tree typeDecl : cu.getTypeDecls()) {
89.608 + if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) {
89.609 + clazz = (ClassTree) typeDecl;
89.610 + break;
89.611 + }
89.612 + }
89.613 + Node.Property prop = comp.getSyntheticProperty("useLocalVariable"); // NOI18N
89.614 + Object value = prop.getValue();
89.615 + VariableTree variable = null;
89.616 + if (Boolean.TRUE.equals(value)) {
89.617 + // local variable in initComponents()
89.618 + for (Tree clMember : clazz.getMembers()) {
89.619 + if (clMember.getKind() == Tree.Kind.METHOD) {
89.620 + MethodTree method = (MethodTree)clMember;
89.621 + String methodName = method.getName().toString();
89.622 + if ("initComponents".equals(methodName)) { // NOI18N
89.623 + for (StatementTree statement : method.getBody().getStatements()) {
89.624 + if (statement.getKind() == Tree.Kind.VARIABLE) {
89.625 + VariableTree var = (VariableTree)statement;
89.626 + if (varName.equals(var.getName().toString())) {
89.627 + variable = var;
89.628 + }
89.629 + }
89.630 + }
89.631 + }
89.632 + }
89.633 + }
89.634 + } else {
89.635 + // fields in class
89.636 + for (Tree clMember : clazz.getMembers()) {
89.637 + if (clMember.getKind() == Tree.Kind.VARIABLE) {
89.638 + VariableTree var = (VariableTree)clMember;
89.639 + if (varName.equals(var.getName().toString())) {
89.640 + variable = var;
89.641 + }
89.642 + }
89.643 + }
89.644 + }
89.645 + if (variable != null) {
89.646 + Tree type = variable.getType();
89.647 + if (type.getKind() == Tree.Kind.PARAMETERIZED_TYPE) {
89.648 + ParameterizedTypeTree params = (ParameterizedTypeTree)type;
89.649 + List<? extends Tree> args = params.getTypeArguments();
89.650 + if (args.size() == 1) {
89.651 + Tree tree = args.get(0);
89.652 + result[0] = treeToType(cc, tree, comp.getFormModel());
89.653 + }
89.654 + }
89.655 + }
89.656 + }
89.657 +
89.658 + @Override
89.659 + public void cancel() {
89.660 + }
89.661 + }, true);
89.662 + } catch (IOException ioex) {
89.663 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ioex.getMessage(), ioex);
89.664 + }
89.665 + if (result[0] == null) {
89.666 + // fallback - covers the situation where the component
89.667 + // has been added but the code hasn't been generated yet
89.668 + Class clazz = comp.getBeanClass();
89.669 + if (clazz.getTypeParameters().length == 1) {
89.670 + try {
89.671 + Object value = comp.getSyntheticProperty("typeParameters").getValue(); // NOI18N
89.672 + if (value instanceof String) {
89.673 + String type = (String)value;
89.674 + if (type.startsWith("<")) { // NOI18N
89.675 + type = type.substring(1, type.length()-1);
89.676 + Map<String,TypeHelper> newMap = new HashMap<String,TypeHelper>();
89.677 + try {
89.678 + Class elemType = ClassPathUtils.loadClass(type, FormEditor.getFormDataObject(comp.getFormModel()).getFormFile());
89.679 + newMap.put(clazz.getTypeParameters()[0].getName(), new TypeHelper(elemType));
89.680 + } catch (ClassNotFoundException cnfex) {
89.681 + newMap.put(clazz.getTypeParameters()[0].getName(), new TypeHelper(type));
89.682 + }
89.683 + result[0] = new TypeHelper(type, newMap);
89.684 + }
89.685 + }
89.686 + } catch (Exception ex) {
89.687 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ex.getMessage(), ex);
89.688 + }
89.689 + }
89.690 + }
89.691 + return result[0];
89.692 + }
89.693 +
89.694 + @Override
89.695 + public TypeHelper determineType(RADComponent comp, String sourcePath) {
89.696 + String[] path = parsePath(sourcePath);
89.697 + TypeHelper type = determineType(comp);
89.698 + for (int i=0; i<path.length; i++) {
89.699 + String pathItem = path[i];
89.700 + List<BindingDescriptor> descriptors = getAllBindingDescriptors(type);
89.701 + BindingDescriptor descriptor = findDescriptor(descriptors, pathItem);
89.702 + if (descriptor == null) return new TypeHelper();
89.703 + type = descriptor.getGenericValueType();
89.704 + if (type == null) {
89.705 + if (javax.swing.JTable.class.isAssignableFrom(comp.getBeanClass())
89.706 + || javax.swing.JList.class.isAssignableFrom(comp.getBeanClass())
89.707 + || javax.swing.JComboBox.class.isAssignableFrom(comp.getBeanClass())) {
89.708 + MetaBinding binding = comp.getBindingProperty("elements").getValue(); // NOI18N
89.709 + if (binding != null) {
89.710 + RADComponent subComp = binding.getSource();
89.711 + String subSourcePath = binding.getSourcePath();
89.712 + subSourcePath = (subSourcePath == null) ? null : unwrapSimpleExpression(subSourcePath);
89.713 + // PENDING beware of stack overflow
89.714 + TypeHelper t = determineType(subComp, subSourcePath);
89.715 + if (javax.swing.JComboBox.class.isAssignableFrom(comp.getBeanClass())) {
89.716 + if ("selectedItem".equals(pathItem)) { // NOI18N
89.717 + type = t.typeOfElement();
89.718 + }
89.719 + } else {
89.720 + if ("selectedElement".equals(pathItem) || pathItem.startsWith("selectedElement_")) { // NOI18N
89.721 + type = t.typeOfElement();
89.722 + } else if (pathItem.startsWith("selectedElements") || "elements".equals(pathItem)) { // NOI18N
89.723 + type = t;
89.724 + }
89.725 + }
89.726 + } else {
89.727 + type = new TypeHelper();
89.728 + }
89.729 + }
89.730 + }
89.731 + }
89.732 + return type;
89.733 + }
89.734 +
89.735 + /**
89.736 + * Finds descriptor that corresponds to the given binding path.
89.737 + *
89.738 + * @param descriptors list of descriptors that should be searched.
89.739 + * @param path binding path to find descriptor for.
89.740 + * @return descriptor that corresponds to the given binding path.
89.741 + */
89.742 + private static BindingDescriptor findDescriptor(List<BindingDescriptor> descriptors, String path) {
89.743 + for (BindingDescriptor descriptor : descriptors) {
89.744 + if (descriptor.getPath().equals(path)) return descriptor;
89.745 + }
89.746 + return null;
89.747 + }
89.748 +
89.749 + /**
89.750 + * Parses binding path into segments.
89.751 + *
89.752 + * @param path path to parse.
89.753 + * @return segments of the binding path. The returned value cannot be <code>null</code>.
89.754 + */
89.755 + private static String[] parsePath(String path) {
89.756 + if (path == null) return new String[0];
89.757 + List<String> pathItems = new LinkedList<String>();
89.758 + int index;
89.759 + while ((index = path.indexOf('.')) != -1) {
89.760 + pathItems.add(path.substring(0,index));
89.761 + path = path.substring(index+1);
89.762 + }
89.763 + pathItems.add(path);
89.764 + return pathItems.toArray(new String[pathItems.size()]);
89.765 + }
89.766 +
89.767 + void establishUpdatedBindings(RADComponent metacomp, boolean recursive,
89.768 + Map map, BindingGroup group, boolean inModel) {
89.769 + for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
89.770 + RADComponent sourceComp = bindingDef.getSource();
89.771 + RADComponent targetComp = bindingDef.getTarget();
89.772 + if (sourceComp.isInModel() && targetComp.isInModel()) {
89.773 + if (inModel) {
89.774 + addBindingInModel(bindingDef);
89.775 + } else {
89.776 + Object source = null;
89.777 + if (map != null)
89.778 + source = map.get(sourceComp.getId());
89.779 + if (source == null)
89.780 + source = sourceComp.getBeanInstance(); // also used if clone not available
89.781 + Object target = map != null ?
89.782 + map.get(targetComp.getId()) : targetComp.getBeanInstance();
89.783 + if (source != null && target != null)
89.784 + addBinding(bindingDef, source, target, group, false);
89.785 + }
89.786 + }
89.787 + }
89.788 + }
89.789 +
89.790 + static void establishOneOffBindings(RADComponent metacomp,
89.791 + boolean recursive, Map map, BindingGroup group) {
89.792 + for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
89.793 + RADComponent sourceComp = bindingDef.getSource();
89.794 + RADComponent targetComp = bindingDef.getTarget();
89.795 + Object source = null;
89.796 + if (map != null)
89.797 + source = map.get(sourceComp.getId());
89.798 + if (source == null)
89.799 + source = sourceComp.getBeanInstance(); // also used if clone not available
89.800 + Object target = map != null ?
89.801 + map.get(targetComp.getId()) : targetComp.getBeanInstance();
89.802 + if (source != null && target != null)
89.803 + createBinding(bindingDef, source, target, group, null);
89.804 + }
89.805 + }
89.806 +
89.807 + private void releaseBindings(RADComponent metacomp, boolean recursive) {
89.808 + for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
89.809 + removeBindings(bindingDef); // unbinds and removes all bindings
89.810 + // created according to this definition
89.811 + }
89.812 + }
89.813 +
89.814 + private static Collection<MetaBinding> collectBindingDefs(RADComponent metacomp, boolean recursive) {
89.815 + Collection<MetaBinding> col = collectBindingDefs(metacomp, recursive, null);
89.816 + if (col == null)
89.817 + col = Collections.emptyList();
89.818 + return col;
89.819 + }
89.820 +
89.821 + private static Collection<MetaBinding> collectBindingDefs(
89.822 + RADComponent metacomp, boolean recursive, Collection<MetaBinding> col)
89.823 + {
89.824 + for (BindingProperty bProp : metacomp.getKnownBindingProperties()) {
89.825 + MetaBinding bindingDef = bProp.getValue();
89.826 + if (bindingDef != null) {
89.827 + if (col == null)
89.828 + col = new LinkedList<MetaBinding>();
89.829 + col.add(bindingDef);
89.830 + }
89.831 + }
89.832 +
89.833 + if (recursive && metacomp instanceof ComponentContainer) {
89.834 + for (RADComponent subcomp : ((ComponentContainer)metacomp).getSubBeans()) {
89.835 + col = collectBindingDefs(subcomp, recursive, col);
89.836 + }
89.837 + }
89.838 +
89.839 + return col;
89.840 + }
89.841 +
89.842 + private void addBindingInModel(MetaBinding bindingDef) {
89.843 + addBinding(bindingDef,
89.844 + bindingDef.getSource().getBeanInstance(),
89.845 + bindingDef.getTarget().getBeanInstance(),
89.846 + bindingGroup, true);
89.847 + }
89.848 +
89.849 + /**
89.850 + * Creates binding according to given MetaBinding between given source and
89.851 + * target objects. The binding is registered, so it is automatically unbound
89.852 + * and removed when the MetaBinding is removed (or the source/target component).
89.853 + *
89.854 + * @param bindingDef description of the binding
89.855 + * @param source binding source
89.856 + * @param target binding target
89.857 + * @param group binding group where the binding should be added
89.858 + * @param inModel determines whether we are creating binding in the model
89.859 + */
89.860 + void addBinding(MetaBinding bindingDef, Object source, Object target,
89.861 + BindingGroup group, boolean inModel) {
89.862 + if (inModel) {
89.863 + if (modelBindings.get(bindingDef) == null) {
89.864 + modelBindings.put(bindingDef, createBinding(bindingDef, source, target, group, bindingToGroup));
89.865 + }
89.866 + } else {
89.867 + List<Binding> establishedBindings = bindingsMap.get(bindingDef);
89.868 + if (establishedBindings != null) {
89.869 + for (Binding binding : establishedBindings) {
89.870 + if (binding.getSourceObject() == source
89.871 + && binding.getTargetObject() == target)
89.872 + return; // this binding already exists
89.873 + }
89.874 + }
89.875 + else {
89.876 + establishedBindings = new LinkedList<Binding>();
89.877 + bindingsMap.put(bindingDef, establishedBindings);
89.878 + }
89.879 + establishedBindings.add(createBinding(bindingDef, source, target, group, bindingToGroup));
89.880 + }
89.881 + }
89.882 +
89.883 + private static String actualTargetPath(MetaBinding bindingDef) {
89.884 + String targetPath = bindingDef.getTargetPath();
89.885 + if ("text".equals(targetPath)) { // NOI18N
89.886 + Class<?> targetClass = bindingDef.getTarget().getBeanClass();
89.887 + if (JTextComponent.class.isAssignableFrom(targetClass)) {
89.888 + String strategy = bindingDef.getParameter(MetaBinding.TEXT_CHANGE_STRATEGY);
89.889 + if (MetaBinding.TEXT_CHANGE_ON_ACTION_OR_FOCUS_LOST.equals(strategy)) {
89.890 + targetPath += "_ON_ACTION_OR_FOCUS_LOST"; // NOI18N
89.891 + } else if (MetaBinding.TEXT_CHANGE_ON_FOCUS_LOST.equals(strategy)) {
89.892 + targetPath += "_ON_FOCUS_LOST"; // NOI18N
89.893 + }
89.894 + }
89.895 + } else if ("selectedElement".equals(targetPath) || "selectedElements".equals(targetPath)) { // NOI18N
89.896 + Class<?> targetClass = bindingDef.getTarget().getBeanClass();
89.897 + if (JList.class.isAssignableFrom(targetClass)
89.898 + || JTable.class.isAssignableFrom(targetClass)
89.899 + || JComboBox.class.isAssignableFrom(targetClass)) {
89.900 + String value = bindingDef.getParameter(MetaBinding.IGNORE_ADJUSTING_PARAMETER);
89.901 + if ("Y".equals(value)) { // NOI18N
89.902 + targetPath += "_IGNORE_ADJUSTING"; // NOI18N
89.903 + }
89.904 + }
89.905 + } else if ("value".equals(targetPath)) { // NOI18N
89.906 + Class<?> targetClass = bindingDef.getTarget().getBeanClass();
89.907 + if (JSlider.class.isAssignableFrom(targetClass)) {
89.908 + String value = bindingDef.getParameter(MetaBinding.IGNORE_ADJUSTING_PARAMETER);
89.909 + if ("Y".equals(value)) { // NOI18N
89.910 + targetPath += "_IGNORE_ADJUSTING"; // NOI18N
89.911 + }
89.912 + }
89.913 + }
89.914 + return targetPath;
89.915 + }
89.916 +
89.917 + private static void generateTargetProperty(MetaBinding bindingDef, StringBuilder buf) {
89.918 + String targetPath = actualTargetPath(bindingDef);
89.919 + String property = BeanProperty.class.getName() + ".create(\"" + targetPath + "\")"; // NOI18N
89.920 + buf.append(property);
89.921 + }
89.922 +
89.923 + private static Property createTargetProperty(MetaBinding bindingDef) {
89.924 + String targetPath = actualTargetPath(bindingDef);
89.925 + Property property = BeanProperty.create(targetPath);
89.926 + return property;
89.927 + }
89.928 +
89.929 + @Override
89.930 + public String generateBinding(BindingProperty prop, StringBuilder buf, CodeGeneratorContext generator) {
89.931 + String variable;
89.932 + MetaBinding bindingDef = prop.getValue();
89.933 + // Update strategy
89.934 + int updateStrategy = bindingDef.getUpdateStrategy();
89.935 + String strategy = AutoBinding.class.getName() + ".UpdateStrategy."; // NOI18N
89.936 + if (updateStrategy == MetaBinding.UPDATE_STRATEGY_READ) {
89.937 + strategy += "READ"; // NOI18N
89.938 + } else if (updateStrategy == MetaBinding.UPDATE_STRATEGY_READ_ONCE) {
89.939 + strategy += "READ_ONCE"; // NOI18N
89.940 + } else {
89.941 + strategy += "READ_WRITE"; // NOI18N
89.942 + }
89.943 + strategy += ", "; // NOI18N
89.944 +
89.945 + RADComponent target = bindingDef.getTarget();
89.946 + Class targetClass = target.getBeanClass();
89.947 + String targetPath = bindingDef.getTargetPath();
89.948 + String sourcePath = bindingDef.getSourcePath();
89.949 + Class<?> sourceClass = bindingDef.getSource().getBeanClass();
89.950 + if ("elements".equals(targetPath) && JTable.class.isAssignableFrom(targetClass)
89.951 + && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
89.952 + String elVariable = elVariableHelper(sourcePath, buf, generator);
89.953 + variable = generator.getBindingDescriptionVariable(JTableBinding.class, buf, false);
89.954 + if (variable == null) {
89.955 + variable = generator.getBindingDescriptionVariable(JTableBinding.class, buf, true);
89.956 + buf.append(' ');
89.957 + }
89.958 + buf.append(variable);
89.959 + buf.append(" = "); // NOI18N
89.960 + buf.append(SwingBindings.class.getName()).append(".createJTableBinding("); // NOI18N
89.961 + buf.append(strategy);
89.962 + buf.append(generator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
89.963 + buf.append(", "); // NOI18N
89.964 + if (sourcePath != null) {
89.965 + buf.append(elVariable);
89.966 + buf.append(", "); // NOI18N
89.967 + }
89.968 + buf.append(generator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
89.969 + buildBindingNameCode(prop, buf);
89.970 + buf.append(");\n"); // NOI18N
89.971 + if (bindingDef.hasSubBindings()) {
89.972 + for (MetaBinding sub : bindingDef.getSubBindings()) {
89.973 + String columnVariable = generator.getBindingDescriptionVariable(JTableBinding.ColumnBinding.class, buf, false);
89.974 + if (columnVariable == null) {
89.975 + columnVariable = generator.getBindingDescriptionVariable(JTableBinding.ColumnBinding.class, buf, true);
89.976 + buf.append(' ');
89.977 + }
89.978 + buf.append(columnVariable);
89.979 + buf.append(" = "); // NOI18N
89.980 + buf.append(variable);
89.981 + String subSourcePath = sub.getSourcePath();
89.982 + buf.append(".addColumnBinding("); // NOI18N
89.983 + if ((subSourcePath == null) || "null".equals(subSourcePath)) { // NOI18N
89.984 + buf.append(ObjectProperty.class.getName());
89.985 + buf.append(".create()"); // NOI18N
89.986 + } else {
89.987 + buf.append(ELProperty.class.getName());
89.988 + buf.append(".create(\""); // NOI18N
89.989 + buf.append(subSourcePath);
89.990 + buf.append("\")"); // NOI18N
89.991 + }
89.992 + buf.append(");\n"); // NOI18N
89.993 + String title = sub.getParameter(MetaBinding.NAME_PARAMETER);
89.994 + if (title == null) {
89.995 + title = subSourcePath;
89.996 + if (isSimpleExpression(title)) {
89.997 + title = unwrapSimpleExpression(title);
89.998 + title = capitalize(title);
89.999 + }
89.1000 + }
89.1001 + if ((title != null) && (!"null".equals(title))) { // NOI18N
89.1002 + buf.append(columnVariable);
89.1003 + buf.append(".setColumnName(\""); // NOI18N
89.1004 + buf.append(title);
89.1005 + buf.append("\");\n"); // NOI18N
89.1006 + }
89.1007 + String columnClass = sub.getParameter(MetaBinding.TABLE_COLUMN_CLASS_PARAMETER);
89.1008 + if (columnClass != null) {
89.1009 + buf.append(columnVariable);
89.1010 + buf.append(".setColumnClass("); // NOI18N
89.1011 + buf.append(columnClass);
89.1012 + buf.append(");\n"); // NOI18N
89.1013 + }
89.1014 + String editable = sub.getParameter(MetaBinding.EDITABLE_PARAMETER);
89.1015 + if (editable != null) {
89.1016 + buf.append(columnVariable);
89.1017 + buf.append(".setEditable("); // NOI18N
89.1018 + buf.append(editable);
89.1019 + buf.append(");\n"); // NOI18N
89.1020 + }
89.1021 + }
89.1022 + }
89.1023 + } else if ("elements".equals(targetPath) && javax.swing.JList.class.isAssignableFrom(targetClass)
89.1024 + && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
89.1025 + String elVariable = elVariableHelper(sourcePath, buf, generator);
89.1026 + variable = generator.getBindingDescriptionVariable(JListBinding.class, buf, false);
89.1027 + if (variable == null) {
89.1028 + variable = generator.getBindingDescriptionVariable(JListBinding.class, buf, true);
89.1029 + buf.append(' ');
89.1030 + }
89.1031 + buf.append(variable);
89.1032 + buf.append(" = "); // NOI18N
89.1033 + buf.append(SwingBindings.class.getName()).append(".createJListBinding("); // NOI18N
89.1034 + buf.append(strategy);
89.1035 + buf.append(generator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
89.1036 + buf.append(", "); // NOI18N
89.1037 + if (sourcePath != null) {
89.1038 + buf.append(elVariable);
89.1039 + buf.append(", "); // NOI18N
89.1040 + }
89.1041 + buf.append(generator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
89.1042 + buildBindingNameCode(prop, buf);
89.1043 + buf.append(");\n"); // NOI18N
89.1044 + String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
89.1045 + if (detailPath != null) {
89.1046 + buf.append(variable);
89.1047 + buf.append(".setDetailBinding("); // NOI18N
89.1048 + buf.append(ELProperty.class.getName());
89.1049 + buf.append(".create(\""); // NOI18N
89.1050 + buf.append(detailPath);
89.1051 + buf.append("\"));\n"); // NOI18N
89.1052 + }
89.1053 + } else if ("elements".equals(targetPath) && javax.swing.JComboBox.class.isAssignableFrom(targetClass)
89.1054 + && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
89.1055 + String elVariable = elVariableHelper(sourcePath, buf, generator);
89.1056 + variable = generator.getBindingDescriptionVariable(JComboBoxBinding.class, buf, false);
89.1057 + if (variable == null) {
89.1058 + variable = generator.getBindingDescriptionVariable(JComboBoxBinding.class, buf, true);
89.1059 + buf.append(' ');
89.1060 + }
89.1061 + buf.append(variable);
89.1062 + buf.append(" = "); // NOI18N
89.1063 + buf.append(SwingBindings.class.getName()).append(".createJComboBoxBinding("); // NOI18N
89.1064 + buf.append(strategy);
89.1065 + buf.append(generator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
89.1066 + buf.append(", "); // NOI18N
89.1067 + if (sourcePath != null) {
89.1068 + buf.append(elVariable);
89.1069 + buf.append(", "); // NOI18N
89.1070 + }
89.1071 + buf.append(generator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
89.1072 + buildBindingNameCode(prop, buf);
89.1073 + buf.append(");\n"); // NOI18N
89.1074 + } else {
89.1075 + variable = generator.getBindingDescriptionVariable(Binding.class, buf, false);
89.1076 + StringBuilder sb = new StringBuilder();
89.1077 + if (variable == null) {
89.1078 + variable = generator.getBindingDescriptionVariable(Binding.class, buf, true);
89.1079 + buf.append(' ');
89.1080 + buf.append(sb);
89.1081 + }
89.1082 + buf.append(variable);
89.1083 + buf.append(" = "); // NOI18N
89.1084 + buf.append(Bindings.class.getName()).append(sb).append(".createAutoBinding("); // NOI18N
89.1085 + buf.append(strategy);
89.1086 + buildBindingParamsCode(prop, buf, generator);
89.1087 + }
89.1088 + return variable;
89.1089 + }
89.1090 +
89.1091 + private static ELProperty createELProperty(String path) {
89.1092 + ELProperty property;
89.1093 + try {
89.1094 + property = ELProperty.create(path);
89.1095 + } catch (Exception ex) {
89.1096 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ex.getMessage(), ex);
89.1097 + // fallback
89.1098 + property = ELProperty.create("error"); // NOI18N
89.1099 + }
89.1100 + return property;
89.1101 + }
89.1102 +
89.1103 + private static String elVariableHelper(String sourcePath, StringBuilder buf, CodeGeneratorContext generator) {
89.1104 + String elVariable = null;
89.1105 + if (sourcePath != null) {
89.1106 + elVariable = generator.getBindingDescriptionVariable(ELProperty.class, buf, false);
89.1107 + if (elVariable == null) {
89.1108 + elVariable = generator.getBindingDescriptionVariable(ELProperty.class, buf, true);
89.1109 + buf.append(' ');
89.1110 + }
89.1111 + buf.append(elVariable);
89.1112 + buf.append(" = "); // NOI18N
89.1113 + buf.append(ELProperty.class.getName());
89.1114 + buf.append(".create(\""); // NOI18N
89.1115 + buf.append(sourcePath);
89.1116 + buf.append("\");\n"); // NOI18N
89.1117 + }
89.1118 + return elVariable;
89.1119 + }
89.1120 +
89.1121 + private static void buildBindingParamsCode(BindingProperty prop, StringBuilder buf, CodeGeneratorContext generator) {
89.1122 + MetaBinding bindingDef = prop.getValue();
89.1123 + String sourcePath = bindingDef.getSourcePath();
89.1124 + String targetPath = bindingDef.getTargetPath();
89.1125 + buf.append(generator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
89.1126 + buf.append(", "); // NOI18N
89.1127 + if (sourcePath != null) {
89.1128 + buf.append(ELProperty.class.getName());
89.1129 + buf.append(".create(\""); // NOI18N
89.1130 + buf.append(sourcePath);
89.1131 + buf.append("\")"); // NOI18N
89.1132 + } else {
89.1133 + buf.append(ObjectProperty.class.getName());
89.1134 + buf.append(".create()"); // NOI18N
89.1135 + }
89.1136 + buf.append(", "); // NOI18N
89.1137 + buf.append(generator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
89.1138 + buf.append(", "); // NOI18N
89.1139 + if (targetPath != null) {
89.1140 + generateTargetProperty(bindingDef, buf);
89.1141 + } else {
89.1142 + buf.append(ObjectProperty.class.getName());
89.1143 + buf.append(".create()"); // NOI18N
89.1144 + }
89.1145 + buildBindingNameCode(prop, buf);
89.1146 + buf.append(");\n"); // NOI18N
89.1147 + }
89.1148 +
89.1149 + private static void buildBindingNameCode(BindingProperty prop, StringBuilder buf) {
89.1150 + MetaBinding bindingDef = prop.getValue();
89.1151 + if (bindingDef.isNameSpecified()) {
89.1152 + try {
89.1153 + FormProperty property = prop.getNameProperty();
89.1154 + Object value = property.getValue();
89.1155 + if (value != null) {
89.1156 + buf.append(", "); // NOI18N
89.1157 + buf.append(property.getJavaInitializationString());
89.1158 + }
89.1159 + } catch (IllegalAccessException iaex) {
89.1160 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1161 + } catch (InvocationTargetException itex) {
89.1162 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1163 + }
89.1164 + }
89.1165 + }
89.1166 +
89.1167 + private static Binding createBinding0(MetaBinding bindingDef, Object source, Object target, BindingGroup group) {
89.1168 + String name = null;
89.1169 + if (bindingDef.isNameSpecified()) {
89.1170 + BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
89.1171 + FormProperty nameProp = prop.getNameProperty();
89.1172 + try {
89.1173 + Object value = nameProp.getRealValue();
89.1174 + if ((value != null) && (value instanceof String)) {
89.1175 + name = (String)value;
89.1176 + }
89.1177 + } catch (IllegalAccessException iaex) {
89.1178 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1179 + } catch (InvocationTargetException itex) {
89.1180 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1181 + }
89.1182 + if ((name != null) && group.getBinding(name) != null) {
89.1183 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, "More than one binding with name: {0}", name); // NOI18N
89.1184 + name = null; // ignore name parameter
89.1185 + }
89.1186 + }
89.1187 + AutoBinding.UpdateStrategy updateStrategy = AutoBinding.UpdateStrategy.READ_WRITE;
89.1188 + switch (bindingDef.getUpdateStrategy()) {
89.1189 + case MetaBinding.UPDATE_STRATEGY_READ_WRITE:
89.1190 + updateStrategy = AutoBinding.UpdateStrategy.READ_WRITE;
89.1191 + break;
89.1192 + case MetaBinding.UPDATE_STRATEGY_READ:
89.1193 + updateStrategy = AutoBinding.UpdateStrategy.READ;
89.1194 + break;
89.1195 + case MetaBinding.UPDATE_STRATEGY_READ_ONCE:
89.1196 + updateStrategy = AutoBinding.UpdateStrategy.READ_ONCE;
89.1197 + break;
89.1198 + default: assert false;
89.1199 + }
89.1200 + Binding<Object,?,Object,?> binding;
89.1201 + Property targetProperty = createTargetProperty(bindingDef);
89.1202 + Property sourceProperty = (bindingDef.getSourcePath() == null) ? ObjectProperty.create() : createELProperty(bindingDef.getSourcePath());
89.1203 + RADComponent targetComp = bindingDef.getTarget();
89.1204 + String targetPath = bindingDef.getTargetPath();
89.1205 + String sourcePath = bindingDef.getSourcePath();
89.1206 + if ("elements".equals(targetPath) && javax.swing.JTable.class.isAssignableFrom(targetComp.getBeanClass())
89.1207 + && ((source instanceof List) || (sourcePath != null))) { // NOI18N
89.1208 + JTableBinding<Object,Object,Object> tableBinding;
89.1209 + if (sourcePath == null) {
89.1210 + tableBinding = SwingBindings.createJTableBinding(updateStrategy, (List)source, (JTable)target, name);
89.1211 + } else {
89.1212 + tableBinding = SwingBindings.createJTableBinding(updateStrategy, source, sourceProperty, (JTable)target, name);
89.1213 + }
89.1214 + if (bindingDef.hasSubBindings()) {
89.1215 + Collection<MetaBinding> subBindings = bindingDef.getSubBindings();
89.1216 + for (MetaBinding sub : subBindings) {
89.1217 + Property prop;
89.1218 + String subSourcePath = sub.getSourcePath();
89.1219 + if ((subSourcePath == null) || ("null".equals(subSourcePath))) { // NOI18N
89.1220 + prop = ObjectProperty.create();
89.1221 + } else {
89.1222 + prop = createELProperty(subSourcePath);
89.1223 + }
89.1224 + JTableBinding.ColumnBinding columnBinding = tableBinding.addColumnBinding(prop);
89.1225 + String title = sub.getParameter(MetaBinding.NAME_PARAMETER);
89.1226 + if (title == null) {
89.1227 + title = sub.getSourcePath();
89.1228 + if (isSimpleExpression0(title)) {
89.1229 + title = unwrapSimpleExpression0(title);
89.1230 + title = capitalize0(title);
89.1231 + }
89.1232 + }
89.1233 + columnBinding.setColumnName(title);
89.1234 + String columnClass = sub.getParameter(MetaBinding.TABLE_COLUMN_CLASS_PARAMETER);
89.1235 + if (columnClass != null) {
89.1236 + try {
89.1237 + if ((columnClass != null) && columnClass.trim().endsWith(".class")) { // NOI18N
89.1238 + columnClass = columnClass.trim();
89.1239 + columnClass = columnClass.substring(0, columnClass.length()-6);
89.1240 + }
89.1241 + if (columnClass.indexOf('.') == -1) {
89.1242 + String prefix = ""; // NOI18N
89.1243 + while (columnClass.endsWith("[]")) { // NOI18N
89.1244 + columnClass = columnClass.substring(0, columnClass.length()-2);
89.1245 + prefix += "["; // NOI18N
89.1246 + }
89.1247 + if ("".equals(prefix)) { // NOI18N
89.1248 + columnClass = "java.lang." + columnClass; // NOI18N
89.1249 + } else {
89.1250 + String suffix = columnClass;
89.1251 + if (columnClass.equals("boolean")) { // NOI18N
89.1252 + suffix = "Z"; // NOI18N
89.1253 + } else if (columnClass.equals("byte")) { // NOI18N
89.1254 + suffix = "B"; // NOI18N
89.1255 + } else if (columnClass.equals("char")) { // NOI18N
89.1256 + suffix = "C"; // NOI18N
89.1257 + } else if (columnClass.equals("char")) { // NOI18N
89.1258 + suffix = "D"; // NOI18N
89.1259 + } else if (columnClass.equals("float")) { // NOI18N
89.1260 + suffix = "F"; // NOI18N
89.1261 + } else if (columnClass.equals("int")) { // NOI18N
89.1262 + suffix = "I"; // NOI18N
89.1263 + } else if (columnClass.equals("long")) { // NOI18N
89.1264 + suffix = "J"; // NOI18N
89.1265 + } else if (columnClass.equals("short")) { // NOI18N
89.1266 + suffix = "S"; // NOI18N
89.1267 + } else {
89.1268 + prefix += "L"; // NOI18N
89.1269 + if (suffix.indexOf('.') == -1) {
89.1270 + suffix = "java.lang." + suffix; // NOI18N
89.1271 + }
89.1272 + suffix += ";"; // NOI18N
89.1273 + }
89.1274 + columnClass = prefix + suffix;
89.1275 + }
89.1276 + }
89.1277 + Class<?> clazz = FormUtils.loadClass(columnClass, bindingDef.getSource().getFormModel());
89.1278 + columnBinding.setColumnClass(clazz);
89.1279 + } catch (ClassNotFoundException cnfex) {
89.1280 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, cnfex.getMessage(), cnfex);
89.1281 + }
89.1282 + }
89.1283 + String editable = sub.getParameter(MetaBinding.EDITABLE_PARAMETER);
89.1284 + if (editable != null) {
89.1285 + Boolean value = "false".equals(editable) ? Boolean.FALSE : Boolean.TRUE; // NOI18N
89.1286 + columnBinding.setEditable(value);
89.1287 + }
89.1288 + }
89.1289 + }
89.1290 + binding = tableBinding;
89.1291 + } else if ("elements".equals(targetPath) && javax.swing.JList.class.isAssignableFrom(targetComp.getBeanClass())
89.1292 + && ((source instanceof List) || (sourcePath != null))) { // NOI18N
89.1293 + JListBinding listBinding;
89.1294 + if (sourcePath == null) {
89.1295 + listBinding = SwingBindings.createJListBinding(updateStrategy, (List)source, (JList)target, name);
89.1296 + } else {
89.1297 + listBinding = SwingBindings.createJListBinding(updateStrategy, source, sourceProperty, (JList)target, name);
89.1298 + }
89.1299 + String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
89.1300 + if (detailPath != null) {
89.1301 + listBinding.setDetailBinding(createELProperty(detailPath));
89.1302 + }
89.1303 + binding = listBinding;
89.1304 + } else if ("elements".equals(targetPath) && javax.swing.JComboBox.class.isAssignableFrom(targetComp.getBeanClass())
89.1305 + && ((source instanceof List) || (sourcePath != null))) { // NOI18N
89.1306 + JComboBoxBinding comboBinding;
89.1307 + if (sourcePath == null) {
89.1308 + comboBinding = SwingBindings.createJComboBoxBinding(updateStrategy, (List)source, (JComboBox)target, name);
89.1309 + } else {
89.1310 + comboBinding = SwingBindings.createJComboBoxBinding(updateStrategy, source, sourceProperty, (JComboBox)target, name);
89.1311 + }
89.1312 +// String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
89.1313 +// if (detailPath != null) {
89.1314 +// comboBinding.setDetailBinding(createELProperty(detailPath));
89.1315 +// }
89.1316 + binding = comboBinding;
89.1317 + } else {
89.1318 + binding = Bindings.createAutoBinding(updateStrategy, source, sourceProperty, target, targetProperty, name);
89.1319 + }
89.1320 + return binding;
89.1321 + }
89.1322 +
89.1323 + private static Binding createBinding(MetaBinding bindingDef,
89.1324 + Object source, Object target,
89.1325 + BindingGroup group,
89.1326 + Map<Binding,BindingGroup> bindingToGroup) {
89.1327 + Binding<Object,Object,Object,Object> binding = (Binding<Object,Object,Object,Object>)createBinding0(bindingDef, source, target, group);
89.1328 + if (bindingDef.isNullValueSpecified()) {
89.1329 + BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
89.1330 + FormProperty nullProp = prop.getNullValueProperty();
89.1331 + try {
89.1332 + Object value = nullProp.getRealValue();
89.1333 + if ((value != null) && (value != FormDesignValue.IGNORED_VALUE)) {
89.1334 + binding.setSourceNullValue(value);
89.1335 + }
89.1336 + } catch (IllegalAccessException iaex) {
89.1337 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1338 + } catch (InvocationTargetException itex) {
89.1339 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1340 + }
89.1341 + }
89.1342 + if (bindingDef.isIncompletePathValueSpecified()) {
89.1343 + BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
89.1344 + FormProperty incompleteProp = prop.getIncompleteValueProperty();
89.1345 + try {
89.1346 + Object value = incompleteProp.getRealValue();
89.1347 + if ((value != null) && (value != FormDesignValue.IGNORED_VALUE)) {
89.1348 + binding.setSourceUnreadableValue(value);
89.1349 + }
89.1350 + } catch (IllegalAccessException iaex) {
89.1351 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1352 + } catch (InvocationTargetException itex) {
89.1353 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1354 + }
89.1355 + }
89.1356 + if (bindingDef.isConverterSpecified()) {
89.1357 + BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
89.1358 + FormProperty converterProp = prop.getConverterProperty();
89.1359 + try {
89.1360 + Object value = converterProp.getRealValue();
89.1361 + if ((value != null) && (value instanceof Converter)) {
89.1362 + binding.setConverter((Converter)value);
89.1363 + }
89.1364 + } catch (IllegalAccessException iaex) {
89.1365 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1366 + } catch (InvocationTargetException itex) {
89.1367 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1368 + }
89.1369 + }
89.1370 + if (bindingDef.isValidatorSpecified()) {
89.1371 + BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
89.1372 + FormProperty validatorProp = prop.getValidatorProperty();
89.1373 + try {
89.1374 + Object value = validatorProp.getRealValue();
89.1375 + if ((value != null) && (value instanceof Validator)) {
89.1376 + binding.setValidator((Validator)value);
89.1377 + }
89.1378 + } catch (IllegalAccessException iaex) {
89.1379 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
89.1380 + } catch (InvocationTargetException itex) {
89.1381 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, itex.getMessage(), itex);
89.1382 + }
89.1383 + }
89.1384 + group.addBinding(binding);
89.1385 + if (bindingToGroup != null) {
89.1386 + bindingToGroup.put(binding, group);
89.1387 + }
89.1388 +
89.1389 + try {
89.1390 + binding.bind();
89.1391 + } catch (Exception ex) {
89.1392 + Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ex.getMessage(), ex);
89.1393 + }
89.1394 + return binding;
89.1395 + }
89.1396 +
89.1397 + private void removeBindings(MetaBinding bindingDef) {
89.1398 + removeBindingInModel(bindingDef);
89.1399 + List<Binding> establishedBindings = bindingsMap.get(bindingDef);
89.1400 + if (establishedBindings != null) {
89.1401 + for (Binding binding : establishedBindings) {
89.1402 + removeBinding(binding);
89.1403 + }
89.1404 + bindingsMap.remove(bindingDef);
89.1405 + }
89.1406 + }
89.1407 +
89.1408 + private void removeBinding(Binding binding) {
89.1409 + BindingGroup group = bindingToGroup.remove(binding);
89.1410 + // It may happen that binding.bind() fails. Binding may
89.1411 + // stay unbound in such situation and binding.unbind()
89.1412 + // throws exception is this case
89.1413 + if (binding.isBound()) {
89.1414 + binding.unbind();
89.1415 + }
89.1416 + group.removeBinding(binding);
89.1417 + }
89.1418 +
89.1419 + private void removeBindingInModel(MetaBinding bindingDef) {
89.1420 + Binding binding = modelBindings.remove(bindingDef);
89.1421 + if (binding != null) {
89.1422 + removeBinding(binding);
89.1423 + }
89.1424 + }
89.1425 +
89.1426 + @Override
89.1427 + public String capitalize(String title) {
89.1428 + return capitalize0(title);
89.1429 + }
89.1430 +
89.1431 + static String capitalize0(String title) {
89.1432 + StringBuilder builder = new StringBuilder(title);
89.1433 + boolean lastWasUpper = false;
89.1434 + for (int i = 0; i < builder.length(); i++) {
89.1435 + char aChar = builder.charAt(i);
89.1436 + if (i == 0) {
89.1437 + builder.setCharAt(i, Character.toUpperCase(aChar));
89.1438 + lastWasUpper = true;
89.1439 + } else if (Character.isUpperCase(aChar)) {
89.1440 + if (!lastWasUpper) {
89.1441 + builder.insert(i, ' ');
89.1442 + }
89.1443 + lastWasUpper = true;
89.1444 + i++;
89.1445 + } else {
89.1446 + lastWasUpper = false;
89.1447 + }
89.1448 + }
89.1449 + return builder.toString();
89.1450 + }
89.1451 +
89.1452 + @Override
89.1453 + public BindingVisualReplicator createReplicator() {
89.1454 + return new BindingVisualReplicatorImpl();
89.1455 + }
89.1456 +
89.1457 + @Override
89.1458 + public Class getBindingGroupClass() {
89.1459 + return BindingGroup.class;
89.1460 + }
89.1461 +
89.1462 + @Override
89.1463 + public Class getConverterClass() {
89.1464 + return Converter.class;
89.1465 + }
89.1466 +
89.1467 + @Override
89.1468 + public Class getValidatorClass() {
89.1469 + return Validator.class;
89.1470 + }
89.1471 +
89.1472 + @Override
89.1473 + public boolean updateProjectForBeansBinding() {
89.1474 + FormEditor formEditor = FormEditor.getFormEditor(formModel);
89.1475 + if (formEditor != null
89.1476 + && !ClassPathUtils.isOnClassPath(formEditor.getFormDataObject().getFormFile(), Binding.class.getName())) {
89.1477 + try {
89.1478 + Library lib = LibraryManager.getDefault().getLibrary("beans-binding"); // NOI18N
89.1479 + if (lib == null) {
89.1480 + return false;
89.1481 + }
89.1482 + ClassSource cs = new ClassSource("", // class name is not needed // NOI18N
89.1483 + new ClassSource.LibraryEntry(lib));
89.1484 + return Boolean.TRUE == ClassPathUtils.updateProject(formEditor.getFormDataObject().getFormFile(), cs);
89.1485 + }
89.1486 + catch (IOException ex) {
89.1487 + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
89.1488 + }
89.1489 + }
89.1490 + return false;
89.1491 + }
89.1492 +
89.1493 + private class BindingVisualReplicatorImpl implements BindingVisualReplicator {
89.1494 + private BindingGroup group;
89.1495 +
89.1496 + BindingVisualReplicatorImpl() {
89.1497 + group = new BindingGroup();
89.1498 + group.bind();
89.1499 + }
89.1500 +
89.1501 + @Override
89.1502 + public void addBinding(MetaBinding bindingDef, Object source, Object target, boolean inModel) {
89.1503 + BindingDesignSupportImpl.this.addBinding(bindingDef, source, target, group, inModel);
89.1504 + }
89.1505 +
89.1506 + @Override
89.1507 + public void establishUpdatedBindings(RADComponent metacomp, boolean recursive, Map map, boolean inModel) {
89.1508 + BindingDesignSupportImpl.this.establishUpdatedBindings(metacomp, recursive, map, group, inModel);
89.1509 + }
89.1510 +
89.1511 + @Override
89.1512 + public void establishOneOffBindings(RADComponent metacomp, boolean recursive, Map map) {
89.1513 + BindingDesignSupportImpl.establishOneOffBindings(metacomp, recursive, map, group);
89.1514 + }
89.1515 +
89.1516 + }
89.1517 +
89.1518 + /**
89.1519 + * Form model listener that updates the bindings.
89.1520 + */
89.1521 + private class ModelListener implements FormModelListener {
89.1522 + @Override
89.1523 + public void formChanged(FormModelEvent[] events) {
89.1524 + if (events == null)
89.1525 + return;
89.1526 +
89.1527 + for (int i=0; i < events.length; i++) {
89.1528 + FormModelEvent ev = events[i];
89.1529 + switch (ev.getChangeType()) {
89.1530 + case FormModelEvent.BINDING_PROPERTY_CHANGED:
89.1531 + if (ev.getSubPropertyName() == null) {
89.1532 + changeBinding(ev.getOldBinding(), ev.getNewBinding());
89.1533 + }
89.1534 + break;
89.1535 + case FormModelEvent.COMPONENT_REMOVED:
89.1536 + releaseBindings(ev.getComponent(), true);
89.1537 + break;
89.1538 + case FormModelEvent.COMPONENT_ADDED:
89.1539 + if (!ev.getCreatedDeleted()) {
89.1540 + establishUpdatedBindings(ev.getComponent(), true, null, bindingGroup, true);
89.1541 + }
89.1542 + break;
89.1543 + }
89.1544 + }
89.1545 + }
89.1546 + }
89.1547 +
89.1548 + static class ModifiableBoolean {
89.1549 + boolean value;
89.1550 + }
89.1551 +
89.1552 +}
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
90.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/BindingDesignSupportProviderImpl.java Wed Jul 27 10:35:25 2011 +0200
90.3 @@ -0,0 +1,58 @@
90.4 +/*
90.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
90.6 + *
90.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
90.8 + *
90.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
90.10 + * Other names may be trademarks of their respective owners.
90.11 + *
90.12 + * The contents of this file are subject to the terms of either the GNU
90.13 + * General Public License Version 2 only ("GPL") or the Common Development and
90.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
90.15 + * this file except in compliance with the License. You can obtain a copy of
90.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
90.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
90.18 + * governing permissions and limitations under the License. When distributing
90.19 + * the software, include this License Header Notice in each file and include
90.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
90.21 + * particular file as subject to the "Classpath" exception as provided by
90.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
90.23 + * this code. If applicable, add the following below the License Header, with
90.24 + * the fields enclosed by brackets [] replaced by your own identifying
90.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
90.26 + *
90.27 + * If you wish your version of this file to be governed by only the CDDL or
90.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
90.29 + * elects to include this software in this distribution under the [CDDL or GPL
90.30 + * Version 2] license." If you do not indicate a single choice of license, a
90.31 + * recipient has the option to distribute your version of this file under
90.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
90.33 + * licensees as provided above. However, if you add GPL Version 2 code and
90.34 + * therefore, elected the GPL Version 2 license, then the option applies only
90.35 + * if the new code is made subject to such option by the copyright holder.
90.36 + *
90.37 + * Contributor(s):
90.38 + *
90.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
90.40 + */
90.41 +package org.netbeans.modules.form.binding;
90.42 +
90.43 +import org.netbeans.modules.form.BindingDesignSupport;
90.44 +import org.netbeans.modules.form.BindingDesignSupportProvider;
90.45 +import org.netbeans.modules.form.FormModel;
90.46 +import org.openide.util.lookup.ServiceProvider;
90.47 +
90.48 +/**
90.49 + * Provider of binding support.
90.50 + *
90.51 + * @author Jan Stola
90.52 + */
90.53 +@ServiceProvider(service=BindingDesignSupportProvider.class)
90.54 +public class BindingDesignSupportProviderImpl implements BindingDesignSupportProvider {
90.55 +
90.56 + @Override
90.57 + public BindingDesignSupport create(FormModel formModel) {
90.58 + return new BindingDesignSupportImpl(formModel);
90.59 + }
90.60 +
90.61 +}
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
91.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
91.3 @@ -0,0 +1,46 @@
91.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
91.5 +#
91.6 +# Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
91.7 +#
91.8 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
91.9 +# Other names may be trademarks of their respective owners.
91.10 +#
91.11 +# The contents of this file are subject to the terms of either the GNU
91.12 +# General Public License Version 2 only ("GPL") or the Common
91.13 +# Development and Distribution License("CDDL") (collectively, the
91.14 +# "License"). You may not use this file except in compliance with the
91.15 +# License. You can obtain a copy of the License at
91.16 +# http://www.netbeans.org/cddl-gplv2.html
91.17 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
91.18 +# specific language governing permissions and limitations under the
91.19 +# License. When distributing the software, include this License Header
91.20 +# Notice in each file and include the License file at
91.21 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
91.22 +# particular file as subject to the "Classpath" exception as provided
91.23 +# by Oracle in the GPL Version 2 section of the License file that
91.24 +# accompanied this code. If applicable, add the following below the
91.25 +# License Header, with the fields enclosed by brackets [] replaced by
91.26 +# your own identifying information:
91.27 +# "Portions Copyrighted [year] [name of copyright owner]"
91.28 +#
91.29 +# Contributor(s):
91.30 +#
91.31 +# The Original Software is NetBeans. The Initial Developer of the Original
91.32 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
91.33 +# Microsystems, Inc. All Rights Reserved.
91.34 +#
91.35 +# If you wish your version of this file to be governed by only the CDDL
91.36 +# or only the GPL Version 2, indicate your decision by adding
91.37 +# "[Contributor] elects to include this software in this distribution
91.38 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
91.39 +# single choice of license, a recipient has the option to distribute
91.40 +# your version of this file under either the CDDL, the GPL Version 2 or
91.41 +# to extend the choice of license to its licensees as provided above.
91.42 +# However, if you add GPL Version 2 code and therefore, elected the GPL
91.43 +# Version 2 license, then the option applies only if the new code is
91.44 +# made subject to such option by the copyright holder.
91.45 +
91.46 +OpenIDE-Module-Name=Beans Binding Support for Form Editor
91.47 +OpenIDE-Module-Short-Description=Visual support for keeping two JavaBeans properties synchronized.
91.48 +OpenIDE-Module-Long-Description=Beans Binding provides a visual support for keeping two JavaBeans properties synchronzied.
91.49 +OpenIDE-Module-Display-Category=Java
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
92.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/resources/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
92.3 @@ -0,0 +1,42 @@
92.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
92.5 +#
92.6 +# Copyright 2011 Oracle and/or its affiliates. All rights reserved.
92.7 +#
92.8 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
92.9 +# Other names may be trademarks of their respective owners.
92.10 +#
92.11 +# The contents of this file are subject to the terms of either the GNU
92.12 +# General Public License Version 2 only ("GPL") or the Common
92.13 +# Development and Distribution License("CDDL") (collectively, the
92.14 +# "License"). You may not use this file except in compliance with the
92.15 +# License. You can obtain a copy of the License at
92.16 +# http://www.netbeans.org/cddl-gplv2.html
92.17 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
92.18 +# specific language governing permissions and limitations under the
92.19 +# License. When distributing the software, include this License Header
92.20 +# Notice in each file and include the License file at
92.21 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
92.22 +# particular file as subject to the "Classpath" exception as provided
92.23 +# by Oracle in the GPL Version 2 section of the License file that
92.24 +# accompanied this code. If applicable, add the following below the
92.25 +# License Header, with the fields enclosed by brackets [] replaced by
92.26 +# your own identifying information:
92.27 +# "Portions Copyrighted [year] [name of copyright owner]"
92.28 +#
92.29 +# If you wish your version of this file to be governed by only the CDDL
92.30 +# or only the GPL Version 2, indicate your decision by adding
92.31 +# "[Contributor] elects to include this software in this distribution
92.32 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
92.33 +# single choice of license, a recipient has the option to distribute
92.34 +# your version of this file under either the CDDL, the GPL Version 2 or
92.35 +# to extend the choice of license to its licensees as provided above.
92.36 +# However, if you add GPL Version 2 code and therefore, elected the GPL
92.37 +# Version 2 license, then the option applies only if the new code is
92.38 +# made subject to such option by the copyright holder.
92.39 +#
92.40 +# Contributor(s):
92.41 +#
92.42 +# Portions Copyrighted 2011 Sun Microsystems, Inc.
92.43 +
92.44 +# library name
92.45 +beans-binding=Beans Binding
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/resources/beans_binding.xml Wed Jul 27 10:35:25 2011 +0200
93.3 @@ -0,0 +1,70 @@
93.4 +<?xml version="1.0"?>
93.5 +<!--
93.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
93.7 +
93.8 +Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
93.9 +
93.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
93.11 +Other names may be trademarks of their respective owners.
93.12 +
93.13 +
93.14 +The contents of this file are subject to the terms of either the GNU
93.15 +General Public License Version 2 only ("GPL") or the Common
93.16 +Development and Distribution License("CDDL") (collectively, the
93.17 +"License"). You may not use this file except in compliance with the
93.18 +License. You can obtain a copy of the License at
93.19 +http://www.netbeans.org/cddl-gplv2.html
93.20 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
93.21 +specific language governing permissions and limitations under the
93.22 +License. When distributing the software, include this License Header
93.23 +Notice in each file and include the License file at
93.24 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
93.25 +particular file as subject to the "Classpath" exception as provided
93.26 +by Oracle in the GPL Version 2 section of the License file that
93.27 +accompanied this code. If applicable, add the following below the
93.28 +License Header, with the fields enclosed by brackets [] replaced by
93.29 +your own identifying information:
93.30 +"Portions Copyrighted [year] [name of copyright owner]"
93.31 +
93.32 +Contributor(s):
93.33 +
93.34 +The Original Software is NetBeans. The Initial Developer of the Original
93.35 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
93.36 +Microsystems, Inc. All Rights Reserved.
93.37 +
93.38 +If you wish your version of this file to be governed by only the CDDL
93.39 +or only the GPL Version 2, indicate your decision by adding
93.40 +"[Contributor] elects to include this software in this distribution
93.41 +under the [CDDL or GPL Version 2] license." If you do not indicate a
93.42 +single choice of license, a recipient has the option to distribute
93.43 +your version of this file under either the CDDL, the GPL Version 2 or
93.44 +to extend the choice of license to its licensees as provided above.
93.45 +However, if you add GPL Version 2 code and therefore, elected the GPL
93.46 +Version 2 license, then the option applies only if the new code is
93.47 +made subject to such option by the copyright holder.
93.48 +-->
93.49 +
93.50 +<!DOCTYPE library PUBLIC "-//NetBeans//DTD Library Declaration 1.0//EN" "http://www.netbeans.org/dtds/library-declaration-1_0.dtd">
93.51 +
93.52 +<library version="1.0">
93.53 + <name>beans-binding</name>
93.54 + <type>j2se</type>
93.55 + <localizing-bundle>org.netbeans.modules.form.binding.resources.Bundle</localizing-bundle>
93.56 + <volume>
93.57 + <type>classpath</type>
93.58 + <resource>jar:nbinst://org.jdesktop.beansbinding/modules/ext/beansbinding-1.2.1.jar!/</resource>
93.59 + </volume>
93.60 + <volume>
93.61 + <type>javadoc</type>
93.62 + <resource>jar:nbinst://org.jdesktop.beansbinding/docs/beansbinding-1.2.1-doc.zip!/</resource>
93.63 + </volume>
93.64 + <volume>
93.65 + <type>maven-pom</type>
93.66 + <resource>http://download.java.net/maven/2/org/jdesktop/beansbinding/1.2.1/beansbinding-1.2.1.pom</resource>
93.67 + <!--
93.68 + The following reference is broken. The corresponding JAR doesn't contain
93.69 + META-INF/services directory. Hence, the special binding properties
93.70 + don't work with that JAR.
93.71 + <resource>http://repo2.maven.org/maven2/net/java/dev/beansbinding/beansbinding/1.2.1/beansbinding-1.2.1.pom</resource>-->
93.72 + </volume>
93.73 +</library>
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94.2 +++ b/form.binding/src/org/netbeans/modules/form/binding/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
94.3 @@ -0,0 +1,55 @@
94.4 +
94.5 +<!--
94.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
94.7 +
94.8 +Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
94.9 +
94.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
94.11 +Other names may be trademarks of their respective owners.
94.12 +
94.13 +
94.14 +The contents of this file are subject to the terms of either the GNU
94.15 +General Public License Version 2 only ("GPL") or the Common
94.16 +Development and Distribution License("CDDL") (collectively, the
94.17 +"License"). You may not use this file except in compliance with the
94.18 +License. You can obtain a copy of the License at
94.19 +http://www.netbeans.org/cddl-gplv2.html
94.20 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
94.21 +specific language governing permissions and limitations under the
94.22 +License. When distributing the software, include this License Header
94.23 +Notice in each file and include the License file at
94.24 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
94.25 +particular file as subject to the "Classpath" exception as provided
94.26 +by Oracle in the GPL Version 2 section of the License file that
94.27 +accompanied this code. If applicable, add the following below the
94.28 +License Header, with the fields enclosed by brackets [] replaced by
94.29 +your own identifying information:
94.30 +"Portions Copyrighted [year] [name of copyright owner]"
94.31 +
94.32 +Contributor(s):
94.33 +
94.34 +The Original Software is NetBeans. The Initial Developer of the Original
94.35 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
94.36 +Microsystems, Inc. All Rights Reserved.
94.37 +
94.38 +If you wish your version of this file to be governed by only the CDDL
94.39 +or only the GPL Version 2, indicate your decision by adding
94.40 +"[Contributor] elects to include this software in this distribution
94.41 +under the [CDDL or GPL Version 2] license." If you do not indicate a
94.42 +single choice of license, a recipient has the option to distribute
94.43 +your version of this file under either the CDDL, the GPL Version 2 or
94.44 +to extend the choice of license to its licensees as provided above.
94.45 +However, if you add GPL Version 2 code and therefore, elected the GPL
94.46 +Version 2 license, then the option applies only if the new code is
94.47 +made subject to such option by the copyright holder.
94.48 +-->
94.49 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
94.50 +<filesystem>
94.51 + <folder name="org-netbeans-api-project-libraries">
94.52 + <folder name="Libraries">
94.53 + <file name="beans_binding.xml" url="beans_binding.xml">
94.54 + <attr name="displayName" bundlevalue="org.netbeans.modules.form.binding.resources.Bundle#beans-binding"/>
94.55 + </file>
94.56 + </folder>
94.57 + </folder>
94.58 +</filesystem>
95.1 --- a/form.j2ee/src/org/netbeans/modules/form/j2ee/DBColumnDrop.java Wed Jul 27 10:33:10 2011 +0200
95.2 +++ b/form.j2ee/src/org/netbeans/modules/form/j2ee/DBColumnDrop.java Wed Jul 27 10:35:25 2011 +0200
95.3 @@ -249,6 +249,7 @@
95.4
95.5 BindingProperty prop;
95.6 MetaBinding binding;
95.7 + BindingDesignSupport bindingSupport = FormEditor.getBindingSupport(model);
95.8 if (metaTable == null) {
95.9 RADComponent metaEntity = null;
95.10 Class<?> entityClass = ClassPathUtils.loadClass(entityInfo[1], formFile); // NOI18N
95.11 @@ -279,13 +280,13 @@
95.12 }
95.13
95.14 prop = control.getBindingProperty(controlProperty); // NOI18N
95.15 - binding = new MetaBinding(metaEntity, BindingDesignSupport.elWrap(sourcePath), control, controlProperty); // NOI18N
95.16 + binding = new MetaBinding(metaEntity, bindingSupport.elWrap(sourcePath), control, controlProperty); // NOI18N
95.17 } else {
95.18 prop = control.getBindingProperty("enabled"); // NOI18N
95.19 - binding = new MetaBinding(metaTable, BindingDesignSupport.elWrap("selectedElement != null"), control, "enabled"); // NOI18N
95.20 + binding = new MetaBinding(metaTable, bindingSupport.elWrap("selectedElement != null"), control, "enabled"); // NOI18N
95.21 prop.setValue(binding);
95.22 prop = control.getBindingProperty(controlProperty);
95.23 - binding = new MetaBinding(metaTable, BindingDesignSupport.elWrap("selectedElement." + sourcePath), control, controlProperty); // NOI18N
95.24 + binding = new MetaBinding(metaTable, bindingSupport.elWrap("selectedElement." + sourcePath), control, controlProperty); // NOI18N
95.25 if (controlProperty.equals("text") && JTextComponent.class.isAssignableFrom(control.getBeanClass())) { // NOI18N
95.26 binding.setIncompletePathValueSpecified(true);
95.27 prop.getSubProperty(BindingProperty.PROP_INCOMPLETE_VALUE).setValue(null);
96.1 --- a/form.j2ee/src/org/netbeans/modules/form/j2ee/DBTableDrop.java Wed Jul 27 10:33:10 2011 +0200
96.2 +++ b/form.j2ee/src/org/netbeans/modules/form/j2ee/DBTableDrop.java Wed Jul 27 10:35:25 2011 +0200
96.3 @@ -313,7 +313,8 @@
96.4 List<String> propertyTypes = J2EEUtils.typesOfProperties(formFile, entityInfo[1], propertyNames);
96.5 Iterator<String> typeIter = propertyTypes.iterator();
96.6 for (String column : propertyNames) {
96.7 - MetaBinding subBinding = binding.addSubBinding(BindingDesignSupport.elWrap(column), null);
96.8 + BindingDesignSupport bindingSupport = FormEditor.getBindingSupport(model);
96.9 + MetaBinding subBinding = binding.addSubBinding(bindingSupport.elWrap(column), null);
96.10 String clazz = typeIter.next();
96.11 if (clazz != null) {
96.12 subBinding.setParameter(MetaBinding.TABLE_COLUMN_CLASS_PARAMETER, clazz);
97.1 --- a/form.kit/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
97.2 +++ b/form.kit/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
97.3 @@ -13,6 +13,13 @@
97.4 </run-dependency>
97.5 </dependency>
97.6 <dependency>
97.7 + <code-name-base>org.netbeans.modules.form.binding</code-name-base>
97.8 + <run-dependency>
97.9 + <release-version>0-1</release-version>
97.10 + <specification-version>0.1</specification-version>
97.11 + </run-dependency>
97.12 + </dependency>
97.13 + <dependency>
97.14 <code-name-base>org.netbeans.modules.i18n.form</code-name-base>
97.15 <run-dependency>
97.16 <release-version>2</release-version>
98.1 --- a/form/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
98.2 +++ b/form/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
98.3 @@ -50,14 +50,6 @@
98.4 <code-name-base>org.netbeans.modules.form</code-name-base>
98.5 <module-dependencies>
98.6 <dependency>
98.7 - <code-name-base>org.jdesktop.beansbinding</code-name-base>
98.8 - <build-prerequisite/>
98.9 - <compile-dependency/>
98.10 - <run-dependency>
98.11 - <release-version>1</release-version>
98.12 - </run-dependency>
98.13 - </dependency>
98.14 - <dependency>
98.15 <code-name-base>org.jdesktop.layout</code-name-base>
98.16 <build-prerequisite/>
98.17 <compile-dependency/>
99.1 --- a/form/src/org/netbeans/modules/form/BindingCustomizer.java Wed Jul 27 10:33:10 2011 +0200
99.2 +++ b/form/src/org/netbeans/modules/form/BindingCustomizer.java Wed Jul 27 10:35:25 2011 +0200
99.3 @@ -427,7 +427,7 @@
99.4 List<String> selected = new LinkedList<String>();
99.5 for (MetaBinding subBinding : binding.getSubBindings()) {
99.6 String column = subBinding.getSourcePath();
99.7 - column = BindingDesignSupport.unwrapSimpleExpression(column);
99.8 + column = designSupport.unwrapSimpleExpression(column);
99.9 if (available.contains(column)) {
99.10 selected.add(column);
99.11 available.remove(column);
99.12 @@ -581,7 +581,7 @@
99.13 List items = columnSelector.getSelectedItems();
99.14 for (int i=0; i<items.size(); i++) {
99.15 String item = items.get(i).toString();
99.16 - MetaBinding subBinding = binding.addSubBinding(BindingDesignSupport.elWrap(item), null);
99.17 + MetaBinding subBinding = binding.addSubBinding(designSupport.elWrap(item), null);
99.18 String columnType = columnToType.get(item);
99.19 if ((columnType != null) && (!columnType.equals("java.lang.Object"))) { // NOI18N
99.20 String clazz = FormUtils.autobox(columnType);
99.21 @@ -1212,11 +1212,11 @@
99.22 if (selectedComponent != null) {
99.23 Object value = expressionCombo.getSelectedItem();
99.24 if ((value == null) || ("null".equals(value))) { // NOI18N
99.25 - type = BindingDesignSupport.determineType(selectedComponent);
99.26 + type = designSupport.determineType(selectedComponent);
99.27 } else {
99.28 String path = value.toString();
99.29 - if (BindingDesignSupport.isSimpleExpression(path)) {
99.30 - type = designSupport.determineType(selectedComponent, BindingDesignSupport.unwrapSimpleExpression(path));
99.31 + if (designSupport.isSimpleExpression(path)) {
99.32 + type = designSupport.determineType(selectedComponent, designSupport.unwrapSimpleExpression(path));
99.33 } else {
99.34 type = new TypeHelper(String.class);
99.35 }
99.36 @@ -1234,7 +1234,7 @@
99.37 if (!showDisplayExpression && (columnSelector == null)) return;
99.38 TypeHelper type = getSelectedType();
99.39 if ((type != null) && Collection.class.isAssignableFrom(FormUtils.typeToClass(type))) {
99.40 - TypeHelper elemType = BindingDesignSupport.typeOfElement(type);
99.41 + TypeHelper elemType = type.typeOfElement();
99.42 if ((elemType != null) && elemType.equals(lastElemType)) return;
99.43 lastElemType = elemType;
99.44 if (columnSelector != null) {
99.45 @@ -1287,7 +1287,7 @@
99.46 private TypeHelper type;
99.47
99.48 ExpressionNode(RADComponent comp) {
99.49 - this(BindingDesignSupport.determineType(comp));
99.50 + this(designSupport.determineType(comp));
99.51 this.comp = comp;
99.52 }
99.53
99.54 @@ -1374,7 +1374,7 @@
99.55
99.56 }
99.57
99.58 - private static class Converter implements ComboBoxWithTree.Converter {
99.59 + private class Converter implements ComboBoxWithTree.Converter {
99.60 private DefaultTreeModel treeModel;
99.61
99.62 Converter(DefaultTreeModel treeModel) {
99.63 @@ -1392,14 +1392,14 @@
99.64 sb.deleteCharAt(sb.length()-1);
99.65 }
99.66 String value = sb.toString().trim();
99.67 - return "null".equals(value) ? "null" : BindingDesignSupport.elWrap(sb.toString()); // NOI18N
99.68 + return "null".equals(value) ? "null" : designSupport.elWrap(sb.toString()); // NOI18N
99.69 }
99.70
99.71 @Override
99.72 public TreePath stringToPath(String value) {
99.73 DefaultMutableTreeNode node = (DefaultMutableTreeNode)treeModel.getRoot();
99.74 - if (BindingDesignSupport.isSimpleExpression(value)) {
99.75 - value = BindingDesignSupport.unwrapSimpleExpression(value);
99.76 + if (designSupport.isSimpleExpression(value)) {
99.77 + value = designSupport.unwrapSimpleExpression(value);
99.78 } else {
99.79 if ("null".equals(value)) { // NOI18N
99.80 return new TreePath(new Object[] {node, node.getChildAt(0)});
100.1 --- a/form/src/org/netbeans/modules/form/BindingDescriptor.java Wed Jul 27 10:33:10 2011 +0200
100.2 +++ b/form/src/org/netbeans/modules/form/BindingDescriptor.java Wed Jul 27 10:35:25 2011 +0200
100.3 @@ -157,7 +157,7 @@
100.4 * may depend on the context and should be determined using
100.5 * <code>BindingDesignSupport.determineType()</code> method.
100.6 */
100.7 - void markTypeAsRelative() {
100.8 + public void markTypeAsRelative() {
100.9 genericValueType = null;
100.10 }
100.11
101.1 --- a/form/src/org/netbeans/modules/form/BindingDesignSupport.java Wed Jul 27 10:33:10 2011 +0200
101.2 +++ b/form/src/org/netbeans/modules/form/BindingDesignSupport.java Wed Jul 27 10:35:25 2011 +0200
101.3 @@ -44,100 +44,64 @@
101.4
101.5 package org.netbeans.modules.form;
101.6
101.7 -import com.sun.source.tree.*;
101.8 -import com.sun.source.util.TreePath;
101.9 -import com.sun.source.util.Trees;
101.10 -import java.lang.reflect.*;
101.11 -import java.util.*;
101.12 -import java.beans.*;
101.13 -import java.io.IOException;
101.14 -import java.util.logging.Level;
101.15 -import java.util.logging.Logger;
101.16 -import javax.lang.model.element.Element;
101.17 -import javax.lang.model.element.ElementKind;
101.18 -import javax.lang.model.element.TypeElement;
101.19 -import javax.lang.model.element.TypeParameterElement;
101.20 -import javax.lang.model.type.TypeKind;
101.21 -import javax.swing.JList;
101.22 -import javax.swing.JTable;
101.23 -import javax.swing.JComboBox;
101.24 -import javax.swing.JFormattedTextField;
101.25 -import javax.swing.JSlider;
101.26 -import javax.swing.JSpinner;
101.27 -import javax.swing.text.JTextComponent;
101.28 -import org.jdesktop.beansbinding.*;
101.29 -import org.jdesktop.beansbinding.ext.BeanAdapterFactory;
101.30 -import org.jdesktop.swingbinding.*;
101.31 -import org.netbeans.api.java.classpath.ClassPath;
101.32 -import org.netbeans.api.java.source.CancellableTask;
101.33 -import org.netbeans.api.java.source.CompilationController;
101.34 -import org.netbeans.api.java.source.JavaSource;
101.35 -import org.netbeans.api.java.source.TreeUtilities;
101.36 -import org.netbeans.modules.form.FormUtils.TypeHelper;
101.37 -import org.netbeans.modules.form.project.ClassPathUtils;
101.38 -import org.openide.filesystems.FileObject;
101.39 -import org.openide.nodes.Node;
101.40 -import org.openide.util.Utilities;
101.41 +import java.util.List;
101.42 +import java.util.Map;
101.43 +import org.netbeans.modules.form.codestructure.CodeExpression;
101.44
101.45 /**
101.46 - * Design support for beans binding.
101.47 + * Design support for beans binding. Note that this is not an API for
101.48 + * a general binding support. It is more a hack that allows this module
101.49 + * not to depend on the beans binding library/support directly.
101.50 *
101.51 * @author Jan Stola, Tomas Pavek
101.52 */
101.53 -public class BindingDesignSupport {
101.54 - /** Form model. */
101.55 - private FormModel formModel;
101.56 -
101.57 - /** Realizations of bindings among replicated components. */
101.58 - private Map<MetaBinding, List<Binding>> bindingsMap = new HashMap<MetaBinding, List<Binding>>();
101.59 - /** Realizations of bindings among metacomponents. */
101.60 - private Map<MetaBinding, Binding> modelBindings = new HashMap<MetaBinding, Binding>();
101.61 - /** Binding to BindingGroup mapping. */
101.62 - private Map<Binding, BindingGroup> bindingToGroup = new HashMap<Binding, BindingGroup>();
101.63 - /** Binding group for reference instances in metacomponents. */
101.64 - private BindingGroup bindingGroup;
101.65 +public interface BindingDesignSupport {
101.66
101.67 /**
101.68 - * Create binding design support for the given form model.
101.69 - *
101.70 - * @param model form model to create the binding support for.
101.71 + * Returns binding group class.
101.72 + *
101.73 + * @return binding group class.
101.74 */
101.75 - public BindingDesignSupport(FormModel model) {
101.76 - formModel = model;
101.77 -
101.78 - bindingGroup = new BindingGroup();
101.79 - bindingGroup.bind();
101.80 -
101.81 - formModel.addFormModelListener(new ModelListener());
101.82 - }
101.83 + Class getBindingGroupClass();
101.84
101.85 /**
101.86 - * Changes the binding between two components (affects only replicated components).
101.87 + * Returns binding validator class.
101.88 *
101.89 - * @param oldBinding the old definition of the binding.
101.90 - * @param newBinding the new definition of the binding.
101.91 + * @return binding validator class.
101.92 */
101.93 - private void changeBinding(MetaBinding oldBinding, MetaBinding newBinding) {
101.94 - if (oldBinding != null) {
101.95 - removeBindings(oldBinding);
101.96 - }
101.97 - // non-model bindings are added from VisualReplicator
101.98 - }
101.99 + Class getValidatorClass();
101.100
101.101 /**
101.102 - * Changes the binding between two components (affects only reference instances in the model).
101.103 + * Returns binding converter class.
101.104 *
101.105 - * @param oldBinding the old definition of the binding.
101.106 - * @param newBinding the new definition of the binding.
101.107 + * @return binding converter class.
101.108 */
101.109 - public void changeBindingInModel(MetaBinding oldBinding, MetaBinding newBinding) {
101.110 - if (oldBinding != null) {
101.111 - removeBindingInModel(oldBinding);
101.112 - }
101.113 - if (newBinding != null) {
101.114 - addBindingInModel(newBinding);
101.115 - }
101.116 - }
101.117 + Class getConverterClass();
101.118 +
101.119 + /**
101.120 + * Returns beans binding replication support.
101.121 + *
101.122 + * @return beans binding replication support.
101.123 + */
101.124 + BindingVisualReplicator createReplicator();
101.125 +
101.126 + /**
101.127 + * Generates source code for the instantiation of the specified binding.
101.128 + *
101.129 + * @param prop property for which the source code should be generated.
101.130 + * @param buf buffer into which the source code should be generated.
101.131 + * @param context context of the code generator.
101.132 + * @return variable used for the generated binding.
101.133 + */
101.134 + String generateBinding(BindingProperty prop, StringBuilder buf, CodeGeneratorContext context);
101.135 +
101.136 + /**
101.137 + * Makes sure that the Beans Binding library is on the classpath of the project.
101.138 + *
101.139 + * @return {@code true} if the library was added on the classpath
101.140 + * returns {@code false} otherwise.
101.141 + */
101.142 + boolean updateProjectForBeansBinding();
101.143
101.144 /**
101.145 * Turns given string (usually dot-separated path) into EL expression
101.146 @@ -146,9 +110,17 @@
101.147 * @param path string to transform into EL expression.
101.148 * @return EL expression corresponding to the given path.
101.149 */
101.150 - public static String elWrap(String path) {
101.151 - return (path == null) ? null : "${" + path + "}"; // NOI18N
101.152 - }
101.153 + String elWrap(String path);
101.154 +
101.155 + /**
101.156 + * Removes <code>${</code> and <code>}</code> braces from a simple
101.157 + * EL expression. Non-simple expressions are left untouched.
101.158 + *
101.159 + * @param expression expression to unwrap.
101.160 + * @return unwrapped expression or the given string
101.161 + * (if it is not a simple EL expression).
101.162 + */
101.163 + String unwrapSimpleExpression(String expression);
101.164
101.165 /**
101.166 * Determines whether the given string is simple EL expression.
101.167 @@ -158,531 +130,25 @@
101.168 * <code>${</code> and ends with <code>}</code>, returns <code>false</code>
101.169 * otherwise.
101.170 */
101.171 - public static boolean isSimpleExpression(String expression) {
101.172 - return (expression.startsWith("${") && expression.endsWith("}")); // NOI18N
101.173 - }
101.174 + public boolean isSimpleExpression(String expression);
101.175
101.176 /**
101.177 - * Removes <code>${</code> and <code>}</code> braces from a simple
101.178 - * EL expression. Non-simple expressions are left untouched.
101.179 + * Produces a title from the given camel case string. For example,
101.180 + * returns 'First Name' for 'firstName'.
101.181 *
101.182 - * @param expression expression to unwrap.
101.183 - * @return unwrapped expression or the given string
101.184 - * (if it is not a simple EL expression).
101.185 + * @param title text to capitalize.
101.186 + * @return title from the given camel case string.
101.187 */
101.188 - public static String unwrapSimpleExpression(String expression) {
101.189 - if (isSimpleExpression(expression)) {
101.190 - expression = expression.substring(2, expression.length()-1);
101.191 - }
101.192 - return expression;
101.193 - }
101.194 -
101.195 - private static boolean hasRelativeType(Class clazz, String property) {
101.196 - // selectedElement(_...), selectedElements(_...)
101.197 - return (("elements".equals(property) || property.startsWith("selectedElement")) // NOI18N
101.198 - && (javax.swing.JTable.class.isAssignableFrom(clazz) || javax.swing.JList.class.isAssignableFrom(clazz)))
101.199 - || (("selectedItem".equals(property)) && javax.swing.JComboBox.class.isAssignableFrom(clazz)); // NOI18N
101.200 - }
101.201 -
101.202 - // Used to determine binding properties only
101.203 - List<BindingDescriptor>[] getBindingDescriptors(RADComponent component) {
101.204 - BeanDescriptor beanDescriptor = component.getBeanInfo().getBeanDescriptor();
101.205 - List<BindingDescriptor>[] descs = getBindingDescriptors(null, beanDescriptor, false);
101.206 - Class<?> beanClass = component.getBeanClass();
101.207 - if (JTextComponent.class.isAssignableFrom(beanClass)) {
101.208 - // get rid of text_... descriptors
101.209 - descs[0] = filterDescriptors(descs[0], "text_"); // NOI18N
101.210 - } else if (JTable.class.isAssignableFrom(beanClass)
101.211 - || JList.class.isAssignableFrom(beanClass)
101.212 - || JComboBox.class.isAssignableFrom(beanClass)) {
101.213 - // get rid of selectedElement(s)_... descriptors
101.214 - descs[0] = filterDescriptors(descs[0], "selectedElement_"); // NOI18N
101.215 - descs[0] = filterDescriptors(descs[0], "selectedElements_"); // NOI18N
101.216 - // add elements descriptor
101.217 - BindingDescriptor desc = new BindingDescriptor("elements", List.class); // NOI18N
101.218 - descs[0].add(0, desc);
101.219 - } else if (JSlider.class.isAssignableFrom(beanClass)) {
101.220 - // get rid of value_... descriptor
101.221 - descs[0] = filterDescriptors(descs[0], "value_"); // NOI18N
101.222 - }
101.223 - return descs;
101.224 - }
101.225 -
101.226 - private List<BindingDescriptor> filterDescriptors(List<BindingDescriptor> descs, String forbiddenPrefix) {
101.227 - List<BindingDescriptor> filtered = new LinkedList<BindingDescriptor>();
101.228 - for (BindingDescriptor bd : descs) {
101.229 - if (!bd.getPath().startsWith(forbiddenPrefix)) { // NOI18N
101.230 - filtered.add(bd);
101.231 - }
101.232 - }
101.233 - return filtered;
101.234 - }
101.235 -
101.236 - private List<PropertyDescriptor> getSpecialBindingDescriptors(Class clazz) {
101.237 - List<PropertyDescriptor> descs = BeanAdapterFactory.getAdapterPropertyDescriptors(clazz);
101.238 - try {
101.239 - if (JComboBox.class.isAssignableFrom(clazz)) {
101.240 - PropertyDescriptor desc = new PropertyDescriptor("selectedItem", JComboBox.class); // NOI18N
101.241 - descs.add(desc);
101.242 - } else if (JSpinner.class.isAssignableFrom(clazz)) {
101.243 - PropertyDescriptor desc = new PropertyDescriptor("value", JSpinner.class); // NOI18N
101.244 - descs.add(desc);
101.245 - } else if (JFormattedTextField.class.isAssignableFrom(clazz)) {
101.246 - for (PropertyDescriptor pd : descs) {
101.247 - if ("text".equals(pd.getName())) { // NOI18N
101.248 - descs.remove(pd);
101.249 - break;
101.250 - }
101.251 - }
101.252 - PropertyDescriptor desc = new PropertyDescriptor("value", JFormattedTextField.class); // NOI18N
101.253 - descs.add(desc);
101.254 - }
101.255 - } catch (Exception ex) {
101.256 - Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
101.257 - }
101.258 - return descs;
101.259 - }
101.260 -
101.261 - private List<BindingDescriptor>[] getBindingDescriptors(TypeHelper type, BeanDescriptor beanDescriptor, boolean includeReadOnly) {
101.262 - Class<?> beanClass = beanDescriptor.getBeanClass();
101.263 - List<BindingDescriptor> bindingList = new LinkedList<BindingDescriptor>();
101.264 - List<BindingDescriptor> prefList = new LinkedList<BindingDescriptor>();
101.265 - List<BindingDescriptor> observableList = new LinkedList<BindingDescriptor>();
101.266 - List<BindingDescriptor> nonObservableList = new LinkedList<BindingDescriptor>();
101.267 - List<BindingDescriptor> list;
101.268 - Object[] propsCats = FormUtils.getPropertiesCategoryClsf(beanClass, beanDescriptor);
101.269 - PropertyDescriptor[] pds;
101.270 - try {
101.271 - pds = FormUtils.getBeanInfo(beanClass).getPropertyDescriptors();
101.272 - } catch (Exception ex) {
101.273 - Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
101.274 - pds = new PropertyDescriptor[0];
101.275 - }
101.276 - List<PropertyDescriptor> specialPds = getSpecialBindingDescriptors(beanClass);
101.277 - Map<String,PropertyDescriptor> pathToDesc = new HashMap<String,PropertyDescriptor>();
101.278 - if (Utilities.isMac()) {
101.279 - try {
101.280 - for (PropertyDescriptor pd : FormUtils.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO).getPropertyDescriptors()) {
101.281 - pathToDesc.put(pd.getName(), pd);
101.282 - }
101.283 - } catch (IntrospectionException iex) {
101.284 - Logger.getLogger(getClass().getName()).log(Level.INFO, iex.getMessage(), iex);
101.285 - }
101.286 - }
101.287 - for (PropertyDescriptor pd : pds) {
101.288 - pathToDesc.put(pd.getName(), pd);
101.289 - }
101.290 - for (PropertyDescriptor pd : specialPds) {
101.291 - if (pathToDesc.get(pd.getName()) != null) {
101.292 - pathToDesc.remove(pd.getName());
101.293 - }
101.294 - }
101.295 - List<PropertyDescriptor> allPds = new LinkedList<PropertyDescriptor>(specialPds);
101.296 - allPds.addAll(pathToDesc.values());
101.297 - int count = 0;
101.298 - for (PropertyDescriptor pd : allPds) {
101.299 - if (count++<specialPds.size()) {
101.300 - list = bindingList;
101.301 - } else {
101.302 - if (!includeReadOnly && (pd.getWriteMethod() == null)) {
101.303 - continue;
101.304 - }
101.305 - Object propCat = FormUtils.getPropertyCategory(pd, propsCats);
101.306 - if (propCat == FormUtils.PROP_HIDDEN) {
101.307 - // hidden property => hide also the binding property
101.308 - continue;
101.309 - } else {
101.310 - if (pd.isBound()) {
101.311 - // observable property
101.312 - if (propCat == FormUtils.PROP_PREFERRED) {
101.313 - list = prefList;
101.314 - } else {
101.315 - list = observableList;
101.316 - }
101.317 - } else {
101.318 - // non-observable property
101.319 - list = nonObservableList;
101.320 - }
101.321 - }
101.322 - }
101.323 -
101.324 - Method method = pd.getReadMethod();
101.325 - if ((method != null) && ("getClass".equals(method.getName()))) continue; // NOI18N
101.326 - Type retType = (method == null) ? pd.getPropertyType() : method.getGenericReturnType();
101.327 - if (retType == null) continue;
101.328 - BindingDescriptor bd;
101.329 - if (type == null) {
101.330 - bd = new BindingDescriptor(pd.getName(), retType);
101.331 - } else {
101.332 - TypeHelper t = new TypeHelper(retType, type.getActualTypeArgs()).normalize();
101.333 - bd = new BindingDescriptor(pd.getName(), t);
101.334 - }
101.335 - bd.setDisplayName(pd.getDisplayName());
101.336 - bd.setShortDescription(pd.getShortDescription());
101.337 -
101.338 - if (hasRelativeType(beanClass, bd.getPath())) {
101.339 - bd.markTypeAsRelative();
101.340 - }
101.341 -
101.342 - list.add(bd);
101.343 - }
101.344 -
101.345 - if (bindingList.isEmpty()) {
101.346 - bindingList = prefList;
101.347 - } else {
101.348 - observableList.addAll(prefList);
101.349 - }
101.350 - Comparator<BindingDescriptor> bdComparator = new Comparator<BindingDescriptor>() {
101.351 - @Override
101.352 - public int compare(BindingDescriptor o1, BindingDescriptor o2) {
101.353 - String path1 = o1.getPath();
101.354 - String path2 = o2.getPath();
101.355 - return path1.compareToIgnoreCase(path2);
101.356 - }
101.357 - };
101.358 - Collections.sort(bindingList, bdComparator);
101.359 - Collections.sort(observableList, bdComparator);
101.360 - Collections.sort(nonObservableList, bdComparator);
101.361 -
101.362 - return new List[] {bindingList, observableList, nonObservableList};
101.363 - }
101.364 -
101.365 - public List<BindingDescriptor> getAllBindingDescriptors(TypeHelper type) {
101.366 - List<BindingDescriptor>[] descs = getBindingDescriptors(type);
101.367 - List<BindingDescriptor> list = new LinkedList<BindingDescriptor>();
101.368 - for (int i=0; i<descs.length; i++ ){
101.369 - list.addAll(descs[i]);
101.370 - }
101.371 - return list;
101.372 - }
101.373 + public String capitalize(String title);
101.374
101.375 /**
101.376 - * Returns possible bindings for the given type.
101.377 - *
101.378 - * @param type type whose possible bindings should be returned.
101.379 - * @return list of <code>BindingDescriptor</code>s describing possible bindings.
101.380 - */
101.381 - @SuppressWarnings("unchecked") // generic array creation NOI18N
101.382 - public List<BindingDescriptor>[] getBindingDescriptors(TypeHelper type) {
101.383 - List<BindingDescriptor> typesFromSource = Collections.emptyList();
101.384 - Class binarySuperClass = null;
101.385 - if (type.getType() == null) {
101.386 - FileObject fileInProject = FormEditor.getFormDataObject(formModel).getPrimaryFile();
101.387 - ClassPath cp = ClassPath.getClassPath(fileInProject, ClassPath.SOURCE);
101.388 - final List<BindingDescriptor> types = new LinkedList<BindingDescriptor>();
101.389 - final String[] superClass = new String[1];
101.390 - superClass[0] = type.getName();
101.391 - do {
101.392 - String typeName = superClass[0];
101.393 - final String resourceName = typeName.replace('.', '/') + ".java"; // NOI18N
101.394 - int lastDot = typeName.lastIndexOf('.');
101.395 - lastDot = (lastDot == -1) ? 0 : lastDot;
101.396 - final String simpleTypeName = typeName.substring(lastDot+1);
101.397 - FileObject fob = cp.findResource(resourceName);
101.398 - if (fob == null) {
101.399 - try {
101.400 - binarySuperClass = ClassPathUtils.loadClass(typeName, fileInProject);
101.401 - } catch (ClassNotFoundException cnfex) {}
101.402 - break;
101.403 - }
101.404 - JavaSource source = JavaSource.forFileObject(fob);
101.405 - try {
101.406 - source.runUserActionTask(new CancellableTask<CompilationController>() {
101.407 - @Override
101.408 - public void run(CompilationController cc) throws Exception {
101.409 - cc.toPhase(JavaSource.Phase.RESOLVED);
101.410 - CompilationUnitTree cu = cc.getCompilationUnit();
101.411 - ClassTree clazz = null;
101.412 - for (Tree typeDecl : cu.getTypeDecls()) {
101.413 - if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) {
101.414 - ClassTree candidate = (ClassTree)typeDecl;
101.415 - if (candidate.getSimpleName().toString().equals(simpleTypeName)) {
101.416 - clazz = candidate;
101.417 - break;
101.418 - }
101.419 - }
101.420 - }
101.421 - if (clazz == null) { // issue 118690
101.422 - // should not happen
101.423 - Logger.getLogger(getClass().getName()).log(Level.INFO, "ClassTree not found in {0}", resourceName); // NOI18N
101.424 - superClass[0] = Object.class.getName();
101.425 - return;
101.426 - }
101.427 - for (Tree clMember : clazz.getMembers()) {
101.428 - if (clMember.getKind() == Tree.Kind.METHOD) {
101.429 - MethodTree method = (MethodTree)clMember;
101.430 - if (!method.getParameters().isEmpty()) continue;
101.431 - Set<javax.lang.model.element.Modifier> modifiers = method.getModifiers().getFlags();
101.432 - if (modifiers.contains(javax.lang.model.element.Modifier.STATIC)
101.433 - || !modifiers.contains(javax.lang.model.element.Modifier.PUBLIC)) {
101.434 - continue;
101.435 - }
101.436 - String methodName = method.getName().toString();
101.437 - Tree returnType = method.getReturnType();
101.438 -
101.439 - String propName;
101.440 - if (methodName.startsWith("get")) { // NOI18N
101.441 - propName = methodName.substring(3);
101.442 - } else if (methodName.startsWith("is")) { // NOI18N
101.443 - if ((returnType.getKind() == Tree.Kind.PRIMITIVE_TYPE)
101.444 - && (((PrimitiveTypeTree)returnType).getPrimitiveTypeKind() == TypeKind.BOOLEAN)) {
101.445 - propName = methodName.substring(2);
101.446 - } else {
101.447 - continue;
101.448 - }
101.449 - } else {
101.450 - continue;
101.451 - }
101.452 - if (propName.length() == 0) continue;
101.453 - if ((propName.length() == 1) || (Character.isLowerCase(propName.charAt(1)))) {
101.454 - propName = Character.toLowerCase(propName.charAt(0)) + propName.substring(1);
101.455 - }
101.456 -
101.457 - TypeHelper type;
101.458 - if (returnType.getKind() == Tree.Kind.PRIMITIVE_TYPE) {
101.459 - PrimitiveTypeTree ptree = (PrimitiveTypeTree)returnType;
101.460 - if (ptree.getPrimitiveTypeKind() == TypeKind.VOID) {
101.461 - continue; // void return type
101.462 - }
101.463 - type = new TypeHelper(ptree.toString());
101.464 - } else {
101.465 - type = treeToType(cc, returnType, formModel);
101.466 - }
101.467 - types.add(0, new BindingDescriptor(propName, type));
101.468 - }
101.469 - }
101.470 - Tree superTree = clazz.getExtendsClause();
101.471 - TypeHelper type = treeToType(cc, superTree, formModel);
101.472 - String typeName = type.getName();
101.473 - superClass[0] = (typeName == null) ? FormUtils.typeToClass(type).getName() : typeName;
101.474 - }
101.475 -
101.476 - @Override
101.477 - public void cancel() {
101.478 - }
101.479 -
101.480 - }, true);
101.481 - } catch (IOException ioex) {
101.482 - Logger.getLogger(getClass().getName()).log(Level.INFO, ioex.getMessage(), ioex);
101.483 - }
101.484 - } while (!Object.class.getName().equals(superClass[0]));
101.485 - typesFromSource = types;
101.486 - }
101.487 - List<BindingDescriptor>[] list = new List[] {Collections.emptyList(), typesFromSource, Collections.emptyList()};
101.488 - Class clazz = (type.getType() == null) ? binarySuperClass : FormUtils.typeToClass(type);
101.489 - if ((clazz != null) && !clazz.getName().startsWith("java.lang.") // NOI18N
101.490 - && !Collection.class.isAssignableFrom(clazz)
101.491 - && !java.util.Date.class.isAssignableFrom(clazz)
101.492 - && !clazz.isArray()) {
101.493 - try {
101.494 - BeanInfo beanInfo = FormUtils.getBeanInfo(clazz);
101.495 - List<BindingDescriptor>[] typesFromBinary = getBindingDescriptors(type, beanInfo.getBeanDescriptor(), true);
101.496 - Map<String,BindingDescriptor>[] maps = new Map[3];
101.497 - for (int i=0; i<3; i++) {
101.498 - maps[i] = listToMap(typesFromBinary[i]);
101.499 - }
101.500 - for (BindingDescriptor descriptor : typesFromSource) {
101.501 - String path = descriptor.getPath();
101.502 - int i;
101.503 - for (i=0; i<3; i++) {
101.504 - if (maps[i].containsKey(path)) break;
101.505 - }
101.506 - if (i == 3) {
101.507 - i = 1; // put into observablle properties by default
101.508 - }
101.509 - maps[i].put(path, descriptor);
101.510 - }
101.511 - for (int i=0; i<3; i++) {
101.512 - list[i] = new LinkedList<BindingDescriptor>(maps[i].values());
101.513 - }
101.514 - } catch (Exception ex) {
101.515 - Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
101.516 - }
101.517 - }
101.518 - return list;
101.519 - }
101.520 -
101.521 - private static TypeHelper treeToType(CompilationController cc, Tree tree, FormModel model) {
101.522 - String typeName = Object.class.getName();
101.523 - Map<String,TypeHelper> map = null;
101.524 - if (tree != null) {
101.525 - CompilationUnitTree cu = cc.getCompilationUnit();
101.526 - Trees trees = cc.getTrees();
101.527 - if (tree.getKind() == Tree.Kind.EXTENDS_WILDCARD) {
101.528 - tree = ((WildcardTree)tree).getBound();
101.529 - }
101.530 - TreePath path = trees.getPath(cu, tree);
101.531 - Element el = trees.getElement(path);
101.532 - if ((el != null) && ((el.getKind() == ElementKind.CLASS) || (el.getKind() == ElementKind.INTERFACE))) {
101.533 - TypeElement tel = (TypeElement) el;
101.534 - typeName = tel.getQualifiedName().toString();
101.535 - if (tree.getKind() == Tree.Kind.PARAMETERIZED_TYPE) {
101.536 - List<? extends Tree> params = ((ParameterizedTypeTree)tree).getTypeArguments();
101.537 - List<? extends TypeParameterElement> elems = tel.getTypeParameters();
101.538 - map = new HashMap<String,TypeHelper>();
101.539 - for (int i=0; i<params.size() && i<elems.size(); i++) {
101.540 - Tree param = params.get(0);
101.541 - TypeHelper paramType = treeToType(cc, param, model);
101.542 - TypeParameterElement elem = elems.get(0);
101.543 - map.put(elem.toString(), paramType);
101.544 - }
101.545 - }
101.546 - }
101.547 - }
101.548 - TypeHelper type = new TypeHelper(typeName, map);
101.549 - if (typeName.indexOf('.') != -1) {
101.550 - try {
101.551 - Class clazz = FormUtils.loadClass(typeName, model);
101.552 - type = new TypeHelper(clazz, map);
101.553 - } catch (ClassNotFoundException cnfex) {
101.554 - // not compiled - use just the name
101.555 - }
101.556 - }
101.557 - return type;
101.558 - }
101.559 -
101.560 - private static Map<String,BindingDescriptor> listToMap(List<BindingDescriptor> list) {
101.561 - Map<String,BindingDescriptor> map = new TreeMap<String,BindingDescriptor>();
101.562 - for (BindingDescriptor descriptor : list) {
101.563 - String path = descriptor.getPath();
101.564 - map.put(path, descriptor);
101.565 - }
101.566 - return map;
101.567 - }
101.568 -
101.569 - /**
101.570 * Determines type of RAD component.
101.571 *
101.572 * @param comp RAD component whose type should be returned.
101.573 * @return <code>TypeHelper</code> that corresponds to the type of the given component.
101.574 */
101.575 - static TypeHelper determineType(RADComponent comp) {
101.576 - TypeHelper type;
101.577 - if (comp.getFormModel().getTopRADComponent() == comp) {
101.578 - FileObject fob = FormEditor.getFormDataObject(comp.getFormModel()).getPrimaryFile();
101.579 - ClassPath cp = ClassPath.getClassPath(fob, ClassPath.SOURCE);
101.580 - String className = cp.getResourceName(fob, '.', false);
101.581 - type = new TypeHelper(className);
101.582 - } else {
101.583 - Type t = null;
101.584 - Map<String,TypeHelper> newMap = null;
101.585 - Class clazz = comp.getBeanClass();
101.586 - t = clazz;
101.587 - if (clazz.getTypeParameters().length == 1) {
101.588 - try {
101.589 - TypeHelper elemType = determineTypeParameter(comp);
101.590 - if (elemType != null) {
101.591 - newMap = new HashMap<String,TypeHelper>();
101.592 - newMap.put(clazz.getTypeParameters()[0].getName(), elemType);
101.593 - }
101.594 - } catch (Exception ex) {
101.595 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, ex.getMessage(), ex);
101.596 - }
101.597 - }
101.598 - type = new TypeHelper(t, newMap);
101.599 - }
101.600 - return type;
101.601 - }
101.602 -
101.603 - static TypeHelper determineTypeParameter(final RADComponent comp) {
101.604 - FileObject fob = FormEditor.getFormDataObject(comp.getFormModel()).getPrimaryFile();
101.605 - JavaSource source = JavaSource.forFileObject(fob);
101.606 - final String varName = comp.getName();
101.607 - final TypeHelper[] result = new TypeHelper[1];
101.608 - try {
101.609 - source.runUserActionTask(new CancellableTask<CompilationController>() {
101.610 - @Override
101.611 - public void run(CompilationController cc) throws Exception {
101.612 - cc.toPhase(JavaSource.Phase.RESOLVED);
101.613 - CompilationUnitTree cu = cc.getCompilationUnit();
101.614 - ClassTree clazz = null;
101.615 - for (Tree typeDecl : cu.getTypeDecls()) {
101.616 - if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) {
101.617 - clazz = (ClassTree) typeDecl;
101.618 - break;
101.619 - }
101.620 - }
101.621 - Node.Property prop = comp.getSyntheticProperty("useLocalVariable"); // NOI18N
101.622 - Object value = prop.getValue();
101.623 - VariableTree variable = null;
101.624 - if (Boolean.TRUE.equals(value)) {
101.625 - // local variable in initComponents()
101.626 - for (Tree clMember : clazz.getMembers()) {
101.627 - if (clMember.getKind() == Tree.Kind.METHOD) {
101.628 - MethodTree method = (MethodTree)clMember;
101.629 - String methodName = method.getName().toString();
101.630 - if ("initComponents".equals(methodName)) { // NOI18N
101.631 - for (StatementTree statement : method.getBody().getStatements()) {
101.632 - if (statement.getKind() == Tree.Kind.VARIABLE) {
101.633 - VariableTree var = (VariableTree)statement;
101.634 - if (varName.equals(var.getName().toString())) {
101.635 - variable = var;
101.636 - }
101.637 - }
101.638 - }
101.639 - }
101.640 - }
101.641 - }
101.642 - } else {
101.643 - // fields in class
101.644 - for (Tree clMember : clazz.getMembers()) {
101.645 - if (clMember.getKind() == Tree.Kind.VARIABLE) {
101.646 - VariableTree var = (VariableTree)clMember;
101.647 - if (varName.equals(var.getName().toString())) {
101.648 - variable = var;
101.649 - }
101.650 - }
101.651 - }
101.652 - }
101.653 - if (variable != null) {
101.654 - Tree type = variable.getType();
101.655 - if (type.getKind() == Tree.Kind.PARAMETERIZED_TYPE) {
101.656 - ParameterizedTypeTree params = (ParameterizedTypeTree)type;
101.657 - List<? extends Tree> args = params.getTypeArguments();
101.658 - if (args.size() == 1) {
101.659 - Tree tree = args.get(0);
101.660 - result[0] = treeToType(cc, tree, comp.getFormModel());
101.661 - }
101.662 - }
101.663 - }
101.664 - }
101.665 -
101.666 - @Override
101.667 - public void cancel() {
101.668 - }
101.669 - }, true);
101.670 - } catch (IOException ioex) {
101.671 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, ioex.getMessage(), ioex);
101.672 - }
101.673 - if (result[0] == null) {
101.674 - // fallback - covers the situation where the component
101.675 - // has been added but the code hasn't been generated yet
101.676 - Class clazz = comp.getBeanClass();
101.677 - if (clazz.getTypeParameters().length == 1) {
101.678 - try {
101.679 - Object value = comp.getSyntheticProperty("typeParameters").getValue(); // NOI18N
101.680 - if (value instanceof String) {
101.681 - String type = (String)value;
101.682 - if (type.startsWith("<")) { // NOI18N
101.683 - type = type.substring(1, type.length()-1);
101.684 - Map<String,TypeHelper> newMap = new HashMap<String,TypeHelper>();
101.685 - try {
101.686 - Class elemType = ClassPathUtils.loadClass(type, FormEditor.getFormDataObject(comp.getFormModel()).getFormFile());
101.687 - newMap.put(clazz.getTypeParameters()[0].getName(), new TypeHelper(elemType));
101.688 - } catch (ClassNotFoundException cnfex) {
101.689 - newMap.put(clazz.getTypeParameters()[0].getName(), new TypeHelper(type));
101.690 - }
101.691 - result[0] = new TypeHelper(type, newMap);
101.692 - }
101.693 - }
101.694 - } catch (Exception ex) {
101.695 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, ex.getMessage(), ex);
101.696 - }
101.697 - }
101.698 - }
101.699 - return result[0];
101.700 - }
101.701 -
101.702 + FormUtils.TypeHelper determineType(RADComponent comp);
101.703 +
101.704 /**
101.705 * Determines type of the binding described by the given component and source path.
101.706 *
101.707 @@ -690,838 +156,53 @@
101.708 * @param sourcePath binding path from the source.
101.709 * @return type of the binding.
101.710 */
101.711 - public TypeHelper determineType(RADComponent comp, String sourcePath) {
101.712 - String[] path = parsePath(sourcePath);
101.713 - TypeHelper type = determineType(comp);
101.714 - for (int i=0; i<path.length; i++) {
101.715 - String pathItem = path[i];
101.716 - List<BindingDescriptor> descriptors = getAllBindingDescriptors(type);
101.717 - BindingDescriptor descriptor = findDescriptor(descriptors, pathItem);
101.718 - if (descriptor == null) return new TypeHelper();
101.719 - type = descriptor.getGenericValueType();
101.720 - if (type == null) {
101.721 - if (javax.swing.JTable.class.isAssignableFrom(comp.getBeanClass())
101.722 - || javax.swing.JList.class.isAssignableFrom(comp.getBeanClass())
101.723 - || javax.swing.JComboBox.class.isAssignableFrom(comp.getBeanClass())) {
101.724 - MetaBinding binding = comp.getBindingProperty("elements").getValue(); // NOI18N
101.725 - if (binding != null) {
101.726 - RADComponent subComp = binding.getSource();
101.727 - String subSourcePath = binding.getSourcePath();
101.728 - subSourcePath = (subSourcePath == null) ? null : BindingDesignSupport.unwrapSimpleExpression(subSourcePath);
101.729 - // PENDING beware of stack overflow
101.730 - TypeHelper t = determineType(subComp, subSourcePath);
101.731 - if (javax.swing.JComboBox.class.isAssignableFrom(comp.getBeanClass())) {
101.732 - if ("selectedItem".equals(pathItem)) { // NOI18N
101.733 - type = typeOfElement(t);
101.734 - }
101.735 - } else {
101.736 - if ("selectedElement".equals(pathItem) || pathItem.startsWith("selectedElement_")) { // NOI18N
101.737 - type = typeOfElement(t);
101.738 - } else if (pathItem.startsWith("selectedElements") || "elements".equals(pathItem)) { // NOI18N
101.739 - type = t;
101.740 - }
101.741 - }
101.742 - } else {
101.743 - type = new TypeHelper();
101.744 - }
101.745 - }
101.746 - }
101.747 - }
101.748 - return type;
101.749 + FormUtils.TypeHelper determineType(RADComponent comp, String sourcePath);
101.750 +
101.751 + List<BindingDescriptor>[] getBindingDescriptors(RADComponent component);
101.752 +
101.753 + public List<BindingDescriptor>[] getBindingDescriptors(FormUtils.TypeHelper type);
101.754 +
101.755 + public List<BindingDescriptor> getAllBindingDescriptors(FormUtils.TypeHelper type);
101.756 +
101.757 + /**
101.758 + * Changes the binding between two components (affects only reference instances in the model).
101.759 + *
101.760 + * @param oldBinding the old definition of the binding.
101.761 + * @param newBinding the new definition of the binding.
101.762 + */
101.763 + void changeBindingInModel(MetaBinding oldBinding, MetaBinding newBinding);
101.764 +
101.765 + /**
101.766 + * Beans binding replication support.
101.767 + */
101.768 + interface BindingVisualReplicator {
101.769 + /**
101.770 + * Creates binding according to given MetaBinding between given source and
101.771 + * target objects. The binding is registered, so it is automatically unbound
101.772 + * and removed when the MetaBinding is removed (or the source/target component).
101.773 + *
101.774 + * @param bindingDef description of the binding
101.775 + * @param source binding source
101.776 + * @param target binding target
101.777 + * @param inModel determines whether we are creating binding in the model
101.778 + */
101.779 + void addBinding(MetaBinding bindingDef, Object source, Object target, boolean inModel);
101.780 +
101.781 + void establishUpdatedBindings(RADComponent metacomp, boolean recursive, Map map, boolean inModel);
101.782 +
101.783 + void establishOneOffBindings(RADComponent metacomp, boolean recursive, Map map);
101.784 }
101.785
101.786 /**
101.787 - * Finds descriptor that corresponds to the given binding path.
101.788 - *
101.789 - * @param descriptors list of descriptors that should be searched.
101.790 - * @param path binding path to find descriptor for.
101.791 - * @return descriptor that corresponds to the given binding path.
101.792 + * Code generation context (set of callbacks usefull during
101.793 + * code generation of beans binding code).
101.794 */
101.795 - private static BindingDescriptor findDescriptor(List<BindingDescriptor> descriptors, String path) {
101.796 - for (BindingDescriptor descriptor : descriptors) {
101.797 - if (descriptor.getPath().equals(path)) return descriptor;
101.798 - }
101.799 - return null;
101.800 + interface CodeGeneratorContext {
101.801 +
101.802 + String getBindingDescriptionVariable(Class descriptionType, StringBuilder buf, boolean create);
101.803 +
101.804 + String getExpressionJavaString(CodeExpression exp, String thisStr);
101.805 }
101.806
101.807 - /**
101.808 - * Parses binding path into segments.
101.809 - *
101.810 - * @param path path to parse.
101.811 - * @return segments of the binding path. The returned value cannot be <code>null</code>.
101.812 - */
101.813 - private static String[] parsePath(String path) {
101.814 - if (path == null) return new String[0];
101.815 - List<String> pathItems = new LinkedList<String>();
101.816 - int index;
101.817 - while ((index = path.indexOf('.')) != -1) {
101.818 - pathItems.add(path.substring(0,index));
101.819 - path = path.substring(index+1);
101.820 - }
101.821 - pathItems.add(path);
101.822 - return pathItems.toArray(new String[pathItems.size()]);
101.823 - }
101.824
101.825 - /**
101.826 - * Returns type of element of the given type - expects type that implements
101.827 - * <code>Collection</code> interface.
101.828 - *
101.829 - * @param type type that implements <code>Collection</code> interface.
101.830 - * @return type of element of the given type.
101.831 - */
101.832 - static TypeHelper typeOfElement(TypeHelper type) {
101.833 - Type t = type.getType();
101.834 - TypeHelper elemType = new TypeHelper();
101.835 - if (t instanceof ParameterizedType) {
101.836 - ParameterizedType pt = (ParameterizedType)t;
101.837 - Type[] args = pt.getActualTypeArguments();
101.838 - // PENDING generalize and improve - track the type variables to the nearest
101.839 - // known collection superclass or check parameter type of add(E o) method
101.840 - if (args.length == 1) { // The only argument should be type of the collection element
101.841 - Type tt = args[0];
101.842 - elemType = new TypeHelper(tt, type.getActualTypeArgs());
101.843 - }
101.844 - } else if (t instanceof Class) {
101.845 - Class classa = (Class)t;
101.846 - TypeVariable[] tvar = classa.getTypeParameters();
101.847 - // PENDING dtto
101.848 - Map<String,TypeHelper> actualTypeArgs = type.getActualTypeArgs();
101.849 - if ((actualTypeArgs != null) && (tvar.length == 1)) {
101.850 - TypeHelper tt = actualTypeArgs.get(tvar[0].getName());
101.851 - if (tt != null) {
101.852 - if (tt.getType() == null) {
101.853 - elemType = tt;
101.854 - } else {
101.855 - Type typ = FormUtils.typeToClass(tt);
101.856 - elemType = new TypeHelper(typ, actualTypeArgs);
101.857 - }
101.858 - }
101.859 - }
101.860 - }
101.861 - return elemType;
101.862 - }
101.863 -
101.864 - public void establishUpdatedBindings(RADComponent metacomp,
101.865 - boolean recursive,
101.866 - Map map,
101.867 - BindingGroup group, boolean inModel)
101.868 - {
101.869 - for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
101.870 - RADComponent sourceComp = bindingDef.getSource();
101.871 - RADComponent targetComp = bindingDef.getTarget();
101.872 - if (sourceComp.isInModel() && targetComp.isInModel()) {
101.873 - if (inModel) {
101.874 - addBindingInModel(bindingDef);
101.875 - } else {
101.876 - Object source = null;
101.877 - if (map != null)
101.878 - source = map.get(sourceComp.getId());
101.879 - if (source == null)
101.880 - source = sourceComp.getBeanInstance(); // also used if clone not available
101.881 - Object target = map != null ?
101.882 - map.get(targetComp.getId()) : targetComp.getBeanInstance();
101.883 - if (source != null && target != null)
101.884 - addBinding(bindingDef, source, target, group, false);
101.885 - }
101.886 - }
101.887 - }
101.888 - }
101.889 -
101.890 - public static void establishOneOffBindings(RADComponent metacomp,
101.891 - boolean recursive,
101.892 - Map map,
101.893 - BindingGroup group)
101.894 - {
101.895 - for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
101.896 - RADComponent sourceComp = bindingDef.getSource();
101.897 - RADComponent targetComp = bindingDef.getTarget();
101.898 - Object source = null;
101.899 - if (map != null)
101.900 - source = map.get(sourceComp.getId());
101.901 - if (source == null)
101.902 - source = sourceComp.getBeanInstance(); // also used if clone not available
101.903 - Object target = map != null ?
101.904 - map.get(targetComp.getId()) : targetComp.getBeanInstance();
101.905 - if (source != null && target != null)
101.906 - createBinding(bindingDef, source, target, group, null);
101.907 - }
101.908 - }
101.909 -
101.910 - private void releaseBindings(RADComponent metacomp, boolean recursive) {
101.911 - for (MetaBinding bindingDef : collectBindingDefs(metacomp, recursive)) {
101.912 - removeBindings(bindingDef); // unbinds and removes all bindings
101.913 - // created according to this definition
101.914 - }
101.915 - }
101.916 -
101.917 - private static Collection<MetaBinding> collectBindingDefs(RADComponent metacomp, boolean recursive) {
101.918 - Collection<MetaBinding> col = collectBindingDefs(metacomp, recursive, null);
101.919 - if (col == null)
101.920 - col = Collections.emptyList();
101.921 - return col;
101.922 - }
101.923 -
101.924 - private static Collection<MetaBinding> collectBindingDefs(
101.925 - RADComponent metacomp, boolean recursive, Collection<MetaBinding> col)
101.926 - {
101.927 - for (BindingProperty bProp : metacomp.getKnownBindingProperties()) {
101.928 - MetaBinding bindingDef = bProp.getValue();
101.929 - if (bindingDef != null) {
101.930 - if (col == null)
101.931 - col = new LinkedList<MetaBinding>();
101.932 - col.add(bindingDef);
101.933 - }
101.934 - }
101.935 -
101.936 - if (recursive && metacomp instanceof ComponentContainer) {
101.937 - for (RADComponent subcomp : ((ComponentContainer)metacomp).getSubBeans()) {
101.938 - col = collectBindingDefs(subcomp, recursive, col);
101.939 - }
101.940 - }
101.941 -
101.942 - return col;
101.943 - }
101.944 -
101.945 - private void addBindingInModel(MetaBinding bindingDef) {
101.946 - addBinding(bindingDef,
101.947 - bindingDef.getSource().getBeanInstance(),
101.948 - bindingDef.getTarget().getBeanInstance(),
101.949 - bindingGroup, true);
101.950 - }
101.951 -
101.952 - /**
101.953 - * Creates binding according to given MetaBinding between given source and
101.954 - * target objects. The binding is registered, so it is automatically unbound
101.955 - * and removed when the MetaBinding is removed (or the source/target component).
101.956 - *
101.957 - * @param bindingDef description of the binding
101.958 - * @param source binding source
101.959 - * @param target binding target
101.960 - * @param group binding group where the binding should be added
101.961 - * @param inModel determines whether we are creating binding in the model
101.962 - */
101.963 - public void addBinding(MetaBinding bindingDef,
101.964 - Object source, Object target,
101.965 - BindingGroup group, boolean inModel)
101.966 - {
101.967 - if (inModel) {
101.968 - if (modelBindings.get(bindingDef) == null) {
101.969 - modelBindings.put(bindingDef, createBinding(bindingDef, source, target, group, bindingToGroup));
101.970 - }
101.971 - } else {
101.972 - List<Binding> establishedBindings = bindingsMap.get(bindingDef);
101.973 - if (establishedBindings != null) {
101.974 - for (Binding binding : establishedBindings) {
101.975 - if (binding.getSourceObject() == source
101.976 - && binding.getTargetObject() == target)
101.977 - return; // this binding already exists
101.978 - }
101.979 - }
101.980 - else {
101.981 - establishedBindings = new LinkedList<Binding>();
101.982 - bindingsMap.put(bindingDef, establishedBindings);
101.983 - }
101.984 - establishedBindings.add(createBinding(bindingDef, source, target, group, bindingToGroup));
101.985 - }
101.986 - }
101.987 -
101.988 - private static String actualTargetPath(MetaBinding bindingDef) {
101.989 - String targetPath = bindingDef.getTargetPath();
101.990 - if ("text".equals(targetPath)) { // NOI18N
101.991 - Class<?> targetClass = bindingDef.getTarget().getBeanClass();
101.992 - if (JTextComponent.class.isAssignableFrom(targetClass)) {
101.993 - String strategy = bindingDef.getParameter(MetaBinding.TEXT_CHANGE_STRATEGY);
101.994 - if (MetaBinding.TEXT_CHANGE_ON_ACTION_OR_FOCUS_LOST.equals(strategy)) {
101.995 - targetPath += "_ON_ACTION_OR_FOCUS_LOST"; // NOI18N
101.996 - } else if (MetaBinding.TEXT_CHANGE_ON_FOCUS_LOST.equals(strategy)) {
101.997 - targetPath += "_ON_FOCUS_LOST"; // NOI18N
101.998 - }
101.999 - }
101.1000 - } else if ("selectedElement".equals(targetPath) || "selectedElements".equals(targetPath)) { // NOI18N
101.1001 - Class<?> targetClass = bindingDef.getTarget().getBeanClass();
101.1002 - if (JList.class.isAssignableFrom(targetClass)
101.1003 - || JTable.class.isAssignableFrom(targetClass)
101.1004 - || JComboBox.class.isAssignableFrom(targetClass)) {
101.1005 - String value = bindingDef.getParameter(MetaBinding.IGNORE_ADJUSTING_PARAMETER);
101.1006 - if ("Y".equals(value)) { // NOI18N
101.1007 - targetPath += "_IGNORE_ADJUSTING"; // NOI18N
101.1008 - }
101.1009 - }
101.1010 - } else if ("value".equals(targetPath)) { // NOI18N
101.1011 - Class<?> targetClass = bindingDef.getTarget().getBeanClass();
101.1012 - if (JSlider.class.isAssignableFrom(targetClass)) {
101.1013 - String value = bindingDef.getParameter(MetaBinding.IGNORE_ADJUSTING_PARAMETER);
101.1014 - if ("Y".equals(value)) { // NOI18N
101.1015 - targetPath += "_IGNORE_ADJUSTING"; // NOI18N
101.1016 - }
101.1017 - }
101.1018 - }
101.1019 - return targetPath;
101.1020 - }
101.1021 -
101.1022 - private static void generateTargetProperty(MetaBinding bindingDef, StringBuilder buf) {
101.1023 - String targetPath = actualTargetPath(bindingDef);
101.1024 - String property = BeanProperty.class.getName() + ".create(\"" + targetPath + "\")"; // NOI18N
101.1025 - buf.append(property);
101.1026 - }
101.1027 -
101.1028 - private static Property createTargetProperty(MetaBinding bindingDef) {
101.1029 - String targetPath = actualTargetPath(bindingDef);
101.1030 - Property property = BeanProperty.create(targetPath);
101.1031 - return property;
101.1032 - }
101.1033 -
101.1034 - public static String generateBinding(BindingProperty prop, StringBuilder buf) {
101.1035 - String variable;
101.1036 - MetaBinding bindingDef = prop.getValue();
101.1037 - // Update strategy
101.1038 - int updateStrategy = bindingDef.getUpdateStrategy();
101.1039 - String strategy = AutoBinding.class.getName() + ".UpdateStrategy."; // NOI18N
101.1040 - if (updateStrategy == MetaBinding.UPDATE_STRATEGY_READ) {
101.1041 - strategy += "READ"; // NOI18N
101.1042 - } else if (updateStrategy == MetaBinding.UPDATE_STRATEGY_READ_ONCE) {
101.1043 - strategy += "READ_ONCE"; // NOI18N
101.1044 - } else {
101.1045 - strategy += "READ_WRITE"; // NOI18N
101.1046 - }
101.1047 - strategy += ", "; // NOI18N
101.1048 -
101.1049 - RADComponent target = bindingDef.getTarget();
101.1050 - FormModel formModel = target.getFormModel();
101.1051 - JavaCodeGenerator generator = (JavaCodeGenerator)FormEditor.getCodeGenerator(formModel);
101.1052 - Class targetClass = target.getBeanClass();
101.1053 - String targetPath = bindingDef.getTargetPath();
101.1054 - String sourcePath = bindingDef.getSourcePath();
101.1055 - Class<?> sourceClass = bindingDef.getSource().getBeanClass();
101.1056 - if ("elements".equals(targetPath) && JTable.class.isAssignableFrom(targetClass)
101.1057 - && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
101.1058 - String elVariable = elVariableHelper(sourcePath, buf, generator);
101.1059 - variable = generator.getBindingDescriptionVariable(JTableBinding.class, buf, false);
101.1060 - if (variable == null) {
101.1061 - variable = generator.getBindingDescriptionVariable(JTableBinding.class, buf, true);
101.1062 - buf.append(' ');
101.1063 - }
101.1064 - buf.append(variable);
101.1065 - buf.append(" = "); // NOI18N
101.1066 - buf.append(SwingBindings.class.getName()).append(".createJTableBinding("); // NOI18N
101.1067 - buf.append(strategy);
101.1068 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
101.1069 - buf.append(", "); // NOI18N
101.1070 - if (sourcePath != null) {
101.1071 - buf.append(elVariable);
101.1072 - buf.append(", "); // NOI18N
101.1073 - }
101.1074 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
101.1075 - buildBindingNameCode(prop, buf);
101.1076 - buf.append(");\n"); // NOI18N
101.1077 - if (bindingDef.hasSubBindings()) {
101.1078 - for (MetaBinding sub : bindingDef.getSubBindings()) {
101.1079 - String columnVariable = generator.getBindingDescriptionVariable(JTableBinding.ColumnBinding.class, buf, false);
101.1080 - if (columnVariable == null) {
101.1081 - columnVariable = generator.getBindingDescriptionVariable(JTableBinding.ColumnBinding.class, buf, true);
101.1082 - buf.append(' ');
101.1083 - }
101.1084 - buf.append(columnVariable);
101.1085 - buf.append(" = "); // NOI18N
101.1086 - buf.append(variable);
101.1087 - String subSourcePath = sub.getSourcePath();
101.1088 - buf.append(".addColumnBinding("); // NOI18N
101.1089 - if ((subSourcePath == null) || "null".equals(subSourcePath)) { // NOI18N
101.1090 - buf.append(ObjectProperty.class.getName());
101.1091 - buf.append(".create()"); // NOI18N
101.1092 - } else {
101.1093 - buf.append(ELProperty.class.getName());
101.1094 - buf.append(".create(\""); // NOI18N
101.1095 - buf.append(subSourcePath);
101.1096 - buf.append("\")"); // NOI18N
101.1097 - }
101.1098 - buf.append(");\n"); // NOI18N
101.1099 - String title = sub.getParameter(MetaBinding.NAME_PARAMETER);
101.1100 - if (title == null) {
101.1101 - title = subSourcePath;
101.1102 - if (isSimpleExpression(title)) {
101.1103 - title = unwrapSimpleExpression(title);
101.1104 - title = capitalize(title);
101.1105 - }
101.1106 - }
101.1107 - if ((title != null) && (!"null".equals(title))) { // NOI18N
101.1108 - buf.append(columnVariable);
101.1109 - buf.append(".setColumnName(\""); // NOI18N
101.1110 - buf.append(title);
101.1111 - buf.append("\");\n"); // NOI18N
101.1112 - }
101.1113 - String columnClass = sub.getParameter(MetaBinding.TABLE_COLUMN_CLASS_PARAMETER);
101.1114 - if (columnClass != null) {
101.1115 - buf.append(columnVariable);
101.1116 - buf.append(".setColumnClass("); // NOI18N
101.1117 - buf.append(columnClass);
101.1118 - buf.append(");\n"); // NOI18N
101.1119 - }
101.1120 - String editable = sub.getParameter(MetaBinding.EDITABLE_PARAMETER);
101.1121 - if (editable != null) {
101.1122 - buf.append(columnVariable);
101.1123 - buf.append(".setEditable("); // NOI18N
101.1124 - buf.append(editable);
101.1125 - buf.append(");\n"); // NOI18N
101.1126 - }
101.1127 - }
101.1128 - }
101.1129 - } else if ("elements".equals(targetPath) && javax.swing.JList.class.isAssignableFrom(targetClass)
101.1130 - && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
101.1131 - String elVariable = elVariableHelper(sourcePath, buf, generator);
101.1132 - variable = generator.getBindingDescriptionVariable(JListBinding.class, buf, false);
101.1133 - if (variable == null) {
101.1134 - variable = generator.getBindingDescriptionVariable(JListBinding.class, buf, true);
101.1135 - buf.append(' ');
101.1136 - }
101.1137 - buf.append(variable);
101.1138 - buf.append(" = "); // NOI18N
101.1139 - buf.append(SwingBindings.class.getName()).append(".createJListBinding("); // NOI18N
101.1140 - buf.append(strategy);
101.1141 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
101.1142 - buf.append(", "); // NOI18N
101.1143 - if (sourcePath != null) {
101.1144 - buf.append(elVariable);
101.1145 - buf.append(", "); // NOI18N
101.1146 - }
101.1147 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
101.1148 - buildBindingNameCode(prop, buf);
101.1149 - buf.append(");\n"); // NOI18N
101.1150 - String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
101.1151 - if (detailPath != null) {
101.1152 - buf.append(variable);
101.1153 - buf.append(".setDetailBinding("); // NOI18N
101.1154 - buf.append(ELProperty.class.getName());
101.1155 - buf.append(".create(\""); // NOI18N
101.1156 - buf.append(detailPath);
101.1157 - buf.append("\"));\n"); // NOI18N
101.1158 - }
101.1159 - } else if ("elements".equals(targetPath) && javax.swing.JComboBox.class.isAssignableFrom(targetClass)
101.1160 - && (List.class.isAssignableFrom(sourceClass) || (sourcePath != null))) { // NOI18N
101.1161 - String elVariable = elVariableHelper(sourcePath, buf, generator);
101.1162 - variable = generator.getBindingDescriptionVariable(JComboBoxBinding.class, buf, false);
101.1163 - if (variable == null) {
101.1164 - variable = generator.getBindingDescriptionVariable(JComboBoxBinding.class, buf, true);
101.1165 - buf.append(' ');
101.1166 - }
101.1167 - buf.append(variable);
101.1168 - buf.append(" = "); // NOI18N
101.1169 - buf.append(SwingBindings.class.getName()).append(".createJComboBoxBinding("); // NOI18N
101.1170 - buf.append(strategy);
101.1171 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
101.1172 - buf.append(", "); // NOI18N
101.1173 - if (sourcePath != null) {
101.1174 - buf.append(elVariable);
101.1175 - buf.append(", "); // NOI18N
101.1176 - }
101.1177 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
101.1178 - buildBindingNameCode(prop, buf);
101.1179 - buf.append(");\n"); // NOI18N
101.1180 - } else {
101.1181 - variable = generator.getBindingDescriptionVariable(Binding.class, buf, false);
101.1182 - StringBuilder sb = new StringBuilder();
101.1183 - if (variable == null) {
101.1184 - variable = generator.getBindingDescriptionVariable(Binding.class, buf, true);
101.1185 - buf.append(' ');
101.1186 - buf.append(sb);
101.1187 - }
101.1188 - buf.append(variable);
101.1189 - buf.append(" = "); // NOI18N
101.1190 - buf.append(Bindings.class.getName()).append(sb).append(".createAutoBinding("); // NOI18N
101.1191 - buf.append(strategy);
101.1192 - buildBindingParamsCode(prop, buf);
101.1193 - }
101.1194 - return variable;
101.1195 - }
101.1196 -
101.1197 - private static ELProperty createELProperty(String path) {
101.1198 - ELProperty property;
101.1199 - try {
101.1200 - property = ELProperty.create(path);
101.1201 - } catch (Exception ex) {
101.1202 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, ex.getMessage(), ex);
101.1203 - // fallback
101.1204 - property = ELProperty.create("error"); // NOI18N
101.1205 - }
101.1206 - return property;
101.1207 - }
101.1208 -
101.1209 - private static String elVariableHelper(String sourcePath, StringBuilder buf, JavaCodeGenerator generator) {
101.1210 - String elVariable = null;
101.1211 - if (sourcePath != null) {
101.1212 - elVariable = generator.getBindingDescriptionVariable(ELProperty.class, buf, false);
101.1213 - if (elVariable == null) {
101.1214 - elVariable = generator.getBindingDescriptionVariable(ELProperty.class, buf, true);
101.1215 - buf.append(' ');
101.1216 - }
101.1217 - buf.append(elVariable);
101.1218 - buf.append(" = "); // NOI18N
101.1219 - buf.append(ELProperty.class.getName());
101.1220 - buf.append(".create(\""); // NOI18N
101.1221 - buf.append(sourcePath);
101.1222 - buf.append("\");\n"); // NOI18N
101.1223 - }
101.1224 - return elVariable;
101.1225 - }
101.1226 -
101.1227 - private static void buildBindingParamsCode(BindingProperty prop, StringBuilder buf) {
101.1228 - MetaBinding bindingDef = prop.getValue();
101.1229 - String sourcePath = bindingDef.getSourcePath();
101.1230 - String targetPath = bindingDef.getTargetPath();
101.1231 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getSource().getCodeExpression(), "this")); // NOI18N
101.1232 - buf.append(", "); // NOI18N
101.1233 - if (sourcePath != null) {
101.1234 - buf.append(ELProperty.class.getName());
101.1235 - buf.append(".create(\""); // NOI18N
101.1236 - buf.append(sourcePath);
101.1237 - buf.append("\")"); // NOI18N
101.1238 - } else {
101.1239 - buf.append(ObjectProperty.class.getName());
101.1240 - buf.append(".create()"); // NOI18N
101.1241 - }
101.1242 - buf.append(", "); // NOI18N
101.1243 - buf.append(JavaCodeGenerator.getExpressionJavaString(bindingDef.getTarget().getCodeExpression(), "this")); // NOI18N
101.1244 - buf.append(", "); // NOI18N
101.1245 - if (targetPath != null) {
101.1246 - generateTargetProperty(bindingDef, buf);
101.1247 - } else {
101.1248 - buf.append(ObjectProperty.class.getName());
101.1249 - buf.append(".create()"); // NOI18N
101.1250 - }
101.1251 - buildBindingNameCode(prop, buf);
101.1252 - buf.append(");\n"); // NOI18N
101.1253 - }
101.1254 -
101.1255 - private static void buildBindingNameCode(BindingProperty prop, StringBuilder buf) {
101.1256 - MetaBinding bindingDef = prop.getValue();
101.1257 - if (bindingDef.isNameSpecified()) {
101.1258 - try {
101.1259 - FormProperty property = prop.getNameProperty();
101.1260 - Object value = property.getValue();
101.1261 - if (value != null) {
101.1262 - buf.append(", "); // NOI18N
101.1263 - buf.append(property.getJavaInitializationString());
101.1264 - }
101.1265 - } catch (IllegalAccessException iaex) {
101.1266 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1267 - } catch (InvocationTargetException itex) {
101.1268 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1269 - }
101.1270 - }
101.1271 - }
101.1272 -
101.1273 - private static Binding createBinding0(MetaBinding bindingDef, Object source, Object target, BindingGroup group) {
101.1274 - String name = null;
101.1275 - if (bindingDef.isNameSpecified()) {
101.1276 - BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
101.1277 - FormProperty nameProp = prop.getNameProperty();
101.1278 - try {
101.1279 - Object value = nameProp.getRealValue();
101.1280 - if ((value != null) && (value instanceof String)) {
101.1281 - name = (String)value;
101.1282 - }
101.1283 - } catch (IllegalAccessException iaex) {
101.1284 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1285 - } catch (InvocationTargetException itex) {
101.1286 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1287 - }
101.1288 - if ((name != null) && group.getBinding(name) != null) {
101.1289 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, "More than one binding with name: {0}", name); // NOI18N
101.1290 - name = null; // ignore name parameter
101.1291 - }
101.1292 - }
101.1293 - AutoBinding.UpdateStrategy updateStrategy = AutoBinding.UpdateStrategy.READ_WRITE;
101.1294 - switch (bindingDef.getUpdateStrategy()) {
101.1295 - case MetaBinding.UPDATE_STRATEGY_READ_WRITE:
101.1296 - updateStrategy = AutoBinding.UpdateStrategy.READ_WRITE;
101.1297 - break;
101.1298 - case MetaBinding.UPDATE_STRATEGY_READ:
101.1299 - updateStrategy = AutoBinding.UpdateStrategy.READ;
101.1300 - break;
101.1301 - case MetaBinding.UPDATE_STRATEGY_READ_ONCE:
101.1302 - updateStrategy = AutoBinding.UpdateStrategy.READ_ONCE;
101.1303 - break;
101.1304 - default: assert false;
101.1305 - }
101.1306 - Binding<Object,?,Object,?> binding;
101.1307 - Property targetProperty = createTargetProperty(bindingDef);
101.1308 - Property sourceProperty = (bindingDef.getSourcePath() == null) ? ObjectProperty.create() : createELProperty(bindingDef.getSourcePath());
101.1309 - RADComponent targetComp = bindingDef.getTarget();
101.1310 - String targetPath = bindingDef.getTargetPath();
101.1311 - String sourcePath = bindingDef.getSourcePath();
101.1312 - if ("elements".equals(targetPath) && javax.swing.JTable.class.isAssignableFrom(targetComp.getBeanClass())
101.1313 - && ((source instanceof List) || (sourcePath != null))) { // NOI18N
101.1314 - JTableBinding<Object,Object,Object> tableBinding;
101.1315 - if (sourcePath == null) {
101.1316 - tableBinding = SwingBindings.createJTableBinding(updateStrategy, (List)source, (JTable)target, name);
101.1317 - } else {
101.1318 - tableBinding = SwingBindings.createJTableBinding(updateStrategy, source, sourceProperty, (JTable)target, name);
101.1319 - }
101.1320 - if (bindingDef.hasSubBindings()) {
101.1321 - Collection<MetaBinding> subBindings = bindingDef.getSubBindings();
101.1322 - for (MetaBinding sub : subBindings) {
101.1323 - Property prop;
101.1324 - String subSourcePath = sub.getSourcePath();
101.1325 - if ((subSourcePath == null) || ("null".equals(subSourcePath))) { // NOI18N
101.1326 - prop = ObjectProperty.create();
101.1327 - } else {
101.1328 - prop = createELProperty(subSourcePath);
101.1329 - }
101.1330 - JTableBinding.ColumnBinding columnBinding = tableBinding.addColumnBinding(prop);
101.1331 - String title = sub.getParameter(MetaBinding.NAME_PARAMETER);
101.1332 - if (title == null) {
101.1333 - title = sub.getSourcePath();
101.1334 - if (isSimpleExpression(title)) {
101.1335 - title = unwrapSimpleExpression(title);
101.1336 - title = capitalize(title);
101.1337 - }
101.1338 - }
101.1339 - columnBinding.setColumnName(title);
101.1340 - String columnClass = sub.getParameter(MetaBinding.TABLE_COLUMN_CLASS_PARAMETER);
101.1341 - if (columnClass != null) {
101.1342 - try {
101.1343 - if ((columnClass != null) && columnClass.trim().endsWith(".class")) { // NOI18N
101.1344 - columnClass = columnClass.trim();
101.1345 - columnClass = columnClass.substring(0, columnClass.length()-6);
101.1346 - }
101.1347 - if (columnClass.indexOf('.') == -1) {
101.1348 - String prefix = ""; // NOI18N
101.1349 - while (columnClass.endsWith("[]")) { // NOI18N
101.1350 - columnClass = columnClass.substring(0, columnClass.length()-2);
101.1351 - prefix += "["; // NOI18N
101.1352 - }
101.1353 - if ("".equals(prefix)) { // NOI18N
101.1354 - columnClass = "java.lang." + columnClass; // NOI18N
101.1355 - } else {
101.1356 - String suffix = columnClass;
101.1357 - if (columnClass.equals("boolean")) { // NOI18N
101.1358 - suffix = "Z"; // NOI18N
101.1359 - } else if (columnClass.equals("byte")) { // NOI18N
101.1360 - suffix = "B"; // NOI18N
101.1361 - } else if (columnClass.equals("char")) { // NOI18N
101.1362 - suffix = "C"; // NOI18N
101.1363 - } else if (columnClass.equals("char")) { // NOI18N
101.1364 - suffix = "D"; // NOI18N
101.1365 - } else if (columnClass.equals("float")) { // NOI18N
101.1366 - suffix = "F"; // NOI18N
101.1367 - } else if (columnClass.equals("int")) { // NOI18N
101.1368 - suffix = "I"; // NOI18N
101.1369 - } else if (columnClass.equals("long")) { // NOI18N
101.1370 - suffix = "J"; // NOI18N
101.1371 - } else if (columnClass.equals("short")) { // NOI18N
101.1372 - suffix = "S"; // NOI18N
101.1373 - } else {
101.1374 - prefix += "L"; // NOI18N
101.1375 - if (suffix.indexOf('.') == -1) {
101.1376 - suffix = "java.lang." + suffix; // NOI18N
101.1377 - }
101.1378 - suffix += ";"; // NOI18N
101.1379 - }
101.1380 - columnClass = prefix + suffix;
101.1381 - }
101.1382 - }
101.1383 - Class<?> clazz = FormUtils.loadClass(columnClass, bindingDef.getSource().getFormModel());
101.1384 - columnBinding.setColumnClass(clazz);
101.1385 - } catch (ClassNotFoundException cnfex) {
101.1386 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, cnfex.getMessage(), cnfex);
101.1387 - }
101.1388 - }
101.1389 - String editable = sub.getParameter(MetaBinding.EDITABLE_PARAMETER);
101.1390 - if (editable != null) {
101.1391 - Boolean value = "false".equals(editable) ? Boolean.FALSE : Boolean.TRUE; // NOI18N
101.1392 - columnBinding.setEditable(value);
101.1393 - }
101.1394 - }
101.1395 - }
101.1396 - binding = tableBinding;
101.1397 - } else if ("elements".equals(targetPath) && javax.swing.JList.class.isAssignableFrom(targetComp.getBeanClass())
101.1398 - && ((source instanceof List) || (sourcePath != null))) { // NOI18N
101.1399 - JListBinding listBinding;
101.1400 - if (sourcePath == null) {
101.1401 - listBinding = SwingBindings.createJListBinding(updateStrategy, (List)source, (JList)target, name);
101.1402 - } else {
101.1403 - listBinding = SwingBindings.createJListBinding(updateStrategy, source, sourceProperty, (JList)target, name);
101.1404 - }
101.1405 - String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
101.1406 - if (detailPath != null) {
101.1407 - listBinding.setDetailBinding(createELProperty(detailPath));
101.1408 - }
101.1409 - binding = listBinding;
101.1410 - } else if ("elements".equals(targetPath) && javax.swing.JComboBox.class.isAssignableFrom(targetComp.getBeanClass())
101.1411 - && ((source instanceof List) || (sourcePath != null))) { // NOI18N
101.1412 - JComboBoxBinding comboBinding;
101.1413 - if (sourcePath == null) {
101.1414 - comboBinding = SwingBindings.createJComboBoxBinding(updateStrategy, (List)source, (JComboBox)target, name);
101.1415 - } else {
101.1416 - comboBinding = SwingBindings.createJComboBoxBinding(updateStrategy, source, sourceProperty, (JComboBox)target, name);
101.1417 - }
101.1418 -// String detailPath = bindingDef.getParameter(MetaBinding.DISPLAY_PARAMETER);
101.1419 -// if (detailPath != null) {
101.1420 -// comboBinding.setDetailBinding(createELProperty(detailPath));
101.1421 -// }
101.1422 - binding = comboBinding;
101.1423 - } else {
101.1424 - binding = Bindings.createAutoBinding(updateStrategy, source, sourceProperty, target, targetProperty, name);
101.1425 - }
101.1426 - return binding;
101.1427 - }
101.1428 -
101.1429 - private static Binding createBinding(MetaBinding bindingDef,
101.1430 - Object source, Object target,
101.1431 - BindingGroup group,
101.1432 - Map<Binding,BindingGroup> bindingToGroup) {
101.1433 - Binding<Object,Object,Object,Object> binding = (Binding<Object,Object,Object,Object>)createBinding0(bindingDef, source, target, group);
101.1434 - if (bindingDef.isNullValueSpecified()) {
101.1435 - BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
101.1436 - FormProperty nullProp = prop.getNullValueProperty();
101.1437 - try {
101.1438 - Object value = nullProp.getRealValue();
101.1439 - if ((value != null) && (value != FormDesignValue.IGNORED_VALUE)) {
101.1440 - binding.setSourceNullValue(value);
101.1441 - }
101.1442 - } catch (IllegalAccessException iaex) {
101.1443 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1444 - } catch (InvocationTargetException itex) {
101.1445 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1446 - }
101.1447 - }
101.1448 - if (bindingDef.isIncompletePathValueSpecified()) {
101.1449 - BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
101.1450 - FormProperty incompleteProp = prop.getIncompleteValueProperty();
101.1451 - try {
101.1452 - Object value = incompleteProp.getRealValue();
101.1453 - if ((value != null) && (value != FormDesignValue.IGNORED_VALUE)) {
101.1454 - binding.setSourceUnreadableValue(value);
101.1455 - }
101.1456 - } catch (IllegalAccessException iaex) {
101.1457 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1458 - } catch (InvocationTargetException itex) {
101.1459 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1460 - }
101.1461 - }
101.1462 - if (bindingDef.isConverterSpecified()) {
101.1463 - BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
101.1464 - FormProperty converterProp = prop.getConverterProperty();
101.1465 - try {
101.1466 - Object value = converterProp.getRealValue();
101.1467 - if ((value != null) && (value instanceof Converter)) {
101.1468 - binding.setConverter((Converter)value);
101.1469 - }
101.1470 - } catch (IllegalAccessException iaex) {
101.1471 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1472 - } catch (InvocationTargetException itex) {
101.1473 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1474 - }
101.1475 - }
101.1476 - if (bindingDef.isValidatorSpecified()) {
101.1477 - BindingProperty prop = bindingDef.getTarget().getBindingProperty(bindingDef.getTargetPath());
101.1478 - FormProperty validatorProp = prop.getValidatorProperty();
101.1479 - try {
101.1480 - Object value = validatorProp.getRealValue();
101.1481 - if ((value != null) && (value instanceof Validator)) {
101.1482 - binding.setValidator((Validator)value);
101.1483 - }
101.1484 - } catch (IllegalAccessException iaex) {
101.1485 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, iaex.getMessage(), iaex);
101.1486 - } catch (InvocationTargetException itex) {
101.1487 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, itex.getMessage(), itex);
101.1488 - }
101.1489 - }
101.1490 - group.addBinding(binding);
101.1491 - if (bindingToGroup != null) {
101.1492 - bindingToGroup.put(binding, group);
101.1493 - }
101.1494 -
101.1495 - try {
101.1496 - binding.bind();
101.1497 - } catch (Exception ex) {
101.1498 - Logger.getLogger(BindingDesignSupport.class.getName()).log(Level.INFO, ex.getMessage(), ex);
101.1499 - }
101.1500 - return binding;
101.1501 - }
101.1502 -
101.1503 - private void removeBindings(MetaBinding bindingDef) {
101.1504 - removeBindingInModel(bindingDef);
101.1505 - List<Binding> establishedBindings = bindingsMap.get(bindingDef);
101.1506 - if (establishedBindings != null) {
101.1507 - for (Binding binding : establishedBindings) {
101.1508 - removeBinding(binding);
101.1509 - }
101.1510 - bindingsMap.remove(bindingDef);
101.1511 - }
101.1512 - }
101.1513 -
101.1514 - private void removeBinding(Binding binding) {
101.1515 - BindingGroup group = bindingToGroup.remove(binding);
101.1516 - // It may happen that binding.bind() fails. Binding may
101.1517 - // stay unbound in such situation and binding.unbind()
101.1518 - // throws exception is this case
101.1519 - if (binding.isBound()) {
101.1520 - binding.unbind();
101.1521 - }
101.1522 - group.removeBinding(binding);
101.1523 - }
101.1524 -
101.1525 - private void removeBindingInModel(MetaBinding bindingDef) {
101.1526 - Binding binding = modelBindings.remove(bindingDef);
101.1527 - if (binding != null) {
101.1528 - removeBinding(binding);
101.1529 - }
101.1530 - }
101.1531 -
101.1532 - public static String capitalize(String title) {
101.1533 - StringBuilder builder = new StringBuilder(title);
101.1534 - boolean lastWasUpper = false;
101.1535 - for (int i = 0; i < builder.length(); i++) {
101.1536 - char aChar = builder.charAt(i);
101.1537 - if (i == 0) {
101.1538 - builder.setCharAt(i, Character.toUpperCase(aChar));
101.1539 - lastWasUpper = true;
101.1540 - } else if (Character.isUpperCase(aChar)) {
101.1541 - if (!lastWasUpper) {
101.1542 - builder.insert(i, ' ');
101.1543 - }
101.1544 - lastWasUpper = true;
101.1545 - i++;
101.1546 - } else {
101.1547 - lastWasUpper = false;
101.1548 - }
101.1549 - }
101.1550 - return builder.toString();
101.1551 - }
101.1552 -
101.1553 - /**
101.1554 - * Form model listener that updates the bindings.
101.1555 - */
101.1556 - private class ModelListener implements FormModelListener {
101.1557 - @Override
101.1558 - public void formChanged(FormModelEvent[] events) {
101.1559 - if (events == null)
101.1560 - return;
101.1561 -
101.1562 - for (int i=0; i < events.length; i++) {
101.1563 - FormModelEvent ev = events[i];
101.1564 - switch (ev.getChangeType()) {
101.1565 - case FormModelEvent.BINDING_PROPERTY_CHANGED:
101.1566 - if (ev.getSubPropertyName() == null) {
101.1567 - changeBinding(ev.getOldBinding(), ev.getNewBinding());
101.1568 - }
101.1569 - break;
101.1570 - case FormModelEvent.COMPONENT_REMOVED:
101.1571 - releaseBindings(ev.getComponent(), true);
101.1572 - break;
101.1573 - case FormModelEvent.COMPONENT_ADDED:
101.1574 - if (!ev.getCreatedDeleted()) {
101.1575 - establishUpdatedBindings(ev.getComponent(), true, null, bindingGroup, true);
101.1576 - }
101.1577 - break;
101.1578 - }
101.1579 - }
101.1580 - }
101.1581 - }
101.1582 -
101.1583 - static class ModifiableBoolean {
101.1584 - boolean value;
101.1585 - }
101.1586 -
101.1587 }
102.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
102.2 +++ b/form/src/org/netbeans/modules/form/BindingDesignSupportProvider.java Wed Jul 27 10:35:25 2011 +0200
102.3 @@ -0,0 +1,55 @@
102.4 +/*
102.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
102.6 + *
102.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
102.8 + *
102.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
102.10 + * Other names may be trademarks of their respective owners.
102.11 + *
102.12 + * The contents of this file are subject to the terms of either the GNU
102.13 + * General Public License Version 2 only ("GPL") or the Common Development and
102.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
102.15 + * this file except in compliance with the License. You can obtain a copy of
102.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
102.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
102.18 + * governing permissions and limitations under the License. When distributing
102.19 + * the software, include this License Header Notice in each file and include
102.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
102.21 + * particular file as subject to the "Classpath" exception as provided by
102.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
102.23 + * this code. If applicable, add the following below the License Header, with
102.24 + * the fields enclosed by brackets [] replaced by your own identifying
102.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
102.26 + *
102.27 + * If you wish your version of this file to be governed by only the CDDL or
102.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
102.29 + * elects to include this software in this distribution under the [CDDL or GPL
102.30 + * Version 2] license." If you do not indicate a single choice of license, a
102.31 + * recipient has the option to distribute your version of this file under
102.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
102.33 + * licensees as provided above. However, if you add GPL Version 2 code and
102.34 + * therefore, elected the GPL Version 2 license, then the option applies only
102.35 + * if the new code is made subject to such option by the copyright holder.
102.36 + *
102.37 + * Contributor(s):
102.38 + *
102.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
102.40 + */
102.41 +package org.netbeans.modules.form;
102.42 +
102.43 +/**
102.44 + * Provider of binding support.
102.45 + *
102.46 + * @author Jan Stola
102.47 + */
102.48 +public interface BindingDesignSupportProvider {
102.49 +
102.50 + /**
102.51 + * Creates a binding support for the specified form model.
102.52 + *
102.53 + * @param formModel form model for which the binding support should be created.
102.54 + * @return binding support for the specified form model.
102.55 + */
102.56 + BindingDesignSupport create(FormModel formModel);
102.57 +
102.58 +}
103.1 --- a/form/src/org/netbeans/modules/form/BindingProperty.java Wed Jul 27 10:33:10 2011 +0200
103.2 +++ b/form/src/org/netbeans/modules/form/BindingProperty.java Wed Jul 27 10:35:25 2011 +0200
103.3 @@ -53,8 +53,6 @@
103.4 import java.util.Map;
103.5 import java.util.logging.Level;
103.6 import java.util.logging.Logger;
103.7 -import org.jdesktop.beansbinding.Converter;
103.8 -import org.jdesktop.beansbinding.Validator;
103.9 import org.openide.nodes.Node;
103.10
103.11 import org.openide.nodes.PropertySupport;
103.12 @@ -87,14 +85,15 @@
103.13 }
103.14 }
103.15 if (prop != null) {
103.16 + BindingDesignSupport bindingSupport = FormEditor.getBindingSupport(getFormModel());
103.17 String name = FormUtils.getBundleString("MSG_Binding_NullProperty"); // NOI18N
103.18 nullValueProperty = new Property(prop, "nullValue", desc.getValueType(), name, name, false); // NOI18N
103.19 name = FormUtils.getBundleString("MSG_Binding_IncompletePathProperty"); // NOI18N
103.20 incompleteValueProperty = new Property(prop, "incompletePathValue", desc.getValueType(), name, name, false); // NOI18N
103.21 name = FormUtils.getBundleString("MSG_Binding_Validator"); // NOI18N
103.22 - validatorProperty = new Property(prop, "validator", Validator.class, name, name, true); // NOI18N
103.23 + validatorProperty = new Property(prop, "validator", bindingSupport.getValidatorClass(), name, name, true); // NOI18N
103.24 name = FormUtils.getBundleString("MSG_Binding_Converter"); // NOI18N
103.25 - converterProperty = new Property(prop, "converter", Converter.class, name, name, true); // NOI18N
103.26 + converterProperty = new Property(prop, "converter", bindingSupport.getConverterClass(), name, name, true); // NOI18N
103.27 name = FormUtils.getBundleString("MSG_Binding_Name"); // NOI18N
103.28 nameProperty = new Property(prop, "name", String.class, name, name, true); // NOI18N
103.29 }
103.30 @@ -244,23 +243,23 @@
103.31 return bindingComponent.getFormModel();
103.32 }
103.33
103.34 - FormProperty getNullValueProperty() {
103.35 + public FormProperty getNullValueProperty() {
103.36 return nullValueProperty;
103.37 }
103.38
103.39 - FormProperty getIncompleteValueProperty() {
103.40 + public FormProperty getIncompleteValueProperty() {
103.41 return incompleteValueProperty;
103.42 }
103.43
103.44 - FormProperty getValidatorProperty() {
103.45 + public FormProperty getValidatorProperty() {
103.46 return validatorProperty;
103.47 }
103.48
103.49 - FormProperty getConverterProperty() {
103.50 + public FormProperty getConverterProperty() {
103.51 return converterProperty;
103.52 }
103.53
103.54 - FormProperty getNameProperty() {
103.55 + public FormProperty getNameProperty() {
103.56 return nameProperty;
103.57 }
103.58
104.1 --- a/form/src/org/netbeans/modules/form/FormDesigner.java Wed Jul 27 10:33:10 2011 +0200
104.2 +++ b/form/src/org/netbeans/modules/form/FormDesigner.java Wed Jul 27 10:35:25 2011 +0200
104.3 @@ -611,7 +611,8 @@
104.4 new Mutex.ExceptionAction () {
104.5 @Override
104.6 public Object run() throws Exception {
104.7 - VisualReplicator r = new VisualReplicator(false, FormUtils.getViewConverters(), null);
104.8 + FormModel formModel = metacomp.getFormModel();
104.9 + VisualReplicator r = new VisualReplicator(false, FormUtils.getViewConverters(), FormEditor.getBindingSupport(formModel));
104.10 r.setTopMetaComponent(metacomp);
104.11 Object container = r.createClone();
104.12 if (container instanceof RootPaneContainer) {
105.1 --- a/form/src/org/netbeans/modules/form/FormEditor.java Wed Jul 27 10:33:10 2011 +0200
105.2 +++ b/form/src/org/netbeans/modules/form/FormEditor.java Wed Jul 27 10:35:25 2011 +0200
105.3 @@ -77,6 +77,7 @@
105.4 import org.netbeans.modules.form.project.ClassSource;
105.5 import org.netbeans.modules.form.project.ClassPathUtils;
105.6 import org.openide.util.Exceptions;
105.7 +import org.openide.util.Lookup;
105.8
105.9 /**
105.10 * Form editor.
105.11 @@ -108,6 +109,7 @@
105.12 private ResourceSupport resourceSupport;
105.13
105.14 /** Instance of binding support for the form.*/
105.15 + private boolean bindingSupportInitialized;
105.16 private BindingDesignSupport bindingSupport;
105.17
105.18 /** List of exceptions occurred during the last persistence operation */
105.19 @@ -227,8 +229,11 @@
105.20 }
105.21
105.22 BindingDesignSupport getBindingSupport() {
105.23 - if (bindingSupport == null && formModel != null) {
105.24 - bindingSupport = new BindingDesignSupport(formModel);
105.25 + if (!bindingSupportInitialized && formModel != null) {
105.26 + BindingDesignSupportProvider provider = Lookup.getDefault().lookup(BindingDesignSupportProvider.class);
105.27 + if (provider != null) {
105.28 + bindingSupport = provider.create(formModel);
105.29 + }
105.30 }
105.31 return bindingSupport;
105.32 }
105.33 @@ -1208,20 +1213,8 @@
105.34 */
105.35 public static boolean updateProjectForBeansBinding(FormModel formModel) {
105.36 FormEditor formEditor = getFormEditor(formModel);
105.37 - if (formEditor != null
105.38 - && !ClassPathUtils.isOnClassPath(formEditor.getFormDataObject().getFormFile(), org.jdesktop.beansbinding.Binding.class.getName())) {
105.39 - try {
105.40 - Library lib = LibraryManager.getDefault().getLibrary("beans-binding"); // NOI18N
105.41 - if (lib == null) {
105.42 - return false;
105.43 - }
105.44 - ClassSource cs = new ClassSource("", // class name is not needed // NOI18N
105.45 - new ClassSource.LibraryEntry(lib));
105.46 - return Boolean.TRUE == ClassPathUtils.updateProject(formEditor.getFormDataObject().getFormFile(), cs);
105.47 - }
105.48 - catch (IOException ex) {
105.49 - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
105.50 - }
105.51 + if (formEditor != null) {
105.52 + return formEditor.getBindingSupport().updateProjectForBeansBinding();
105.53 }
105.54 return false;
105.55 }
106.1 --- a/form/src/org/netbeans/modules/form/FormUtils.java Wed Jul 27 10:33:10 2011 +0200
106.2 +++ b/form/src/org/netbeans/modules/form/FormUtils.java Wed Jul 27 10:35:25 2011 +0200
106.3 @@ -91,10 +91,10 @@
106.4 private static final Object CLASS_AND_SUBCLASSES = new Object();
106.5 private static final Object CLASS_AND_SWING_SUBCLASSES = new Object();
106.6
106.7 - static final Object PROP_PREFERRED = new Object();
106.8 - static final Object PROP_NORMAL = new Object();
106.9 - static final Object PROP_EXPERT = new Object();
106.10 - static final Object PROP_HIDDEN = new Object();
106.11 + public static final Object PROP_PREFERRED = new Object();
106.12 + public static final Object PROP_NORMAL = new Object();
106.13 + public static final Object PROP_EXPERT = new Object();
106.14 + public static final Object PROP_HIDDEN = new Object();
106.15
106.16 static final String PROP_REQUIRES_PARENT = "thisPropertyRequiresParent"; // NOI18N
106.17 static final String PROP_REQUIRES_CHILDREN = "thisPropertyRequiresChildren"; // NOI18N
106.18 @@ -1143,7 +1143,7 @@
106.19 * @return Object[] array of property categories for given bean class, or
106.20 * null if nothing specified for the class
106.21 */
106.22 - static Object[] getPropertiesCategoryClsf(Class beanClass,
106.23 + public static Object[] getPropertiesCategoryClsf(Class beanClass,
106.24 BeanDescriptor beanDescriptor)
106.25 {
106.26 List<Object> reClsf = null;
106.27 @@ -1171,9 +1171,7 @@
106.28 * properties classification for given bean class (returned from
106.29 * getPropertiesCategoryClsf method).
106.30 */
106.31 - static Object getPropertyCategory(FeatureDescriptor pd,
106.32 - Object[] propsClsf)
106.33 - {
106.34 + public static Object getPropertyCategory(FeatureDescriptor pd, Object[] propsClsf) {
106.35 Object cat = findPropertyClsf(pd.getName(), propsClsf);
106.36 if (cat != null)
106.37 return cat;
106.38 @@ -1692,7 +1690,7 @@
106.39 /**
106.40 * Returns (undefined ;-)) normalized form of this type.
106.41 */
106.42 - TypeHelper normalize() {
106.43 + public TypeHelper normalize() {
106.44 TypeHelper t = this;
106.45 if (type instanceof TypeVariable) {
106.46 if (actualTypeArgs != null) {
106.47 @@ -1720,6 +1718,44 @@
106.48 return t;
106.49 }
106.50
106.51 + /**
106.52 + * Returns type of element of the given type - expects type that implements
106.53 + * <code>Collection</code> interface.
106.54 + *
106.55 + * @param type type that implements <code>Collection</code> interface.
106.56 + * @return type of element of the given type.
106.57 + */
106.58 + public TypeHelper typeOfElement() {
106.59 + Type t = getType();
106.60 + TypeHelper elemType = new TypeHelper();
106.61 + if (t instanceof ParameterizedType) {
106.62 + ParameterizedType pt = (ParameterizedType)t;
106.63 + Type[] args = pt.getActualTypeArguments();
106.64 + // PENDING generalize and improve - track the type variables to the nearest
106.65 + // known collection superclass or check parameter type of add(E o) method
106.66 + if (args.length == 1) { // The only argument should be type of the collection element
106.67 + Type tt = args[0];
106.68 + elemType = new TypeHelper(tt, actualTypeArgs);
106.69 + }
106.70 + } else if (t instanceof Class) {
106.71 + Class classa = (Class)t;
106.72 + TypeVariable[] tvar = classa.getTypeParameters();
106.73 + // PENDING dtto
106.74 + if ((actualTypeArgs != null) && (tvar.length == 1)) {
106.75 + TypeHelper tt = actualTypeArgs.get(tvar[0].getName());
106.76 + if (tt != null) {
106.77 + if (tt.getType() == null) {
106.78 + elemType = tt;
106.79 + } else {
106.80 + Type typ = FormUtils.typeToClass(tt);
106.81 + elemType = new TypeHelper(typ, actualTypeArgs);
106.82 + }
106.83 + }
106.84 + }
106.85 + }
106.86 + return elemType;
106.87 + }
106.88 +
106.89 @Override
106.90 public boolean equals(Object o) {
106.91 if (o instanceof TypeHelper) {
106.92 @@ -1798,7 +1834,7 @@
106.93 }
106.94
106.95 // helper method for getBeanInfo(Class)
106.96 - static BeanInfo getBeanInfo(Class clazz, int mode) throws IntrospectionException {
106.97 + public static BeanInfo getBeanInfo(Class clazz, int mode) throws IntrospectionException {
106.98 if (mode == Introspector.IGNORE_IMMEDIATE_BEANINFO) {
106.99 try {
106.100 return Introspector.getBeanInfo(clazz, Introspector.IGNORE_IMMEDIATE_BEANINFO);
107.1 --- a/form/src/org/netbeans/modules/form/JavaCodeGenerator.java Wed Jul 27 10:33:10 2011 +0200
107.2 +++ b/form/src/org/netbeans/modules/form/JavaCodeGenerator.java Wed Jul 27 10:35:25 2011 +0200
107.3 @@ -169,7 +169,6 @@
107.4
107.5 private Map<String,String> repeatedCodeVariables;
107.6
107.7 - private static Class bindingGroupClass = org.jdesktop.beansbinding.BindingGroup.class;
107.8 private String bindingGroupVariable;
107.9 private Map<String,String> bindingVariables;
107.10 private static String variablesHeader;
107.11 @@ -1067,7 +1066,7 @@
107.12 addLocalVariables(writer);
107.13
107.14 if (bindingGroupVariable != null) {
107.15 - initCodeWriter.write(bindingGroupVariable + " = new " + bindingGroupClass.getName() + "();\n\n"); // NOI18N
107.16 + initCodeWriter.write(bindingGroupVariable + " = new " + getBindingGroupClass().getName() + "();\n\n"); // NOI18N
107.17 }
107.18
107.19 emptyLineRequest++;
107.20 @@ -1138,6 +1137,10 @@
107.21 cleanup();
107.22 }
107.23
107.24 + private Class getBindingGroupClass() {
107.25 + return formEditor.getBindingSupport().getBindingGroupClass();
107.26 + }
107.27 +
107.28 private void cleanup() {
107.29 emptyLineCounter = 0;
107.30 emptyLineRequest = 0;
107.31 @@ -1153,7 +1156,7 @@
107.32 bindingVariables = null;
107.33 if (bindingGroupVariable != null) { // we need to keep this variable registered
107.34 bindingGroupVariable = formModel.getCodeStructure().getExternalVariableName(
107.35 - bindingGroupClass, bindingGroupVariable, true);
107.36 + getBindingGroupClass(), bindingGroupVariable, true);
107.37 }
107.38 }
107.39
107.40 @@ -1707,11 +1710,11 @@
107.41 anyBinding = true;
107.42 if (bindingGroupVariable == null) { // Should happen only for Code Customizer
107.43 bindingGroupVariable = formModel.getCodeStructure().getExternalVariableName(
107.44 - bindingGroupClass, "bindingGroup", true); // NOI18N
107.45 + getBindingGroupClass(), "bindingGroup", true); // NOI18N
107.46 }
107.47 }
107.48 StringBuilder buf = new StringBuilder();
107.49 - String variable = BindingDesignSupport.generateBinding(prop, buf);
107.50 + String variable = formEditor.getBindingSupport().generateBinding(prop, buf, getBindingContext());
107.51 initCodeWriter.write(buf.toString());
107.52
107.53 if (bindingDef.isNullValueSpecified()) {
107.54 @@ -1737,6 +1740,24 @@
107.55 }
107.56 }
107.57
107.58 + BindingDesignSupport.CodeGeneratorContext bindingContext;
107.59 + private BindingDesignSupport.CodeGeneratorContext getBindingContext() {
107.60 + if (bindingContext == null) {
107.61 + bindingContext = new BindingDesignSupport.CodeGeneratorContext() {
107.62 + @Override
107.63 + public String getBindingDescriptionVariable(Class descriptionType, StringBuilder buf, boolean create) {
107.64 + return JavaCodeGenerator.this.getBindingDescriptionVariable(descriptionType, buf, create);
107.65 + }
107.66 +
107.67 + @Override
107.68 + public String getExpressionJavaString(CodeExpression exp, String thisStr) {
107.69 + return JavaCodeGenerator.getExpressionJavaString(exp, thisStr);
107.70 + }
107.71 + };
107.72 + }
107.73 + return bindingContext;
107.74 + }
107.75 +
107.76 private void generateComponentBinding0(CodeWriter initCodeWriter, FormProperty property, String method) throws IOException {
107.77 initCodeWriter.write(method + "(" + property.getJavaInitializationString() + ");\n"); // NOI18N
107.78 }
107.79 @@ -2592,9 +2613,9 @@
107.80 anyBinding = true;
107.81 if (bindingGroupVariable == null) {
107.82 bindingGroupVariable = formModel.getCodeStructure().getExternalVariableName(
107.83 - bindingGroupClass, "bindingGroup", true); // NOI18N
107.84 + getBindingGroupClass(), "bindingGroup", true); // NOI18N
107.85 }
107.86 - variablesWriter.write("private " + bindingGroupClass.getName() + " " + bindingGroupVariable + ";\n"); // NOI18N
107.87 + variablesWriter.write("private " + getBindingGroupClass().getName() + " " + bindingGroupVariable + ";\n"); // NOI18N
107.88 variableNames.add(bindingGroupVariable);
107.89 break;
107.90 }
108.1 --- a/form/src/org/netbeans/modules/form/RADComponent.java Wed Jul 27 10:33:10 2011 +0200
108.2 +++ b/form/src/org/netbeans/modules/form/RADComponent.java Wed Jul 27 10:35:25 2011 +0200
108.3 @@ -700,7 +700,7 @@
108.4 return null;
108.5 }
108.6
108.7 - synchronized BindingProperty[] getKnownBindingProperties() {
108.8 + public synchronized BindingProperty[] getKnownBindingProperties() {
108.9 return bindingProperties != null ? getAllBindingProperties() : NO_BINDINGS;
108.10 }
108.11
108.12 @@ -1375,15 +1375,20 @@
108.13 }
108.14
108.15 private synchronized void createBindingProperties() {
108.16 - Collection<BindingDescriptor>[] props = FormEditor.getBindingSupport(formModel).getBindingDescriptors(this);
108.17 - bindingProperties = new BindingProperty[props.length][];
108.18 - for (int i=0; i<props.length; i++) {
108.19 - bindingProperties[i] = new BindingProperty[props[i].size()];
108.20 - int j = 0;
108.21 - for (BindingDescriptor desc : props[i]) {
108.22 - bindingProperties[i][j++] = new BindingProperty(this, desc);
108.23 + BindingDesignSupport bindingSupport = FormEditor.getBindingSupport(formModel);
108.24 + if (bindingSupport == null) {
108.25 + bindingProperties = new BindingProperty[][] {{},{},{}};
108.26 + } else {
108.27 + Collection<BindingDescriptor>[] props = bindingSupport.getBindingDescriptors(this);
108.28 + bindingProperties = new BindingProperty[props.length][];
108.29 + for (int i=0; i<props.length; i++) {
108.30 + bindingProperties[i] = new BindingProperty[props[i].size()];
108.31 + int j = 0;
108.32 + for (BindingDescriptor desc : props[i]) {
108.33 + bindingProperties[i][j++] = new BindingProperty(this, desc);
108.34 + }
108.35 }
108.36 - }
108.37 + }
108.38 }
108.39
108.40 private synchronized void createEventProperties() {
109.1 --- a/form/src/org/netbeans/modules/form/RADComponentNode.java Wed Jul 27 10:33:10 2011 +0200
109.2 +++ b/form/src/org/netbeans/modules/form/RADComponentNode.java Wed Jul 27 10:35:25 2011 +0200
109.3 @@ -265,7 +265,9 @@
109.4 } else {
109.5 actions.add(SystemAction.get(TestAction.class));
109.6 }
109.7 - actions.add(SystemAction.get(BindAction.class));
109.8 + if (FormEditor.getBindingSupport(component.getFormModel()) != null) {
109.9 + actions.add(SystemAction.get(BindAction.class));
109.10 + }
109.11 actions.add(SystemAction.get(EventsAction.class));
109.12 actions.add(null);
109.13
110.1 --- a/form/src/org/netbeans/modules/form/VisualReplicator.java Wed Jul 27 10:33:10 2011 +0200
110.2 +++ b/form/src/org/netbeans/modules/form/VisualReplicator.java Wed Jul 27 10:35:25 2011 +0200
110.3 @@ -51,8 +51,6 @@
110.4 import java.util.logging.Level;
110.5 import java.util.logging.Logger;
110.6
110.7 -import org.jdesktop.beansbinding.BindingGroup;
110.8 -
110.9 import org.openide.ErrorManager;
110.10
110.11 import org.netbeans.modules.form.fakepeer.FakePeerSupport;
110.12 @@ -81,8 +79,8 @@
110.13
110.14 private Map<String,SwingLayoutBuilder> layoutBuilders = new HashMap<String,SwingLayoutBuilder>();
110.15
110.16 - private BindingGroup bindingGroup;
110.17 private BindingDesignSupport bindingSupport;
110.18 + private BindingDesignSupport.BindingVisualReplicator bindingReplicator;
110.19
110.20 private boolean designRestrictions;
110.21
110.22 @@ -139,12 +137,11 @@
110.23 return builder;
110.24 }
110.25
110.26 - private BindingGroup getBindingGroup() {
110.27 - if (bindingGroup == null) {
110.28 - bindingGroup = new BindingGroup();
110.29 - bindingGroup.bind();
110.30 + private BindingDesignSupport.BindingVisualReplicator getBindingReplicator() {
110.31 + if (bindingReplicator == null) {
110.32 + bindingReplicator = bindingSupport.createReplicator();
110.33 }
110.34 - return bindingGroup;
110.35 + return bindingReplicator;
110.36 }
110.37
110.38 // ---------
110.39 @@ -159,7 +156,7 @@
110.40 idToClone.clear();
110.41 cloneToId.clear();
110.42 layoutBuilders.clear();
110.43 - bindingGroup = null;
110.44 + bindingReplicator = null;
110.45 }
110.46
110.47 public boolean getDesignRestrictions() {
110.48 @@ -200,19 +197,18 @@
110.49 entry.setValue(rc.getBeanInstance());
110.50 }
110.51 }
110.52 - BindingGroup group = getBindingGroup();
110.53 boolean restrictions = getDesignRestrictions();
110.54 for (String id : mapToClones.keySet()) {
110.55 RADComponent rc = formModel.getMetaComponent(id);
110.56 - if (rc != null) {
110.57 + if ((rc != null) && (rc.getKnownBindingProperties().length != 0)) {
110.58 if (restrictions) { // this is an updated view (designer)
110.59 - bindingSupport.establishUpdatedBindings(
110.60 - rc, false, mapToClones, group, false);
110.61 + getBindingReplicator().establishUpdatedBindings(
110.62 + rc, false, mapToClones, false);
110.63 // BindingDesignSupport will unbind and remove these bindings
110.64 // automatically if user removes a binding or whole component
110.65 } else { // this is a one-off view (preview)
110.66 - BindingDesignSupport.establishOneOffBindings(
110.67 - rc, false, mapToClones, group);
110.68 + getBindingReplicator().establishOneOffBindings(
110.69 + rc, false, mapToClones);
110.70 }
110.71 }
110.72 }
110.73 @@ -645,7 +641,7 @@
110.74 Object source = isConverted(metaSource) ? metaSource.getBeanInstance() : getClonedComponent(metaSource);
110.75 if (source == null) // source not cloned - let's use the bean instance directly
110.76 source = newBinding.getSource().getBeanInstance();
110.77 - bindingSupport.addBinding(newBinding, source, target, getBindingGroup(), false);
110.78 + getBindingReplicator().addBinding(newBinding, source, target, false);
110.79 }
110.80 }
110.81 }
111.1 --- a/form/src/org/netbeans/modules/form/editors/TableCustomizer.java Wed Jul 27 10:33:10 2011 +0200
111.2 +++ b/form/src/org/netbeans/modules/form/editors/TableCustomizer.java Wed Jul 27 10:35:25 2011 +0200
111.3 @@ -110,6 +110,9 @@
111.4 /** Table model for table with row information. */
111.5 private TableModelEditor.NbTableModel rowTableModel;
111.6
111.7 + /** Binding support for the corresponding form model. */
111.8 + private BindingDesignSupport bindingSupport;
111.9 +
111.10 /**
111.11 * Creates new <code>TableCustomizer</code>.
111.12 */
111.13 @@ -1306,6 +1309,9 @@
111.14 columnModelProperty = (RADProperty)comp.getPropertyByName("columnModel"); // NOI18N
111.15 columnSelectionAllowedProperty = (FormProperty)comp.getPropertyByName("columnSelectionAllowed"); // NOI18N
111.16
111.17 + // Obtain binding support
111.18 + bindingSupport = FormEditor.getBindingSupport(formModel);
111.19 +
111.20 // Determine type of model
111.21 try {
111.22 Object value = modelProperty.getValue();
111.23 @@ -1528,9 +1534,9 @@
111.24 columnName = model.getColumnName(index);
111.25 } else {
111.26 String name = subBinding.getSourcePath();
111.27 - if (BindingDesignSupport.isSimpleExpression(name)) {
111.28 - columnName = BindingDesignSupport.unwrapSimpleExpression(name);
111.29 - columnName = BindingDesignSupport.capitalize(columnName);
111.30 + if (bindingSupport.isSimpleExpression(name)) {
111.31 + columnName = bindingSupport.unwrapSimpleExpression(name);
111.32 + columnName = bindingSupport.capitalize(columnName);
111.33 }
111.34 }
111.35 }
112.1 --- a/form/src/org/netbeans/modules/form/resources/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
112.2 +++ b/form/src/org/netbeans/modules/form/resources/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
112.3 @@ -362,4 +362,3 @@
112.4 #libraries
112.5 swing-layout=Swing Layout Extensions
112.6 absolutelayout=Absolute Layout
112.7 -beans-binding=Beans Binding
113.1 --- a/form/src/org/netbeans/modules/form/resources/beans_binding.xml Wed Jul 27 10:33:10 2011 +0200
113.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
113.3 @@ -1,70 +0,0 @@
113.4 -<?xml version="1.0"?>
113.5 -<!--
113.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
113.7 -
113.8 -Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
113.9 -
113.10 -Oracle and Java are registered trademarks of Oracle and/or its affiliates.
113.11 -Other names may be trademarks of their respective owners.
113.12 -
113.13 -
113.14 -The contents of this file are subject to the terms of either the GNU
113.15 -General Public License Version 2 only ("GPL") or the Common
113.16 -Development and Distribution License("CDDL") (collectively, the
113.17 -"License"). You may not use this file except in compliance with the
113.18 -License. You can obtain a copy of the License at
113.19 -http://www.netbeans.org/cddl-gplv2.html
113.20 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
113.21 -specific language governing permissions and limitations under the
113.22 -License. When distributing the software, include this License Header
113.23 -Notice in each file and include the License file at
113.24 -nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
113.25 -particular file as subject to the "Classpath" exception as provided
113.26 -by Oracle in the GPL Version 2 section of the License file that
113.27 -accompanied this code. If applicable, add the following below the
113.28 -License Header, with the fields enclosed by brackets [] replaced by
113.29 -your own identifying information:
113.30 -"Portions Copyrighted [year] [name of copyright owner]"
113.31 -
113.32 -Contributor(s):
113.33 -
113.34 -The Original Software is NetBeans. The Initial Developer of the Original
113.35 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
113.36 -Microsystems, Inc. All Rights Reserved.
113.37 -
113.38 -If you wish your version of this file to be governed by only the CDDL
113.39 -or only the GPL Version 2, indicate your decision by adding
113.40 -"[Contributor] elects to include this software in this distribution
113.41 -under the [CDDL or GPL Version 2] license." If you do not indicate a
113.42 -single choice of license, a recipient has the option to distribute
113.43 -your version of this file under either the CDDL, the GPL Version 2 or
113.44 -to extend the choice of license to its licensees as provided above.
113.45 -However, if you add GPL Version 2 code and therefore, elected the GPL
113.46 -Version 2 license, then the option applies only if the new code is
113.47 -made subject to such option by the copyright holder.
113.48 --->
113.49 -
113.50 -<!DOCTYPE library PUBLIC "-//NetBeans//DTD Library Declaration 1.0//EN" "http://www.netbeans.org/dtds/library-declaration-1_0.dtd">
113.51 -
113.52 -<library version="1.0">
113.53 - <name>beans-binding</name>
113.54 - <type>j2se</type>
113.55 - <localizing-bundle>org.netbeans.modules.form.resources.Bundle</localizing-bundle>
113.56 - <volume>
113.57 - <type>classpath</type>
113.58 - <resource>jar:nbinst://org.jdesktop.beansbinding/modules/ext/beansbinding-1.2.1.jar!/</resource>
113.59 - </volume>
113.60 - <volume>
113.61 - <type>javadoc</type>
113.62 - <resource>jar:nbinst://org.jdesktop.beansbinding/docs/beansbinding-1.2.1-doc.zip!/</resource>
113.63 - </volume>
113.64 - <volume>
113.65 - <type>maven-pom</type>
113.66 - <resource>http://download.java.net/maven/2/org/jdesktop/beansbinding/1.2.1/beansbinding-1.2.1.pom</resource>
113.67 - <!--
113.68 - The following reference is broken. The corresponding JAR doesn't contain
113.69 - META-INF/services directory. Hence, the special binding properties
113.70 - don't work with that JAR.
113.71 - <resource>http://repo2.maven.org/maven2/net/java/dev/beansbinding/beansbinding/1.2.1/beansbinding-1.2.1.pom</resource>-->
113.72 - </volume>
113.73 -</library>
114.1 --- a/form/src/org/netbeans/modules/form/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
114.2 +++ b/form/src/org/netbeans/modules/form/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
114.3 @@ -54,9 +54,6 @@
114.4 <file name="absolutelayout.xml" url="absolutelayout.xml">
114.5 <attr name="displayName" bundlevalue="org.netbeans.modules.form.resources.Bundle#absolutelayout"/>
114.6 </file>
114.7 - <file name="beans_binding.xml" url="beans_binding.xml">
114.8 - <attr name="displayName" bundlevalue="org.netbeans.modules.form.resources.Bundle#beans-binding"/>
114.9 - </file>
114.10 </folder>
114.11 </folder>
114.12 <folder name="Loaders">
114.13 @@ -458,13 +455,6 @@
114.14 </folder>
114.15
114.16 <folder name="Templates">
114.17 - <folder name="Privileged">
114.18 - <file name="JFrame.shadow">
114.19 - <attr name="originalFile" stringvalue="Templates/GUIForms/JFrame.java"/>
114.20 - <attr name="position" intvalue="400"/>
114.21 - </file>
114.22 - </folder>
114.23 -
114.24 <folder name="GUIForms">
114.25 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.form.resources.Bundle"/>
114.26 <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/form/resources/Forms.html"/>
115.1 --- a/html/src/org/netbeans/modules/html/mf-layer.xml Wed Jul 27 10:33:10 2011 +0200
115.2 +++ b/html/src/org/netbeans/modules/html/mf-layer.xml Wed Jul 27 10:35:25 2011 +0200
115.3 @@ -46,27 +46,6 @@
115.4 <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
115.5 <filesystem>
115.6
115.7 - <folder name="Templates">
115.8 - <folder name="Other">
115.9 - <file name="html.html" url="templates/html.html">
115.10 - <attr name="displayName" bundlevalue="org.netbeans.modules.html.Bundle#Templates/Other/html.html"/>
115.11 - <attr name="position" intvalue="100"/>
115.12 - <attr name="template" boolvalue="true"/>
115.13 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
115.14 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/html/TemplateHelp.html"/>
115.15 - <attr name="templateCategory" stringvalue="simple-files"/>
115.16 - </file>
115.17 - <file name="xhtml.xhtml" url="templates/xhtml.xhtml">
115.18 - <attr name="displayName" bundlevalue="org.netbeans.modules.html.Bundle#Templates/Other/xhtml.xhtml"/>
115.19 - <attr name="position" intvalue="200"/>
115.20 - <attr name="template" boolvalue="true"/>
115.21 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
115.22 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/html/XhtmlTemplateHelp.html"/>
115.23 - <attr name="templateCategory" stringvalue="simple-files"/>
115.24 - </file>
115.25 - </folder>
115.26 - </folder>
115.27 -
115.28 <folder name="Services">
115.29 <folder name="MIMEResolver">
115.30 <file name="html.xml" url="resolver.xml">
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
116.2 +++ b/html/src/org/netbeans/modules/html/package-info.java Wed Jul 27 10:35:25 2011 +0200
116.3 @@ -0,0 +1,46 @@
116.4 +/*
116.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
116.6 + *
116.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
116.8 + *
116.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
116.10 + * Other names may be trademarks of their respective owners.
116.11 + *
116.12 + * The contents of this file are subject to the terms of either the GNU
116.13 + * General Public License Version 2 only ("GPL") or the Common Development and
116.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
116.15 + * this file except in compliance with the License. You can obtain a copy of
116.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
116.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
116.18 + * governing permissions and limitations under the License. When distributing
116.19 + * the software, include this License Header Notice in each file and include
116.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
116.21 + * particular file as subject to the "Classpath" exception as provided by
116.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
116.23 + * this code. If applicable, add the following below the License Header, with
116.24 + * the fields enclosed by brackets [] replaced by your own identifying
116.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
116.26 + *
116.27 + * If you wish your version of this file to be governed by only the CDDL or
116.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
116.29 + * elects to include this software in this distribution under the [CDDL or GPL
116.30 + * Version 2] license." If you do not indicate a single choice of license, a
116.31 + * recipient has the option to distribute your version of this file under
116.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
116.33 + * licensees as provided above. However, if you add GPL Version 2 code and
116.34 + * therefore, elected the GPL Version 2 license, then the option applies only
116.35 + * if the new code is made subject to such option by the copyright holder.
116.36 + *
116.37 + * Contributor(s):
116.38 + *
116.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
116.40 + */
116.41 +
116.42 +@TemplateRegistrations({
116.43 + @TemplateRegistration(folder="Other", position=100, displayName="#Templates/Other/html.html", content="templates/html.html", scriptEngine="freemarker", category="simple-files", description="TemplateHelp.html"),
116.44 + @TemplateRegistration(folder="Other", position=200, displayName="#Templates/Other/xhtml.xhtml", content="templates/xhtml.xhtml", scriptEngine="freemarker", category="simple-files", description="XhtmlTemplateHelp.html")
116.45 +})
116.46 +package org.netbeans.modules.html;
116.47 +
116.48 +import org.netbeans.api.templates.TemplateRegistration;
116.49 +import org.netbeans.api.templates.TemplateRegistrations;
117.1 --- a/ide.ergonomics/src-ant/org/netbeans/modules/ide/ergonomics/ant/ExtractLayer.java Wed Jul 27 10:33:10 2011 +0200
117.2 +++ b/ide.ergonomics/src-ant/org/netbeans/modules/ide/ergonomics/ant/ExtractLayer.java Wed Jul 27 10:35:25 2011 +0200
117.3 @@ -452,8 +452,10 @@
117.4 String bundle = bundlevalue.substring(0, idx);
117.5 String key = bundlevalue.substring(idx + 1);
117.6 String bundlepath = bundle.replace('.', '/') + ".*properties";
117.7 + if (!additionalKeys.add(key)) {
117.8 + throw new IllegalStateException("key " + key + " from " + bundlepath + " was already defined among " + concat);
117.9 + }
117.10 concat.add(bundlepath);
117.11 - additionalKeys.add(key);
117.12 } else {
117.13 addResource(attributes.getValue("urlvalue"), false);
117.14 }
118.1 --- a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java Wed Jul 27 10:33:10 2011 +0200
118.2 +++ b/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java Wed Jul 27 10:35:25 2011 +0200
118.3 @@ -341,8 +341,8 @@
118.4 return true;
118.5 if (newOffset >= caretOffset) {
118.6 try {
118.7 - TokenSequence<JavaTokenId> ts = TokenHierarchy.get(component.getDocument()).tokenSequence(JavaTokenId.language());
118.8 - if (ts.move(offset) == 0 && ts.moveNext()) {
118.9 + TokenSequence<JavaTokenId> ts = SourceUtils.getJavaTokenSequence(TokenHierarchy.get(component.getDocument()), offset);
118.10 + if (ts != null && ts.move(offset) == 0 && ts.moveNext()) {
118.11 int len = newOffset - offset;
118.12 if (len >= 0 && (ts.token().id() == JavaTokenId.IDENTIFIER ||
118.13 ts.token().id().primaryCategory().startsWith("keyword") || //NOI18N
119.1 --- a/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/hibernate/hibernate_about.html Wed Jul 27 10:33:10 2011 +0200
119.2 +++ b/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/hibernate/hibernate_about.html Wed Jul 27 10:35:25 2011 +0200
119.3 @@ -56,6 +56,7 @@
119.4 <dt><a name="seealso">See Also</a></dt>
119.5 <dd><a href="hibernate_addsupport.html">Adding Hibernate Support to a Project</a></dd>
119.6 <dd><a href="hibernate_cfg.html">Creating the Hibernate Configuration File</a> </dd>
119.7 + <dd><a href="hibernate_uninstall.html">Removing Hibernate Support from the IDE</a> </dd>
119.8 </dl>
119.9
119.10 <hr>
120.1 --- a/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/hibernate/hibernate_addsupport.html Wed Jul 27 10:33:10 2011 +0200
120.2 +++ b/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/hibernate/hibernate_addsupport.html Wed Jul 27 10:35:25 2011 +0200
120.3 @@ -43,6 +43,7 @@
120.4 <dd><a href="hibernate_about.html">About Hibernate Support</a></dd>
120.5 <dd><a href="hibernate_cfg.html">Creating a Hibernate Configuration File</a></dd>
120.6 <dd><a href="hibernate_cfgedit.html">Editing the Hibernate Configuration File</a> </dd>
120.7 + <dd><a href="hibernate_uninstall.html">Removing Hibernate Support from the IDE</a> </dd>
120.8 </dl>
120.9
120.10 <hr><small><a href="../credits.html">Legal Notices</a></small>
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121.2 +++ b/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/hibernate/hibernate_uninstall.html Wed Jul 27 10:35:25 2011 +0200
121.3 @@ -0,0 +1,50 @@
121.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
121.5 +<!--
121.6 +* Copyright © 2009 Sun Microsystems, Inc. All rights reserved.
121.7 +* Use is subject to license terms.
121.8 +-->
121.9 +<html>
121.10 +<head>
121.11 +<meta http-equiv="content-type" content="text/html; charset=UTF-8">
121.12 + <title>Removing Hibernate Support from the IDE</title>
121.13 + <link href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css"
121.14 + rel="StyleSheet" type="text/css">
121.15 + </head>
121.16 +
121.17 + <body>
121.18 + <h2>Removing Hibernate Support from the IDE</h2>
121.19 +
121.20 + <p><small><a href="#seealso">See Also</a></small></p>
121.21 +
121.22 + <p>Hibernate support for various Java-based applications, such as
121.23 + Java SE, EJB, and web applications is enabled by default in the IDE.
121.24 + You can use the Plugins manager to uninstall the Hibernate plugin to
121.25 + remove the Hibernate libraries and Hibernate-related wizards from the IDE.
121.26 + </p>
121.27 +
121.28 +
121.29 + <p><strong>To remove Hibernate support and the Hibernate libraries from the IDE, perform the following steps.</strong></p>
121.30 +
121.31 + <ol>
121.32 + <li>Choose Tools & Plugins from the main menu.</li>
121.33 + <li>Select the Installed tab in the Plugins manager.</li>
121.34 + <li>Select Hibernate in the left pane of the Plugins manager.</li>
121.35 + <li>Click Uninstall and follow the steps in the Uninstallation wizard.</li>
121.36 + </ol>
121.37 + <p>To finish uninstalling the Hibernate plugin you will need to restart the IDE.</p>
121.38 +
121.39 + <p>You can reinstall the Hibernate plugin from the Available Plugins tab of the Plugins manager.</p>
121.40 +
121.41 + <dl>
121.42 + <dt><a name="seealso">See Also</a></dt>
121.43 + <dd><a href="hibernate_about.html">About Hibernate Support</a></dd>
121.44 + <dd><a href="hibernate_addsupport.html">Adding Hibernate Support to a Project</a></dd>
121.45 + <dd><a href="hibernate_cfg.html">Creating a Hibernate Configuration File</a></dd>
121.46 + <dd><a href="hibernate_cfgedit.html">Editing the Hibernate Configuration File</a> </dd>
121.47 + </dl>
121.48 +
121.49 + <hr><small><a href="../credits.html">Legal Notices</a></small>
121.50 + <table cellpadding="20" border="0"><tr><td> </td></tr></table>
121.51 + </body>
121.52 +</html>
121.53 +
122.1 --- a/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/javadev-map.jhm Wed Jul 27 10:33:10 2011 +0200
122.2 +++ b/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/javadev-map.jhm Wed Jul 27 10:35:25 2011 +0200
122.3 @@ -524,6 +524,7 @@
122.4 <mapID target="hibernate_hql" url="hibernate/hibernate_hql.html" />
122.5 <mapID target="hibernate_map" url="hibernate/hibernate_mapping.html" />
122.6 <mapID target="hibernate_workingwith" url="hibernate/hibernate_workingwith.html" />
122.7 + <mapID target="hibernate_uninstall" url="hibernate/hibernate_uninstall.html" />
122.8
122.9 <!-- Hibernate topics CSH -->
122.10
123.1 --- a/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/javadev-toc.xml Wed Jul 27 10:33:10 2011 +0200
123.2 +++ b/java.helpset/javahelp/org/netbeans/modules/java/helpset/docs/javadev-toc.xml Wed Jul 27 10:35:25 2011 +0200
123.3 @@ -203,6 +203,7 @@
123.4 <tocitem text="Generating Hibernate Mapping Files and POJOs from a Database" target="hibernate_fromdb"/>
123.5 <tocitem text="Using the Hibernate Query Language Editor" target="hibernate_hql"/>
123.6 <tocitem text="Creating a Hibernate Utility Helper File" target="hibernate_util"/>
123.7 + <tocitem text="Removing Hibernate Support from the IDE" target="hibernate_uninstall"/>
123.8 </tocitem>
123.9 <tocitem text="Working with the Spring Framework">
123.10 <tocitem text="About Spring Framework Support" target="spring.framework.about"/>
124.1 --- a/java.hints/src/org/netbeans/modules/java/hints/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
124.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
124.3 @@ -439,3 +439,8 @@
124.4
124.5 LBL_WarnHiddenStaticFields=Warn when the hidden field is static
124.6 TP_WarnHiddenStaticFields=Whether the hint should warn when the hidden field is static
124.7 +
124.8 +DN_org.netbeans.modules.java.hints.RemoveUnnecessaryReturn=Remove Unnecessary Return Statement
124.9 +DESC_org.netbeans.modules.java.hints.RemoveUnnecessaryReturn=Remove Unnecessary Return Statement
124.10 +ERR_UnnecessaryReturnStatement=Unnecessary return statement
124.11 +FIX_UnnecessaryReturnStatement=Remove unnecessary return statement
125.1 --- a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java Wed Jul 27 10:33:10 2011 +0200
125.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java Wed Jul 27 10:35:25 2011 +0200
125.3 @@ -66,7 +66,7 @@
125.4 @Hint(category="general", id="org.netbeans.modules.java.hints.EqualsMethodHint", suppressWarnings="EqualsWhichDoesntCheckParameterClass", options=Options.QUERY)
125.5 public class EqualsMethodHint {
125.6
125.7 - @TriggerPattern(value="public boolean equals(java.lang.Object $param) { $statements$; }")
125.8 + @TriggerPattern(value="$mods$ boolean equals(java.lang.Object $param) { $statements$; }")
125.9 public static ErrorDescription run(HintContext ctx) {
125.10 TreePath paramPath = ctx.getVariables().get("$param");
125.11
126.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
126.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/RemoveUnnecessaryReturn.java Wed Jul 27 10:35:25 2011 +0200
126.3 @@ -0,0 +1,112 @@
126.4 +/*
126.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
126.6 + *
126.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
126.8 + *
126.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
126.10 + * Other names may be trademarks of their respective owners.
126.11 + *
126.12 + * The contents of this file are subject to the terms of either the GNU
126.13 + * General Public License Version 2 only ("GPL") or the Common Development and
126.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
126.15 + * this file except in compliance with the License. You can obtain a copy of
126.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
126.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
126.18 + * governing permissions and limitations under the License. When distributing
126.19 + * the software, include this License Header Notice in each file and include
126.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
126.21 + * particular file as subject to the "Classpath" exception as provided by
126.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
126.23 + * this code. If applicable, add the following below the License Header, with
126.24 + * the fields enclosed by brackets [] replaced by your own identifying
126.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
126.26 + *
126.27 + * If you wish your version of this file to be governed by only the CDDL or
126.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
126.29 + * elects to include this software in this distribution under the [CDDL or GPL
126.30 + * Version 2] license." If you do not indicate a single choice of license, a
126.31 + * recipient has the option to distribute your version of this file under
126.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
126.33 + * licensees as provided above. However, if you add GPL Version 2 code and
126.34 + * therefore, elected the GPL Version 2 license, then the option applies only
126.35 + * if the new code is made subject to such option by the copyright holder.
126.36 + *
126.37 + * Contributor(s):
126.38 + *
126.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
126.40 + */
126.41 +package org.netbeans.modules.java.hints;
126.42 +
126.43 +import com.sun.source.tree.BlockTree;
126.44 +import com.sun.source.tree.CaseTree;
126.45 +import com.sun.source.tree.MethodTree;
126.46 +import com.sun.source.tree.StatementTree;
126.47 +import com.sun.source.tree.SwitchTree;
126.48 +import com.sun.source.tree.Tree;
126.49 +import com.sun.source.tree.Tree.Kind;
126.50 +import com.sun.source.util.TreePath;
126.51 +import java.util.List;
126.52 +import javax.lang.model.type.TypeKind;
126.53 +import javax.lang.model.type.TypeMirror;
126.54 +import org.netbeans.api.java.source.TreeUtilities;
126.55 +import org.netbeans.modules.java.hints.errors.Utilities;
126.56 +import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
126.57 +import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
126.58 +import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
126.59 +import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
126.60 +import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
126.61 +import org.netbeans.spi.editor.hints.ErrorDescription;
126.62 +import org.openide.util.NbBundle;
126.63 +
126.64 +/**
126.65 + *
126.66 + * @author lahvac
126.67 + */
126.68 +@Hint(category="general")
126.69 +public class RemoveUnnecessaryReturn {
126.70 +
126.71 + @TriggerPattern("return $val$;")
126.72 + public static ErrorDescription hint(HintContext ctx) {
126.73 + TreePath tp = ctx.getPath();
126.74 +
126.75 + OUTER: while (tp != null && !TreeUtilities.CLASS_TREE_KINDS.contains(tp.getLeaf().getKind())) {
126.76 + Tree current = tp.getLeaf();
126.77 + List<? extends StatementTree> statements;
126.78 +
126.79 + tp = tp.getParentPath();
126.80 +
126.81 + switch (tp.getLeaf().getKind()) {
126.82 + case METHOD:
126.83 + MethodTree mt = (MethodTree) tp.getLeaf();
126.84 + TypeMirror tm = ctx.getInfo().getTrees().getTypeMirror(new TreePath(tp, mt.getReturnType()));
126.85 +
126.86 + if (tm == null || tm.getKind() != TypeKind.VOID) return null;
126.87 + break OUTER;
126.88 + case BLOCK: statements = ((BlockTree) tp.getLeaf()).getStatements(); break;
126.89 + case CASE: {
126.90 + boolean exits = Utilities.exitsFromAllBranchers(ctx.getInfo(), tp);
126.91 +
126.92 + if (tp.getParentPath().getLeaf().getKind() == Kind.SWITCH) {
126.93 + List<? extends CaseTree> cases = ((SwitchTree) tp.getParentPath().getLeaf()).getCases();
126.94 + exits |= cases.get(cases.size() - 1) == tp.getLeaf();
126.95 + }
126.96 +
126.97 + if (!exits) return null;
126.98 +
126.99 + statements = ((CaseTree) tp.getLeaf()).getStatements();
126.100 + break;
126.101 + }
126.102 + default: continue OUTER;
126.103 + }
126.104 +
126.105 + assert !statements.isEmpty();
126.106 +
126.107 + if (statements.get(statements.size() - 1) != current) return null;
126.108 + }
126.109 +
126.110 + String displayName = NbBundle.getMessage(RemoveUnnecessaryReturn.class, "ERR_UnnecessaryReturnStatement");
126.111 + String fixDisplayName = NbBundle.getMessage(RemoveUnnecessaryReturn.class, "FIX_UnnecessaryReturnStatement");
126.112 +
126.113 + return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), displayName, JavaFix.removeFromParent(ctx, fixDisplayName, ctx.getPath()));
126.114 + }
126.115 +}
127.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/AnnotationsNotRuntime.java Wed Jul 27 10:33:10 2011 +0200
127.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/AnnotationsNotRuntime.java Wed Jul 27 10:35:25 2011 +0200
127.3 @@ -58,6 +58,7 @@
127.4 import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
127.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
127.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
127.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
127.8 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
127.9 import org.netbeans.spi.editor.hints.ErrorDescription;
127.10 import org.openide.util.NbBundle;
127.11 @@ -66,7 +67,7 @@
127.12 *
127.13 * @author lahvac
127.14 */
127.15 -@Hint(category="bugs", suppressWarnings="ReflectionForUnavailableAnnotation")
127.16 +@Hint(category="bugs", suppressWarnings="ReflectionForUnavailableAnnotation", options=Options.QUERY)
127.17 public class AnnotationsNotRuntime {
127.18
127.19 @TriggerPattern(value="$el.isAnnotationPresent($annotation.class)",
128.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/CastVSInstanceOf.java Wed Jul 27 10:33:10 2011 +0200
128.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/CastVSInstanceOf.java Wed Jul 27 10:35:25 2011 +0200
128.3 @@ -49,6 +49,7 @@
128.4 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
128.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPatterns;
128.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
128.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
128.8 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
128.9 import org.netbeans.spi.editor.hints.ErrorDescription;
128.10 import org.openide.util.NbBundle;
128.11 @@ -57,7 +58,7 @@
128.12 *
128.13 * @author lahvac
128.14 */
128.15 -@Hint(category="bugs", suppressWarnings="CastConflictsWithInstanceof")
128.16 +@Hint(category="bugs", suppressWarnings="CastConflictsWithInstanceof", options=Options.QUERY)
128.17 public class CastVSInstanceOf {
128.18
128.19 @TriggerPatterns({
129.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/CollectionRemove.java Wed Jul 27 10:33:10 2011 +0200
129.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/CollectionRemove.java Wed Jul 27 10:35:25 2011 +0200
129.3 @@ -71,6 +71,7 @@
129.4 import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
129.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
129.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
129.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
129.8 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
129.9 import org.netbeans.modules.java.hints.jackpot.spi.support.OneCheckboxCustomizerProvider;
129.10 import org.netbeans.spi.editor.hints.ErrorDescription;
129.11 @@ -83,7 +84,8 @@
129.12 @Hint(id="org.netbeans.modules.java.hints.bugs.CollectionRemove",
129.13 category="bugs",
129.14 customizerProvider=CollectionRemoveCustomizerImpl.class,
129.15 - suppressWarnings={CollectionRemove.SUPPRESS_WARNING_KEY, "", "collection-remove"})
129.16 + suppressWarnings={CollectionRemove.SUPPRESS_WARNING_KEY, "", "collection-remove"},
129.17 + options=Options.QUERY)
129.18 public class CollectionRemove {
129.19
129.20 static final String SUPPRESS_WARNING_KEY = "element-type-mismatch";
130.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/EqualsHint.java Wed Jul 27 10:33:10 2011 +0200
130.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/EqualsHint.java Wed Jul 27 10:35:25 2011 +0200
130.3 @@ -53,6 +53,7 @@
130.4 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
130.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPatterns;
130.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
130.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
130.8 import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
130.9 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
130.10 import org.netbeans.modules.java.hints.jackpot.spi.support.OneCheckboxCustomizerProvider;
130.11 @@ -136,7 +137,7 @@
130.12 return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), displayName, arrays, instance);
130.13 }
130.14
130.15 - @Hint(id="org.netbeans.modules.java.hints.EqualsHint", category="bugs", customizerProvider=CustomizerProviderImpl.class, suppressWarnings="IncompatibleEquals")
130.16 + @Hint(id="org.netbeans.modules.java.hints.EqualsHint", category="bugs", customizerProvider=CustomizerProviderImpl.class, suppressWarnings="IncompatibleEquals", options=Options.QUERY)
130.17 @TriggerPattern(value="$this.equals($par)",
130.18 constraints={
130.19 @Constraint(variable="$this", type="java.lang.Object"),
131.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java Wed Jul 27 10:33:10 2011 +0200
131.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java Wed Jul 27 10:35:25 2011 +0200
131.3 @@ -60,6 +60,7 @@
131.4 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
131.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPatterns;
131.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
131.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
131.8 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
131.9 import org.netbeans.spi.editor.hints.ErrorDescription;
131.10 import org.openide.util.NbBundle;
131.11 @@ -68,7 +69,7 @@
131.12 *
131.13 * @author lahvac
131.14 */
131.15 -@Hint(category="bugs", suppressWarnings="MalformedRegexp")
131.16 +@Hint(category="bugs", suppressWarnings="MalformedRegexp", options=Options.QUERY)
131.17 public class Regexp {
131.18
131.19 @TriggerPatterns({
132.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java Wed Jul 27 10:33:10 2011 +0200
132.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java Wed Jul 27 10:35:25 2011 +0200
132.3 @@ -65,6 +65,7 @@
132.4 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
132.5 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPatterns;
132.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
132.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
132.8 import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
132.9 import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
132.10 import org.netbeans.spi.editor.hints.ErrorDescription;
132.11 @@ -91,7 +92,7 @@
132.12 return ErrorDescriptionFactory.forTree(ctx, constant, displayName, fix);
132.13 }
132.14
132.15 - @Hint(category="bugs", suppressWarnings="ResultOfObjectAllocationIgnored")
132.16 + @Hint(category="bugs", suppressWarnings="ResultOfObjectAllocationIgnored", options=Options.QUERY)
132.17 //TODO: anonymous innerclasses?
132.18 @TriggerPatterns({
132.19 @TriggerPattern(value="new $type($params$);"),
132.20 @@ -103,7 +104,7 @@
132.21 return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), displayName);
132.22 }
132.23
132.24 - @Hint(category="bugs", suppressWarnings="SuspiciousSystemArraycopy")
132.25 + @Hint(category="bugs", suppressWarnings="SuspiciousSystemArraycopy", options=Options.QUERY)
132.26 @TriggerPattern(value="java.lang.System.arraycopy($src, $srcPos, $dest, $destPos, $length)")
132.27 public static List<ErrorDescription> systemArrayCopy(HintContext ctx) {
132.28 List<ErrorDescription> result = new LinkedList<ErrorDescription>();
132.29 @@ -146,7 +147,7 @@
132.30 return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), displayName, fix);
132.31 }
132.32
132.33 - @Hint(category="bugs", suppressWarnings="UseOfIndexZeroInJDBCResultSet")
132.34 + @Hint(category="bugs", suppressWarnings="UseOfIndexZeroInJDBCResultSet", options=Options.QUERY)
132.35 @TriggerPattern(value="$set.$method($columnIndex, $other$)",
132.36 constraints={
132.37 @Constraint(variable="$set", type="java.sql.ResultSet"),
133.1 --- a/java.hints/src/org/netbeans/modules/java/hints/bugs/UnusedAssignmentOrBranch.java Wed Jul 27 10:33:10 2011 +0200
133.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/UnusedAssignmentOrBranch.java Wed Jul 27 10:35:25 2011 +0200
133.3 @@ -76,6 +76,7 @@
133.4 import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerTreeKind;
133.5 import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
133.6 import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
133.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Options;
133.8 import org.netbeans.modules.java.hints.options.HintsSettings;
133.9 import org.netbeans.spi.editor.highlighting.HighlightsLayer;
133.10 import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory;
133.11 @@ -241,13 +242,13 @@
133.12 return p.getBoolean(ENABLED_KEY, true);
133.13 }
133.14
133.15 - @Hint(category="bugs", id=UNUSED_ASSIGNMENT_ID)
133.16 + @Hint(category="bugs", id=UNUSED_ASSIGNMENT_ID, options={Options.NO_BATCH, Options.QUERY})
133.17 @TriggerTreeKind(Tree.Kind.COMPILATION_UNIT)
133.18 public static ErrorDescription unusedAssignment(HintContext ctx) {
133.19 return null;
133.20 }
133.21
133.22 - @Hint(category="bugs", id=DEAD_BRANCH_ID)
133.23 + @Hint(category="bugs", id=DEAD_BRANCH_ID, options={Options.NO_BATCH, Options.QUERY})
133.24 @TriggerTreeKind(Tree.Kind.COMPILATION_UNIT)
133.25 public static ErrorDescription deadBranch(HintContext ctx) {
133.26 return null;
134.1 --- a/java.hints/src/org/netbeans/modules/java/hints/errors/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
134.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/errors/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
134.3 @@ -195,3 +195,5 @@
134.4 FIX_VarArgsCast=Cast {0} to {1}
134.5 SurroundWithTryCatchLog.rethrowRuntime.text=Use throw new RuntimeException(...)
134.6 SurroundWithTryCatchLog.rethrow.text=Use throw ...
134.7 +DN_ChangeMethodReturnType=Change Method Return Type
134.8 +FIX_ChangeMethodReturnType=Change method return type to {0}
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
135.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/errors/ChangeMethodReturnType.java Wed Jul 27 10:35:25 2011 +0200
135.3 @@ -0,0 +1,152 @@
135.4 +/*
135.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
135.6 + *
135.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
135.8 + *
135.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
135.10 + * Other names may be trademarks of their respective owners.
135.11 + *
135.12 + * The contents of this file are subject to the terms of either the GNU
135.13 + * General Public License Version 2 only ("GPL") or the Common Development and
135.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
135.15 + * this file except in compliance with the License. You can obtain a copy of
135.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
135.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
135.18 + * governing permissions and limitations under the License. When distributing
135.19 + * the software, include this License Header Notice in each file and include
135.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
135.21 + * particular file as subject to the "Classpath" exception as provided by
135.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
135.23 + * this code. If applicable, add the following below the License Header, with
135.24 + * the fields enclosed by brackets [] replaced by your own identifying
135.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
135.26 + *
135.27 + * If you wish your version of this file to be governed by only the CDDL or
135.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
135.29 + * elects to include this software in this distribution under the [CDDL or GPL
135.30 + * Version 2] license." If you do not indicate a single choice of license, a
135.31 + * recipient has the option to distribute your version of this file under
135.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
135.33 + * licensees as provided above. However, if you add GPL Version 2 code and
135.34 + * therefore, elected the GPL Version 2 license, then the option applies only
135.35 + * if the new code is made subject to such option by the copyright holder.
135.36 + *
135.37 + * Contributor(s):
135.38 + *
135.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
135.40 + */
135.41 +package org.netbeans.modules.java.hints.errors;
135.42 +
135.43 +import com.sun.source.tree.MethodTree;
135.44 +import com.sun.source.tree.Tree.Kind;
135.45 +import com.sun.source.util.TreePath;
135.46 +import java.util.Arrays;
135.47 +import java.util.Collections;
135.48 +import java.util.HashSet;
135.49 +import java.util.List;
135.50 +import java.util.Set;
135.51 +import javax.lang.model.type.ErrorType;
135.52 +import javax.lang.model.type.TypeKind;
135.53 +import javax.lang.model.type.TypeMirror;
135.54 +import org.netbeans.api.java.source.CompilationInfo;
135.55 +import org.netbeans.api.java.source.TreeMaker;
135.56 +import org.netbeans.api.java.source.TreeUtilities;
135.57 +import org.netbeans.api.java.source.TypeMirrorHandle;
135.58 +import org.netbeans.api.java.source.WorkingCopy;
135.59 +import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
135.60 +import org.netbeans.modules.java.hints.spi.ErrorRule;
135.61 +import org.netbeans.spi.editor.hints.Fix;
135.62 +import org.openide.util.NbBundle;
135.63 +
135.64 +/**
135.65 + *
135.66 + * @author lahvac
135.67 + */
135.68 +public class ChangeMethodReturnType implements ErrorRule<Void> {
135.69 +
135.70 + private final static Set<String> CODES = new HashSet<String>(Arrays.asList(
135.71 + "compiler.err.cant.ret.val.from.meth.decl.void",
135.72 + "compiler.err.prob.found.req"
135.73 + ));
135.74 +
135.75 + @Override
135.76 + public Set<String> getCodes() {
135.77 + return CODES;
135.78 + }
135.79 +
135.80 + @Override
135.81 + public List<Fix> run(CompilationInfo info, String diagnosticKey, int offset, TreePath treePath, Data<Void> data) {
135.82 + if (treePath.getParentPath().getLeaf().getKind() != Kind.RETURN) return null;
135.83 +
135.84 + TreePath method = null;
135.85 + TreePath tp = treePath;
135.86 +
135.87 + while (tp != null && !TreeUtilities.CLASS_TREE_KINDS.contains(tp.getLeaf().getKind())) {
135.88 + if (tp.getLeaf().getKind() == Kind.METHOD) {
135.89 + method = tp;
135.90 + break;
135.91 + }
135.92 +
135.93 + tp = tp.getParentPath();
135.94 + }
135.95 +
135.96 + if (method == null) return null;
135.97 +
135.98 + TypeMirror targetType = info.getTrees().getTypeMirror(treePath);
135.99 +
135.100 + if (targetType != null && targetType.getKind() == TypeKind.ERROR) {
135.101 + targetType = info.getTrees().getOriginalType((ErrorType) targetType);
135.102 + }
135.103 +
135.104 + if (targetType == null || targetType.getKind() == /*XXX:*/TypeKind.ERROR) return null;
135.105 +
135.106 + return Collections.singletonList(JavaFix.toEditorFix(new FixImpl(info, method, TypeMirrorHandle.create(targetType), info.getTypeUtilities().getTypeName(targetType).toString())));
135.107 + }
135.108 +
135.109 + @Override
135.110 + public String getId() {
135.111 + return ChangeMethodReturnType.class.getName();
135.112 + }
135.113 +
135.114 + @Override
135.115 + public String getDisplayName() {
135.116 + return NbBundle.getMessage(ChangeMethodReturnType.class, "DN_ChangeMethodReturnType");
135.117 + }
135.118 +
135.119 + @Override
135.120 + public void cancel() {}
135.121 +
135.122 + private static final class FixImpl extends JavaFix {
135.123 +
135.124 + private final TypeMirrorHandle targetTypeHandle;
135.125 + private final String targetTypeDN;
135.126 +
135.127 + public FixImpl(CompilationInfo info, TreePath tp, TypeMirrorHandle targetTypeHandle, String targetTypeDN) {
135.128 + super(info, tp);
135.129 + this.targetTypeHandle = targetTypeHandle;
135.130 + this.targetTypeDN = targetTypeDN;
135.131 + }
135.132 +
135.133 + @Override
135.134 + protected String getText() {
135.135 + return NbBundle.getMessage(ChangeMethodReturnType.class, "FIX_ChangeMethodReturnType", targetTypeDN);
135.136 + }
135.137 +
135.138 + @Override
135.139 + protected void performRewrite(WorkingCopy wc, TreePath tp, boolean canShowUI) {
135.140 + TypeMirror targetType = targetTypeHandle.resolve(wc);
135.141 +
135.142 + if (targetType == null) {
135.143 + //XXX: log
135.144 + return ;
135.145 + }
135.146 +
135.147 + MethodTree mt = (MethodTree) tp.getLeaf();
135.148 + TreeMaker make = wc.getTreeMaker();
135.149 +
135.150 + wc.rewrite(mt.getReturnType(), make.Type(targetType));
135.151 + }
135.152 +
135.153 + }
135.154 +
135.155 +}
136.1 --- a/java.hints/src/org/netbeans/modules/java/hints/jackpot/spi/JavaFix.java Wed Jul 27 10:33:10 2011 +0200
136.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/jackpot/spi/JavaFix.java Wed Jul 27 10:35:25 2011 +0200
136.3 @@ -1245,6 +1245,9 @@
136.4
136.5 wc.rewrite(tryTree, newTry);
136.6 break;
136.7 + default:
136.8 + wc.rewrite(tp.getLeaf(), make.Block(Collections.<StatementTree>emptyList(), false));
136.9 + break;
136.10 }
136.11 }
136.12
137.1 --- a/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
137.2 +++ b/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
137.3 @@ -206,6 +206,7 @@
137.4 <file name="org-netbeans-modules-java-hints-errors-NotInitializedVariable.instance"/>
137.5 <file name="org-netbeans-modules-java-hints-errors-ConvertToDiamond.instance"/>
137.6 <file name="org-netbeans-modules-java-hints-errors-VarArgsCast.instance"/>
137.7 + <file name="org-netbeans-modules-java-hints-errors-ChangeMethodReturnType.instance"/>
137.8 <file name="org-netbeans-modules-java-hints-SerialVersionUID.instance"/>
137.9 <folder name="text">
137.10 <folder name="x-jsp">
138.1 --- a/java.hints/test/unit/data/goldenfiles/org/netbeans/modules/java/hints/errors/ErrorHintsTest/testAddCastHint7-hints.pass Wed Jul 27 10:33:10 2011 +0200
138.2 +++ b/java.hints/test/unit/data/goldenfiles/org/netbeans/modules/java/hints/errors/ErrorHintsTest/testAddCastHint7-hints.pass Wed Jul 27 10:35:25 2011 +0200
138.3 @@ -1,1 +1,2 @@
138.4 Cast ...o to String
138.5 +FIX_ChangeMethodReturnType Object
139.1 --- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/Bundle_test.properties Wed Jul 27 10:33:10 2011 +0200
139.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/Bundle_test.properties Wed Jul 27 10:35:25 2011 +0200
139.3 @@ -107,3 +107,4 @@
139.4 HNT_AnnotationAsSuperInterface=HNT_AnnotationAsSuperInterface ({0})
139.5
139.6 ERR_AssignmentToItself=ERR_AssignmentToItself
139.7 +ERR_UnnecessaryReturnStatement=ERR_UnnecessaryReturnStatement
140.1 --- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/EqualsMethodHintTest.java Wed Jul 27 10:33:10 2011 +0200
140.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/EqualsMethodHintTest.java Wed Jul 27 10:35:25 2011 +0200
140.3 @@ -108,4 +108,15 @@
140.4
140.5 }
140.6
140.7 + public void testAnnotations() throws Exception {
140.8 + performAnalysisTest("test/Test.java",
140.9 + "package test;\n" +
140.10 + "public class Test {\n" +
140.11 + " @SuppressWarnings(\"a\") public boolean equals(Object o) {\n" +
140.12 + " return true;" +
140.13 + " }" +
140.14 + "}\n",
140.15 + "2:42-2:48:verifier:ENC");
140.16 +
140.17 + }
140.18 }
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
141.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/RemoveUnnecessaryReturnTest.java Wed Jul 27 10:35:25 2011 +0200
141.3 @@ -0,0 +1,159 @@
141.4 +/*
141.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
141.6 + *
141.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
141.8 + *
141.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
141.10 + * Other names may be trademarks of their respective owners.
141.11 + *
141.12 + * The contents of this file are subject to the terms of either the GNU
141.13 + * General Public License Version 2 only ("GPL") or the Common Development and
141.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
141.15 + * this file except in compliance with the License. You can obtain a copy of
141.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
141.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
141.18 + * governing permissions and limitations under the License. When distributing
141.19 + * the software, include this License Header Notice in each file and include
141.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
141.21 + * particular file as subject to the "Classpath" exception as provided by
141.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
141.23 + * this code. If applicable, add the following below the License Header, with
141.24 + * the fields enclosed by brackets [] replaced by your own identifying
141.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
141.26 + *
141.27 + * If you wish your version of this file to be governed by only the CDDL or
141.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
141.29 + * elects to include this software in this distribution under the [CDDL or GPL
141.30 + * Version 2] license." If you do not indicate a single choice of license, a
141.31 + * recipient has the option to distribute your version of this file under
141.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
141.33 + * licensees as provided above. However, if you add GPL Version 2 code and
141.34 + * therefore, elected the GPL Version 2 license, then the option applies only
141.35 + * if the new code is made subject to such option by the copyright holder.
141.36 + *
141.37 + * Contributor(s):
141.38 + *
141.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
141.40 + */
141.41 +package org.netbeans.modules.java.hints;
141.42 +
141.43 +import org.netbeans.modules.java.hints.jackpot.code.spi.TestBase;
141.44 +
141.45 +/**
141.46 + *
141.47 + * @author lahvac
141.48 + */
141.49 +public class RemoveUnnecessaryReturnTest extends TestBase {
141.50 +
141.51 + public RemoveUnnecessaryReturnTest(String name) {
141.52 + super(name, RemoveUnnecessaryReturn.class);
141.53 + }
141.54 +
141.55 + public void testSimple() throws Exception {
141.56 + performFixTest("test/Test.java",
141.57 + "package test;\n" +
141.58 + "public class Test {\n" +
141.59 + " public void test() {\n" +
141.60 + " return ;\n" +
141.61 + " }\n" +
141.62 + "}\n",
141.63 + "3:8-3:16:verifier:ERR_UnnecessaryReturnStatement",
141.64 + "FixImpl",
141.65 + ("package test;\n" +
141.66 + "public class Test {\n" +
141.67 + " public void test() {\n" +
141.68 + " }\n" +
141.69 + "}\n").replaceAll("[ \t\n]+", " "));
141.70 + }
141.71 +
141.72 + public void testIfNoBlock() throws Exception {
141.73 + performFixTest("test/Test.java",
141.74 + "package test;\n" +
141.75 + "public class Test {\n" +
141.76 + " public void test(boolean b) {\n" +
141.77 + " if (b) return ;\n" +
141.78 + " }\n" +
141.79 + "}\n",
141.80 + "3:15-3:23:verifier:ERR_UnnecessaryReturnStatement",
141.81 + "FixImpl",
141.82 + ("package test;\n" +
141.83 + "public class Test {\n" +
141.84 + " public void test(boolean b) {\n" +
141.85 + " if (b) { }\n" +
141.86 + " }\n" +
141.87 + "}\n").replaceAll("[ \t\n]+", " "));
141.88 + }
141.89 +
141.90 + public void testNeg1() throws Exception {
141.91 + performAnalysisTest("test/Test.java",
141.92 + "package test;\n" +
141.93 + "public class Test {\n" +
141.94 + " public void test(boolean b) {\n" +
141.95 + " if (b) { return ; }\n" +
141.96 + " System.err.println();\n" +
141.97 + " }\n" +
141.98 + "}\n");
141.99 + }
141.100 +
141.101 + public void testNeg2() throws Exception {
141.102 + performAnalysisTest("test/Test.java",
141.103 + "package test;\n" +
141.104 + "public class Test {\n" +
141.105 + " public void test(boolean b) {\n" +
141.106 + " switch (b) {\n" +
141.107 + " case true: if (b) { return ; }\n" +
141.108 + " System.err.println();\n" +
141.109 + " break;\n" +
141.110 + " }\n" +
141.111 + "}\n");
141.112 + }
141.113 +
141.114 + public void testNeg3() throws Exception {
141.115 + performAnalysisTest("test/Test.java",
141.116 + "package test;\n" +
141.117 + "public class Test {\n" +
141.118 + " public void test(boolean b) {\n" +
141.119 + " switch (b) {\n" +
141.120 + " case true: if (b) { return ; }\n" +
141.121 + " case false: System.err.println(); break;\n" +
141.122 + " }\n" +
141.123 + "}\n");
141.124 + }
141.125 +
141.126 + public void testNeg4() throws Exception {
141.127 + performAnalysisTest("test/Test.java",
141.128 + "package test;\n" +
141.129 + "public class Test {\n" +
141.130 + " public int test(boolean b) {\n" +
141.131 + " switch (b) {\n" +
141.132 + " case true: if (b) { return 1; }\n" +
141.133 + " case false: System.err.println(); break;\n" +
141.134 + " }\n" +
141.135 + "}\n");
141.136 + }
141.137 +
141.138 + public void testSwitchRemove() throws Exception {
141.139 + performAnalysisTest("test/Test.java",
141.140 + "package test;\n" +
141.141 + "public class Test {\n" +
141.142 + " public void test(boolean b) {\n" +
141.143 + " switch (b) {\n" +
141.144 + " case true: if (b) { return ; } else break;\n" +
141.145 + " case false: System.err.println(); break;\n" +
141.146 + " }\n" +
141.147 + "}\n",
141.148 + "4:32-4:40:verifier:ERR_UnnecessaryReturnStatement");
141.149 + }
141.150 +
141.151 + public void testLastCase() throws Exception {
141.152 + performAnalysisTest("test/Test.java",
141.153 + "package test;\n" +
141.154 + "public class Test {\n" +
141.155 + " public void test(boolean b) {\n" +
141.156 + " switch (b) {\n" +
141.157 + " case false: if (b) { return ; }\n" +
141.158 + " }\n" +
141.159 + "}\n",
141.160 + "4:33-4:41:verifier:ERR_UnnecessaryReturnStatement");
141.161 + }
141.162 +}
142.1 --- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/Bundle_test.properties Wed Jul 27 10:33:10 2011 +0200
142.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/Bundle_test.properties Wed Jul 27 10:35:25 2011 +0200
142.3 @@ -57,3 +57,4 @@
142.4 FIX_VarArgsCast=VarArgsCastFix:{1}
142.5 MSG_ChangeVariablesType=Change type of {0} to {1}
142.6 LBL_FIX_ChangeMethodParameters={0} to {1}
142.7 +FIX_ChangeMethodReturnType=FIX_ChangeMethodReturnType {0}
142.8 \ No newline at end of file
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
143.2 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ChangeMethodReturnTypeTest.java Wed Jul 27 10:35:25 2011 +0200
143.3 @@ -0,0 +1,85 @@
143.4 +/*
143.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
143.6 + *
143.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
143.8 + *
143.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
143.10 + * Other names may be trademarks of their respective owners.
143.11 + *
143.12 + * The contents of this file are subject to the terms of either the GNU
143.13 + * General Public License Version 2 only ("GPL") or the Common Development and
143.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
143.15 + * this file except in compliance with the License. You can obtain a copy of
143.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
143.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
143.18 + * governing permissions and limitations under the License. When distributing
143.19 + * the software, include this License Header Notice in each file and include
143.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
143.21 + * particular file as subject to the "Classpath" exception as provided by
143.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
143.23 + * this code. If applicable, add the following below the License Header, with
143.24 + * the fields enclosed by brackets [] replaced by your own identifying
143.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
143.26 + *
143.27 + * If you wish your version of this file to be governed by only the CDDL or
143.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
143.29 + * elects to include this software in this distribution under the [CDDL or GPL
143.30 + * Version 2] license." If you do not indicate a single choice of license, a
143.31 + * recipient has the option to distribute your version of this file under
143.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
143.33 + * licensees as provided above. However, if you add GPL Version 2 code and
143.34 + * therefore, elected the GPL Version 2 license, then the option applies only
143.35 + * if the new code is made subject to such option by the copyright holder.
143.36 + *
143.37 + * Contributor(s):
143.38 + *
143.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
143.40 + */
143.41 +package org.netbeans.modules.java.hints.errors;
143.42 +
143.43 +import com.sun.source.util.TreePath;
143.44 +import java.util.List;
143.45 +import org.netbeans.api.java.source.CompilationInfo;
143.46 +import org.netbeans.modules.java.hints.infrastructure.ErrorHintsTestBase;
143.47 +import org.netbeans.spi.editor.hints.Fix;
143.48 +import org.openide.util.NbBundle;
143.49 +
143.50 +/**
143.51 + *
143.52 + * @author lahvac
143.53 + */
143.54 +public class ChangeMethodReturnTypeTest extends ErrorHintsTestBase {
143.55 +
143.56 + public ChangeMethodReturnTypeTest(String name) {
143.57 + super(name);
143.58 + }
143.59 +
143.60 + public void testVoidToInt() throws Exception {
143.61 + performFixTest("test/Test.java",
143.62 + "package test; public class Test { private void t() { return 1|;} }",
143.63 + "FIX_ChangeMethodReturnType int",
143.64 + "package test; public class Test { private int t() { return 1;} }");
143.65 + }
143.66 +
143.67 + public void testStringToInt() throws Exception {
143.68 + performFixTest("test/Test.java",
143.69 + "package test; public class Test { private String t() { return 1|;} }",
143.70 + "FIX_ChangeMethodReturnType int",
143.71 + "package test; public class Test { private int t() { return 1;} }");
143.72 + }
143.73 +
143.74 + @Override
143.75 + protected List<Fix> computeFixes(CompilationInfo info, int pos, TreePath path) throws Exception {
143.76 + return new ChangeMethodReturnType().run(info, null, pos, path, null);
143.77 + }
143.78 +
143.79 + @Override
143.80 + protected String toDebugString(CompilationInfo info, Fix f) {
143.81 + return f.getText();
143.82 + }
143.83 +
143.84 + static {
143.85 + NbBundle.setBranding("test");
143.86 + }
143.87 +
143.88 +}
144.1 --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
144.2 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
144.3 @@ -48,43 +48,10 @@
144.4
144.5 <folder name="Templates">
144.6 <folder name="Project">
144.7 -
144.8 <folder name="Standard">
144.9 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.j2seproject.ui.wizards.Bundle"/>
144.10 + <attr name="displayName" bundlevalue="org.netbeans.modules.java.j2seproject.ui.wizards.Bundle#Templates/Project/Standard"/>
144.11 <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/desktop.html"/>
144.12 -
144.13 <attr name="position" intvalue="100"/>
144.14 - <file name="emptyJ2SE.xml">
144.15 - <attr name="position" intvalue="100"/>
144.16 - <attr name="template" boolvalue="true"/>
144.17 - <attr name="instantiatingIterator" newvalue="org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator"/>
144.18 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.j2seproject.ui.wizards.Bundle"/>
144.19 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png"/>
144.20 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/emptyProject.html"/>
144.21 - </file>
144.22 -
144.23 -
144.24 -
144.25 - <file name="emptyJ2SElibrary.xml">
144.26 - <attr name="position" intvalue="200"/>
144.27 - <attr name="template" boolvalue="true"/>
144.28 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator.library"/>
144.29 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.j2seproject.ui.wizards.Bundle"/>
144.30 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png"/>
144.31 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/emptyLibrary.html"/>
144.32 - </file>
144.33 -
144.34 -
144.35 -
144.36 - <file name="existingJ2SE.xml">
144.37 - <attr name="position" intvalue="300"/>
144.38 - <attr name="template" boolvalue="true"/>
144.39 - <attr name="templateWizardIterator" methodvalue="org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator.existing"/>
144.40 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.j2seproject.ui.wizards.Bundle"/>
144.41 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png"/>
144.42 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/j2seproject/ui/resources/existingProject.html"/>
144.43 - </file>
144.44 -
144.45 </folder>
144.46 </folder>
144.47 </folder>
145.1 --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
145.2 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
145.3 @@ -40,11 +40,7 @@
145.4 # Version 2 license, then the option applies only if the new code is
145.5 # made subject to such option by the copyright holder.
145.6
145.7 -#System file system
145.8 -Templates/Project/Standard/emptyJ2SE.xml=Java Application
145.9 -Templates/Project/Standard/emptyJ2SElibrary.xml=Java Class Library
145.10 Templates/Project/Standard=Java
145.11 -Templates/Project/Standard/existingJ2SE.xml= Java Project with Existing Sources
145.12 #New project wizard
145.13 TXT_DefaultPackageName=mypkg
145.14
146.1 --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/NewJ2SEProjectWizardIterator.java Wed Jul 27 10:33:10 2011 +0200
146.2 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/NewJ2SEProjectWizardIterator.java Wed Jul 27 10:35:25 2011 +0200
146.3 @@ -66,7 +66,9 @@
146.4 import org.openide.filesystems.FileLock;
146.5 import org.openide.filesystems.FileObject;
146.6 import org.openide.filesystems.FileUtil;
146.7 +import org.netbeans.api.templates.TemplateRegistration;
146.8 import org.openide.util.NbBundle;
146.9 +import org.openide.util.NbBundle.Messages;
146.10
146.11 /**
146.12 * Wizard to create a new J2SE project.
146.13 @@ -83,19 +85,24 @@
146.14
146.15 private WizardType type;
146.16
146.17 - /** Create a new wizard iterator. */
146.18 - public NewJ2SEProjectWizardIterator() {
146.19 - this(WizardType.APP);
146.20 - }
146.21 -
146.22 - public NewJ2SEProjectWizardIterator(WizardType type) {
146.23 + private NewJ2SEProjectWizardIterator(WizardType type) {
146.24 this.type = type;
146.25 }
146.26 -
146.27 +
146.28 + @TemplateRegistration(folder="Project/Standard", position=100, displayName="#template_app", iconBase="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", description="../resources/emptyProject.html")
146.29 + @Messages("template_app=Java Application")
146.30 + public static NewJ2SEProjectWizardIterator app() {
146.31 + return new NewJ2SEProjectWizardIterator(WizardType.APP);
146.32 + }
146.33 +
146.34 + @TemplateRegistration(folder="Project/Standard", position=200, displayName="#template_library", iconBase="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", description="../resources/emptyLibrary.html")
146.35 + @Messages("template_library=Java Class Library")
146.36 public static NewJ2SEProjectWizardIterator library() {
146.37 return new NewJ2SEProjectWizardIterator(WizardType.LIB);
146.38 }
146.39 -
146.40 +
146.41 + @TemplateRegistration(folder="Project/Standard", position=300, displayName="#template_existing", iconBase="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", description="../resources/existingProject.html")
146.42 + @Messages("template_existing=Java Project with Existing Sources")
146.43 public static NewJ2SEProjectWizardIterator existing() {
146.44 return new NewJ2SEProjectWizardIterator(WizardType.EXT);
146.45 }
147.1 --- a/java.project/apichanges.xml Wed Jul 27 10:33:10 2011 +0200
147.2 +++ b/java.project/apichanges.xml Wed Jul 27 10:35:25 2011 +0200
147.3 @@ -109,6 +109,21 @@
147.4 <!-- ACTUAL CHANGES BEGIN HERE: -->
147.5
147.6 <changes>
147.7 + <change id="JAVA_ICON">
147.8 + <api name="general"/>
147.9 + <summary>Added <code>JavaTemplates.JAVA_ICON</code></summary>
147.10 + <version major="1" minor="40"/>
147.11 + <date day="25" month="7" year="2011"/>
147.12 + <author login="jglick"/>
147.13 + <compatibility addition="yes"/>
147.14 + <description>
147.15 + <p>
147.16 + Added a constant for a Java template icon.
147.17 + </p>
147.18 + </description>
147.19 + <class package="org.netbeans.spi.java.project.support.ui.templates" name="JavaTemplates"/>
147.20 + <issue number="200175"/>
147.21 + </change>
147.22 <change id="BrokenReferencesSupport-showAlert">
147.23 <api name="general"/>
147.24 <summary>Added <code>showAlert</code> method into the<code>BrokenReferencesSupport</code></summary>
148.1 --- a/java.project/manifest.mf Wed Jul 27 10:33:10 2011 +0200
148.2 +++ b/java.project/manifest.mf Wed Jul 27 10:35:25 2011 +0200
148.3 @@ -3,7 +3,7 @@
148.4 OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
148.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
148.6 OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
148.7 -OpenIDE-Module-Specification-Version: 1.39
148.8 +OpenIDE-Module-Specification-Version: 1.40
148.9 OpenIDE-Module-Recommends: org.netbeans.spi.java.project.runner.JavaRunnerImplementation
148.10 AutoUpdate-Show-In-Client: false
148.11
149.1 --- a/java.project/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
149.2 +++ b/java.project/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
149.3 @@ -206,7 +206,9 @@
149.4 <code-name-base>org.openide.loaders</code-name-base>
149.5 <build-prerequisite/>
149.6 <compile-dependency/>
149.7 - <run-dependency/>
149.8 + <run-dependency>
149.9 + <specification-version>7.29</specification-version>
149.10 + </run-dependency>
149.11 </dependency>
149.12 <dependency>
149.13 <code-name-base>org.openide.modules</code-name-base>
150.1 --- a/java.project/src/org/netbeans/modules/java/project/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
150.2 +++ b/java.project/src/org/netbeans/modules/java/project/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
150.3 @@ -48,24 +48,7 @@
150.4 types which work with Java sources. Supplies the package view, package chooser \
150.5 for the New File wizard, etc.
150.6
150.7 -#layer
150.8 -Templates/Privileged/Package.shadow=Java Package
150.9 -Templates/Privileged/Main.shadow=Java Main Class
150.10 -Templates/Privileged/Class.shadow=Java Class
150.11 -
150.12 -Templates/Classes/Package=Java Package
150.13 Templates/Classes=Java
150.14 -Templates/Classes/Applet.java=Applet
150.15 -Templates/Classes/Class.java=Java Class
150.16 -Templates/Classes/Empty.java=Empty Java File
150.17 -Templates/Classes/Exception.java=Java Exception
150.18 -Templates/Classes/Interface.java=Java Interface
150.19 -Templates/Classes/JApplet.java=JApplet
150.20 -Templates/Classes/Main.java=Java Main Class
150.21 -Templates/Classes/Singleton.java=Java Singleton Class
150.22 -Templates/Classes/Enum.java=Java Enum
150.23 -Templates/Classes/AnnotationType.java=Java Annotation Type
150.24 -Templates/Classes/package-info.java=Java Package Info
150.25
150.26 LBL_BrokenLinksCustomizer_Fix=&Resolve...
150.27 LBL_BrokenLinksCustomizer_Description=&Description\:
150.28 @@ -88,7 +71,6 @@
150.29 ERR_JavaTargetChooser_InvalidPackage=The Package Name is not valid
150.30 ERR_JavaTargetChooser_InvalidClass=The Class Name is not valid
150.31 ERR_JavaTargetChooser_DefaultPackage=Warning: It is highly recommended that you do NOT place Java classes in the default package.
150.32 -ERR_JavaTargetChooser_WrongPlatform=Wrong source level of the project. You will NOT be able to compile this file since it contains JDK 1.5 features.
150.33 ERR_JavaTargetChooser_InvalidFolder=The Package is not a folder
150.34
150.35 INFO_JavaTargetChooser_ProvideClassName=Provide valid Java Class name
151.1 --- a/java.project/src/org/netbeans/modules/java/project/JavaTargetChooserPanel.java Wed Jul 27 10:33:10 2011 +0200
151.2 +++ b/java.project/src/org/netbeans/modules/java/project/JavaTargetChooserPanel.java Wed Jul 27 10:35:25 2011 +0200
151.3 @@ -48,6 +48,7 @@
151.4 import java.io.File;
151.5 import java.io.IOException;
151.6 import java.util.ArrayList;
151.7 +import java.util.Arrays;
151.8 import java.util.Iterator;
151.9 import java.util.List;
151.10 import java.util.StringTokenizer;
151.11 @@ -65,7 +66,9 @@
151.12 import org.openide.util.Exceptions;
151.13 import org.openide.util.HelpCtx;
151.14 import org.openide.util.NbBundle;
151.15 +import org.openide.util.NbBundle.Messages;
151.16 import org.openide.util.Utilities;
151.17 +import static org.netbeans.modules.java.project.Bundle.*;
151.18
151.19 /**
151.20 * @author Petr Hrebejk
151.21 @@ -114,6 +117,7 @@
151.22 return new HelpCtx(JavaTargetChooserPanel.class);
151.23 }
151.24
151.25 + @Messages("ERR_JavaTargetChooser_WrongPlatform=Wrong source level of the project. You will NOT be able to compile this file since it contains JDK 1.5 features.")
151.26 public boolean isValid() {
151.27 if (gui == null) {
151.28 setErrorMessage( null );
151.29 @@ -191,10 +195,12 @@
151.30 //Only warning, display it only if everything else is OK.
151.31 setErrorMessage( "ERR_JavaTargetChooser_DefaultPackage" );
151.32 }
151.33 - String templateSrcLev = (String) template.getAttribute("javac.source"); // NOI18N
151.34 - //Only warning, display it only if everything else id OK.
151.35 - if (specVersion != null && templateSrcLev != null && specVersion.compareTo(new SpecificationVersion(templateSrcLev)) < 0) {
151.36 - setErrorMessage("ERR_JavaTargetChooser_WrongPlatform"); // NOI18N
151.37 + String categories = (String) template.getAttribute("templateCategory"); // NOI18N
151.38 + if (categories != null && Arrays.asList(categories.split(",")).contains(NewJavaFileWizardIterator.JDK_5)) {
151.39 + //Only warning, display it only if everything else id OK.
151.40 + if (specVersion != null && specVersion.compareTo(JDK_14) <= 0) {
151.41 + wizard.getNotificationLineSupport().setErrorMessage(ERR_JavaTargetChooser_WrongPlatform());
151.42 + }
151.43 }
151.44
151.45 // this enables to display error messages from the bottom panel
152.1 --- a/java.project/src/org/netbeans/modules/java/project/NewJavaFileWizardIterator.java Wed Jul 27 10:33:10 2011 +0200
152.2 +++ b/java.project/src/org/netbeans/modules/java/project/NewJavaFileWizardIterator.java Wed Jul 27 10:35:25 2011 +0200
152.3 @@ -61,6 +61,8 @@
152.4 import org.netbeans.api.project.ProjectUtils;
152.5 import org.netbeans.api.project.SourceGroup;
152.6 import org.netbeans.api.project.Sources;
152.7 +import org.netbeans.api.templates.TemplateRegistration;
152.8 +import org.netbeans.api.templates.TemplateRegistrations;
152.9 import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates;
152.10 import org.netbeans.spi.project.ui.templates.support.Templates;
152.11 import org.openide.WizardDescriptor;
152.12 @@ -69,11 +71,40 @@
152.13 import org.openide.loaders.DataFolder;
152.14 import org.openide.loaders.DataObject;
152.15 import org.openide.util.Exceptions;
152.16 +import org.openide.util.NbBundle.Messages;
152.17
152.18 /**
152.19 * Wizard to create a new Java file.
152.20 */
152.21 +@TemplateRegistrations({
152.22 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 100, content = "resources/Class.java.template", scriptEngine = "freemarker", displayName = "#Class.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Class.html", category = {"java-classes", "java-classes-basic"}),
152.23 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 200, content = "resources/Interface.java.template", scriptEngine = "freemarker", displayName = "#Interface.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Interface.html", category = {"java-classes", "java-classes-basic"}),
152.24 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 300, content = "resources/Enum.java.template", scriptEngine = "freemarker", displayName = "#Enum.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Enum.html", category = {"java-classes", NewJavaFileWizardIterator.JDK_5}),
152.25 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 400, content = "resources/AnnotationType.java.template", scriptEngine = "freemarker", displayName = "#AnnotationType.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/AnnotationType.html", category = {"java-classes", NewJavaFileWizardIterator.JDK_5}),
152.26 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 600, content = "resources/Exception.java.template", scriptEngine = "freemarker", displayName = "#Exception.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Exception.html", category = {"java-classes", "java-classes-basic"}),
152.27 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 700, content = "resources/JApplet.java.template", scriptEngine = "freemarker", displayName = "#JApplet.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/JApplet.html", category = "java-classes"),
152.28 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 800, content = "resources/Applet.java.template", scriptEngine = "freemarker", displayName = "#Applet.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Applet.html", category = "java-classes"),
152.29 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 900, content = "resources/Main.java.template", scriptEngine = "freemarker", displayName = "#Main.java", iconBase = "org/netbeans/modules/java/project/resources/main-class.png", description = "resources/Main.html", category = "java-main-class"),
152.30 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 950, content = "resources/Singleton.java.template", scriptEngine = "freemarker", displayName = "#Singleton.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Singleton.html", category = "java-classes"),
152.31 + @TemplateRegistration(folder = NewJavaFileWizardIterator.FOLDER, position = 1000, content = "resources/Empty.java.template", scriptEngine = "freemarker", displayName = "#Empty.java", iconBase = JavaTemplates.JAVA_ICON, description = "resources/Empty.html", category = {"java-classes", "java-classes-basic"})
152.32 +})
152.33 +@Messages({
152.34 + "Class.java=Java Class",
152.35 + "Interface.java=Java Interface",
152.36 + "Enum.java=Java Enum",
152.37 + "AnnotationType.java=Java Annotation Type",
152.38 + "Exception.java=Java Exception",
152.39 + "JApplet.java=JApplet",
152.40 + "Applet.java=Applet",
152.41 + "Main.java=Java Main Class",
152.42 + "Singleton.java=Java Singleton Class",
152.43 + "Empty.java=Empty Java File"
152.44 +})
152.45 public class NewJavaFileWizardIterator implements WizardDescriptor.AsynchronousInstantiatingIterator<WizardDescriptor> {
152.46 +
152.47 + static final String FOLDER = "Classes";
152.48 +
152.49 + static final String JDK_5 = "jdk5";
152.50
152.51 private static final long serialVersionUID = 1L;
152.52
152.53 @@ -91,10 +122,14 @@
152.54 this.type = type;
152.55 }
152.56
152.57 + @TemplateRegistration(folder = FOLDER, id="Package", position = 1100, displayName = "#packageWizard", iconBase = "org/netbeans/spi/java/project/support/ui/package.gif", description = "resources/Package.html", category = {"java-classes", "java-classes-basic"})
152.58 + @Messages("packageWizard=Java Package")
152.59 public static NewJavaFileWizardIterator packageWizard() {
152.60 return new NewJavaFileWizardIterator(Type.PACKAGE);
152.61 }
152.62
152.63 + @TemplateRegistration(folder = FOLDER, position = 650, content = "resources/package-info.java.template", scriptEngine = "freemarker", displayName = "#packageInfoWizard", iconBase = JavaTemplates.JAVA_ICON, description = "resources/package-info.html", category = {"java-classes", JDK_5})
152.64 + @Messages("packageInfoWizard=Java Package Info")
152.65 public static NewJavaFileWizardIterator packageInfoWizard () {
152.66 return new NewJavaFileWizardIterator(Type.PKG_INFO);
152.67 }
153.1 --- a/java.project/src/org/netbeans/modules/java/project/layer.xml Wed Jul 27 10:33:10 2011 +0200
153.2 +++ b/java.project/src/org/netbeans/modules/java/project/layer.xml Wed Jul 27 10:35:25 2011 +0200
153.3 @@ -43,162 +43,15 @@
153.4 Version 2 license, then the option applies only if the new code is
153.5 made subject to such option by the copyright holder.
153.6 -->
153.7 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
153.8 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
153.9 <filesystem>
153.10 -
153.11 - <folder name="Templates">
153.12 -
153.13 - <folder name="Privileged">
153.14 - <file name="Package.shadow">
153.15 - <attr name="originalFile" stringvalue="Templates/Classes/Package"/>
153.16 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.Bundle"/>
153.17 - <attr name="position" intvalue="100"/>
153.18 - </file>
153.19 - <file name="Main.shadow">
153.20 - <attr name="originalFile" stringvalue="Templates/Classes/Main.java"/>
153.21 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.Bundle"/>
153.22 - <attr name="position" intvalue="200"/>
153.23 - </file>
153.24 - <file name="Class.shadow">
153.25 - <attr name="originalFile" stringvalue="Templates/Classes/Class.java"/>
153.26 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.Bundle"/>
153.27 - <attr name="position" intvalue="300"/>
153.28 - </file>
153.29 + <folder name="Templates">
153.30 + <folder name="Classes">
153.31 + <attr name="displayName" bundlevalue="org.netbeans.modules.java.project.Bundle#Templates/Classes"/>
153.32 + <attr name="position" intvalue="900"/>
153.33 + <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Classes.html"/>
153.34 + </folder>
153.35 </folder>
153.36 -
153.37 -
153.38 - <folder name="Classes">
153.39 - <attr name="position" intvalue="900"/>
153.40 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Classes.html"/>
153.41 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.42 - <file name="Class.java" url="resources/Class.template">
153.43 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.44 - <attr name="position" intvalue="100"/>
153.45 - <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
153.46 - <attr name="template" boolvalue="true"/>
153.47 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.48 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Class.html"/>
153.49 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.50 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.51 - </file>
153.52 - <file name="Interface.java" url="resources/Interface.template">
153.53 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.54 - <attr name="position" intvalue="200"/>
153.55 - <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
153.56 - <attr name="template" boolvalue="true"/>
153.57 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.58 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Interface.html"/>
153.59 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.60 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.61 - </file>
153.62 - <file name="Enum.java" url="resources/Enum.template">
153.63 - <attr name="position" intvalue="300"/>
153.64 - <attr name="template" boolvalue="true"/>
153.65 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.66 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.67 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Enum.html"/>
153.68 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.69 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.70 - <attr name="templateCategory" stringvalue="java-classes"/>
153.71 - <attr name="javac.source" stringvalue="1.5"/>
153.72 - </file>
153.73 - <file name="AnnotationType.java" url="resources/AnnotationType.template">
153.74 - <attr name="position" intvalue="400"/>
153.75 - <attr name="template" boolvalue="true"/>
153.76 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.77 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.78 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/AnnotationType.html"/>
153.79 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.80 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.81 - <attr name="templateCategory" stringvalue="java-classes"/>
153.82 - <attr name="javac.source" stringvalue="1.5"/>
153.83 - </file>
153.84 - <file name="Exception.java" url="resources/Exception.template">
153.85 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.86 - <attr name="position" intvalue="600"/>
153.87 - <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
153.88 - <attr name="template" boolvalue="true"/>
153.89 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.90 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Exception.html"/>
153.91 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.92 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.93 - </file>
153.94 - <file name="package-info.java" url="resources/package-info.template">
153.95 - <attr name="position" intvalue="650"/>
153.96 - <attr name="template" boolvalue="true"/>
153.97 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.98 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.java.project.NewJavaFileWizardIterator.packageInfoWizard"/>
153.99 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/package-info.html"/>
153.100 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.101 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.102 - <attr name="templateCategory" stringvalue="java-classes"/>
153.103 - <attr name="javac.source" stringvalue="1.5"/>
153.104 - </file>
153.105 - <file name="JApplet.java" url="resources/JApplet.template">
153.106 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.107 - <attr name="position" intvalue="700"/>
153.108 - <attr name="templateCategory" stringvalue="java-classes"/>
153.109 - <attr name="template" boolvalue="true"/>
153.110 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.111 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/JApplet.html"/>
153.112 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.113 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.114 - </file>
153.115 - <file name="Applet.java" url="resources/Applet.template">
153.116 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.117 - <attr name="position" intvalue="800"/>
153.118 - <attr name="templateCategory" stringvalue="java-classes"/>
153.119 - <attr name="template" boolvalue="true"/>
153.120 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.121 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Applet.html"/>
153.122 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.123 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.124 - </file>
153.125 - <file name="Main.java" url="resources/Main.template">
153.126 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.127 - <attr name="position" intvalue="900"/>
153.128 - <attr name="templateCategory" stringvalue="java-main-class"/>
153.129 - <attr name="template" boolvalue="true"/>
153.130 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.131 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Main.html"/>
153.132 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.133 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/main-class.png"/>
153.134 - </file>
153.135 - <file name="Singleton.java" url="resources/Singleton.template">
153.136 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.137 - <attr name="position" intvalue="950"/>
153.138 - <attr name="templateCategory" stringvalue="java-classes"/>
153.139 - <attr name="template" boolvalue="true"/>
153.140 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.141 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Singleton.html"/>
153.142 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.143 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.png"/>
153.144 - </file>
153.145 - <file name="Empty.java" url="resources/Empty.template">
153.146 - <attr name="instantiatingIterator" methodvalue="org.netbeans.spi.java.project.support.ui.templates.JavaTemplates.createJavaTemplateIterator"/>
153.147 - <attr name="position" intvalue="1000"/>
153.148 - <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
153.149 - <attr name="template" boolvalue="true"/>
153.150 - <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
153.151 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Empty.html"/>
153.152 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.153 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/java/resources/class.gif"/>
153.154 - </file>
153.155 - <file name="Package" url="resources/Package.template">
153.156 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.java.project.NewJavaFileWizardIterator.packageWizard"/>
153.157 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/spi/java/project/support/ui/package.gif"/>
153.158 - <attr name="position" intvalue="1100"/>
153.159 - <attr name="templateCategory" stringvalue="java-classes, java-classes-basic"/>
153.160 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.project.Bundle"/>
153.161 - <attr name="template" boolvalue="true"/>
153.162 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/java/project/resources/Package.html"/>
153.163 - </file>
153.164 - </folder>
153.165 -
153.166 - </folder>
153.167 -
153.168 -
153.169 -
153.170 <folder name="Loaders">
153.171 <folder name="text">
153.172 <folder name="x-java">
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
154.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/AnnotationType.java.template Wed Jul 27 10:35:25 2011 +0200
154.3 @@ -0,0 +1,16 @@
154.4 +<#assign licenseFirst = "/*">
154.5 +<#assign licensePrefix = " * ">
154.6 +<#assign licenseLast = " */">
154.7 +<#include "../Licenses/license-${project.license}.txt">
154.8 +
154.9 +<#if package?? && package != "">
154.10 +package ${package};
154.11 +
154.12 +</#if>
154.13 +/**
154.14 + *
154.15 + * @author ${user}
154.16 + */
154.17 +public @interface ${name} {
154.18 +
154.19 +}
155.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/AnnotationType.template Wed Jul 27 10:33:10 2011 +0200
155.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
155.3 @@ -1,16 +0,0 @@
155.4 -<#assign licenseFirst = "/*">
155.5 -<#assign licensePrefix = " * ">
155.6 -<#assign licenseLast = " */">
155.7 -<#include "../Licenses/license-${project.license}.txt">
155.8 -
155.9 -<#if package?? && package != "">
155.10 -package ${package};
155.11 -
155.12 -</#if>
155.13 -/**
155.14 - *
155.15 - * @author ${user}
155.16 - */
155.17 -public @interface ${name} {
155.18 -
155.19 -}
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
156.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Applet.java.template Wed Jul 27 10:35:25 2011 +0200
156.3 @@ -0,0 +1,27 @@
156.4 +<#assign licenseFirst = "/*">
156.5 +<#assign licensePrefix = " * ">
156.6 +<#assign licenseLast = " */">
156.7 +<#include "../Licenses/license-${project.license}.txt">
156.8 +
156.9 +<#if package?? && package != "">
156.10 +package ${package};
156.11 +
156.12 +</#if>
156.13 +import java.applet.Applet;
156.14 +
156.15 +/**
156.16 + *
156.17 + * @author ${user}
156.18 + */
156.19 +public class ${name} extends Applet {
156.20 +
156.21 + /**
156.22 + * Initialization method that will be called after the applet is loaded
156.23 + * into the browser.
156.24 + */
156.25 + public void init() {
156.26 + // TODO start asynchronous download of heavy resources
156.27 + }
156.28 +
156.29 + // TODO overwrite start(), stop() and destroy() methods
156.30 +}
157.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Applet.template Wed Jul 27 10:33:10 2011 +0200
157.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
157.3 @@ -1,27 +0,0 @@
157.4 -<#assign licenseFirst = "/*">
157.5 -<#assign licensePrefix = " * ">
157.6 -<#assign licenseLast = " */">
157.7 -<#include "../Licenses/license-${project.license}.txt">
157.8 -
157.9 -<#if package?? && package != "">
157.10 -package ${package};
157.11 -
157.12 -</#if>
157.13 -import java.applet.Applet;
157.14 -
157.15 -/**
157.16 - *
157.17 - * @author ${user}
157.18 - */
157.19 -public class ${name} extends Applet {
157.20 -
157.21 - /**
157.22 - * Initialization method that will be called after the applet is loaded
157.23 - * into the browser.
157.24 - */
157.25 - public void init() {
157.26 - // TODO start asynchronous download of heavy resources
157.27 - }
157.28 -
157.29 - // TODO overwrite start(), stop() and destroy() methods
157.30 -}
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
158.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Class.java.template Wed Jul 27 10:35:25 2011 +0200
158.3 @@ -0,0 +1,16 @@
158.4 +<#assign licenseFirst = "/*">
158.5 +<#assign licensePrefix = " * ">
158.6 +<#assign licenseLast = " */">
158.7 +<#include "../Licenses/license-${project.license}.txt">
158.8 +
158.9 +<#if package?? && package != "">
158.10 +package ${package};
158.11 +
158.12 +</#if>
158.13 +/**
158.14 + *
158.15 + * @author ${user}
158.16 + */
158.17 +public class ${name} {
158.18 +
158.19 +}
159.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Class.template Wed Jul 27 10:33:10 2011 +0200
159.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
159.3 @@ -1,16 +0,0 @@
159.4 -<#assign licenseFirst = "/*">
159.5 -<#assign licensePrefix = " * ">
159.6 -<#assign licenseLast = " */">
159.7 -<#include "../Licenses/license-${project.license}.txt">
159.8 -
159.9 -<#if package?? && package != "">
159.10 -package ${package};
159.11 -
159.12 -</#if>
159.13 -/**
159.14 - *
159.15 - * @author ${user}
159.16 - */
159.17 -public class ${name} {
159.18 -
159.19 -}
160.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
160.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Enum.java.template Wed Jul 27 10:35:25 2011 +0200
160.3 @@ -0,0 +1,16 @@
160.4 +<#assign licenseFirst = "/*">
160.5 +<#assign licensePrefix = " * ">
160.6 +<#assign licenseLast = " */">
160.7 +<#include "../Licenses/license-${project.license}.txt">
160.8 +
160.9 +<#if package?? && package != "">
160.10 +package ${package};
160.11 +
160.12 +</#if>
160.13 +/**
160.14 + *
160.15 + * @author ${user}
160.16 + */
160.17 +public enum ${name} {
160.18 +
160.19 +}
161.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Enum.template Wed Jul 27 10:33:10 2011 +0200
161.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
161.3 @@ -1,16 +0,0 @@
161.4 -<#assign licenseFirst = "/*">
161.5 -<#assign licensePrefix = " * ">
161.6 -<#assign licenseLast = " */">
161.7 -<#include "../Licenses/license-${project.license}.txt">
161.8 -
161.9 -<#if package?? && package != "">
161.10 -package ${package};
161.11 -
161.12 -</#if>
161.13 -/**
161.14 - *
161.15 - * @author ${user}
161.16 - */
161.17 -public enum ${name} {
161.18 -
161.19 -}
162.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Exception.java.template Wed Jul 27 10:35:25 2011 +0200
162.3 @@ -0,0 +1,30 @@
162.4 +<#assign licenseFirst = "/*">
162.5 +<#assign licensePrefix = " * ">
162.6 +<#assign licenseLast = " */">
162.7 +<#include "../Licenses/license-${project.license}.txt">
162.8 +
162.9 +<#if package?? && package != "">
162.10 +package ${package};
162.11 +
162.12 +</#if>
162.13 +/**
162.14 + *
162.15 + * @author ${user}
162.16 + */
162.17 +public class ${name} extends Exception {
162.18 +
162.19 + /**
162.20 + * Creates a new instance of <code>${name}</code> without detail message.
162.21 + */
162.22 + public ${name}() {
162.23 + }
162.24 +
162.25 +
162.26 + /**
162.27 + * Constructs an instance of <code>${name}</code> with the specified detail message.
162.28 + * @param msg the detail message.
162.29 + */
162.30 + public ${name}(String msg) {
162.31 + super(msg);
162.32 + }
162.33 +}
163.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Exception.template Wed Jul 27 10:33:10 2011 +0200
163.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
163.3 @@ -1,30 +0,0 @@
163.4 -<#assign licenseFirst = "/*">
163.5 -<#assign licensePrefix = " * ">
163.6 -<#assign licenseLast = " */">
163.7 -<#include "../Licenses/license-${project.license}.txt">
163.8 -
163.9 -<#if package?? && package != "">
163.10 -package ${package};
163.11 -
163.12 -</#if>
163.13 -/**
163.14 - *
163.15 - * @author ${user}
163.16 - */
163.17 -public class ${name} extends Exception {
163.18 -
163.19 - /**
163.20 - * Creates a new instance of <code>${name}</code> without detail message.
163.21 - */
163.22 - public ${name}() {
163.23 - }
163.24 -
163.25 -
163.26 - /**
163.27 - * Constructs an instance of <code>${name}</code> with the specified detail message.
163.28 - * @param msg the detail message.
163.29 - */
163.30 - public ${name}(String msg) {
163.31 - super(msg);
163.32 - }
163.33 -}
164.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
164.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Interface.java.template Wed Jul 27 10:35:25 2011 +0200
164.3 @@ -0,0 +1,16 @@
164.4 +<#assign licenseFirst = "/*">
164.5 +<#assign licensePrefix = " * ">
164.6 +<#assign licenseLast = " */">
164.7 +<#include "../Licenses/license-${project.license}.txt">
164.8 +
164.9 +<#if package?? && package != "">
164.10 +package ${package};
164.11 +
164.12 +</#if>
164.13 +/**
164.14 + *
164.15 + * @author ${user}
164.16 + */
164.17 +public interface ${name} {
164.18 +
164.19 +}
165.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Interface.template Wed Jul 27 10:33:10 2011 +0200
165.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
165.3 @@ -1,16 +0,0 @@
165.4 -<#assign licenseFirst = "/*">
165.5 -<#assign licensePrefix = " * ">
165.6 -<#assign licenseLast = " */">
165.7 -<#include "../Licenses/license-${project.license}.txt">
165.8 -
165.9 -<#if package?? && package != "">
165.10 -package ${package};
165.11 -
165.12 -</#if>
165.13 -/**
165.14 - *
165.15 - * @author ${user}
165.16 - */
165.17 -public interface ${name} {
165.18 -
165.19 -}
166.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
166.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/JApplet.java.template Wed Jul 27 10:35:25 2011 +0200
166.3 @@ -0,0 +1,28 @@
166.4 +<#assign licenseFirst = "/*">
166.5 +<#assign licensePrefix = " * ">
166.6 +<#assign licenseLast = " */">
166.7 +<#include "../Licenses/license-${project.license}.txt">
166.8 +
166.9 +<#if package?? && package != "">
166.10 +package ${package};
166.11 +
166.12 +</#if>
166.13 +import javax.swing.JApplet;
166.14 +
166.15 +/**
166.16 + *
166.17 + * @author ${user}
166.18 + */
166.19 +public class ${name} extends JApplet {
166.20 +
166.21 + /**
166.22 + * Initialization method that will be called after the applet is loaded
166.23 + * into the browser.
166.24 + */
166.25 + public void init() {
166.26 + // TODO start asynchronous download of heavy resources
166.27 + }
166.28 +
166.29 + // TODO overwrite start(), stop() and destroy() methods
166.30 +
166.31 +}
167.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/JApplet.template Wed Jul 27 10:33:10 2011 +0200
167.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
167.3 @@ -1,28 +0,0 @@
167.4 -<#assign licenseFirst = "/*">
167.5 -<#assign licensePrefix = " * ">
167.6 -<#assign licenseLast = " */">
167.7 -<#include "../Licenses/license-${project.license}.txt">
167.8 -
167.9 -<#if package?? && package != "">
167.10 -package ${package};
167.11 -
167.12 -</#if>
167.13 -import javax.swing.JApplet;
167.14 -
167.15 -/**
167.16 - *
167.17 - * @author ${user}
167.18 - */
167.19 -public class ${name} extends JApplet {
167.20 -
167.21 - /**
167.22 - * Initialization method that will be called after the applet is loaded
167.23 - * into the browser.
167.24 - */
167.25 - public void init() {
167.26 - // TODO start asynchronous download of heavy resources
167.27 - }
167.28 -
167.29 - // TODO overwrite start(), stop() and destroy() methods
167.30 -
167.31 -}
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Main.java.template Wed Jul 27 10:35:25 2011 +0200
168.3 @@ -0,0 +1,23 @@
168.4 +<#assign licenseFirst = "/*">
168.5 +<#assign licensePrefix = " * ">
168.6 +<#assign licenseLast = " */">
168.7 +<#include "../Licenses/license-${project.license}.txt">
168.8 +
168.9 +<#if package?? && package != "">
168.10 +package ${package};
168.11 +
168.12 +</#if>
168.13 +/**
168.14 + *
168.15 + * @author ${user}
168.16 + */
168.17 +public class ${name} {
168.18 +
168.19 + /**
168.20 + * @param args the command line arguments
168.21 + */
168.22 + public static void main(String[] args) {
168.23 + // TODO code application logic here
168.24 + }
168.25 +
168.26 +}
169.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Main.template Wed Jul 27 10:33:10 2011 +0200
169.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
169.3 @@ -1,23 +0,0 @@
169.4 -<#assign licenseFirst = "/*">
169.5 -<#assign licensePrefix = " * ">
169.6 -<#assign licenseLast = " */">
169.7 -<#include "../Licenses/license-${project.license}.txt">
169.8 -
169.9 -<#if package?? && package != "">
169.10 -package ${package};
169.11 -
169.12 -</#if>
169.13 -/**
169.14 - *
169.15 - * @author ${user}
169.16 - */
169.17 -public class ${name} {
169.18 -
169.19 - /**
169.20 - * @param args the command line arguments
169.21 - */
169.22 - public static void main(String[] args) {
169.23 - // TODO code application logic here
169.24 - }
169.25 -
169.26 -}
170.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Package.template Wed Jul 27 10:33:10 2011 +0200
170.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
170.3 @@ -1,1 +0,0 @@
170.4 -This is just a placeholder for the "package" template.
170.5 \ No newline at end of file
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/Singleton.java.template Wed Jul 27 10:35:25 2011 +0200
171.3 @@ -0,0 +1,26 @@
171.4 +<#assign licenseFirst = "/*">
171.5 +<#assign licensePrefix = " * ">
171.6 +<#assign licenseLast = " */">
171.7 +<#include "../Licenses/license-${project.license}.txt">
171.8 +
171.9 +<#if package?? && package != "">
171.10 +package ${package};
171.11 +
171.12 +</#if>
171.13 +/**
171.14 + *
171.15 + * @author ${user}
171.16 + */
171.17 +public class ${name} {
171.18 +
171.19 + private ${name}() {
171.20 + }
171.21 +
171.22 + public static ${name} getInstance() {
171.23 + return ${name}Holder.INSTANCE;
171.24 + }
171.25 +
171.26 + private static class ${name}Holder {
171.27 + private static final ${name} INSTANCE = new ${name}();
171.28 + }
171.29 + }
172.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/Singleton.template Wed Jul 27 10:33:10 2011 +0200
172.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
172.3 @@ -1,26 +0,0 @@
172.4 -<#assign licenseFirst = "/*">
172.5 -<#assign licensePrefix = " * ">
172.6 -<#assign licenseLast = " */">
172.7 -<#include "../Licenses/license-${project.license}.txt">
172.8 -
172.9 -<#if package?? && package != "">
172.10 -package ${package};
172.11 -
172.12 -</#if>
172.13 -/**
172.14 - *
172.15 - * @author ${user}
172.16 - */
172.17 -public class ${name} {
172.18 -
172.19 - private ${name}() {
172.20 - }
172.21 -
172.22 - public static ${name} getInstance() {
172.23 - return ${name}Holder.INSTANCE;
172.24 - }
172.25 -
172.26 - private static class ${name}Holder {
172.27 - private static final ${name} INSTANCE = new ${name}();
172.28 - }
172.29 - }
173.1 Binary file java.project/src/org/netbeans/modules/java/project/resources/main-class.png has changed
174.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
174.2 +++ b/java.project/src/org/netbeans/modules/java/project/resources/package-info.java.template Wed Jul 27 10:35:25 2011 +0200
174.3 @@ -0,0 +1,8 @@
174.4 +<#assign licenseFirst = "/*">
174.5 +<#assign licensePrefix = " * ">
174.6 +<#assign licenseLast = " */">
174.7 +<#include "../Licenses/license-${project.license}.txt">
174.8 +
174.9 +<#if package?? && package != "">
174.10 +package ${package};
174.11 +</#if>
175.1 --- a/java.project/src/org/netbeans/modules/java/project/resources/package-info.template Wed Jul 27 10:33:10 2011 +0200
175.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
175.3 @@ -1,8 +0,0 @@
175.4 -<#assign licenseFirst = "/*">
175.5 -<#assign licensePrefix = " * ">
175.6 -<#assign licenseLast = " */">
175.7 -<#include "../Licenses/license-${project.license}.txt">
175.8 -
175.9 -<#if package?? && package != "">
175.10 -package ${package};
175.11 -</#if>
176.1 --- a/java.project/src/org/netbeans/spi/java/project/support/ui/templates/JavaTemplates.java Wed Jul 27 10:33:10 2011 +0200
176.2 +++ b/java.project/src/org/netbeans/spi/java/project/support/ui/templates/JavaTemplates.java Wed Jul 27 10:35:25 2011 +0200
176.3 @@ -49,6 +49,7 @@
176.4 import org.netbeans.modules.java.project.NewJavaFileWizardIterator;
176.5 import org.netbeans.api.project.SourceGroup;
176.6 import org.openide.WizardDescriptor;
176.7 +import org.netbeans.api.templates.TemplateRegistration;
176.8
176.9 /**
176.10 * Default implementations of Java-specific template UI.
176.11 @@ -111,11 +112,28 @@
176.12 return new JavaTargetChooserPanel(project, folders, bottomPanel, NewJavaFileWizardIterator.Type.FILE, validPackageRequired);
176.13 }
176.14
176.15 - /** Creates new WizardIterator containing standard Package chooser
176.16 + /**
176.17 + * Creates new WizardIterator containing standard Package chooser.
176.18 + * Sample usage:
176.19 + * <pre>
176.20 + * @TemplateRegistration(..., iconBase=JavaTemplates.JAVA_ICON)
176.21 + * public static WizardDescriptor.InstantiatingIterator<?> myTemplates() {
176.22 + * return JavaTemplates.createJavaTemplateIterator();
176.23 + * }
176.24 + * </pre>
176.25 * @return WizardIterator consisting of one panel containing package chooser
176.26 + * @see TemplateRegistration
176.27 + * @see #JAVA_ICON
176.28 */
176.29 - public static WizardDescriptor.InstantiatingIterator createJavaTemplateIterator () {
176.30 + public static WizardDescriptor.InstantiatingIterator<WizardDescriptor> createJavaTemplateIterator() {
176.31 return new NewJavaFileWizardIterator ();
176.32 }
176.33 +
176.34 + /**
176.35 + * Icon for Java templates.
176.36 + * @see #createJavaTemplateIterator
176.37 + * @since 1.40
176.38 + */
176.39 + public static final String JAVA_ICON = "org/netbeans/spi/java/project/support/ui/templates/class.png";
176.40
176.41 }
177.1 Binary file java.project/src/org/netbeans/spi/java/project/support/ui/templates/class.png has changed
178.1 --- a/java.source/src/org/netbeans/modules/java/source/save/Reformatter.java Wed Jul 27 10:33:10 2011 +0200
178.2 +++ b/java.source/src/org/netbeans/modules/java/source/save/Reformatter.java Wed Jul 27 10:35:25 2011 +0200
178.3 @@ -3281,6 +3281,7 @@
178.4 int state = 0; // 0 - initial text, 1 - after param tag, 2 - param description, 3 - return description,
178.5 // 4 - after throws tag, 5 - exception description, 6 - after pre tag, 7 - after other tag
178.6 int lastWSOffset = -1;
178.7 + boolean afterText = false;
178.8 while (javadocTokens.moveNext()) {
178.9 switch (javadocTokens.token().id()) {
178.10 case TAG:
178.11 @@ -3296,9 +3297,9 @@
178.12 newState = 7;
178.13 }
178.14 if (lastWSOffset >= 0) {
178.15 - marks.add(Pair.of(lastWSOffset, state == 0 && cs.blankLineAfterJavadocDescription()
178.16 + marks.add(Pair.of(lastWSOffset, afterText && (state == 0 && cs.blankLineAfterJavadocDescription()
178.17 || state == 2 && newState != 1 && cs.blankLineAfterJavadocParameterDescriptions()
178.18 - || state == 3 && cs.blankLineAfterJavadocReturnTag() ? 0 : 1));
178.19 + || state == 3 && cs.blankLineAfterJavadocReturnTag()) ? 0 : 1));
178.20 }
178.21 state = newState;
178.22 if (state == 3 && cs.alignJavadocReturnDescription()) {
178.23 @@ -3323,6 +3324,7 @@
178.24 state = 5;
178.25 }
178.26 lastWSOffset = -1;
178.27 + afterText = true;
178.28 break;
178.29 case OTHER_TEXT:
178.30 lastWSOffset = -1;
178.31 @@ -3339,6 +3341,7 @@
178.32 }
178.33 } else if (!Character.isWhitespace(c) && c != '*') {
178.34 lastWSOffset = javadocTokens.offset() + i - offset;
178.35 + afterText = true;
178.36 break;
178.37 }
178.38 }
178.39 @@ -3346,7 +3349,12 @@
178.40 break;
178.41 case HTML_TAG:
178.42 tokenText = javadocTokens.token().text().toString();
178.43 - if (PRE_TAG.equalsIgnoreCase(tokenText)) {
178.44 + if (P_TAG.equalsIgnoreCase(tokenText)) {
178.45 + if (lastWSOffset >= 0) {
178.46 + marks.add(Pair.of(lastWSOffset, 1));
178.47 + }
178.48 + afterText = false;
178.49 + } else if (PRE_TAG.equalsIgnoreCase(tokenText)) {
178.50 if (lastWSOffset >= 0) {
178.51 marks.add(Pair.of(lastWSOffset, 1));
178.52 }
178.53 @@ -3444,13 +3452,13 @@
178.54 noFormat = false;
178.55 switch (actionType) {
178.56 case 0:
178.57 - addDiff(new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE + blankLineString + NEWLINE));
178.58 + pendingDiff = new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE + blankLineString + NEWLINE);
178.59 lastNewLinePos = i - 1;
178.60 preserveNewLines = true;
178.61 align = -1;
178.62 break;
178.63 case 1:
178.64 - addDiff(new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE));
178.65 + pendingDiff = new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE);
178.66 lastNewLinePos = i - 1;
178.67 preserveNewLines = true;
178.68 align = -1;
178.69 @@ -3458,7 +3466,7 @@
178.70 case 2:
178.71 int num = maxParamNameLength + lastNWSPos - currWSPos;
178.72 if (num > 0) {
178.73 - addDiff(new Diff(offset + i, offset + i, getSpaces(num)));
178.74 + pendingDiff = new Diff(offset + i, offset + i, getSpaces(num));
178.75 col += num;
178.76 }
178.77 align = col;
178.78 @@ -3469,7 +3477,7 @@
178.79 case 4:
178.80 num = maxExcNameLength + lastNWSPos - currWSPos;
178.81 if (num > 0) {
178.82 - addDiff(new Diff(offset + i, offset + i, getSpaces(num)));
178.83 + pendingDiff = new Diff(offset + i, offset + i, getSpaces(num));
178.84 col += num;
178.85 }
178.86 align = col;
178.87 @@ -3494,13 +3502,13 @@
178.88 }
178.89 }
178.90 if (lastNewLinePos >= 0) {
178.91 - if (pendingDiff != null) {
178.92 - addDiff(pendingDiff);
178.93 - pendingDiff = null;
178.94 - }
178.95 if (!preserveNewLines && !noFormat && i < text.length() - 2 && enableCommentFormatting && !cs.preserveNewLinesInComments() && cs.wrapCommentText()) {
178.96 lastWSPos = lastNewLinePos;
178.97 - pendingDiff = new Diff(offset + lastNewLinePos, offset + i, SPACE);
178.98 + if (pendingDiff != null) {
178.99 + pendingDiff.text += SPACE;
178.100 + } else {
178.101 + pendingDiff = new Diff(offset + lastNewLinePos, offset + i, SPACE);
178.102 + }
178.103 lastNewLinePos = -1;
178.104 if (c == '*') {
178.105 while(++i < text.length()) {
178.106 @@ -3516,14 +3524,27 @@
178.107 break;
178.108 }
178.109 }
178.110 - if (pendingDiff != null)
178.111 - pendingDiff.end = offset + i;
178.112 + if (pendingDiff != null) {
178.113 + String sub = text.substring(pendingDiff.start - offset, i);
178.114 + if (sub.equals(pendingDiff.text)) {
178.115 + pendingDiff = null;
178.116 + } else {
178.117 + pendingDiff.end = offset + i;
178.118 + }
178.119 + }
178.120 }
178.121 } else {
178.122 String s = indentString + SPACE;
178.123 - String subs = text.substring(lastNewLinePos + 1, i);
178.124 - if (!s.equals(subs))
178.125 - pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, s);
178.126 + if (pendingDiff != null) {
178.127 + pendingDiff.text += s;
178.128 + String subs = text.substring(pendingDiff.start - offset, i);
178.129 + if (pendingDiff.text.equals(subs))
178.130 + pendingDiff = null;
178.131 + } else {
178.132 + String subs = text.substring(lastNewLinePos + 1, i);
178.133 + if (!s.equals(subs))
178.134 + pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, s);
178.135 + }
178.136 lastWSPos = currWSPos = -1;
178.137 lastNewLinePos = -1;
178.138 col = getCol(s);
178.139 @@ -3534,17 +3555,22 @@
178.140 c = text.charAt(i);
178.141 if (c == '\n') {
178.142 if (!cs.addLeadingStarInComment()) {
178.143 - if (pendingDiff != null) {
178.144 - pendingDiff.end = offset + i;
178.145 - pendingDiff.text = blankLineString;
178.146 + String subs = text.substring(lastNewLinePos + 1, i);
178.147 + if (blankLineString.equals(subs)) {
178.148 + pendingDiff = null;
178.149 } else {
178.150 - pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, blankLineString);
178.151 + if (pendingDiff != null) {
178.152 + pendingDiff.end = offset + i;
178.153 + pendingDiff.text = blankLineString;
178.154 + } else {
178.155 + pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, blankLineString);
178.156 + }
178.157 }
178.158 } else if (currWSPos >= 0) {
178.159 if (pendingDiff != null) {
178.160 addDiff(pendingDiff);
178.161 }
178.162 - pendingDiff = new Diff(offset + currWSPos, offset + i, javadocTokens != null && cs.generateParagraphTagOnBlankLines() ? SPACE + P_TAG : EMPTY);
178.163 + pendingDiff = new Diff(offset + currWSPos, offset + i, javadocTokens != null && lastNWSPos >= 0 && cs.generateParagraphTagOnBlankLines() ? SPACE + P_TAG : EMPTY);
178.164 }
178.165 currWSPos = -1;
178.166 lastNewLinePos = i;
178.167 @@ -3579,7 +3605,7 @@
178.168 currWSPos = i;
178.169 col++;
178.170 }
178.171 - subs = text.substring(currWSPos, i);
178.172 + String subs = text.substring(currWSPos, i);
178.173 if (!noFormat && !SPACE.equals(subs)) {
178.174 if (pendingDiff != null)
178.175 addDiff(pendingDiff);
179.1 --- a/java.source/src/org/netbeans/modules/java/ui/FmtOptions.java Wed Jul 27 10:33:10 2011 +0200
179.2 +++ b/java.source/src/org/netbeans/modules/java/ui/FmtOptions.java Wed Jul 27 10:35:25 2011 +0200
179.3 @@ -497,7 +497,7 @@
179.4 { blankLineAfterJavadocDescription, TRUE}, //NOI18N
179.5 { blankLineAfterJavadocParameterDescriptions, FALSE}, //NOI18N
179.6 { blankLineAfterJavadocReturnTag, FALSE}, //NOI18N
179.7 - { generateParagraphTagOnBlankLines, TRUE}, //NOI18N
179.8 + { generateParagraphTagOnBlankLines, FALSE}, //NOI18N
179.9 { alignJavadocParameterDescriptions, FALSE}, //NOI18N
179.10 { alignJavadocReturnDescription, FALSE}, //NOI18N
179.11 { alignJavadocExceptionDescriptions, FALSE}, //NOI18N
180.1 --- a/java.source/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java Wed Jul 27 10:33:10 2011 +0200
180.2 +++ b/java.source/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java Wed Jul 27 10:35:25 2011 +0200
180.3 @@ -3080,6 +3080,7 @@
180.4
180.5 Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
180.6 preferences.putInt("text-limit-width", 45);
180.7 + preferences.putBoolean("generateParagraphTagOnBlankLines", true);
180.8
180.9 String golden =
180.10 "package hierbas.del.litoral;\n"
180.11 @@ -3360,7 +3361,7 @@
180.12 preferences.putBoolean("addLeadingStarInComment", false);
180.13 reformat(doc, content, golden);
180.14 preferences.remove("addLeadingStarInComment");
180.15 - preferences.remove("generateParagraphTagOnBlankLines");
180.16 + preferences.putBoolean("generateParagraphTagOnBlankLines", true);
180.17
180.18 golden =
180.19 "package hierbas.del.litoral;\n"
180.20 @@ -3544,7 +3545,26 @@
180.21 + " }\n"
180.22 + "}\n";
180.23 reformat(doc, content, golden);
180.24 -
180.25 +
180.26 + content =
180.27 + "package hierbas.del.litoral;\n"
180.28 + + "\n"
180.29 + + "/**\n"
180.30 + + " * @author XYZ\n"
180.31 + + " */\n"
180.32 + + "public class Test {\n"
180.33 + + "}\n";
180.34 + golden =
180.35 + "package hierbas.del.litoral;\n"
180.36 + + "\n"
180.37 + + "/**\n"
180.38 + + " * @author XYZ\n"
180.39 + + " */\n"
180.40 + + "public class Test {\n"
180.41 + + "}\n";
180.42 + reformat(doc, content, golden);
180.43 +
180.44 + preferences.remove("generateParagraphTagOnBlankLines");
180.45 preferences.remove("text-limit-width");
180.46 }
180.47
181.1 --- a/javahelp/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
181.2 +++ b/javahelp/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
181.3 @@ -79,7 +79,7 @@
181.4 <build-prerequisite/>
181.5 <compile-dependency/>
181.6 <run-dependency>
181.7 - <specification-version>7.19</specification-version>
181.8 + <specification-version>7.51</specification-version>
181.9 </run-dependency>
181.10 </dependency>
181.11 <dependency>
182.1 --- a/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java Wed Jul 27 10:33:10 2011 +0200
182.2 +++ b/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java Wed Jul 27 10:35:25 2011 +0200
182.3 @@ -45,7 +45,6 @@
182.4 import com.sun.java.help.search.Indexer;
182.5 import java.io.File;
182.6 import java.io.FileInputStream;
182.7 -import java.io.FileNotFoundException;
182.8 import java.io.FileOutputStream;
182.9 import java.io.IOException;
182.10 import java.io.InputStream;
182.11 @@ -68,6 +67,7 @@
182.12 import javax.tools.StandardLocation;
182.13 import org.netbeans.api.javahelp.HelpSetRegistration;
182.14 import org.openide.filesystems.FileUtil;
182.15 +import org.openide.filesystems.annotations.LayerBuilder;
182.16 import org.openide.filesystems.annotations.LayerGeneratingProcessor;
182.17 import org.openide.filesystems.annotations.LayerGenerationException;
182.18 import org.openide.util.lookup.ServiceProvider;
182.19 @@ -94,7 +94,8 @@
182.20 HelpSetRegistration r = e.getAnnotation(HelpSetRegistration.class);
182.21 String pkg = ((PackageElement) e).getQualifiedName().toString();
182.22 String hs = pkg.replace('.', '/') + '/' + r.helpSet();
182.23 - layer(e).file("Services/JavaHelp/" + pkg.replace('.', '-') + ".xml").contents(""
182.24 + LayerBuilder builder = layer(e);
182.25 + builder.file("Services/JavaHelp/" + pkg.replace('.', '-') + ".xml").contents(""
182.26 + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
182.27 + "<!DOCTYPE helpsetref PUBLIC \"-//NetBeans//DTD JavaHelp Help Set Reference 1.0//EN\" \"http://www.netbeans.org/dtds/helpsetref-1_0.dtd\">\n"
182.28 + "<helpsetref url=\"nbdocs:/" + hs + "\" merge=\"" + r.merge() + "\"/>\n"
182.29 @@ -103,13 +104,7 @@
182.30 Document doc;
182.31 URI loc;
182.32 try {
182.33 - FileObject hsf = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", hs);
182.34 - try { // #181355
182.35 - hsf.openInputStream().close();
182.36 - } catch (FileNotFoundException x) {
182.37 - hsf = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", hs);
182.38 - }
182.39 - loc = hsf.toUri();
182.40 + loc = builder.validateResource(hs, e, r, "helpSet", false).toUri();
182.41 if (loc.getScheme() == null) {
182.42 // JDK #6419926: FileObject.toUri() generates URI without schema
182.43 loc = new File(loc.toString()).toURI();
182.44 @@ -126,9 +121,9 @@
182.45 }
182.46 });
182.47 } catch (IOException x) {
182.48 - throw new LayerGenerationException("Could not parse " + hs + ": " + x, e);
182.49 + throw new LayerGenerationException("Could not parse " + hs + ": " + x, e, processingEnv, r, "helpSet");
182.50 } catch (SAXException x) {
182.51 - throw new LayerGenerationException("Could not parse " + hs + ": " + x, e);
182.52 + throw new LayerGenerationException("Could not parse " + hs + ": " + x, e, processingEnv, r, "helpSet");
182.53 }
182.54 String searchDir = null;
182.55 for (Element view : XMLUtil.findSubElements(doc.getDocumentElement())) {
183.1 --- a/jira/src/org/netbeans/modules/jira/query/QueryController.java Wed Jul 27 10:33:10 2011 +0200
183.2 +++ b/jira/src/org/netbeans/modules/jira/query/QueryController.java Wed Jul 27 10:35:25 2011 +0200
183.3 @@ -988,10 +988,13 @@
183.4 }
183.5
183.6 private void onGotoIssue() {
183.7 - final String key = getIdTextField();
183.8 - if(key == null || key.trim().equals("") || !validateIssueKey(key)) { //NOI18N
183.9 + String keyText = panel.idTextField.getText().trim();
183.10 + if(keyText == null || keyText.trim().equals("") || !validateIssueKey(keyText)) { //NOI18N
183.11 return;
183.12 }
183.13 +
183.14 + final String key = keyText.replaceAll("\\s", ""); // NOI18N
183.15 +
183.16 final Task[] t = new Task[1];
183.17 Cancellable c = new Cancellable() {
183.18 @Override
184.1 --- a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/Bundle.properties Wed Jul 27 10:33:10 2011 +0200
184.2 +++ b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/Bundle.properties Wed Jul 27 10:35:25 2011 +0200
184.3 @@ -44,9 +44,6 @@
184.4 repo.netbeans=NetBeans
184.5 PublicPackagesPanel.jLabel1.text=&Public packages:
184.6
184.7 -template.module=NetBeans Module
184.8 -template.suite=NetBeans Module Suite
184.9 -template.app=NetBeans Application
184.10
184.11 NbmWizardPanelVisual.panel.accessiblename=additional properties of the project
184.12 NbmWizardPanelVisual.panel.accessibledesc=Select the additional project properties.
185.1 --- a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java Wed Jul 27 10:33:10 2011 +0200
185.2 +++ b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java Wed Jul 27 10:35:25 2011 +0200
185.3 @@ -80,6 +80,7 @@
185.4 import org.openide.WizardDescriptor;
185.5 import org.openide.filesystems.FileObject;
185.6 import org.openide.filesystems.FileUtil;
185.7 +import org.netbeans.api.templates.TemplateRegistration;
185.8 import org.openide.util.NbBundle.Messages;
185.9 import static org.netbeans.modules.maven.apisupport.Bundle.*;
185.10
185.11 @@ -116,15 +117,21 @@
185.12 private NbmWizardIterator(Archetype archetype) {
185.13 this.archetype = archetype;
185.14 }
185.15 -
185.16 +
185.17 + @TemplateRegistration(folder="Project/Maven2", position=400, displayName="#template.module", iconBase="org/netbeans/modules/maven/apisupport/nbmicon.png", description="NbModuleDescription.html")
185.18 + @Messages("template.module=NetBeans Module")
185.19 public static NbmWizardIterator createNbModuleIterator() {
185.20 return new NbmWizardIterator(NB_MODULE_ARCH);
185.21 }
185.22
185.23 + @TemplateRegistration(folder="Project/Maven2", position=500, displayName="#template.app", iconBase="org/netbeans/modules/maven/apisupport/suiteicon.png", description="NbAppDescription.html")
185.24 + @Messages("template.app=NetBeans Application")
185.25 public static NbmWizardIterator createNbAppIterator() {
185.26 return new NbmWizardIterator(NB_APP_ARCH);
185.27 }
185.28
185.29 + @TemplateRegistration(folder="Project/Maven2", position=450, displayName="#template.suite", iconBase="org/netbeans/modules/maven/apisupport/suiteicon.png", description="NbSuiteDescription.html")
185.30 + @Messages("template.suite=NetBeans Module Suite")
185.31 public static NbmWizardIterator createNbSuiteIterator() {
185.32 return new NbmWizardIterator(NB_SUITE_ARCH);
185.33 }
186.1 --- a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/layer.xml Wed Jul 27 10:33:10 2011 +0200
186.2 +++ b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/layer.xml Wed Jul 27 10:35:25 2011 +0200
186.3 @@ -57,34 +57,4 @@
186.4 </folder>
186.5 </folder>
186.6 </folder>
186.7 - <folder name="Templates">
186.8 - <folder name="Project">
186.9 - <folder name="Maven2">
186.10 - <file name="NbModule">
186.11 - <attr name="position" intvalue="400"/>
186.12 - <attr name="displayName" bundlevalue="org.netbeans.modules.maven.apisupport.Bundle#template.module"/>
186.13 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.maven.apisupport.NbmWizardIterator.createNbModuleIterator"/>
186.14 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/maven/apisupport/NbModuleDescription.html"/>
186.15 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/maven/resources/nbmicon.png"/>
186.16 - <attr name="template" boolvalue="true"/>
186.17 - </file>
186.18 - <file name="NbSuite">
186.19 - <attr name="position" intvalue="450"/>
186.20 - <attr name="displayName" bundlevalue="org.netbeans.modules.maven.apisupport.Bundle#template.suite"/>
186.21 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.maven.apisupport.NbmWizardIterator.createNbSuiteIterator"/>
186.22 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/maven/apisupport/NbSuiteDescription.html"/>
186.23 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/maven/resources/suiteicon.png"/>
186.24 - <attr name="template" boolvalue="true"/>
186.25 - </file>
186.26 - <file name="NbApp">
186.27 - <attr name="position" intvalue="500"/>
186.28 - <attr name="displayName" bundlevalue="org.netbeans.modules.maven.apisupport.Bundle#template.app"/>
186.29 - <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.maven.apisupport.NbmWizardIterator.createNbAppIterator"/>
186.30 - <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/maven/apisupport/NbAppDescription.html"/>
186.31 - <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/maven/resources/suiteicon.png"/>
186.32 - <attr name="template" boolvalue="true"/>
186.33 - </file>
186.34 - </folder>
186.35 - </folder>
186.36 - </folder>
186.37 </filesystem>
187.1 Binary file maven.apisupport/src/org/netbeans/modules/maven/apisupport/nbmicon.png has changed
188.1 Binary file maven.apisupport/src/org/netbeans/modules/maven/apisupport/suiteicon.png has changed
189.1 --- a/maven.refactoring/src/org/netbeans/modules/maven/refactoring/MavenRefactoringPlugin.java Wed Jul 27 10:33:10 2011 +0200
189.2 +++ b/maven.refactoring/src/org/netbeans/modules/maven/refactoring/MavenRefactoringPlugin.java Wed Jul 27 10:35:25 2011 +0200
189.3 @@ -91,7 +91,7 @@
189.4 fqn.set(info.getElements().getBinaryName((TypeElement) e).toString());
189.5 break;
189.6 default:
189.7 - LOG.log(Level.WARNING, "unexpected element {0}", e);
189.8 + LOG.log(Level.FINE, "unexpected element {0}", e);
189.9 }
189.10 }
189.11 @Override public void cancel() {}
190.1 --- a/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java Wed Jul 27 10:33:10 2011 +0200
190.2 +++ b/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java Wed Jul 27 10:35:25 2011 +0200
190.3 @@ -576,9 +576,9 @@
190.4 put(NbMavenProject.TYPE_APPCLIENT, "org/netbeans/modules/maven/resources/appclient.png"); //NOI18N
190.5 put(NbMavenProject.TYPE_EAR, "org/netbeans/modules/maven/resources/maven_enterprise_application_16.png"); //NOI18N
190.6 put(NbMavenProject.TYPE_POM, "org/netbeans/modules/maven/resources/Maven2Icon.gif"); //NOI18N
190.7 - put(NbMavenProject.TYPE_NBM, "org/netbeans/modules/maven/resources/nbmicon.png"); //NOI18N
190.8 + put(NbMavenProject.TYPE_NBM, "org/netbeans/modules/maven/apisupport/nbmicon.png"); //NOI18N
190.9 put(NbMavenProject.TYPE_OSGI, "org/netbeans/modules/maven/resources/maven_osgi_16.png"); //NOI18N
190.10 - put(NbMavenProject.TYPE_NBM_APPLICATION, "org/netbeans/modules/maven/resources/suiteicon.png"); //NOI18N
190.11 + put(NbMavenProject.TYPE_NBM_APPLICATION, "org/netbeans/modules/maven/apisupport/suiteicon.png"); //NOI18N
190.12 }
190.13 });
190.14
191.1 Binary file maven/src/org/netbeans/modules/maven/resources/nbmicon.png has changed
192.1 Binary file maven/src/org/netbeans/modules/maven/resources/suiteicon.png has changed
193.1 --- a/nbbuild/antsrc/org/netbeans/nbbuild/ParseProjectXml.java Wed Jul 27 10:33:10 2011 +0200
193.2 +++ b/nbbuild/antsrc/org/netbeans/nbbuild/ParseProjectXml.java Wed Jul 27 10:35:25 2011 +0200
193.3 @@ -1477,9 +1477,10 @@
193.4 replaceAll(",", "|").
193.5 replaceAll("\\*\\*", "(.+/)?").
193.6 replaceAll("\\*", "");
193.7 - Pattern p = Pattern.compile("(" + corePattern + ")[^/]+\\.class");
193.8 + // include e.g. icons so that annotation processors using validateResource can confirm they exist
193.9 + Pattern p = Pattern.compile("(" + corePattern + ")[^/]+[.].+");
193.10 boolean foundAtLeastOneEntry = false;
193.11 - // E.g.: (org/netbeans/api/foo/|org/netbeans/spi/foo/)[^/]+\.class
193.12 + // E.g.: (org/netbeans/api/foo/|org/netbeans/spi/foo/)[^/]+[.].+
193.13 OutputStream os = new FileOutputStream(ppjar);
193.14 try {
193.15 ZipOutputStream zos = new ZipOutputStream(os);
194.1 --- a/nbbuild/cluster.properties Wed Jul 27 10:33:10 2011 +0200
194.2 +++ b/nbbuild/cluster.properties Wed Jul 27 10:35:25 2011 +0200
194.3 @@ -418,6 +418,7 @@
194.4 debugger.jpda.ui,\
194.5 debugger.jpda.visual,\
194.6 form,\
194.7 + form.binding,\
194.8 form.j2ee,\
194.9 form.kit,\
194.10 hibernate,\
195.1 --- a/nbbuild/hudson/core-main Wed Jul 27 10:33:10 2011 +0200
195.2 +++ b/nbbuild/hudson/core-main Wed Jul 27 10:35:25 2011 +0200
195.3 @@ -34,6 +34,11 @@
195.4 editor.mimelookup.impl,\
195.5 extexecution,\
195.6 favorites,\
195.7 +hudson,\
195.8 +hudson.maven,\
195.9 +hudson.mercurial,\
195.10 +hudson.subversion,\
195.11 +hudson.tasklist,\
195.12 java.api.common,\
195.13 java.freeform,\
195.14 java.j2seplatform,\
196.1 --- a/openide.awt/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
196.2 +++ b/openide.awt/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
196.3 @@ -54,7 +54,7 @@
196.4 <build-prerequisite/>
196.5 <compile-dependency/>
196.6 <run-dependency>
196.7 - <specification-version>7.39</specification-version>
196.8 + <specification-version>7.51</specification-version>
196.9 </run-dependency>
196.10 </dependency>
196.11 <dependency>
197.1 --- a/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java Wed Jul 27 10:33:10 2011 +0200
197.2 +++ b/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java Wed Jul 27 10:35:25 2011 +0200
197.3 @@ -40,8 +40,6 @@
197.4 package org.netbeans.modules.openide.awt;
197.5
197.6 import java.awt.event.ActionListener;
197.7 -import java.io.IOException;
197.8 -import java.io.InputStream;
197.9 import java.util.Collections;
197.10 import java.util.HashSet;
197.11 import java.util.Set;
197.12 @@ -65,13 +63,12 @@
197.13 import javax.swing.Action;
197.14 import javax.swing.JSeparator;
197.15 import javax.swing.KeyStroke;
197.16 -import javax.tools.FileObject;
197.17 -import javax.tools.StandardLocation;
197.18 import org.openide.awt.ActionID;
197.19 import org.openide.awt.ActionReference;
197.20 import org.openide.awt.ActionReferences;
197.21 import org.openide.awt.ActionRegistration;
197.22 import org.openide.awt.DynamicMenuContent;
197.23 +import org.openide.filesystems.annotations.LayerBuilder;
197.24 import org.openide.filesystems.annotations.LayerBuilder.File;
197.25 import org.openide.filesystems.annotations.LayerGeneratingProcessor;
197.26 import org.openide.filesystems.annotations.LayerGenerationException;
197.27 @@ -179,26 +176,27 @@
197.28 ActionRegistration ar = e.getAnnotation(ActionRegistration.class);
197.29 ActionID aid = e.getAnnotation(ActionID.class);
197.30 if (aid == null) {
197.31 - throw new LayerGenerationException("@ActionRegistration can only be used together with @ActionID annotation", e);
197.32 + throw new LayerGenerationException("@ActionRegistration can only be used together with @ActionID annotation", e, processingEnv, ar);
197.33 }
197.34 if (aid.category().startsWith("Actions/")) {
197.35 - throw new LayerGenerationException("@ActionID category() cannot contain /", e);
197.36 + throw new LayerGenerationException("@ActionID category() cannot contain /", e, processingEnv, aid, "category");
197.37 }
197.38 if (!FQN.matcher(aid.id()).matches()) {
197.39 - throw new LayerGenerationException("@ActionID id() must be valid fully qualified name", e);
197.40 + throw new LayerGenerationException("@ActionID id() must be valid fully qualified name", e, processingEnv, aid, "id");
197.41 }
197.42 String id = aid.id().replace('.', '-');
197.43 - File f = layer(e).file("Actions/" + aid.category() + "/" + id + ".instance");
197.44 - f.bundlevalue("displayName", ar.displayName());
197.45 + LayerBuilder builder = layer(e);
197.46 + File f = builder.file("Actions/" + aid.category() + "/" + id + ".instance");
197.47 + f.bundlevalue("displayName", ar.displayName(), ar, "displayName");
197.48
197.49 String menuText = ar.menuText();
197.50 if(!menuText.isEmpty()) {
197.51 - f.bundlevalue("menuText", menuText);
197.52 + f.bundlevalue("menuText", menuText, ar, "menuText");
197.53 }
197.54
197.55 String popupText = ar.popupText();
197.56 if (!popupText.isEmpty()) {
197.57 - f.bundlevalue("popupText", popupText);
197.58 + f.bundlevalue("popupText", popupText, ar, "popupText");
197.59 }
197.60
197.61 String key;
197.62 @@ -212,25 +210,25 @@
197.63 !e.getModifiers().contains(Modifier.STATIC) ||
197.64 !e.getModifiers().contains(Modifier.FINAL)
197.65 ) {
197.66 - throw new LayerGenerationException("Only static string constant fields can be annotated", e);
197.67 + throw new LayerGenerationException("Only static string constant fields can be annotated", e, processingEnv, ar);
197.68 }
197.69 if (ar.key().length() != 0) {
197.70 - throw new LayerGenerationException("When annotating field, one cannot define key()", e);
197.71 + throw new LayerGenerationException("When annotating field, one cannot define key()", e, processingEnv, ar, "key");
197.72 }
197.73
197.74 createDelegate = false;
197.75 key = var.getConstantValue().toString();
197.76 } else if (e.getKind() == ElementKind.CLASS) {
197.77 if (!isAssignable(e.asType(), actionListener)) {
197.78 - throw new LayerGenerationException("Class annotated with @ActionRegistration must implement java.awt.event.ActionListener!", e);
197.79 + throw new LayerGenerationException("Class annotated with @ActionRegistration must implement java.awt.event.ActionListener!", e, processingEnv, ar);
197.80 }
197.81 if (!e.getModifiers().contains(Modifier.PUBLIC)) {
197.82 - throw new LayerGenerationException("Class has to be public", e);
197.83 + throw new LayerGenerationException("Class has to be public", e, processingEnv, ar);
197.84 }
197.85 key = ar.key();
197.86 } else {
197.87 assert e.getKind() == ElementKind.METHOD : e;
197.88 - layer(e).instanceFile("dummy", null, ActionListener.class);
197.89 + builder.instanceFile("dummy", null, ActionListener.class, ar, null);
197.90 key = ar.key();
197.91 }
197.92
197.93 @@ -244,7 +242,7 @@
197.94
197.95 if (direct) {
197.96 if (key.length() != 0) {
197.97 - throw new LayerGenerationException("Cannot specify key and implement Presenter interface", e);
197.98 + throw new LayerGenerationException("Cannot specify key and implement Presenter interface", e, processingEnv, ar, "key");
197.99 }
197.100 f.instanceAttribute("instanceCreate", Action.class);
197.101 } else {
197.102 @@ -259,29 +257,13 @@
197.103 }
197.104 if (createDelegate) {
197.105 try {
197.106 - f.instanceAttribute("delegate", ActionListener.class);
197.107 + f.instanceAttribute("delegate", ActionListener.class, ar, null);
197.108 } catch (LayerGenerationException ex) {
197.109 - generateContext(e, f);
197.110 + generateContext(e, f, ar);
197.111 }
197.112 }
197.113 if (ar.iconBase().length() > 0) {
197.114 - boolean found = false;
197.115 - for (StandardLocation l : StandardLocation.values()) {
197.116 - try {
197.117 - processingEnv.getFiler().getResource(l, "", ar.iconBase());
197.118 - found = true;
197.119 - break;
197.120 - } catch (IOException ex) {
197.121 - continue;
197.122 - } catch (IllegalArgumentException x) {
197.123 - throw new LayerGenerationException("Problem with " + ar.iconBase() + " (should be resource path with no leading slash)", e);
197.124 - }
197.125 - }
197.126 - if (!found) {
197.127 - throw new LayerGenerationException(
197.128 - "Cannot find iconBase file at " + ar.iconBase(), e
197.129 - );
197.130 - }
197.131 + builder.validateResource(ar.iconBase(), e, ar, "iconBase", true);
197.132 f.stringvalue("iconBase", ar.iconBase());
197.133 }
197.134 f.boolvalue("noIconInMenu", !ar.iconInMenu());
197.135 @@ -310,35 +292,34 @@
197.136 if (e.getAnnotation(ActionRegistration.class) != null) {
197.137 continue;
197.138 }
197.139 + ActionReference ref = e.getAnnotation(ActionReference.class);
197.140 ActionID id = e.getAnnotation(ActionID.class);
197.141 if (id != null) {
197.142 - ActionReference ref = e.getAnnotation(ActionReference.class);
197.143 processReferences(e, ref, id);
197.144 continue;
197.145 }
197.146 - throw new LayerGenerationException("Don't use @ActionReference without @ActionID", e);
197.147 + throw new LayerGenerationException("Don't use @ActionReference without @ActionID", e, processingEnv, ref);
197.148 }
197.149 for (Element e : roundEnv.getElementsAnnotatedWith(ActionReferences.class)) {
197.150 if (e.getAnnotation(ActionRegistration.class) != null) {
197.151 continue;
197.152 }
197.153 + ActionReferences refs = e.getAnnotation(ActionReferences.class);
197.154 if (e.getKind() != ElementKind.PACKAGE) {
197.155 ActionID id = e.getAnnotation(ActionID.class);
197.156 if (id == null) {
197.157 - throw new LayerGenerationException("Don't use @ActionReferences without @ActionRegistration", e);
197.158 + throw new LayerGenerationException("Don't use @ActionReferences without @ActionRegistration", e, processingEnv, refs);
197.159 }
197.160 - ActionReferences refs = e.getAnnotation(ActionReferences.class);
197.161 for (ActionReference actionReference : refs.value()) {
197.162 if (!actionReference.id().id().isEmpty() || !actionReference.id().category().isEmpty()) {
197.163 - throw new LayerGenerationException("Don't specify additional id=@ActionID(...) when using @ActionID on the element", e);
197.164 + throw new LayerGenerationException("Don't specify additional id=@ActionID(...) when using @ActionID on the element", e, processingEnv, actionReference.id());
197.165 }
197.166 processReferences(e, actionReference, id);
197.167 }
197.168 } else {
197.169 - ActionReferences refs = e.getAnnotation(ActionReferences.class);
197.170 for (ActionReference actionReference : refs.value()) {
197.171 if (actionReference.id().id().isEmpty() || actionReference.id().category().isEmpty()) {
197.172 - throw new LayerGenerationException("Specify real id=@ActionID(...)", e);
197.173 + throw new LayerGenerationException("Specify real id=@ActionID(...)", e, processingEnv, actionReference.id());
197.174 }
197.175 processReferences(e, actionReference, actionReference.id());
197.176 }
197.177 @@ -352,7 +333,7 @@
197.178 return e == null ? null : e.asType();
197.179 }
197.180
197.181 - private void generateContext(Element e, File f) throws LayerGenerationException {
197.182 + private void generateContext(Element e, File f, ActionRegistration ar) throws LayerGenerationException {
197.183 ExecutableElement ee = null;
197.184 ExecutableElement candidate = null;
197.185 for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
197.186 @@ -362,7 +343,7 @@
197.187 continue;
197.188 }
197.189 if (ee != null) {
197.190 - throw new LayerGenerationException("Only one public constructor allowed", e); // NOI18N
197.191 + throw new LayerGenerationException("Only one public constructor allowed", e, processingEnv, ar); // NOI18N
197.192 }
197.193 ee = element;
197.194 }
197.195 @@ -412,7 +393,7 @@
197.196 private void processReferences(Element e, ActionReference ref, ActionID aid) throws LayerGenerationException {
197.197 if (!ref.id().category().isEmpty() && !ref.id().id().isEmpty()) {
197.198 if (!aid.id().equals(ref.id().id()) || !aid.category().equals(ref.id().category())) {
197.199 - throw new LayerGenerationException("Can't specify id() attribute when @ActionID provided on the element", e);
197.200 + throw new LayerGenerationException("Can't specify id() attribute when @ActionID provided on the element", e, processingEnv, aid);
197.201 }
197.202 }
197.203 String name = ref.name();
197.204 @@ -427,7 +408,7 @@
197.205 "Registrations in Shortcuts folder need to represent a key. "
197.206 + "Specify value for 'name' attribute.\n"
197.207 + "See org.openide.util.Utilities.stringToKeys for possible values. Current "
197.208 - + "name=\"" + name + "\" is not valid.\n"
197.209 + + "name=\"" + name + "\" is not valid.\n", e, processingEnv, ref, "path"
197.210 );
197.211 }
197.212 }
197.213 @@ -439,7 +420,7 @@
197.214
197.215 if (ref.separatorAfter() != Integer.MAX_VALUE) {
197.216 if (ref.position() == Integer.MAX_VALUE || ref.position() >= ref.separatorAfter()) {
197.217 - throw new LayerGenerationException("separatorAfter() must be greater than position()", e);
197.218 + throw new LayerGenerationException("separatorAfter() must be greater than position()", e, processingEnv, ref);
197.219 }
197.220 File after = layer(e).file(ref.path() + "/" + name + "-separatorAfter.instance");
197.221 after.newvalue("instanceCreate", JSeparator.class.getName());
197.222 @@ -448,7 +429,7 @@
197.223 }
197.224 if (ref.separatorBefore() != Integer.MAX_VALUE) {
197.225 if (ref.position() == Integer.MAX_VALUE || ref.position() <= ref.separatorBefore()) {
197.226 - throw new LayerGenerationException("separatorBefore() must be lower than position()", e);
197.227 + throw new LayerGenerationException("separatorBefore() must be lower than position()", e, processingEnv, ref);
197.228 }
197.229 File before = layer(e).file(ref.path() + "/" + name + "-separatorBefore.instance");
197.230 before.newvalue("instanceCreate", JSeparator.class.getName());
198.1 --- a/openide.filesystems/apichanges.xml Wed Jul 27 10:33:10 2011 +0200
198.2 +++ b/openide.filesystems/apichanges.xml Wed Jul 27 10:35:25 2011 +0200
198.3 @@ -49,6 +49,44 @@
198.4 <apidef name="filesystems">Filesystems API</apidef>
198.5 </apidefs>
198.6 <changes>
198.7 + <change id="validateResource_196452">
198.8 + <api name="filesystems"/>
198.9 + <summary><code>LayerBuilder</code> can validate resources</summary>
198.10 + <version major="7" minor="51"/>
198.11 + <date day="25" month="7" year="2011"/>
198.12 + <author login="jglick"/>
198.13 + <compatibility addition="yes"/>
198.14 + <description>
198.15 + <p>
198.16 + <code>LayerBuilder</code> has a new <code>validateResource</code> method.
198.17 + <code>absolutizeResource</code> was also added.
198.18 + </p>
198.19 + </description>
198.20 + <class package="org.openide.filesystems.annotations" name="LayerBuilder"/>
198.21 + <issue number="196452"/>
198.22 + </change>
198.23 + <change id="LayerGenerationException_194545">
198.24 + <api name="filesystems"/>
198.25 + <summary><code>LayerGenerationException</code> has new constructors</summary>
198.26 + <version major="7" minor="50"/>
198.27 + <date day="25" month="7" year="2011"/>
198.28 + <author login="jglick"/>
198.29 + <compatibility addition="yes">
198.30 + <p>
198.31 + Code using the constructors not specifying an annotation should now do so.
198.32 + </p>
198.33 + </compatibility>
198.34 + <description>
198.35 + <p>
198.36 + <code>LayerGenerationException</code> has new constructors making it easier to specify
198.37 + the particular annotation responsible for a problem.
198.38 + Some methods in <code>LayerBuilder</code> have new overloads to take advantage of it.
198.39 + </p>
198.40 + </description>
198.41 + <class package="org.openide.filesystems.annotations" name="LayerGenerationException"/>
198.42 + <class package="org.openide.filesystems.annotations" name="LayerBuilder"/>
198.43 + <issue number="194545"/>
198.44 + </change>
198.45 <change id="getConfigObject">
198.46 <api name="filesystems"/>
198.47 <summary>FileUtil.getConfigObject</summary>
198.48 @@ -59,7 +97,7 @@
198.49 <description>
198.50 <p>
198.51 One can convert files in SystemFileSystem to Object with
198.52 - a
198.53 + a
198.54 <a href="@TOP@org/openide/filesystems/FileUtil.html#getConfigObject(java.lang.String,%20java.lang.Class)">
198.55 single utility method</a>.
198.56 </p>
199.1 --- a/openide.filesystems/manifest.mf Wed Jul 27 10:33:10 2011 +0200
199.2 +++ b/openide.filesystems/manifest.mf Wed Jul 27 10:35:25 2011 +0200
199.3 @@ -2,5 +2,5 @@
199.4 OpenIDE-Module: org.openide.filesystems
199.5 OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
199.6 OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
199.7 -OpenIDE-Module-Specification-Version: 7.49
199.8 +OpenIDE-Module-Specification-Version: 7.51
199.9
200.1 --- a/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java Wed Jul 27 10:33:10 2011 +0200
200.2 +++ b/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java Wed Jul 27 10:35:25 2011 +0200
200.3 @@ -46,7 +46,9 @@
200.4 import java.io.IOException;
200.5 import java.io.InputStream;
200.6 import java.io.ObjectOutputStream;
200.7 +import java.lang.annotation.Annotation;
200.8 import java.net.URI;
200.9 +import java.net.URISyntaxException;
200.10 import java.util.Arrays;
200.11 import java.util.LinkedHashMap;
200.12 import java.util.LinkedList;
200.13 @@ -66,6 +68,8 @@
200.14 import javax.lang.model.type.TypeMirror;
200.15 import javax.lang.model.util.ElementFilter;
200.16 import javax.tools.Diagnostic.Kind;
200.17 +import javax.tools.FileObject;
200.18 +import javax.tools.JavaFileManager.Location;
200.19 import javax.tools.StandardLocation;
200.20 import org.openide.util.NbBundle.Messages;
200.21 import org.w3c.dom.Document;
200.22 @@ -146,8 +150,27 @@
200.23 * {@linkplain TypeElement class} or {@linkplain ExecutableElement method}
200.24 * @throws LayerGenerationException if the associated element would not be loadable as an instance of the specified type
200.25 */
200.26 - public File instanceFile(String path, String name, Class type) throws IllegalArgumentException, LayerGenerationException {
200.27 - String[] clazzOrMethod = instantiableClassOrMethod(type);
200.28 + public File instanceFile(String path, String name, Class<?> type) throws IllegalArgumentException, LayerGenerationException {
200.29 + return instanceFile(path, name, type, null, null);
200.30 + }
200.31 + /**
200.32 + * Generates an instance file whose {@code InstanceCookie} would load the associated class or method.
200.33 + * Useful for {@link LayerGeneratingProcessor}s which define layer fragments which instantiate Java objects from the annotated code.
200.34 + * <p>While you can pick a specific instance file name, if possible you should pass null for {@code name}
200.35 + * as using the generated name will help avoid accidental name collisions between annotations.
200.36 + * @param path path to folder of instance file, e.g. {@code "Menu/File"}
200.37 + * @param name instance file basename, e.g. {@code "my-menu-Item"}, or null to pick a name according to the element
200.38 + * @param type a type to which the instance ought to be assignable, or null to skip this check
200.39 + * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.40 + * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.41 + * @return an instance file (call {@link File#write} to finalize)
200.42 + * @throws IllegalArgumentException if the builder is not associated with exactly one
200.43 + * {@linkplain TypeElement class} or {@linkplain ExecutableElement method}
200.44 + * @throws LayerGenerationException if the associated element would not be loadable as an instance of the specified type
200.45 + * @since 7.50
200.46 + */
200.47 + public File instanceFile(String path, String name, Class<?> type, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException {
200.48 + String[] clazzOrMethod = instantiableClassOrMethod(type, annotation, annotationMethod);
200.49 String clazz = clazzOrMethod[0];
200.50 String method = clazzOrMethod[1];
200.51 String basename;
200.52 @@ -185,7 +208,28 @@
200.53 * @since org.openide.filesystems 7.27
200.54 */
200.55 public File instanceFile(String path, String name) throws IllegalArgumentException, LayerGenerationException {
200.56 - String[] clazzOrMethod = instantiableClassOrMethod(null);
200.57 + return instanceFile(path, name, null, null);
200.58 + }
200.59 + /**
200.60 + * Generates an instance file that is <em>not initialized</em> with an instance.
200.61 + * Useful for {@link LayerGeneratingProcessor}s which define layer fragments
200.62 + * which indirectly instantiate Java objects from the annotated code via a generic factory method.
200.63 + * Invoke the factory using {@link File#methodvalue} on {@code instanceCreate}
200.64 + * and configure it with a {@link File#instanceAttribute} appropriate to the factory.
200.65 + * <p>While you can pick a specific instance file name, if possible you should pass null for {@code name}
200.66 + * as using the generated name will help avoid accidental name collisions between annotations.
200.67 + * @param path path to folder of instance file, e.g. {@code "Menu/File"}
200.68 + * @param name instance file basename, e.g. {@code "my-menu-Item"}, or null to pick a name according to the element
200.69 + * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.70 + * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.71 + * @return an instance file (call {@link File#write} to finalize)
200.72 + * @throws IllegalArgumentException if the builder is not associated with exactly one
200.73 + * {@linkplain TypeElement class} or {@linkplain ExecutableElement method}
200.74 + * @throws LayerGenerationException if the associated element would not be loadable as an instance
200.75 + * @since org.openide.filesystems 7.50
200.76 + */
200.77 + public File instanceFile(String path, String name, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException {
200.78 + String[] clazzOrMethod = instantiableClassOrMethod(null, annotation, annotationMethod);
200.79 String clazz = clazzOrMethod[0];
200.80 String method = clazzOrMethod[1];
200.81 String basename;
200.82 @@ -200,7 +244,7 @@
200.83 return file(path + "/" + basename + ".instance");
200.84 }
200.85
200.86 - private String[] instantiableClassOrMethod(Class type) throws IllegalArgumentException, LayerGenerationException {
200.87 + private String[] instantiableClassOrMethod(Class<?> type, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException {
200.88 if (originatingElement == null) {
200.89 throw new IllegalArgumentException("Only applicable to builders with exactly one associated element");
200.90 }
200.91 @@ -212,7 +256,7 @@
200.92 case CLASS: {
200.93 String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement).toString();
200.94 if (originatingElement.getModifiers().contains(Modifier.ABSTRACT)) {
200.95 - throw new LayerGenerationException(clazz + " must not be abstract", originatingElement);
200.96 + throw new LayerGenerationException(clazz + " must not be abstract", originatingElement, processingEnv, annotation, annotationMethod);
200.97 }
200.98 {
200.99 boolean hasDefaultCtor = false;
200.100 @@ -223,14 +267,14 @@
200.101 }
200.102 }
200.103 if (!hasDefaultCtor) {
200.104 - throw new LayerGenerationException(clazz + " must have a no-argument constructor", originatingElement);
200.105 + throw new LayerGenerationException(clazz + " must have a no-argument constructor", originatingElement, processingEnv, annotation, annotationMethod);
200.106 }
200.107 }
200.108 if (typeMirror != null && !processingEnv.getTypeUtils().isAssignable(originatingElement.asType(), typeMirror)) {
200.109 - throw new LayerGenerationException(clazz + " is not assignable to " + typeMirror, originatingElement);
200.110 + throw new LayerGenerationException(clazz + " is not assignable to " + typeMirror, originatingElement, processingEnv, annotation, annotationMethod);
200.111 }
200.112 if (!originatingElement.getModifiers().contains(Modifier.PUBLIC)) {
200.113 - throw new LayerGenerationException(clazz + " is not public", originatingElement);
200.114 + throw new LayerGenerationException(clazz + " is not public", originatingElement, processingEnv, annotation, annotationMethod);
200.115 }
200.116 return new String[] {clazz, null};
200.117 }
200.118 @@ -238,13 +282,13 @@
200.119 String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement.getEnclosingElement()).toString();
200.120 String method = originatingElement.getSimpleName().toString();
200.121 if (!originatingElement.getModifiers().contains(Modifier.STATIC)) {
200.122 - throw new LayerGenerationException(clazz + "." + method + " must be static", originatingElement);
200.123 + throw new LayerGenerationException(clazz + "." + method + " must be static", originatingElement, processingEnv, annotation, annotationMethod);
200.124 }
200.125 if (!((ExecutableElement) originatingElement).getParameters().isEmpty()) {
200.126 - throw new LayerGenerationException(clazz + "." + method + " must not take arguments", originatingElement);
200.127 + throw new LayerGenerationException(clazz + "." + method + " must not take arguments", originatingElement, processingEnv, annotation, annotationMethod);
200.128 }
200.129 if (typeMirror != null && !processingEnv.getTypeUtils().isAssignable(((ExecutableElement) originatingElement).getReturnType(), typeMirror)) {
200.130 - throw new LayerGenerationException(clazz + "." + method + " is not assignable to " + typeMirror, originatingElement);
200.131 + throw new LayerGenerationException(clazz + "." + method + " is not assignable to " + typeMirror, originatingElement, processingEnv, annotation, annotationMethod);
200.132 }
200.133 return new String[] {clazz, method};
200.134 }
200.135 @@ -270,6 +314,94 @@
200.136 }
200.137
200.138 /**
200.139 + * Validates a resource named in an annotation.
200.140 + * <p>Note that resources found in the binary classpath (if permitted)
200.141 + * cannot actually be located when running inside javac on JDK 6 (see #196933 for discussion), in which case
200.142 + * no exception is thrown but the return value may not permit {@link FileObject#openInputStream}.
200.143 + * <p>Also remember that the binary compilation classpath for an Ant-based NetBeans module does
200.144 + * not include non-public packages.
200.145 + * (As of the 7.1 harness it does include non-classfile resources from public packages of module dependencies.)
200.146 + * The processorpath does contain all of these but it is not consulted.
200.147 + * The classpath for a Maven-based module does contain all resources from dependencies.
200.148 + * @param resource an absolute resource path with no leading slash (perhaps the output of {@link #absolutizeResource})
200.149 + * @param originatingElement the annotated element; used both for error reporting, and (optionally) for its package
200.150 + * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.151 + * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.152 + * @param searchClasspath true to search in the binary classpath and not just source path (see caveat about JDK 6)
200.153 + * @return the content of the resource, for further validation
200.154 + * @throws LayerGenerationException if no such resource can be found
200.155 + * @since 7.51
200.156 + */
200.157 + public FileObject validateResource(String resource, Element originatingElement, Annotation annotation, String annotationMethod, boolean searchClasspath) throws LayerGenerationException {
200.158 + if (resource.startsWith("/")) {
200.159 + throw new LayerGenerationException("do not use leading slashes on resource paths", originatingElement, processingEnv, annotation, annotationMethod);
200.160 + }
200.161 + if (searchClasspath) {
200.162 + for (Location loc : new Location[] {StandardLocation.SOURCE_PATH, /* #181355 */StandardLocation.CLASS_OUTPUT, StandardLocation.CLASS_PATH, StandardLocation.PLATFORM_CLASS_PATH}) {
200.163 + try {
200.164 + return processingEnv.getFiler().getResource(loc, "", resource);
200.165 + } catch (IOException ex) {
200.166 + continue;
200.167 + }
200.168 + }
200.169 + throw new LayerGenerationException("Cannot find resource " + resource, originatingElement, processingEnv, annotation, annotationMethod);
200.170 + } else {
200.171 + try {
200.172 + try {
200.173 + FileObject f = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", resource);
200.174 + f.openInputStream().close();
200.175 + return f;
200.176 + } catch (FileNotFoundException x) {
200.177 + try {
200.178 + FileObject f = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
200.179 + f.openInputStream().close();
200.180 + return f;
200.181 + } catch (IOException x2) {
200.182 + throw x;
200.183 + }
200.184 + }
200.185 + } catch (IOException x) {
200.186 + throw new LayerGenerationException("Cannot find resource " + resource, originatingElement, processingEnv, annotation, annotationMethod);
200.187 + }
200.188 + }
200.189 + }
200.190 +
200.191 + /**
200.192 + * Allows a processor to accept relative resource paths.
200.193 + * For example, to produce the output value {@code net/nowhere/lib/icon.png}
200.194 + * given an element in the package {@code net.nowhere.app}, the following inputs are permitted:
200.195 + * <ul>
200.196 + * <li>{@code ../lib/icon.png}
200.197 + * <li>{@code /net/nowhere/lib/icon.png}
200.198 + * </ul>
200.199 + * @param originatingElement the annotated element, used for its package
200.200 + * @param resource a possibly relative resource path
200.201 + * @return an absolute resource path (with no leading slash)
200.202 + * @throws LayerGenerationException in case the resource path is malformed
200.203 + * @since 7.51
200.204 + */
200.205 + public static String absolutizeResource(Element originatingElement, String resource) throws LayerGenerationException {
200.206 + if (resource.startsWith("/")) {
200.207 + return resource.substring(1);
200.208 + } else {
200.209 + try {
200.210 + return new URI(null, findPackage(originatingElement).replace('.', '/') + "/", null).resolve(new URI(null, resource, null)).getPath();
200.211 + } catch (URISyntaxException x) {
200.212 + throw new LayerGenerationException(x.toString(), originatingElement);
200.213 + }
200.214 + }
200.215 + }
200.216 + private static String findPackage(Element e) {
200.217 + switch (e.getKind()) {
200.218 + case PACKAGE:
200.219 + return ((PackageElement) e).getQualifiedName().toString();
200.220 + default:
200.221 + return findPackage(e.getEnclosingElement());
200.222 + }
200.223 + }
200.224 +
200.225 +
200.226 + /**
200.227 * Builder for creating a single file entry.
200.228 */
200.229 public final class File {
200.230 @@ -485,8 +617,23 @@
200.231 * @throws IllegalArgumentException if the associated element is not a {@linkplain TypeElement class} or {@linkplain ExecutableElement method}
200.232 * @throws LayerGenerationException if the associated element would not be loadable as an instance of the specified type
200.233 */
200.234 - public File instanceAttribute(String attr, Class type) throws IllegalArgumentException, LayerGenerationException {
200.235 - String[] clazzOrMethod = instantiableClassOrMethod(type);
200.236 + public File instanceAttribute(String attr, Class<?> type) throws IllegalArgumentException, LayerGenerationException {
200.237 + return instanceAttribute(attr, type, null, null);
200.238 + }
200.239 + /**
200.240 + * Adds an attribute to load the associated class or method.
200.241 + * Useful for {@link LayerGeneratingProcessor}s which define layer fragments which instantiate Java objects from the annotated code.
200.242 + * @param attr the attribute name
200.243 + * @param type a type to which the instance ought to be assignable, or null to skip this check
200.244 + * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.245 + * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.246 + * @return this builder
200.247 + * @throws IllegalArgumentException if the associated element is not a {@linkplain TypeElement class} or {@linkplain ExecutableElement method}
200.248 + * @throws LayerGenerationException if the associated element would not be loadable as an instance of the specified type
200.249 + * @since 7.50
200.250 + */
200.251 + public File instanceAttribute(String attr, Class<?> type, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException {
200.252 + String[] clazzOrMethod = instantiableClassOrMethod(type, annotation, annotationMethod);
200.253 if (clazzOrMethod[1] == null) {
200.254 newvalue(attr, clazzOrMethod[0]);
200.255 } else {
200.256 @@ -518,6 +665,22 @@
200.257 * @throws LayerGenerationException if a bundle key is requested but it cannot be found in sources
200.258 */
200.259 public File bundlevalue(String attr, String label) throws LayerGenerationException {
200.260 + return bundlevalue(attr, label, null, null);
200.261 + }
200.262 + /**
200.263 + * Adds an attribute for a possibly localized string.
200.264 + * @param attr the attribute name
200.265 + * @param label either a general string to store as is, or a resource bundle reference
200.266 + * such as {@code "my.module.Bundle#some_key"},
200.267 + * or just {@code "#some_key"} to load from a {@code "Bundle"}
200.268 + * in the same package as the element associated with this builder (if exactly one)
200.269 + * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.270 + * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
200.271 + * @return this builder
200.272 + * @throws LayerGenerationException if a bundle key is requested but it cannot be found in sources
200.273 + * @since 7.50
200.274 + */
200.275 + public File bundlevalue(String attr, String label, Annotation annotation, String annotationMethod) throws LayerGenerationException {
200.276 String javaIdentifier = "(?:\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)";
200.277 Matcher m = Pattern.compile("((?:" + javaIdentifier + "\\.)+[^\\s.#]+)?#(\\S*)").matcher(label);
200.278 if (m.matches()) {
200.279 @@ -533,14 +696,14 @@
200.280 }
200.281 bundle = ((PackageElement) referenceElement).getQualifiedName() + ".Bundle";
200.282 }
200.283 - verifyBundleKey(bundle, key, m.group(1) == null);
200.284 + verifyBundleKey(bundle, key, m.group(1) == null, annotation, annotationMethod);
200.285 bundlevalue(attr, bundle, key);
200.286 } else {
200.287 stringvalue(attr, label);
200.288 }
200.289 return this;
200.290 }
200.291 - private void verifyBundleKey(String bundle, String key, boolean samePackage) throws LayerGenerationException {
200.292 + private void verifyBundleKey(String bundle, String key, boolean samePackage, Annotation annotation, String annotationMethod) throws LayerGenerationException {
200.293 if (processingEnv == null) {
200.294 return;
200.295 }
200.296 @@ -556,29 +719,19 @@
200.297 }
200.298 }
200.299 }
200.300 - String resource = bundle.replace('.', '/') + ".properties";
200.301 try {
200.302 - InputStream is;
200.303 - try {
200.304 - is = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", resource).openInputStream();
200.305 - } catch (FileNotFoundException x) { // #181355
200.306 - try {
200.307 - is = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource).openInputStream();
200.308 - } catch (IOException x2) {
200.309 - throw x;
200.310 - }
200.311 - }
200.312 + InputStream is = validateResource(bundle.replace('.', '/') + ".properties", originatingElement, null, null, false).openInputStream();
200.313 try {
200.314 Properties p = new Properties();
200.315 p.load(is);
200.316 if (p.getProperty(key) == null) {
200.317 - throw new LayerGenerationException("No key '" + key + "' found in " + resource, originatingElement);
200.318 + throw new LayerGenerationException("No key '" + key + "' found in " + bundle, originatingElement, processingEnv, annotation, annotationMethod);
200.319 }
200.320 } finally {
200.321 is.close();
200.322 }
200.323 } catch (IOException x) {
200.324 - throw new LayerGenerationException("Could not open " + resource + ": " + x, originatingElement);
200.325 + throw new LayerGenerationException("Could not open " + bundle + ": " + x, originatingElement, processingEnv, annotation, annotationMethod);
200.326 }
200.327 }
200.328
201.1 --- a/openide.filesystems/src/org/openide/filesystems/annotations/LayerGenerationException.java Wed Jul 27 10:33:10 2011 +0200
201.2 +++ b/openide.filesystems/src/org/openide/filesystems/annotations/LayerGenerationException.java Wed Jul 27 10:35:25 2011 +0200
201.3 @@ -42,13 +42,19 @@
201.4
201.5 package org.openide.filesystems.annotations;
201.6
201.7 +import java.lang.annotation.Annotation;
201.8 +import java.util.Map;
201.9 import javax.annotation.processing.Messager;
201.10 +import javax.annotation.processing.ProcessingEnvironment;
201.11 import javax.lang.model.element.AnnotationMirror;
201.12 import javax.lang.model.element.AnnotationValue;
201.13 import javax.lang.model.element.Element;
201.14 +import javax.lang.model.element.ExecutableElement;
201.15 +import javax.lang.model.element.TypeElement;
201.16
201.17 /**
201.18 * Exception thrown when a layer entry cannot be generated due to erroneous sources.
201.19 + * @see LayerGeneratingProcessor
201.20 * @since org.openide.filesystems 7.15
201.21 */
201.22 public class LayerGenerationException extends Exception {
201.23 @@ -63,7 +69,7 @@
201.24 * @see Messager#printMessage(javax.tools.Diagnostic.Kind, CharSequence)
201.25 */
201.26 public LayerGenerationException(String message) {
201.27 - this(message, null, null, null);
201.28 + this(message, (Element) null, (AnnotationMirror) null, (AnnotationValue) null);
201.29 }
201.30
201.31 /**
201.32 @@ -73,7 +79,7 @@
201.33 * @see Messager#printMessage(javax.tools.Diagnostic.Kind, CharSequence, Element)
201.34 */
201.35 public LayerGenerationException(String message, Element erroneousElement) {
201.36 - this(message, erroneousElement, null, null);
201.37 + this(message, erroneousElement, (AnnotationMirror) null, (AnnotationValue) null);
201.38 }
201.39
201.40 /**
201.41 @@ -84,7 +90,7 @@
201.42 * @see Messager#printMessage(javax.tools.Diagnostic.Kind, CharSequence, Element, AnnotationMirror)
201.43 */
201.44 public LayerGenerationException(String message, Element erroneousElement, AnnotationMirror erroneousAnnotation) {
201.45 - this(message, erroneousElement, erroneousAnnotation, null);
201.46 + this(message, erroneousElement, erroneousAnnotation, (AnnotationValue) null);
201.47 }
201.48
201.49 /**
201.50 @@ -102,4 +108,84 @@
201.51 this.erroneousAnnotationValue = erroneousAnnotationValue;
201.52 }
201.53
201.54 + /**
201.55 + * An exception with an associated annotation.
201.56 + * Convenience constructor which locates an annotation on the erroneous element for you.
201.57 + * @param message a detail message which could be reported to the user
201.58 + * @param erroneousElement the associated element
201.59 + * @param processingEnv the processing environment passed to the processor
201.60 + * @param erroneousAnnotation the reflected annotation on the element (may be null as a convenience)
201.61 + * @see Messager#printMessage(javax.tools.Diagnostic.Kind, CharSequence, Element, AnnotationMirror)
201.62 + * @since 7.50
201.63 + */
201.64 + public LayerGenerationException(String message, Element erroneousElement, ProcessingEnvironment processingEnv,
201.65 + Annotation erroneousAnnotation) {
201.66 + this(message, erroneousElement, processingEnv, erroneousAnnotation, (String) null);
201.67 + }
201.68 +
201.69 + /**
201.70 + * An exception with an associated annotation value.
201.71 + * Convenience constructor which locates an annotation and its value on the erroneous element for you.
201.72 + * @param message a detail message which could be reported to the user
201.73 + * @param erroneousElement the associated element
201.74 + * @param processingEnv the processing environment passed to the processor
201.75 + * @param erroneousAnnotation the reflected annotation on the element (may be null as a convenience)
201.76 + * @param erroneousAnnotationMethod the name of a method in that annotation (may be null)
201.77 + * @see Messager#printMessage(javax.tools.Diagnostic.Kind, CharSequence, Element, AnnotationMirror, AnnotationValue)
201.78 + * @since 7.50
201.79 + */
201.80 + public LayerGenerationException(String message, Element erroneousElement, ProcessingEnvironment processingEnv,
201.81 + Annotation erroneousAnnotation, String erroneousAnnotationMethod) {
201.82 + super(message);
201.83 + this.erroneousElement = erroneousElement;
201.84 + if (erroneousAnnotation != null) {
201.85 + Class<? extends Annotation> clazz = null;
201.86 + Class<?> implClass = erroneousAnnotation.getClass();
201.87 + for (Class<?> xface : implClass.getInterfaces()) {
201.88 + if (xface.isAnnotation()) {
201.89 + if (clazz == null) {
201.90 + clazz = xface.asSubclass(Annotation.class);
201.91 + } else {
201.92 + throw new IllegalArgumentException(">1 annotation implemented by " + implClass.getName());
201.93 + }
201.94 + }
201.95 + }
201.96 + if (clazz == null) {
201.97 + throw new IllegalArgumentException("no annotation implemented by " + implClass.getName());
201.98 + }
201.99 + if (erroneousAnnotationMethod != null) {
201.100 + try {
201.101 + clazz.getMethod(erroneousAnnotationMethod);
201.102 + } catch (NoSuchMethodException x) {
201.103 + throw new IllegalArgumentException("No such method " + erroneousAnnotationMethod + " in " + erroneousAnnotation);
201.104 + } catch (SecurityException x) {/* ignore? */}
201.105 + }
201.106 + this.erroneousAnnotation = findAnnotationMirror(erroneousElement, processingEnv, clazz);
201.107 + this.erroneousAnnotationValue = this.erroneousAnnotation != null && erroneousAnnotationMethod != null ?
201.108 + findAnnotationValue(this.erroneousAnnotation, erroneousAnnotationMethod) : null;
201.109 + } else {
201.110 + this.erroneousAnnotation = null;
201.111 + this.erroneousAnnotationValue = null;
201.112 + }
201.113 + }
201.114 +
201.115 + private static AnnotationMirror findAnnotationMirror(Element element, ProcessingEnvironment processingEnv, Class<? extends Annotation> annotation) {
201.116 + for (AnnotationMirror ann : element.getAnnotationMirrors()) {
201.117 + if (processingEnv.getElementUtils().getBinaryName((TypeElement) ann.getAnnotationType().asElement()).
201.118 + contentEquals(annotation.getName())) {
201.119 + return ann;
201.120 + }
201.121 + }
201.122 + return null;
201.123 + }
201.124 +
201.125 + private AnnotationValue findAnnotationValue(AnnotationMirror annotation, String name) {
201.126 + for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> entry : annotation.getElementValues().entrySet()) {
201.127 + if (entry.getKey().getSimpleName().contentEquals(name)) {
201.128 + return entry.getValue();
201.129 + }
201.130 + }
201.131 + return null;
201.132 + }
201.133 +
201.134 }
202.1 --- a/openide.filesystems/test/unit/src/org/openide/filesystems/annotations/LayerBuilderTest.java Wed Jul 27 10:33:10 2011 +0200
202.2 +++ b/openide.filesystems/test/unit/src/org/openide/filesystems/annotations/LayerBuilderTest.java Wed Jul 27 10:35:25 2011 +0200
202.3 @@ -44,8 +44,11 @@
202.4
202.5 import java.io.ByteArrayOutputStream;
202.6 import java.io.File;
202.7 +import java.io.FileNotFoundException;
202.8 import java.io.IOException;
202.9 import java.lang.annotation.Annotation;
202.10 +import java.net.URL;
202.11 +import java.net.URLClassLoader;
202.12 import java.util.Collections;
202.13 import java.util.List;
202.14 import java.util.Set;
202.15 @@ -61,7 +64,11 @@
202.16 import javax.lang.model.element.Name;
202.17 import javax.lang.model.element.TypeElement;
202.18 import javax.lang.model.type.TypeMirror;
202.19 +import javax.tools.Diagnostic;
202.20 +import javax.tools.ToolProvider;
202.21 import org.netbeans.junit.NbTestCase;
202.22 +import org.openide.filesystems.FileObject;
202.23 +import org.openide.filesystems.XMLFileSystem;
202.24 import org.openide.util.lookup.ServiceProvider;
202.25 import org.openide.util.test.AnnotationProcessorTestUtils;
202.26 import org.openide.util.test.TestFileUtils;
202.27 @@ -295,4 +302,85 @@
202.28 }
202.29 }
202.30
202.31 + public void testAbsolutizeAndValidateResourcesExistent() throws Exception {
202.32 + File src = new File(getWorkDir(), "src");
202.33 + File dest = new File(getWorkDir(), "dest");
202.34 + AnnotationProcessorTestUtils.makeSource(src, "p.C", "@" + V.class.getCanonicalName() + "(r1=\"other/x1\", r2=\"resources/x2\") public class C {}");
202.35 + File j = TestFileUtils.writeZipFile(new File(getWorkDir(), "cp.jar"), "other/x1:x1");
202.36 + TestFileUtils.writeFile(new File(src, "p/resources/x2"), "x2");
202.37 + ByteArrayOutputStream err = new ByteArrayOutputStream();
202.38 + boolean status = AnnotationProcessorTestUtils.runJavac(src, null, dest, new File[] {j, new File(LayerBuilderTest.class.getProtectionDomain().getCodeSource().getLocation().toURI())}, err);
202.39 + String msgs = err.toString();
202.40 + assertTrue(msgs, status);
202.41 + // JDK 7: assertTrue(msgs, msgs.contains("r1=x1"));
202.42 + assertTrue(msgs, msgs.contains("r2=x2"));
202.43 + FileObject f = new XMLFileSystem(new File(dest, "META-INF/generated-layer.xml").toURI().toURL()).findResource("f");
202.44 + assertNotNull(f);
202.45 + assertEquals("other/x1", f.getAttribute("r1"));
202.46 + assertEquals("p/resources/x2", f.getAttribute("r2"));
202.47 + }
202.48 +
202.49 + public void testValidateResourceNonexistent() throws Exception {
202.50 + File src = new File(getWorkDir(), "src");
202.51 + File dest = new File(getWorkDir(), "dest");
202.52 + AnnotationProcessorTestUtils.makeSource(src, "p.C", "@" + V.class.getCanonicalName() + "(r1=\"other/x1\", r2=\"resourcez/x2\") public class C {}");
202.53 + File j = TestFileUtils.writeZipFile(new File(getWorkDir(), "cp.jar"), "other/x1:x1");
202.54 + TestFileUtils.writeFile(new File(src, "p/resources/x2"), "x2");
202.55 + ByteArrayOutputStream err = new ByteArrayOutputStream();
202.56 + boolean status = AnnotationProcessorTestUtils.runJavac(src, null, dest, new File[] {j, new File(LayerBuilderTest.class.getProtectionDomain().getCodeSource().getLocation().toURI())}, err);
202.57 + String msgs = err.toString();
202.58 + assertFalse(msgs, status);
202.59 + assertTrue(msgs, msgs.contains("resourcez"));
202.60 + if (new URLClassLoader(new URL[] {ToolProvider.getSystemJavaCompiler().getClass().getProtectionDomain().getCodeSource().getLocation()}).findResource("com/sun/tools/javac/util/Filter.class") == null) {
202.61 + System.err.println("#196933: second half of testValidateResourceNonexistent will only pass when using JDK 7 javac, skipping");
202.62 + return;
202.63 + }
202.64 + assertTrue(msgs, msgs.contains("r1=x1"));
202.65 + AnnotationProcessorTestUtils.makeSource(src, "p.C", "@" + V.class.getCanonicalName() + "(r1=\"othr/x1\", r2=\"resources/x2\") public class C {}");
202.66 + err = new ByteArrayOutputStream();
202.67 + status = AnnotationProcessorTestUtils.runJavac(src, null, dest, new File[] {j, new File(LayerBuilderTest.class.getProtectionDomain().getCodeSource().getLocation().toURI())}, err);
202.68 + msgs = err.toString();
202.69 + assertFalse(msgs, status);
202.70 + assertTrue(msgs, msgs.contains("othr"));
202.71 + }
202.72 +
202.73 + // XXX verify that CLASS_OUTPUT may be used as well
202.74 +
202.75 + public @interface V {
202.76 + /** absolute, may be in classpath */ String r1();
202.77 + /** relative, must be in sourcepath */ String r2();
202.78 + }
202.79 + @ServiceProvider(service=Processor.class)
202.80 + @SupportedSourceVersion(SourceVersion.RELEASE_6)
202.81 + public static class VP extends LayerGeneratingProcessor {
202.82 + public @Override Set<String> getSupportedAnnotationTypes() {
202.83 + return Collections.singleton(V.class.getCanonicalName());
202.84 + }
202.85 + protected @Override boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
202.86 + if (roundEnv.processingOver()) {
202.87 + return false;
202.88 + }
202.89 + for (Element e : roundEnv.getElementsAnnotatedWith(V.class)) {
202.90 + V v = e.getAnnotation(V.class);
202.91 + LayerBuilder b = layer(e);
202.92 + LayerBuilder.File f = b.file("f");
202.93 + String r2 = LayerBuilder.absolutizeResource(e, v.r2());
202.94 + try {
202.95 + try {
202.96 + processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "r1=" + b.validateResource(v.r1(), e, v, "r1", true).getCharContent(true));
202.97 + } catch (FileNotFoundException x) {
202.98 + // OK, JDK 6, ignore
202.99 + }
202.100 + processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "r2=" + b.validateResource(r2, e, v, "r2", false).getCharContent(true));
202.101 + } catch (IOException x) {
202.102 + throw new LayerGenerationException(x.toString(), e, processingEnv, v);
202.103 + }
202.104 + f.stringvalue("r1", v.r1());
202.105 + f.stringvalue("r2", r2);
202.106 + f.write();
202.107 + }
202.108 + return true;
202.109 + }
202.110 + }
202.111 +
202.112 }
203.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
203.2 +++ b/openide.filesystems/test/unit/src/org/openide/filesystems/annotations/LayerGenerationExceptionTest.java Wed Jul 27 10:35:25 2011 +0200
203.3 @@ -0,0 +1,126 @@
203.4 +/*
203.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
203.6 + * <p/>
203.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
203.8 + * <p/>
203.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
203.10 + * Other names may be trademarks of their respective owners.
203.11 + * <p/>
203.12 + * The contents of this file are subject to the terms of either the GNU
203.13 + * General Public License Version 2 only ("GPL") or the Common Development and
203.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
203.15 + * this file except in compliance with the License. You can obtain a copy of
203.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
203.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
203.18 + * governing permissions and limitations under the License. When distributing
203.19 + * the software, include this License Header Notice in each file and include
203.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
203.21 + * particular file as subject to the "Classpath" exception as provided by
203.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
203.23 + * this code. If applicable, add the following below the License Header, with
203.24 + * the fields enclosed by brackets [] replaced by your own identifying
203.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
203.26 + * <p/>
203.27 + * If you wish your version of this file to be governed by only the CDDL or
203.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
203.29 + * elects to include this software in this distribution under the [CDDL or GPL
203.30 + * Version 2] license." If you do not indicate a single choice of license, a
203.31 + * recipient has the option to distribute your version of this file under
203.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
203.33 + * licensees as provided above. However, if you add GPL Version 2 code and
203.34 + * therefore, elected the GPL Version 2 license, then the option applies only
203.35 + * if the new code is made subject to such option by the copyright holder.
203.36 + * <p/>
203.37 + * Contributor(s):
203.38 + * <p/>
203.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
203.40 + */
203.41 +
203.42 +package org.openide.filesystems.annotations;
203.43 +
203.44 +import java.io.ByteArrayOutputStream;
203.45 +import java.io.File;
203.46 +import java.util.Arrays;
203.47 +import java.util.HashSet;
203.48 +import java.util.Set;
203.49 +import javax.annotation.processing.Processor;
203.50 +import javax.annotation.processing.RoundEnvironment;
203.51 +import javax.annotation.processing.SupportedSourceVersion;
203.52 +import javax.lang.model.SourceVersion;
203.53 +import javax.lang.model.element.Element;
203.54 +import javax.lang.model.element.TypeElement;
203.55 +import javax.tools.Diagnostic.Kind;
203.56 +import org.netbeans.junit.NbTestCase;
203.57 +import org.openide.util.lookup.ServiceProvider;
203.58 +import org.openide.util.test.AnnotationProcessorTestUtils;
203.59 +
203.60 +public class LayerGenerationExceptionTest extends NbTestCase {
203.61 +
203.62 + public LayerGenerationExceptionTest(String name) {
203.63 + super(name);
203.64 + }
203.65 +
203.66 + public void testFindAnnotationMirror() throws Exception {
203.67 + File src = new File(getWorkDir(), "src");
203.68 + AnnotationProcessorTestUtils.makeSource(src, "p.C", "@" + A.class.getCanonicalName() + "(attr1=\"one\", attr2=\"two\") public class C {}");
203.69 + File dest = new File(getWorkDir(), "dest");
203.70 + ByteArrayOutputStream err = new ByteArrayOutputStream();
203.71 + assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, err));
203.72 + assertTrue(err.toString(), err.toString().contains("p.C two"));
203.73 + }
203.74 +
203.75 + /* XXX not yet implemented:
203.76 + public void testFindAnnotationMirrorNested() throws Exception {
203.77 + File src = new File(getWorkDir(), "src");
203.78 + AnnotationProcessorTestUtils.makeSource(src, "p.C",
203.79 + "@" + AS.class.getCanonicalName() + "({",
203.80 + "@" + A.class.getCanonicalName() + "(attr1=\"one\", attr2=\"two\"),",
203.81 + "@" + A.class.getCanonicalName() + "(attr1=\"three\", attr2=\"four\")",
203.82 + "})",
203.83 + "public class C {}");
203.84 + File dest = new File(getWorkDir(), "dest");
203.85 + ByteArrayOutputStream err = new ByteArrayOutputStream();
203.86 + boolean r = AnnotationProcessorTestUtils.runJavac(src, null, dest, null, err);
203.87 + String out = err.toString();
203.88 + assertTrue(out, r);
203.89 + assertTrue(out,out.contains("p.C two"));
203.90 + assertTrue(out,out.contains("p.C four"));
203.91 + }
203.92 + */
203.93 +
203.94 + public @interface A {
203.95 + String attr1();
203.96 + String attr2();
203.97 + }
203.98 +
203.99 + public @interface AS {
203.100 + A[] value();
203.101 + }
203.102 +
203.103 + @ServiceProvider(service=Processor.class)
203.104 + @SupportedSourceVersion(SourceVersion.RELEASE_6)
203.105 + public static class AP extends LayerGeneratingProcessor {
203.106 + public @Override Set<String> getSupportedAnnotationTypes() {
203.107 + return new HashSet<String>(Arrays.asList(A.class.getCanonicalName(), AS.class.getCanonicalName()));
203.108 + }
203.109 + protected @Override boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
203.110 + if (roundEnv.processingOver()) {
203.111 + return false;
203.112 + }
203.113 + for (Element e : roundEnv.getElementsAnnotatedWith(A.class)) {
203.114 + handle(e, e.getAnnotation(A.class));
203.115 + }
203.116 + for (Element e : roundEnv.getElementsAnnotatedWith(AS.class)) {
203.117 + for (A a : e.getAnnotation(AS.class).value()) {
203.118 + handle(e, a);
203.119 + }
203.120 + }
203.121 + return true;
203.122 + }
203.123 + private void handle(Element e, A a) {
203.124 + LayerGenerationException lge = new LayerGenerationException("msg", e, processingEnv, a, "attr2");
203.125 + processingEnv.getMessager().printMessage(Kind.NOTE, lge.erroneousElement + " " + (lge.erroneousAnnotationValue != null ? lge.erroneousAnnotationValue.getValue() : null));
203.126 + }
203.127 + }
203.128 +
203.129 +}
204.1 --- a/openide.loaders/apichanges.xml Wed Jul 27 10:33:10 2011 +0200
204.2 +++ b/openide.loaders/apichanges.xml Wed Jul 27 10:35:25 2011 +0200
204.3 @@ -109,6 +109,22 @@
204.4 <!-- ACTUAL CHANGES BEGIN HERE: -->
204.5
204.6 <changes>
204.7 + <change id="Template">
204.8 + <api name="loaders"/>
204.9 + <summary>Introduced <code>Template</code></summary>
204.10 + <version major="7" minor="29"/>
204.11 + <date day="25" month="7" year="2011"/>
204.12 + <author login="jglick"/>
204.13 + <compatibility addition="yes"/>
204.14 + <description>
204.15 + <p>
204.16 + Introduced a new annotation for registering (file or project) templates.
204.17 + </p>
204.18 + </description>
204.19 + <class package="org.netbeans.api.templates" name="TemplateRegistration"/>
204.20 + <class package="org.netbeans.api.templates" name="TemplateRegistrations"/>
204.21 + <issue number="200175"/>
204.22 + </change>
204.23 <change id="DataEditorSupport.constr3">
204.24 <api name="editor"/>
204.25 <summary>DataEditorSupport constructor with Lookup parameter</summary>
205.1 --- a/openide.loaders/arch.xml Wed Jul 27 10:33:10 2011 +0200
205.2 +++ b/openide.loaders/arch.xml Wed Jul 27 10:35:25 2011 +0200
205.3 @@ -942,7 +942,7 @@
205.4 </question>
205.5 -->
205.6 <answer id="resources-read">
205.7 -Module reads a list of templates from folders Privileged and Recent from core/ui layer.
205.8 +NewTemplateAction reads a list of templates from folders Privileged and Recent.
205.9 This list is exposed in a popup menu.
205.10 </answer>
205.11
206.1 --- a/openide.loaders/manifest.mf Wed Jul 27 10:33:10 2011 +0200
206.2 +++ b/openide.loaders/manifest.mf Wed Jul 27 10:35:25 2011 +0200
206.3 @@ -1,6 +1,6 @@
206.4 Manifest-Version: 1.0
206.5 OpenIDE-Module: org.openide.loaders
206.6 -OpenIDE-Module-Specification-Version: 7.28
206.7 +OpenIDE-Module-Specification-Version: 7.29
206.8 OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
206.9 OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
206.10 OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
207.1 --- a/openide.loaders/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
207.2 +++ b/openide.loaders/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
207.3 @@ -122,7 +122,7 @@
207.4 <build-prerequisite/>
207.5 <compile-dependency/>
207.6 <run-dependency>
207.7 - <specification-version>7.19</specification-version>
207.8 + <specification-version>7.51</specification-version>
207.9 </run-dependency>
207.10 </dependency>
207.11 <dependency>
207.12 @@ -249,8 +249,9 @@
207.13 </test-type>
207.14 </test-dependencies>
207.15 <public-packages>
207.16 + <package>org.netbeans.api.templates</package>
207.17 + <package>org.openide.actions</package>
207.18 <package>org.openide.awt</package>
207.19 - <package>org.openide.actions</package>
207.20 <package>org.openide.loaders</package>
207.21 <package>org.openide.text</package>
207.22 </public-packages>
208.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
208.2 +++ b/openide.loaders/src/org/netbeans/api/templates/TemplateRegistration.java Wed Jul 27 10:35:25 2011 +0200
208.3 @@ -0,0 +1,128 @@
208.4 +/*
208.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
208.6 + *
208.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
208.8 + *
208.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
208.10 + * Other names may be trademarks of their respective owners.
208.11 + *
208.12 + * The contents of this file are subject to the terms of either the GNU
208.13 + * General Public License Version 2 only ("GPL") or the Common Development and
208.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
208.15 + * this file except in compliance with the License. You can obtain a copy of
208.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
208.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
208.18 + * governing permissions and limitations under the License. When distributing
208.19 + * the software, include this License Header Notice in each file and include
208.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
208.21 + * particular file as subject to the "Classpath" exception as provided by
208.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
208.23 + * this code. If applicable, add the following below the License Header, with
208.24 + * the fields enclosed by brackets [] replaced by your own identifying
208.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
208.26 + *
208.27 + * If you wish your version of this file to be governed by only the CDDL or
208.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
208.29 + * elects to include this software in this distribution under the [CDDL or GPL
208.30 + * Version 2] license." If you do not indicate a single choice of license, a
208.31 + * recipient has the option to distribute your version of this file under
208.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
208.33 + * licensees as provided above. However, if you add GPL Version 2 code and
208.34 + * therefore, elected the GPL Version 2 license, then the option applies only
208.35 + * if the new code is made subject to such option by the copyright holder.
208.36 + *
208.37 + * Contributor(s):
208.38 + *
208.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
208.40 + */
208.41 +
208.42 +package org.netbeans.api.templates;
208.43 +
208.44 +import java.lang.annotation.ElementType;
208.45 +import java.lang.annotation.Retention;
208.46 +import java.lang.annotation.RetentionPolicy;
208.47 +import java.lang.annotation.Target;
208.48 +import javax.script.ScriptEngineFactory;
208.49 +import org.openide.WizardDescriptor.InstantiatingIterator;
208.50 +import org.openide.loaders.TemplateWizard;
208.51 +
208.52 +/**
208.53 + * Registers a template the user can select.
208.54 + * May be placed on a class (with a default constructor) or static method (with no arguments)
208.55 + * to register an {@link InstantiatingIterator} for a custom template;
208.56 + * or on a package to register a plain-file template with no custom behavior.
208.57 + * @since 7.29
208.58 + * @see TemplateWizard
208.59 + * @see TemplateRegistrations
208.60 + */
208.61 +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PACKAGE})
208.62 +@Retention(RetentionPolicy.SOURCE)
208.63 +public @interface TemplateRegistration {
208.64 +
208.65 + /**
208.66 + * Subfolder in which to place the template, such as {@code Other} or {@code Project/Standard}.
208.67 + */
208.68 + String folder();
208.69 +
208.70 + /**
208.71 + * Optional position within {@link #folder}.
208.72 + */
208.73 + int position() default Integer.MAX_VALUE;
208.74 +
208.75 + /**
208.76 + * Special file basename to use rather than inferring one from the declaring element,
208.77 + * when {@link #content} is empty.
208.78 + * Useful for pure templates referenced from {@code PrivilegedTemplates}.
208.79 + */
208.80 + String id() default "";
208.81 +
208.82 + /**
208.83 + * File contents, as resources relative to the package of this declaration.
208.84 + * A nonempty list is mandatory for a template registered on a package.
208.85 + * For a template with a custom iterator, the content may be omitted, though it may still be specified.
208.86 + * <p>Normally only a single file is specified, but for a multifile data object, list the primary entry first.
208.87 + * <p>The file basenames (incl. extension) of the actual template files (as in {@link TemplateWizard#getTemplate})
208.88 + * will be taken from the basename of the content resources, though a {@code .template} suffix
208.89 + * may be appended to prevent template resources in a source project from being misinterpreted.
208.90 + * For a "pure" custom iterator with no specified content, the template basename
208.91 + * defaults to the FQN of the class or method defining it but with {@code -} for {@code .} characters,
208.92 + * e.g. {@code pkg-Class-method}, but may be overridden with {@link #id}.
208.93 + * <p>Example usage for a simple, single-file template (with or without custom iterator):
208.94 + * <pre>content="resources/empty.php"</pre>
208.95 + * <p>For a form template:
208.96 + * <pre>content={"Login.java.template", "Login.form.template"}</pre>
208.97 + */
208.98 + String[] content() default {};
208.99 +
208.100 + /**
208.101 + * Localized label for the template.
208.102 + * Mandatory unless {@link #content} is specified, in which case it would be defaulted by the data node.
208.103 + * May use the usual {@code #key} syntax.
208.104 + */
208.105 + String displayName() default "";
208.106 +
208.107 + /**
208.108 + * Icon to use for the template.
208.109 + * Should be an absolute resource path (no initial slash).
208.110 + * Mandatory unless {@link #content} is specified, in which case it would be defaulted by the data node.
208.111 + */
208.112 + String iconBase() default "";
208.113 +
208.114 + /**
208.115 + * Optional but recommended relative resource path to an HTML description of the template.
208.116 + * @see TemplateWizard#getDescription
208.117 + */
208.118 + String description() default "";
208.119 +
208.120 + /**
208.121 + * Optional name of a script engine to use when processing file content, such as {@code freemarker}.
208.122 + * @see ScriptEngineFactory#getNames
208.123 + */
208.124 + String scriptEngine() default "";
208.125 +
208.126 + /**
208.127 + * Optional list of categories interpreted by the project system.
208.128 + */
208.129 + String[] category() default {};
208.130 +
208.131 +}
209.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
209.2 +++ b/openide.loaders/src/org/netbeans/api/templates/TemplateRegistrations.java Wed Jul 27 10:35:25 2011 +0200
209.3 @@ -0,0 +1,56 @@
209.4 +/*
209.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
209.6 + *
209.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
209.8 + *
209.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
209.10 + * Other names may be trademarks of their respective owners.
209.11 + *
209.12 + * The contents of this file are subject to the terms of either the GNU
209.13 + * General Public License Version 2 only ("GPL") or the Common Development and
209.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
209.15 + * this file except in compliance with the License. You can obtain a copy of
209.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
209.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
209.18 + * governing permissions and limitations under the License. When distributing
209.19 + * the software, include this License Header Notice in each file and include
209.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
209.21 + * particular file as subject to the "Classpath" exception as provided by
209.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
209.23 + * this code. If applicable, add the following below the License Header, with
209.24 + * the fields enclosed by brackets [] replaced by your own identifying
209.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
209.26 + *
209.27 + * If you wish your version of this file to be governed by only the CDDL or
209.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
209.29 + * elects to include this software in this distribution under the [CDDL or GPL
209.30 + * Version 2] license." If you do not indicate a single choice of license, a
209.31 + * recipient has the option to distribute your version of this file under
209.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
209.33 + * licensees as provided above. However, if you add GPL Version 2 code and
209.34 + * therefore, elected the GPL Version 2 license, then the option applies only
209.35 + * if the new code is made subject to such option by the copyright holder.
209.36 + *
209.37 + * Contributor(s):
209.38 + *
209.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
209.40 + */
209.41 +
209.42 +package org.netbeans.api.templates;
209.43 +
209.44 +import java.lang.annotation.ElementType;
209.45 +import java.lang.annotation.Retention;
209.46 +import java.lang.annotation.RetentionPolicy;
209.47 +import java.lang.annotation.Target;
209.48 +
209.49 +/**
209.50 + * May be used to register multiple plain-file {@link TemplateRegistration}s.
209.51 + * Use on a package for simple templates, or on an iterator for multiple variants of a template
209.52 + * with different {@link TemplateRegistration#content}.
209.53 + * @since 7.29
209.54 + */
209.55 +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PACKAGE})
209.56 +@Retention(RetentionPolicy.SOURCE)
209.57 +public @interface TemplateRegistrations {
209.58 + TemplateRegistration[] value();
209.59 +}
210.1 --- a/openide.loaders/src/org/netbeans/modules/openide/loaders/layer.xml Wed Jul 27 10:33:10 2011 +0200
210.2 +++ b/openide.loaders/src/org/netbeans/modules/openide/loaders/layer.xml Wed Jul 27 10:35:25 2011 +0200
210.3 @@ -23,4 +23,14 @@
210.4 </folder>
210.5 </folder>
210.6 </folder>
210.7 + <folder name="Templates"><!-- see NewTemplateAction -->
210.8 + <folder name="Privileged">
210.9 + <attr name="simple" boolvalue="false"/>
210.10 + <attr name="position" intvalue="0"/>
210.11 + </folder>
210.12 + <folder name="Recent">
210.13 + <attr name="simple" boolvalue="false"/>
210.14 + <attr name="position" intvalue="0"/>
210.15 + </folder>
210.16 + </folder>
210.17 </filesystem>
211.1 --- a/openide.loaders/src/org/netbeans/modules/templates/ScriptingCreateFromTemplateHandler.java Wed Jul 27 10:33:10 2011 +0200
211.2 +++ b/openide.loaders/src/org/netbeans/modules/templates/ScriptingCreateFromTemplateHandler.java Wed Jul 27 10:35:25 2011 +0200
211.3 @@ -64,6 +64,9 @@
211.4 */
211.5 @ServiceProvider(service=CreateFromTemplateHandler.class)
211.6 public class ScriptingCreateFromTemplateHandler extends CreateFromTemplateHandler {
211.7 +
211.8 + public static final String SCRIPT_ENGINE_ATTR = "javax.script.ScriptEngine";
211.9 +
211.10 private static ScriptEngineManager manager;
211.11
211.12 private static final String ENCODING_PROPERTY_NAME = "encoding"; //NOI18N
211.13 @@ -121,7 +124,7 @@
211.14 }
211.15
211.16 private static ScriptEngine engine(FileObject fo) {
211.17 - Object obj = fo.getAttribute("javax.script.ScriptEngine"); // NOI18N
211.18 + Object obj = fo.getAttribute(SCRIPT_ENGINE_ATTR); // NOI18N
211.19 if (obj instanceof ScriptEngine) {
211.20 return (ScriptEngine)obj;
211.21 }
212.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
212.2 +++ b/openide.loaders/src/org/netbeans/modules/templates/TemplateProcessor.java Wed Jul 27 10:35:25 2011 +0200
212.3 @@ -0,0 +1,158 @@
212.4 +/*
212.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
212.6 + *
212.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
212.8 + *
212.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
212.10 + * Other names may be trademarks of their respective owners.
212.11 + *
212.12 + * The contents of this file are subject to the terms of either the GNU
212.13 + * General Public License Version 2 only ("GPL") or the Common Development and
212.14 + * Distribution License("CDDL") (collectively, the "License"). You may not use
212.15 + * this file except in compliance with the License. You can obtain a copy of
212.16 + * the License at http://www.netbeans.org/cddl-gplv2.html or
212.17 + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
212.18 + * governing permissions and limitations under the License. When distributing
212.19 + * the software, include this License Header Notice in each file and include
212.20 + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
212.21 + * particular file as subject to the "Classpath" exception as provided by
212.22 + * Oracle in the GPL Version 2 section of the License file that accompanied
212.23 + * this code. If applicable, add the following below the License Header, with
212.24 + * the fields enclosed by brackets [] replaced by your own identifying
212.25 + * information: "Portions Copyrighted [year] [name of copyright owner]"
212.26 + *
212.27 + * If you wish your version of this file to be governed by only the CDDL or
212.28 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
212.29 + * elects to include this software in this distribution under the [CDDL or GPL
212.30 + * Version 2] license." If you do not indicate a single choice of license, a
212.31 + * recipient has the option to distribute your version of this file under
212.32 + * either the CDDL, the GPL Version 2 or to extend the choice of license to its
212.33 + * licensees as provided above. However, if you add GPL Version 2 code and
212.34 + * therefore, elected the GPL Version 2 license, then the option applies only
212.35 + * if the new code is made subject to such option by the copyright holder.
212.36 + *
212.37 + * Contributor(s):
212.38 + *
212.39 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
212.40 + */
212.41 +
212.42 +package org.netbeans.modules.templates;
212.43 +
212.44 +import java.net.URI;
212.45 +import java.net.URISyntaxException;
212.46 +import java.util.Arrays;
212.47 +import java.util.HashSet;
212.48 +import java.util.Set;
212.49 +import javax.annotation.processing.Processor;
212.50 +import javax.annotation.processing.RoundEnvironment;
212.51 +import javax.annotation.processing.SupportedSourceVersion;
212.52 +import javax.lang.model.SourceVersion;
212.53 +import javax.lang.model.element.Element;
212.54 +import javax.lang.model.element.ElementKind;
212.55 +import javax.lang.model.element.TypeElement;
212.56 +import org.openide.filesystems.annotations.LayerGenerationException;
212.57 +import org.netbeans.api.templates.TemplateRegistration;
212.58 +import org.netbeans.api.templates.TemplateRegistrations;
212.59 +import org.openide.WizardDescriptor.InstantiatingIterator;
212.60 +import org.openide.filesystems.annotations.LayerBuilder;
212.61 +import org.openide.filesystems.annotations.LayerGeneratingProcessor;
212.62 +import org.openide.util.lookup.ServiceProvider;
212.63 +
212.64 +@ServiceProvider(service=Processor.class)
212.65 +@SupportedSourceVersion(SourceVersion.RELEASE_6)
212.66 +public class TemplateProcessor extends LayerGeneratingProcessor {
212.67 +
212.68 + @Override public Set<String> getSupportedAnnotationTypes() {
212.69 + return new HashSet<String>(Arrays.asList(TemplateRegistration.class.getCanonicalName(), TemplateRegistrations.class.getCanonicalName()));
212.70 + }
212.71 +
212.72 + @Override protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
212.73 + if (roundEnv.processingOver()) {
212.74 + return false;
212.75 + }
212.76 + for (Element e : roundEnv.getElementsAnnotatedWith(TemplateRegistration.class)) {
212.77 + process(e, e.getAnnotation(TemplateRegistration.class));
212.78 + }
212.79 + for (Element e : roundEnv.getElementsAnnotatedWith(TemplateRegistrations.class)) {
212.80 + for (TemplateRegistration t : e.getAnnotation(TemplateRegistrations.class).value()) {
212.81 + process(e, t);
212.82 + }
212.83 + }
212.84 + return true;
212.85 + }
212.86 +
212.87 + private void process(Element e, TemplateRegistration t) throws LayerGenerationException {
212.88 + LayerBuilder builder = layer(e);
212.89 + String basename;
212.90 + if (!t.id().isEmpty()) {
212.91 + if (t.content().length > 0) {
212.92 + throw new LayerGenerationException("Cannot specify both id and content", e, processingEnv, t);
212.93 + }
212.94 + basename = t.id();
212.95 + } else if (t.content().length > 0) {
212.96 + basename = basename(t.content()[0]);
212.97 + } else {
212.98 + if (e.getKind() == ElementKind.CLASS) {
212.99 + basename = ((TypeElement) e).getQualifiedName().toString().replace('.', '-');
212.100 + } else if (e.getKind() == ElementKind.METHOD) {
212.101 + basename = ((TypeElement) e.getEnclosingElement()).getQualifiedName().toString().replace('.', '-') + '-' + e.getSimpleName();
212.102 + } else {
212.103 + throw new LayerGenerationException("cannot use @Template on a package without specifying content", e, processingEnv, t);
212.104 + }
212.105 + }
212.106 + String folder = "Templates/" + t.folder() + '/';
212.107 + LayerBuilder.File f = builder.file(folder + basename);
212.108 + f.boolvalue("template", true);
212.109 + f.position(t.position());
212.110 + if (!t.displayName().isEmpty()) {
212.111 + f.bundlevalue("displayName", t.displayName());
212.112 + }
212.113 + if (!t.iconBase().isEmpty()) {
212.114 + builder.validateResource(t.iconBase(), e, t, "iconBase", true);
212.115 + f.stringvalue("iconBase", t.iconBase());
212.116 + } else if (t.content().length == 0) {
212.117 + throw new LayerGenerationException("Must specify iconBase if content is not specified", e, processingEnv, t);
212.118 + }
212.119 + if (!t.description().isEmpty()) {
212.120 + f.urlvalue("instantiatingWizardURL", contentURI(e, t.description(), builder, t, "description"));
212.121 + }
212.122 + if (e.getKind() != ElementKind.PACKAGE) {
212.123 + f.instanceAttribute("instantiatingIterator", InstantiatingIterator.class);
212.124 + }
212.125 + if (t.content().length > 0) {
212.126 + f.url(contentURI(e, t.content()[0], builder, t, "content").toString());
212.127 + for (int i = 1; i < t.content().length; i++) {
212.128 + builder.file(folder + basename(t.content()[i])).url(contentURI(e, t.content()[i], builder, t, "content").toString()).position(0).write();
212.129 + }
212.130 + }
212.131 + if (!t.scriptEngine().isEmpty()) {
212.132 + f.stringvalue(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, t.scriptEngine());
212.133 + }
212.134 + if (t.category().length > 0) {
212.135 + StringBuilder sb = new StringBuilder();
212.136 + for (String c : t.category()) {
212.137 + if (sb.length() > 0) {
212.138 + sb.append(',');
212.139 + }
212.140 + sb.append(c);
212.141 + }
212.142 + f.stringvalue("templateCategory", sb.toString());
212.143 + }
212.144 + f.write();
212.145 + }
212.146 +
212.147 + private static String basename(String relativeResource) {
212.148 + return relativeResource.replaceFirst(".+/", "").replaceFirst("[.]template$", "");
212.149 + }
212.150 +
212.151 + private URI contentURI(Element e, String relativePath, LayerBuilder builder, TemplateRegistration t, String annotationMethod) throws LayerGenerationException {
212.152 + String path = LayerBuilder.absolutizeResource(e, relativePath);
212.153 + builder.validateResource(path, e, t, annotationMethod, false);
212.154 + try {
212.155 + return new URI("nbresloc", "/" + path, null).normalize();
212.156 + } catch (URISyntaxException x) {
212.157 + throw new LayerGenerationException("could not translate " + path, e, processingEnv, t);
212.158 + }
212.159 + }
212.160 +
212.161 +}
213.1 --- a/openide.loaders/src/org/openide/actions/SaveAsTemplateAction.java Wed Jul 27 10:33:10 2011 +0200
213.2 +++ b/openide.loaders/src/org/openide/actions/SaveAsTemplateAction.java Wed Jul 27 10:35:25 2011 +0200
213.3 @@ -50,6 +50,7 @@
213.4 import java.util.HashMap;
213.5 import java.util.Map;
213.6 import java.util.Map.Entry;
213.7 +import org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler;
213.8 import org.openide.cookies.SaveCookie;
213.9 import org.openide.filesystems.FileObject;
213.10 import org.openide.loaders.*;
213.11 @@ -155,7 +156,7 @@
213.12 newTemplate.setTemplate(true);
213.13 if (templateSample == null) {
213.14 // a fallback if no template sample found
213.15 - newTemplate.getPrimaryFile ().setAttribute ("javax.script.ScriptEngine", "freemarker"); // NOI18N
213.16 + newTemplate.getPrimaryFile().setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "freemarker"); // NOI18N
213.17 } else {
213.18 setTemplateAttributes (newTemplate.getPrimaryFile (), getAttributes (templateSample.getPrimaryFile ()));
213.19 }
214.1 --- a/openide.loaders/src/org/openide/loaders/TemplateWizard.java Wed Jul 27 10:33:10 2011 +0200
214.2 +++ b/openide.loaders/src/org/openide/loaders/TemplateWizard.java Wed Jul 27 10:35:25 2011 +0200
214.3 @@ -56,6 +56,7 @@
214.4 import java.util.logging.Logger;
214.5 import javax.swing.*;
214.6 import org.netbeans.api.progress.ProgressHandle;
214.7 +import org.netbeans.api.templates.TemplateRegistration;
214.8 import org.openide.*;
214.9 import org.openide.WizardDescriptor.Panel;
214.10 import org.openide.filesystems.*;
214.11 @@ -65,6 +66,7 @@
214.12 /** Wizard for creation of new objects from a template.
214.13 *
214.14 * @author Jaroslav Tulach, Jiri Rechtacek
214.15 +* @see TemplateRegistration
214.16 */
214.17 public class TemplateWizard extends WizardDescriptor {
214.18 /** EA that defines the wizards description */
214.19 @@ -832,6 +834,7 @@
214.20 * use of <CODE>putProperty</CODE> method and read it using <code>getProperty</code>.
214.21 * <P>
214.22 * Implements <code>Node.Cookie</code> since version 2.13
214.23 + * @see TemplateRegistration
214.24 */
214.25 public interface Iterator extends WizardDescriptor.Iterator<WizardDescriptor>,
214.26 java.io.Serializable, org.openide.nodes.Node.Cookie {
215.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/templates/Bug138973Test.java Wed Jul 27 10:33:10 2011 +0200
215.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/templates/Bug138973Test.java Wed Jul 27 10:35:25 2011 +0200
215.3 @@ -102,7 +102,7 @@
215.4 FileObject templateFile = FileUtil.createData(templatesFolder,
215.5 TEMPLATE_NAME_EXT);
215.6 templateFile.setAttribute ("template", Boolean.TRUE);
215.7 - templateFile.setAttribute("javax.script.ScriptEngine", "js");
215.8 + templateFile.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
215.9 byte[] templateBytes = TESTING_TEXT.getBytes("ISO-8859-1");
215.10 InputStream source = new ByteArrayInputStream(templateBytes);
215.11 OutputStream target = templateFile.getOutputStream();
216.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/templates/IndentEngineIntTest.java Wed Jul 27 10:33:10 2011 +0200
216.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/templates/IndentEngineIntTest.java Wed Jul 27 10:35:25 2011 +0200
216.3 @@ -93,7 +93,7 @@
216.4 String txt = "print('<html><h1>'); print(title); print('</h1></html>');";
216.5 os.write(txt.getBytes());
216.6 os.close();
216.7 - fo.setAttribute("javax.script.ScriptEngine", "JavaScript");
216.8 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "JavaScript");
216.9
216.10
216.11 DataObject obj = DataObject.find(fo);
217.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java Wed Jul 27 10:33:10 2011 +0200
217.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java Wed Jul 27 10:35:25 2011 +0200
217.3 @@ -113,7 +113,7 @@
217.4 String txt = "print('<html><h1>'); print(title); print('</h1></html>');";
217.5 os.write(txt.getBytes());
217.6 os.close();
217.7 - fo.setAttribute("javax.script.ScriptEngine", "js");
217.8 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.9
217.10
217.11 DataObject obj = DataObject.find(fo);
217.12 @@ -138,7 +138,7 @@
217.13 String txt = "print('<html><h1>'); print(nameAndExt); print('</h1></html>')";
217.14 os.write(txt.getBytes());
217.15 os.close();
217.16 - fo.setAttribute("javax.script.ScriptEngine", "js");
217.17 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.18
217.19
217.20 DataObject obj = DataObject.find(fo);
217.21 @@ -165,14 +165,14 @@
217.22 String txt = "print('<html><h1>'); print(nameAndExt); print('</h1></html>')";
217.23 os.write(txt.getBytes());
217.24 os.close();
217.25 - fo.setAttribute("javax.script.ScriptEngine", "js");
217.26 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.27
217.28 FileObject fo2 = FileUtil.createData(root, "j.form");
217.29 OutputStream os2 = fo2.getOutputStream();
217.30 String txt2 = "print('<html><h2>'); print(nameAndExt); print('</h2></html>')";
217.31 os2.write(txt2.getBytes());
217.32 os2.close();
217.33 - fo2.setAttribute("javax.script.ScriptEngine", "js");
217.34 + fo2.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.35
217.36 DataObject obj = DataObject.find(fo);
217.37 assertEquals("Both files", 2, obj.files().size());
217.38 @@ -215,7 +215,7 @@
217.39 "print('</html>');";
217.40 os.write(txt.getBytes());
217.41 os.close();
217.42 - fo.setAttribute("javax.script.ScriptEngine", "js");
217.43 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.44
217.45
217.46 DataObject obj = DataObject.find(fo);
217.47 @@ -262,7 +262,7 @@
217.48 FileObject xml = FileUtil.createData(xmldir, "class.txt");
217.49 OutputStream os = xml.getOutputStream();
217.50 FileUtil.copy(getClass().getResourceAsStream("utf8.xml"), os);
217.51 - xml.setAttribute("javax.script.ScriptEngine", "js");
217.52 + xml.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.53 os.close();
217.54
217.55 DataObject obj = DataObject.find(xml);
217.56 @@ -298,8 +298,8 @@
217.57 FileObject root = fs.getRoot();
217.58 FileObject fo = FileUtil.createData(root, "simpleObject.java");
217.59 FileObject fo2 = FileUtil.createData(root, "simpleObject.form");
217.60 - fo.setAttribute("javax.script.ScriptEngine", "js");
217.61 - fo2.setAttribute("javax.script.ScriptEngine", "js");
217.62 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.63 + fo2.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
217.64
217.65 Charset set = Charset.forName("iso-8859-2");
217.66 OutputStream os = fo2.getOutputStream();
218.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/templates/ScriptingCreateFromTemplateTest.java Wed Jul 27 10:33:10 2011 +0200
218.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/templates/ScriptingCreateFromTemplateTest.java Wed Jul 27 10:35:25 2011 +0200
218.3 @@ -89,7 +89,7 @@
218.4 assertEquals("content/unknown", fo.getMIMEType());
218.5 fo.setAttribute ("template", Boolean.TRUE);
218.6 assertEquals("content/unknown", fo.getMIMEType());
218.7 - fo.setAttribute("javax.script.ScriptEngine", "js");
218.8 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
218.9
218.10 DataObject obj = DataObject.find(fo);
218.11 DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
218.12 @@ -118,7 +118,7 @@
218.13 os.write("println('#!/usr/bin/perl'); print('# ');println(license);print('# ');print(name);print(' in ');println(nameAndExt);".getBytes());
218.14 os.close();
218.15 template.setAttribute("template", true);
218.16 - template.setAttribute("javax.script.ScriptEngine", "js");
218.17 + template.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
218.18 Map<String,Object> parameters = new HashMap<String,Object>();
218.19 parameters.put("license", "GPL");
218.20 parameters.put(CreateFromTemplateHandler.FREE_FILE_EXTENSION, true);
218.21 @@ -163,7 +163,7 @@
218.22 os.write("test".getBytes());
218.23 os.close();
218.24 fo.setAttribute ("template", Boolean.TRUE);
218.25 - fo.setAttribute("javax.script.ScriptEngine", "js");
218.26 + fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
218.27
218.28 MockServices.setServices(MockMimeLookup.class);
218.29 MockMimeLookup.setInstances(MimePath.parse("content/unknown"), new TestEditorKit());
219.1 --- a/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Wed Jul 27 10:33:10 2011 +0200
219.2 +++ b/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Wed Jul 27 10:35:25 2011 +0200
219.3 @@ -83,7 +83,7 @@
219.4
219.5 Description info = findInfo(e);
219.6 if (info == null) {
219.7 - throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e);
219.8 + throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
219.9 }
219.10 String id = info.preferredID().replace('.', '-');
219.11
219.12 @@ -112,11 +112,11 @@
219.13 File actionFile = layer(e).
219.14 file("Actions/" + aid.category() + "/" + aid.id().replace('.', '-') + ".instance").
219.15 methodvalue("instanceCreate", "org.openide.windows.TopComponent", "openAction");
219.16 - actionFile.instanceAttribute("component", TopComponent.class);
219.17 + actionFile.instanceAttribute("component", TopComponent.class, reg, null);
219.18 if (reg.preferredID().length() > 0) {
219.19 actionFile.stringvalue("preferredID", reg.preferredID());
219.20 }
219.21 - actionFile.bundlevalue("displayName", reg.displayName());
219.22 + actionFile.bundlevalue("displayName", reg.displayName(), reg, "displayName");
219.23 if (info != null && info.iconBase().length() > 0) {
219.24 actionFile.stringvalue("iconBase", info.iconBase());
219.25 }
220.1 --- a/options.api/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
220.2 +++ b/options.api/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
220.3 @@ -120,7 +120,7 @@
220.4 <build-prerequisite/>
220.5 <compile-dependency/>
220.6 <run-dependency>
220.7 - <specification-version>7.27</specification-version>
220.8 + <specification-version>7.51</specification-version>
220.9 </run-dependency>
220.10 </dependency>
220.11 <dependency>
221.1 --- a/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java Wed Jul 27 10:33:10 2011 +0200
221.2 +++ b/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java Wed Jul 27 10:35:25 2011 +0200
221.3 @@ -42,8 +42,7 @@
221.4
221.5 package org.netbeans.modules.options;
221.6
221.7 -import java.io.FileNotFoundException;
221.8 -import java.io.IOException;
221.9 +import java.lang.annotation.Annotation;
221.10 import java.util.Arrays;
221.11 import java.util.HashSet;
221.12 import java.util.Set;
221.13 @@ -53,13 +52,13 @@
221.14 import javax.lang.model.SourceVersion;
221.15 import javax.lang.model.element.Element;
221.16 import javax.lang.model.element.TypeElement;
221.17 -import javax.tools.StandardLocation;
221.18 import org.netbeans.spi.options.AdvancedOption;
221.19 import org.netbeans.spi.options.OptionsCategory;
221.20 import org.netbeans.spi.options.OptionsPanelController;
221.21 import org.netbeans.spi.options.OptionsPanelController.ContainerRegistration;
221.22 import org.netbeans.spi.options.OptionsPanelController.SubRegistration;
221.23 import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration;
221.24 +import org.openide.filesystems.annotations.LayerBuilder;
221.25 import org.openide.filesystems.annotations.LayerBuilder.File;
221.26 import org.openide.filesystems.annotations.LayerGeneratingProcessor;
221.27 import org.openide.filesystems.annotations.LayerGenerationException;
221.28 @@ -83,69 +82,59 @@
221.29 }
221.30 for (Element e : roundEnv.getElementsAnnotatedWith(TopLevelRegistration.class)) {
221.31 TopLevelRegistration r = e.getAnnotation(TopLevelRegistration.class);
221.32 - File file = layer(e).instanceFile("OptionsDialog", r.id().length() > 0 ? r.id() : null).
221.33 + LayerBuilder builder = layer(e);
221.34 + File file = builder.instanceFile("OptionsDialog", r.id().length() > 0 ? r.id() : null, r, null).
221.35 methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
221.36 instanceAttribute("controller", OptionsPanelController.class).
221.37 bundlevalue("categoryName", r.categoryName()).
221.38 position(r.position());
221.39 - iconBase(e, r.iconBase(), file);
221.40 - keywords(e, r.keywords(), r.keywordsCategory(), file);
221.41 + iconBase(e, r.iconBase(), r, file, builder);
221.42 + keywords(e, r.keywords(), r.keywordsCategory(), r, file);
221.43 file.write();
221.44 }
221.45 for (Element e : roundEnv.getElementsAnnotatedWith(SubRegistration.class)) {
221.46 SubRegistration r = e.getAnnotation(SubRegistration.class);
221.47 if (r.position() != Integer.MAX_VALUE && r.location().equals("Advanced")) {
221.48 - throw new LayerGenerationException("position ignored for Advanced subpanels", e);
221.49 + throw new LayerGenerationException("position ignored for Advanced subpanels", e, processingEnv, r, "position");
221.50 }
221.51 - File file = layer(e).instanceFile("OptionsDialog/" + r.location(), r.id().length() > 0 ? r.id() : null).
221.52 + File file = layer(e).instanceFile("OptionsDialog/" + r.location(), r.id().length() > 0 ? r.id() : null, r, null).
221.53 methodvalue("instanceCreate", AdvancedOption.class.getName(), "createSubCategory").
221.54 instanceAttribute("controller", OptionsPanelController.class).
221.55 bundlevalue("displayName", r.displayName()).
221.56 position(r.position());
221.57 - keywords(e, r.keywords(), r.keywordsCategory(), file);
221.58 + keywords(e, r.keywords(), r.keywordsCategory(), r, file);
221.59 file.write();
221.60 }
221.61 for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) {
221.62 ContainerRegistration r = e.getAnnotation(ContainerRegistration.class);
221.63 - File file = layer(e).file("OptionsDialog/" + r.id() + ".instance").
221.64 + LayerBuilder builder = layer(e);
221.65 + File file = builder.file("OptionsDialog/" + r.id() + ".instance").
221.66 methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
221.67 stringvalue("advancedOptionsFolder", "OptionsDialog/" + r.id()).
221.68 bundlevalue("categoryName", r.categoryName()).
221.69 position(r.position());
221.70 - iconBase(e, r.iconBase(), file);
221.71 - keywords(e, r.keywords(), r.keywordsCategory(), file);
221.72 + iconBase(e, r.iconBase(), r, file, builder);
221.73 + keywords(e, r.keywords(), r.keywordsCategory(), r, file);
221.74 file.write();
221.75 layer(e).folder("OptionsDialog/" + r.id()).position(0).write();
221.76 }
221.77 return true;
221.78 }
221.79
221.80 - private void iconBase(Element e, String iconBase, File file) throws LayerGenerationException {
221.81 - try { // XXX should probably be made a utility method in LayerBuilder
221.82 - try {
221.83 - processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", iconBase).openInputStream().close();
221.84 - } catch (FileNotFoundException x) {
221.85 - try {
221.86 - processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", iconBase).openInputStream().close();
221.87 - } catch (IOException x2) {
221.88 - throw x;
221.89 - }
221.90 - }
221.91 - } catch (IOException x) {
221.92 - throw new LayerGenerationException("Could not open " + iconBase + ": " + x, e);
221.93 - }
221.94 + private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException {
221.95 + builder.validateResource(iconBase, e, r, "iconBase", false);
221.96 file.stringvalue("iconBase", iconBase);
221.97 }
221.98
221.99 - private void keywords(Element e, String keywords, String keywordsCategory, File file) throws LayerGenerationException {
221.100 + private void keywords(Element e, String keywords, String keywordsCategory, Annotation r, File file) throws LayerGenerationException {
221.101 if (keywords.length() > 0) {
221.102 if (keywordsCategory.length() == 0) {
221.103 - throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e);
221.104 + throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e, processingEnv, r, "keywordsCategory");
221.105 }
221.106 - file.bundlevalue("keywords", keywords).bundlevalue("keywordsCategory", keywordsCategory);
221.107 + file.bundlevalue("keywords", keywords, r, "keywords").bundlevalue("keywordsCategory", keywordsCategory, r, "keywordsCategory");
221.108 } else {
221.109 if (keywordsCategory.length() > 0) {
221.110 - throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e);
221.111 + throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e, processingEnv, r, "keywords");
221.112 }
221.113 }
221.114 }
222.1 --- a/php.help/javahelp/org/netbeans/modules/php/help/docs/csh/new-project-run-configuration.html Wed Jul 27 10:33:10 2011 +0200
222.2 +++ b/php.help/javahelp/org/netbeans/modules/php/help/docs/csh/new-project-run-configuration.html Wed Jul 27 10:35:25 2011 +0200
222.3 @@ -54,15 +54,13 @@
222.4 </h2>
222.5
222.6 <p>
222.7 - Run configurations accommodate the most commonly used PHP development use cases. A run
222.8 - configuration is a stored setting for running a PHP project. You can define several
222.9 + A run configuration is a stored setting for running a PHP project. You can define several
222.10 configurations for one project and switch between them back and forth. Run configurations
222.11 apply to both running and debugging.
222.12 </p>
222.13 - <p>
222.14 - <strong>Note:</strong> During the project creation, the default run configuration is
222.15 - defined. To define additional run configuration, customize your project setup.
222.16 - </p>
222.17 + <ul class="note"><li>All projects have a default run configuration, which is created in this
222.18 + panel. After you create a project, you can
222.19 + add additional run configurations in the project's Properties.</li></ul>
222.20 <ul>
222.21 <li>
222.22 <b>Run As:</b> Choose one of the following. The Run Configuration options change depending
223.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
223.2 +++ b/php.help/javahelp/org/netbeans/modules/php/help/docs/csh/refactoring.html Wed Jul 27 10:35:25 2011 +0200
223.3 @@ -0,0 +1,124 @@
223.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
223.5 +<!--
223.6 + Sun Public License Notice
223.7 +
223.8 +The contents of this file are subject to the Sun Public License
223.9 +Version 1.0 (the "License"). You may not use this file except in
223.10 +compliance with the License. A copy of the License is available at
223.11 +http://www.sun.com/
223.12 +
223.13 +The Original Code is NetBeans. The Initial Developer of the Original
223.14 +Code is Sun Microsystems, Inc. Portions Copyright 2009 Sun
223.15 +Microsystems, Inc. All Rights Reserved.
223.16 +
223.17 +If you wish your version of this file to be governed by only the CDDL
223.18 +or only the GPL Version 2, indicate your decision by adding
223.19 +"[Contributor] elects to include this software in this distribution
223.20 +under the [CDDL or GPL Version 2] license." If you do not indicate a
223.21 +single choice of license, a recipient has the option to distribute
223.22 +your version of this file under either the CDDL, the GPL Version 2 or
223.23 +to extend the choice of license to its licensees as provided above.
223.24 +However, if you add GPL Version 2 code and therefore, elected the GPL
223.25 +Version 2 license, then the option applies only if the new code is
223.26 +made subject to such option by the copyright holder.
223.27 +-->
223.28 +<html>
223.29 + <head>
223.30 + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
223.31 + <link rel="stylesheet" href=
223.32 + "nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type=
223.33 + "text/css">
223.34 + <meta content="Helen" name="generator">
223.35 + <style type="text/css">
223.36 + <!--
223.37 + .comment {
223.38 + color: blue;
223.39 + }
223.40 + .change-bar {
223.41 + border-color: black;
223.42 + border-left-style: solid;
223.43 + border-left: thin;
223.44 + padding-left: 6px;
223.45 + }
223.46 + .deleted {
223.47 + text-decoration: line-through;
223.48 + }
223.49 + -->
223.50 + </style>
223.51 + <title>Rename Refactoring</title>
223.52 + </head>
223.53 + <body>
223.54 + <h2>
223.55 + Rename Refactoring
223.56 + </h2>
223.57 + <p>Rename Refactoring allows you to safely rename an element across all files in an application.
223.58 + For safety, rename refactoring requires you to preview and approve your changes.</p>
223.59 + <h3>Rename dialog</h3>
223.60 + <ul>
223.61 + <li><b>New name:</b> Type the new name in this field.</li>
223.62 + <li><b>Preview.</b> You must click Preview to rename the element. Clicking Preview opens
223.63 + the Refactoring window.</li>
223.64 + </ul>
223.65 + <h3>Refactoring Window</h3>
223.66 + <p>The Refactoring window opens below the Editor window. The Refactoring window shows every place in your
223.67 + application that could be affected by refactoring, and lets you exclude files or individual instances
223.68 + from refactoring. The Refactoring window contains the following sections:</p>
223.69 + <ul>
223.70 + <li><a name="buttons"></a><b>Navigation buttons.</b> On the left side of the Refactoring window are a series of buttons for navigating through the
223.71 + <a href="#tree">tree of instances</a>. Hover your cursor over a button to see a tooltip describing its function.
223.72 + <table>
223.73 + <tr>
223.74 + <td><img src="../images/refactoring/nav-buttons.png" alt="Navigation buttons on left side of Refactoring window"></td>
223.75 + <td>
223.76 + <ul>
223.77 + <li>Refresh</li>
223.78 + <li>Collapse/expand all nodes in tree</li>
223.79 + <li>Show logical view (organized by syntax)</li>
223.80 + <li>Show physical view (organized by location)</li>
223.81 + <li>Previous occurance</li>
223.82 + <li>Next occurance</li>
223.83 + </ul></td>
223.84 + </tr>
223.85 + </table></li>
223.86 + <li><a name="tree"></a><b>Tree of instances.</b> A tree view of all instances of the element
223.87 + that you want to rename. Using the <a href="#buttons">navigation buttons</a> you can view either a logical tree,
223.88 + organized by syntax, or a physical view, organized by location. By default, all instances are ticked.
223.89 + Untick an instance if you do not want to rename that instance. Select an instance to preview the
223.90 + current/refactored form in the preview.<br>
223.91 + <img alt="Tree of instances in Refactoring window" src="../images/refactoring/tree.png" >
223.92 + </li>
223.93 + <li><b>Preview.</b> In the preview, compare the original and refactored versions of the code line
223.94 + you selected in the tree of instances.<br>
223.95 + <img alt="Preview panel in the Refactoring window" src="../images/refactoring/preview.png">
223.96 + </li>
223.97 + <li><b>Do refactoring/Cancel.</b> After you have previewed the refactoring and excluded any
223.98 + instances that you do not want to rename, click <b>Do refactoring</b>. If you do not want to rename
223.99 + any instances, click <b>Cancel</b>.</li>
223.100 + </ul>
223.101 + <p>For a demonstration of rename refactoring, see <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
223.102 + <param name="content" value="http://netbeans.org/kb/docs/php/screencast-rename-refactoring.html">
223.103 + <param name="text" value="<html><u>Rename Refactoring and Other Editor Improvements in NetBeans IDE for PHP 7.0</u>.</html>">
223.104 + <param name="textFontSize" value="medium">
223.105 + <param name="textColor" value="blue"></object></p>
223.106 + <hr>
223.107 + <small><a href="../credits.html">Legal Notices</a></small>
223.108 +
223.109 + <table border="0" cellpadding="150">
223.110 + <tr>
223.111 + <td>
223.112 +
223.113 + </td>
223.114 + </tr>
223.115 + <tr>
223.116 + <td>
223.117 +
223.118 + </td>
223.119 + </tr>
223.120 + <tr>
223.121 + <td>
223.122 +
223.123 + </td>
223.124 + </tr>
223.125 + </table>
223.126 + </body>
223.127 +</html>
224.1 Binary file php.help/javahelp/org/netbeans/modules/php/help/docs/images/refactoring/nav-buttons.png has changed
225.1 Binary file php.help/javahelp/org/netbeans/modules/php/help/docs/images/refactoring/preview.png has changed
226.1 Binary file php.help/javahelp/org/netbeans/modules/php/help/docs/images/refactoring/tree.png has changed
227.1 --- a/project.ant/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
227.2 +++ b/project.ant/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
227.3 @@ -139,7 +139,7 @@
227.4 <build-prerequisite/>
227.5 <compile-dependency/>
227.6 <run-dependency>
227.7 - <specification-version>7.19</specification-version>
227.8 + <specification-version>7.50</specification-version>
227.9 </run-dependency>
227.10 </dependency>
227.11 <dependency>
228.1 --- a/project.ant/src/org/netbeans/modules/project/ant/AntBasedProcessor.java Wed Jul 27 10:33:10 2011 +0200
228.2 +++ b/project.ant/src/org/netbeans/modules/project/ant/AntBasedProcessor.java Wed Jul 27 10:35:25 2011 +0200
228.3 @@ -95,10 +95,10 @@
228.4 name = classname.replace('.', '-');
228.5 methodname = null;
228.6 if (!e.getModifiers().contains(Modifier.PUBLIC)) {
228.7 - throw new LayerGenerationException("Class needs to be public"); // NOI18N
228.8 + throw new LayerGenerationException("Class needs to be public", e, processingEnv, reg); // NOI18N
228.9 }
228.10 if (!processingEnv.getTypeUtils().isAssignable(e.asType(), project)) {
228.11 - throw new LayerGenerationException("Class needs to extend Project"); // NOI18N
228.12 + throw new LayerGenerationException("Class needs to extend Project", e, processingEnv, reg); // NOI18N
228.13 }
228.14 boolean found = false;
228.15 for (Element cns : processingEnv.getElementUtils().getAllMembers((TypeElement)e)) {
228.16 @@ -118,7 +118,7 @@
228.17 }
228.18 }
228.19 if (!found) {
228.20 - throw new LayerGenerationException("There needs to be public constructor taking AntProjectHelper parameter"); // NOI18N
228.21 + throw new LayerGenerationException("There needs to be public constructor taking AntProjectHelper parameter", e, processingEnv, reg); // NOI18N
228.22 }
228.23
228.24 break;
228.25 @@ -128,7 +128,7 @@
228.26 name = (classname + "." + methodname).replace('.', '-');
228.27
228.28 if (!e.getEnclosingElement().getModifiers().contains(Modifier.PUBLIC)) {
228.29 - throw new LayerGenerationException("Class needs to be public"); // NOI18N
228.30 + throw new LayerGenerationException("Class needs to be public", e, processingEnv, reg); // NOI18N
228.31 }
228.32
228.33 ExecutableElement exec = (ExecutableElement)e;
228.34 @@ -138,10 +138,10 @@
228.35 exec.getParameters().size() != 1 ||
228.36 !exec.getParameters().get(0).asType().equals(antHelper)
228.37 ) {
228.38 - throw new LayerGenerationException("The method needs to be public, static and take AntProjectHelper argument"); // NOI18N
228.39 + throw new LayerGenerationException("The method needs to be public, static and take AntProjectHelper argument", e, processingEnv, reg); // NOI18N
228.40 }
228.41 if (!processingEnv.getTypeUtils().isAssignable(exec.getReturnType(), project)) {
228.42 - throw new LayerGenerationException("Method needs to return Project"); // NOI18N
228.43 + throw new LayerGenerationException("Method needs to return Project", e, processingEnv, reg); // NOI18N
228.44 }
228.45
228.46 break;
229.1 --- a/projectapi/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
229.2 +++ b/projectapi/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
229.3 @@ -63,7 +63,7 @@
229.4 <build-prerequisite/>
229.5 <compile-dependency/>
229.6 <run-dependency>
229.7 - <specification-version>6.2</specification-version>
229.8 + <specification-version>7.50</specification-version>
229.9 </run-dependency>
229.10 </dependency>
229.11 <dependency>
230.1 --- a/projectapi/src/org/netbeans/modules/projectapi/LookupProviderAnnotationProcessor.java Wed Jul 27 10:33:10 2011 +0200
230.2 +++ b/projectapi/src/org/netbeans/modules/projectapi/LookupProviderAnnotationProcessor.java Wed Jul 27 10:35:25 2011 +0200
230.3 @@ -96,32 +96,32 @@
230.4 for (Element e : roundEnv.getElementsAnnotatedWith(LookupProvider.Registration.class)) {
230.5 LookupProvider.Registration lpr = e.getAnnotation(LookupProvider.Registration.class);
230.6 if (lpr.projectType().length == 0 && lpr.projectTypes().length == 0) {
230.7 - throw new LayerGenerationException("You must specify either projectType or projectTypes", e);
230.8 + throw new LayerGenerationException("You must specify either projectType or projectTypes", e, processingEnv, lpr);
230.9 }
230.10 for (String type : lpr.projectType()) {
230.11 - layer(e).instanceFile("Projects/" + type + "/Lookup", null, LookupProvider.class).write();
230.12 + layer(e).instanceFile("Projects/" + type + "/Lookup", null, LookupProvider.class, lpr, null).write();
230.13 }
230.14 for (LookupProvider.Registration.ProjectType type : lpr.projectTypes()) {
230.15 - layer(e).instanceFile("Projects/" + type.id() + "/Lookup", null, LookupProvider.class).position(type.position()).write();
230.16 + layer(e).instanceFile("Projects/" + type.id() + "/Lookup", null, LookupProvider.class, type, null).position(type.position()).write();
230.17 }
230.18 }
230.19 for (Element e : roundEnv.getElementsAnnotatedWith(ProjectServiceProvider.class)) {
230.20 + ProjectServiceProvider psp = e.getAnnotation(ProjectServiceProvider.class);
230.21 List<TypeMirror> services = findServiceAnnotation(e);
230.22 if (services.isEmpty()) {
230.23 - throw new LayerGenerationException("Must specify at least one service", e);
230.24 + throw new LayerGenerationException("Must specify at least one service", e, processingEnv, psp);
230.25 }
230.26 String servicesBinName = null;
230.27 for (TypeMirror service : services) {
230.28 String n = processingEnv.getElementUtils().getBinaryName((TypeElement) processingEnv.getTypeUtils().asElement(service)).toString();
230.29 if (n.equals(LookupMerger.class.getName())) {
230.30 - throw new LayerGenerationException("@ProjectServiceProvider should not be used on LookupMerger; use @LookupMerger.Registration instead", e);
230.31 + throw new LayerGenerationException("@ProjectServiceProvider should not be used on LookupMerger; use @LookupMerger.Registration instead", e, processingEnv, psp);
230.32 }
230.33 servicesBinName = servicesBinName == null ? n : servicesBinName + "," + n;
230.34 }
230.35 - String[] binAndMethodNames = findPSPDefinition(e, services);
230.36 - ProjectServiceProvider psp = e.getAnnotation(ProjectServiceProvider.class);
230.37 + String[] binAndMethodNames = findPSPDefinition(e, services, psp);
230.38 if (psp.projectType().length == 0 && psp.projectTypes().length == 0) {
230.39 - throw new LayerGenerationException("You must specify either projectType or projectTypes", e);
230.40 + throw new LayerGenerationException("You must specify either projectType or projectTypes", e, processingEnv, psp);
230.41 }
230.42 String fileBaseName = binAndMethodNames[0].replace('.', '-');
230.43 if (binAndMethodNames[1] != null) {
230.44 @@ -163,11 +163,11 @@
230.45 }
230.46 DeclaredType service = findLookupMergerType(impl);
230.47 if (service == null) {
230.48 - throw new LayerGenerationException("Not assignable to LookupMerger<T> for some T", e);
230.49 + throw new LayerGenerationException("Not assignable to LookupMerger<T> for some T", e, processingEnv, lmr);
230.50 }
230.51 String serviceBinName = processingEnv.getElementUtils().getBinaryName((TypeElement) service.asElement()).toString();
230.52 if (lmr.projectType().length == 0 && lmr.projectTypes().length == 0) {
230.53 - throw new LayerGenerationException("You must specify either projectType or projectTypes", e);
230.54 + throw new LayerGenerationException("You must specify either projectType or projectTypes", e, processingEnv, lmr);
230.55 }
230.56 for (String type : lmr.projectType()) {
230.57 layer(e).file("Projects/" + type + "/Lookup/" + fileBaseName + ".instance").
230.58 @@ -208,12 +208,12 @@
230.59 throw new LayerGenerationException("No @ProjectServiceProvider found", e);
230.60 }
230.61
230.62 - private String[] findPSPDefinition(Element e, List<TypeMirror> services) throws LayerGenerationException {
230.63 + private String[] findPSPDefinition(Element e, List<TypeMirror> services, ProjectServiceProvider psp) throws LayerGenerationException {
230.64 if (e.getKind() == ElementKind.CLASS) {
230.65 TypeElement clazz = (TypeElement) e;
230.66 for (TypeMirror service : services) {
230.67 if (!processingEnv.getTypeUtils().isAssignable(clazz.asType(), service)) {
230.68 - throw new LayerGenerationException("Not assignable to " + service, e);
230.69 + throw new LayerGenerationException("Not assignable to " + service, e, processingEnv, psp);
230.70 }
230.71 }
230.72 int constructorCount = 0;
230.73 @@ -234,37 +234,37 @@
230.74 constructorCount++;
230.75 }
230.76 if (constructorCount != 1) {
230.77 - throw new LayerGenerationException("Must have exactly one public constructor optionally taking Project and/or Lookup", e);
230.78 + throw new LayerGenerationException("Must have exactly one public constructor optionally taking Project and/or Lookup", e, processingEnv, psp);
230.79 }
230.80 if (!clazz.getModifiers().contains(Modifier.PUBLIC)) {
230.81 - throw new LayerGenerationException("Class must be public", e);
230.82 + throw new LayerGenerationException("Class must be public", e, processingEnv, psp);
230.83 }
230.84 return new String[] {processingEnv.getElementUtils().getBinaryName(clazz).toString(), null};
230.85 } else {
230.86 ExecutableElement meth = (ExecutableElement) e;
230.87 for (TypeMirror service : services) {
230.88 if (!processingEnv.getTypeUtils().isAssignable(meth.getReturnType(), service)) {
230.89 - throw new LayerGenerationException("Not assignable to " + service, e);
230.90 + throw new LayerGenerationException("Not assignable to " + service, e, processingEnv, psp);
230.91 }
230.92 }
230.93 if (!meth.getModifiers().contains(Modifier.PUBLIC)) {
230.94 - throw new LayerGenerationException("Method must be public", e);
230.95 + throw new LayerGenerationException("Method must be public", e, processingEnv, psp);
230.96 }
230.97 if (!meth.getModifiers().contains(Modifier.STATIC)) {
230.98 - throw new LayerGenerationException("Method must be static", e);
230.99 + throw new LayerGenerationException("Method must be static", e, processingEnv, psp);
230.100 }
230.101 List<? extends VariableElement> params = meth.getParameters();
230.102 if (params.size() > 2) {
230.103 - throw new LayerGenerationException("Method must take at most two parameters", e);
230.104 + throw new LayerGenerationException("Method must take at most two parameters", e, processingEnv, psp);
230.105 }
230.106 for (VariableElement param : params) {
230.107 if (!param.asType().equals(processingEnv.getElementUtils().getTypeElement(Project.class.getCanonicalName()).asType()) &&
230.108 !param.asType().equals(processingEnv.getElementUtils().getTypeElement(Lookup.class.getCanonicalName()).asType())) {
230.109 - throw new LayerGenerationException("Method parameters may be either Lookup or Project", e);
230.110 + throw new LayerGenerationException("Method parameters may be either Lookup or Project", e, processingEnv, psp);
230.111 }
230.112 }
230.113 if (!meth.getEnclosingElement().getModifiers().contains(Modifier.PUBLIC)) {
230.114 - throw new LayerGenerationException("Class must be public", e);
230.115 + throw new LayerGenerationException("Class must be public", e, processingEnv, psp);
230.116 }
230.117 return new String[] {
230.118 processingEnv.getElementUtils().getBinaryName((TypeElement) meth.getEnclosingElement()).toString(),
231.1 --- a/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java Wed Jul 27 10:33:10 2011 +0200
231.2 +++ b/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java Wed Jul 27 10:35:25 2011 +0200
231.3 @@ -44,7 +44,6 @@
231.4
231.5 package org.netbeans.modules.project.ui;
231.6
231.7 -import java.awt.EventQueue;
231.8 import java.beans.BeanInfo;
231.9 import java.beans.PropertyChangeEvent;
231.10 import java.beans.PropertyChangeListener;
231.11 @@ -82,7 +81,6 @@
231.12 import java.util.logging.LogRecord;
231.13 import java.util.logging.Logger;
231.14 import javax.swing.Icon;
231.15 -import javax.swing.JDialog;
231.16 import javax.swing.SwingUtilities;
231.17 import org.netbeans.api.annotations.common.NonNull;
231.18 import org.netbeans.api.progress.ProgressHandle;
231.19 @@ -100,8 +98,6 @@
231.20 import org.netbeans.spi.project.ui.PrivilegedTemplates;
231.21 import org.netbeans.spi.project.ui.ProjectOpenedHook;
231.22 import org.netbeans.spi.project.ui.RecommendedTemplates;
231.23 -import org.openide.DialogDescriptor;
231.24 -import org.openide.DialogDisplayer;
231.25 import org.openide.ErrorManager;
231.26 import org.openide.filesystems.FileChangeAdapter;
231.27 import org.openide.filesystems.FileEvent;
231.28 @@ -113,6 +109,7 @@
231.29 import org.openide.loaders.DataObjectNotFoundException;
231.30 import org.openide.modules.ModuleInfo;
231.31 import org.openide.nodes.Node;
231.32 +import org.openide.util.Cancellable;
231.33 import org.openide.util.Exceptions;
231.34 import org.openide.util.ImageUtilities;
231.35 import org.openide.util.Lookup;
231.36 @@ -551,8 +548,7 @@
231.37 public void open(final Project[] projects, final boolean openSubprojects, final boolean asynchronously) {
231.38 open(projects, openSubprojects, asynchronously, null);
231.39 }
231.40 -
231.41 - @Messages("LBL_Opening_Projects_Progress=Opening Projects")
231.42 +
231.43 public void open(final Project[] projects, final boolean openSubprojects, final boolean asynchronously, final Project/*|null*/ mainProject) {
231.44 if (projects.length == 0) {
231.45 //nothing to do:
231.46 @@ -561,56 +557,35 @@
231.47
231.48 long start = System.currentTimeMillis();
231.49
231.50 - if (asynchronously) {
231.51 - if (!EventQueue.isDispatchThread()) { // #89935
231.52 - EventQueue.invokeLater(new Runnable() {
231.53 - public void run() {
231.54 - open(projects, openSubprojects, asynchronously, mainProject);
231.55 + if (asynchronously) {
231.56 + class Cancellation extends AtomicBoolean implements Cancellable {
231.57 + Thread t;
231.58 + @Override public boolean cancel() {
231.59 + if (t != null) {
231.60 + t.interrupt();
231.61 }
231.62 - });
231.63 - return;
231.64 + return compareAndSet(false, true);
231.65 + }
231.66 }
231.67 - final ProgressHandle handle = ProgressHandleFactory.createHandle(CAP_Opening_Projects());
231.68 - final OpeningProjectPanel panel = new OpeningProjectPanel();
231.69 - panel.setProjectName(projects[0].getProjectDirectory().getNameExt());
231.70 - final DialogDescriptor dd = new DialogDescriptor(panel, LBL_Opening_Projects_Progress(), true, null);
231.71 - dd.setLeaf(true);
231.72 - dd.setOptions(new Object[0]);
231.73 - final JDialog dialog = (JDialog) DialogDisplayer.getDefault().createDialog(
231.74 - dd);
231.75 - dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); //make sure the dialog is not closed during the project open
231.76 -
231.77 - OPENING_RP.post(new Runnable() {
231.78 - public void run() {
231.79 - try {
231.80 - doOpen(projects, openSubprojects, handle, panel);
231.81 - if (mainProject != null && Arrays.asList(projects).contains(mainProject) && openProjects.contains(mainProject)) {
231.82 - setMainProject(mainProject);
231.83 - }
231.84 - } finally {
231.85 - SwingUtilities.invokeLater(new Runnable() {
231.86 - public void run() {
231.87 - //fix for #67114:
231.88 - try {
231.89 - Thread.sleep(50);
231.90 - } catch (InterruptedException e) {
231.91 - // ignored
231.92 - }
231.93 - dialog.setVisible(false);
231.94 - dialog.dispose();
231.95 - }
231.96 - });
231.97 - }
231.98 - }
231.99 - });
231.100 -
231.101 - dialog.setVisible(true);
231.102 - } else {
231.103 - doOpen(projects, openSubprojects, null, null);
231.104 + final Cancellation cancellation = new Cancellation();
231.105 + final ProgressHandle handle = ProgressHandleFactory.createHandle(CAP_Opening_Projects(), cancellation);
231.106 + handle.start();
231.107 + handle.progress(projects[0].getProjectDirectory().getNameExt());
231.108 + OPENING_RP.post(new Runnable() {
231.109 + @Override public void run() {
231.110 + cancellation.t = Thread.currentThread();
231.111 + doOpen(projects, openSubprojects, handle, cancellation);
231.112 + if (mainProject != null && Arrays.asList(projects).contains(mainProject) && openProjects.contains(mainProject)) {
231.113 + setMainProject(mainProject);
231.114 + }
231.115 + }
231.116 + });
231.117 + } else {
231.118 + doOpen(projects, openSubprojects, null, null);
231.119 if (mainProject != null && Arrays.asList(projects).contains(mainProject) && openProjects.contains(mainProject)) {
231.120 setMainProject(mainProject);
231.121 }
231.122 - }
231.123 + }
231.124
231.125 long end = System.currentTimeMillis();
231.126
231.127 @@ -618,8 +593,9 @@
231.128 log(Level.FINE, "opening projects took: " + (end - start) + "ms");
231.129 }
231.130 }
231.131 -
231.132 - private void doOpen(Project[] projects, boolean openSubprojects, ProgressHandle handle, OpeningProjectPanel panel) {
231.133 +
231.134 + @Messages({"# {0} - project display name", "OpenProjectList.finding_subprojects=Finding required projects of {0}"})
231.135 + private void doOpen(Project[] projects, boolean openSubprojects, ProgressHandle handle, AtomicBoolean canceled) {
231.136 assert !Arrays.asList(projects).contains(null) : "Projects can't be null";
231.137 LOAD.waitFinished();
231.138
231.139 @@ -633,21 +609,19 @@
231.140 Collection<Project> projectsToOpen = new LinkedHashSet<Project>();
231.141
231.142 if (handle != null) {
231.143 - handle.start(maxWork);
231.144 + handle.switchToDeterminate(maxWork);
231.145 handle.progress(0);
231.146 }
231.147
231.148 - if (panel != null) {
231.149 - assert projects.length > 0 : "at least one project to open";
231.150 -
231.151 - panel.setProjectName(ProjectUtils.getInformation(projects[0]).getDisplayName());
231.152 - }
231.153 -
231.154 Map<Project,Set<? extends Project>> subprojectsCache = new HashMap<Project,Set<? extends Project>>(); // #59098
231.155
231.156 List<Project> toHandle = new LinkedList<Project>(Arrays.asList(projects));
231.157
231.158 while (!toHandle.isEmpty()) {
231.159 + if (canceled != null && canceled.get()) {
231.160 + break;
231.161 + }
231.162 +
231.163 Project p = toHandle.remove(0);
231.164 assert p != null;
231.165 Set<? extends Project> subprojects = openSubprojects ? subprojectsCache.get(p) : Collections.<Project>emptySet();
231.166 @@ -655,6 +629,9 @@
231.167 if (subprojects == null) {
231.168 SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
231.169 if (spp != null) {
231.170 + if (handle != null) {
231.171 + handle.progress(OpenProjectList_finding_subprojects(ProjectUtils.getInformation(p).getDisplayName()));
231.172 + }
231.173 subprojects = spp.getSubprojects();
231.174 } else {
231.175 subprojects = Collections.emptySet();
231.176 @@ -693,9 +670,11 @@
231.177 });
231.178
231.179 for (Project p: projectsToOpen) {
231.180 -
231.181 - if (panel != null) {
231.182 - panel.setProjectName(ProjectUtils.getInformation(p).getDisplayName());
231.183 + if (canceled != null && canceled.get()) {
231.184 + break;
231.185 + }
231.186 + if (handle != null) {
231.187 + handle.progress(ProjectUtils.getInformation(p).getDisplayName());
231.188 }
231.189
231.190 recentProjectsChanged |= doOpenProject(p);
231.191 @@ -709,6 +688,8 @@
231.192 }
231.193 }
231.194
231.195 + Thread.interrupted(); // just to clear status
231.196 +
231.197 final boolean _recentProjectsChanged = recentProjectsChanged;
231.198 ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
231.199 public @Override Void run() {
232.1 --- a/projectui/src/org/netbeans/modules/project/ui/OpeningProjectPanel.form Wed Jul 27 10:33:10 2011 +0200
232.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
232.3 @@ -1,54 +0,0 @@
232.4 -<?xml version="1.0" encoding="UTF-8" ?>
232.5 -
232.6 -<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
232.7 - <Properties>
232.8 - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
232.9 - <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
232.10 - <EmptyBorder bottom="11" left="11" right="11" top="11"/>
232.11 - </Border>
232.12 - </Property>
232.13 - </Properties>
232.14 - <AuxValues>
232.15 - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
232.16 - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
232.17 - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
232.18 - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
232.19 - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
232.20 - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
232.21 - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
232.22 - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
232.23 - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
232.24 - </AuxValues>
232.25 -
232.26 - <Layout>
232.27 - <DimensionLayout dim="0">
232.28 - <Group type="103" groupAlignment="0" attributes="0">
232.29 - <Group type="102" alignment="0" attributes="0">
232.30 - <Component id="openingProjectLabel" min="-2" max="-2" attributes="0"/>
232.31 - <EmptySpace type="unrelated" max="-2" attributes="0"/>
232.32 - <Component id="nameOfTheProject" pref="298" max="32767" attributes="0"/>
232.33 - <EmptySpace max="-2" attributes="0"/>
232.34 - </Group>
232.35 - </Group>
232.36 - </DimensionLayout>
232.37 - <DimensionLayout dim="1">
232.38 - <Group type="103" groupAlignment="0" attributes="0">
232.39 - <Group type="103" groupAlignment="3" attributes="0">
232.40 - <Component id="openingProjectLabel" alignment="3" min="-2" max="-2" attributes="0"/>
232.41 - <Component id="nameOfTheProject" alignment="3" min="-2" max="-2" attributes="0"/>
232.42 - </Group>
232.43 - </Group>
232.44 - </DimensionLayout>
232.45 - </Layout>
232.46 - <SubComponents>
232.47 - <Component class="javax.swing.JLabel" name="openingProjectLabel">
232.48 - <Properties>
232.49 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
232.50 - <ResourceString bundle="org/netbeans/modules/project/ui/Bundle.properties" key="OpeningProjectPanel.openingProjectLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
232.51 - </Property>
232.52 - </Properties>
232.53 - </Component>
232.54 - <Component class="javax.swing.JLabel" name="nameOfTheProject">
232.55 - </Component>
232.56 - </SubComponents>
232.57 -</Form>
233.1 --- a/projectui/src/org/netbeans/modules/project/ui/OpeningProjectPanel.java Wed Jul 27 10:33:10 2011 +0200
233.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
233.3 @@ -1,93 +0,0 @@
233.4 -/*
233.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
233.6 - *
233.7 - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
233.8 - *
233.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
233.10 - * Other names may be trademarks of their respective owners.
233.11 - *
233.12 - * The contents of this file are subject to the terms of either the GNU
233.13 - * General Public License Version 2 only ("GPL") or the Common
233.14 - * Development and Distribution License("CDDL") (collectively, the
233.15 - * "License"). You may not use this file except in compliance with the
233.16 - * License. You can obtain a copy of the License at
233.17 - * http://www.netbeans.org/cddl-gplv2.html
233.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
233.19 - * specific language governing permissions and limitations under the
233.20 - * License. When distributing the software, include this License Header
233.21 - * Notice in each file and include the License file at
233.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
233.23 - * particular file as subject to the "Classpath" exception as provided
233.24 - * by Oracle in the GPL Version 2 section of the License file that
233.25 - * accompanied this code. If applicable, add the following below the
233.26 - * License Header, with the fields enclosed by brackets [] replaced by
233.27 - * your own identifying information:
233.28 - * "Portions Copyrighted [year] [name of copyright owner]"
233.29 - *
233.30 - * Contributor(s):
233.31 - *
233.32 - * The Original Software is NetBeans. The Initial Developer of the Original
233.33 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
233.34 - * Microsystems, Inc. All Rights Reserved.
233.35 - *
233.36 - * If you wish your version of this file to be governed by only the CDDL
233.37 - * or only the GPL Version 2, indicate your decision by adding
233.38 - * "[Contributor] elects to include this software in this distribution
233.39 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
233.40 - * single choice of license, a recipient has the option to distribute
233.41 - * your version of this file under either the CDDL, the GPL Version 2 or
233.42 - * to extend the choice of license to its licensees as provided above.
233.43 - * However, if you add GPL Version 2 code and therefore, elected the GPL
233.44 - * Version 2 license, then the option applies only if the new code is
233.45 - * made subject to such option by the copyright holder.
233.46 - */
233.47 -
233.48 -package org.netbeans.modules.project.ui;
233.49 -
233.50 -/**
233.51 - *
233.52 - * @author Jan Lahoda
233.53 - */
233.54 -public class OpeningProjectPanel extends javax.swing.JPanel {
233.55 - public OpeningProjectPanel() {
233.56 - initComponents();
233.57 - }
233.58 -
233.59 - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
233.60 - private void initComponents() {
233.61 -
233.62 - openingProjectLabel = new javax.swing.JLabel();
233.63 - nameOfTheProject = new javax.swing.JLabel();
233.64 -
233.65 - setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11));
233.66 -
233.67 - openingProjectLabel.setText(org.openide.util.NbBundle.getMessage(OpeningProjectPanel.class, "OpeningProjectPanel.openingProjectLabel.text")); // NOI18N
233.68 -
233.69 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
233.70 - this.setLayout(layout);
233.71 - layout.setHorizontalGroup(
233.72 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233.73 - .addGroup(layout.createSequentialGroup()
233.74 - .addComponent(openingProjectLabel)
233.75 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
233.76 - .addComponent(nameOfTheProject, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
233.77 - .addContainerGap())
233.78 - );
233.79 - layout.setVerticalGroup(
233.80 - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233.81 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
233.82 - .addComponent(openingProjectLabel)
233.83 - .addComponent(nameOfTheProject))
233.84 - );
233.85 - }// </editor-fold>//GEN-END:initComponents
233.86 -
233.87 -
233.88 - // Variables declaration - do not modify//GEN-BEGIN:variables
233.89 - private javax.swing.JLabel nameOfTheProject;
233.90 - private javax.swing.JLabel openingProjectLabel;
233.91 - // End of variables declaration//GEN-END:variables
233.92 -
233.93 - public void setProjectName(String name) {
233.94 - nameOfTheProject.setText(name);
233.95 - }
233.96 -}
234.1 --- a/projectui/src/org/netbeans/modules/project/ui/actions/RecentProjects.java Wed Jul 27 10:33:10 2011 +0200
234.2 +++ b/projectui/src/org/netbeans/modules/project/ui/actions/RecentProjects.java Wed Jul 27 10:35:25 2011 +0200
234.3 @@ -86,7 +86,6 @@
234.4 /** Key for remembering project in JMenuItem
234.5 */
234.6 private static final String PROJECT_URL_KEY = "org.netbeans.modules.project.ui.RecentProjectItem.Project_URL"; // NOI18N
234.7 - private static final String STATUS_MESSAGE_KEY = "org.netbeans.modules.project.ui.RecentProjectItem.STATUS_MESSAGE_KEY"; // NOI18N
234.8 private final ProjectDirListener prjDirListener = new ProjectDirListener();
234.9
234.10 private UpdatingMenu subMenu;
234.11 @@ -164,7 +163,7 @@
234.12 public @Override void menuSelectionChanged(boolean isIncluded) {
234.13 super.menuSelectionChanged(isIncluded);
234.14 if (isIncluded) {
234.15 - putClientProperty(STATUS_MESSAGE_KEY, StatusDisplayer.getDefault().setStatusText(FileUtil.getFileDisplayName(prjDir), 1));
234.16 + StatusDisplayer.getDefault().setStatusText(FileUtil.getFileDisplayName(prjDir));
234.17 }
234.18 }
234.19 };
234.20 @@ -199,11 +198,8 @@
234.21 if ( e.getSource() instanceof JMenuItem ) {
234.22 JMenuItem jmi = (JMenuItem)e.getSource();
234.23
234.24 - StatusDisplayer.Message statusMessage = (StatusDisplayer.Message) jmi.getClientProperty(STATUS_MESSAGE_KEY);
234.25 - if (statusMessage != null) {
234.26 - statusMessage.clear(0);
234.27 - }
234.28 -
234.29 + StatusDisplayer.getDefault().setStatusText("");
234.30 +
234.31 URL url = (URL)jmi.getClientProperty( PROJECT_URL_KEY );
234.32 Project project = null;
234.33
235.1 --- a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Wed Jul 27 10:33:10 2011 +0200
235.2 +++ b/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Wed Jul 27 10:35:25 2011 +0200
235.3 @@ -207,13 +207,6 @@
235.4 </folder>
235.5 </folder>
235.6
235.7 - <folder name="Privileged">
235.8 - <file name="Folder.shadow">
235.9 - <attr name="originalFile" stringvalue="Templates/Other/Folder"/>
235.10 - <attr name="position" intvalue="2000"/>
235.11 - </file>
235.12 - </folder>
235.13 -
235.14 <!-- Licenses folder -->
235.15 <folder name="Licenses">
235.16 <attr name="templateCategory" stringvalue="invisible"/>
236.1 --- a/projectuiapi/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
236.2 +++ b/projectuiapi/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
236.3 @@ -114,7 +114,7 @@
236.4 <build-prerequisite/>
236.5 <compile-dependency/>
236.6 <run-dependency>
236.7 - <specification-version>7.26</specification-version>
236.8 + <specification-version>7.50</specification-version>
236.9 </run-dependency>
236.10 </dependency>
236.11 <dependency>
237.1 --- a/projectuiapi/src/org/netbeans/modules/project/uiapi/CompositeCategoryProviderAnnotationProcessor.java Wed Jul 27 10:33:10 2011 +0200
237.2 +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/CompositeCategoryProviderAnnotationProcessor.java Wed Jul 27 10:35:25 2011 +0200
237.3 @@ -97,10 +97,10 @@
237.4 }
237.5 if (e.getKind() == ElementKind.PACKAGE) {
237.6 if (!addsFolder) {
237.7 - throw new LayerGenerationException("Must specify categoryLabel", e);
237.8 + throw new LayerGenerationException("Must specify categoryLabel", e, processingEnv, r);
237.9 }
237.10 } else {
237.11 - File f = layer(e).instanceFile(path, addsFolder ? "Self" : null, CompositeCategoryProvider.class);
237.12 + File f = layer(e).instanceFile(path, addsFolder ? "Self" : null, CompositeCategoryProvider.class, r, null);
237.13 f.position(addsFolder ? 0 : r.position());
237.14 f.write();
237.15 }
237.16 @@ -108,9 +108,9 @@
237.17
237.18 private void handleFolder(String path, Element e, Registration r) throws LayerGenerationException {
237.19 if (r.category().length() == 0) {
237.20 - throw new LayerGenerationException("Must specify category", e);
237.21 + throw new LayerGenerationException("Must specify category", e, processingEnv, r);
237.22 }
237.23 - layer(e).folder(path).bundlevalue("displayName", r.categoryLabel()).position(r.position()).write();
237.24 + layer(e).folder(path).bundlevalue("displayName", r.categoryLabel(), r, "categoryLabel").position(r.position()).write();
237.25 }
237.26
237.27 }
238.1 --- a/projectuiapi/src/org/netbeans/modules/project/uiapi/NodeFactoryAnnotationProcessor.java Wed Jul 27 10:33:10 2011 +0200
238.2 +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/NodeFactoryAnnotationProcessor.java Wed Jul 27 10:35:25 2011 +0200
238.3 @@ -73,10 +73,10 @@
238.4 return false;
238.5 }
238.6 for (Element e : roundEnv.getElementsAnnotatedWith(NodeFactory.Registration.class)) {
238.7 - NodeFactory.Registration lpr = e.getAnnotation(NodeFactory.Registration.class);
238.8 - for (String type : lpr.projectType()) {
238.9 - layer(e).instanceFile("Projects/" + type + "/Nodes", null, NodeFactory.class). //NOI18N
238.10 - position(lpr.position()).write();
238.11 + NodeFactory.Registration r = e.getAnnotation(NodeFactory.Registration.class);
238.12 + for (String type : r.projectType()) {
238.13 + layer(e).instanceFile("Projects/" + type + "/Nodes", null, NodeFactory.class, r, null). //NOI18N
238.14 + position(r.position()).write();
238.15 }
238.16 }
238.17 return true;
239.1 --- a/projectuiapi/src/org/netbeans/spi/project/ui/PrivilegedTemplates.java Wed Jul 27 10:33:10 2011 +0200
239.2 +++ b/projectuiapi/src/org/netbeans/spi/project/ui/PrivilegedTemplates.java Wed Jul 27 10:35:25 2011 +0200
239.3 @@ -44,6 +44,8 @@
239.4
239.5 package org.netbeans.spi.project.ui;
239.6
239.7 +import org.netbeans.api.templates.TemplateRegistration;
239.8 +
239.9 /**
239.10 * List of templates which should be in the initial "privileged" list
239.11 * when making a new file.
239.12 @@ -65,6 +67,9 @@
239.13 /**
239.14 * Lists privileged templates.
239.15 * @return full paths to privileged templates, e.g. <samp>Templates/Other/XmlFile.xml</samp>
239.16 + * @see TemplateRegistration#folder
239.17 + * @see TemplateRegistration#content
239.18 + * @see TemplateRegistration#id
239.19 */
239.20 public String[] getPrivilegedTemplates();
239.21
240.1 --- a/projectuiapi/src/org/netbeans/spi/project/ui/RecommendedTemplates.java Wed Jul 27 10:33:10 2011 +0200
240.2 +++ b/projectuiapi/src/org/netbeans/spi/project/ui/RecommendedTemplates.java Wed Jul 27 10:35:25 2011 +0200
240.3 @@ -44,6 +44,8 @@
240.4
240.5 package org.netbeans.spi.project.ui;
240.6
240.7 +import org.netbeans.api.templates.TemplateRegistration;
240.8 +
240.9 /**
240.10 * List of template types supported by a project when making a new file.
240.11 * An instance should be placed in {@link org.netbeans.api.project.Project#getLookup}
240.12 @@ -58,6 +60,7 @@
240.13 /**
240.14 * Lists supported template types.
240.15 * @return types of supported templates (should match template file attribute names)
240.16 + * @see TemplateRegistration#category
240.17 */
240.18 public String[] getRecommendedTypes();
240.19
241.1 --- a/projectuiapi/src/org/netbeans/spi/project/ui/templates/support/package.html Wed Jul 27 10:33:10 2011 +0200
241.2 +++ b/projectuiapi/src/org/netbeans/spi/project/ui/templates/support/package.html Wed Jul 27 10:35:25 2011 +0200
241.3 @@ -58,7 +58,7 @@
241.4 provide own iterator for project-specific customization of given file type.</p>
241.5
241.6 <p>The project type has to declare its file templates in the module's layer file
241.7 -in folder the <code>Templates</code>. The declaration should look as follows:
241.8 +in folder the <code>Templates</code>. The declaration should look as follows (or <code>@TemplateRegistration</code> may be used):
241.9 <p>
241.10 <code>
241.11 <folder name="Templates"><br>
242.1 --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java Wed Jul 27 10:33:10 2011 +0200
242.2 +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java Wed Jul 27 10:35:25 2011 +0200
242.3 @@ -86,7 +86,8 @@
242.4 this.query.getContext().add(RetoucheUtils.getClasspathInfoFor(handle));
242.5 this.element = handle;
242.6 Element el = handle.resolveElement(info);
242.7 - elementHandle = ElementHandle.create(el);
242.8 + if (!(el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER))
242.9 + elementHandle = ElementHandle.create(el);
242.10 if (el!=null) {
242.11 name = ElementHeaders.getHeader(el, info, ElementHeaders.NAME);
242.12 kind = el.getKind();
242.13 @@ -226,7 +227,9 @@
242.14
242.15 @Override
242.16 public void open() {
242.17 - ElementOpen.open(element.getFileObject(), elementHandle);
242.18 + if (elementHandle!=null) {
242.19 + ElementOpen.open(element.getFileObject(), elementHandle);
242.20 + }
242.21 }
242.22
242.23 }
243.1 --- a/schema2beans/src/org/netbeans/modules/schema2beansdev/Schema2BeansProcessor.java Wed Jul 27 10:33:10 2011 +0200
243.2 +++ b/schema2beans/src/org/netbeans/modules/schema2beansdev/Schema2BeansProcessor.java Wed Jul 27 10:35:25 2011 +0200
243.3 @@ -189,6 +189,7 @@
243.4 }
243.5
243.6 private FileObject findResource(String path, String pkg) throws URISyntaxException, IOException {
243.7 + // XXX LayerBuilder has standard versions of this logic now
243.8 String abspath;
243.9 if (path.startsWith("/")) {
243.10 abspath = path.substring(1);
244.1 --- a/settings/nbproject/project.xml Wed Jul 27 10:33:10 2011 +0200
244.2 +++ b/settings/nbproject/project.xml Wed Jul 27 10:35:25 2011 +0200
244.3 @@ -88,7 +88,7 @@
244.4 <build-prerequisite/>
244.5 <compile-dependency/>
244.6 <run-dependency>
244.7 - <specification-version>7.49</specification-version>
244.8 + <specification-version>7.50</specification-version>
244.9 </run-dependency>
244.10 </dependency>
244.11 <dependency>
245.1 --- a/settings/src/org/netbeans/modules/settings/convertors/ConvertorProcessor.java Wed Jul 27 10:33:10 2011 +0200
245.2 +++ b/settings/src/org/netbeans/modules/settings/convertors/ConvertorProcessor.java Wed Jul 27 10:35:25 2011 +0200
245.3 @@ -44,6 +44,7 @@
245.4
245.5 package org.netbeans.modules.settings.convertors;
245.6
245.7 +import java.lang.annotation.Annotation;
245.8 import java.util.Arrays;
245.9 import java.util.HashSet;
245.10 import java.util.Set;
245.11 @@ -93,7 +94,7 @@
245.12 for (Element e : env.getElementsAnnotatedWith(ConvertAsProperties.class)) {
245.13 ConvertAsProperties reg = e.getAnnotation(ConvertAsProperties.class);
245.14
245.15 - String convElem = instantiableClassOrMethod(e, true);
245.16 + String convElem = instantiableClassOrMethod(e, true, reg);
245.17 final String dtd = reg.dtd();
245.18
245.19 String dtdCode = convertPublicId(dtd);
245.20 @@ -146,7 +147,7 @@
245.21
245.22 for (Element e : env.getElementsAnnotatedWith(ConvertAsJavaBean.class)) {
245.23 ConvertAsJavaBean reg = e.getAnnotation(ConvertAsJavaBean.class);
245.24 - String convElem = instantiableClassOrMethod(e, false);
245.25 + String convElem = instantiableClassOrMethod(e, false, reg);
245.26 File f = layer(e).file("xml/memory/" + convElem.replace('.', '/'));
245.27 f.stringvalue("settings.providerPath", "xml/lookups/NetBeans/DTD_XML_beans_1_0.instance");
245.28 if (reg.subclasses()) {
245.29 @@ -228,12 +229,12 @@
245.30 return f.stringvalue("xmlproperties.ignoreChanges", sb.toString());
245.31 }
245.32
245.33 - private String instantiableClassOrMethod(Element e, boolean checkMethods) throws IllegalArgumentException, LayerGenerationException {
245.34 + private String instantiableClassOrMethod(Element e, boolean checkMethods, Annotation r) throws IllegalArgumentException, LayerGenerationException {
245.35 switch (e.getKind()) {
245.36 case CLASS: {
245.37 String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString();
245.38 if (e.getModifiers().contains(Modifier.ABSTRACT)) {
245.39 - throw new LayerGenerationException(clazz + " must not be abstract", e);
245.40 + throw new LayerGenerationException(clazz + " must not be abstract", e, processingEnv, r);
245.41 }
245.42 {
245.43 boolean hasDefaultCtor = false;
245.44 @@ -244,7 +245,7 @@
245.45 }
245.46 }
245.47 if (!hasDefaultCtor) {
245.48 - throw new LayerGenerationException(clazz + " must have a no-argument constructor", e);
245.49 + throw new LayerGenerationException(clazz + " must have a no-argument constructor", e, processingEnv, r);
245.50 }
245.51 }
245.52 if (checkMethods) {
245.53 @@ -270,16 +271,16 @@
245.54 }
245.55 }
245.56 if (!hasRead) {
245.57 - throw new LayerGenerationException(clazz + " must have proper readProperties method", e);
245.58 + throw new LayerGenerationException(clazz + " must have proper readProperties method", e, processingEnv, r);
245.59 }
245.60 if (!hasWrite) {
245.61 - throw new LayerGenerationException(clazz + " must have proper writeProperties method", e);
245.62 + throw new LayerGenerationException(clazz + " must have proper writeProperties method", e, processingEnv, r);
245.63 }
245.64 }
245.65 return clazz;
245.66 }
245.67 default:
245.68 - throw new LayerGenerationException("Annotated element is not loadable as an instance: " + e);
245.69 + throw new LayerGenerationException("Annotated element is not loadable as an instance", e, processingEnv, r);
245.70 }
245.71 }
245.72 }
246.1 --- a/spi.tasklist/src/org/netbeans/spi/tasklist/Task.java Wed Jul 27 10:33:10 2011 +0200
246.2 +++ b/spi.tasklist/src/org/netbeans/spi/tasklist/Task.java Wed Jul 27 10:35:25 2011 +0200
246.3 @@ -82,7 +82,7 @@
246.4 * Create a new Task
246.5 *
246.6 * @param resource Resource which the Task applies to, cannot be null.
246.7 - * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
246.8 + * @param groupName Name of the group this task belongs to ({@code nb-tasklist-error}, {@code nb-tasklist-warning}, {@code nb-tasklist-todo}, etc).
246.9 * @param description A brief summary of the task (one line if possible), cannot be null.
246.10 *
246.11 * @return New task.
246.12 @@ -103,7 +103,7 @@
246.13 * to be available at all times.</p>
246.14 *
246.15 * @param resource Resource which the Task applies to, cannot be null.
246.16 - * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
246.17 + * @param groupName Name of the group this task belongs to ({@code nb-tasklist-error}, {@code nb-tasklist-warning}, {@code nb-tasklist-todo}, etc).
246.18 * @param description A brief summary of the task (one line if possible), cannot be null.
246.19 * @param defaultAction Task's default action, e.g. double-click or Enter key in the Task List window.
246.20 * @param popupActions Actions to show in task's popup menu.
246.21 @@ -119,7 +119,7 @@
246.22 * Create a new Task
246.23 *
246.24 * @param resource File or folder which the Task applies to, cannot be null.
246.25 - * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
246.26 + * @param groupName Name of the group this task belongs to ({@code nb-tasklist-error}, {@code nb-tasklist-warning}, {@code nb-tasklist-todo}, etc).
246.27 * @param description A brief summary of the task (one line if possible), cannot be null.
246.28 * @param line Line number in a text file, use negative value if line number is not applicable.
246.29 *
246.30 @@ -140,7 +140,7 @@
246.31 * if ActionListener is required to be available at all times.</p>
246.32 *
246.33 * @param resource File or folder which the Task applies to, cannot be null.
246.34 - * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
246.35 + * @param groupName Name of the group this task belongs to ({@code nb-tasklist-error}, {@code nb-tasklist-warning}, {@code nb-tasklist-todo}, etc).
246.36 * @param description A brief summary of the task (one line if possible), cannot be null.
246.37 * @param al Task's default action, e.g. double-click or Enter key in the Task List window.
246.38 *