Lines 20-25
Link Here
|
20 |
package org.apache.tools.ant.module.wizards.shortcut; |
20 |
package org.apache.tools.ant.module.wizards.shortcut; |
21 |
|
21 |
|
22 |
import java.awt.Component; |
22 |
import java.awt.Component; |
|
|
23 |
import java.util.ArrayList; |
24 |
import java.util.List; |
23 |
import java.util.NoSuchElementException; |
25 |
import java.util.NoSuchElementException; |
24 |
import javax.swing.JComponent; |
26 |
import javax.swing.JComponent; |
25 |
import javax.swing.event.ChangeListener; |
27 |
import javax.swing.event.ChangeListener; |
Lines 29-58
Link Here
|
29 |
import org.openide.util.ChangeSupport; |
31 |
import org.openide.util.ChangeSupport; |
30 |
import org.openide.util.NbBundle; |
32 |
import org.openide.util.NbBundle; |
31 |
|
33 |
|
32 |
final class ShortcutIterator implements WizardDescriptor.Iterator { |
34 |
final class ShortcutIterator implements WizardDescriptor.Iterator<ShortcutWizard> { |
33 |
|
35 |
|
34 |
ShortcutIterator() {} |
36 |
ShortcutIterator() {} |
35 |
|
37 |
|
36 |
// You should define what panels you want to use here: |
38 |
// You should define what panels you want to use here: |
37 |
|
39 |
|
38 |
private WizardDescriptor.Panel[] createPanels () { |
40 |
private List<WizardDescriptor.Panel<ShortcutWizard>> createPanels() { |
39 |
return new WizardDescriptor.Panel[] { |
41 |
List<WizardDescriptor.Panel<ShortcutWizard>> panels = new ArrayList<WizardDescriptor.Panel<ShortcutWizard>>(); |
40 |
new IntroPanel.IntroWizardPanel (), |
42 |
panels.add(new IntroPanel.IntroWizardPanel()); |
41 |
new SelectFolderPanel.SelectFolderWizardPanel( |
43 |
panels.add(new SelectFolderPanel.SelectFolderWizardPanel( |
42 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_select_menu_to_add_to"), |
44 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_select_menu_to_add_to"), |
43 |
NbBundle.getMessage(ShortcutIterator.class, "SI_TEXT_menu_locn"), |
45 |
NbBundle.getMessage(ShortcutIterator.class, "SI_TEXT_menu_locn"), |
44 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_display_name_for_menu"), |
46 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_display_name_for_menu"), |
45 |
DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource("Menu")), // NOI18N |
47 |
DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource("Menu")), // NOI18N |
46 |
true, ShortcutWizard.PROP_FOLDER_MENU), |
48 |
true, ShortcutWizard.PROP_FOLDER_MENU)); |
47 |
new SelectFolderPanel.SelectFolderWizardPanel( |
49 |
panels.add(new SelectFolderPanel.SelectFolderWizardPanel( |
48 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_select_toolbar"), |
50 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_select_toolbar"), |
49 |
NbBundle.getMessage(ShortcutIterator.class, "SI_TEXT_toolbar_locn"), |
51 |
NbBundle.getMessage(ShortcutIterator.class, "SI_TEXT_toolbar_locn"), |
50 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_display_name_for_toolbar"), |
52 |
NbBundle.getMessage(ShortcutIterator.class, "SI_LBL_display_name_for_toolbar"), |
51 |
DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource("Toolbars")), // NOI18N |
53 |
DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource("Toolbars")), // NOI18N |
52 |
false, ShortcutWizard.PROP_FOLDER_TOOL), |
54 |
false, ShortcutWizard.PROP_FOLDER_TOOL)); |
53 |
new SelectKeyboardShortcutPanel.SelectKeyboardShortcutWizardPanel (), |
55 |
panels.add(new SelectKeyboardShortcutPanel.SelectKeyboardShortcutWizardPanel()); |
54 |
new CustomizeScriptPanel.CustomizeScriptWizardPanel (), |
56 |
panels.add(new CustomizeScriptPanel.CustomizeScriptWizardPanel()); |
55 |
}; |
57 |
return panels; |
56 |
} |
58 |
} |
57 |
|
59 |
|
58 |
// And the list of step names: |
60 |
// And the list of step names: |
Lines 68-74
Link Here
|
68 |
} |
70 |
} |
69 |
|
71 |
|
70 |
private transient int index; |
72 |
private transient int index; |
71 |
private transient WizardDescriptor.Panel[] panels; |
73 |
private transient List<WizardDescriptor.Panel<ShortcutWizard>> panels; |
72 |
private transient ShortcutWizard wiz; |
74 |
private transient ShortcutWizard wiz; |
73 |
|
75 |
|
74 |
// You can keep a reference to the TemplateWizard which can |
76 |
// You can keep a reference to the TemplateWizard which can |
Lines 81-91
Link Here
|
81 |
panels = createPanels (); |
83 |
panels = createPanels (); |
82 |
// #44409: make sure IntroWizardPanel knows about wiz |
84 |
// #44409: make sure IntroWizardPanel knows about wiz |
83 |
// XXX workaround should no longer be necessary... |
85 |
// XXX workaround should no longer be necessary... |
84 |
((IntroPanel.IntroWizardPanel) panels[0]).initialize(wiz); |
86 |
((IntroPanel.IntroWizardPanel) panels.get(0)).initialize(wiz); |
85 |
// Make sure list of steps is accurate. |
87 |
// Make sure list of steps is accurate. |
86 |
String[] steps = createSteps (); |
88 |
String[] steps = createSteps (); |
87 |
for (int i = 0; i < panels.length; i++) { |
89 |
for (int i = 0; i < panels.size(); i++) { |
88 |
Component c = panels[i].getComponent (); |
90 |
Component c = panels.get(i).getComponent(); |
89 |
if (steps[i] == null) { |
91 |
if (steps[i] == null) { |
90 |
// Default step name to component name of panel. |
92 |
// Default step name to component name of panel. |
91 |
// Mainly useful for getting the name of the target |
93 |
// Mainly useful for getting the name of the target |
Lines 106-112
Link Here
|
106 |
|
108 |
|
107 |
public String name () { |
109 |
public String name () { |
108 |
return NbBundle.getMessage (ShortcutIterator.class, "TITLE_x_of_y", |
110 |
return NbBundle.getMessage (ShortcutIterator.class, "TITLE_x_of_y", |
109 |
new Integer (index + 1), new Integer (panels.length)); |
111 |
index + 1, panels.size()); |
110 |
} |
112 |
} |
111 |
|
113 |
|
112 |
boolean showing(String prop) { |
114 |
boolean showing(String prop) { |
Lines 130-136
Link Here
|
130 |
} |
132 |
} |
131 |
} |
133 |
} |
132 |
public boolean hasNext () { |
134 |
public boolean hasNext () { |
133 |
for (int i = index + 1; i < panels.length; i++) { |
135 |
for (int i = index + 1; i < panels.size(); i++) { |
134 |
if (showing (i)) { |
136 |
if (showing (i)) { |
135 |
return true; |
137 |
return true; |
136 |
} |
138 |
} |
Lines 158-165
Link Here
|
158 |
index--; |
160 |
index--; |
159 |
while (! showing (index)) index--; |
161 |
while (! showing (index)) index--; |
160 |
} |
162 |
} |
161 |
public WizardDescriptor.Panel current () { |
163 |
public WizardDescriptor.Panel<ShortcutWizard> current() { |
162 |
return panels[index]; |
164 |
return panels.get(index); |
163 |
} |
165 |
} |
164 |
|
166 |
|
165 |
private transient ChangeSupport cs = new ChangeSupport(this); |
167 |
private transient ChangeSupport cs = new ChangeSupport(this); |