Search in sources :

Example 1 with IItemStatusLineProvider

use of org.eclipse.ecf.discovery.ui.model.IItemStatusLineProvider in project ecf by eclipse.

the class AdapterFactoryStatuslineProvider method selectionChanged.

/*
	 * (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
	 */
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        EObject object = (EObject) ss.getFirstElement();
        if (object != null) {
            // do we really have a selection?
            IItemStatusLineProvider itemStatusLineProvider = (IItemStatusLineProvider) adapterFactory.adapt(object, IItemStatusLineProvider.class);
            if (itemStatusLineProvider != null) {
                statusline.setMessage(itemStatusLineProvider.getStatusLineText(object));
            } else {
                // fallback to IItemLabelProvider.getText(..)
                IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(object, IItemLabelProvider.class);
                if (itemLabelProvider != null) {
                    statusline.setMessage(itemLabelProvider.getText(object));
                }
            }
        }
    } else {
        // $NON-NLS-1$
        statusline.setMessage("");
    }
}
Also used : IItemStatusLineProvider(org.eclipse.ecf.discovery.ui.model.IItemStatusLineProvider) IItemLabelProvider(org.eclipse.emf.edit.provider.IItemLabelProvider) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

IItemStatusLineProvider (org.eclipse.ecf.discovery.ui.model.IItemStatusLineProvider)1 EObject (org.eclipse.emf.ecore.EObject)1 IItemLabelProvider (org.eclipse.emf.edit.provider.IItemLabelProvider)1