use of org.eclipse.jface.viewers.ICheckStateListener in project egit by eclipse.
the class RepositorySearchDialog method createControl.
@Override
public void createControl(Composite parent) {
setMessage(UIText.RepositorySearchDialog_searchRepositoriesMessage);
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(1, false));
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Group searchGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
searchGroup.setText(UIText.RepositorySearchDialog_SearchCriteriaGroup);
searchGroup.setLayout(new GridLayout(4, false));
GridDataFactory.fillDefaults().grab(true, false).minSize(SWT.DEFAULT, SWT.DEFAULT).applyTo(searchGroup);
Label dirLabel = new Label(searchGroup, SWT.NONE);
dirLabel.setText(UIText.RepositorySearchDialog_directory);
dir = new Text(searchGroup, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).hint(300, SWT.DEFAULT).minSize(100, SWT.DEFAULT).applyTo(dir);
dir.setToolTipText(UIText.RepositorySearchDialog_EnterDirectoryToolTip);
String defaultRepoPath = RepositoryUtil.getDefaultRepositoryDir();
String initialPath = prefs.get(PREF_PATH, defaultRepoPath);
dir.setText(initialPath);
Button browse = new Button(searchGroup, SWT.PUSH);
browse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
browse.setText(UIText.RepositorySearchDialog_browse);
browse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(getShell());
dd.setMessage(UIText.RepositorySearchDialog_BrowseDialogMessage);
dd.setFilterPath(dir.getText());
String directory = dd.open();
if (directory != null) {
dir.setText(directory);
prefs.put(PREF_PATH, directory);
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore here
}
doSearch();
}
}
});
searchButton = new Button(searchGroup, SWT.PUSH);
searchButton.setText(UIText.RepositorySearchDialog_Search);
searchButton.setToolTipText(UIText.RepositorySearchDialog_SearchTooltip);
searchButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doSearch();
}
});
lookForNestedButton = new Button(searchGroup, SWT.CHECK);
lookForNestedButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
lookForNestedButton.setSelection(prefs.getBoolean(PREF_DEEP_SEARCH, false));
lookForNestedButton.setText(UIText.RepositorySearchDialog_DeepSearch_button);
lookForNestedButton.setToolTipText(UIText.RepositorySearchDialog_SearchRecursiveToolTip);
lookForNestedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
prefs.putBoolean(PREF_DEEP_SEARCH, lookForNestedButton.getSelection());
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore
}
setNeedsSearch();
}
});
skipHiddenButton = new Button(searchGroup, SWT.CHECK);
skipHiddenButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
skipHiddenButton.setSelection(prefs.getBoolean(PREF_SKIP_HIDDEN, true));
skipHiddenButton.setText(UIText.RepositorySearchDialog_SkipHidden);
skipHiddenButton.setToolTipText(UIText.RepositorySearchDialog_SkipHiddenTooltip);
skipHiddenButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
prefs.putBoolean(PREF_SKIP_HIDDEN, skipHiddenButton.getSelection());
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore
}
setNeedsSearch();
}
});
Group searchResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
searchResultGroup.setText(UIText.RepositorySearchDialog_SearchResultGroup);
searchResultGroup.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 0).applyTo(searchResultGroup);
PatternFilter filter = new PatternFilter() {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
if (getCheckedItems().contains(element)) {
return true;
}
return super.isElementVisible(viewer, element);
}
};
fTree = new FilteredCheckboxTree(searchResultGroup, null, SWT.NONE, filter);
fTreeViewer = fTree.getCheckboxTreeViewer();
fTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
enableOk();
}
});
fTreeViewer.addDoubleClickListener(event -> {
Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
fTreeViewer.setChecked(element, !fTreeViewer.getChecked(element));
enableOk();
});
// Set a reasonable minimum height here; otherwise the dialog comes up
// with a tree that has only a few rows visible.
GridDataFactory.fillDefaults().grab(true, true).minSize(0, 300).applyTo(fTree);
ToolBar toolbar = new ToolBar(searchResultGroup, SWT.FLAT | SWT.VERTICAL);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(toolbar);
checkAllItem = new ToolItem(toolbar, SWT.PUSH);
checkAllItem.setToolTipText(UIText.RepositorySearchDialog_CheckAllRepositories);
checkAllItem.setEnabled(false);
Image checkImage = UIIcons.CHECK_ALL.createImage();
UIUtils.hookDisposal(checkAllItem, checkImage);
checkAllItem.setImage(checkImage);
checkAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fTreeViewer.setAllChecked(true);
enableOk();
}
});
uncheckAllItem = new ToolItem(toolbar, SWT.PUSH);
uncheckAllItem.setToolTipText(UIText.RepositorySearchDialog_UncheckAllRepositories);
uncheckAllItem.setEnabled(false);
Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
uncheckAllItem.setImage(uncheckImage);
uncheckAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fTreeViewer.setAllChecked(false);
enableOk();
}
});
// TODO this isn't the most optimal way of handling this... ideally we
// should have some type of delay
// if we could use databinding an observeDelayedValue would totally work
// here
dir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setNeedsSearch();
}
});
fTreeViewer.setContentProvider(new ContentProvider());
fTreeViewer.setLabelProvider(new RepositoryLabelProvider());
setControl(main);
enableOk();
if (fillSearch)
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!getControl().isDisposed())
doSearch();
}
});
}
use of org.eclipse.jface.viewers.ICheckStateListener in project tdq-studio-se by Talend.
the class TablesSelectionDialog method addCheckedListener.
@Override
protected void addCheckedListener() {
// When user checks a checkbox in the tree, check all its children
getTreeViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
TreePath treePath = new TreePath(new Object[] { event.getElement() });
getTreeViewer().setSelection(new TreeSelection(treePath));
if (event.getChecked()) {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, true);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, true);
}
} else {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, false);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, false);
}
}
updateOKStatus();
}
});
getTableViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof DBTableRepNode || element instanceof DBViewRepNode) {
handleTableChecked((IRepositoryNode) element, event.getChecked());
}
}
});
}
use of org.eclipse.jface.viewers.ICheckStateListener in project tdq-studio-se by Talend.
the class AbstractJarSelectDialog method createManageTreeViewer.
/**
* DOC msjian Comment method "createManageTreeViewer".
*
* @param parent
* @return
*/
protected CheckboxTreeViewer createManageTreeViewer(Composite parent) {
if (fContainerMode) {
fManageViewer = new ContainerCheckedTreeViewer(parent, SWT.BORDER);
} else {
fManageViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
}
fManageViewer.setContentProvider(fContentProvider);
fManageViewer.setLabelProvider(fLabelProvider);
fManageViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
}
});
fManageViewer.setComparator(fComparator);
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++) {
fManageViewer.addFilter((ViewerFilter) fFilters.get(i));
}
}
fManageViewer.setInput(fInput);
return fManageViewer;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project tdq-studio-se by Talend.
the class ColumnsSelectionDialog method addCheckedListener.
/*
* (non-Javadoc)
*
* @seeorg.talend.dataprofiler.core.ui.dialog.TwoPartCheckSelectionDialog# addCheckedListener()
*/
@Override
protected void addCheckedListener() {
// When user checks a checkbox in the tree, check all its children
getTreeViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// Added TDQ-8718 20140506 yyin: should not load from db when checking
DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
try {
ColumnSelectionViewer columnViewer = (ColumnSelectionViewer) event.getSource();
TreePath treePath = new TreePath(new Object[] { event.getElement() });
columnViewer.setSelection(new TreeSelection(treePath));
setOutput(event.getElement());
RepositoryNode selectedNode = (RepositoryNode) event.getElement();
if (selectedNode instanceof DBTableRepNode || selectedNode instanceof DBViewRepNode || selectedNode instanceof DFTableRepNode) {
handleTreeElementsChecked(selectedNode, event.getChecked());
} else {
checkChildrenElements(selectedNode, event.getChecked());
}
getTreeViewer().setSubtreeChecked(event.getElement(), event.getChecked());
updateStatusBySelection();
} finally {
// Added TDQ-8718 20140506 yyin
DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
}
}
private void checkChildrenElements(RepositoryNode repNode, Boolean checkedFlag) {
Set<?> keySet = modelElementCheckedMap.keySet();
RepositoryNode[] repNodeArray = (RepositoryNode[]) modelElementCheckedMap.keySet().toArray(new RepositoryNode[keySet.size()]);
for (RepositoryNode reposNode : repNodeArray) {
RepositoryNode parentNode = reposNode.getParent();
while (parentNode != null) {
if (repNode.equals(parentNode)) {
handleTreeElementsChecked(reposNode, checkedFlag);
break;
} else {
parentNode = parentNode.getParent();
}
}
}
}
});
getTableViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
handleTableElementsChecked((RepositoryNode) event.getElement(), event.getChecked());
updateStatusBySelection();
}
});
}
use of org.eclipse.jface.viewers.ICheckStateListener in project tdq-studio-se by Talend.
the class TwoPartCheckSelectionDialog method createFirstPart.
/**
* Creates the tree viewer.
*
* @param parent the parent composite
* @return the tree viewer
*/
protected CheckboxTreeViewer createFirstPart(Composite parent) {
if (fContainerMode) {
if (DIALOG_TYPE_TABLE == this.getDialogType()) {
fViewer = new TableSelectionViewer(parent, SWT.BORDER);
} else if (!this.addConnFilter) {
fViewer = new MatchColumnSelectionViewer(parent, SWT.BORDER);
} else {
fViewer = new ColumnSelectionViewer(parent, SWT.BORDER);
}
// {
//
// protected void handleTreeExpand(TreeEvent event) {
// super.handleTreeExpand(event);
// checkElementChecked();
// }
// };
} else {
fViewer = new CheckboxTreeViewer(parent, SWT.BORDER) {
@Override
protected void handleTreeExpand(TreeEvent event) {
super.handleTreeExpand(event);
// checkElementChecked();
}
};
}
fViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
applyDialogFont(fViewer.getTree());
fViewer.setContentProvider(fContentProvider);
// mod gdbu 2011-7-25 bug 23220
((ResourceViewContentProvider) fContentProvider).setTreeViewer(fViewer);
// ~23220
fViewer.setLabelProvider(fLabelProvider);
fViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
}
});
fViewer.setComparator(fComparator);
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++) {
fViewer.addFilter(fFilters.get(i));
}
}
fViewer.setInput(fInput);
// fViewer.
fViewer.addSelectionChangedListener(this);
return fViewer;
}
Aggregations