/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package at.medevit.e4.app.parts; import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.e4.ui.workbench.swt.modeling.EMenuService; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; public class SamplePart { private Label label; private TableViewer tableViewer; @Inject private ESelectionService selectionService; private static final String ID_PART_POPUP_MENU = "at.medevit.e4.main.part.table.popupmenu"; @PostConstruct public void createComposite(Composite parent, final EMenuService menuService) { parent.setLayout(new GridLayout()); label = new Label(parent, SWT.NONE); label.setText("Sample table"); tableViewer = new TableViewer(parent); tableViewer.add("Sample item 1"); tableViewer.add("Sample item 2"); tableViewer.add("Sample item 3"); tableViewer.add("Sample item 4"); tableViewer.add("Sample item 5"); tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); menuService.registerContextMenu(tableViewer.getTable(), ID_PART_POPUP_MENU); } @Focus public void setFocus() { tableViewer.getTable().setFocus(); } }