This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 46195
Collapse All | Expand All

(-)src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java (-10 / +59 lines)
Lines 16-21 Link Here
16
import java.awt.Component;
16
import java.awt.Component;
17
import java.awt.ContainerOrderFocusTraversalPolicy;
17
import java.awt.ContainerOrderFocusTraversalPolicy;
18
import java.awt.FocusTraversalPolicy;
18
import java.awt.FocusTraversalPolicy;
19
import java.awt.GridBagConstraints;
19
import java.awt.event.ActionEvent;
20
import java.awt.event.ActionEvent;
20
import java.awt.event.ActionListener;
21
import java.awt.event.ActionListener;
21
import java.beans.PropertyChangeEvent;
22
import java.beans.PropertyChangeEvent;
Lines 56-62 Link Here
56
import org.openide.nodes.Children;
57
import org.openide.nodes.Children;
57
import org.openide.nodes.FilterNode;
58
import org.openide.nodes.FilterNode;
58
import org.openide.nodes.Node;
59
import org.openide.nodes.Node;
60
import org.openide.util.AsyncGUIJob;
59
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
62
import org.openide.util.Utilities;
60
63
61
/** If you are looking for the non-GUI part of the panel please look
64
/** If you are looking for the non-GUI part of the panel please look
62
 * into new file wizard
65
 * into new file wizard
Lines 79-98 Link Here
79
    //GUI Builder
82
    //GUI Builder
80
    private TemplatesPanelGUI.Builder builder;
83
    private TemplatesPanelGUI.Builder builder;
81
    
84
    
85
    private Project project;
86
    
82
    public TemplateChooserPanelGUI(Project p /* , String[] recommendedTypes */ ) {
87
    public TemplateChooserPanelGUI(Project p /* , String[] recommendedTypes */ ) {
83
        this.builder = new FileChooserBuilder ();
84
        initComponents();
88
        initComponents();
85
        final TemplatesPanelGUI tempPanel = (TemplatesPanelGUI)this.templatesPanel;
89
        project = p;
86
        ((TemplatesPanelGUI)this.templatesPanel).setTemplatesFolder (Repository.getDefault().getDefaultFileSystem().findResource("Templates"));  //NOI18N
87
        // select first category
88
        SwingUtilities.invokeLater (new Runnable () {
89
            public void run () {
90
                tempPanel.setSelectedCategoryByName (null);
91
            }
92
        });
93
        initValues( p );        
94
        setPreferredSize( PREF_DIM );
90
        setPreferredSize( PREF_DIM );
95
        setName (org.openide.util.NbBundle.getMessage(TemplateChooserPanelGUI.class, "LBL_TemplateChooserPanelGUI_Name")); // NOI18N
91
        setName (org.openide.util.NbBundle.getMessage(TemplateChooserPanelGUI.class, "LBL_TemplateChooserPanelGUI_Name")); // NOI18N
92
        Utilities.attachInitJob (this, new InitJobImpl ());
96
        projectsComboBox.setRenderer( PROJECT_CELL_RENDERER );                
93
        projectsComboBox.setRenderer( PROJECT_CELL_RENDERER );                
97
     }
94
     }
98
    
95
    
Lines 137-142 Link Here
137
    }
134
    }
138
    
135
    
139
    public FileObject getTemplate() {
136
    public FileObject getTemplate() {
137
        if ((TemplatesPanelGUI)this.templatesPanel == null) {
138
            return null;
139
        }
140
        
140
        return ((TemplatesPanelGUI)this.templatesPanel).getSelectedTemplate ();
141
        return ((TemplatesPanelGUI)this.templatesPanel).getSelectedTemplate ();
141
    }
142
    }
142
    
143
    
Lines 150-159 Link Here
150
    }
151
    }
151
    
152
    
152
    private String getCategory () {
153
    private String getCategory () {
154
        if ((TemplatesPanelGUI)this.templatesPanel == null) {
155
            return null;
156
        }
153
        return ((TemplatesPanelGUI)this.templatesPanel).getSelectedCategoryName ();
157
        return ((TemplatesPanelGUI)this.templatesPanel).getSelectedCategoryName ();
154
    }
158
    }
155
159
156
    public void setCategory (String category) {
160
    public void setCategory (String category) {
161
        if ((TemplatesPanelGUI)this.templatesPanel == null) {
162
            System.out.println("Wrong !!!!");
163
        }
157
        ((TemplatesPanelGUI)this.templatesPanel).setSelectedCategoryByName (category);
164
        ((TemplatesPanelGUI)this.templatesPanel).setSelectedCategoryByName (category);
158
    }
165
    }
159
    
166
    
Lines 434-437 Link Here
434
        
441
        
435
    }
442
    }
436
    
443
    
444
    // implementation of AsyncGUIJob
445
    private final class InitJobImpl implements AsyncGUIJob {
446
447
        public void construct () {
448
            System.out.println("start construct");
449
            builder = new FileChooserBuilder ();
450
//            System.out.println("sleeping");
451
//            try {
452
//                Thread.sleep (10000);
453
//            } catch (Exception x) {
454
//                x.printStackTrace();
455
//            }
456
//            System.out.println("wake up");
457
        }
458
459
        public void finished () {
460
            System.out.println("is finished");
461
            
462
            initValues (project);
463
            
464
            remove (templatesPanel);
465
            
466
            templatesPanel = new TemplatesPanelGUI (builder);
467
            
468
            final TemplatesPanelGUI tempPanel = (TemplatesPanelGUI)templatesPanel;
469
            ((TemplatesPanelGUI)templatesPanel).setTemplatesFolder (Repository.getDefault().getDefaultFileSystem().findResource("Templates"));  //NOI18N
470
            // select first category
471
            SwingUtilities.invokeLater (new Runnable () {
472
                public void run () {
473
                    tempPanel.setSelectedCategoryByName (null);
474
                }
475
            });
476
477
            GridBagConstraints gridBagConstraints = new GridBagConstraints ();
478
            gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
479
            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
480
            gridBagConstraints.weightx = 1.0;
481
            gridBagConstraints.weighty = 1.0;
482
            add(templatesPanel, gridBagConstraints);
483
        }
484
    }
485
437
}
486
}
(-)src/org/netbeans/modules/project/ui/TemplatesPanelGUI.java (-1 / +14 lines)
Lines 72-87 Link Here
72
    public static final String TEMPLATES_FOLDER = "templatesFolder";        //NOI18N
72
    public static final String TEMPLATES_FOLDER = "templatesFolder";        //NOI18N
73
    public static final String TARGET_TEMPLATE = "targetTemplate";          //NOI18N
73
    public static final String TARGET_TEMPLATE = "targetTemplate";          //NOI18N
74
    private static final String ATTR_INSTANTIATING_DESC = "instantiatingWizardURL"; //NOI18N
74
    private static final String ATTR_INSTANTIATING_DESC = "instantiatingWizardURL"; //NOI18N
75
    private boolean isInitialized = false;
75
    
76
    
76
    private Builder firer;
77
    private Builder firer;
77
    
78
    
78
    /** Creates new form TemplatesPanelGUI */
79
    /** Creates new form TemplatesPanelGUI */
79
    public TemplatesPanelGUI (Builder firer) {
80
    public TemplatesPanelGUI (Builder firer) {
81
        if (firer == null) {
82
            isInitialized = false;
83
            return ;
84
        }
80
        assert firer != null : "Builder can not be null";  //NOI18N
85
        assert firer != null : "Builder can not be null";  //NOI18N
81
        this.firer = firer;
86
        this.firer = firer;
87
        isInitialized = true;
82
        initComponents();
88
        initComponents();
83
        postInitComponents ();
89
        postInitComponents ();
84
        setName (NbBundle.getMessage(TemplatesPanelGUI.class,"TXT_SelectTemplate"));
90
        setName (NbBundle.getMessage(TemplatesPanelGUI.class, "TXT_SelectTemplate")); // NOI18N
85
    }
91
    }
86
92
87
93
Lines 126-131 Link Here
126
    }
132
    }
127
    
133
    
128
    public FileObject getSelectedTemplate () {
134
    public FileObject getSelectedTemplate () {
135
        if (!isInitialized) {
136
            return null;
137
        }
129
        Node[] nodes = (Node[]) ((ExplorerProviderPanel)this.projectsPanel).getSelectedNodes();
138
        Node[] nodes = (Node[]) ((ExplorerProviderPanel)this.projectsPanel).getSelectedNodes();
130
        if (nodes != null && nodes.length == 1) {
139
        if (nodes != null && nodes.length == 1) {
131
            DataObject dobj = (DataObject) nodes[0].getCookie (DataObject.class);
140
            DataObject dobj = (DataObject) nodes[0].getCookie (DataObject.class);
Lines 198-203 Link Here
198
207
199
    public void addNotify() {
208
    public void addNotify() {
200
        super.addNotify();
209
        super.addNotify();
210
        
211
        if (!isInitialized) {
212
            return ;
213
        }
201
        
214
        
202
        if (description.getEditorKit() instanceof HTMLEditorKit) {
215
        if (description.getEditorKit() instanceof HTMLEditorKit) {
203
            // override the Swing default CSS to make the HTMLEditorKit use the
216
            // override the Swing default CSS to make the HTMLEditorKit use the

Return to bug 46195