Search in sources :

Example 1 with Collection

use of org.mongodb.meclipse.views.objects.Collection in project meclipse by flaper87.

the class ConnectionEditorCall method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    MeclipseView view = (MeclipseView) page.findView(MeclipseView.ID);
    // Get the selection
    IStructuredSelection selection = (IStructuredSelection) view.getViewer().getSelection();
    if (selection != null && selection instanceof IStructuredSelection) {
        Collection obj = (Collection) selection.getFirstElement();
        // If we had a selection lets open the editor
        if (obj != null) {
            CollectionEditorInput input = new CollectionEditorInput(obj);
            try {
                page.openEditor(input, CollectionEditor.ID);
            } catch (PartInitException e) {
                System.out.println(e.getStackTrace());
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MeclipseView(org.mongodb.meclipse.views.MeclipseView) CollectionEditorInput(org.mongodb.meclipse.editors.CollectionEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Collection(org.mongodb.meclipse.views.objects.Collection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with Collection

use of org.mongodb.meclipse.views.objects.Collection in project meclipse by flaper87.

the class FilterWizard method addFilter.

public void addFilter(ISelection selection, Filter filter) {
    if (selection == null)
        throw new IllegalStateException(getCaption("filterWizard.error.nullSelection"));
    if (!(selection instanceof ITreeSelection))
        throw new IllegalStateException(selection.getClass().getSimpleName() + getCaption("filterWizard.error.noITreeSelection"));
    ITreeSelection treeSelection = (ITreeSelection) selection;
    Object obj = treeSelection.getFirstElement();
    if (!(obj instanceof Collection) && !(obj instanceof Filter))
        throw new IllegalStateException(obj.getClass().getSimpleName() + getCaption("filterWizard.error.noCollection"));
    TreeParent parent = (TreeParent) obj;
    filter.setParent(parent);
    MeclipsePlugin.getDefault().addFilter(new FilterPlacement(parent), filter);
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) Filter(org.mongodb.meclipse.views.objects.Filter) TreeParent(org.mongodb.meclipse.views.objects.TreeParent) FilterPlacement(org.mongodb.meclipse.views.FilterPlacement) Collection(org.mongodb.meclipse.views.objects.Collection)

Aggregations

Collection (org.mongodb.meclipse.views.objects.Collection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 CollectionEditorInput (org.mongodb.meclipse.editors.CollectionEditorInput)1 FilterPlacement (org.mongodb.meclipse.views.FilterPlacement)1 MeclipseView (org.mongodb.meclipse.views.MeclipseView)1 Filter (org.mongodb.meclipse.views.objects.Filter)1 TreeParent (org.mongodb.meclipse.views.objects.TreeParent)1