use of org.eclipse.jface.viewers.CheckboxTreeViewer in project tdi-studio-se by Talend.
the class UpdateDetectionDialog method createTreeTableView.
/**
* create table view.
*/
private Composite createTreeTableView(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
int style = SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
if (!isOnlySimpleShow()) {
// display check button.
style = SWT.CHECK | style;
}
viewer = new CheckboxTreeViewer(new Tree(composite, style));
viewer.setContentProvider(new UpdateContentProvider());
viewer.setLabelProvider(new UpdateLabelProvider());
viewer.setSorter(new UpdateViewerSorter());
viewer.setInput(getInputElements());
// viewer.setColumnProperties(new String[] { ITEMS, OPERATIONS, REMARKS });
// viewer.setCellEditors(new CellEditor[] { null, null, null });
// viewer.setCellModifier(new UpdateCellModifier());
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
addViewerListener();
createColumns(tree);
return composite;
}
use of org.eclipse.jface.viewers.CheckboxTreeViewer in project cubrid-manager by CUBRID.
the class FilterSettingDialog method createTreeComposite.
/**
*
* Create the tree composite
*
* @param parent Composite
*/
private void createTreeComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
composite.setLayout(layout);
Label label = new Label(composite, SWT.LEFT);
label.setText(Messages.lblTreeFilter);
label.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
ctv = new CheckboxTreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
ctv.getControl().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 300));
ctv.setContentProvider(new FilterTreeContentProvider());
ctv.setLabelProvider(tv.getLabelProvider(0));
ctv.setInput(tv.getInput());
ctv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ctv.setSubtreeChecked(event.getElement(), event.getChecked());
ctv.setGrayChecked(event.getElement(), false);
ctv.setChecked(event.getElement(), event.getChecked());
if (event.getElement() instanceof ICubridNode) {
ICubridNode node = (ICubridNode) event.getElement();
ICubridNode parent = node.getParent();
setParentStatus(parent);
}
}
/**
*
* Set parent element status
*
* @param parent ICubridNode
*/
private void setParentStatus(ICubridNode parent) {
if (parent == null) {
return;
}
int state = getAllChildrenCheckedState(parent);
if (state == -1) {
ctv.setGrayChecked(parent, false);
ctv.setChecked(parent, false);
} else if (state == 1 || state == 0) {
ctv.setChecked(parent, false);
ctv.setGrayChecked(parent, true);
}
setParentStatus(parent.getParent());
}
/**
*
* Return checked children element status
*
* @param parent ICubridNode
* @return int <code>-1</code>all is not checked;<code>1</code>all
* is checked;<code>0</code> some is checked,others is not
* checked
*/
private int getAllChildrenCheckedState(ICubridNode parent) {
List<ICubridNode> childrenList = parent.getChildren();
boolean isAllChecked = true;
boolean isHasChecked = false;
for (ICubridNode node : childrenList) {
if (ctv.getGrayed(node)) {
isAllChecked = false;
isHasChecked = true;
} else if (ctv.getChecked(node)) {
isHasChecked = true;
} else {
isAllChecked = false;
}
}
if (!isHasChecked) {
return -1;
}
if (isAllChecked) {
return 1;
}
return 0;
}
});
Composite btnComposite = new Composite(composite, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.marginRight = 10;
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.END;
gridData.verticalAlignment = GridData.CENTER;
gridData.grabExcessHorizontalSpace = true;
btnComposite.setLayoutData(gridData);
btnComposite.setLayout(gridLayout);
Button restoreBtn = new Button(btnComposite, SWT.PUSH);
restoreBtn.setText(Messages.btnRest);
restoreBtn.setLayoutData(CommonUITool.createGridData(GridData.END, 1, 1, -1, -1));
restoreBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ctv.setCheckedElements(defaultCheckedList.toArray());
for (ICubridNode node : defaultGrayCheckedList) {
ctv.setGrayChecked(node, true);
}
}
});
}
use of org.eclipse.jface.viewers.CheckboxTreeViewer in project cubrid-manager by CUBRID.
the class ExportSettingForLoadDBPage method createControl.
/**
* Create the page content
*
* @param parent Composite
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout());
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(45, 0);
leftComposite.setLayoutData(leftData);
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(45, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Label tableInfoLabel = new Label(leftComposite, SWT.None);
tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
ctv = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ctv.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
ctv.setContentProvider(new FilterTreeContentProvider());
ctv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateDialogStatus();
}
});
final TreeViewerColumn dbObjectCol = new TreeViewerColumn(ctv, SWT.NONE);
dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
final TreeViewerColumn whereCnd = new TreeViewerColumn(ctv, SWT.NONE);
whereCnd.setLabelProvider(new ExportObjectLabelProvider());
whereCnd.setEditingSupport(new EditingSupport(ctv) {
TextCellEditor textCellEditor;
protected boolean canEdit(Object element) {
if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
return true;
}
}
return false;
}
protected CellEditor getCellEditor(Object element) {
if (textCellEditor == null) {
textCellEditor = new TextCellEditor(ctv.getTree());
}
return textCellEditor;
}
protected Object getValue(Object element) {
final ICubridNode node = (ICubridNode) element;
String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
if (condition == null) {
return "";
} else {
return condition;
}
}
protected void setValue(Object element, Object value) {
final ICubridNode node = (ICubridNode) element;
node.setData(ExportObjectLabelProvider.CONDITION, value);
ctv.refresh();
}
});
dbObjectCol.getColumn().setWidth(160);
dbObjectCol.getColumn().setText(Messages.tableLabel);
whereCnd.getColumn().setWidth(120);
whereCnd.getColumn().setText(Messages.conditionLabel);
final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
{
selectAllBtn.setText(Messages.btnSelectAll);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 3;
selectAllBtn.setLayoutData(gridData);
}
selectAllBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
boolean selection = selectAllBtn.getSelection();
for (ICubridNode node : tablesOrViewLst) {
ctv.setGrayed(node, false);
ctv.setChecked(node, selection);
}
updateDialogStatus();
}
});
Group fileOptionGroup = new Group(rightComposite, SWT.None);
fileOptionGroup.setText(Messages.exportWizardWhereExport);
fileOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
fileOptionGroup.setLayout(new GridLayout(3, false));
schemaButton = new Button(fileOptionGroup, SWT.CHECK);
schemaButton.setText("Schema");
schemaButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
schemaButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (schemaButton.getSelection()) {
schemaPathText.setEnabled(true);
schemaBrowseButton.setEnabled(true);
startValueButton.setEnabled(true);
} else {
schemaPathText.setEnabled(false);
schemaBrowseButton.setEnabled(false);
startValueButton.setEnabled(false);
}
updateDialogStatus();
}
});
schemaPathText = new Text(fileOptionGroup, SWT.BORDER);
schemaPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
schemaPathText.setEnabled(true);
schemaPathText.setEditable(false);
schemaPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
schemaBrowseButton = new Button(fileOptionGroup, SWT.None);
schemaBrowseButton.setText(Messages.btnBrowse);
schemaBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
schemaBrowseButton.setEnabled(true);
schemaBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbSchema = databaseName + "_schema";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbSchema, null, null);
if (savedFile != null) {
schemaPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
indexButton = new Button(fileOptionGroup, SWT.CHECK);
indexButton.setText("Index");
indexButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
indexButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (indexButton.getSelection()) {
indexPathText.setEnabled(true);
indexBrowseButton.setEnabled(true);
} else {
indexPathText.setEnabled(false);
indexBrowseButton.setEnabled(false);
}
updateDialogStatus();
}
});
indexPathText = new Text(fileOptionGroup, SWT.BORDER);
indexPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
indexPathText.setEnabled(true);
indexPathText.setEditable(false);
indexPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
indexBrowseButton = new Button(fileOptionGroup, SWT.None);
indexBrowseButton.setText(Messages.btnBrowse);
indexBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
indexBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbIndex = databaseName + "_indexes";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbIndex, null, null);
if (savedFile != null) {
indexPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
dataButton = new Button(fileOptionGroup, SWT.CHECK);
dataButton.setText("Data");
dataButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dataButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (dataButton.getSelection()) {
dataPathText.setEnabled(true);
dataBrowseButton.setEnabled(true);
} else {
dataPathText.setEnabled(false);
dataBrowseButton.setEnabled(false);
}
updateDialogStatus();
}
});
dataPathText = new Text(fileOptionGroup, SWT.BORDER);
dataPathText.setEditable(false);
dataPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
dataPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
dataBrowseButton = new Button(fileOptionGroup, SWT.None);
dataBrowseButton.setText(Messages.btnBrowse);
dataBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dataBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
String databaseName = databaseInfo.getDbName();
String fileNameForLoaddbData = databaseName + "_objects";
File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbData, null, null);
if (savedFile != null) {
dataPathText.setText(savedFile.getAbsolutePath());
}
updateDialogStatus();
}
});
Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
enCodingOptionGroup.setText(Messages.exportWizardDataOption);
enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
enCodingOptionGroup.setLayout(new GridLayout(4, false));
Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblJDBCCharset);
dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus();
}
});
startValueButton = new Button(enCodingOptionGroup, SWT.CHECK);
startValueButton.setText(Messages.lblExportTargetStartValue);
startValueButton.setLayoutData(CommonUITool.createGridData(4, 1, -1, -1));
startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
setControl(container);
}
use of org.eclipse.jface.viewers.CheckboxTreeViewer 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);
}
use of org.eclipse.jface.viewers.CheckboxTreeViewer in project dbeaver by serge-rider.
the class DiagramCreateWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
Composite configGroup = UIUtils.createControlGroup(placeholder, ERDMessages.wizard_page_diagram_create_group_settings, 2, GridData.FILL_BOTH, 0);
//$NON-NLS-1$
final Text projectNameText = UIUtils.createLabelText(configGroup, "Name", null);
projectNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
diagram.setName(projectNameText.getText());
updateState();
}
});
Label contentLabel = UIUtils.createControlLabel(configGroup, ERDMessages.wizard_page_diagram_create_label_init_content);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 2;
contentLabel.setLayoutData(gd);
final DBNProject rootNode = DBeaverCore.getInstance().getNavigatorModel().getRoot().getProject(DBeaverCore.getInstance().getProjectRegistry().getActiveProject());
if (rootNode == null) {
setControl(placeholder);
return;
}
contentTree = new DatabaseNavigatorTree(configGroup, rootNode.getDatabases(), SWT.SINGLE | SWT.CHECK);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
gd.heightHint = 400;
contentTree.setLayoutData(gd);
CheckboxTreeViewer viewer = (CheckboxTreeViewer) contentTree.getViewer();
viewer.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isChecked(Object element) {
return false;
}
@Override
public boolean isGrayed(Object element) {
if (element instanceof DBNDatabaseNode && !(element instanceof DBNDataSource)) {
DBSObject object = ((DBNDatabaseNode) element).getObject();
if (object instanceof DBSTable) {
return false;
}
}
return true;
}
});
setControl(placeholder);
}
Aggregations