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-278
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 |
|
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-350
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 |
|
Lines 371-381
Link Here
|
371 |
super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton }); |
368 |
super.setOptions(new Object[] { previousButton, nextButton, finishButton, cancelButton }); |
372 |
super.setClosingOptions(new Object[] { finishOption, cancelButton }); |
369 |
super.setClosingOptions(new Object[] { finishOption, cancelButton }); |
373 |
|
370 |
|
374 |
this.panels = panels; |
|
|
375 |
|
376 |
// attach the change listener to iterator |
371 |
// attach the change listener to iterator |
377 |
weakChangeListener = WeakListeners.change(baseListener, panels); |
372 |
weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this)); |
378 |
panels.addChangeListener(weakChangeListener); |
373 |
data.getIterator(this).addChangeListener(weakChangeListener); |
379 |
|
374 |
|
380 |
callInitialize(); |
375 |
callInitialize(); |
381 |
} |
376 |
} |
Lines 385-393
Link Here
|
385 |
* |
380 |
* |
386 |
* @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 |
387 |
*/ |
382 |
*/ |
388 |
public WizardDescriptor(Iterator panels) { |
383 |
public WizardDescriptor(Iterator<WizardDescriptor> panels) { |
389 |
// passing CLOSE_PREVENTER which is treated especially |
384 |
this(SettingsAndIterator.create(panels)); |
390 |
this(panels, CLOSE_PREVENTER); |
|
|
391 |
} |
385 |
} |
392 |
|
386 |
|
393 |
/** Initializes settings. |
387 |
/** Initializes settings. |
Lines 431-444
Link Here
|
431 |
* Correctly updates the buttons. |
425 |
* Correctly updates the buttons. |
432 |
* @param panels the new list of {@link WizardDescriptor.Panel}s |
426 |
* @param panels the new list of {@link WizardDescriptor.Panel}s |
433 |
*/ |
427 |
*/ |
|
|
428 |
@SuppressWarnings("unchecked") |
434 |
public final synchronized void setPanels(Iterator panels) { |
429 |
public final synchronized void setPanels(Iterator panels) { |
435 |
if (this.panels != null) { |
430 |
if (data.getIterator(this) != null) { |
436 |
this.panels.removeChangeListener(weakChangeListener); |
431 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
437 |
} |
432 |
} |
438 |
|
433 |
|
439 |
this.panels = panels; |
434 |
data = data.clone(panels); |
440 |
weakChangeListener = WeakListeners.change(baseListener, panels); |
435 |
weakChangeListener = WeakListeners.change(baseListener, data.getIterator(this)); |
441 |
panels.addChangeListener(weakChangeListener); |
436 |
data.getIterator(this).addChangeListener(weakChangeListener); |
442 |
init = false; |
437 |
init = false; |
443 |
|
438 |
|
444 |
updateState(); |
439 |
updateState(); |
Lines 657-689
Link Here
|
657 |
* </PRE></code> |
652 |
* </PRE></code> |
658 |
*/ |
653 |
*/ |
659 |
protected synchronized void updateState() { |
654 |
protected synchronized void updateState() { |
660 |
Panel p = panels.current(); |
655 |
updateStateOpen(data); |
|
|
656 |
} |
657 |
private <A> void updateStateOpen(SettingsAndIterator<A> data) { |
658 |
Panel<A> p = data.getIterator(this).current(); |
661 |
|
659 |
|
662 |
// listeners on the panel |
660 |
// listeners on the panel |
663 |
if (current != p) { |
661 |
if (data.current != p) { |
664 |
if (current != null) { |
662 |
if (data.current != null) { |
665 |
// remove |
663 |
// remove |
666 |
current.removeChangeListener(weakChangeListener); |
664 |
data.current.removeChangeListener(weakChangeListener); |
667 |
current.storeSettings(settings); |
665 |
data.current.storeSettings(data.getSettings(this)); |
668 |
} |
666 |
} |
669 |
|
667 |
|
670 |
// Hack - obtain current panel again |
668 |
// Hack - obtain current panel again |
671 |
// It's here to allow dynamic change of panels in wizard |
669 |
// It's here to allow dynamic change of panels in wizard |
672 |
// (which can be done in storeSettings method) |
670 |
// (which can be done in storeSettings method) |
673 |
p = panels.current(); |
671 |
p = data.getIterator(this).current(); |
674 |
|
672 |
|
675 |
// add to new, detach old change listener and attach new one |
673 |
// add to new, detach old change listener and attach new one |
676 |
panels.removeChangeListener(weakChangeListener); |
674 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
677 |
weakChangeListener = WeakListeners.change(baseListener, p); |
675 |
weakChangeListener = WeakListeners.change(baseListener, p); |
678 |
panels.addChangeListener(weakChangeListener); |
676 |
data.getIterator(this).addChangeListener(weakChangeListener); |
679 |
p.addChangeListener(weakChangeListener); |
677 |
p.addChangeListener(weakChangeListener); |
680 |
|
678 |
|
681 |
current = p; |
679 |
data.current = p; |
682 |
current.readSettings(settings); |
680 |
p.readSettings(data.getSettings(this)); |
683 |
} |
681 |
} |
684 |
|
682 |
|
685 |
boolean next = panels.hasNext(); |
683 |
boolean next = data.getIterator(this).hasNext(); |
686 |
boolean prev = panels.hasPrevious(); |
684 |
boolean prev = data.getIterator(this).hasPrevious(); |
687 |
boolean valid = p.isValid(); |
685 |
boolean valid = p.isValid(); |
688 |
|
686 |
|
689 |
// AWT sensitive code |
687 |
// AWT sensitive code |
Lines 778-784
Link Here
|
778 |
panelName = ""; // NOI18N |
776 |
panelName = ""; // NOI18N |
779 |
} |
777 |
} |
780 |
|
778 |
|
781 |
Object[] args = { panelName, panels.name() }; |
779 |
Object[] args = { panelName, data.getIterator(this).name() }; |
782 |
MessageFormat mf = getTitleFormat(); |
780 |
MessageFormat mf = getTitleFormat(); |
783 |
|
781 |
|
784 |
if (autoWizardStyle) { |
782 |
if (autoWizardStyle) { |
Lines 796-817
Link Here
|
796 |
|
794 |
|
797 |
// for xtesting usage only |
795 |
// for xtesting usage only |
798 |
boolean isForwardEnabled () { |
796 |
boolean isForwardEnabled () { |
799 |
return panels.current ().isValid () && !validationRuns; |
797 |
return data.getIterator(this).current ().isValid () && !validationRuns; |
800 |
} |
798 |
} |
801 |
|
799 |
|
802 |
private void updateStateInAWT () { |
800 |
private void updateStateInAWT () { |
803 |
Panel p = panels.current (); |
801 |
Panel<?> p = data.getIterator(this).current (); |
804 |
boolean next = panels.hasNext (); |
802 |
boolean next = data.getIterator(this).hasNext (); |
805 |
boolean prev = panels.hasPrevious (); |
803 |
boolean prev = data.getIterator(this).hasPrevious (); |
806 |
boolean valid = p.isValid () && !validationRuns; |
804 |
boolean valid = p.isValid () && !validationRuns; |
807 |
|
805 |
|
808 |
nextButton.setEnabled (next && valid); |
806 |
nextButton.setEnabled (next && valid); |
809 |
previousButton.setEnabled (prev); |
807 |
previousButton.setEnabled (prev); |
810 |
cancelButton.setEnabled (true); |
808 |
cancelButton.setEnabled (true); |
811 |
|
809 |
|
812 |
if (current instanceof FinishablePanel) { |
810 |
if (data.current instanceof FinishablePanel) { |
813 |
// check if isFinishPanel |
811 |
// check if isFinishPanel |
814 |
if (((FinishablePanel)current).isFinishPanel ()) { |
812 |
if (((FinishablePanel)data.current).isFinishPanel ()) { |
815 |
finishButton.setEnabled (valid); |
813 |
finishButton.setEnabled (valid); |
816 |
} else { |
814 |
} else { |
817 |
// XXX What if the last panel is not FinishPanel ??? enable ? |
815 |
// XXX What if the last panel is not FinishPanel ??? enable ? |
Lines 821-827
Link Here
|
821 |
// original way |
819 |
// original way |
822 |
finishButton.setEnabled ( |
820 |
finishButton.setEnabled ( |
823 |
valid && |
821 |
valid && |
824 |
(!next || (current instanceof FinishPanel)) |
822 |
(!next || (data.current instanceof FinishPanel)) |
825 |
); |
823 |
); |
826 |
} |
824 |
} |
827 |
} |
825 |
} |
Lines 881-887
Link Here
|
881 |
* wizard window exceeds screen bounds after resize. |
879 |
* wizard window exceeds screen bounds after resize. |
882 |
*/ |
880 |
*/ |
883 |
private void resizeWizard(Window parentWindow, Dimension prevSize) { |
881 |
private void resizeWizard(Window parentWindow, Dimension prevSize) { |
884 |
Dimension curSize = panels.current().getComponent().getPreferredSize(); |
882 |
Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize(); |
885 |
|
883 |
|
886 |
// only enlarge if needed, don't shrink |
884 |
// only enlarge if needed, don't shrink |
887 |
if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) { |
885 |
if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) { |
Lines 1117-1124
Link Here
|
1117 |
/** Overrides superclass method. Adds reseting of wizard |
1115 |
/** Overrides superclass method. Adds reseting of wizard |
1118 |
* for <code>CLOSED_OPTION</code>. */ |
1116 |
* for <code>CLOSED_OPTION</code>. */ |
1119 |
public void setValue(Object value) { |
1117 |
public void setValue(Object value) { |
|
|
1118 |
setValueOpen(value, data); |
1119 |
} |
1120 |
|
1121 |
private <A> void setValueOpen(Object value, SettingsAndIterator<A> data) { |
1120 |
Object convertedValue = backConvertOption(value); |
1122 |
Object convertedValue = backConvertOption(value); |
1121 |
|
|
|
1122 |
// set new value w/o fire PROP_VALUE change |
1123 |
// set new value w/o fire PROP_VALUE change |
1123 |
Object oldValue = getValue(); |
1124 |
Object oldValue = getValue(); |
1124 |
setValueWithoutPCH(convertedValue); |
1125 |
setValueWithoutPCH(convertedValue); |
Lines 1129-1136
Link Here
|
1129 |
} else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) { |
1130 |
} else if (FINISH_OPTION.equals(convertedValue) || NEXT_OPTION.equals(convertedValue)) { |
1130 |
//Bugfix #25820: make sure that storeSettings |
1131 |
//Bugfix #25820: make sure that storeSettings |
1131 |
//is called before propertyChange. |
1132 |
//is called before propertyChange. |
1132 |
if (current != null) { |
1133 |
if (data.current != null) { |
1133 |
current.storeSettings(settings); |
1134 |
data.current.storeSettings(data.getSettings(this)); |
1134 |
} |
1135 |
} |
1135 |
} |
1136 |
} |
1136 |
|
1137 |
|
Lines 1140-1149
Link Here
|
1140 |
|
1141 |
|
1141 |
/** Resets wizard when after closed/cancelled/finished the wizard dialog. */ |
1142 |
/** Resets wizard when after closed/cancelled/finished the wizard dialog. */ |
1142 |
private void resetWizard() { |
1143 |
private void resetWizard() { |
1143 |
if (current != null) { |
1144 |
resetWizardOpen(data); |
1144 |
current.storeSettings(settings); |
1145 |
} |
1145 |
current.removeChangeListener(weakChangeListener); |
1146 |
|
1146 |
current = null; |
1147 |
private <A> void resetWizardOpen(SettingsAndIterator<A> data) { |
|
|
1148 |
if (data.current != null) { |
1149 |
data.current.storeSettings(data.getSettings(this)); |
1150 |
data.current.removeChangeListener(weakChangeListener); |
1151 |
data.current = null; |
1147 |
|
1152 |
|
1148 |
if (wizardPanel != null) { |
1153 |
if (wizardPanel != null) { |
1149 |
wizardPanel.resetPreferredSize(); |
1154 |
wizardPanel.resetPreferredSize(); |
Lines 1153-1159
Link Here
|
1153 |
callUninitialize(); |
1158 |
callUninitialize(); |
1154 |
|
1159 |
|
1155 |
// detach the change listener at the end of wizard |
1160 |
// detach the change listener at the end of wizard |
1156 |
panels.removeChangeListener(weakChangeListener); |
1161 |
data.getIterator(this).removeChangeListener(weakChangeListener); |
1157 |
} |
1162 |
} |
1158 |
|
1163 |
|
1159 |
private int getIntFromBundle(String key) { |
1164 |
private int getIntFromBundle(String key) { |
Lines 1243-1266
Link Here
|
1243 |
|
1248 |
|
1244 |
// helper methods which call to InstantiatingIterator |
1249 |
// helper methods which call to InstantiatingIterator |
1245 |
private void callInitialize() { |
1250 |
private void callInitialize() { |
1246 |
assert panels != null; |
1251 |
assert data.getIterator(this) != null; |
1247 |
|
1252 |
|
1248 |
if (panels instanceof InstantiatingIterator) { |
1253 |
if (data.getIterator(this) instanceof InstantiatingIterator) { |
1249 |
((InstantiatingIterator) panels).initialize(this); |
1254 |
((InstantiatingIterator) data.getIterator(this)).initialize(this); |
1250 |
} |
1255 |
} |
1251 |
|
1256 |
|
1252 |
newObjects = Collections.EMPTY_SET; |
1257 |
newObjects = Collections.EMPTY_SET; |
1253 |
} |
1258 |
} |
1254 |
|
1259 |
|
1255 |
private void callUninitialize() { |
1260 |
private void callUninitialize() { |
1256 |
assert panels != null; |
1261 |
assert data.getIterator(this) != null; |
1257 |
|
1262 |
|
1258 |
if (panels instanceof InstantiatingIterator) { |
1263 |
if (data.getIterator(this) instanceof InstantiatingIterator) { |
1259 |
((InstantiatingIterator) panels).uninitialize(this); |
1264 |
((InstantiatingIterator) data.getIterator(this)).uninitialize(this); |
1260 |
} |
1265 |
} |
1261 |
} |
1266 |
} |
1262 |
|
1267 |
|
1263 |
private void callInstantiate() throws IOException { |
1268 |
private void callInstantiate() throws IOException { |
|
|
1269 |
callInstantiateOpen(data); |
1270 |
} |
1271 |
|
1272 |
private <A> void callInstantiateOpen(SettingsAndIterator<A> data) throws IOException { |
1273 |
Iterator<A> panels = data.getIterator(this); |
1274 |
|
1264 |
assert panels != null; |
1275 |
assert panels != null; |
1265 |
|
1276 |
|
1266 |
err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator)); |
1277 |
err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator)); |
Lines 1287-1293
Link Here
|
1287 |
} |
1298 |
} |
1288 |
|
1299 |
|
1289 |
// bugfix #44444, force store settings before do instantiate new objects |
1300 |
// bugfix #44444, force store settings before do instantiate new objects |
1290 |
panels.current().storeSettings(settings); |
1301 |
panels.current().storeSettings(data.getSettings(this)); |
1291 |
|
1302 |
|
1292 |
if (panels instanceof InstantiatingIterator) { |
1303 |
if (panels instanceof InstantiatingIterator) { |
1293 |
showWaitCursor(); |
1304 |
showWaitCursor(); |
Lines 1361-1371
Link Here
|
1361 |
/** Iterator on the sequence of panels. |
1372 |
/** Iterator on the sequence of panels. |
1362 |
* @see WizardDescriptor.Panel |
1373 |
* @see WizardDescriptor.Panel |
1363 |
*/ |
1374 |
*/ |
1364 |
public interface Iterator { |
1375 |
public interface Iterator<Data> { |
1365 |
/** Get the current panel. |
1376 |
/** Get the current panel. |
1366 |
* @return the panel |
1377 |
* @return the panel |
1367 |
*/ |
1378 |
*/ |
1368 |
public Panel current(); |
1379 |
public Panel<Data> current(); |
1369 |
|
1380 |
|
1370 |
/** Get the name of the current panel. |
1381 |
/** Get the name of the current panel. |
1371 |
* @return the name |
1382 |
* @return the name |
Lines 1414-1420
Link Here
|
1414 |
* |
1425 |
* |
1415 |
* Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html |
1426 |
* Please see complete guide at http://performance.netbeans.org/howto/dialogs/wizard-panels.html |
1416 |
*/ |
1427 |
*/ |
1417 |
public interface Panel { |
1428 |
public interface Panel<Data> { |
1418 |
/** Get the component displayed in this panel. |
1429 |
/** Get the component displayed in this panel. |
1419 |
* |
1430 |
* |
1420 |
* Note; method can be called from any thread, but not concurrently |
1431 |
* Note; method can be called from any thread, but not concurrently |
Lines 1442-1448
Link Here
|
1442 |
* @exception IllegalStateException if the the data provided |
1453 |
* @exception IllegalStateException if the the data provided |
1443 |
* by the wizard are not valid. |
1454 |
* by the wizard are not valid. |
1444 |
*/ |
1455 |
*/ |
1445 |
public void readSettings(Object settings); |
1456 |
public void readSettings(Data settings); |
1446 |
|
1457 |
|
1447 |
/** Provides the wizard panel with the opportunity to update the |
1458 |
/** Provides the wizard panel with the opportunity to update the |
1448 |
* settings with its current customized state. |
1459 |
* settings with its current customized state. |
Lines 1457-1463
Link Here
|
1457 |
* in fact the <code>TemplateWizard</code>. |
1468 |
* in fact the <code>TemplateWizard</code>. |
1458 |
* @param settings the object representing wizard panel state |
1469 |
* @param settings the object representing wizard panel state |
1459 |
*/ |
1470 |
*/ |
1460 |
public void storeSettings(Object settings); |
1471 |
public void storeSettings(Data settings); |
1461 |
|
1472 |
|
1462 |
/** Test whether the panel is finished and it is safe to proceed to the next one. |
1473 |
/** Test whether the panel is finished and it is safe to proceed to the next one. |
1463 |
* If the panel is valid, the "Next" (or "Finish") button will be enabled. |
1474 |
* If the panel is valid, the "Next" (or "Finish") button will be enabled. |
Lines 1487-1500
Link Here
|
1487 |
* implementing this interface. |
1498 |
* implementing this interface. |
1488 |
* @deprecated 4.28 Use FinishablePanel instead. |
1499 |
* @deprecated 4.28 Use FinishablePanel instead. |
1489 |
*/ |
1500 |
*/ |
1490 |
public interface FinishPanel extends Panel { |
1501 |
public interface FinishPanel<Data> extends Panel<Data> { |
1491 |
} |
1502 |
} |
1492 |
|
1503 |
|
1493 |
/** A special interface for panels that need to do additional |
1504 |
/** A special interface for panels that need to do additional |
1494 |
* validation when Next or Finish button is clicked. |
1505 |
* validation when Next or Finish button is clicked. |
1495 |
* @since 4.28 |
1506 |
* @since 4.28 |
1496 |
*/ |
1507 |
*/ |
1497 |
public interface ValidatingPanel extends Panel { |
1508 |
public interface ValidatingPanel<Data> extends Panel<Data> { |
1498 |
/** |
1509 |
/** |
1499 |
* Is called when Next of Finish buttons are clicked and |
1510 |
* Is called when Next of Finish buttons are clicked and |
1500 |
* allows deeper check to find out that panel is in valid |
1511 |
* allows deeper check to find out that panel is in valid |
Lines 1520-1526
Link Here
|
1520 |
* |
1531 |
* |
1521 |
* @since 6.2 (16 May 2005) |
1532 |
* @since 6.2 (16 May 2005) |
1522 |
*/ |
1533 |
*/ |
1523 |
public interface AsynchronousValidatingPanel extends ValidatingPanel { |
1534 |
public interface AsynchronousValidatingPanel<Data> extends ValidatingPanel<Data> { |
1524 |
|
1535 |
|
1525 |
/** |
1536 |
/** |
1526 |
* Called synchronously from UI thread when Next |
1537 |
* Called synchronously from UI thread when Next |
Lines 1544-1550
Link Here
|
1544 |
* Finish button. |
1555 |
* Finish button. |
1545 |
* @since 4.28 |
1556 |
* @since 4.28 |
1546 |
*/ |
1557 |
*/ |
1547 |
public interface FinishablePanel extends Panel { |
1558 |
public interface FinishablePanel<Data> extends Panel<Data> { |
1548 |
/** Specify if this panel would enable Finish button. Finish button is |
1559 |
/** Specify if this panel would enable Finish button. Finish button is |
1549 |
* enabled if and only if isValid() returns true and isFinishPanel() |
1560 |
* enabled if and only if isValid() returns true and isFinishPanel() |
1550 |
* returns true. |
1561 |
* returns true. |
Lines 1562-1568
Link Here
|
1562 |
* in a template's declaration.) |
1573 |
* in a template's declaration.) |
1563 |
* @since org.openide/1 4.33 |
1574 |
* @since org.openide/1 4.33 |
1564 |
*/ |
1575 |
*/ |
1565 |
public interface InstantiatingIterator extends Iterator { |
1576 |
public interface InstantiatingIterator<Data> extends Iterator<Data> { |
1566 |
/** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values. |
1577 |
/** Returns set of instantiated objects. If instantiation fails then wizard remains open to enable correct values. |
1567 |
* |
1578 |
* |
1568 |
* @throws IOException |
1579 |
* @throws IOException |
Lines 1591-1597
Link Here
|
1591 |
* in a template's declaration.) |
1602 |
* in a template's declaration.) |
1592 |
* @since org.openide/1 6.5 |
1603 |
* @since org.openide/1 6.5 |
1593 |
*/ |
1604 |
*/ |
1594 |
public interface AsynchronousInstantiatingIterator extends InstantiatingIterator { |
1605 |
public interface AsynchronousInstantiatingIterator<Data> extends InstantiatingIterator<Data> { |
1595 |
|
1606 |
|
1596 |
/** |
1607 |
/** |
1597 |
* Is called in separate thread when the Finish button |
1608 |
* Is called in separate thread when the Finish button |
Lines 1613-1619
Link Here
|
1613 |
* in a template's declaration.) |
1624 |
* in a template's declaration.) |
1614 |
* @since org.openide.dialogs 7.1 |
1625 |
* @since org.openide.dialogs 7.1 |
1615 |
*/ |
1626 |
*/ |
1616 |
public interface ProgressInstantiatingIterator extends AsynchronousInstantiatingIterator { |
1627 |
public interface ProgressInstantiatingIterator<Data> extends AsynchronousInstantiatingIterator<Data> { |
1617 |
|
1628 |
|
1618 |
/** |
1629 |
/** |
1619 |
* Is called in separate thread when the Finish button |
1630 |
* Is called in separate thread when the Finish button |
Lines 1633-1642
Link Here
|
1633 |
|
1644 |
|
1634 |
/** Special iterator that works on an array of <code>Panel</code>s. |
1645 |
/** Special iterator that works on an array of <code>Panel</code>s. |
1635 |
*/ |
1646 |
*/ |
1636 |
public static class ArrayIterator extends Object implements Iterator { |
1647 |
public static class ArrayIterator<Data> extends Object implements Iterator<Data> { |
1637 |
/** Array of items. |
1648 |
/** Array of items. |
1638 |
*/ |
1649 |
*/ |
1639 |
private Panel[] panels; |
1650 |
private Panel<Data>[] panels; |
1640 |
|
1651 |
|
1641 |
/** Index into the array |
1652 |
/** Index into the array |
1642 |
*/ |
1653 |
*/ |
Lines 1653-1659
Link Here
|
1653 |
/** Construct an iterator. |
1664 |
/** Construct an iterator. |
1654 |
* @param array the list of panels to use |
1665 |
* @param array the list of panels to use |
1655 |
*/ |
1666 |
*/ |
1656 |
public ArrayIterator(Panel[] array) { |
1667 |
public ArrayIterator(Panel<Data>[] array) { |
1657 |
panels = array; |
1668 |
panels = array; |
1658 |
index = 0; |
1669 |
index = 0; |
1659 |
} |
1670 |
} |
Lines 1662-1674
Link Here
|
1662 |
* constructed using default constructor. |
1673 |
* constructed using default constructor. |
1663 |
* (for example during deserialization. |
1674 |
* (for example during deserialization. |
1664 |
* Default implementation returns empty array. */ |
1675 |
* Default implementation returns empty array. */ |
1665 |
protected Panel[] initializePanels() { |
1676 |
@SuppressWarnings("unchecked") |
|
|
1677 |
protected Panel<Data>[] initializePanels() { |
1666 |
return new Panel[0]; |
1678 |
return new Panel[0]; |
1667 |
} |
1679 |
} |
1668 |
|
1680 |
|
1669 |
/* The current panel. |
1681 |
/* The current panel. |
1670 |
*/ |
1682 |
*/ |
1671 |
public Panel current() { |
1683 |
public Panel<Data> current() { |
1672 |
return panels[index]; |
1684 |
return panels[index]; |
1673 |
} |
1685 |
} |
1674 |
|
1686 |
|
Lines 1746-1751
Link Here
|
1746 |
|
1758 |
|
1747 |
/** Action listener */ |
1759 |
/** Action listener */ |
1748 |
public void actionPerformed(ActionEvent ev) { |
1760 |
public void actionPerformed(ActionEvent ev) { |
|
|
1761 |
final Iterator<?> panels = data.getIterator(WizardDescriptor.this); |
1749 |
if (wizardPanel != null) { |
1762 |
if (wizardPanel != null) { |
1750 |
wizardPanel.setErrorMessage(" ", null); //NOI18N |
1763 |
wizardPanel.setErrorMessage(" ", null); //NOI18N |
1751 |
} |
1764 |
} |
Lines 2638-2643
Link Here
|
2638 |
assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon."; |
2651 |
assert ESTIMATED_HEIGHT == Utilities.loadImage ("org/netbeans/modules/dialogs/warning.gif").getHeight (null) : "Use only 16px icon."; |
2639 |
preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height); |
2652 |
preferredSize.height = Math.max (ESTIMATED_HEIGHT, preferredSize.height); |
2640 |
return preferredSize; |
2653 |
return preferredSize; |
|
|
2654 |
} |
2655 |
} |
2656 |
|
2657 |
private static final class SettingsAndIterator<Data> { |
2658 |
private final Iterator<Data> panels; |
2659 |
private final Data settings; |
2660 |
private final boolean useThis; |
2661 |
/** current panel */ |
2662 |
private Panel<Data> current; |
2663 |
|
2664 |
|
2665 |
public SettingsAndIterator(Iterator<Data> iterator, Data settings) { |
2666 |
this(iterator, settings, false); |
2667 |
} |
2668 |
public SettingsAndIterator(Iterator<Data> iterator, Data settings, boolean useThis) { |
2669 |
this.panels = iterator; |
2670 |
this.settings = settings; |
2671 |
this.useThis = useThis; |
2672 |
} |
2673 |
public static SettingsAndIterator<WizardDescriptor> create(Iterator<WizardDescriptor> iterator) { |
2674 |
return new SettingsAndIterator<WizardDescriptor>(iterator, null, true); |
2675 |
} |
2676 |
|
2677 |
public Iterator<Data> getIterator(WizardDescriptor caller) { |
2678 |
return panels; |
2679 |
} |
2680 |
|
2681 |
@SuppressWarnings("unchecked") |
2682 |
public Data getSettings(WizardDescriptor caller) { |
2683 |
return useThis ? (Data)caller : settings; |
2684 |
} |
2685 |
|
2686 |
public SettingsAndIterator<Data> clone(Iterator<Data> it) { |
2687 |
SettingsAndIterator<Data> s = new SettingsAndIterator<Data>(it, settings, useThis); |
2688 |
return s; |
2641 |
} |
2689 |
} |
2642 |
} |
2690 |
} |
2643 |
} |
2691 |
} |