use of org.eclipse.jface.viewers.CheckboxTableViewer 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;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project bndtools by bndtools.
the class WorkspacePreviewPage method createControl.
@Override
public void createControl(Composite parent) {
setTitle("Preview Changes");
// $NON-NLS-1$
setImageDescriptor(Plugin.imageDescriptorFromPlugin("icons/bndtools-wizban.png"));
imgAdded = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/incoming.gif").createImage(parent.getDisplay());
imgOverwrite = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/conflict.gif").createImage(parent.getDisplay());
imgError = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/error_obj.gif").createImage(parent.getDisplay());
int columns = 4;
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(columns, false);
composite.setLayout(layout);
setControl(composite);
Label lblTitle = new Label(composite, SWT.NONE);
lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
// Table
tblOutputs = new Table(composite, SWT.BORDER | SWT.CHECK);
tblOutputs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, columns, 1));
vwrOutputs = new CheckboxTableViewer(tblOutputs);
vwrOutputs.setContentProvider(ArrayContentProvider.getInstance());
vwrOutputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
StyledString label;
Image icon;
String path = (String) cell.getElement();
String error = resourceErrors.get(path);
if (error != null) {
label = new StyledString(path, ItalicStyler.INSTANCE_ERROR);
icon = imgError;
} else {
label = new StyledString(path);
icon = existingFiles.contains(path) ? imgOverwrite : imgAdded;
}
cell.setText(path);
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(icon);
}
});
vwrOutputs.setSorter(new ViewerSorter(Collator.getInstance()));
// Details display
final Label lblDetails = new Label(composite, SWT.NONE);
lblDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
lblDetails.setText(MSG_NOTHING_SELECTED);
// Button Panel
Label spacer1 = new Label(composite, SWT.NONE);
spacer1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button btnSelectNonConflict = new Button(composite, SWT.PUSH);
btnSelectNonConflict.setText("Select Non-Conflicting");
btnSelectNonConflict.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
checkedPaths.clear();
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (!existingFiles.contains(path))
checkedPaths.add(path);
}
vwrOutputs.setCheckedElements(checkedPaths.toArray());
}
});
}
});
Button btnSelectAll = new Button(composite, SWT.PUSH);
btnSelectAll.setText("Select All");
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(true);
}
});
Button btnSelectNone = new Button(composite, SWT.PUSH);
btnSelectNone.setText("Select None");
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(false);
}
});
// Listeners
vwrOutputs.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) vwrOutputs.getSelection();
if (sel.isEmpty()) {
lblDetails.setText(MSG_NOTHING_SELECTED);
} else {
String path = (String) sel.getFirstElement();
String resourceError = resourceErrors.get(path);
if (resourceError != null) {
lblDetails.setText(resourceError);
} else if (existingFiles.contains(path)) {
lblDetails.setText("This file already exists and will be overwritten");
} else {
lblDetails.setText("This file will be created");
}
}
}
});
vwrOutputs.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
modifyLock.ifNotModifying(new Runnable() {
@Override
public void run() {
final String updatedPath = (String) event.getElement();
if (event.getChecked()) {
checkedPaths.add(updatedPath);
// Check any directories that are parents of this path
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.endsWith("/") && updatedPath.startsWith(path)) {
checkedPaths.add(path);
vwrOutputs.setChecked(path, true);
}
}
}
});
} else {
checkedPaths.remove(updatedPath);
// Uncheck any paths that are descendants of this path
if (updatedPath.endsWith("/")) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.startsWith(updatedPath)) {
checkedPaths.remove(path);
vwrOutputs.setChecked(path, false);
}
}
}
});
}
}
}
});
}
});
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project bndtools by bndtools.
the class ProjectListControl method createTableLayout.
private void createTableLayout(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// Add TableColumnLayout
TableColumnLayout layout = new TableColumnLayout();
composite.setLayout(layout);
// Instantiate TableViewer
projects = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
projects.setHeaderVisible(true);
projects.setLinesVisible(true);
projects.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
selectionListener.widgetSelected(e);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
selectionListener.widgetDefaultSelected(e);
}
});
tableViewer = new CheckboxTableViewer(projects);
tableViewer.setUseHashlookup(true);
// Project
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
TableColumn tableCol = tableViewerColumn.getColumn();
layout.setColumnData(tableCol, new ColumnWeightData(60, 100, true));
tableCol.setText(Messages.project1);
// Repository
tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
tableCol = tableViewerColumn.getColumn();
layout.setColumnData(tableCol, new ColumnWeightData(26, 80, true));
tableCol.setText(Messages.repository);
tableViewerColumn.setEditingSupport(new InlineComboEditingSupport(tableViewer));
// Bundles
tableViewerColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
tableCol = tableViewerColumn.getColumn();
layout.setColumnData(tableCol, new ColumnWeightData(14, 35, true));
tableCol.setText(Messages.bundles);
contentProvider = new ContentProvider();
tableViewer.setContentProvider(contentProvider);
tableViewer.setLabelProvider(new TableLabelProvider());
tableViewer.setColumnProperties(columnNames);
tableViewer.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
return false;
}
@Override
public boolean isChecked(Object element) {
ProjectDiff diff = (ProjectDiff) element;
return diff.isRelease();
}
});
projects.pack();
TableSortingEnabler.applyTableColumnSorting(tableViewer);
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project tesb-studio-se by Talend.
the class CheckedCamelDependenciesPanel method createTableViewer.
@Override
protected TableViewer createTableViewer() {
final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setCheckStateProvider(checkStateProvider);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (((ManifestItem) event.getElement()).isBuiltIn()) {
viewer.setChecked(event.getElement(), !event.getChecked());
} else {
((ManifestItem) event.getElement()).setOptional(!event.getChecked());
fireDependenciesChangedListener();
}
}
});
return viewer;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer 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);
}
Aggregations