Lines 38-44
Link Here
|
38 |
import org.netbeans.spi.project.ui.CustomizerProvider; |
38 |
import org.netbeans.spi.project.ui.CustomizerProvider; |
39 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
39 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
40 |
import org.openide.util.HelpCtx; |
40 |
import org.openide.util.HelpCtx; |
|
|
41 |
import org.openide.util.Lookup; |
41 |
import org.openide.util.NbBundle; |
42 |
import org.openide.util.NbBundle; |
|
|
43 |
import org.openide.util.lookup.Lookups; |
42 |
|
44 |
|
43 |
|
45 |
|
44 |
/** Customization of J2SE project |
46 |
/** Customization of J2SE project |
Lines 63-68
Link Here
|
63 |
// Option command names |
65 |
// Option command names |
64 |
private static final String COMMAND_OK = "OK"; // NOI18N |
66 |
private static final String COMMAND_OK = "OK"; // NOI18N |
65 |
private static final String COMMAND_CANCEL = "CANCEL"; // NOI18N |
67 |
private static final String COMMAND_CANCEL = "CANCEL"; // NOI18N |
|
|
68 |
|
69 |
public static final String CUSTOMIZER_FOLDER_PATH = "J2SEProject/Customizer"; //NO18N |
66 |
|
70 |
|
67 |
private static Map /*<Project,Dialog>*/project2Dialog = new HashMap(); |
71 |
private static Map /*<Project,Dialog>*/project2Dialog = new HashMap(); |
68 |
|
72 |
|
Lines 87-267
Link Here
|
87 |
|
91 |
|
88 |
Dialog dialog = (Dialog)project2Dialog.get (project); |
92 |
Dialog dialog = (Dialog)project2Dialog.get (project); |
89 |
if ( dialog != null ) { |
93 |
if ( dialog != null ) { |
90 |
dialog.show (); |
94 |
dialog.setVisible(true); |
91 |
return; |
95 |
return; |
92 |
} |
96 |
} |
93 |
else { |
97 |
else { |
94 |
J2SEProjectProperties uiProperties = new J2SEProjectProperties( (J2SEProject)project, updateHelper, evaluator, refHelper, genFileHelper ); |
98 |
J2SEProjectProperties uiProperties = new J2SEProjectProperties( (J2SEProject)project, updateHelper, evaluator, refHelper, genFileHelper ); |
95 |
init( uiProperties ); |
99 |
Lookup context = Lookups.fixed(new Object[] { |
|
|
100 |
project, |
101 |
uiProperties, |
102 |
new SubCategoryProvider(preselectedCategory, preselectedSubCategory) |
103 |
}); |
96 |
|
104 |
|
97 |
OptionListener listener = new OptionListener( project, uiProperties ); |
105 |
OptionListener listener = new OptionListener( project, uiProperties ); |
98 |
// HelpCtx helpCtx = new HelpCtx( "org.netbeans.modules.java.j2seproject.ui.customizer.J2SECustomizer" ); |
106 |
dialog = ProjectCustomizer.createCustomizerDialog( CUSTOMIZER_FOLDER_PATH, context, preselectedCategory, listener, null ); |
99 |
if (preselectedCategory != null && preselectedSubCategory != null) { |
|
|
100 |
for (int i=0; i<categories.length; i++ ) { |
101 |
if (preselectedCategory.equals(categories[i].getName())) { |
102 |
JComponent component = panelProvider.create (categories[i]); |
103 |
if (component instanceof SubCategoryProvider) { |
104 |
((SubCategoryProvider)component).showSubCategory(preselectedSubCategory); |
105 |
} |
106 |
break; |
107 |
} |
108 |
} |
109 |
} |
110 |
dialog = ProjectCustomizer.createCustomizerDialog( categories, panelProvider, preselectedCategory, listener, null ); |
111 |
dialog.addWindowListener( listener ); |
107 |
dialog.addWindowListener( listener ); |
112 |
dialog.setTitle( MessageFormat.format( |
108 |
dialog.setTitle( MessageFormat.format( |
113 |
NbBundle.getMessage( CustomizerProviderImpl.class, "LBL_Customizer_Title" ), // NOI18N |
109 |
NbBundle.getMessage( CustomizerProviderImpl.class, "LBL_Customizer_Title" ), // NOI18N |
114 |
new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) ); |
110 |
new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) ); |
115 |
|
111 |
|
116 |
project2Dialog.put(project, dialog); |
112 |
project2Dialog.put(project, dialog); |
117 |
dialog.show(); |
113 |
dialog.setVisible(true); |
118 |
} |
114 |
} |
119 |
} |
115 |
} |
120 |
|
116 |
|
121 |
// Names of categories |
|
|
122 |
private static final String BUILD_CATEGORY = "BuildCategory"; |
123 |
private static final String RUN_CATEGORY = "RunCategory"; |
124 |
|
125 |
private static final String GENERAL = "General"; |
126 |
private static final String SOURCES = "Sources"; |
127 |
private static final String LIBRARIES = "Libraries"; |
128 |
|
129 |
private static final String BUILD = "Build"; |
130 |
private static final String BUILD_TESTS = "BuildTests"; |
131 |
private static final String JAR = "Jar"; |
132 |
private static final String JAVADOC = "Javadoc"; |
133 |
private static final String RUN = "Run"; |
134 |
private static final String RUN_TESTS = "RunTests"; |
135 |
|
136 |
private static final String WEBSERVICECLIENTS = "WebServiceClients"; |
137 |
private static final String WEBSERVICE_CATEGORY = "WebServiceCategory"; |
138 |
|
139 |
private void init( J2SEProjectProperties uiProperties ) { |
140 |
|
141 |
ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); |
142 |
|
143 |
/* |
144 |
ProjectCustomizer.Category general = ProjectCustomizer.Category.create( |
145 |
BUILD, |
146 |
bundle.getString( "LBL_Config_Build" ), |
147 |
null, |
148 |
null ); |
149 |
*/ |
150 |
|
151 |
|
152 |
ProjectCustomizer.Category sources = ProjectCustomizer.Category.create( |
153 |
SOURCES, |
154 |
bundle.getString ("LBL_Config_Sources"), |
155 |
null, |
156 |
null); |
157 |
|
158 |
ProjectCustomizer.Category libraries = ProjectCustomizer.Category.create ( |
159 |
LIBRARIES, |
160 |
bundle.getString( "LBL_Config_Libraries" ), // NOI18N |
161 |
null, |
162 |
null ); |
163 |
|
164 |
ProjectCustomizer.Category build = ProjectCustomizer.Category.create( |
165 |
BUILD, |
166 |
bundle.getString( "LBL_Config_Build" ), // NOI18N |
167 |
null, |
168 |
null); |
169 |
ProjectCustomizer.Category jar = ProjectCustomizer.Category.create( |
170 |
JAR, |
171 |
bundle.getString( "LBL_Config_Jar" ), // NOI18N |
172 |
null, |
173 |
null ); |
174 |
ProjectCustomizer.Category javadoc = ProjectCustomizer.Category.create( |
175 |
JAVADOC, |
176 |
bundle.getString( "LBL_Config_Javadoc" ), // NOI18N |
177 |
null, |
178 |
null ); |
179 |
|
180 |
ProjectCustomizer.Category run = ProjectCustomizer.Category.create( |
181 |
RUN, |
182 |
bundle.getString( "LBL_Config_Run" ), // NOI18N |
183 |
null, |
184 |
null ); |
185 |
ProjectCustomizer.Category runTests = ProjectCustomizer.Category.create( |
186 |
RUN_TESTS, |
187 |
bundle.getString( "LBL_Config_Test" ), // NOI18N |
188 |
null, |
189 |
null); |
190 |
|
191 |
ProjectCustomizer.Category buildCategory = ProjectCustomizer.Category.create( |
192 |
BUILD_CATEGORY, |
193 |
bundle.getString( "LBL_Config_BuildCategory" ), // NOI18N |
194 |
null, |
195 |
new ProjectCustomizer.Category[] { build, jar, javadoc } ); |
196 |
|
197 |
ProjectCustomizer.Category clients = ProjectCustomizer.Category.create( |
198 |
WEBSERVICECLIENTS, |
199 |
bundle.getString( "LBL_Config_WebServiceClients" ), // NOI18N |
200 |
null, |
201 |
null); |
202 |
|
203 |
ProjectCustomizer.Category webServices = ProjectCustomizer.Category.create( |
204 |
WEBSERVICE_CATEGORY, |
205 |
bundle.getString( "LBL_Config_WebServices" ), // NOI18N |
206 |
null, |
207 |
new ProjectCustomizer.Category[] { clients } ); |
208 |
|
209 |
categories = new ProjectCustomizer.Category[] { |
210 |
sources, |
211 |
libraries, |
212 |
buildCategory, |
213 |
run, |
214 |
webServices |
215 |
}; |
216 |
|
217 |
List serviceClientsSettings = null; |
218 |
WebServicesClientSupport clientSupport = WebServicesClientSupport.getWebServicesClientSupport(project.getProjectDirectory()); |
219 |
if (clientSupport != null) { |
220 |
serviceClientsSettings = clientSupport.getServiceClients(); |
221 |
} |
222 |
|
223 |
categories = new ProjectCustomizer.Category[] { |
224 |
sources, |
225 |
libraries, |
226 |
buildCategory, |
227 |
run, |
228 |
webServices |
229 |
}; |
230 |
|
231 |
Map panels = new HashMap(); |
232 |
panels.put( sources, new CustomizerSources( uiProperties ) ); |
233 |
panels.put( libraries, new CustomizerLibraries( uiProperties ) ); |
234 |
panels.put( build, new CustomizerCompile( uiProperties ) ); |
235 |
panels.put( jar, new CustomizerJar( uiProperties ) ); |
236 |
panels.put( javadoc, new CustomizerJavadoc( uiProperties ) ); |
237 |
panels.put( run, new CustomizerRun( uiProperties ) ); |
238 |
|
239 |
if(serviceClientsSettings != null && serviceClientsSettings.size() > 0) { |
240 |
panels.put( clients, new CustomizerWSClientHost( uiProperties, serviceClientsSettings )); |
241 |
} else { |
242 |
panels.put( clients, new NoWebServiceClientsPanel()); |
243 |
} |
244 |
panelProvider = new PanelProvider( panels ); |
245 |
|
246 |
} |
247 |
|
248 |
private static class PanelProvider implements ProjectCustomizer.CategoryComponentProvider { |
249 |
|
250 |
private JPanel EMPTY_PANEL = new JPanel(); |
251 |
|
252 |
private Map /*<Category,JPanel>*/ panels; |
253 |
|
254 |
PanelProvider( Map panels ) { |
255 |
this.panels = panels; |
256 |
} |
257 |
|
258 |
public JComponent create( ProjectCustomizer.Category category ) { |
259 |
JComponent panel = (JComponent)panels.get( category ); |
260 |
return panel == null ? EMPTY_PANEL : panel; |
261 |
} |
262 |
|
263 |
} |
264 |
|
265 |
/** Listens to the actions on the Customizer's option buttons */ |
117 |
/** Listens to the actions on the Customizer's option buttons */ |
266 |
private class OptionListener extends WindowAdapter implements ActionListener { |
118 |
private class OptionListener extends WindowAdapter implements ActionListener { |
267 |
|
119 |
|
Lines 282-288
Link Here
|
282 |
// Close & dispose the the dialog |
134 |
// Close & dispose the the dialog |
283 |
Dialog dialog = (Dialog)project2Dialog.get( project ); |
135 |
Dialog dialog = (Dialog)project2Dialog.get( project ); |
284 |
if ( dialog != null ) { |
136 |
if ( dialog != null ) { |
285 |
dialog.hide(); |
137 |
dialog.setVisible(false); |
286 |
dialog.dispose(); |
138 |
dialog.dispose(); |
287 |
} |
139 |
} |
288 |
} |
140 |
} |
Lines 298-311
Link Here
|
298 |
//may not be called |
150 |
//may not be called |
299 |
Dialog dialog = (Dialog)project2Dialog.get( project ); |
151 |
Dialog dialog = (Dialog)project2Dialog.get( project ); |
300 |
if ( dialog != null ) { |
152 |
if ( dialog != null ) { |
301 |
dialog.hide (); |
153 |
dialog.setVisible(false); |
302 |
dialog.dispose(); |
154 |
dialog.dispose(); |
303 |
} |
155 |
} |
304 |
} |
156 |
} |
305 |
} |
157 |
} |
306 |
|
158 |
|
307 |
static interface SubCategoryProvider { |
159 |
static final class SubCategoryProvider { |
308 |
public void showSubCategory (String name); |
160 |
|
|
|
161 |
private String subcategory; |
162 |
|
163 |
private String category; |
164 |
|
165 |
SubCategoryProvider(String category, String subcategory) { |
166 |
this.category = category; |
167 |
this.subcategory = subcategory; |
168 |
} |
169 |
public String getCategory() { |
170 |
return category; |
171 |
} |
172 |
public String getSubcategory() { |
173 |
return subcategory; |
174 |
} |
309 |
} |
175 |
} |
310 |
|
176 |
|
311 |
|
177 |
|