? project86405.patch Index: apichanges.xml =================================================================== RCS file: /cvs/projects/projectuiapi/apichanges.xml,v retrieving revision 1.25 diff -u -r1.25 apichanges.xml --- apichanges.xml 5 Oct 2006 09:21:26 -0000 1.25 +++ apichanges.xml 16 Oct 2006 07:13:00 -0000 @@ -81,6 +81,24 @@ + + + Ability to attach a ok button listener on single customizer category. + + + + + + + Allow to attach a listener to ProjectCustomizer.Category that will notify the Category + and it's panel that the changes ought to be applied. This is generally useful as a fallback, general + solution for 3rd party plugging into the project customizer in case the given project type doesn't provide + model-driven project updating mechanism. + + + + + Added LookupMerger implementations for PrivilegedTemplates and RecommendedTemplates Index: nbproject/project.properties =================================================================== RCS file: /cvs/projects/projectuiapi/nbproject/project.properties,v retrieving revision 1.27 diff -u -r1.27 project.properties --- nbproject/project.properties 5 Oct 2006 11:26:30 -0000 1.27 +++ nbproject/project.properties 16 Oct 2006 07:13:00 -0000 @@ -17,7 +17,7 @@ javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.5 -spec.version.base=1.19.0 +spec.version.base=1.20.0 is.autoload=true javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml Index: src/org/netbeans/modules/project/uiapi/CustomizerDialog.java =================================================================== RCS file: /cvs/projects/projectuiapi/src/org/netbeans/modules/project/uiapi/CustomizerDialog.java,v retrieving revision 1.8 diff -u -r1.8 CustomizerDialog.java --- src/org/netbeans/modules/project/uiapi/CustomizerDialog.java 15 Sep 2006 18:30:41 -0000 1.8 +++ src/org/netbeans/modules/project/uiapi/CustomizerDialog.java 16 Oct 2006 07:13:00 -0000 @@ -79,7 +79,7 @@ // RegisterListener - ActionListener optionsListener = new OptionListener( okOptionListener ); + ActionListener optionsListener = new OptionListener( okOptionListener, categories ); options[ OPTION_OK ].addActionListener( optionsListener ); options[ OPTION_CANCEL ].addActionListener( optionsListener ); @@ -148,19 +148,33 @@ private static class OptionListener implements ActionListener { private ActionListener okOptionListener; + private ProjectCustomizer.Category[] categories; - OptionListener( ActionListener okOptionListener ) { + OptionListener( ActionListener okOptionListener, ProjectCustomizer.Category[] categs) { this.okOptionListener = okOptionListener; + categories = categs; } - + public void actionPerformed( ActionEvent e ) { String command = e.getActionCommand(); - + if ( COMMAND_OK.equals( command ) ) { // Call the OK option listener okOptionListener.actionPerformed( e ); // XXX maybe create new event + actionPerformed(e, categories); + } + } + + private void actionPerformed(ActionEvent e, ProjectCustomizer.Category[] categs) { + for (int i = 0; i < categs.length; i++) { + ActionListener list = categs[i].getOkButtonListener(); + if (list != null) { + actionPerformed(e);// XXX maybe create new event + } + if (categs[i].getSubcategories() != null) { + actionPerformed(e, categs[i].getSubcategories()); + } } - } } Index: src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java =================================================================== RCS file: /cvs/projects/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java,v retrieving revision 1.9 diff -u -r1.9 ProjectCustomizer.java --- src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java 15 Sep 2006 18:30:42 -0000 1.9 +++ src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java 16 Oct 2006 07:13:00 -0000 @@ -21,6 +21,7 @@ import java.awt.Dialog; import java.awt.Image; +import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.ArrayList; @@ -194,6 +195,9 @@ * Interface for creation of Customizer categories and their respective UI panels. * Implementations are to be registered in System FileSystem via module layers. Used by the * {@link org.netbeans.spi.project.ui.support.ProjectCustomizer#createCustomizerDialog(String,Lookup,String,ActionListener,HelpCtx)} + * The panel/category created by the provider can get notified that the customizer got + * closed by setting an ActionListener to + * {@link org.netbeans.spi.project.ui.support.ProjectCustomizer.Category#setOkButtonListener} . * @since org.netbeans.modules.projectuiapi/1 1.15 */ public static interface CompositeCategoryProvider { @@ -209,6 +213,9 @@ /** * create the UI component for given category and context. + * The panel/category created by the provider can get notified that the customizer got + * closed by setting an ActionListener to + * {@link org.netbeans.spi.project.ui.support.ProjectCustomizer.Category#setOkButtonListener}. * @param category Category instance that was created in the createCategory method. * @param context Lookup instance passed from project The content is up to the project type, please consult documentation * for the project type you want to integrate your panel into. @@ -226,6 +233,7 @@ private Category[] subcategories; private boolean valid; private String errorMessage; + private ActionListener okListener; /** Private constructor. See the factory method. */ @@ -255,7 +263,6 @@ return new Category( name, displayName, icon, subcategories ); } - // Public methods ------------------------------------------------------ /** Gets programmatic name of given category. @@ -334,6 +341,26 @@ Utilities.getCategoryChangeSupport(this).firePropertyChange( CategoryChangeSupport.ERROR_MESSAGE_PROPERTY, oldMessage, message); } + } + + /** + * set the action listener that will get notified when the changes in the customizer + * are to be applied. + * @param okButtonListener ActionListener to notify + * @since org.netbeans.modules.projectuiapi/1 1.20 + */ + public void setOkButtonListener(ActionListener okButtonListener) { + okListener = okButtonListener; + } + + /** + * returns the action listener associated wth this category that gets notified + * when ok button is pressed on the customizer. + * @returns instance of ActionListener or null if not set. + * @since org.netbeans.modules.projectuiapi/1 1.20 + */ + public ActionListener getOkButtonListener() { + return okListener; } }