Lines 13-25
Link Here
|
13 |
</head> |
13 |
</head> |
14 |
<body> |
14 |
<body> |
15 |
|
15 |
|
16 |
<h2>Creating a custom filtered item selection dialog</h2> |
16 |
<h2>Creating a custom filtered items selection dialog</h2> |
17 |
<p>In this example, we will contribute a basic search dialog to illustrate the steps |
17 |
<p>In this example, we will contribute a basic search dialog to illustrate the steps |
18 |
needed to create a custom subclass of <a href="../reference/api/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.html"> |
18 |
needed to create a custom subclass of <a href="../reference/api/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.html"> |
19 |
<b> FilteredItemsSelectionDialog</b></a>.</p> |
19 |
<b> FilteredItemsSelectionDialog</b></a>.</p> |
20 |
|
20 |
|
21 |
<ol> |
21 |
<ol> |
22 |
<li> |
22 |
<li> |
|
|
23 |
Create a new Plug-in Project using Hello, world template. |
24 |
</li> |
25 |
<li> |
23 |
Create a class extending <em>org.eclipse.ui.dialogs.FilteredItemsSelectionDialog</em>. |
26 |
Create a class extending <em>org.eclipse.ui.dialogs.FilteredItemsSelectionDialog</em>. |
24 |
Let's name it <em>FilteredResourcesSelectionDialogExample</em>. |
27 |
Let's name it <em>FilteredResourcesSelectionDialogExample</em>. |
25 |
</li> |
28 |
</li> |
Lines 28-33
Link Here
|
28 |
example we will generate our own set of random strings as follows: |
31 |
example we will generate our own set of random strings as follows: |
29 |
<pre> |
32 |
<pre> |
30 |
private static ArrayList resources = new ArrayList(); |
33 |
private static ArrayList resources = new ArrayList(); |
|
|
34 |
|
31 |
static { |
35 |
static { |
32 |
generateRescourcesTestCases('A', 'C', 8, ""); //$NON-NLS-1$ |
36 |
generateRescourcesTestCases('A', 'C', 8, ""); //$NON-NLS-1$ |
33 |
generateRescourcesTestCases('a', 'c', 4, ""); //$NON-NLS-1$ |
37 |
generateRescourcesTestCases('a', 'c', 4, ""); //$NON-NLS-1$ |
Lines 91-96
Link Here
|
91 |
information about how the dialog information is persisted. This method can't |
95 |
information about how the dialog information is persisted. This method can't |
92 |
return null, so we'll just return a simple settings object: |
96 |
return null, so we'll just return a simple settings object: |
93 |
<pre> |
97 |
<pre> |
|
|
98 |
private static final String DIALOG_SETTINGS = "FilteredResourcesSelectionDialogExampleSettings"; |
99 |
|
94 |
protected IDialogSettings getDialogSettings() { |
100 |
protected IDialogSettings getDialogSettings() { |
95 |
IDialogSettings settings = Activator.getDefault().getDialogSettings() |
101 |
IDialogSettings settings = Activator.getDefault().getDialogSettings() |
96 |
.getSection(DIALOG_SETTINGS); |
102 |
.getSection(DIALOG_SETTINGS); |
Lines 126-132
Link Here
|
126 |
|
132 |
|
127 |
</ul> |
133 |
</ul> |
128 |
</li> |
134 |
</li> |
129 |
|
135 |
<li> |
|
|
136 |
Add title of dialog and set simple implementation of <em>SelectionHistory</em> on dialog:<pre> |
137 |
public FilteredResourcesSelectionDialogExample(Shell shell, boolean multi) { |
138 |
super(shell, multi); |
139 |
setTitle("Filtered Resources Selection Dialog Example"); |
140 |
setSelectionHistory(new ResourceSelectionHistory()); |
141 |
} |
142 |
|
143 |
private class ResourceSelectionHistory extends SelectionHistory { |
144 |
protected Object restoreItemFromMemento(IMemento element) { |
145 |
return null; |
146 |
} |
147 |
protected void storeItemToMemento(Object item, IMemento element) { |
148 |
} |
149 |
}</pre></li> |
150 |
<li> |
151 |
Change <em>run(IAction)</em> method from <em>SimpleAction</em> to:<pre> |
152 |
public void run(IAction action) { |
153 |
Shell shell = new Shell(); |
154 |
FilteredItemsSelectionDialog dialog = new FilteredResourcesSelectionDialogExample(shell, true); |
155 |
dialog.setInitialPattern("a"); |
156 |
dialog.open(); |
157 |
}</pre></li> |
158 |
<li> |
159 |
Change tooltip of SimpleAction from <em>"Hello, Eclipse world"</em> to <em>"Filtered Items Selection Dialog Example"</em>. |
160 |
</li> |
161 |
<li> |
162 |
Run Eclipse with created plug-in. |
163 |
</li> |
130 |
<li> |
164 |
<li> |
131 |
The resulting dialog looks as follows: |
165 |
The resulting dialog looks as follows: |
132 |
<p><img |
166 |
<p><img |