use of org.eclipse.jface.viewers.CheckStateChangedEvent 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;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project n4js by eclipse.
the class ExportSelectionPage method createChoiceListGroup.
/**
* The List of projects
*
* @param composite
*/
private void createChoiceListGroup(Composite parent) {
Composite choiceListGroup = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
choiceListGroup.setLayout(layout);
choiceListGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
choiceListGroup.setFont(parent.getFont());
choiceList = CheckboxTableViewer.newCheckList(choiceListGroup, SWT.BORDER);
choiceList.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
choiceList.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
// sort the projects before displaying, ignoring case like in the workspace projects view.
final List<IProject> sortedProjects = new ArrayList<>(projects.keySet());
sortedProjects.sort((a, b) -> a.getName().compareToIgnoreCase(b.getName()));
choiceList.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// n.t.d.
}
@Override
public void dispose() {
// n.t.d.
}
@Override
public Object[] getElements(Object inputElement) {
return sortedProjects.toArray();
}
});
choiceList.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
return false;
}
@Override
public boolean isChecked(Object element) {
Boolean checkedState = projects.get(element);
return checkedState != null && checkedState.booleanValue();
}
});
choiceList.setInput(new StructuredSelection(projects));
choiceList.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
handleCheckStateChange(event);
}
});
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project hale by halestudio.
the class LayersDialog method createDialogArea.
/**
* @see TitleAreaDialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
page.setLayoutData(data);
page.setLayout(new FillLayout());
CheckboxTableViewer table = CheckboxTableViewer.newCheckList(page, SWT.V_SCROLL | SWT.BORDER);
TableColumn names = new TableColumn(table.getTable(), SWT.NONE);
names.setWidth(200);
names.setText(Messages.LayersDialog_2);
TableColumn descs = new TableColumn(table.getTable(), SWT.NONE);
descs.setWidth(200);
descs.setText(Messages.LayersDialog_3);
// labels
table.setLabelProvider(new LayerLabelProvider());
table.setCheckStateProvider(new LayerCheckStateProvider());
table.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
((Layer) event.getElement()).setSelected(event.getChecked());
}
});
// content
table.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
@Override
public void dispose() {
// ignore
}
@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
return ((List<Layer>) inputElement).toArray();
}
});
table.setInput(layers);
table.getTable().setLinesVisible(true);
table.getTable().setHeaderVisible(true);
// pack columns
names.pack();
descs.pack();
return page;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project hale by halestudio.
the class MergeParameterPage method createContent.
@Override
protected void createContent(Composite page) {
// set layout of page
page.setLayout(new GridLayout());
Label name = new Label(page, SWT.NONE);
name.setText(parameter.getDisplayName());
// create checkbox tree viewer
viewer = new CheckboxTreeViewer(page, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
// comparator
viewer.setComparator(new DefinitionComparator());
// label provider
viewer.setLabelProvider(labelProvider);
// content provider
viewer.setContentProvider(new PropertyPathContentProvider(SchemaSpaceID.SOURCE));
// check state listener
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
// add/remove it from/to set of selected properties
EntityDefinition eventSource = (EntityDefinition) event.getElement();
if (event.getChecked())
selection.add(eventSource);
else
selection.remove(eventSource);
}
});
// for now filter everything after first level
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return parentElement == sourceType;
}
});
if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY))
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return !filtered.contains(element);
}
});
Cell unfinishedCell = getWizard().getUnfinishedCell();
if (unfinishedCell.getSource() != null) {
sourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
}
viewer.setInput(sourceType);
// add initial selection
if (sourceType != null && initialSelection != null) {
for (String propertyPath : initialSelection) {
EntityDefinition entity = getEntityDefinition(propertyPath, sourceType);
if (entity != null) {
selection.add(entity);
} else {
log.warn("Could not find child for property path " + propertyPath);
}
}
viewer.setCheckedElements(selection.toArray());
}
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
* .lang.Object)
*/
public Object[] getChildren(Object parentElement) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
* .lang.Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
* .lang.Object)
*/
public Object getParent(Object element) {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
* (org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts) {
projectsList.setChecked(element, false);
}
setPageComplete(projectsList.getCheckedElements().length > 0);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
Aggregations