Search in sources :

Example 1 with ViewpointSelectionListener

use of org.obeonetwork.tools.linker.ui.view.util.ViewpointSelectionListener in project InformationSystem by ObeoNetwork.

the class EObjectLinksView method createPartControl.

/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 */
public void createPartControl(Composite parent) {
    Composite viewContainer = new Composite(parent, SWT.NONE);
    viewContainer.setLayout(new GridLayout());
    eobjectLabel = new Label(viewContainer, SWT.NONE);
    eobjectLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite tableContainer = new Composite(viewContainer, SWT.NONE);
    tableContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    TableColumnLayout layout = new TableColumnLayout();
    tableContainer.setLayout(layout);
    viewer = new TableViewer(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    addColumns();
    contentProvider = createContentProvider();
    viewer.setContentProvider(contentProvider);
    List<ViewerFilter> filters = createFilters();
    if (filters.size() > 0) {
        for (ViewerFilter viewerFilter : filters) {
            viewer.addFilter(viewerFilter);
        }
    }
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            for (ViewListener listener : listeners) {
                listener.fireSelectionChanged(getSelectedEntries());
            }
        }
    });
    ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);
    listener = new ViewpointSelectionListener() {

        /**
         * {@inheritDoc}
         * @see org.obeonetwork.tools.linker.ui.view.util.ViewpointSelectionListener#eObjectSelected(org.eclipse.emf.ecore.EObject)
         */
        @Override
        protected void eObjectSelected(EObject selectedEObject) {
            update(selectedEObject);
        }
    };
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
    makeActions();
    fillLocalActionBar();
    fillLocalPullDown();
    hookDoubleClickAction();
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ViewpointSelectionListener(org.obeonetwork.tools.linker.ui.view.util.ViewpointSelectionListener) EObject(org.eclipse.emf.ecore.EObject) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1 ViewpointSelectionListener (org.obeonetwork.tools.linker.ui.view.util.ViewpointSelectionListener)1