use of org.eclipse.jface.viewers.IDoubleClickListener in project yamcs-studio by yamcs.
the class WidgetsSelectDialog method createWidgetsViewer.
private TableViewer createWidgetsViewer(Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WidgetsListLableProvider());
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
selectedWidget = (String) ((StructuredSelection) viewer.getSelection()).getFirstElement();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
return viewer;
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project yamcs-studio by yamcs.
the class ResourceSelectionGroup method createTreeViewer.
/**
* Returns a new drill down viewer for this dialog.
*
* @param fileExtensions
* The file extensions of files to include in the tree.
* @param heightHint
* height hint for the drill down composite
*/
protected void createTreeViewer(final String[] fileExtensions, final int heightHint) {
// Create drill down.
DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true);
spec.widthHint = SIZING_SELECTION_PANE_WIDTH;
spec.heightHint = heightHint;
drillDown.setLayoutData(spec);
// Create tree viewer inside drill down.
_treeViewer = new TreeViewer(drillDown, SWT.NONE);
drillDown.setChildTree(_treeViewer);
WorkspaceResourceContentProvider cp = new WorkspaceResourceContentProvider(fileExtensions);
cp.showClosedProjects(_showClosedProjects);
_treeViewer.setContentProvider(cp);
_treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
_treeViewer.setSorter(new ViewerSorter());
_treeViewer.setUseHashlookup(true);
_treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
containerSelectionChanged((IResource) selection.getFirstElement());
if (_newFolderAction != null) {
_newFolderAction.setEnabled(selection != null);
}
}
});
_treeViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(final DoubleClickEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object item = ((IStructuredSelection) selection).getFirstElement();
if (item == null) {
return;
}
if (_treeViewer.getExpandedState(item)) {
_treeViewer.collapseToLevel(item, 1);
} else if (_treeViewer.isExpandable(item)) {
_treeViewer.expandToLevel(item, 1);
} else if (!(item instanceof IContainer))
itemDoubleClicked((IResource) item);
}
}
});
// This has to be done after the viewer has been laid out
_treeViewer.setInput(ResourcesPlugin.getWorkspace());
this.addNewContainerActions(drillDown.getToolBarManager());
this.addPopupMenu(_treeViewer);
this.setDefaultSelection(_treeViewer);
}
Aggregations