use of org.eclipse.jface.viewers.SelectionChangedEvent in project knime-core by knime.
the class WorkflowSelectionDialog method createDialogArea.
/**
* {@inheritDoc}
*/
@Override
protected Control createDialogArea(final Composite parent) {
// a tree viewer to select a workflow group or workflow
Group overall = new Group(parent, SWT.SHADOW_ETCHED_IN);
overall.setText("Export selection:");
overall.setLayout(new GridLayout(1, false));
GridData shellLayout = new GridData(GridData.FILL_BOTH);
shellLayout.widthHint = 300;
shellLayout.heightHint = 350;
overall.setLayoutData(shellLayout);
GridData fillBoth = new GridData(GridData.FILL_BOTH);
m_viewer = new TreeViewer(overall, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
m_viewer.getTree().setLayoutData(fillBoth);
m_viewer.setLabelProvider(new KnimeResourceLabelProviderWithRoot());
m_viewer.setContentProvider(new KnimeResourceContentProviderWithRoot());
m_viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
if (element instanceof IWorkspaceRoot) {
return true;
}
IResource resource = null;
if (element instanceof NodeContainer) {
ProjectWorkflowMap.findProjectFor(((NodeContainer) element).getID());
} else if (element instanceof IResource) {
resource = (IResource) element;
}
if (KnimeResourceUtil.isWorkflow(resource)) {
return true;
}
if (KnimeResourceUtil.isWorkflowGroup(resource)) {
return true;
}
return false;
}
});
m_viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
m_viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
m_selectedObjs = (IStructuredSelection) m_viewer.getSelection();
}
});
if (m_initialSelection != null) {
m_viewer.setSelection(m_initialSelection);
}
m_viewer.expandAll();
return overall;
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project bndtools by bndtools.
the class PluginPathPart method createClient.
/**
* Fill the section.
*/
private void createClient(Section section, FormToolkit toolkit) {
section.setText("Plugin Path");
createToolBar(section);
Table table = new Table(section, SWT.BORDER | SWT.FULL_SELECTION);
toolkit.adapt(table);
toolkit.paintBordersFor(table);
section.setClient(table);
viewer = new TableViewer(table);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new PluginPathLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
boolean enable = !viewer.getSelection().isEmpty();
removeItem.setEnabled(enable);
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemove();
} else if (e.character == '+') {
doAdd();
}
}
});
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project bndtools by bndtools.
the class JpmDependencyWizardPage method createControl.
@Override
@SuppressWarnings("unused")
public void createControl(Composite parent) {
// CREATE CONTROLS
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
Label lblDirect = new Label(container, SWT.NONE);
lblDirect.setFont(JFaceResources.getBannerFont());
lblDirect.setText("Direct Dependencies:");
Table tblDirect = new Table(container, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerDirect = new TableViewer(tblDirect);
viewerDirect.setContentProvider(ArrayContentProvider.getInstance());
viewerDirect.setLabelProvider(new ResourceDescriptorLabelProvider());
createHelpLabel(container, "The above dependencies will be added to the project and, if necessary, to the JPM4J local index.");
Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
Label lblIndirect = new Label(container, SWT.NONE);
lblIndirect.setFont(JFaceResources.getBannerFont());
lblIndirect.setText("Transitive Dependencies:");
Composite cmpIndirect = new Composite(container, SWT.NONE);
Table tblIndirect = new Table(cmpIndirect, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerIndirect = new CheckboxTableViewer(tblIndirect);
viewerIndirect.setContentProvider(ArrayContentProvider.getInstance());
viewerIndirect.setLabelProvider(new ResourceDescriptorLabelProvider());
Button btnSelectAll = new Button(cmpIndirect, SWT.PUSH);
btnSelectAll.setText("All");
Button btnSelectNone = new Button(cmpIndirect, SWT.PUSH);
btnSelectNone.setText("None");
new Label(cmpIndirect, SWT.NONE);
createHelpLabel(container, "The above dependencies will be added to the JPM4J local index. Checked dependencies will also be added directly to the project.");
// LISTENERS
// Query JPM and show results *after* dialog is shown. This ensures progress is visible in the dialog's
// progress bar
getContainer().getShell().addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
runQuery();
}
});
viewerIndirect.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent ev) {
if (selectedIndirectResources == null)
selectedIndirectResources = new HashSet<ResourceDescriptor>();
ResourceDescriptor resource = (ResourceDescriptor) ev.getElement();
if (ev.getChecked())
selectedIndirectResources.add(resource);
else
selectedIndirectResources.remove(resource);
}
});
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.addAll(indirectResources);
updateSelectedCheckboxes();
}
});
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.clear();
updateSelectedCheckboxes();
}
});
viewerDirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerIndirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
viewerIndirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerDirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
// LAYOUT
GridLayout layout;
GridData gd;
layout = new GridLayout(1, true);
container.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 30;
tblDirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
separator.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
cmpIndirect.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 2;
cmpIndirect.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.heightHint = 100;
tblIndirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectAll.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectNone.setLayoutData(gd);
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project yamcs-studio by yamcs.
the class ScriptsInputDialog method createScriptsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createScriptsTableViewer(final Composite parent) {
TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
viewer.setContentProvider(new BaseWorkbenchContentProvider() {
@SuppressWarnings("unchecked")
@Override
public Object[] getElements(final Object element) {
return (((List<ScriptData>) element).toArray());
}
});
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
refreshGUIOnSelection();
}
});
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return viewer;
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project yamcs-studio by yamcs.
the class ResourceSelectionGroup method createTreeViewer.
/**
* Returns a new drill down viewer for this dialog.
*
* @param filters
* @param heightHint
* height hint for the drill down composite
*/
protected void createTreeViewer(final String[] filters, final int heightHint) {
// Create drill down.
DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = SIZING_SELECTION_PANE_WIDTH;
gridData.heightHint = heightHint;
drillDown.setLayoutData(gridData);
// Create tree viewer inside drill down.
_treeViewer = new TreeViewer(drillDown, SWT.NONE);
drillDown.setChildTree(_treeViewer);
WorkspaceResourceContentProvider contentProvider = new WorkspaceResourceContentProvider(filters);
contentProvider.showClosedProjects(_showClosedProjects);
_treeViewer.setContentProvider(contentProvider);
_treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
_treeViewer.setSorter(new ViewerSorter());
_treeViewer.setUseHashlookup(true);
_treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null) {
containerSelectionChanged(null);
} else {
containerSelectionChanged((IResource) selection.getFirstElement());
}
if (_newFolderAction != null) {
_newFolderAction.setEnabled(selection != null);
}
}
});
_treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
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 {
_treeViewer.expandToLevel(item, 1);
}
}
}
});
// 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