use of org.eclipse.jface.viewers.CheckStateChangedEvent in project webtools.sourceediting by eclipse.
the class OutlineCustomFiltersDialog method createCheckBoxList.
private void createCheckBoxList(Composite parent) {
// Filler
new Label(parent, SWT.NONE);
Label info = new Label(parent, SWT.LEFT);
info.setText(OutlineFilterMessages.CustomFiltersDialog_filterList_label);
fCheckBoxList = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = fCheckBoxList.getTable().getItemHeight() * 10;
fCheckBoxList.getTable().setLayoutData(data);
fCheckBoxList.setLabelProvider(createLabelPrivder());
fCheckBoxList.setContentProvider(new ArrayContentProvider());
Arrays.sort(fBuiltInFilters);
fCheckBoxList.setInput(fBuiltInFilters);
setInitialSelections(getEnabledFilterDescriptors());
List initialSelection = getInitialElementSelections();
if (initialSelection != null && !initialSelection.isEmpty())
checkInitialSelections();
// Description
info = new Label(parent, SWT.LEFT);
info.setText(OutlineFilterMessages.CustomFiltersDialog_description_label);
final Text description = new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
data = new GridData(GridData.FILL_HORIZONTAL);
data.heightHint = convertHeightInCharsToPixels(3);
description.setLayoutData(data);
fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
if (selectedElement instanceof OutlineFilterDescriptor)
description.setText(((OutlineFilterDescriptor) selectedElement).getDescription());
}
}
});
fCheckBoxList.addCheckStateListener(new ICheckStateListener() {
/*
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof OutlineFilterDescriptor) {
// renew if already touched
if (fFilterDescriptorChangeHistory.contains(element))
fFilterDescriptorChangeHistory.remove(element);
fFilterDescriptorChangeHistory.push(element);
}
}
});
addSelectionButtons(parent);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project webtools.sourceediting by eclipse.
the class CodeAssistCyclingConfigurationBlock method createDefaultPageViewer.
private void createDefaultPageViewer(Composite composite) {
fDefaultPageViewer = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
Table table = fDefaultPageViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(false);
table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 1, 1));
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
nameColumn.setText(SSEUIMessages.CodeAssistAdvancedConfigurationBlock_default_table_category_column_title);
nameColumn.setResizable(false);
fDefaultPageViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
ModelElement element = (ModelElement) event.getElement();
element.setShouldDisplayOnDefaultPage(checked);
}
});
fDefaultPageViewer.setContentProvider(new ArrayContentProvider());
DefaultPageTableLabelProvider labelProvider = new DefaultPageTableLabelProvider();
fDefaultPageViewer.setLabelProvider(labelProvider);
fDefaultPageViewer.setInput(fModel.defaultPageElements);
fDefaultPageViewer.setComparator(new ModelViewerComparator(fCategoryDefaultPageComparator));
final int ICON_AND_CHECKBOX_WITH = 50;
final int HEADER_MARGIN = 20;
int minNameWidth = computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
for (int i = 0; i < fModel.defaultPageElements.size(); i++) {
minNameWidth = Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.defaultPageElements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
}
nameColumn.setWidth(minNameWidth);
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleDefaultPageTableSelection();
}
});
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project webtools.servertools by eclipse.
the class OverviewEditorPart method createPublishSection.
protected void createPublishSection(Composite rightColumnComp, FormToolkit toolkit) {
Section section = toolkit.createSection(rightColumnComp, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(Messages.serverEditorOverviewPublishSection);
section.setDescription(Messages.serverEditorOverviewPublishDescription);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 15;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE);
toolkit.paintBordersFor(composite);
section.setClient(composite);
// auto-publish
if (server != null) {
final Server svr = (Server) server;
int publishSetting = svr.getAutoPublishSetting();
GridData data = new GridData(GridData.FILL_HORIZONTAL);
autoPublishDisable = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishDisable, SWT.RADIO);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
autoPublishDisable.setLayoutData(data);
autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
whs.setHelp(autoPublishDisable, ContextIds.EDITOR_AUTOPUBLISH_DISABLE);
autoPublishEnableResource = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledResource, SWT.RADIO);
autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
autoPublishEnableResource.setLayoutData(data);
whs.setHelp(autoPublishEnableResource, ContextIds.EDITOR_AUTOPUBLISH_ENABLE);
autoPublishEnableBuild = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabledBuild, SWT.RADIO);
autoPublishEnableBuild.setSelection(publishSetting == Server.AUTO_PUBLISH_BUILD);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
autoPublishEnableBuild.setLayoutData(data);
whs.setHelp(autoPublishEnableBuild, ContextIds.EDITOR_AUTOPUBLISH_BUILD);
final Label autoPublishTimeLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewAutoPublishEnabledInterval);
data = new GridData();
data.horizontalIndent = 20;
autoPublishTimeLabel.setLayoutData(data);
autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
autoPublishTime = new Spinner(composite, SWT.BORDER);
autoPublishTime.setMinimum(0);
autoPublishTime.setIncrement(5);
autoPublishTime.setMaximum(MAX_SPINNER_TIME);
autoPublishTime.setSelection(svr.getAutoPublishTime());
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.widthHint = SWT.DEFAULT;
autoPublishTime.setLayoutData(data);
autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
SWTUtil.setSpinnerTooltip(autoPublishTime);
whs.setHelp(autoPublishTime, ContextIds.EDITOR_AUTOPUBLISH_INTERVAL);
autoPublishEnableResource.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (updating || !autoPublishEnableResource.getSelection())
return;
updating = true;
execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_RESOURCE));
updating = false;
autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
validate();
}
});
autoPublishEnableBuild.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (updating || !autoPublishEnableBuild.getSelection())
return;
updating = true;
execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_BUILD));
updating = false;
autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
validate();
}
});
autoPublishDisable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (updating || !autoPublishDisable.getSelection())
return;
updating = true;
execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_DISABLE));
updating = false;
autoPublishTimeLabel.setEnabled(!autoPublishDisable.getSelection());
autoPublishTime.setEnabled(!autoPublishDisable.getSelection());
validate();
}
});
autoPublishTime.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new SetServerAutoPublishTimeCommand(getServer(), autoPublishTime.getSelection()));
SWTUtil.setSpinnerTooltip(autoPublishTime);
updating = false;
validate();
}
});
// publishers
Publisher[] pubs = ((Server) server).getAllPublishers();
if (pubs != null && pubs.length > 0) {
Label label = toolkit.createLabel(composite, Messages.serverEditorOverviewPublishers);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
label.setLayoutData(data);
publishersTable = toolkit.createTable(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
publishersTable.setHeaderVisible(false);
publishersTable.setLinesVisible(false);
whs.setHelp(publishersTable, ContextIds.EDITOR_PUBLISHTASKS_CONFIGURATION);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
data.horizontalSpan = 2;
data.heightHint = 80;
publishersTable.setLayoutData(data);
publishersViewer = new CheckboxTableViewer(publishersTable);
publishersViewer.setColumnProperties(new String[] { "name" });
publishersViewer.setContentProvider(new PublisherContentProvider(pubs));
publishersViewer.setLabelProvider(new PublishLabelProvider());
publishersViewer.setInput("root");
Publisher[] pubs2 = ((Server) server).getEnabledPublishers();
for (Publisher p : pubs2) publishersViewer.setChecked(p, true);
publishersViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element == null || !(element instanceof Publisher))
return;
if (updating)
return;
updating = true;
execute(new SetPublisherEnablementCommand(getServer(), (Publisher) element, event.getChecked()));
updating = false;
}
});
}
}
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent 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();
}
Aggregations