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

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

Introduction

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

Prototype

@Override
    public boolean isEmpty() 

Source Link

Usage

From source file:org.eclipse.epf.export.wizards.SelectPluginPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 *//*from   w  ww.  java 2  s . c om*/
public void selectionChanged(SelectionChangedEvent event) {
    StructuredSelection selection = (StructuredSelection) event.getSelection();
    if (!selection.isEmpty()) {
        Object[] plugin = selection.toArray();
        setDisplayAttributes((MethodPlugin) plugin[0]);
    }

}

From source file:org.eclipse.epf.importing.wizards.SelectConfigSpecsToImportPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 *///from   w  w w  .j  a va  2 s .co m
public void selectionChanged(SelectionChangedEvent event) {
    StructuredSelection selection = (StructuredSelection) event.getSelection();
    if (!selection.isEmpty()) {
        Object[] configs = selection.toArray();
        setDisplayAttributes((ConfigSpecs.Entry) configs[0]);
    } else {
        clearDisplayAttributes();
    }
}

From source file:org.eclipse.epf.importing.wizards.SelectPluginsToImport.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 *//*w  w  w .j  a  v a2  s  .c om*/
public void selectionChanged(SelectionChangedEvent event) {
    StructuredSelection selection = (StructuredSelection) event.getSelection();
    if (!selection.isEmpty()) {
        Object[] plugin = selection.toArray();
        setDisplayAttributes((PluginInfo) plugin[0]);
    } else {
        clearDisplayAttributes();
    }
}

From source file:org.eclipse.epf.publishing.ui.wizards.SelectConfigPage.java

License:Open Source License

/**
 * Adds event handlers to the wizard page controls.
 *///ww  w.  j a  v a  2  s  . co  m
protected void addListeners() {
    configViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection selection = (StructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                Object[] configs = selection.toArray();
                setBriefDescription((MethodConfiguration) configs[0]);
            }
            setPageComplete(isPageComplete());
            getWizard().getContainer().updateButtons();
        }
    });
}

From source file:org.eclipse.gef4.mvc.fx.ui.parts.SelectionForwarder.java

License:Open Source License

@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof StructuredSelection) {
        StructuredSelection sel = (StructuredSelection) selection;
        if (sel.isEmpty()) {
            selectionModel.prependToSelection(Collections.<IContentPart<VR, ? extends VR>>emptyList());
        } else {//from www. ja  v a2  s  .co m
            // find the content parts associated with the selection
            Object[] selected = sel.toArray();
            List<IContentPart<VR, ? extends VR>> parts = new ArrayList<>(selected.length);
            for (Object content : selected) {
                IContentPart<VR, ? extends VR> part = viewer.getContentPartMap().get(content);
                if (part != null) {
                    parts.add(part);
                }
            }
            // set the content parts as the new selection on the
            // SelectionModel
            if (!selectionModel.getSelection().equals(parts)) {
                selectionModel.prependToSelection(parts);
            }
        }
    }
}

From source file:org.eclipse.gef4.zest.fx.jface.ZestContentViewer.java

License:Open Source License

@Override
public void setSelection(ISelection selection, boolean reveal) {
    if (selection.isEmpty()) {
        getSelectionModel().clearSelection();
    } else if (selection instanceof StructuredSelection) {
        StructuredSelection structuredSelection = (StructuredSelection) selection;
        if (!structuredSelection.isEmpty()) {
            List<IContentPart<javafx.scene.Node, ? extends javafx.scene.Node>> toBeSelectedParts = new ArrayList<>();
            for (Object toBeSelectedContent : structuredSelection.toArray()) {
                IContentPart<javafx.scene.Node, ? extends javafx.scene.Node> toBeSelectedPart = viewer
                        .getContentPartMap().get(toBeSelectedContent);
                if (toBeSelectedPart != null) {
                    toBeSelectedParts.add(toBeSelectedPart);
                    if (reveal) {
                        // TODO: we need to reveal all in a single step
                        viewer.reveal(toBeSelectedPart);
                    }/*www.  ja v  a2s.c o  m*/
                } else {
                    throw new IllegalArgumentException(
                            toBeSelectedContent + " is not visualized by a content part of this viewer.");
                }
            }
            getSelectionModel().prependToSelection(toBeSelectedParts);
        }
    } else {
        throw new IllegalArgumentException(
                "A non-empty selection of unsupported type '" + selection.getClass() + "' was passed in.");
    }
}

From source file:org.eclipse.gef4.zest.fx.ui.jface.ZestContentViewer.java

License:Open Source License

@Override
public void setSelection(ISelection selection, boolean reveal) {
    if (this.selection != selection && (this.selection == null || !this.selection.equals(selection))) {
        this.selection = selection;
        fireSelectionChanged(new SelectionChangedEvent(this, selection));
        if (reveal) {
            if (selection instanceof StructuredSelection) {
                // TODO: Find a better place to parse an ISelection.
                StructuredSelection sel = (StructuredSelection) selection;
                if (!sel.isEmpty()) {
                    for (Object content : sel.toArray()) {
                        IContentPart<javafx.scene.Node, ? extends javafx.scene.Node> part = viewer
                                .getContentPartMap().get(content);
                        if (part != null) {
                            viewer.reveal(part);
                        }/*w  w w.jav a  2  s  . c  o m*/
                    }
                }
            }
        }
    }
}

From source file:org.eclipse.gmf.runtime.common.ui.services.elementselection.ElementSelectionComposite.java

License:Open Source License

/**
 * If there is no selection in the composite, set the selection to the
 * provided MatchingObject./*from  ww  w.  ja  v a  2  s .co  m*/
 * 
 * @param matchingObject
 *            the MatchingObject to select.
 */
protected void setSelection() {
    StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
    if (selection.isEmpty()) {
        tableViewer.getTable().setSelection(0);
        handleSelectionChange();
    }
}

From source file:org.eclipse.gyrex.admin.ui.p2.internal.RepositoriesListDialog.java

License:Open Source License

private RepositoryDefinition getSelectedRepo() {
    final StructuredSelection selection = (StructuredSelection) reposViewer.getSelection();
    if (!selection.isEmpty() && selection.getFirstElement() instanceof RepositoryDefinition) {
        return (RepositoryDefinition) selection.getFirstElement();
    }/*ww  w .  j av  a 2  s  .  c  o  m*/

    return null;
}

From source file:org.eclipse.gyrex.admin.ui.p2.internal.SoftwareLandingPage.java

License:Open Source License

private PackageDefinition getSelectedPackage() {
    final StructuredSelection selection = (StructuredSelection) packagesViewer.getSelection();
    if (!selection.isEmpty() && (selection.getFirstElement() instanceof PackageDefinition))
        return (PackageDefinition) selection.getFirstElement();

    return null;//w ww.j a  v  a  2  s  . co m
}