1 package mograsim.rcp.parts;
3 import java.util.Arrays;
6 import javax.annotation.PostConstruct;
7 import javax.inject.Inject;
9 import org.eclipse.e4.ui.di.Focus;
10 import org.eclipse.e4.ui.di.Persist;
11 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
12 import org.eclipse.jface.viewers.ArrayContentProvider;
13 import org.eclipse.jface.viewers.TableViewer;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Text;
20 public class SamplePart
23 private TableViewer tableViewer;
29 public void createComposite(Composite parent)
31 parent.setLayout(new GridLayout(1, false));
33 Text txtInput = new Text(parent, SWT.BORDER);
34 txtInput.setMessage("Enter text to mark part as dirty");
35 txtInput.addModifyListener(e -> part.setDirty(true));
36 txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
38 tableViewer = new TableViewer(parent);
40 tableViewer.setContentProvider(ArrayContentProvider.getInstance());
41 tableViewer.setInput(createInitialDataModel());
42 tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
46 public void setFocus()
48 tableViewer.getTable().setFocus();
57 private static List<String> createInitialDataModel()
59 return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5");