use of org.eclipse.jface.viewers.CheckStateChangedEvent in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method createTable.
private void createTable(Composite composite) {
hostListView = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
hostListView.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (isExport) {
valid();
}
}
});
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.horizontalSpan = 3;
gdColumnsTable.heightHint = 189;
hostListView.getTable().setLayoutData(gdColumnsTable);
hostListView.getTable().setLinesVisible(true);
hostListView.getTable().setHeaderVisible(true);
final TableColumn hostName = new TableColumn(hostListView.getTable(), SWT.NONE);
hostName.setAlignment(SWT.LEFT);
hostName.setWidth(WIDTH_NAME);
hostName.setText(Messages.columnHeaderServerInfo);
if (isExport) {
hostName.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
} else {
hostName.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
}
hostName.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
selectAll = !selectAll;
hostListView.setAllChecked(selectAll);
Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
hostName.setImage(image);
hostListView.refresh();
if (isExport) {
valid();
}
}
});
final TableColumn hostAddress = new TableColumn(hostListView.getTable(), SWT.NONE);
hostAddress.setAlignment(SWT.CENTER);
hostAddress.setWidth(WIDTH_ADDRESS);
hostAddress.setText(Messages.columnHeaderServerAddress);
final TableColumn hostPort = new TableColumn(hostListView.getTable(), SWT.NONE);
hostPort.setAlignment(SWT.CENTER);
hostPort.setWidth(WIDTH_PORT);
hostPort.setText(Messages.columnHeaderServerPort);
final TableColumn jdbcVer = new TableColumn(hostListView.getTable(), SWT.NONE);
jdbcVer.setAlignment(SWT.CENTER);
jdbcVer.setWidth(WIDTH_JDBC);
jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
final TableColumn hostUser = new TableColumn(hostListView.getTable(), SWT.NONE);
hostUser.setAlignment(SWT.CENTER);
hostUser.setWidth(WIDTH_USER);
hostUser.setText(Messages.columnHeaderServerUserName);
// final TableColumn savedPass = new TableColumn(hostListView.getTable(), SWT.NONE);
// savedPass.setAlignment(SWT.CENTER);
// savedPass.setWidth(WIDTH_SAVEPASS);
// savedPass.setText(Messages.columnHeaderServerAutoSave);
hostListView.setContentProvider(new ServerInfoTableViewerContentProvider());
hostListView.setLabelProvider(new ServerInfoTableViewerLabelProvider());
if (isExport) {
initExportTableData();
}
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project cubrid-manager by CUBRID.
the class LoadDatabaseDialog method createDbUnloadInfoTable.
/**
*
* Create database unload information table
*
* @param parent the parent composite
*/
private void createDbUnloadInfoTable(Composite parent) {
final String[] columnNameArr = new String[] { Messages.tblColumnLoadType, Messages.tblColumnPath, Messages.tblColumnDate };
tableViewer = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(parent, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, 100));
tableViewer.addCheckStateListener(new ICheckStateListener() {
@SuppressWarnings("unchecked")
public void checkStateChanged(CheckStateChangedEvent event) {
Map<String, String> map = (Map<String, String>) event.getElement();
String checkedType = map.get("0");
String checkedPath = map.get("1");
String checkedDate = map.get("2");
if (event.getChecked()) {
for (int i = 0, n = unloadInfoTable.getItemCount(); i < n; i++) {
if (unloadInfoTable.getItem(i).getChecked()) {
String type = unloadInfoTable.getItem(i).getText(0);
String path = unloadInfoTable.getItem(i).getText(1);
String date = unloadInfoTable.getItem(i).getText(2);
if (checkedType.equals(type) && checkedPath.equals(path) && checkedDate.equals(date)) {
continue;
}
if (checkedType.equals(type)) {
unloadInfoTable.getItem(i).setChecked(false);
}
}
}
}
valid();
}
});
unloadInfoTable = tableViewer.getTable();
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project translationstudio8 by heartsome.
the class WizardExportResourcesPage2 method createResourcesGroup.
/**
* Creates the checkbox tree and list for selecting resources.
* @param parent
* the parent control
*/
protected final void createResourcesGroup(Composite parent) {
// create the input element, which has the root resource
// as its only child
List input = new ArrayList();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
if (projects[i].isOpen()) {
input.add(projects[i]);
}
}
this.resourceGroup = new ResourceTreeAndListGroup(parent, input, getResourceProvider(IResource.FOLDER | IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), SWT.NONE, DialogUtil.inRegularFontMode(parent));
ICheckStateListener listener = new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateWidgetEnablements();
}
};
this.resourceGroup.addCheckStateListener(listener);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent 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);
}
Aggregations