Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.util.HashSet; |
13 |
import java.util.HashSet; |
14 |
import java.util.Iterator; |
14 |
import java.util.Iterator; |
|
|
15 |
import java.util.List; |
15 |
import java.util.Map; |
16 |
import java.util.Map; |
16 |
import java.util.Set; |
17 |
import java.util.Set; |
17 |
import java.util.SortedMap; |
18 |
import java.util.SortedMap; |
Lines 123-128
Link Here
|
123 |
// unknown (non-existent) image. created locally, dispose locally |
124 |
// unknown (non-existent) image. created locally, dispose locally |
124 |
private Image imageUnkown; |
125 |
private Image imageUnkown; |
125 |
|
126 |
|
|
|
127 |
private List missingPaths; |
128 |
|
129 |
private Label missingPathLabel; |
130 |
|
131 |
private Table missingPathTable; |
132 |
|
126 |
/** |
133 |
/** |
127 |
* Creates a new PathVariablesGroup. |
134 |
* Creates a new PathVariablesGroup. |
128 |
* |
135 |
* |
Lines 159-165
Link Here
|
159 |
} |
166 |
} |
160 |
|
167 |
|
161 |
/** |
168 |
/** |
162 |
* Opens a dialog for creating a new variable. |
169 |
* Creates a new PathVariablesGroup. This constructor differs in that |
|
|
170 |
* it will display a list of resources that refer to missing path variables. |
171 |
* |
172 |
* @param multiSelect create a multi select tree |
173 |
* @param variableType the type of variables that are displayed in |
174 |
* the widget group. <code>IResource.FILE</code> and/or <code>IResource.FOLDER</code> |
175 |
* logically ORed together. |
176 |
* @param missingPaths list of <code>IPath</code> elements that refer to missing |
177 |
* path variables. |
178 |
*/ |
179 |
public PathVariablesGroup(boolean multiSelect, int variableType, |
180 |
List missingPaths){ |
181 |
this(multiSelect, variableType); |
182 |
this.missingPaths = missingPaths; |
183 |
} |
184 |
/** |
185 |
* Opens a dialog for creating a new variable. If a missing path |
186 |
* is selected in the missing path table, the variable name will be |
187 |
* initialized to the missing variable name. |
163 |
*/ |
188 |
*/ |
164 |
private void addNewVariable() { |
189 |
private void addNewVariable() { |
165 |
// constructs a dialog for editing the new variable's current name and value |
190 |
// constructs a dialog for editing the new variable's current name and value |
Lines 167-172
Link Here
|
167 |
PathVariableDialog.NEW_VARIABLE, variableType, |
192 |
PathVariableDialog.NEW_VARIABLE, variableType, |
168 |
pathVariableManager, tempPathVariables.keySet()); |
193 |
pathVariableManager, tempPathVariables.keySet()); |
169 |
|
194 |
|
|
|
195 |
// if the missing path table exists and has a selection, use the selected |
196 |
// item to initialize the variable name |
197 |
if (missingPathTable != null && missingPathTable.getSelectionIndex() >= 0){ |
198 |
IPath selectedPath = (IPath) missingPathTable.getItem(missingPathTable.getSelectionIndex()).getData(); |
199 |
dialog.setVariableName(selectedPath.segment(0)); |
200 |
} |
170 |
// opens the dialog - just returns if the user cancels it |
201 |
// opens the dialog - just returns if the user cancels it |
171 |
if (dialog.open() == Window.CANCEL) { |
202 |
if (dialog.open() == Window.CANCEL) { |
172 |
return; |
203 |
return; |
Lines 231-236
Link Here
|
231 |
variableTable = new Table(pageComponent, tableStyle); |
262 |
variableTable = new Table(pageComponent, tableStyle); |
232 |
variableTable.addSelectionListener(new SelectionAdapter() { |
263 |
variableTable.addSelectionListener(new SelectionAdapter() { |
233 |
public void widgetSelected(SelectionEvent e) { |
264 |
public void widgetSelected(SelectionEvent e) { |
|
|
265 |
updateTableSelected(e); |
234 |
updateEnabledState(); |
266 |
updateEnabledState(); |
235 |
if (selectionListener != null) { |
267 |
if (selectionListener != null) { |
236 |
selectionListener.handleEvent(new Event()); |
268 |
selectionListener.handleEvent(new Event()); |
Lines 243-255
Link Here
|
243 |
variableTable.setFont(font); |
275 |
variableTable.setFont(font); |
244 |
|
276 |
|
245 |
createButtonGroup(pageComponent); |
277 |
createButtonGroup(pageComponent); |
246 |
// populate table with current internal state and set buttons' initial state |
278 |
|
|
|
279 |
// if missing paths passed in constructor, create the |
280 |
// missing path table |
281 |
if (missingPaths != null){ |
282 |
createMissingPathsGroup(pageComponent); |
283 |
} |
284 |
|
285 |
// populate tables with current internal state and set buttons' initial state |
247 |
updateWidgetState(null); |
286 |
updateWidgetState(null); |
248 |
|
287 |
|
249 |
return pageComponent; |
288 |
return pageComponent; |
250 |
} |
289 |
} |
251 |
|
290 |
|
252 |
/** |
291 |
/** |
|
|
292 |
* @param e |
293 |
*/ |
294 |
protected void updateTableSelected(SelectionEvent e) { |
295 |
if (e.getSource() == variableTable){ |
296 |
// clear missing path selection when variable table selected |
297 |
if (missingPathTable != null){ |
298 |
missingPathTable.deselectAll(); |
299 |
} |
300 |
} |
301 |
// clear variable table selection when missing path table selected |
302 |
else if (e.getSource() == missingPathTable) { |
303 |
variableTable.deselectAll(); |
304 |
} |
305 |
|
306 |
} |
307 |
|
308 |
/** |
309 |
* Create missing path table to display the list of resources |
310 |
* that refer to a missing path variable |
311 |
* |
312 |
* @param pageComponent parent component |
313 |
*/ |
314 |
private void createMissingPathsGroup(Composite pageComponent) { |
315 |
GridData data = new GridData(GridData.FILL_BOTH); |
316 |
// layout the table |
317 |
missingPathLabel = new Label(pageComponent, SWT.LEFT); |
318 |
missingPathLabel.setText("Undefined"); //$NON-NLS-1$ |
319 |
data = new GridData(); |
320 |
data.horizontalAlignment = GridData.FILL; |
321 |
data.horizontalSpan = 2; |
322 |
missingPathLabel.setLayoutData(data); |
323 |
missingPathLabel.setFont(pageComponent.getFont()); |
324 |
|
325 |
int tableStyle = SWT.BORDER | SWT.FULL_SELECTION; |
326 |
missingPathTable = new Table(pageComponent, tableStyle); |
327 |
missingPathTable.addSelectionListener(new SelectionAdapter() { |
328 |
public void widgetSelected(SelectionEvent e) { |
329 |
updateTableSelected(e); |
330 |
updateEnabledState(); |
331 |
} |
332 |
}); |
333 |
data = new GridData(GridData.FILL_BOTH); |
334 |
int numberItems = missingPaths.size() > 7 ? 7 : missingPaths.size(); |
335 |
data.heightHint = missingPathTable.getItemHeight() * numberItems; |
336 |
missingPathTable.setLayoutData(data); |
337 |
missingPathTable.setFont(pageComponent.getFont()); |
338 |
|
339 |
} |
340 |
|
341 |
/** |
253 |
* Disposes the group's resources. |
342 |
* Disposes the group's resources. |
254 |
*/ |
343 |
*/ |
255 |
public void dispose() { |
344 |
public void dispose() { |
Lines 578-583
Link Here
|
578 |
*/ |
667 |
*/ |
579 |
private void updateWidgetState(String selectedVarName) { |
668 |
private void updateWidgetState(String selectedVarName) { |
580 |
updateVariableTable(selectedVarName); |
669 |
updateVariableTable(selectedVarName); |
|
|
670 |
updateMissingPathTable(); |
581 |
updateEnabledState(); |
671 |
updateEnabledState(); |
582 |
} |
672 |
} |
|
|
673 |
|
674 |
/** |
675 |
* Rebuilds missing path table widget state with the current list of |
676 |
* paths with missing path variables. Paths that refer to variables |
677 |
* added to the temp variable list will not be displayed in the table. |
678 |
*/ |
679 |
private void updateMissingPathTable() { |
680 |
if (missingPathTable != null){ |
681 |
missingPathTable.removeAll(); |
682 |
for (Iterator paths = missingPaths.iterator(); paths.hasNext();){ |
683 |
IPath missingPath = (IPath) paths.next(); |
684 |
// variable name is always the first segment |
685 |
String variableName = missingPath.segment(0); |
686 |
IPath resolvedPath = (IPath) tempPathVariables.get(variableName); |
687 |
if (resolvedPath == null){ |
688 |
// path variable has still not been defined so include |
689 |
// the path in the table |
690 |
TableItem item = new TableItem(missingPathTable, SWT.NONE); |
691 |
item.setText(missingPath.segment(0) + " - " + missingPath ); //$NON-NLS-1$ |
692 |
item.setData(missingPath); |
693 |
item.setImage(imageUnkown); |
694 |
} |
695 |
} |
696 |
} |
697 |
|
698 |
} |
583 |
} |
699 |
} |