|
Lines 16-21
Link Here
|
| 16 |
import java.util.concurrent.atomic.AtomicBoolean; |
16 |
import java.util.concurrent.atomic.AtomicBoolean; |
| 17 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
| 18 |
import org.eclipse.equinox.internal.p2.ui.ProvUI; |
18 |
import org.eclipse.equinox.internal.p2.ui.ProvUI; |
|
|
19 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
| 19 |
import org.eclipse.equinox.internal.p2.ui.actions.PropertyDialogAction; |
20 |
import org.eclipse.equinox.internal.p2.ui.actions.PropertyDialogAction; |
| 20 |
import org.eclipse.equinox.internal.p2.ui.dialogs.*; |
21 |
import org.eclipse.equinox.internal.p2.ui.dialogs.*; |
| 21 |
import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext; |
22 |
import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext; |
|
Lines 303-309
Link Here
|
| 303 |
GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData(); |
304 |
GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData(); |
| 304 |
data.heightHint = 200; |
305 |
data.heightHint = 200; |
| 305 |
|
306 |
|
| 306 |
fSelectionCount = SWTFactory.createLabel(parent, NLS.bind(Messages.EditIUContainerPage_itemsSelected, Integer.toString(0)), 1); |
307 |
// fSelectionCount = SWTFactory.createLabel(parent, NLS.bind(Messages.EditIUContainerPage_itemsSelected, Integer.toString(0)), 1); |
|
|
308 |
Composite buttonParent = new Composite(parent, SWT.NONE); |
| 309 |
GridLayout gridLayout = new GridLayout(); |
| 310 |
gridLayout.numColumns = 3; |
| 311 |
gridLayout.marginWidth = 0; |
| 312 |
gridLayout.horizontalSpacing = 10; |
| 313 |
buttonParent.setLayout(gridLayout); |
| 314 |
|
| 315 |
GridData gridData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); |
| 316 |
buttonParent.setLayoutData(gridData); |
| 317 |
|
| 318 |
Button selectAll = new Button(buttonParent, SWT.PUSH); |
| 319 |
selectAll.setText(ProvUIMessages.SelectableIUsPage_Select_All); |
| 320 |
GridData selectAllData = setButtonLayoutData(selectAll); |
| 321 |
selectAllData.widthHint = 90; |
| 322 |
|
| 323 |
selectAll.addListener(SWT.Selection, new Listener() { |
| 324 |
@Override |
| 325 |
public void handleEvent(Event event) { |
| 326 |
setAllChecked(true); |
| 327 |
} |
| 328 |
}); |
| 329 |
|
| 330 |
Button deselectAll = new Button(buttonParent, SWT.PUSH); |
| 331 |
deselectAll.setText(ProvUIMessages.SelectableIUsPage_Deselect_All); |
| 332 |
GridData deselectAllData = setButtonLayoutData(deselectAll); |
| 333 |
deselectAllData.widthHint = 90; |
| 334 |
deselectAll.addListener(SWT.Selection, new Listener() { |
| 335 |
@Override |
| 336 |
public void handleEvent(Event event) { |
| 337 |
setAllChecked(false); |
| 338 |
} |
| 339 |
}); |
| 340 |
fSelectionCount = SWTFactory.createLabel(buttonParent, NLS.bind(Messages.EditIUContainerPage_itemsSelected, Integer.toString(0)), 1); |
| 341 |
GridData labelData = new GridData(); |
| 342 |
labelData.widthHint = 200; |
| 343 |
fSelectionCount.setLayoutData(labelData); |
| 344 |
} |
| 345 |
|
| 346 |
void setAllChecked(boolean checked) { |
| 347 |
if (checked) { |
| 348 |
TreeItem[] items = fAvailableIUGroup.getCheckboxTreeViewer().getTree().getItems(); |
| 349 |
checkAll(checked, items); |
| 350 |
fAvailableIUGroup.setChecked(fAvailableIUGroup.getCheckboxTreeViewer().getCheckedElements()); |
| 351 |
} else { |
| 352 |
fAvailableIUGroup.setChecked(new Object[0]); |
| 353 |
} |
| 354 |
updateSelection(); |
| 355 |
} |
| 356 |
|
| 357 |
private void checkAll(boolean checked, TreeItem[] items) { |
| 358 |
for (int i = 0; i < items.length; i++) { |
| 359 |
items[i].setChecked(checked); |
| 360 |
TreeItem[] children = items[i].getItems(); |
| 361 |
checkAll(checked, children); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
void updateSelection() { |
| 366 |
int count = fAvailableIUGroup.getCheckedLeafIUs().length; |
| 367 |
setPageComplete(count > 0); |
| 368 |
String message; |
| 369 |
if (count == 0) { |
| 370 |
message = ProvUIMessages.AvailableIUsPage_MultipleSelectionCount; |
| 371 |
fSelectionCount.setText(NLS.bind(message, Integer.toString(count))); |
| 372 |
} else { |
| 373 |
message = count == 1 ? ProvUIMessages.AvailableIUsPage_SingleSelectionCount : ProvUIMessages.AvailableIUsPage_MultipleSelectionCount; |
| 374 |
fSelectionCount.setText(NLS.bind(message, Integer.toString(count))); |
| 375 |
} |
| 307 |
} |
376 |
} |
| 308 |
|
377 |
|
| 309 |
/** |
378 |
/** |