Example usage for org.eclipse.jface.viewers StructuredSelection EMPTY

List of usage examples for org.eclipse.jface.viewers StructuredSelection EMPTY

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection EMPTY.

Prototype

StructuredSelection EMPTY

To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.

Click Source Link

Document

The canonical empty selection.

Usage

From source file:com.nokia.tools.variant.common.ui.views.GenericPageBookView.java

License:Open Source License

/**
 * The <code>ContentOutline</code> implementation of this
 * <code>PageBookView</code> method extends the behavior of its parent to
 * use the current page as a selection provider.
 * /*from   w  w  w  .  ja va  2s  . c o  m*/
 * @param pageRec
 *            the page record containing the page to show
 */
protected void showPageRec(PageRec pageRec) {
    IPage current = getCurrentPage();
    IPage newPage = pageRec.page;

    if (current != newPage && current instanceof ISelectionListener) {
        ((ISelectionListener) current).selectionChanged(lastSelectionSource, StructuredSelection.EMPTY);
    }

    super.showPageRec(pageRec);

    if (current != newPage && newPage instanceof ISelectionListener) {
        ((ISelectionListener) newPage).selectionChanged(lastSelectionSource, lastSelection);
    }
}

From source file:com.nokia.tools.variant.confml.ui.editors.CompositeSelectionProvider.java

License:Open Source License

public ISelection getSelection() {
    if (lastSelectedViewer == null) {
        return StructuredSelection.EMPTY;
    }
    return lastSelectedViewer.getSelection();
}

From source file:com.nokia.tools.variant.confml.ui.popup.actions.NewConfiguration.java

License:Open Source License

public void run(IAction action) {
    IWorkbench workbench;//from w  w w. j  a va2 s  .co m
    IStructuredSelection ss;
    Shell shell;
    if (workbenchWindow != null) {
        workbench = workbenchWindow.getWorkbench();
        selection = workbenchWindow.getSelectionService().getSelection();
        shell = workbenchWindow.getShell();
    } else if (workbenchPart != null) {
        workbench = workbenchPart.getSite().getWorkbenchWindow().getWorkbench();
        shell = workbenchPart.getSite().getShell();
    } else {
        throw new IllegalStateException();
    }

    if (selection instanceof IStructuredSelection) {
        ss = (IStructuredSelection) selection;
    } else {
        ss = StructuredSelection.EMPTY;
    }
    NewConfigurationWizard wizard = new NewConfigurationWizard();
    wizard.init(workbench, ss);

    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.open();
}

From source file:com.nokia.tools.variant.confml.ui.popup.actions.NewConfigurationFileAction.java

License:Open Source License

public void run(IAction action) {

    IWorkbench workbench;/* w  w w  .  ja v  a  2s . co m*/
    IStructuredSelection ss;
    Shell shell;
    if (workbenchWindow != null) {
        // IWorkbenchWindowActionDelegate
        shell = workbenchWindow.getShell();
        workbench = workbenchWindow.getWorkbench();
        selection = workbenchWindow.getSelectionService().getSelection();
    } else if (workbenchPart != null) {
        // IObjectActionDelegate
        shell = workbenchPart.getSite().getShell();
        workbench = workbenchPart.getSite().getWorkbenchWindow().getWorkbench();
    } else {
        throw new IllegalStateException();
    }

    if (selection instanceof IStructuredSelection) {
        ss = (IStructuredSelection) selection;
    } else {
        ss = StructuredSelection.EMPTY;
    }

    NewConfMLWizard newConfMLWizard = new NewConfMLWizard();
    newConfMLWizard.init(workbench, ss);

    WizardDialog dialog = new WizardDialog(shell, newConfMLWizard);
    dialog.create();
    dialog.open();
}

From source file:com.nokia.tools.variant.confml.ui.popup.actions.NewConfigurationLayer.java

License:Open Source License

public void run(IAction action) {
    IWorkbench workbench;//from  w w w . j  a v a  2  s  . c  om
    IStructuredSelection ss;
    Shell shell;
    if (workbenchWindow != null) {
        workbench = workbenchWindow.getWorkbench();
        selection = workbenchWindow.getSelectionService().getSelection();
        shell = workbenchWindow.getShell();
    } else if (workbenchPart != null) {
        workbench = workbenchPart.getSite().getWorkbenchWindow().getWorkbench();
        shell = workbenchPart.getSite().getShell();
    } else {
        throw new IllegalStateException();
    }

    if (selection instanceof IStructuredSelection) {
        ss = (IStructuredSelection) selection;
    } else {
        ss = StructuredSelection.EMPTY;
    }
    NewConfigurationLayerWizard wizard = new NewConfigurationLayerWizard();
    wizard.init(workbench, ss);

    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.open();
}

From source file:com.nokia.tools.variant.confml.ui.popup.actions.NewConfigurationProjectAction.java

License:Open Source License

public void run(IAction action) {
    IWorkbench workbench;/*from   w w w . j a v  a 2s  . c o  m*/
    IStructuredSelection ss;
    Shell shell;
    if (workbenchPart != null) {
        shell = workbenchPart.getSite().getShell();
        workbench = workbenchPart.getSite().getWorkbenchWindow().getWorkbench();
    } else if (workbenchWindow != null) {
        workbench = workbenchWindow.getWorkbench();
        shell = workbenchWindow.getShell();
        this.selection = workbenchWindow.getSelectionService().getSelection();
    } else {
        throw new IllegalStateException();
    }

    if (selection instanceof IStructuredSelection) {
        ss = (IStructuredSelection) selection;
    } else {
        ss = StructuredSelection.EMPTY;
    }
    NewConfigurationProjectWizard wizard = new NewConfigurationProjectWizard();
    wizard.init(workbench, ss);

    WizardDialog dialog = new WizardDialog(shell, (IWizard) wizard);
    dialog.create();
    dialog.open();
}

From source file:com.nokia.tools.variant.confml.ui.popup.actions.NewImplMLFileAction.java

License:Open Source License

public void run(IAction action) {

    IWorkbench workbench;//from  w  w w. j av  a2 s. c om
    IStructuredSelection ss;
    Shell shell;
    if (workbenchWindow != null) {
        // IWorkbenchWindowActionDelegate
        shell = workbenchWindow.getShell();
        workbench = workbenchWindow.getWorkbench();
        selection = workbenchWindow.getSelectionService().getSelection();
    } else if (workbenchPart != null) {
        // IObjectActionDelegate
        shell = workbenchPart.getSite().getShell();
        workbench = workbenchPart.getSite().getWorkbenchWindow().getWorkbench();
    } else {
        throw new IllegalStateException();
    }

    if (selection instanceof IStructuredSelection) {
        ss = (IStructuredSelection) selection;
    } else {
        ss = StructuredSelection.EMPTY;
    }

    NewImplMLWizard newImplMLWizard = new NewImplMLWizard();
    newImplMLWizard.init(workbench, ss);

    WizardDialog dialog = new WizardDialog(shell, newImplMLWizard);
    dialog.create();
    dialog.open();
}

From source file:com.nokia.tools.variant.confml.ui.views.ConfMLNavigator.java

License:Open Source License

public ISelection getSelection() {
    return viewer == null ? StructuredSelection.EMPTY : viewer.getSelection();
}

From source file:com.nokia.tools.variant.editor.editors.CPFEditor.java

License:Open Source License

private ISelection getNextItemSelection(Group l) {
    if (l instanceof ParentGroup) {
        EList<ParentGroup> parentGroups = view.getParentGroup();
        int indexOf = parentGroups.indexOf(l);
        if (indexOf != -1) {
            if (parentGroups.size() > indexOf + 1) {
                ParentGroup element = parentGroups.get(indexOf + 1);
                if (filterSettings(getAllSettings(element)).size() > 0) {
                    return new StructuredSelection(element);
                } else {
                    return getNextItemSelection(element);
                }//from  w ww  .  j av a2  s  . c o  m
            } else if (indexOf > 0) {
                ParentGroup element = parentGroups.get(indexOf - 1);
                if (filterSettings(getAllSettings(element)).size() > 0) {
                    return new StructuredSelection(element);
                } else {
                    return getNextItemSelection(element);
                }
            }
        } else {
            return StructuredSelection.EMPTY;
        }
    } else {
        LeafGroup newLeafGroup = null;
        ParentGroup parent = (ParentGroup) l.eContainer();
        EList<LeafGroup> leafGroups = parent.getLeafGroup();
        int index = leafGroups.indexOf(l);
        // if leafGroup is not last
        if ((leafGroups.size() - 1) > index) {
            newLeafGroup = leafGroups.get(index + 1);
            if (validateLeafGroup(newLeafGroup)) {
                return new StructuredSelection(newLeafGroup);
            }
            return getNextItemSelection(newLeafGroup);
        } else {
            View view = (View) parent.eContainer();
            EList<ParentGroup> parentGroupList = view.getParentGroup();
            index = parentGroupList.indexOf(parent);
            if ((parentGroupList.size() - 1) > index) {
                parent = parentGroupList.get(index + 1);
                leafGroups = parent.getLeafGroup();
                if (leafGroups != null && leafGroups.size() > 0)
                    newLeafGroup = leafGroups.get(0);
                if (validateLeafGroup(newLeafGroup)) {
                    return new StructuredSelection(newLeafGroup);
                }
                return getNextItemSelection(newLeafGroup);
            }
        }
        return getPrevItemSelection(l);
    }
    return StructuredSelection.EMPTY;
}

From source file:com.nokia.tools.variant.editor.listeners.NavigatorViewerSelectionChangedListener.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    if (!selection.equals(StructuredSelection.EMPTY)
            && selection.getFirstElement().equals(editor.getCurrentGroup())) {
        return;//  w  w w .j av a2 s  .c o  m
    }
    UIModel createUIModel = null;
    Object firstElement = selection.getFirstElement();
    if (firstElement instanceof ParentGroup) {
        ParentGroup parentGroup = (ParentGroup) firstElement;
        EList<LeafGroup> leafGroup = parentGroup.getLeafGroup();
        if (leafGroup.size() > 0 && leafGroup.get(0) instanceof SummaryLeafGroup) {

            firstElement = leafGroup.get(0);

        } else {

            createUIModel = editor.getViewModelToUIModelConvertor().createUIModel(parentGroup);
            editor.setNotesSorting(false);
            editor.setDirtySorting(false);
            editor.setErrorSorting(false);
            editor.setCurrentGroup(parentGroup);
            if (createUIModel != null) {
                SettingsViewer settingsViewer = editor.getSettingsViewer();
                settingsViewer.setGroupName(parentGroup.getName());
                settingsViewer.setInput(null);
                settingsViewer
                        .setContentProvider(new EditorViewerContentProvider(editor.getCommandStack(), editor));
                settingsViewer.setInput(createUIModel);

                settingsViewer.setLabelProvider(new EditorViewerLabelProvider(
                        (ResourceModelRoot) editor.getAdapter(ResourceModelRoot.class)));

            }
            return;
        }
    }
    if (firstElement instanceof LeafGroup) {
        SettingsViewer settingsViewer = editor.getSettingsViewer();
        CommandStack stack = editor.getCommandStack();
        Group currentLeafGroup = editor.getCurrentGroup();
        if (currentLeafGroup != null && currentLeafGroup.equals(firstElement)) {
            return;
        }
        editor.setNotesSorting(false);
        editor.setDirtySorting(false);
        editor.setErrorSorting(false);
        LeafGroup leaf = (LeafGroup) firstElement;
        editor.setCurrentGroup(leaf);
        ParentGroup parent = (ParentGroup) leaf.eContainer();

        if (parent instanceof SummaryParentGroup) {
            UISummaryModel summaryModelRoot = editor.getSummaryModelroot();
            if (summaryModelRoot == null)
                summaryModelRoot = editor.getViewModelToUIModelConvertor().createUISummaryModel(leaf);
            editor.setSummaryModelRoot(summaryModelRoot);
            editor.setSummaryLeafGroup((SummaryLeafGroup) leaf);
            if (summaryModelRoot != null) {

                if (!(settingsViewer.getInput() instanceof UISummaryModel)) {
                    settingsViewer.setGroupName("Summary");
                    settingsViewer.setInput(null);
                    settingsViewer.setContentProvider(new SummaryViewerContentProvider(stack, editor));
                    settingsViewer.setInput(summaryModelRoot);
                    settingsViewer.setLabelProvider(new SummaryViewerLabelProvider());
                }
                editor.handleSummary(leaf);

            }

        } else {
            createUIModel = editor.getViewModelToUIModelConvertor().createUIModel(leaf);
            if (createUIModel != null) {
                settingsViewer.setGroupName(leaf.getName());
                settingsViewer.setInput(null);
                settingsViewer.setContentProvider(new EditorViewerContentProvider(stack, editor));
                settingsViewer.setInput(createUIModel);

                settingsViewer.setLabelProvider(new EditorViewerLabelProvider(
                        (ResourceModelRoot) editor.getAdapter(ResourceModelRoot.class)));

            }
        }
    }

}