use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent 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.CheckStateChangedEvent in project applause by applause.
the class GeneratorFragmentSelectionWizardPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(1, false));
checkboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.FULL_SELECTION);
table = checkboxTableViewer.getTable();
GridData gd_table = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
gd_table.heightHint = 272;
gd_table.widthHint = 581;
table.setLayoutData(gd_table);
checkboxTableViewer.setLabelProvider(new TableLabelProvider());
checkboxTableViewer.setContentProvider(new ArrayContentProvider());
checkboxTableViewer.setInput(BuildStrategyRegistry.getSupportedMobilePlatforms());
checkboxTableViewer.addCheckStateListener((new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
validatePage();
}
}));
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
* .lang.Object)
*/
public Object[] getChildren(Object parentElement) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
* .lang.Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
* .lang.Object)
*/
public Object getParent(Object element) {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
* (org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts) {
projectsList.setChecked(element, false);
}
setPageComplete(projectsList.getCheckedElements().length > 0);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
Aggregations