Search in sources :

Example 1 with IItemLabelProvider

use of org.eclipse.emf.edit.provider.IItemLabelProvider 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)

Example 2 with IItemLabelProvider

use of org.eclipse.emf.edit.provider.IItemLabelProvider in project InformationSystem by ObeoNetwork.

the class UtilServices method getLabel.

public String getLabel(EObject object) {
    ComposedAdapterFactory composeable = new ComposedAdapterFactory();
    composeable.addAdapterFactory(dbEvolution);
    composeable.addAdapterFactory(compare);
    composeable.addAdapterFactory(database);
    composeable.addAdapterFactory(library);
    IItemLabelProvider provider = (IItemLabelProvider) composeable.adapt(object, IItemLabelProvider.class);
    if (provider != null) {
        return provider.getText(object);
    }
    return "";
}
Also used : IItemLabelProvider(org.eclipse.emf.edit.provider.IItemLabelProvider) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory)

Example 3 with IItemLabelProvider

use of org.eclipse.emf.edit.provider.IItemLabelProvider in project InformationSystem by ObeoNetwork.

the class TransitionItemProvider method addNodeLabeltoTransitionLabel.

/**
 * Add the label for the source or target node of a transition inside this transition's label
 * @param node
 * @param transitionLabel
 */
private void addNodeLabeltoTransitionLabel(Node node, StringBuilder transitionLabel) {
    String nodeLabel = null;
    if (node != null) {
        IItemLabelProvider sourceLabelProvider = (IItemLabelProvider) getRootAdapterFactory().adapt(node, IItemLabelProvider.class);
        nodeLabel = sourceLabelProvider.getText(node);
    }
    if (nodeLabel != null) {
        transitionLabel.append(nodeLabel);
    } else {
        transitionLabel.append("?");
    }
}
Also used : IItemLabelProvider(org.eclipse.emf.edit.provider.IItemLabelProvider)

Aggregations

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