Lines 253-260
Link Here
|
253 |
/** 'North' or 'South' */ |
253 |
/** 'North' or 'South' */ |
254 |
private String imageAlignment = "North"; // NOI18N |
254 |
private String imageAlignment = "North"; // NOI18N |
255 |
|
255 |
|
256 |
/** Iterator between panels in the wizard */ |
256 |
/** Iterator between panels in the wizard and its settings */ |
257 |
private Iterator panels; |
257 |
private SettingsAndIterator<?> data; |
258 |
|
258 |
|
259 |
/** Change listener that invokes method update state */ |
259 |
/** Change listener that invokes method update state */ |
260 |
private ChangeListener weakChangeListener; |
260 |
private ChangeListener weakChangeListener; |
Lines 267-285
Link Here
|
267 |
// base listener which won't be directly attached, will only wrapped by WeakListener |
267 |
// base listener which won't be directly attached, will only wrapped by WeakListener |
268 |
private Listener baseListener; |
268 |
private Listener baseListener; |
269 |
|
269 |
|
270 |
/** current panel */ |
|
|
271 |
private Panel current; |
272 |
|
273 |
/** settings to be used for the panels */ |
274 |
private Object settings; |
275 |
|
276 |
/** message format to create title of the document */ |
270 |
/** message format to create title of the document */ |
277 |
private MessageFormat titleFormat; |
271 |
private MessageFormat titleFormat; |
278 |
|
272 |
|
279 |
/** hashtable with additional settings that is usually used |
273 |
/** hashtable with additional settings that is usually used |
280 |
* by Panels to store their data |
274 |
* by Panels to store their data |
281 |
*/ |
275 |
*/ |
282 |
private Map properties; |
276 |
private Map<String,Object> properties; |
283 |
ResourceBundle bundle = NbBundle.getBundle(WizardDescriptor.class); |
277 |
ResourceBundle bundle = NbBundle.getBundle(WizardDescriptor.class); |
284 |
|
278 |
|
285 |
/** Request processor that is used for asynchronous jobs (background validation, |
279 |
/** Request processor that is used for asynchronous jobs (background validation, |
Lines 320-338
Link Here
|
320 |
* @param settings the settings to pass to panels, or <code>null</code> |
314 |
* @param settings the settings to pass to panels, or <code>null</code> |
321 |
* @see #WizardDescriptor(WizardDescriptor.Iterator, Object) |
315 |
* @see #WizardDescriptor(WizardDescriptor.Iterator, Object) |
322 |
*/ |
316 |
*/ |
323 |
public WizardDescriptor(Panel[] wizardPanels, Object settings) { |
317 |
public <Data> WizardDescriptor(Panel<Data>[] wizardPanels, Data settings) { |
324 |
this(new ArrayIterator(wizardPanels), settings); |
318 |
this(new SettingsAndIterator<Data>(new ArrayIterator<Data>(wizardPanels), settings)); |
325 |
} |
319 |
} |
326 |
|
320 |
|
327 |
/** Create a new wizard from a fixed list of panels with settings |
321 |
/** Create a new wizard from a fixed list of panels with settings |
328 |
* defaulted to <CODE>this</CODE>. |
322 |
* defaulted to <CODE>this</CODE>. |
329 |
* |
323 |
* |
330 |
* @param wizardPanels the panels to use |
324 |
* @param wizardPanels the panels to use |
331 |
* @see #WizardDescriptor(WizardDescriptor.Iterator, Object) |
325 |
* @see #WizardDescriptor(WizardDescriptor.Iterator, Object) |
332 |
*/ |
326 |
*/ |
333 |
public WizardDescriptor(Panel[] wizardPanels) { |
327 |
public WizardDescriptor(Panel<WizardDescriptor>[] wizardPanels) { |
334 |
// passing CLOSE_PREVENTER which is treated especially |
328 |
this(SettingsAndIterator.create(new ArrayIterator<WizardDescriptor>(wizardPanels))); |
335 |
this(wizardPanels, CLOSE_PREVENTER); |
|
|
336 |
} |
329 |
} |
337 |
|
330 |
|
338 |
/** Create wizard for a sequence of panels, passing some settings to the panels. |
331 |
/** Create wizard for a sequence of panels, passing some settings to the panels. |
Lines 341-369
Link Here
|
341 |
* @see WizardDescriptor.Panel#readSettings |
334 |
* @see WizardDescriptor.Panel#readSettings |
342 |
* @see WizardDescriptor.Panel#storeSettings |
335 |
* @see WizardDescriptor.Panel#storeSettings |
343 |
*/ |
336 |
*/ |
344 |
public WizardDescriptor(Iterator panels, Object settings) { |
337 |
public <Data>WizardDescriptor(Iterator<Data> panels, Data settings) { |
|
|
338 |
this(new SettingsAndIterator<Data>(panels, settings)); |
339 |
} |
340 |
|
341 |
private <Data> WizardDescriptor(SettingsAndIterator<Data> data) { |
345 |
super("", "", true, DEFAULT_OPTION, null, CLOSE_PREVENTER); // NOI18N |
342 |
super("", "", true, DEFAULT_OPTION, null, CLOSE_PREVENTER); // NOI18N |
346 |
|
343 |
|
347 |
this.settings = (settings == CLOSE_PREVENTER) ? this : settings; |
344 |
this.data = data; |
348 |
|
345 |
|
349 |
baseListener = new Listener(); |
346 |
baseListener = new Listener(); |
350 |
|
347 |
|
351 |
try { |
348 |
weakNextButtonListener = WeakListeners.create(ActionListener.class, |
352 |
weakNextButtonListener = (ActionListener) WeakListeners.create( |
349 |
baseListener, nextButton |
353 |
Class.forName("java.awt.event.ActionListener"), baseListener, nextButton |
350 |
); // NOI18N |
354 |
); // NOI18N |
351 |
weakPreviousButtonListener = WeakListeners.create( |
355 |
weakPreviousButtonListener = (ActionListener) WeakListeners.create( |
352 |
ActionListener.class, baseListener, previousButton |
356 |
Class.forName("java.awt.event.ActionListener"), baseListener, previousButton |
353 |
); // NOI18N |
357 |
); // NOI18N |
354 |
weakFinishButtonListener = WeakListeners.create( |
358 |
weakFinishButtonListener = (ActionListener) WeakListeners.create( |
355 |
ActionListener.class, baseListener, finishButton |
359 |
Class.forName("java.awt.event.ActionListener"), baseListener, finishButton |
356 |
); // NOI18N |
360 |
); // NOI18N |
357 |
weakCancelButtonListener = WeakListeners.create( |
361 |
weakCancelButtonListener = (ActionListener) WeakListeners.create( |
358 |
ActionListener.class, baseListener, cancelButton |
362 |
Class.forName("java.awt.event.ActionListener"), baseListener, cancelButton |
359 |
); // NOI18N |
363 |
); // NOI18N |
|
|
364 |
} catch (ClassNotFoundException e) { |
365 |
// cannot happen, java.awt.event.ActionListener listener can always be found |
366 |
} |
367 |
|
360 |
|
368 |
nextButton.addActionListener(weakNextButtonListener); |
361 |
nextButton.addActionListener(weakNextButtonListener); |
369 |
previousButton.addActionListener(weakPreviousButtonListener); |
362 |
previousButton.addActionListener(weakPreviousButtonListener); |
Lines 375-385
Link Here
|
375 |
super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton }); |
368 |
super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton }); |
376 |
super.setClosingOptions(new Object[] { finishOption, cancelButton }); |
369 |
super.setClosingOptions(new Object[] { finishOption, cancelButton }); |
377 |
|
370 |
|
378 |
this.panels = panels; |
|
|
379 |
|
380 |
// attach the change listener to iterator |
371 |
// attach the change listener to iterator |
381 |
weakChangeListener = WeakListeners.change(baseListener, panels); |
372 |
weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this)); |
382 |
panels.addChangeListener(weakChangeListener); |
373 |
data.getIterator(this).addChangeListener(weakChangeListener); |
383 |
|
374 |
|
384 |
callInitialize(); |
375 |
callInitialize(); |
385 |
} |
376 |
} |
Lines 389-397
Link Here
|
389 |
* |
380 |
* |
390 |
* @param panels iterator over all {@link WizardDescriptor.Panel}s that can appear in the wizard |
381 |
* @param panels iterator over all {@link WizardDescriptor.Panel}s that can appear in the wizard |
391 |
*/ |
382 |
*/ |
392 |
public WizardDescriptor(Iterator panels) { |
383 |
public WizardDescriptor(Iterator<WizardDescriptor> panels) { |
393 |
// passing CLOSE_PREVENTER which is treated especially |
384 |
this(SettingsAndIterator.create(panels)); |
394 |
this(panels, CLOSE_PREVENTER); |
|
|
395 |
} |
385 |
} |
396 |
|
386 |
|
397 |
/** Initializes settings. |
387 |
/** Initializes settings. |
Lines 434-448
Link Here
|
434 |
/** Set a different list of panels. |
424 |
/** Set a different list of panels. |
435 |
* Correctly updates the buttons. |
425 |
* Correctly updates the buttons. |
436 |
* @param panels the new list of {@link WizardDescriptor.Panel}s |
426 |
* @param panels the new list of {@link WizardDescriptor.Panel}s |
|
|
427 |
* @deprecated use setPanelsAndSettings if needed. |
437 |
*/ |
428 |
*/ |
|
|
429 |
@Deprecated |
430 |
@SuppressWarnings("unchecked") |
438 |
public final synchronized void setPanels(Iterator panels) { |
431 |
public final synchronized void setPanels(Iterator panels) { |
439 |
if (this.panels != null) { |
432 |
if (data.getIterator(this) != null) { |
440 |
this.panels.removeChangeListener(weakChangeListener); |
433 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
441 |
} |
434 |
} |
442 |
|
435 |
|
443 |
this.panels = panels; |
436 |
data = data.clone(panels); |
444 |
weakChangeListener = WeakListeners.change(baseListener, panels); |
437 |
weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this)); |
445 |
panels.addChangeListener(weakChangeListener); |
438 |
data.getIterator(this).addChangeListener(weakChangeListener); |
|
|
439 |
init = false; |
440 |
|
441 |
updateState(); |
442 |
} |
443 |
|
444 |
/** Set a different list of panels. |
445 |
* Correctly updates the buttons. |
446 |
* @param panels the new list of {@link WizardDescriptor.Panel}s |
447 |
* @param settings the new settings that will be passed to the panels |
448 |
* @since 7.2 |
449 |
*/ |
450 |
public final synchronized <Data> void setPanelsAndSettings(Iterator<Data> panels, Data settings) { |
451 |
if (data.getIterator(this) != null) { |
452 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
453 |
} |
454 |
|
455 |
data = new SettingsAndIterator<Data>(panels, settings); |
456 |
weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this)); |
457 |
data.getIterator(this).addChangeListener(weakChangeListener); |
446 |
init = false; |
458 |
init = false; |
447 |
|
459 |
|
448 |
updateState(); |
460 |
updateState(); |
Lines 474-480
Link Here
|
474 |
/** Converts some options. |
486 |
/** Converts some options. |
475 |
*/ |
487 |
*/ |
476 |
private Object[] convertOptions(Object[] options) { |
488 |
private Object[] convertOptions(Object[] options) { |
477 |
Object[] clonedOptions = (Object[]) options.clone(); |
489 |
Object[] clonedOptions = options.clone(); |
478 |
|
490 |
|
479 |
for (int i = clonedOptions.length - 1; i >= 0; i--) { |
491 |
for (int i = clonedOptions.length - 1; i >= 0; i--) { |
480 |
if (clonedOptions[i] == NEXT_OPTION) { |
492 |
if (clonedOptions[i] == NEXT_OPTION) { |
Lines 576-582
Link Here
|
576 |
|
588 |
|
577 |
synchronized (this) { |
589 |
synchronized (this) { |
578 |
if (properties == null) { |
590 |
if (properties == null) { |
579 |
properties = new HashMap(7); |
591 |
properties = new HashMap<String,Object>(7); |
580 |
} |
592 |
} |
581 |
|
593 |
|
582 |
oldValue = properties.get(name); |
594 |
oldValue = properties.get(name); |
Lines 653-685
Link Here
|
653 |
* </PRE></code> |
665 |
* </PRE></code> |
654 |
*/ |
666 |
*/ |
655 |
protected synchronized void updateState() { |
667 |
protected synchronized void updateState() { |
656 |
Panel p = panels.current(); |
668 |
updateStateOpen(data); |
|
|
669 |
} |
670 |
private <A> void updateStateOpen(SettingsAndIterator<A> data) { |
671 |
Panel<A> p = data.getIterator(this).current(); |
657 |
|
672 |
|
658 |
// listeners on the panel |
673 |
// listeners on the panel |
659 |
if (current != p) { |
674 |
if (data.current != p) { |
660 |
if (current != null) { |
675 |
if (data.current != null) { |
661 |
// remove |
676 |
// remove |
662 |
current.removeChangeListener(weakChangeListener); |
677 |
data.current.removeChangeListener(weakChangeListener); |
663 |
current.storeSettings(settings); |
678 |
data.current.storeSettings(data.getSettings(this)); |
664 |
} |
679 |
} |
665 |
|
680 |
|
666 |
// Hack - obtain current panel again |
681 |
// Hack - obtain current panel again |
667 |
// It's here to allow dynamic change of panels in wizard |
682 |
// It's here to allow dynamic change of panels in wizard |
668 |
// (which can be done in storeSettings method) |
683 |
// (which can be done in storeSettings method) |
669 |
p = panels.current(); |
684 |
p = data.getIterator(this).current(); |
670 |
|
685 |
|
671 |
// add to new, detach old change listener and attach new one |
686 |
// add to new, detach old change listener and attach new one |
672 |
panels.removeChangeListener(weakChangeListener); |
687 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
673 |
weakChangeListener = WeakListeners.change(baseListener, p); |
688 |
weakChangeListener = WeakListeners.change(baseListener, p); |
674 |
panels.addChangeListener(weakChangeListener); |
689 |
data.getIterator(this).addChangeListener(weakChangeListener); |
675 |
p.addChangeListener(weakChangeListener); |
690 |
p.addChangeListener(weakChangeListener); |
676 |
|
691 |
|
677 |
current = p; |
692 |
data.current = p; |
678 |
current.readSettings(settings); |
693 |
p.readSettings(data.getSettings(this)); |
679 |
} |
694 |
} |
680 |
|
695 |
|
681 |
boolean next = panels.hasNext(); |
696 |
boolean next = data.getIterator(this).hasNext(); |
682 |
boolean prev = panels.hasPrevious(); |
697 |
boolean prev = data.getIterator(this).hasPrevious(); |
683 |
boolean valid = p.isValid(); |
698 |
boolean valid = p.isValid(); |
684 |
|
699 |
|
685 |
// AWT sensitive code |
700 |
// AWT sensitive code |
Lines 774-780
Link Here
|
774 |
panelName = ""; // NOI18N |
789 |
panelName = ""; // NOI18N |
775 |
} |
790 |
} |
776 |
|
791 |
|
777 |
Object[] args = { panelName, panels.name() }; |
792 |
Object[] args = { panelName, data.getIterator(this).name() }; |
778 |
MessageFormat mf = getTitleFormat(); |
793 |
MessageFormat mf = getTitleFormat(); |
779 |
|
794 |
|
780 |
if (autoWizardStyle) { |
795 |
if (autoWizardStyle) { |
Lines 792-813
Link Here
|
792 |
|
807 |
|
793 |
// for xtesting usage only |
808 |
// for xtesting usage only |
794 |
boolean isForwardEnabled () { |
809 |
boolean isForwardEnabled () { |
795 |
return panels.current ().isValid () && !validationRuns; |
810 |
return data.getIterator(this).current ().isValid () && !validationRuns; |
796 |
} |
811 |
} |
797 |
|
812 |
|
798 |
private void updateStateInAWT () { |
813 |
private void updateStateInAWT () { |
799 |
Panel p = panels.current (); |
814 |
Panel<?> p = data.getIterator(this).current (); |
800 |
boolean next = panels.hasNext (); |
815 |
boolean next = data.getIterator(this).hasNext (); |
801 |
boolean prev = panels.hasPrevious (); |
816 |
boolean prev = data.getIterator(this).hasPrevious (); |
802 |
boolean valid = p.isValid () && !validationRuns; |
817 |
boolean valid = p.isValid () && !validationRuns; |
803 |
|
818 |
|
804 |
nextButton.setEnabled (next && valid); |
819 |
nextButton.setEnabled (next && valid); |
805 |
previousButton.setEnabled (prev); |
820 |
previousButton.setEnabled (prev); |
806 |
cancelButton.setEnabled (true); |
821 |
cancelButton.setEnabled (true); |
807 |
|
822 |
|
808 |
if (current instanceof FinishablePanel) { |
823 |
if (data.current instanceof FinishablePanel) { |
809 |
// check if isFinishPanel |
824 |
// check if isFinishPanel |
810 |
if (((FinishablePanel)current).isFinishPanel ()) { |
825 |
if (((FinishablePanel)data.current).isFinishPanel ()) { |
811 |
finishButton.setEnabled (valid); |
826 |
finishButton.setEnabled (valid); |
812 |
} else { |
827 |
} else { |
813 |
// XXX What if the last panel is not FinishPanel ??? enable ? |
828 |
// XXX What if the last panel is not FinishPanel ??? enable ? |
Lines 817-823
Link Here
|
817 |
// original way |
832 |
// original way |
818 |
finishButton.setEnabled ( |
833 |
finishButton.setEnabled ( |
819 |
valid && |
834 |
valid && |
820 |
(!next || (current instanceof FinishPanel)) |
835 |
(!next || (data.current instanceof FinishPanel)) |
821 |
); |
836 |
); |
822 |
} |
837 |
} |
823 |
} |
838 |
} |
Lines 877-883
Link Here
|
877 |
* wizard window exceeds screen bounds after resize. |
892 |
* wizard window exceeds screen bounds after resize. |
878 |
*/ |
893 |
*/ |
879 |
private void resizeWizard(Window parentWindow, Dimension prevSize) { |
894 |
private void resizeWizard(Window parentWindow, Dimension prevSize) { |
880 |
Dimension curSize = panels.current().getComponent().getPreferredSize(); |
895 |
Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize(); |
881 |
|
896 |
|
882 |
// only enlarge if needed, don't shrink |
897 |
// only enlarge if needed, don't shrink |
883 |
if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) { |
898 |
if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) { |
Lines 1113-1120
Link Here
|
1113 |
/** Overrides superclass method. Adds reseting of wizard |
1128 |
/** Overrides superclass method. Adds reseting of wizard |
1114 |
* for <code>CLOSED_OPTION</code>. */ |
1129 |
* for <code>CLOSED_OPTION</code>. */ |
1115 |
public void setValue(Object value) { |
1130 |
public void setValue(Object value) { |
|
|
1131 |
setValueOpen(value, data); |
1132 |
} |
1133 |
|
1134 |
private <A> void setValueOpen(Object value, SettingsAndIterator<A> data) { |
1116 |
Object convertedValue = backConvertOption(value); |
1135 |
Object convertedValue = backConvertOption(value); |
1117 |
|
|
|
1118 |
// set new value w/o fire PROP_VALUE change |
1136 |
// set new value w/o fire PROP_VALUE change |
1119 |
Object oldValue = getValue(); |
1137 |
Object oldValue = getValue(); |
1120 |
setValueWithoutPCH(convertedValue); |
1138 |
setValueWithoutPCH(convertedValue); |
Lines 1125-1132
Link Here
|
1125 |
} else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) { |
1143 |
} else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) { |
1126 |
//Bugfix #25820: make sure that storeSettings |
1144 |
//Bugfix #25820: make sure that storeSettings |
1127 |
//is called before propertyChange. |
1145 |
//is called before propertyChange. |
1128 |
if (current != null) { |
1146 |
if (data.current != null) { |
1129 |
current.storeSettings(settings); |
1147 |
data.current.storeSettings(data.getSettings(this)); |
1130 |
} |
1148 |
} |
1131 |
} |
1149 |
} |
1132 |
|
1150 |
|
Lines 1136-1145
Link Here
|
1136 |
|
1154 |
|
1137 |
/** Resets wizard when after closed/cancelled/finished the wizard dialog. */ |
1155 |
/** Resets wizard when after closed/cancelled/finished the wizard dialog. */ |
1138 |
private void resetWizard() { |
1156 |
private void resetWizard() { |
1139 |
if (current != null) { |
1157 |
resetWizardOpen(data); |
1140 |
current.storeSettings(settings); |
1158 |
} |
1141 |
current.removeChangeListener(weakChangeListener); |
1159 |
|
1142 |
current = null; |
1160 |
private <A> void resetWizardOpen(SettingsAndIterator<A> data) { |
|
|
1161 |
if (data.current != null) { |
1162 |
data.current.storeSettings(data.getSettings(this)); |
1163 |
data.current.removeChangeListener(weakChangeListener); |
1164 |
data.current = null; |
1143 |
|
1165 |
|
1144 |
if (wizardPanel != null) { |
1166 |
if (wizardPanel != null) { |
1145 |
wizardPanel.resetPreferredSize(); |
1167 |
wizardPanel.resetPreferredSize(); |
Lines 1149-1155
Link Here
|
1149 |
callUninitialize(); |
1171 |
callUninitialize(); |
1150 |
|
1172 |
|
1151 |
// detach the change listener at the end of wizard |
1173 |
// detach the change listener at the end of wizard |
1152 |
panels.removeChangeListener(weakChangeListener); |
1174 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
1153 |
} |
1175 |
} |
1154 |
|
1176 |
|
1155 |
private int getIntFromBundle(String key) { |
1177 |
private int getIntFromBundle(String key) { |
Lines 1210-1216
Link Here
|
1210 |
} |
1232 |
} |
1211 |
|
1233 |
|
1212 |
// focus source of this problem |
1234 |
// focus source of this problem |
1213 |
final JComponent comp = (JComponent) wve.getSource(); |
1235 |
final JComponent comp = wve.getSource(); |
1214 |
if (comp != null && comp.isFocusable()) { |
1236 |
if (comp != null && comp.isFocusable()) { |
1215 |
comp.requestFocus(); |
1237 |
comp.requestFocus(); |
1216 |
} |
1238 |
} |
Lines 1239-1262
Link Here
|
1239 |
|
1261 |
|
1240 |
// helper methods which call to InstantiatingIterator |
1262 |
// helper methods which call to InstantiatingIterator |
1241 |
private void callInitialize() { |
1263 |
private void callInitialize() { |
1242 |
assert panels != null; |
1264 |
assert data.getIterator(this) != null; |
1243 |
|
1265 |
|
1244 |
if (panels instanceof InstantiatingIterator) { |
1266 |
if (data.getIterator(this) instanceof InstantiatingIterator) { |
1245 |
((InstantiatingIterator) panels).initialize(this); |
1267 |
((InstantiatingIterator) data.getIterator(this)).initialize(this); |
1246 |
} |
1268 |
} |
1247 |
|
1269 |
|
1248 |
newObjects = Collections.EMPTY_SET; |
1270 |
newObjects = Collections.EMPTY_SET; |
1249 |
} |
1271 |
} |
1250 |
|
1272 |
|
1251 |
private void callUninitialize() { |
1273 |
private void callUninitialize() { |
1252 |
assert panels != null; |
1274 |
assert data.getIterator(this) != null; |
1253 |
|
1275 |
|
1254 |
if (panels instanceof InstantiatingIterator) { |
1276 |
if (data.getIterator(this) instanceof InstantiatingIterator) { |
1255 |
((InstantiatingIterator) panels).uninitialize(this); |
1277 |
((InstantiatingIterator) data.getIterator(this)).uninitialize(this); |
1256 |
} |
1278 |
} |
1257 |
} |
1279 |
} |
1258 |
|
1280 |
|
1259 |
private void callInstantiate() throws IOException { |
1281 |
private void callInstantiate() throws IOException { |
|
|
1282 |
callInstantiateOpen(data); |
1283 |
} |
1284 |
|
1285 |
private <A> void callInstantiateOpen(SettingsAndIterator<A> data) throws IOException { |
1286 |
Iterator<A> panels = data.getIterator(this); |
1287 |
|
1260 |
assert panels != null; |
1288 |
assert panels != null; |
1261 |
|
1289 |
|
1262 |
err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator)); |
1290 |
err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator)); |
Lines 1283-1289
Link Here
|
1283 |
} |
1311 |
} |
1284 |
|
1312 |
|
1285 |
// bugfix #44444, force store settings before do instantiate new objects |
1313 |
// bugfix #44444, force store settings before do instantiate new objects |
1286 |
panels.current().storeSettings(settings); |
1314 |
panels.current().storeSettings(data.getSettings(this)); |
1287 |
|
1315 |
|
1288 |
if (panels instanceof InstantiatingIterator) { |
1316 |
if (panels instanceof InstantiatingIterator) { |
1289 |
showWaitCursor(); |
1317 |
showWaitCursor(); |
Lines 1357-1367
Link Here
|
1357 |
/** Iterator on the sequence of panels. |
1385 |
/** Iterator on the sequence of panels. |
1358 |
* @see WizardDescriptor.Panel |
1386 |
* @see WizardDescriptor.Panel |
1359 |
*/ |
1387 |
*/ |
1360 |
public interface Iterator { |
1388 |
public interface Iterator<Data> { |
1361 |
/** Get the current panel. |
1389 |
/** Get the current panel. |
1362 |
* @return the panel |
1390 |
* @return the panel |
1363 |
*/ |
1391 |
*/ |
1364 |
public Panel current(); |
1392 |
public Panel<Data> current(); |
1365 |
|
1393 |
|
1366 |
/** Get the name of the current panel. |
1394 |
/** Get the name of the current panel. |
1367 |
* @return the name |
1395 |
* @return the name |
Lines 1410-1416
Link Here
|
1410 |
* |
1438 |
* |
1411 |
* Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html |
1439 |
* Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html |
1412 |
*/ |
1440 |
*/ |
1413 |
public interface Panel { |
1441 |
public interface Panel<Data> { |
1414 |
/** Get the component displayed in this panel. |
1442 |
/** Get the component displayed in this panel. |
1415 |
* |
1443 |
* |
1416 |
* Note; method can be called from any thread, but not concurrently |
1444 |
* Note; method can be called from any thread, but not concurrently |
Lines 1438-1444
Link Here
|
1438 |
* @exception IllegalStateException if the the data provided |
1466 |
* @exception IllegalStateException if the the data provided |
1439 |
* by the wizard are not valid. |
1467 |
* by the wizard are not valid. |
1440 |
*/ |
1468 |
*/ |
1441 |
public void readSettings(Object settings); |
1469 |
public void readSettings(Data settings); |
1442 |
|
1470 |
|
1443 |
/** Provides the wizard panel with the opportunity to update the |
1471 |
/** Provides the wizard panel with the opportunity to update the |
1444 |
* settings with its current customized state. |
1472 |
* settings with its current customized state. |
Lines 1453-1459
Link Here
|
1453 |
* in fact the <code>TemplateWizard</code>. |
1481 |
* in fact the <code>TemplateWizard</code>. |
1454 |
* @param settings the object representing wizard panel state |
1482 |
* @param settings the object representing wizard panel state |
1455 |
*/ |
1483 |
*/ |
1456 |
public void storeSettings(Object settings); |
1484 |
public void storeSettings(Data settings); |
1457 |
|
1485 |
|
1458 |
/** Test whether the panel is finished and it is safe to proceed to the next one. |
1486 |
/** Test whether the panel is finished and it is safe to proceed to the next one. |
1459 |
* If the panel is valid, the "Next" (or "Finish") button will be enabled. |
1487 |
* If the panel is valid, the "Next" (or "Finish") button will be enabled. |
Lines 1483-1496
Link Here
|
1483 |
* implementing this interface. |
1511 |
* implementing this interface. |
1484 |
* @deprecated 4.28 Use FinishablePanel instead. |
1512 |
* @deprecated 4.28 Use FinishablePanel instead. |
1485 |
*/ |
1513 |
*/ |
1486 |
public interface FinishPanel extends Panel { |
1514 |
@Deprecated |
|
|
1515 |
public interface FinishPanel<Data> extends Panel<Data> { |
1487 |
} |
1516 |
} |
1488 |
|
1517 |
|
1489 |
/** A special interface for panels that need to do additional |
1518 |
/** A special interface for panels that need to do additional |
1490 |
* validation when Next or Finish button is clicked. |
1519 |
* validation when Next or Finish button is clicked. |
1491 |
* @since 4.28 |
1520 |
* @since 4.28 |
1492 |
*/ |
1521 |
*/ |
1493 |
public interface ValidatingPanel extends Panel { |
1522 |
public interface ValidatingPanel<Data> extends Panel<Data> { |
1494 |
/** |
1523 |
/** |
1495 |
* Is called when Next of Finish buttons are clicked and |
1524 |
* Is called when Next of Finish buttons are clicked and |
1496 |
* allows deeper check to find out that panel is in valid |
1525 |
* allows deeper check to find out that panel is in valid |
Lines 1516-1522
Link Here
|
1516 |
* |
1545 |
* |
1517 |
* @since 6.2 (16 May 2005) |
1546 |
* @since 6.2 (16 May 2005) |
1518 |
*/ |
1547 |
*/ |
1519 |
public interface AsynchronousValidatingPanel extends ValidatingPanel { |
1548 |
public interface AsynchronousValidatingPanel<Data> extends ValidatingPanel<Data> { |
1520 |
|
1549 |
|
1521 |
/** |
1550 |
/** |
1522 |
* Called synchronously from UI thread when Next |
1551 |
* Called synchronously from UI thread when Next |
Lines 1540-1546
Link Here
|
1540 |
* Finish button. |
1569 |
* Finish button. |
1541 |
* @since 4.28 |
1570 |
* @since 4.28 |
1542 |
*/ |
1571 |
*/ |
1543 |
public interface FinishablePanel extends Panel { |
1572 |
public interface FinishablePanel<Data> extends Panel<Data> { |
1544 |
/** Specify if this panel would enable Finish button. Finish button is |
1573 |
/** Specify if this panel would enable Finish button. Finish button is |
1545 |
* enabled if and only if isValid() returns true and isFinishPanel() |
1574 |
* enabled if and only if isValid() returns true and isFinishPanel() |
1546 |
* returns true. |
1575 |
* returns true. |
Lines 1558-1564
Link Here
|
1558 |
* in a template's declaration.) |
1587 |
* in a template's declaration.) |
1559 |
* @since org.openide/1 4.33 |
1588 |
* @since org.openide/1 4.33 |
1560 |
*/ |
1589 |
*/ |
1561 |
public interface InstantiatingIterator extends Iterator { |
1590 |
public interface InstantiatingIterator<Data> extends Iterator<Data> { |
1562 |
/** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values. |
1591 |
/** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values. |
1563 |
* |
1592 |
* |
1564 |
* @throws IOException |
1593 |
* @throws IOException |
Lines 1587-1593
Link Here
|
1587 |
* in a template's declaration.) |
1616 |
* in a template's declaration.) |
1588 |
* @since org.openide/1 6.5 |
1617 |
* @since org.openide/1 6.5 |
1589 |
*/ |
1618 |
*/ |
1590 |
public interface AsynchronousInstantiatingIterator extends InstantiatingIterator { |
1619 |
public interface AsynchronousInstantiatingIterator<Data> extends InstantiatingIterator<Data> { |
1591 |
|
1620 |
|
1592 |
/** |
1621 |
/** |
1593 |
* Is called in separate thread when the Finish button |
1622 |
* Is called in separate thread when the Finish button |
Lines 1609-1615
Link Here
|
1609 |
* in a template's declaration.) |
1638 |
* in a template's declaration.) |
1610 |
* @since org.openide.dialogs 7.1 |
1639 |
* @since org.openide.dialogs 7.1 |
1611 |
*/ |
1640 |
*/ |
1612 |
public interface ProgressInstantiatingIterator extends AsynchronousInstantiatingIterator { |
1641 |
public interface ProgressInstantiatingIterator<Data> extends AsynchronousInstantiatingIterator<Data> { |
1613 |
|
1642 |
|
1614 |
/** |
1643 |
/** |
1615 |
* Is called in separate thread when the Finish button |
1644 |
* Is called in separate thread when the Finish button |
Lines 1629-1638
Link Here
|
1629 |
|
1658 |
|
1630 |
/** Special iterator that works on an array of <code>Panel</code>s. |
1659 |
/** Special iterator that works on an array of <code>Panel</code>s. |
1631 |
*/ |
1660 |
*/ |
1632 |
public static class ArrayIterator extends Object implements Iterator { |
1661 |
public static class ArrayIterator<Data> extends Object implements Iterator<Data> { |
1633 |
/** Array of items. |
1662 |
/** Array of items. |
1634 |
*/ |
1663 |
*/ |
1635 |
private Panel[] panels; |
1664 |
private Panel<Data>[] panels; |
1636 |
|
1665 |
|
1637 |
/** Index into the array |
1666 |
/** Index into the array |
1638 |
*/ |
1667 |
*/ |
Lines 1649-1655
Link Here
|
1649 |
/** Construct an iterator. |
1678 |
/** Construct an iterator. |
1650 |
* @param array the list of panels to use |
1679 |
* @param array the list of panels to use |
1651 |
*/ |
1680 |
*/ |
1652 |
public ArrayIterator(Panel[] array) { |
1681 |
public ArrayIterator(Panel<Data>[] array) { |
1653 |
panels = array; |
1682 |
panels = array; |
1654 |
index = 0; |
1683 |
index = 0; |
1655 |
} |
1684 |
} |
Lines 1658-1670
Link Here
|
1658 |
* constructed using default constructor. |
1687 |
* constructed using default constructor. |
1659 |
* (for example during deserialization. |
1688 |
* (for example during deserialization. |
1660 |
* Default implementation returns empty array. */ |
1689 |
* Default implementation returns empty array. */ |
1661 |
protected Panel[] initializePanels() { |
1690 |
@SuppressWarnings("unchecked") |
|
|
1691 |
protected Panel<Data>[] initializePanels() { |
1662 |
return new Panel[0]; |
1692 |
return new Panel[0]; |
1663 |
} |
1693 |
} |
1664 |
|
1694 |
|
1665 |
/* The current panel. |
1695 |
/* The current panel. |
1666 |
*/ |
1696 |
*/ |
1667 |
public Panel current() { |
1697 |
public Panel<Data> current() { |
1668 |
return panels[index]; |
1698 |
return panels[index]; |
1669 |
} |
1699 |
} |
1670 |
|
1700 |
|
Lines 1742-1747
Link Here
|
1742 |
|
1772 |
|
1743 |
/** Action listener */ |
1773 |
/** Action listener */ |
1744 |
public void actionPerformed(ActionEvent ev) { |
1774 |
public void actionPerformed(ActionEvent ev) { |
|
|
1775 |
final Iterator<?> panels = data.getIterator(WizardDescriptor.this); |
1745 |
if (wizardPanel != null) { |
1776 |
if (wizardPanel != null) { |
1746 |
wizardPanel.setErrorMessage(" ", null); //NOI18N |
1777 |
wizardPanel.setErrorMessage(" ", null); //NOI18N |
1747 |
} |
1778 |
} |
Lines 2546-2551
Link Here
|
2546 |
|
2577 |
|
2547 |
/** Overriden to delegate call to user component. |
2578 |
/** Overriden to delegate call to user component. |
2548 |
*/ |
2579 |
*/ |
|
|
2580 |
@Deprecated |
2549 |
public boolean requestDefaultFocus() { |
2581 |
public boolean requestDefaultFocus() { |
2550 |
if (rightComponent instanceof JComponent) { |
2582 |
if (rightComponent instanceof JComponent) { |
2551 |
return ((JComponent) rightComponent).requestDefaultFocus(); |
2583 |
return ((JComponent) rightComponent).requestDefaultFocus(); |
Lines 2633-2638
Link Here
|
2633 |
assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon."; |
2665 |
assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon."; |
2634 |
preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height); |
2666 |
preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height); |
2635 |
return preferredSize; |
2667 |
return preferredSize; |
|
|
2668 |
} |
2669 |
} |
2670 |
|
2671 |
private static final class SettingsAndIterator<Data> { |
2672 |
private final Iterator<Data> panels; |
2673 |
private final Data settings; |
2674 |
private final boolean useThis; |
2675 |
/** current panel */ |
2676 |
private Panel<Data> current; |
2677 |
|
2678 |
|
2679 |
public SettingsAndIterator(Iterator<Data> iterator, Data settings) { |
2680 |
this(iterator, settings, false); |
2681 |
} |
2682 |
public SettingsAndIterator(Iterator<Data> iterator, Data settings, boolean useThis) { |
2683 |
this.panels = iterator; |
2684 |
this.settings = settings; |
2685 |
this.useThis = useThis; |
2686 |
} |
2687 |
public static SettingsAndIterator<WizardDescriptor> create(Iterator<WizardDescriptor> iterator) { |
2688 |
return new SettingsAndIterator<WizardDescriptor>(iterator, null, true); |
2689 |
} |
2690 |
|
2691 |
public Iterator<Data> getIterator(WizardDescriptor caller) { |
2692 |
return panels; |
2693 |
} |
2694 |
|
2695 |
@SuppressWarnings("unchecked") |
2696 |
public Data getSettings(WizardDescriptor caller) { |
2697 |
return useThis ? (Data)caller : settings; |
2698 |
} |
2699 |
|
2700 |
public SettingsAndIterator<Data> clone(Iterator<Data> it) { |
2701 |
SettingsAndIterator<Data> s = new SettingsAndIterator<Data>(it, settings, useThis); |
2702 |
return s; |
2636 |
} |
2703 |
} |
2637 |
} |
2704 |
} |
2638 |
} |
2705 |
} |