use of org.eclipse.jface.viewers.ICheckStateListener in project eclipse-integration-commons by spring-projects.
the class ChooseMultipleSection method createContents.
@Override
public void createContents(Composite page) {
Composite composite = new Composite(page, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
composite.setLayout(layout);
GridDataFactory grab = GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, UIConstants.SCROLLABLE_LIST_HEIGTH);
grab.applyTo(composite);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(composite, SWT.NONE);
label.setText(labelText);
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).hint(UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT).applyTo(label);
CheckboxTableViewer tv = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
grab.applyTo(tv.getTable());
tv.setContentProvider(new ContentProvider());
tv.setLabelProvider(new LabelProvider());
tv.setInput(validChoices);
tv.setCheckedElements(chosen.getValues().toArray());
tv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
@SuppressWarnings("unchecked") T e = (T) event.getElement();
boolean checked = event.getChecked();
if (checked) {
chosen.add(e);
} else {
chosen.remove(e);
}
}
});
if (DEBUG) {
chosen.addListener(new ValueListener<Set<T>>() {
public void gotValue(LiveExpression<Set<T>> exp, Set<T> value) {
System.out.println(">>>> starters");
for (T e : value) {
System.out.println(e.getLabel());
}
System.out.println("<<<< starters");
}
});
}
}
use of org.eclipse.jface.viewers.ICheckStateListener in project webtools.sourceediting by eclipse.
the class CodeAssistCyclingConfigurationBlock method createOwnPageViewer.
private void createOwnPageViewer(Composite composite) {
fOwnPageViewer = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
Table table = fOwnPageViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(false);
table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1));
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
nameColumn.setText(SSEUIMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
nameColumn.setResizable(false);
fOwnPageViewer.setContentProvider(new ArrayContentProvider());
ITableLabelProvider labelProvider = new OwnPageTableLabelProvider();
fOwnPageViewer.setLabelProvider(labelProvider);
fOwnPageViewer.setInput(fModel.pageElements);
fOwnPageViewer.setComparator(new ModelViewerComparator(fCategoryPageComparator));
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.pageElements.size(); i++) {
minNameWidth = Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.pageElements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
}
nameColumn.setWidth(minNameWidth);
fOwnPageViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
ModelElement element = (ModelElement) event.getElement();
element.setShouldDisplayOnOwnPage(checked);
}
});
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleOwnPageTableSelection();
}
});
}
use of org.eclipse.jface.viewers.ICheckStateListener in project webtools.sourceediting by eclipse.
the class TextHoverPreferenceTab method createContents.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.sse.ui.preferences.ui.IPreferenceTab#createContents(org.eclipse.swt.widgets.Composite)
*/
public Control createContents(Composite tabFolder) {
Composite hoverComposite = new Composite(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
hoverComposite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
hoverComposite.setLayoutData(gd);
// commented out until these preferences are actually handled in some
// way
// String rollOverLabel=
// ResourceHandler.getString("TextHoverPreferenceTab.annotationRollover");
// //$NON-NLS-1$
// addCheckBox(hoverComposite, rollOverLabel,
// CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER, 0);
//
// // Affordance checkbox
// String showAffordanceLabel =
// ResourceHandler.getString("TextHoverPreferenceTab.showAffordance");
// //$NON-NLS-1$
// addCheckBox(hoverComposite, showAffordanceLabel,
// CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, 0);
Label label = new Label(hoverComposite, SWT.NONE);
// $NON-NLS-1$
label.setText(SSEUIMessages.TextHoverPreferenceTab_hoverPreferences);
gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
fHoverTableViewer = CheckboxTableViewer.newCheckList(hoverComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
// Hover table
fHoverTable = fHoverTableViewer.getTable();
fHoverTable.setHeaderVisible(true);
fHoverTable.setLinesVisible(true);
gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=104507
GC gc = new GC(fHoverTable);
gc.setFont(fHoverTable.getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
int heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 7);
gd.heightHint = heightHint;
fHoverTable.setLayoutData(gd);
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
fHoverTable.setLayout(tableLayout);
fHoverTable.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
handleHoverListSelection();
}
});
fNameColumn = new TableColumn(fHoverTable, SWT.NONE);
// $NON-NLS-1$
fNameColumn.setText(SSEUIMessages.TextHoverPreferenceTab_nameColumnTitle);
fNameColumn.setResizable(true);
fModifierColumn = new TableColumn(fHoverTable, SWT.NONE);
// $NON-NLS-1$
fModifierColumn.setText(SSEUIMessages.TextHoverPreferenceTab_modifierColumnTitle);
fModifierColumn.setResizable(true);
fHoverTableViewer.setUseHashlookup(true);
fHoverTableViewer.setContentProvider(new ArrayContentProvider());
fHoverTableViewer.setLabelProvider(new InternalTableLabelProvider());
((CheckboxTableViewer) fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
/*
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
String id = ((TextHoverDescriptor) event.getElement()).getId();
if (id == null)
return;
TextHoverManager.TextHoverDescriptor[] descriptors = getTextHoverManager().getTextHovers();
TextHoverManager.TextHoverDescriptor hoverConfig = null;
int i = 0, length = fTextHovers.length;
while (i < length) {
if (id.equals(descriptors[i].getId())) {
hoverConfig = fTextHovers[i];
hoverConfig.setEnabled(event.getChecked());
fModifierEditor.setEnabled(event.getChecked());
fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
}
i++;
}
handleHoverListSelection();
updateStatus(hoverConfig);
}
});
// Text field for modifier string
label = new Label(hoverComposite, SWT.LEFT);
// $NON-NLS-1$
label.setText(SSEUIMessages.TextHoverPreferenceTab_keyModifier);
fModifierEditor = new Text(hoverComposite, SWT.BORDER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
fModifierEditor.setLayoutData(gd);
fModifierEditor.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// &&
// e.time
// -time
// <
// 1000)
// {
String text = fModifierEditor.getText();
Point selection = fModifierEditor.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(text.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
i = selection.y;
while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertDelimiterAndModifierAndDelimiter, new String[] { Action.findModifierString(e.stateMask) });
else if (needsPrefixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertDelimiterAndModifier, new String[] { Action.findModifierString(e.stateMask) });
else if (needsPostfixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertModifierAndDelimiter, new String[] { Action.findModifierString(e.stateMask) });
else
insertString = Action.findModifierString(e.stateMask);
if (insertString != null)
fModifierEditor.insert(insertString);
}
}
});
fModifierEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
handleModifierModified();
}
});
// Description
Label descriptionLabel = new Label(hoverComposite, SWT.LEFT);
// $NON-NLS-1$
descriptionLabel.setText(SSEUIMessages.TextHoverPreferenceTab_description);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
descriptionLabel.setLayoutData(gd);
fDescription = new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.horizontalSpan = 2;
fDescription.setLayoutData(gd);
initialize();
Dialog.applyDialogFont(hoverComposite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(hoverComposite, IHelpContextIds.PREFSTE_HOVERS_HELPID);
return hoverComposite;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project webtools.sourceediting by eclipse.
the class InstalledProcessorsBlock method createControl.
public void createControl(Composite ancestor) {
Composite parent = new Composite(ancestor, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
Font font = ancestor.getFont();
parent.setFont(font);
fControl = parent;
GridData data;
Label tableLabel = new Label(parent, SWT.NONE);
tableLabel.setText(Messages.InstalledProcessorsBlock_0);
data = new GridData();
data.horizontalSpan = 2;
tableLabel.setLayoutData(data);
tableLabel.setFont(font);
Table fTable = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = 450;
fTable.setLayoutData(data);
fTable.setFont(font);
fTable.setHeaderVisible(true);
fTable.setLinesVisible(true);
TableColumn column1 = new TableColumn(fTable, SWT.NONE);
column1.setWidth(180);
column1.setResizable(true);
column1.setText(Messages.InstalledProcessorsBlock_1);
column1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByName();
}
});
TableColumn column2 = new TableColumn(fTable, SWT.NONE);
column2.setWidth(90);
column2.setResizable(true);
column2.setText(Messages.InstalledProcessorsBlock_2);
column2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByType();
}
});
TableColumn column4 = new TableColumn(fTable, SWT.NONE);
column4.setWidth(180);
column4.setResizable(true);
column4.setText(Messages.InstalledProcessorsBlock_4);
column4.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByVersion();
}
});
tableViewer = new CheckboxTableViewer(fTable);
tableViewer.setLabelProvider(new VMLabelProvider());
tableViewer.setContentProvider(new ProcessorsContentProvider());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent evt) {
enableButtons();
}
});
tableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked()) {
setCheckedInstall((IProcessorInstall) event.getElement());
} else {
setCheckedInstall(null);
}
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
if (!tableViewer.getSelection().isEmpty()) {
editProcessor();
}
}
});
fTable.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
removeProcessors();
}
}
});
Composite buttons = new Composite(parent, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
buttons.setLayout(layout);
buttons.setFont(font);
fAddButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_5);
fAddButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
addProcessor();
}
});
fEditButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_6);
fEditButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
editProcessor();
}
});
fRemoveButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_7);
fRemoveButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
removeProcessors();
}
});
// copied from ListDialogField.CreateSeparator()
Label separator = new Label(buttons, SWT.NONE);
separator.setVisible(false);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.BEGINNING;
gd.heightHint = 4;
separator.setLayoutData(gd);
fillWithWorkspaceProcessors();
enableButtons();
restoreColumnSettings();
}
use of org.eclipse.jface.viewers.ICheckStateListener in project pmd-eclipse-plugin by pmd.
the class RuleSetSelectionDialog method setupRuleTable.
private void setupRuleTable() {
Table tbl = ruleTable.getTable();
tbl.setLinesVisible(true);
tbl.setHeaderVisible(true);
ruleTable.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
RuleSet rs = selectedRuleset();
return rs == null ? new Object[0] : rs.getRules().toArray();
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
ruleTable.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ruleChecked();
}
});
createCheckBoxColumn(tbl);
for (int i = 0; i < columns.length; i++) {
columns[i].newTableColumnFor(tbl, i + 1, null, null);
}
ruleTable.setLabelProvider(new RuleLabelProvider(columns));
}
Aggregations