use of org.eclipse.jface.viewers.ICheckStateListener in project epp.mpc by eclipse.
the class ShowNatureProposalsDialog method createDialogArea.
@Override
public Control createDialogArea(Composite parent) {
setTitle(Messages.MissingNatureDetector_Title);
setMessage(Messages.MissingNatureDetector_Desc);
wizban = DiscoveryImages.BANNER_DISOVERY.createImage();
setTitleImage(wizban);
Composite res = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(res);
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).equalWidth(false).applyTo(res);
Label label = new Label(res, SWT.WRAP);
label.setText(Messages.MissingNatureDetector_Message);
naturesCheckList = CheckboxTableViewer.newCheckList(res, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
naturesCheckList.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return ((Set<?>) inputElement).toArray();
}
});
naturesCheckList.setComparator(new ViewerComparator());
naturesCheckList.setInput(candidates.keySet());
naturesCheckList.setAllChecked(true);
GridDataFactory.fillDefaults().applyTo(naturesCheckList.getControl());
naturesCheckList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Button okButton = getButton(IDialogConstants.OK_ID);
if (okButton != null) {
okButton.setEnabled(canComplete());
}
updateSelectedNatures();
}
});
Link preferencesLink = new Link(res, SWT.NONE);
preferencesLink.setText(Messages.MissingNatureDetector_linkToPreferences);
preferencesLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(), ProjectNaturesPreferencePage.ID, null, null);
pref.setBlockOnOpen(false);
pref.open();
}
});
return res;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
switchResultLayout = new StackLayout();
container.setLayout(switchResultLayout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
defaultComposite = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
TreeColumnLayout columnLayout = new TreeColumnLayout();
treeContainer.setLayout(columnLayout);
viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setUseHashlookup(true);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == e2) {
return 0;
}
String s1;
String s2;
if (e1 instanceof CatalogItemEntry) {
s1 = ((CatalogItemEntry) e1).getItem().getName();
s2 = ((CatalogItemEntry) e2).getItem().getName();
} else {
FeatureEntry fe1 = (FeatureEntry) e1;
FeatureEntry fe2 = (FeatureEntry) e2;
if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
// required items first
return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
}
s1 = fe1.getFeatureDescriptor().getName();
s2 = fe2.getFeatureDescriptor().getName();
}
int i = s1.compareToIgnoreCase(s2);
if (i == 0) {
i = s1.compareTo(s2);
if (i == 0) {
i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
}
}
return i;
}
});
viewer.setContentProvider(new ContentProvider());
viewer.setInput(getWizard().getSelectionModel());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
if (event.getElement() instanceof CatalogItemEntry) {
CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
for (FeatureEntry child : entry.getChildren()) {
child.setChecked(checked);
}
} else if (event.getElement() instanceof FeatureEntry) {
FeatureEntry featureEntry = (FeatureEntry) event.getElement();
featureEntry.setChecked(checked);
}
refreshState();
}
});
column = new TreeViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
GridLayoutFactory.fillDefaults().applyTo(detailsControl);
detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
setControl(container);
Dialog.applyDialogFont(container);
MarketplaceClientUi.setDefaultHelp(getControl());
flipToDefaultComposite();
}
use of org.eclipse.jface.viewers.ICheckStateListener in project n4js by eclipse.
the class AbstractExportToSingleFileWizardPage method createProjectList.
/**
* Creates the checkbox tree and list for selecting resources.
*
* @param parent
* the parent control
*/
protected void createProjectList(Composite parent) {
// create the input element, which has the root resource
// as its only child
List<IProject> input = new ArrayList<>();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
if (projects[i].isOpen()) {
input.add(projects[i]);
}
}
listViewer = CheckboxTableViewer.newCheckList(parent, SWT.TOP | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
listViewer.getTable().setLayoutData(data);
listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
listViewer.setContentProvider(getContentProvider());
listViewer.setComparator(new ViewerComparator());
// check for initial modification to avoid work if no changes are made
listViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked()) {
for (Object currentlyChecked : listViewer.getCheckedElements()) {
if (currentlyChecked != event.getElement()) {
listViewer.setChecked(currentlyChecked, false);
}
}
}
updateWidgetEnablements();
}
});
listViewer.setInput(workspace);
}
use of org.eclipse.jface.viewers.ICheckStateListener in project liferay-ide by liferay.
the class SDKProjectConvertWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(Msgs.importProjectLabel);
title.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
// Composite listComposite = new Composite(workArea, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 0;
// layout.makeColumnsEqualWidth = false;
// listComposite.setLayout(layout);
// GridData gd = new GridData(GridData.GRAB_HORIZONTAL
// | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
// gd.grabExcessHorizontalSpace = true;
// gd.horizontalSpan = 3;
// listComposite.setLayoutData(gd);
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return (Object[]) getDataModel().getProperty(SELECTED_PROJECTS);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts()) {
projectsList.setChecked(element, false);
}
getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
}
use of org.eclipse.jface.viewers.ICheckStateListener in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
labelProjectsList = new Label(workArea, SWT.NONE);
labelProjectsList.setText(Msgs.importProjectsLabel);
labelProjectsList.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(createProjectsListLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
handleCheckStateChangedEvent(event);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(workArea);
}
Aggregations