Example usage for org.eclipse.jface.viewers TableViewer TableViewer

List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TableViewer TableViewer.

Prototype

public TableViewer(Table table) 

Source Link

Document

Creates a table viewer on the given table control.

Usage

From source file:com.googlecode.osde.internal.editors.contents.SupportedViewsPart.java

License:Apache License

private void createContents(Section section, FormToolkit toolkit) {
    section.setText("Supported Views ");
    Composite composite = toolkit.createComposite(section);
    composite.setLayout(new GridLayout(2, false));
    // Supported views list
    Table table = toolkit.createTable(composite,
            SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    table.setHeaderVisible(true);/*from w ww  .j  a v  a  2  s  . c  o m*/
    table.setLinesVisible(true);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(layoutData);
    TableColumn column = new TableColumn(table, SWT.LEFT, 0);
    column.setText("");
    column.setWidth(20);
    column = new TableColumn(table, SWT.LEFT, 1);
    column.setText("View");
    column.setWidth(100);
    column = new TableColumn(table, SWT.LEFT, 2);
    column.setText("Type");
    column.setWidth(100);
    supportedViewList = new TableViewer(table);
    supportedViewList.setContentProvider(new SupportedViewListContentProvider());
    supportedViewList.setLabelProvider(new SupportedViewListLabelProvider());
    final SectionPart part = SectionPartFactory.create(section, getManagedForm());
    supportedViewList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            getManagedForm().fireSelectionChanged(part, event.getSelection());
        }
    });
    // Buttons
    Composite buttonPane = toolkit.createComposite(composite);
    buttonPane.setLayout(new GridLayout());
    layoutData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    buttonPane.setLayoutData(layoutData);
    Button addButton = toolkit.createButton(buttonPane, "Add", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    addButton.setLayoutData(layoutData);
    addButton.addSelectionListener(new AddButtonSelectionListener());
    Button deleteButton = toolkit.createButton(buttonPane, "Delete", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    deleteButton.setLayoutData(layoutData);
    deleteButton.addSelectionListener(new DeleteButtonSelectionListener());
    Button upButton = toolkit.createButton(buttonPane, "Up", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    upButton.setLayoutData(layoutData);
    upButton.addSelectionListener(new UpButtonSelectionListener());
    Button downButton = toolkit.createButton(buttonPane, "Down", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    downButton.setLayoutData(layoutData);
    downButton.addSelectionListener(new DownButtonSelectionListener());
    //
    section.setClient(composite);
}

From source file:com.googlecode.osde.internal.editors.locale.MessageBundlePage.java

License:Apache License

public void createContents(Composite parent) {
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;//  w  w  w  .j a v  a2s  .c  om
    layout.marginHeight = 0;
    parent.setLayout(layout);
    FormToolkit toolkit = managedForm.getToolkit();
    // Message bundle
    Section messagesSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
    messagesSection.setText("Message bundle");
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    messagesSection.setLayoutData(layoutData);
    Composite messagesPane = toolkit.createComposite(messagesSection);
    messagesPane.setLayout(new GridLayout(2, false));
    messagesSection.setClient(messagesPane);
    final SectionPart messagesPart = SectionPartFactory.create(messagesSection, managedForm);
    //
    internalButton = new Button(messagesPane, SWT.CHECK);
    internalButton.setText("Define this message bundle in Gadget XML file.");
    layoutData = new GridData();
    layoutData.horizontalSpan = 2;
    internalButton.setLayoutData(layoutData);
    internalButton.addSelectionListener(new InternalButtonSelectionListener(messagesPart));
    //
    Table messagesTable = toolkit.createTable(messagesPane,
            SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    messagesTable.setHeaderVisible(true);
    messagesTable.setLinesVisible(true);
    layoutData = new GridData(GridData.FILL_BOTH);
    messagesTable.setLayoutData(layoutData);
    TableColumn column = new TableColumn(messagesTable, SWT.LEFT, 0);
    column.setText("");
    column.setWidth(20);
    column = new TableColumn(messagesTable, SWT.LEFT, 1);
    column.setText("Name");
    column.setWidth(130);
    column = new TableColumn(messagesTable, SWT.LEFT, 2);
    column.setText("Text");
    column.setWidth(150);
    messagesList = new TableViewer(messagesTable);
    messagesList.setContentProvider(new MessagesListContentProvider());
    messagesList.setLabelProvider(new MessagesListLabelProvider());
    //
    Composite buttonPane = toolkit.createComposite(messagesPane);
    buttonPane.setLayout(new GridLayout());
    layoutData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    buttonPane.setLayoutData(layoutData);
    Button addButton = toolkit.createButton(buttonPane, "Add", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    addButton.setLayoutData(layoutData);
    addButton.addSelectionListener(new AddButtonSelectionListener(messagesPart));
    Button deleteButton = toolkit.createButton(buttonPane, "Remove", SWT.PUSH);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = GridData.BEGINNING;
    deleteButton.setLayoutData(layoutData);
    deleteButton.addSelectionListener(new RemoveButtonSelectionListener(messagesPart));
}