use of org.eclipse.jface.viewers.IOpenListener in project tdi-studio-se by Talend.
the class AbstractFilteredTree method addListeners.
/**
* Adds the listeners.
*/
private void addListeners() {
TreeViewer viewer = getViewer();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
openAction.selectionChanged(event);
copyAction.selectionChanged(event);
}
});
viewer.addSelectionChangedListener(showCallersCalleesAction);
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
openAction.run();
}
});
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class TestSuiteLabelProvider method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText(Messages.TestSuitesPart_section_junit_tests);
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
// Section toolbar buttons
ToolBar toolbar = new ToolBar(section, SWT.FLAT);
section.setTextClient(toolbar);
final ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
addItem.setToolTipText(Messages.TestSuitesPart_add);
final ToolItem removeItem = new ToolItem(toolbar, SWT.PUSH);
removeItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
removeItem.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
removeItem.setToolTipText(Messages.TestSuitesPart_remove);
removeItem.setEnabled(false);
Table table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new TestSuiteLabelProvider());
toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
final ToolItem btnMoveUp = new ToolItem(toolbar, SWT.PUSH);
btnMoveUp.setText("Up");
btnMoveUp.setImage(imgUp);
btnMoveUp.setEnabled(false);
final ToolItem btnMoveDown = new ToolItem(toolbar, SWT.PUSH);
btnMoveDown.setText("Down");
btnMoveDown.setImage(imgDown);
btnMoveDown.setEnabled(false);
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
boolean enabled = selection != null && !selection.isEmpty();
removeItem.setEnabled(enabled);
btnMoveUp.setEnabled(enabled);
btnMoveDown.setEnabled(enabled);
getManagedForm().fireSelectionChanged(TestSuitesPart.this, selection);
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
String name = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (name != null)
doOpenSource(name);
}
});
viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ResourceTransfer.getInstance() }, new TestSuiteListDropAdapter());
addItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAdd();
}
});
removeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRemove();
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemove();
} else if (e.character == '+') {
doAdd();
}
}
});
btnMoveUp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveUp();
}
});
btnMoveDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveDown();
}
});
// Layout
GridLayout layout;
layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
// gd.widthHint = 75;
gd.heightHint = 75;
table.setLayoutData(gd);
toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class LocalRepositorySelectionPage method createControl.
public void createControl(Composite parent) {
setTitle("Select Local Repository");
setMessage("Bundle will be imported into the selected repository.");
Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
final TableViewer viewer = new TableViewer(table);
viewer.setContentProvider(new RepositoryTreeContentProvider());
viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
}
} });
try {
Workspace workspace = Central.getWorkspace();
viewer.setInput(workspace);
if (selectedRepository != null)
viewer.setSelection(new StructuredSelection(selectedRepository));
validate(workspace);
} catch (Exception e) {
logger.logError("Error querying local repositories", e);
setErrorMessage("Error querying local repositories, see log for details.");
}
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
}
});
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent evt) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
IWizardPage nextPage = getNextPage();
if (nextPage != null)
getContainer().showPage(nextPage);
}
});
setControl(table);
}
use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class MapValuesContentProvider method createAvailableBundlesPanel.
Control createAvailableBundlesPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
new Label(panel, SWT.NONE).setText("Available Bundles:");
selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
selectionSearchTxt.setMessage("filter bundle name");
final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
availableViewer = new TreeViewer(availableTree);
availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
availableViewer.setContentProvider(new RepositoryTreeContentProvider());
availableViewer.setAutoExpandLevel(2);
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
// Load data
try {
refreshBundleList();
} catch (Exception e) {
setErrorMessage("Error querying repositories: " + e.getMessage());
logger.logError("Error querying repository configuration.", e);
}
// Listeners
selectionSearchTxt.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN)
availableTree.setFocus();
}
});
selectionSearchTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
}
});
availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// Enable add button when a bundle or bundle version is selected on
// the left
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
addButton.setEnabled(true);
return;
}
}
addButton.setEnabled(false);
}
});
availableViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doAdd();
}
});
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
panel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
selectionSearchTxt.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 300;
gd.widthHint = 250;
availableTree.setLayoutData(gd);
return panel;
}
use of org.eclipse.jface.viewers.IOpenListener in project tdi-studio-se by Talend.
the class HeapHistogramPage method createContextMenu.
/**
* Creates the context menu.
*
* @param actionBars The action bars
*/
private void createContextMenu(IActionBars actionBars) {
final OpenDeclarationAction openAction = OpenDeclarationAction.createOpenDeclarationAction(actionBars);
final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
configureColumnsAction = new ConfigureColumnsAction(this);
heapViewer.addSelectionChangedListener(openAction);
heapViewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
heapViewer.removeSelectionChangedListener(copyAction);
}
@Override
public void focusGained(FocusEvent e) {
heapViewer.addSelectionChangedListener(copyAction);
}
});
heapViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
openAction.run();
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.add(openAction);
manager.add(copyAction);
manager.add(new Separator());
manager.add(configureColumnsAction);
}
});
Menu menu = menuMgr.createContextMenu(heapViewer.getControl());
heapViewer.getControl().setMenu(menu);
}
Aggregations