use of org.eclipse.jface.viewers.ICheckStateListener in project jbosstools-hibernate by jbosstools.
the class ExporterSettingsTab method createOldExporterTable.
// currently unused functionality
@SuppressWarnings("unused")
private void createOldExporterTable(Composite parent) {
Composite exporterOptions = createComposite(parent, HibernateConsoleMessages.ExporterSettingsTab_exporters);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.minimumHeight = 100;
exporterOptions.setLayoutData(gd);
exporterOptions.setLayout(new GridLayout(2, false));
Table table = new Table(exporterOptions, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL);
// setExporterTable(new CheckboxTableViewer( table ));
getExporterTable().setContentProvider(new ExporterContentProvider());
getExporterTable().setLabelProvider(new ExporterLabelProvider());
// exporterTable.getControl().setLayoutData(
// new GridData( SWT.FILL, SWT.FILL, true, true ) );
// $NON-NLS-1$
getExporterTable().setColumnProperties(new String[] { "", HibernateConsoleMessages.ExporterSettingsTab_description });
getExporterTable().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ExporterFactory factory = (ExporterFactory) event.getElement();
if (!event.getChecked() && selectedExporters.contains(factory)) {
selectedExporters.remove(factory);
} else if (event.getChecked() && !selectedExporters.contains(factory)) {
selectedExporters.add(factory);
}
dialogChanged();
}
});
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.verticalSpan = 2;
gd.horizontalSpan = 1;
table.setLayoutData(gd);
selectAll = new Button(exporterOptions, SWT.PUSH);
selectAll.setText(HibernateConsoleMessages.ExporterSettingsTab_select_all);
selectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getExporterTable().setAllChecked(true);
dialogChanged();
}
});
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalIndent = 5;
selectAll.setLayoutData(gd);
deselectAll = new Button(exporterOptions, SWT.PUSH);
deselectAll.setText(HibernateConsoleMessages.ExporterSettingsTab_deselect_all);
deselectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getExporterTable().setAllChecked(false);
dialogChanged();
}
});
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalIndent = 5;
deselectAll.setLayoutData(gd);
}
use of org.eclipse.jface.viewers.ICheckStateListener in project eclipse-cs by checkstyle.
the class EnhancedCheckBoxTableViewer method fireCheckStateChanged.
/**
* Notifies any check state listeners that a check state changed has been received. Only listeners
* registered at the time this method is called are notified.
*
* @param event
* a check state changed event
* @see ICheckStateListener#checkStateChanged
*/
private void fireCheckStateChanged(final CheckStateChangedEvent event) {
Object[] array = checkStateListeners.getListeners();
for (int i = 0; i < array.length; i++) {
final ICheckStateListener l = (ICheckStateListener) array[i];
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() {
l.checkStateChanged(event);
}
});
}
}
use of org.eclipse.jface.viewers.ICheckStateListener in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method createContents.
/**
* {@inheritDoc}
*/
@Override
public Control createContents(Composite parent) throws CheckstylePluginException {
mComposite = parent;
Group composite = new Group(parent, SWT.NONE);
composite.setText(Messages.ComplexFileSetsEditor_titleAdvancedFilesetEditor);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
//
// Create the table of file sets.
//
Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION);
GridData data = new GridData(GridData.FILL_BOTH);
table.setLayoutData(data);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
TableColumn column1 = new TableColumn(table, SWT.NONE);
column1.setText(Messages.ComplexFileSetsEditor_colEnabled);
column1.setResizable(false);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setText(Messages.ComplexFileSetsEditor_colFilesetName);
TableColumn column3 = new TableColumn(table, SWT.NONE);
column3.setText(Messages.ComplexFileSetsEditor_colConfiguration);
tableLayout.addColumnData(new ColumnWeightData(20));
tableLayout.addColumnData(new ColumnWeightData(40));
tableLayout.addColumnData(new ColumnWeightData(40));
mViewer = new CheckboxTableViewer(table);
mViewer.setLabelProvider(new FileSetLabelProvider());
mViewer.setContentProvider(new ArrayContentProvider());
mViewer.setComparator(new FileSetViewerSorter());
mViewer.setInput(mFileSets);
//
for (FileSet fileSet : mFileSets) {
mViewer.setChecked(fileSet, fileSet.isEnabled());
}
mViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent e) {
editFileSet();
}
});
mViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
changeEnabledState(event);
}
});
//
// Build the buttons.
//
Composite buttons = new Composite(composite, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
buttons.setLayout(layout);
mAddButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnAdd);
mAddButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
addFileSet();
}
});
mEditButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnEdit);
mEditButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
editFileSet();
}
});
mRemoveButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnRemove);
mRemoveButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
removeFileSet();
}
});
return composite;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project janrufmonitor by tbrandt77.
the class UpdatesPage method createControl.
public void createControl(Composite c) {
Composite select = new Composite(c, SWT.NONE);
select.setLayout(new GridLayout(1, false));
select.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label ln = new Label(select, SWT.LEFT);
ln.setText(this.m_i18n.getString(this.getNamespace(), "updates", "label", this.m_language));
updates = CheckboxTableViewer.newCheckList(select, SWT.FULL_SELECTION | SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
updates.setLabelProvider(new UpdateLabelProvider());
updates.setContentProvider(new UpdateContentProvider());
updates.getTable().setHeaderVisible(true);
TableColumn col = new TableColumn(updates.getTable(), SWT.LEFT | SWT.TOP);
col.setWidth(200);
col.setText(this.m_i18n.getString(this.getNamespace(), "modname", "label", this.m_language));
col = new TableColumn(updates.getTable(), SWT.LEFT | SWT.TOP);
col.setWidth(50);
col.setText(this.m_i18n.getString(this.getNamespace(), "currentversion", "label", this.m_language));
col = new TableColumn(updates.getTable(), SWT.LEFT | SWT.TOP);
col.setWidth(50);
col.setText(this.m_i18n.getString(this.getNamespace(), "newversion", "label", this.m_language));
// col = new TableColumn(updates.getTable(), SWT.LEFT | SWT.TOP);
// col.setWidth(350);
Listener paintListener = new Listener() {
public void handleEvent(Event event) {
if (event.index != 3)
return;
switch(event.type) {
case SWT.MeasureItem:
{
TableItem item = (TableItem) event.item;
String text = item.getText(event.index);
Point size = event.gc.textExtent(text);
event.width = size.x;
event.height = Math.max(event.height, size.y + 7);
break;
}
case SWT.PaintItem:
{
TableItem item = (TableItem) event.item;
String text = item.getText(event.index);
Point size = event.gc.textExtent(text);
int offset2 = (event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0) + 3;
event.gc.drawText(text, event.x + offset2, event.y + offset2, true);
break;
}
case SWT.EraseItem:
{
event.detail &= ~SWT.FOREGROUND;
break;
}
}
}
};
updates.getTable().addListener(SWT.MeasureItem, paintListener);
updates.getTable().addListener(SWT.PaintItem, paintListener);
updates.getTable().addListener(SWT.EraseItem, paintListener);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 220;
// gd.minimumWidth = 490;
gd.grabExcessHorizontalSpace = true;
updates.getTable().setLayoutData(gd);
updates.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent e) {
Object[] o = updates.getCheckedElements();
setPageComplete(o.length > 0);
}
});
final Button refresh = new Button(select, SWT.PUSH);
refresh.setText(this.m_i18n.getString(this.getNamespace(), "refresh", "label", this.m_language));
refresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
try {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
pm.setTaskName(m_i18n.getString(getNamespace(), "task", "label", m_language));
final List l = m_um.getUpdates();
DisplayManager.getDefaultDisplay().asyncExec(new Runnable() {
public void run() {
updates.setInput(l);
updates.refresh(true);
}
});
if (l.size() == 0) {
DisplayManager.getDefaultDisplay().asyncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(getShell(), "", m_i18n.getString(getNamespace(), "noupdates", "label", m_language));
}
});
}
}
};
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
});
ln = new Label(select, SWT.LEFT | SWT.WRAP);
ln.setText(this.m_i18n.getString(this.getNamespace(), "updates", "description", this.m_language));
gd = new GridData(480, 50);
gd.horizontalSpan = 2;
gd.minimumWidth = 480;
ln.setLayoutData(gd);
this.setControl(c);
if (this.m_preload) {
try {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
pm.setTaskName(m_i18n.getString(getNamespace(), "task", "label", m_language));
final List l = m_um.getUpdates();
DisplayManager.getDefaultDisplay().asyncExec(new Runnable() {
public void run() {
updates.setInput(l);
updates.refresh(true);
}
});
if (l.size() == 0) {
DisplayManager.getDefaultDisplay().asyncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(getShell(), "", m_i18n.getString(getNamespace(), "noupdates", "label", m_language));
}
});
}
}
};
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
pmd.run(false, true, op);
} catch (InvocationTargetException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InterruptedException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
use of org.eclipse.jface.viewers.ICheckStateListener in project janrufmonitor by tbrandt77.
the class RuleAssistent method createContents.
protected Control createContents(Composite parent) {
this.setTitle(this.m_i18n.getString(this.getNamespace(), "title", "label", this.m_language));
this.noDefaultAndApplyButton();
Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(1, false));
Label l = new Label(c, SWT.NONE);
l.setText(this.m_i18n.getString(this.NAMESPACE, "available", "label", this.m_language));
cl = CheckboxTableViewer.newCheckList(c, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL);
cl.setLabelProvider(new RuleLabelProvider());
cl.setContentProvider(new RuleContentProvider());
List rules = this.getRules();
cl.setInput(rules);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 100;
cl.getTable().setLayoutData(gd);
IRule rule = null;
for (int i = 0; i < rules.size(); i++) {
rule = (IRule) rules.get(i);
cl.setChecked(rule, rule.isActive());
}
cl.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
IRule rule = (IRule) event.getElement();
rule.setActive(checked);
}
});
Composite buttonGroup = new Composite(c, SWT.NONE);
buttonGroup.setLayout(new GridLayout(4, false));
Button newButton = new Button(buttonGroup, SWT.PUSH);
newButton.setText(this.m_i18n.getString(this.NAMESPACE, "new", "label", this.m_language));
newButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
openRuleWizard(null);
IRule rule = null;
List rules = getRules();
for (int i = 0; i < rules.size(); i++) {
rule = (IRule) rules.get(i);
cl.setChecked(rule, rule.isActive());
}
}
});
final Button changeButton = new Button(buttonGroup, SWT.PUSH);
changeButton.setText(this.m_i18n.getString(this.NAMESPACE, "change", "label", this.m_language));
changeButton.setEnabled(false);
changeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
StructuredSelection s = (StructuredSelection) cl.getSelection();
if (!s.isEmpty()) {
IRule rule = (IRule) s.getFirstElement();
openRuleWizard(rule);
IRule r = null;
List rules = getRules();
for (int i = 0; i < rules.size(); i++) {
r = (IRule) rules.get(i);
cl.setChecked(r, r.isActive());
}
}
}
});
final Button copyButton = new Button(buttonGroup, SWT.PUSH);
copyButton.setText(this.m_i18n.getString(this.NAMESPACE, "copy", "label", this.m_language));
copyButton.setEnabled(false);
copyButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
StructuredSelection s = (StructuredSelection) cl.getSelection();
if (!s.isEmpty()) {
if (MessageDialog.openConfirm(e.display.getActiveShell(), m_i18n.getString(NAMESPACE, "copytitle", "label", m_language), m_i18n.getString(NAMESPACE, "copyconfirmation", "label", m_language))) {
List ruleList = s.toList();
IRule r = null;
IRule copiedRule = null;
for (int i = 0; i < ruleList.size(); i++) {
r = (IRule) ruleList.get(i);
copiedRule = getRuntime().getRuleEngine().createRule(r.toString());
copiedRule.setName(m_i18n.getString(NAMESPACE, "copyof", "label", m_language) + r.getName());
m_rules.add(copiedRule);
cl.add(copiedRule);
cl.setChecked(copiedRule, copiedRule.isActive());
}
cl.refresh();
}
}
}
});
final Button deleteButton = new Button(buttonGroup, SWT.PUSH);
deleteButton.setText(this.m_i18n.getString(this.NAMESPACE, "delete", "label", this.m_language));
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
StructuredSelection s = (StructuredSelection) cl.getSelection();
if (!s.isEmpty()) {
if (MessageDialog.openConfirm(e.display.getActiveShell(), m_i18n.getString(NAMESPACE, "deletetitle", "label", m_language), m_i18n.getString(NAMESPACE, "deleteconfirmation", "label", m_language))) {
Object o = s.getFirstElement();
cl.remove(o);
m_rules.remove(o);
cl.refresh();
}
}
}
});
l = new Label(c, SWT.NONE);
l.setText(this.m_i18n.getString(this.NAMESPACE, "ruledesc", "label", this.m_language));
final Text ruleAsText = new Text(c, SWT.BORDER | SWT.WRAP);
ruleAsText.setLayoutData(new GridData(GridData.FILL_BOTH));
ruleAsText.setEditable(false);
cl.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
StructuredSelection selected = (StructuredSelection) event.getSelection();
if (selected.isEmpty()) {
deleteButton.setEnabled(false);
changeButton.setEnabled(false);
copyButton.setEnabled(false);
} else {
deleteButton.setEnabled(true);
changeButton.setEnabled(true);
copyButton.setEnabled(true);
}
IRule rule = (IRule) selected.getFirstElement();
ruleAsText.setText(createDescription(rule));
}
});
return c;
}
Aggregations