use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent 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.CheckStateChangedEvent 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));
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project bndtools by bndtools.
the class JpmDependencyWizardPage method createControl.
@Override
@SuppressWarnings("unused")
public void createControl(Composite parent) {
// CREATE CONTROLS
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
Label lblDirect = new Label(container, SWT.NONE);
lblDirect.setFont(JFaceResources.getBannerFont());
lblDirect.setText("Direct Dependencies:");
Table tblDirect = new Table(container, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerDirect = new TableViewer(tblDirect);
viewerDirect.setContentProvider(ArrayContentProvider.getInstance());
viewerDirect.setLabelProvider(new ResourceDescriptorLabelProvider());
createHelpLabel(container, "The above dependencies will be added to the project and, if necessary, to the Searchable Repository local index.");
Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
Label lblIndirect = new Label(container, SWT.NONE);
lblIndirect.setFont(JFaceResources.getBannerFont());
lblIndirect.setText("Transitive Dependencies:");
Composite cmpIndirect = new Composite(container, SWT.NONE);
Table tblIndirect = new Table(cmpIndirect, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerIndirect = new CheckboxTableViewer(tblIndirect);
viewerIndirect.setContentProvider(ArrayContentProvider.getInstance());
viewerIndirect.setLabelProvider(new ResourceDescriptorLabelProvider());
Button btnSelectAll = new Button(cmpIndirect, SWT.PUSH);
btnSelectAll.setText("All");
Button btnSelectNone = new Button(cmpIndirect, SWT.PUSH);
btnSelectNone.setText("None");
new Label(cmpIndirect, SWT.NONE);
createHelpLabel(container, "The above dependencies will be added to the Searchable Repository local index. Checked dependencies will also be added directly to the project.");
// LISTENERS
// Query JPM and show results *after* dialog is shown. This ensures progress is visible in the dialog's
// progress bar
getContainer().getShell().addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
runQuery();
}
});
viewerIndirect.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent ev) {
if (selectedIndirectResources == null)
selectedIndirectResources = new HashSet<ResourceDescriptor>();
ResourceDescriptor resource = (ResourceDescriptor) ev.getElement();
if (ev.getChecked())
selectedIndirectResources.add(resource);
else
selectedIndirectResources.remove(resource);
}
});
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.addAll(indirectResources);
updateSelectedCheckboxes();
}
});
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.clear();
updateSelectedCheckboxes();
}
});
viewerDirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerIndirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
viewerIndirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerDirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
// LAYOUT
GridLayout layout;
GridData gd;
layout = new GridLayout(1, true);
container.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 30;
tblDirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
separator.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
cmpIndirect.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 2;
cmpIndirect.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.heightHint = 100;
tblIndirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectAll.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectNone.setLayoutData(gd);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project bndtools by bndtools.
the class PackageInfoDialog method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setMessage(Messages.PackageInfoDialog_Message);
setTitle(Messages.PackageInfoDialog_Title);
Composite container = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
table = new Table(composite, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_table.heightHint = 100;
table.setLayoutData(gd_table);
table.setLinesVisible(true);
TableColumn tblclmnPackage = new TableColumn(table, SWT.NONE);
tblclmnPackage.setWidth(267);
tblclmnPackage.setText(Messages.PackageInfoDialog_ExportedPackage);
TableColumn tblclmnVersion = new TableColumn(table, SWT.NONE);
tblclmnVersion.setWidth(77);
tblclmnVersion.setText(Messages.PackageInfoDialog_Version);
Button btnCheckAll = new Button(composite, SWT.NONE);
btnCheckAll.setText(Messages.PackageInfoDialog_btnCheckAll_text);
btnCheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnCheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selection.clear();
selection.addAll(packages);
viewer.setCheckedElements(selection.toArray());
validate();
}
});
Button btnUncheckAll = new Button(composite, SWT.NONE);
btnUncheckAll.setText(Messages.PackageInfoDialog_btnUncheckAll_text_1);
btnUncheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnUncheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selection.clear();
viewer.setCheckedElements(selection.toArray());
validate();
}
});
final Button btnAlwaysGenerate = new Button(composite, SWT.CHECK);
btnAlwaysGenerate.setText(Messages.PackageInfoDialog_AlwaysGenerate);
viewer = new CheckboxTableViewer(table);
TableViewerColumn tblViewerClmnPackage = new TableViewerColumn(viewer, tblclmnPackage);
tblViewerClmnPackage.setLabelProvider(new PackageNameLabelProvider(table.getDisplay()));
TableViewerColumn tblViewerClmnVersion = new TableViewerColumn(viewer, tblclmnVersion);
tblViewerClmnVersion.setLabelProvider(new PackageVersionLabelProvider());
tblViewerClmnVersion.setEditingSupport(new VersionEditingSupport(viewer));
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
FileVersionTuple f1 = (FileVersionTuple) e1;
FileVersionTuple f2 = (FileVersionTuple) e2;
return f1.compareTo(f2);
}
});
viewer.setInput(packages);
viewer.setCheckedElements(selection.toArray());
new Label(composite, SWT.NONE);
btnAlwaysGenerate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dontAsk = btnAlwaysGenerate.getSelection();
}
});
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
FileVersionTuple pkg = (FileVersionTuple) event.getElement();
if (event.getChecked())
selection.add(pkg);
else
selection.remove(pkg);
validate();
}
});
return container;
}
Aggregations