use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class RevisionSelectionProvider method install.
/**
* Installs the selection provider on the viewer.
*
* @param viewer the viewer on which we listen to for post selection events
*/
void install(ITextViewer viewer) {
uninstall();
fViewer = viewer;
if (fViewer != null) {
ISelectionProvider provider = fViewer.getSelectionProvider();
if (provider instanceof IPostSelectionProvider) {
IPostSelectionProvider postProvider = (IPostSelectionProvider) provider;
fSelectionListener = new PostSelectionListener(postProvider);
}
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class PaintManager method addListeners.
/**
* Installs our listener set on the text viewer and the text widget,
* respectively.
*/
private void addListeners() {
ISelectionProvider provider = fTextViewer.getSelectionProvider();
provider.addSelectionChangedListener(this);
fTextViewer.addTextListener(this);
StyledText text = fTextViewer.getTextWidget();
text.addKeyListener(this);
text.addMouseListener(this);
}
use of org.eclipse.jface.viewers.ISelectionProvider in project knime-core by knime.
the class WorkflowEditor method onF2Pressed.
/**
* Opens editor for (node) annotation (given that a single node or
* annotation is selected).
*/
private void onF2Pressed() {
ISelectionProvider provider = getEditorSite().getSelectionProvider();
if (provider == null) {
return;
}
ISelection sel = provider.getSelection();
if (!(sel instanceof IStructuredSelection)) {
return;
}
Set<AnnotationEditPart> selectedAnnoParts = new HashSet<AnnotationEditPart>();
@SuppressWarnings("rawtypes") Iterator selIter = ((IStructuredSelection) sel).iterator();
while (selIter.hasNext()) {
Object next = selIter.next();
if (next instanceof AnnotationEditPart) {
selectedAnnoParts.add((AnnotationEditPart) next);
} else if (next instanceof NodeContainerEditPart) {
NodeAnnotationEditPart nodeAnnoPart = ((NodeContainerEditPart) next).getNodeAnnotationEditPart();
if (nodeAnnoPart != null) {
selectedAnnoParts.add(nodeAnnoPart);
}
} else {
// unknown type selected
return;
}
}
if (selectedAnnoParts.size() == 1) {
AnnotationEditPart next = selectedAnnoParts.iterator().next();
next.performEdit();
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.
the class CompileHandler method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
List<OracleSourceObject> objects = new ArrayList<>();
IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
if (partSite != null) {
final ISelectionProvider selectionProvider = partSite.getSelectionProvider();
if (selectionProvider != null) {
ISelection selection = selectionProvider.getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
final Object item = iter.next();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(item, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
}
if (objects.isEmpty()) {
final IWorkbenchPart activePart = partSite.getPart();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(activePart, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
if (!objects.isEmpty()) {
if (objects.size() > 1) {
element.setText("Compile " + objects.size() + " objects");
} else {
final OracleSourceObject sourceObject = objects.get(0);
String objectType = TextUtils.formatWord(sourceObject.getSourceType().name());
element.setText("Compile " + objectType);
}
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.
the class AggregateColumnsPanel method refresh.
@Override
public void refresh(boolean force) {
aggregateTable.setRedraw(false);
try {
aggregateTable.removeAll();
if (this.presentation instanceof ISelectionProvider) {
ISelection selection = ((ISelectionProvider) presentation).getSelection();
if (selection instanceof IResultSetSelection) {
aggregateSelection((IResultSetSelection) selection);
}
}
UIUtils.packColumns(aggregateTable, true, null);
} finally {
aggregateTable.setRedraw(true);
}
saveSettings();
}
Aggregations