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 |
} |