Search in sources :

Example 26 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.

the class UpdateNoteDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).extendedMargins(5, 5, 5, 5).applyTo(tparent);
    GridDataFactory.fillDefaults().hint(620, 250).grab(true, true).applyTo(tparent);
    Group noteGroup = new Group(tparent, SWT.None);
    noteGroup.setText(Messages.getString("dialog.UpdateNoteDialog.noteGroup"));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(noteGroup);
    noteGroup.setLayout(new GridLayout());
    tableViewer = new TableViewer(noteGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = tableViewer.getTable();
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    String[] arrColName = new String[] { Messages.getString("dialog.UpdateNoteDialog.tableColumn1"), Messages.getString("dialog.UpdateNoteDialog.tableColumn2"), Messages.getString("dialog.UpdateNoteDialog.tableColumn3"), Messages.getString("dialog.UpdateNoteDialog.tableColumn4"), Messages.getString("dialog.UpdateNoteDialog.tableColumn5") };
    int[] arrColWidth = new int[] { 40, 100, 100, 150, 120 };
    for (int i = 0; i < arrColName.length; i++) {
        TableColumn column = new TableColumn(table, SWT.LEFT);
        column.setWidth(arrColWidth[i]);
        column.setText(arrColName[i]);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    Composite cmpBtn = new Composite(tparent, SWT.None);
    // cmpBtn.setLayout(new GridLayout());
    GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(0, 0, 35, 5).applyTo(cmpBtn);
    cmpBtn.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    btnAdd = new Button(cmpBtn, SWT.NONE);
    btnAdd.setText(Messages.getString("dialog.UpdateNoteDialog.btnAdd"));
    btnAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnEdit = new Button(cmpBtn, SWT.NONE);
    btnEdit.setText(Messages.getString("dialog.UpdateNoteDialog.btnEdit"));
    btnEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnDelete = new Button(cmpBtn, SWT.NONE);
    btnDelete.setText(Messages.getString("dialog.UpdateNoteDialog.btnDelete"));
    btnDelete.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    initTable();
    initListener();
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) Composite(org.eclipse.swt.widgets.Composite) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 27 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.

the class ExportTmxDialog method createTableViewerColumn.

/**
	 * 设置TableViewer 列属性
	 * @param viewer
	 * @param title
	 *            列标题
	 * @param bound
	 *            列宽
	 * @param colNumber
	 *            列序号
	 * @return {@link TableViewerColumn};
	 */
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, final int colNumber) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE | SWT.Resize);
    final TableColumn column = viewerColumn.getColumn();
    column.setText(title);
    column.setWidth(bound);
    column.setResizable(true);
    column.setMoveable(true);
    return viewerColumn;
}
Also used : TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 28 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.

the class TmDbManagerDialog method createTableViewerColumn.

/**
	 * 设置TableViewer 列属性
	 * @param viewer
	 * @param title
	 *            列标题
	 * @param bound
	 *            列宽
	 * @param colNumber
	 *            列序号
	 * @return {@link TableViewerColumn};
	 */
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, final int colNumber) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE | SWT.Resize);
    final TableColumn column = viewerColumn.getColumn();
    column.setText(title);
    column.setWidth(bound);
    column.setResizable(true);
    column.setMoveable(true);
    return viewerColumn;
}
Also used : TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 29 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project otertool by wuntee.

the class GuiWorkshop method addColumnSorter.

public static void addColumnSorter(final Table table, TableColumn column, final int index, final String[] dataKeys) {
    Listener sortListener = new Listener() {

        public void handleEvent(Event e) {
            TableItem[] items = table.getItems();
            Collator collator = Collator.getInstance(Locale.getDefault());
            TableColumn column = (TableColumn) e.widget;
            for (int i = 1; i < items.length; i++) {
                String value1 = items[i].getText(index);
                for (int j = 0; j < i; j++) {
                    String value2 = items[j].getText(index);
                    if (table.getSortDirection() == SWT.UP || table.getSortDirection() == SWT.NONE && collator.compare(value1, value2) < 0) {
                        String[] values = new String[table.getColumnCount()];
                        for (int k = 0; k < table.getColumnCount(); k++) {
                            values[k] = items[i].getText(k);
                        }
                        // Get data from list item
                        Map<String, Object> dataMap = new HashMap<String, Object>();
                        for (String key : dataKeys) {
                            dataMap.put(key, items[i].getData(key));
                        }
                        items[i].dispose();
                        TableItem item = new TableItem(table, SWT.NONE, j);
                        item.setText(values);
                        // Set data for new item
                        for (String key : dataMap.keySet()) {
                            item.setData(key, dataMap.get(key));
                        }
                        items = table.getItems();
                        break;
                    } else if (table.getSortDirection() == SWT.DOWN && collator.compare(value1, value2) > 0) {
                        String[] values = new String[table.getColumnCount()];
                        for (int k = 0; k < table.getColumnCount(); k++) {
                            values[k] = items[i].getText(k);
                        }
                        // Get data from list item
                        Map<String, Object> dataMap = new HashMap<String, Object>();
                        for (String key : dataKeys) {
                            dataMap.put(key, items[i].getData(key));
                        }
                        items[i].dispose();
                        TableItem item = new TableItem(table, SWT.NONE, j);
                        item.setText(values);
                        // Set data for new item
                        for (String key : dataMap.keySet()) {
                            item.setData(key, dataMap.get(key));
                        }
                        items = table.getItems();
                        break;
                    }
                }
            }
            if (table.getSortDirection() == SWT.NONE || table.getSortDirection() == SWT.UP) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
        }
    };
    column.addListener(SWT.Selection, sortListener);
}
Also used : Listener(org.eclipse.swt.widgets.Listener) HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn) Collator(java.text.Collator) Event(org.eclipse.swt.widgets.Event) HashMap(java.util.HashMap) Map(java.util.Map)

Example 30 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project otertool by wuntee.

the class LoadApkFromDeviceDialog method createContents.

/**
	 * Create contents of the dialog.
	 */
private void createContents() {
    shlSelectApk = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE);
    shlSelectApk.setSize(592, 486);
    shlSelectApk.setText("Select APK");
    shlSelectApk.setLayout(new GridLayout(1, false));
    table = new Table(shlSelectApk, SWT.BORDER | SWT.FULL_SELECTION);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            result = (PackageBean) table.getSelection()[0].getData(PACKAGE_BEAN);
            shlSelectApk.close();
        }
    });
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    table.setBounds(0, 0, 3, 19);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final TableColumn tblclmnApk = new TableColumn(table, SWT.NONE);
    tblclmnApk.setWidth(240);
    tblclmnApk.setText("APK");
    final TableColumn tblclmnPackage = new TableColumn(table, SWT.NONE);
    tblclmnPackage.setWidth(338);
    tblclmnPackage.setText("Package");
    final String[] keys = { PACKAGE_BEAN };
    GuiWorkshop.addColumnSorter(table, tblclmnApk, 0, keys);
    GuiWorkshop.addColumnSorter(table, tblclmnPackage, 1, keys);
    Composite composite = new Composite(shlSelectApk, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    composite.setBounds(0, 0, 64, 64);
    GridLayout gl_composite = new GridLayout(2, false);
    gl_composite.verticalSpacing = 0;
    gl_composite.marginWidth = 0;
    gl_composite.marginHeight = 0;
    gl_composite.horizontalSpacing = 0;
    composite.setLayout(gl_composite);
    Button btnLoad = new Button(composite, SWT.NONE);
    btnLoad.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            if (table.getSelection().length == 0) {
                GuiWorkshop.messageError(shlSelectApk, "Please Select an APK to load.");
            } else {
                result = (PackageBean) table.getSelection()[0].getData(PACKAGE_BEAN);
                shlSelectApk.close();
            }
        }
    });
    btnLoad.setText("Load");
    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            result = null;
            shlSelectApk.close();
        }
    });
    btnCancel.setText("Cancel");
}
Also used : Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) PackageBean(com.wuntee.oter.packagemanager.PackageBean) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

TableColumn (org.eclipse.swt.widgets.TableColumn)200 Table (org.eclipse.swt.widgets.Table)100 TableViewer (org.eclipse.jface.viewers.TableViewer)87 GridData (org.eclipse.swt.layout.GridData)80 SelectionEvent (org.eclipse.swt.events.SelectionEvent)72 Composite (org.eclipse.swt.widgets.Composite)71 GridLayout (org.eclipse.swt.layout.GridLayout)56 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)51 Label (org.eclipse.swt.widgets.Label)39 Button (org.eclipse.swt.widgets.Button)32 TableItem (org.eclipse.swt.widgets.TableItem)31 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)26 Event (org.eclipse.swt.widgets.Event)23 Listener (org.eclipse.swt.widgets.Listener)23 Point (org.eclipse.swt.graphics.Point)21 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)20 TableLayout (org.eclipse.jface.viewers.TableLayout)19 SelectionListener (org.eclipse.swt.events.SelectionListener)18 Group (org.eclipse.swt.widgets.Group)15 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14