use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tmdm-studio-se by Talend.
the class RepositoryViewFilterDialog method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
GridLayout gl_container = new GridLayout(1, false);
gl_container.marginRight = 5;
container.setLayout(gl_container);
Group nameGroup = new Group(container, SWT.NONE);
nameGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
GridLayout gl_nameGroup = new GridLayout(1, false);
nameGroup.setLayout(gl_nameGroup);
nameGroup.setText(Messages.RepositoryViewFilterDialog_groupNamePattern);
enableNameFilterBun = new Button(nameGroup, SWT.CHECK);
enableNameFilterBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
namePatternTxt.setEnabled(enableNameFilterBun.getSelection());
}
});
enableNameFilterBun.setText(Messages.RepositoryViewFilterDialog_enableNameFilter);
namePatternTxt = new Text(nameGroup, SWT.BORDER);
namePatternTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
namePatternTxt.setSize(440, 18);
objectgroup = new Group(container, SWT.NONE);
objectgroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
objectgroup.setText(Messages.RepositoryViewFilterDialog_groupServerObject);
objectgroup.setLayout(new GridLayout(1, false));
enableServerObjFilterBun = new Button(objectgroup, SWT.CHECK);
enableServerObjFilterBun.setSize(183, 16);
enableServerObjFilterBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableServerObjFilterComposite(enableServerObjFilterBun.getSelection());
}
});
enableServerObjFilterBun.setText(Messages.RepositoryViewFilterDialog_enableServerObjFilter);
serverObjViewer = CheckboxTableViewer.newCheckList(objectgroup, SWT.BORDER | SWT.FULL_SELECTION);
table = serverObjViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
table.setSize(441, 121);
enableAllBun = new Button(objectgroup, SWT.CHECK);
enableAllBun.setSize(171, 16);
enableAllBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean selected = enableAllBun.getSelection();
enableAllBun.setSelection(selected);
serverObjViewer.setAllChecked(selected);
if (selected)
enabledConfigs.addAll(allConfigs);
else
enabledConfigs.clear();
}
});
enableAllBun.setText(Messages.RepositoryViewFilterDialog_enableAllServerObject);
//
serverObjViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
IRepositoryViewObject config = (IRepositoryViewObject) event.getElement();
if (event.getChecked())
enabledConfigs.add(config);
else
enabledConfigs.remove(config);
solveProcTriCase();
enableAllBun.setSelection(enabledConfigs.size() == allConfigs.size());
}
});
serverObjViewer.setLabelProvider(new MDMRepositoryLabelProvider());
serverObjViewer.setContentProvider(new ArrayContentProvider());
Group lastServerGroup = new Group(container, SWT.NONE);
lastServerGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lastServerGroup.setLayout(new GridLayout(3, false));
lastServerGroup.setText(Messages.RepositoryViewFilterDialog_groupLastServer);
enableLastServerFilterBun = new Button(lastServerGroup, SWT.CHECK);
enableLastServerFilterBun.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
enableLastServerFilterBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableLastServerFilterComposite(enableLastServerFilterBun.getSelection());
}
});
enableLastServerFilterBun.setText(Messages.RepositoryViewFilterDialog_enableLastServerFilter);
enableLastServerFilterBun.setSelection(false);
new Label(lastServerGroup, SWT.NONE);
lastServerLabel = new Label(lastServerGroup, SWT.NONE);
lastServerLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lastServerLabel.setText(Messages.RepositoryViewFilterDialog_lblLastServer);
serverNameTxt = new Text(lastServerGroup, SWT.BORDER | SWT.READ_ONLY);
serverNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
selServerBun = new Button(lastServerGroup, SWT.NONE);
selServerBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SelectServerDefDialog dlg = new SelectServerDefDialog(getShell());
if (dlg.open() == IDialogConstants.OK_ID) {
MDMServerDef def = dlg.getSelectedServerDef();
serverNameTxt.setText(def.getName());
}
}
});
selServerBun.setText(Messages.RepositoryViewFilterDialog_btnSelectServer);
//
getShell().setText(Messages.RepositoryViewFilterDialog_title);
//
initServerObjectFilter();
return container;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmDevicePeripheralsView method createPartControl.
// /**
// * Provides the editor for the tree elements
// *
// * Does minor modifications to the default editor.
// */
// private class PeripheralsViewTextCellEditor extends TextCellEditor {
//
// private int minHeight;
//
// public PeripheralsViewTextCellEditor(Tree tree) {
// super(tree, SWT.BORDER);
// Text txt = (Text) getControl();
//
// Font fnt = txt.getFont();
// FontData[] fontData = fnt.getFontData();
// if (fontData != null && fontData.length > 0) {
// minHeight = fontData[0].getHeight() + 10;
// }
// }
//
// public LayoutData getLayoutData() {
// LayoutData data = super.getLayoutData();
// if (minHeight > 0)
// data.minimumHeight = minHeight;
// return data;
// }
// }
/**
* Callback that creates the viewer and initialises it.
*
* The View consists of a tree and a information panel
*/
public void createPartControl(Composite parent) {
// Create the manager and bind to main composite
resManager = new LocalResourceManager(JFaceResources.getResources(), parent);
parent.setLayoutData(new FillLayout());
SashForm form = new SashForm(parent, SWT.VERTICAL);
form.setLayout(new FillLayout());
// Make sash visible
form.setSashWidth(4);
form.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
// =============================
fPeripheralsTreeViewer = new CheckboxTreeViewer(form, SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
Tree tree = fPeripheralsTreeViewer.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
ColumnViewerToolTipSupport.enableFor(fPeripheralsTreeViewer);
// // Suppress tree expansion on double-click
// // see http://www.eclipse.org/forums/index.php/t/257325/
// peripheralsTreeViewer.getControl().addListener(SWT.MeasureItem, new Listener(){
// @Override
// public void handleEvent(Event event) {
// }});
fPeripheralsTreeViewer.setColumnProperties(fTreeProperties);
fPeripheralsTreeViewer.setCellEditors(new CellEditor[] { null, new TextCellEditor(fPeripheralsTreeViewer.getTree()), null });
// peripheralsTreeViewer.setCellEditors(new CellEditor[] { null, new PeripheralsViewTextCellEditor(peripheralsTreeViewer.getTree()), null });
fPeripheralsTreeViewer.setCellModifier(new PeripheralsViewCellModifier(this));
/*
* Name column
*/
TreeColumn column;
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultNameColumnWidth);
column.setText("Name");
// Add listener to column so peripherals are sorted by name when clicked
column.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fPeripheralsTreeViewer.setComparator(new PeripheralsViewSorter(PeripheralsViewSorter.SortCriteria.PeripheralNameOrder));
}
});
/*
* Value column
*/
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultValueColumnWidth);
column.setText("Value");
column.setResizable(fDefaultValueColumnWidth != 0);
/*
* Field column
*/
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultFieldColumnWidth);
column.setText("Field");
column.setResizable(fDefaultFieldColumnWidth != 0);
/*
* Mode column
*/
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultModeWidth);
column.setText("Mode");
column.setResizable(fDefaultModeWidth != 0);
/*
* Location column
*/
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultLocationColumnWidth);
column.setText("Location");
column.setResizable(fDefaultLocationColumnWidth != 0);
// Add listener to column so peripheral are sorted by address when clicked
column.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fPeripheralsTreeViewer.setComparator(new PeripheralsViewSorter(PeripheralsViewSorter.SortCriteria.AddressOrder));
}
});
/*
* Description column
*/
column = new TreeColumn(fPeripheralsTreeViewer.getTree(), SWT.NONE);
column.setWidth(fDefaultDescriptionColumnWidth);
column.setText("Description");
column.setResizable(fDefaultDescriptionColumnWidth != 0);
// Default to sorted by Peripheral name
fPeripheralsTreeViewer.setComparator(new PeripheralsViewSorter(PeripheralsViewSorter.SortCriteria.PeripheralNameOrder));
// Noting filtered
fPeripheralsTreeViewer.addFilter(new PeripheralsViewFilter(PeripheralsViewFilter.SelectionCriteria.SelectAll));
// Label provider
fPeripheralsTreeViewer.setLabelProvider(new PeripheralsViewCellLabelProvider(this));
// Content provider
fPeripheralsTreeViewer.setContentProvider(new PeripheralsViewContentProvider(this));
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(fPeripheralsTreeViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
// ||
return (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION);
// (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
}
};
TreeViewerEditor.create(fPeripheralsTreeViewer, actSupport, TreeViewerEditor.DEFAULT);
// Create the help context id for the viewer's control
// PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(),
// "usbdmMemory.viewer");
// =============================
fPeripheralsInformationPanel = new PeripheralsInformationPanel(form, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY, this.fPeripheralsTreeViewer);
form.setWeights(new int[] { 80, 20 });
// Tree expansion/collapse
fPeripheralsTreeViewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeExpanded(TreeExpansionEvent event) {
Object element = event.getElement();
// System.err.println("treeExpanded() => event.getElement().getClass() = " + element.getClass());
if (element instanceof RegisterModel) {
((RegisterModel) element).update();
}
if (element instanceof PeripheralModel) {
((PeripheralModel) element).update();
}
}
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
});
// When user checks a checkbox in the tree, check all its children
fPeripheralsTreeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// peripheralsTreeViewer.expandToLevel(event.getElement(), 1);
fPeripheralsTreeViewer.setSubtreeChecked(event.getElement(), event.getChecked());
}
});
// Create the actions
makeActions();
// Add selected actions to context menu
hookContextMenu();
// Add selected actions to menu bar
contributeToActionBars();
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project eclipse-cs by checkstyle.
the class EnhancedCheckBoxTableViewer method handleSelect.
/*
* (non-Javadoc) Method declared on StructuredViewer.
*/
@Override
public void handleSelect(SelectionEvent event) {
if (event.detail == SWT.CHECK) {
// this will change the current
super.handleSelect(event);
// selection
TableItem item = (TableItem) event.item;
Object data = item.getData();
if (data != null) {
fireCheckStateChanged(new CheckStateChangedEvent(this, data, item.getChecked()));
}
} else {
super.handleSelect(event);
}
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project statecharts by Yakindu.
the class TreeExpandingDoubleClickListener method doubleClick.
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object firstElement = selection.getFirstElement();
if (treeViewer.isExpandable(firstElement)) {
boolean expanded = treeViewer.getExpandedState(firstElement);
treeViewer.setExpandedState(firstElement, !expanded);
} else {
// FIXME :: does not trigger validation
boolean newState = !treeViewer.getChecked(firstElement);
treeViewer.setChecked(firstElement, newState);
if (checkStateListener != null) {
checkStateListener.checkStateChanged(new CheckStateChangedEvent(treeViewer, firstElement, newState));
}
}
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.
the class AbstractJarSelectDialog method createTreeViewer.
/**
* Creates the tree viewer.
*
* @param parent the parent composite
* @return the tree viewer
*/
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
if (fContainerMode) {
fViewer = new ContainerCheckedTreeViewer(parent, SWT.BORDER);
} else {
fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
}
fViewer.setContentProvider(fContentProvider);
fViewer.setLabelProvider(fLabelProvider);
fViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
// ADD msjian 2011-8-9 TDQ-3199 fixed: Make it convenient to delete the jar which is used already.
handleChecked();
handleClassNameFromJarFile();
// ADD end
updateOKStatus();
}
});
fViewer.setComparator(fComparator);
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++) {
fViewer.addFilter((ViewerFilter) fFilters.get(i));
}
}
fViewer.setInput(fInput);
return fViewer;
}
Aggregations