Search in sources :

Example 1 with GroupLayout

use of org.eclipse.wb.swt.layout.grouplayout.GroupLayout in project core by jcryptool.

the class CommonPropertyDialog method createDialogArea.

/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(area, SWT.NONE);
    TableColumnLayout tclComposite = new TableColumnLayout();
    composite.setLayout(tclComposite);
    TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection selection = (StructuredSelection) event.getSelectionProvider().getSelection();
            TableEntry tableEntry = (TableEntry) selection.getFirstElement();
            final Clipboard cb = new Clipboard(Display.getCurrent());
            cb.setContents(new Object[] { tableEntry.getValue() }, new Transfer[] { TextTransfer.getInstance() });
        }
    });
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableViewerColumn tableViewerNameColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tableViewerNameColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public Image getImage(Object element) {
            return null;
        }

        @Override
        public String getText(Object element) {
            TableEntry entry = (TableEntry) element;
            return entry == null ? "" : entry.getName();
        }
    });
    TableColumn tblclmnNameColumn = tableViewerNameColumn.getColumn();
    tclComposite.setColumnData(tblclmnNameColumn, new ColumnWeightData(1, 2));
    // $NON-NLS-1$
    tblclmnNameColumn.setText(Messages.getString("AbstractKeyDialog.tblclmnNameColumn.text"));
    TableViewerColumn tableViewerValueColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tableViewerValueColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public Image getImage(Object element) {
            return null;
        }

        @Override
        public String getText(Object element) {
            TableEntry entry = (TableEntry) element;
            return entry == null ? "" : entry.getValue();
        }
    });
    TableColumn tblclmnValueColumn = tableViewerValueColumn.getColumn();
    tclComposite.setColumnData(tblclmnValueColumn, new ColumnWeightData(2, 2));
    // $NON-NLS-1$
    tblclmnValueColumn.setText(Messages.getString("AbstractKeyDialog.tblclmnValueColumn.text"));
    tableViewer.setContentProvider(getContentProvider());
    tableViewer.setInput(treeNode);
    Label lblTableLabel = new Label(area, SWT.NONE);
    // $NON-NLS-1$
    lblTableLabel.setText(Messages.getString("AbstractKeyDialog.lblTableLabel.text"));
    GroupLayout glArea = new GroupLayout(area);
    glArea.setHorizontalGroup(glArea.createParallelGroup(GroupLayout.LEADING).add(glArea.createSequentialGroup().addContainerGap().add(glArea.createParallelGroup(GroupLayout.LEADING).add(lblTableLabel).add(composite, GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE)).addContainerGap()));
    glArea.setVerticalGroup(glArea.createParallelGroup(GroupLayout.LEADING).add(glArea.createSequentialGroup().addContainerGap().add(lblTableLabel).addPreferredGap(LayoutStyle.RELATED).add(composite, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE).addContainerGap()));
    area.setLayout(glArea);
    return area;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) GroupLayout(org.eclipse.wb.swt.layout.grouplayout.GroupLayout) Clipboard(org.eclipse.swt.dnd.Clipboard) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 Image (org.eclipse.swt.graphics.Image)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 GroupLayout (org.eclipse.wb.swt.layout.grouplayout.GroupLayout)1