Index: src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java =================================================================== RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java,v --- src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java 2 Jul 2004 10:18:00 -0000 1.23 +++ src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java 20 Jul 2004 15:51:29 -0000 @@ -16,6 +16,7 @@ import java.awt.Component; import java.awt.ContainerOrderFocusTraversalPolicy; import java.awt.FocusTraversalPolicy; +import java.awt.GridBagConstraints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -56,7 +57,9 @@ import org.openide.nodes.Children; import org.openide.nodes.FilterNode; import org.openide.nodes.Node; +import org.openide.util.AsyncGUIJob; import org.openide.util.NbBundle; +import org.openide.util.Utilities; /** If you are looking for the non-GUI part of the panel please look * into new file wizard @@ -79,20 +82,14 @@ //GUI Builder private TemplatesPanelGUI.Builder builder; + private Project project; + public TemplateChooserPanelGUI(Project p /* , String[] recommendedTypes */ ) { - this.builder = new FileChooserBuilder (); initComponents(); - final TemplatesPanelGUI tempPanel = (TemplatesPanelGUI)this.templatesPanel; - ((TemplatesPanelGUI)this.templatesPanel).setTemplatesFolder (Repository.getDefault().getDefaultFileSystem().findResource("Templates")); //NOI18N - // select first category - SwingUtilities.invokeLater (new Runnable () { - public void run () { - tempPanel.setSelectedCategoryByName (null); - } - }); - initValues( p ); + project = p; setPreferredSize( PREF_DIM ); setName (org.openide.util.NbBundle.getMessage(TemplateChooserPanelGUI.class, "LBL_TemplateChooserPanelGUI_Name")); // NOI18N + Utilities.attachInitJob (this, new InitJobImpl ()); projectsComboBox.setRenderer( PROJECT_CELL_RENDERER ); } @@ -137,6 +134,10 @@ } public FileObject getTemplate() { + if ((TemplatesPanelGUI)this.templatesPanel == null) { + return null; + } + return ((TemplatesPanelGUI)this.templatesPanel).getSelectedTemplate (); } @@ -150,10 +151,16 @@ } private String getCategory () { + if ((TemplatesPanelGUI)this.templatesPanel == null) { + return null; + } return ((TemplatesPanelGUI)this.templatesPanel).getSelectedCategoryName (); } public void setCategory (String category) { + if ((TemplatesPanelGUI)this.templatesPanel == null) { + System.out.println("Wrong !!!!"); + } ((TemplatesPanelGUI)this.templatesPanel).setSelectedCategoryByName (category); } @@ -434,4 +441,46 @@ } + // implementation of AsyncGUIJob + private final class InitJobImpl implements AsyncGUIJob { + + public void construct () { + System.out.println("start construct"); + builder = new FileChooserBuilder (); +// System.out.println("sleeping"); +// try { +// Thread.sleep (10000); +// } catch (Exception x) { +// x.printStackTrace(); +// } +// System.out.println("wake up"); + } + + public void finished () { + System.out.println("is finished"); + + initValues (project); + + remove (templatesPanel); + + templatesPanel = new TemplatesPanelGUI (builder); + + final TemplatesPanelGUI tempPanel = (TemplatesPanelGUI)templatesPanel; + ((TemplatesPanelGUI)templatesPanel).setTemplatesFolder (Repository.getDefault().getDefaultFileSystem().findResource("Templates")); //NOI18N + // select first category + SwingUtilities.invokeLater (new Runnable () { + public void run () { + tempPanel.setSelectedCategoryByName (null); + } + }); + + GridBagConstraints gridBagConstraints = new GridBagConstraints (); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(templatesPanel, gridBagConstraints); + } + } + } Index: src/org/netbeans/modules/project/ui/TemplatesPanelGUI.java =================================================================== RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/TemplatesPanelGUI.java,v --- src/org/netbeans/modules/project/ui/TemplatesPanelGUI.java 1 Jul 2004 15:26:18 -0000 1.22 +++ src/org/netbeans/modules/project/ui/TemplatesPanelGUI.java 20 Jul 2004 15:51:29 -0000 @@ -72,16 +72,22 @@ public static final String TEMPLATES_FOLDER = "templatesFolder"; //NOI18N public static final String TARGET_TEMPLATE = "targetTemplate"; //NOI18N private static final String ATTR_INSTANTIATING_DESC = "instantiatingWizardURL"; //NOI18N + private boolean isInitialized = false; private Builder firer; /** Creates new form TemplatesPanelGUI */ public TemplatesPanelGUI (Builder firer) { + if (firer == null) { + isInitialized = false; + return ; + } assert firer != null : "Builder can not be null"; //NOI18N this.firer = firer; + isInitialized = true; initComponents(); postInitComponents (); - setName (NbBundle.getMessage(TemplatesPanelGUI.class,"TXT_SelectTemplate")); + setName (NbBundle.getMessage(TemplatesPanelGUI.class, "TXT_SelectTemplate")); // NOI18N } @@ -126,6 +132,9 @@ } public FileObject getSelectedTemplate () { + if (!isInitialized) { + return null; + } Node[] nodes = (Node[]) ((ExplorerProviderPanel)this.projectsPanel).getSelectedNodes(); if (nodes != null && nodes.length == 1) { DataObject dobj = (DataObject) nodes[0].getCookie (DataObject.class); @@ -198,6 +207,10 @@ public void addNotify() { super.addNotify(); + + if (!isInitialized) { + return ; + } if (description.getEditorKit() instanceof HTMLEditorKit) { // override the Swing default CSS to make the HTMLEditorKit use the