use of org.eclipse.jface.viewers.ICheckStateListener in project GT by Tencent.
the class DevicesView method createTargetPkgTableView.
/**
* 创建被测进程列表
* @Title: createTargetPkgTableView
* @Description:
* @param parent
* void
* @throws
*/
private void createTargetPkgTableView(Composite parent) {
targetPkgTableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
ctv = new CheckboxTableViewer(targetPkgTableViewer.getTable());
ctv.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (isSupportCheckChangePer) {
GetCurCheckedStateUtil.update();
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
});
// 设置表头内容
for (int i = 0; i < TARGET_COLUMN_NAME.length; i++) {
new TableColumn(targetPkgTableViewer.getTable(), SWT.LEFT).setText(TARGET_COLUMN_NAME[i]);
}
targetPkgTableViewer.getTable().getColumn(0).setWidth(200);
targetPkgTableViewer.getTable().getColumn(1).setWidth(50);
// 设置表头和表格线可见
targetPkgTableViewer.getTable().setHeaderVisible(true);
targetPkgTableViewer.getTable().setLinesVisible(true);
targetPkgTableViewer.setContentProvider(new ViewContentProvider());
targetPkgTableViewer.setLabelProvider(new ViewLabelProvider());
targetPkgTableViewer.getTable().addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
}
@Override
public void mouseDown(MouseEvent e) {
}
@Override
public void mouseDoubleClick(MouseEvent e) {
if (isSupportAddOrDeleteOper) {
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
if (selectData == null || selectData.length == 0) {
return;
}
PkgInfo itemData = (PkgInfo) selectData[0].getData();
targetPkgTableViewer.remove(itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
});
targetPkgTableViewer.getTable().setToolTipText("双击或者右键菜单可删除被测进程");
FormData tableViewFormData = new FormData();
tableViewFormData.left = new FormAttachment(0, 5);
tableViewFormData.right = new FormAttachment(100, -5);
tableViewFormData.top = new FormAttachment(pkgNameText, 10);
tableViewFormData.height = 125;
Table table = targetPkgTableViewer.getTable();
table.setLayoutData(tableViewFormData);
}
use of org.eclipse.jface.viewers.ICheckStateListener in project hale by halestudio.
the class SchemasRetrievalPage method createComponent.
private void createComponent() {
if (multipleSelection) {
selectAll = new Button(page, SWT.CHECK);
selectAll.setText("Select all");
selectAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
schemaTable.setAllChecked(((Button) e.getSource()).getSelection());
}
});
schemaTable = CheckboxTableViewer.newCheckList(page, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
} else
schemaTable = CheckboxTableViewer.newCheckList(page, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
schemaTable.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return element.toString();
}
});
schemaTable.setContentProvider(ArrayContentProvider.getInstance());
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
layoutData.widthHint = SWT.DEFAULT;
layoutData.heightHint = 8 * schemaTable.getTable().getItemHeight();
schemaTable.getControl().setLayoutData(layoutData);
schemaTable.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked() && (!multipleSelection)) {
schemaTable.setAllChecked(false);
schemaTable.setCheckedElements(new Object[] { event.getElement() });
}
setPageComplete(validate());
}
});
setPageComplete(false);
page.layout(true, true);
}
use of org.eclipse.jface.viewers.ICheckStateListener in project hale by halestudio.
the class EditMappableTypesPage method createControl.
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
parent.setLayout(new GridLayout());
// create filtered tree
PatternFilter patternFilter = new PatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(parent, SWT.BORDER | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true) {
@Override
protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
return new CheckboxTreeViewer(parent, style);
}
};
// configure viewer
viewer = (CheckboxTreeViewer) tree.getViewer();
contentProvider = new NSTypeTreeContentProvider();
viewer.setContentProvider(contentProvider);
viewer.setComparator(new DefinitionComparator());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object doubleClicked = selection.getFirstElement();
if (doubleClicked instanceof String)
viewer.setExpandedState(doubleClicked, !viewer.getExpandedState(doubleClicked));
else {
boolean newState = !checkStateProvider.isChecked(doubleClicked);
viewer.setChecked(doubleClicked, newState);
checkStateOfTypeChanged((TypeDefinition) doubleClicked, newState);
}
}
});
viewer.setLabelProvider(definitionLabels);
// because elements filtered by FilteredTree lose their checked state:
checkStateProvider = new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
if (element instanceof String) {
Object[] children = contentProvider.getChildren(element);
boolean containsChecked = false;
boolean containsUnchecked = false;
for (Object child : children) {
if (isChecked(child))
containsChecked = true;
else
containsUnchecked = true;
if (containsChecked && containsUnchecked)
return true;
}
}
return false;
}
@Override
public boolean isChecked(Object element) {
if (element instanceof String) {
for (Object child : contentProvider.getChildren(element)) if (isChecked(child))
return true;
return false;
}
return ((TypeDefinition) element).getConstraint(MappingRelevantFlag.class).isEnabled() != changedTypes.contains(element);
}
};
viewer.setCheckStateProvider(checkStateProvider);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getElement() instanceof String) {
// update children
viewer.setGrayed(event.getElement(), false);
for (Object child : contentProvider.getChildren(event.getElement())) {
// if (mappedTypeFilter.select(viewer, event.getElement(), child)) {
if (checkStateProvider.isChecked(child) != event.getChecked()) {
viewer.setChecked(child, event.getChecked());
checkStateOfTypeChanged((TypeDefinition) child, event.getChecked());
}
// }
}
viewer.setGrayed(event.getElement(), checkStateProvider.isGrayed(event.getElement()));
// only two levels, no need to update any parents or
// children's children
} else {
// if (mappedTypeFilter.select(viewer, null, event.getElement()))
checkStateOfTypeChanged((TypeDefinition) event.getElement(), event.getChecked());
// else if (!event.getChecked())
// viewer.setChecked(event.getElement(), true);
}
}
});
// // filter types which are used in the current alignment
// viewer.addFilter(mappedTypeFilter);
// set input to all types in the given index
viewer.setInput(typeIndex.getTypes());
// expand all except XMLSchema
viewer.expandAll();
viewer.setExpandedState("http://www.w3.org/2001/XMLSchema", false);
// set control
setControl(viewer.getControl());
}
use of org.eclipse.jface.viewers.ICheckStateListener in project hale by halestudio.
the class AbstractFeatureTypesPage method createContent.
@Override
protected void createContent(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(new GridLayout(1, false));
// create filtered tree
PatternFilter patternFilter = new PatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(page, SWT.BORDER | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true) {
@Override
protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
return new CheckboxTreeViewer(parent, style);
}
};
// configure viewer
viewer = (CheckboxTreeViewer) tree.getViewer();
contentProvider = new FeatureTypeTreeContentProvider();
viewer.setContentProvider(contentProvider);
// viewer.setComparator(new DefinitionComparator());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object doubleClicked = selection.getFirstElement();
if (doubleClicked instanceof String)
viewer.setExpandedState(doubleClicked, !viewer.getExpandedState(doubleClicked));
else {
boolean newState = !checkStateProvider.isChecked(doubleClicked);
viewer.setChecked(doubleClicked, newState);
checkStateOfTypeChanged((QName) doubleClicked, newState);
}
}
});
viewer.setLabelProvider(new FeatureTypeTreeLabelProvider());
// because elements filtered by FilteredTree lose their checked state:
checkStateProvider = new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
if (element instanceof String) {
Object[] children = contentProvider.getChildren(element);
boolean containsChecked = false;
boolean containsUnchecked = false;
for (Object child : children) {
if (isChecked(child))
containsChecked = true;
else
containsUnchecked = true;
if (containsChecked && containsUnchecked)
return true;
}
}
return false;
}
@Override
public boolean isChecked(Object element) {
if (element instanceof String) {
for (Object child : contentProvider.getChildren(element)) if (isChecked(child))
return true;
return false;
}
return selected.contains(element);
}
};
viewer.setCheckStateProvider(checkStateProvider);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getElement() instanceof String) {
// update children
viewer.setGrayed(event.getElement(), false);
for (Object child : contentProvider.getChildren(event.getElement())) {
if (checkStateProvider.isChecked(child) != event.getChecked()) {
viewer.setChecked(child, event.getChecked());
checkStateOfTypeChanged((QName) child, event.getChecked());
}
}
viewer.setGrayed(event.getElement(), checkStateProvider.isGrayed(event.getElement()));
// only two levels, no need to update any parents or
// children's children
} else {
checkStateOfTypeChanged((QName) event.getElement(), event.getChecked());
}
}
});
setControl(page);
// initial update
updateState(selected);
}
use of org.eclipse.jface.viewers.ICheckStateListener in project tbd-studio-se by Talend.
the class HadoopServicesTableComposite method addListener.
private void addListener() {
servicesTableViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
checkServices();
}
});
selectAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doSelectAll();
}
});
deselectAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doDeselectAll();
}
});
}
Aggregations