use of org.eclipse.ui.internal.AggregateWorkingSet in project org.eclipse.rap by eclipse-rap.
the class WorkingSetSelectionDialog method createDialogArea.
/**
* Overrides method from Dialog.
* Create the dialog widgets.
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
*/
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
Composite composite = (Composite) super.createDialogArea(parent);
createMessageArea(composite);
SelectionListener listener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateButtonAvailability();
}
};
buttonWindowSet = new Button(composite, SWT.RADIO);
buttonWindowSet.setText(WorkbenchMessages.get().WindowWorkingSets);
buttonWindowSet.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonWindowSet.addSelectionListener(listener);
buttonNoSet = new Button(composite, SWT.RADIO);
buttonNoSet.setText(WorkbenchMessages.get().NoWorkingSet);
buttonNoSet.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonNoSet.addSelectionListener(listener);
buttonSelectedSets = new Button(composite, SWT.RADIO);
buttonSelectedSets.setText(WorkbenchMessages.get().SelectedWorkingSets);
buttonSelectedSets.addSelectionListener(listener);
switch(getInitialRadioSelection()) {
case 0:
buttonWindowSet.setSelection(true);
break;
case 1:
buttonNoSet.setSelection(true);
break;
case 2:
buttonSelectedSets.setSelection(true);
break;
}
buttonSelectedSets.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite viewerComposite = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = layout.marginWidth = 0;
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
viewerComposite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
// fudge? I like fudge.
data.widthHint = SIZING_SELECTION_WIDGET_WIDTH + 300;
viewerComposite.setLayoutData(data);
listViewer = CheckboxTableViewer.newCheckList(viewerComposite, SWT.BORDER | SWT.MULTI);
data = new GridData(GridData.FILL_BOTH);
data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
listViewer.getTable().setLayoutData(data);
listViewer.setLabelProvider(labelProvider);
listViewer.setContentProvider(contentProvider);
listViewer.setComparator(new WorkbenchViewerComparator());
listViewer.addFilter(new WorkingSetFilter(getSupportedWorkingSetIds()));
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
handleSelectionChanged();
}
});
listViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object obj = ((IStructuredSelection) listViewer.getSelection()).getFirstElement();
listViewer.setCheckedElements(new Object[] { obj });
buttonWindowSet.setSelection(false);
buttonNoSet.setSelection(false);
buttonSelectedSets.setSelection(true);
okPressed();
}
});
listViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// implicitly select the third radio button
buttonWindowSet.setSelection(false);
buttonNoSet.setSelection(false);
buttonSelectedSets.setSelection(true);
}
});
addModifyButtons(viewerComposite);
addSelectionButtons(composite);
listViewer.setInput(Arrays.asList(WorkbenchPlugin.getDefault().getWorkingSetManager().getWorkingSets()));
List initialElementSelections = getInitialElementSelections();
if (multiSelect) {
listViewer.setCheckedElements(initialElementSelections.toArray());
} else if (!initialElementSelections.isEmpty()) {
IWorkingSet set = (IWorkingSet) initialElementSelections.get(0);
if (set instanceof AggregateWorkingSet) {
AggregateWorkingSet aggregate = (AggregateWorkingSet) set;
listViewer.setCheckedElements(aggregate.getComponents());
} else {
listViewer.setCheckedElements(initialElementSelections.toArray());
}
}
availableWorkingSetsChanged();
Dialog.applyDialogFont(composite);
return composite;
}
Aggregations