use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.
the class AggregateColumnsPanel method createContents.
@Override
public Control createContents(final IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
this.panelSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_AGGREGATE);
loadSettings();
this.aggregateTable = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION);
this.aggregateTable.setHeaderVisible(true);
this.aggregateTable.setLinesVisible(true);
new TreeColumn(this.aggregateTable, SWT.LEFT).setText("Function");
new TreeColumn(this.aggregateTable, SWT.RIGHT).setText("Value");
if (this.presentation instanceof ISelectionProvider) {
((ISelectionProvider) this.presentation).addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (presentation.getController().getVisiblePanel() == AggregateColumnsPanel.this) {
refresh(false);
}
}
});
}
MenuManager menuMgr = new MenuManager();
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.add(new CopyAction());
manager.add(new CopyAllAction());
manager.add(new Separator());
fillToolBar(manager);
}
});
menuMgr.setRemoveAllWhenShown(true);
this.aggregateTable.setMenu(menuMgr.createContextMenu(this.aggregateTable));
aggregateTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
presentation.getController().updatePanelActions();
}
});
return this.aggregateTable;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project erlide_eclipse by erlang.
the class MarkOccurencesSupport method installOccurrencesFinder.
protected void installOccurrencesFinder(final boolean forceUpdate) {
fMarkOccurrenceAnnotations = true;
fPostSelectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) selection, editor.getModule());
}
};
final ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider != null) {
((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fPostSelectionListener);
if (forceUpdate) {
fForcedMarkOccurrencesSelection = selectionProvider.getSelection();
final IErlModule module = editor.getModule();
if (module != null) {
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, module);
}
}
}
if (fOccurrencesFinderJobCanceler == null) {
fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
fOccurrencesFinderJobCanceler.install();
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project erlide_eclipse by erlang.
the class ImplementorsSearchGroup method dispose.
/*
* Overrides method declared in ActionGroup
*/
@Override
public void dispose() {
final ISelectionProvider provider = fSite.getSelectionProvider();
if (provider != null) {
disposeAction(fFindImplementorsAction, provider);
disposeAction(fFindImplementorsInProjectAction, provider);
disposeAction(fFindImplementorsInWorkingSetAction, provider);
}
fFindImplementorsAction = null;
fFindImplementorsInProjectAction = null;
fFindImplementorsInWorkingSetAction = null;
updateGlobalActionHandlers();
super.dispose();
}
use of org.eclipse.jface.viewers.ISelectionProvider in project liferay-ide by liferay.
the class KaleoContentAssistProcessor method _addProposals.
private void _addProposals(ContentAssistRequest request, KaleoTemplateContext context) {
ISelectionProvider selectionProvider = _sourceViewer.getSelectionProvider();
ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
int offset = request.getReplacementBeginPosition();
if (selection.getOffset() == offset) {
offset = selection.getOffset() + selection.getLength();
}
String prefix = extractPrefix(_sourceViewer, offset);
_addProposals(request, context, _getCurrentNode(request), prefix);
}
use of org.eclipse.jface.viewers.ISelectionProvider in project liferay-ide by liferay.
the class AddMacroLibrary method run.
public void run(IAction action) {
ISelectionProvider provider = part.getSite().getSelectionProvider();
if (null != provider) {
if (provider.getSelection() instanceof IStructuredSelection) {
try {
IStructuredSelection selection = (IStructuredSelection) provider.getSelection();
Object[] obj = selection.toArray();
List documents = new ArrayList();
for (int i = 0; i < obj.length; i++) {
if (obj[i] instanceof IFile) {
IFile file = (IFile) obj[i];
documents.add(file);
} else if (obj[i] instanceof JarEntryFile) {
JarEntryFile jef = (JarEntryFile) obj[i];
documents.add(jef);
System.out.println(jef.getFullPath().makeAbsolute());
System.out.println(jef.getFullPath().makeRelative());
IPath path = jef.getFullPath();
System.out.println(path);
System.out.println(jef.getName());
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(jef.getFullPath());
System.out.println(resource);
} else if (obj[i] instanceof IStorage) {
}
}
IProject project = null;
if (documents.size() > 0) {
// what project?
HashSet projects = new HashSet();
IProject[] p = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < p.length; i++) {
projects.add(p[i]);
}
ProjectSelectionDialog dialog = new ProjectSelectionDialog(Display.getCurrent().getActiveShell(), projects);
dialog.setTitle(Messages.AddMacroLibrary_Title);
dialog.setMessage(Messages.AddMacroLibrary_Message);
int rtn = dialog.open();
if (rtn == IDialogConstants.OK_ID) {
if (dialog.getFirstResult() instanceof IJavaProject) {
project = ((IJavaProject) dialog.getFirstResult()).getProject();
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.AddMacroLibrary_Error, Messages.AddMacroLibrary_ErrorDesc);
}
}
}
if (null != project) {
ConfigurationManager.getInstance(project).associateMappingLibraries(documents, Display.getCurrent().getActiveShell());
}
} catch (Exception e) {
Plugin.error(e);
}
}
}
}
Aggregations