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.s60ct.cenrep.gui.editors.CRBrowser.java

License:Open Source License

public void setCurrentViewer(Viewer viewer) {
    // If it is changing...
    ///* w w w  . j  a v  a2  s . c o m*/
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            //
            selectionChangedListener = new ISelectionChangedListener() {
                // This just notifies those things that are affected by the section.
                //
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    if (!settingSelection) {
                        focusDomain.setSelection(selectionChangedEvent.getSelection());
                    }
                }
            };
        }

        // Stop listening to the old one.
        //
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }

        // Start listening to the new one.
        //
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }

        // Remember it.
        //
        currentViewer = viewer;

        // Set the editors selection based on the current viewer's selection.
        //
        if (!settingSelection) {
            focusDomain.setSelection(
                    currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
        }
    }
}

From source file:com.nokia.s60ct.gui.actions.NewConfigurationAction.java

License:Open Source License

public void run(IAction action) {
    NewConfigurationWizard wizard = new NewConfigurationWizard();
    wizard.init(getWindow().getWorkbench(), StructuredSelection.EMPTY);
    WizardDialog wizardDialog = new WizardDialog(getWindow().getShell(), wizard);
    wizardDialog.open();//w  w  w . jav a2s . co m
}

From source file:com.nokia.s60ct.gui.editors.ConfigurationBrowser.java

License:Open Source License

public void setCurrentViewer(Viewer viewer) {
    // If it is changing...
    ///*from  w  w  w . j  a v a2 s .  c om*/
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            //
            selectionChangedListener = new ISelectionChangedListener() {
                // This just notifies those things that are affected by the section.
                //
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    setSelection(selectionChangedEvent.getSelection());
                }
            };
        }

        // Stop listening to the old one.
        //
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }

        // Start listening to the new one.
        //
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }

        // Remember it.
        //
        currentViewer = viewer;

        // Set the editors selection based on the current viewer's selection.
        //
        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
    }
}

From source file:com.nokia.sdt.symbian.ui.appeditor.S60ApplicationEditorExtender.java

License:Open Source License

private void createAppUiPage() throws PartInitException {
    if (editorContext.getS60RootModelType() != S60ModelUtils.S60RootModelType.LEGACY) {
        lastAppUiPageSelection = StructuredSelection.EMPTY;
        DesignerEditorPage designerEditorPage = new DesignerEditorPage(editorContext.getFormEditor());
        appUiPageIndex = formEditor.addPage(designerEditorPage, dmEditor.getEditorInput());
        editorContext.setAppUiPageIndex(appUiPageIndex);
        dmEditor.setTabTitle(appUiPageIndex, Messages.getString("ApplicationEditor.appUiPageLabel")); //$NON-NLS-1$
        appUiPage = designerEditorPage;/*from  w w w .j  a va  2 s.c  om*/

        IContentOutlinePage outlinePage = (IContentOutlinePage) dmEditor.getAdapter(IContentOutlinePage.class);
        if (outlinePage instanceof MultiPageContentOutlinePage)
            contentOutlinePage = (MultiPageContentOutlinePage) outlinePage;
    }
}

From source file:com.nokia.sdt.symbian.ui.appeditor.S60ApplicationEditorExtender.java

License:Open Source License

public void pageChanged(PageChangedEvent event) {
    Object selectedPage = event.getSelectedPage();
    if ((selectedPage == null) || (selectedPage == lastSelectedPage))
        return;//from  w w w  .  ja v a  2 s . c  o m

    lastSelectedPage = selectedPage;
    if (contentOutlinePage != null) {
        contentOutlinePage.activatePage(selectedPage);
    }

    if (appUiPage == null)
        return;
    ISelectionManager selectionManager = appUiPage.getSelectionManager();
    if (selectionManager == null)
        return;

    if (!selectedPage.equals(appUiPage)) {
        lastAppUiPageSelection = selectionManager.getSelection();
        selectionManager.setSelection(StructuredSelection.EMPTY);
    } else {
        if (!appUiPageActivated) {
            appUiPageActivated = true;
            WorkbenchUtils.setHelpContextId(appUiPage.getControl(), APPUI_PAGE_HELP_CONTEXT_ID);
        }
        pruneAppUiSelection();
        selectionManager.setSelection(lastAppUiPageSelection);
    }
}

From source file:com.nokia.sdt.symbian.ui.editors.ArrayEditorDialog.java

License:Open Source License

private void setPropertyViewInput(Object obj) {
    if (obj == null) {
        propertyPage.selectionChanged(null, StructuredSelection.EMPTY);
    } else if (obj instanceof IPropertySource) {
        IStructuredSelection ss = new StructuredSelection(obj);
        propertyPage.selectionChanged(null, ss);
    }/*  ww w .  j a  va 2 s.com*/
}

From source file:com.nokia.sdt.uidesigner.ui.DesignerEditorPage.java

License:Open Source License

public void prepareForReload() {
    // don't do anything else if the editor is broken
    if (getUpperGraphicalViewer() == null)
        return;/*w  w  w. j  a va 2 s.  co  m*/

    EditorUtils.saveCurrentLayout(this);
    saveSelectionForReload();
    setLayoutMode();
    getSelectionManager().setSelection(StructuredSelection.EMPTY);
    resetLayers();
    getSelectionManager().setSync(false);
    resetViewers();
}

From source file:com.nokia.sdt.uidesigner.ui.SelectionManager.java

License:Open Source License

public ISelection getSelection() {
    if (currentSelection != null)
        return currentSelection;

    // create a new list of edit parts from the various viewers.
    // favor upper viewer parts to outline part to allow alignment and matching actions to work.
    // However, avoid mixing outline with graphical parts - some GEF actions throw NPEs.
    // So if there are outline-only objects in the selection, use only outline parts
    List<EditPart> selectedEditParts = new ArrayList();
    boolean useGraphicalViewers = false;
    EditPartViewer outlineViewer = this.editor.getOutlineViewer();
    if (outlineViewer != null) {
        Set<EObject> selectedObjects = new HashSet();
        addModelsFromViewer(selectedObjects, outlineViewer);
        if (selectedObjects.isEmpty())
            return currentSelection = StructuredSelection.EMPTY;

        if (containsOutlineOnlyObjects(selectedObjects))
            addUniqueSelectedPartsFromViewer(selectedEditParts, outlineViewer);
        else//ww w .jav a2s.  c  o  m
            useGraphicalViewers = true;
    } else
        useGraphicalViewers = true;

    if (useGraphicalViewers) {
        addUniqueSelectedPartsFromViewer(selectedEditParts, this.editor.getUpperGraphicalViewer());
        addUniqueSelectedPartsFromViewer(selectedEditParts, this.editor.getLowerGraphicalViewer());
    }

    // prune the list to not include contents or transient parts 
    List selection = new ArrayList();
    for (EditPart editPart : selectedEditParts) {
        selection.add(editPart);
    }

    return currentSelection = new StructuredSelection(selection);
}

From source file:com.nokia.sdt.uidesigner.ui.SelectionManager.java

License:Open Source License

private void setViewerSelection(EditPartViewer viewer, ISelection selection) {
    if (viewer == null)
        return;//from   w w w  .  j a  va2  s.c o m
    List selectedParts = getViewerSelection(viewer, selection);
    if ((selectedParts != null) && (!selectedParts.isEmpty())) {
        viewer.setSelection(new StructuredSelection(selectedParts));
        if (selectedParts.size() > 0) {
            viewer.reveal((EditPart) selectedParts.get(selectedParts.size() - 1));
        }
    } else {
        viewer.setSelection(StructuredSelection.EMPTY);
    }
}

From source file:com.nokia.sdt.uidesigner.ui.utils.EditorUtils.java

License:Open Source License

public static void setSelectionToAffectedObjects(IDesignerEditor editor, Collection affectedObjects) {
    setDisplayModelSelectedObjects(editor.getDisplayModel(), affectedObjects);

    boolean setFocusToGraphicalViewer = !isOutlineActive(editor);
    List selectedParts = new ArrayList();
    for (Iterator iter = affectedObjects.iterator(); iter.hasNext();) {
        EObject object = (EObject) iter.next();
        EditPart part = getPrimaryEditPartForObject(editor, object);
        if (part != null) {
            selectedParts.add(part);//from   w w w . j a va 2s  .com
            if (setFocusToGraphicalViewer)
                part.getViewer().getControl().setFocus();
        }
    }
    if (!selectedParts.isEmpty()) {
        StructuredSelection selection = new StructuredSelection(selectedParts);
        editor.getSelectionManager().setSelection(selection);
    } else {
        if (setFocusToGraphicalViewer)
            editor.getUpperGraphicalViewer().getControl().setFocus();
        editor.getSelectionManager().setSelection(StructuredSelection.EMPTY);
    }
}