Search in sources :

Example 6 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn 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 7 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn 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 8 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project translationstudio8 by heartsome.

the class PreMachineTranslationResultDialog 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 9 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project translationstudio8 by heartsome.

the class PreTranslationDialog 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 10 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project translationstudio8 by heartsome.

the class NonTranslationQAPage method createContents.

@Override
protected Control createContents(Composite parent) {
    isInit = true;
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).hint(550, 400).applyTo(tparent);
    Group instalGroup = new Group(tparent, SWT.NONE);
    instalGroup.setLayout(new GridLayout());
    instalGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    instalGroup.setText(Messages.getString("qa.preference.NonTranslationQAPage.nonTransElementInstal"));
    String tip = Messages.getString("preference.NonTranslationQAPage.instalLbl");
    HsImageLabel instalLbl = new HsImageLabel(tip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_QA_nontrans_nontransInstal));
    Composite instalCmp = instalLbl.createControl(instalGroup);
    instalCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // 一排按钮
    Composite buttonCmp = new Composite(instalGroup, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(4).applyTo(buttonCmp);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonCmp);
    addBtn = new Button(buttonCmp, SWT.NONE);
    addBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.add"));
    editBtn = new Button(buttonCmp, SWT.NONE);
    editBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.editBtn"));
    editBtn.setEnabled(false);
    deleteBtn = new Button(buttonCmp, SWT.NONE);
    deleteBtn.setText(Messages.getString("qa.preference.NonTranslationQAPage.delete"));
    deleteBtn.setEnabled(false);
    Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point editPoint = editBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point delPoint = deleteBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    GridData btnData = new GridData();
    int width = Math.max(addPoint.x, Math.max(editPoint.x, delPoint.x));
    btnData.widthHint = width + 10;
    addBtn.setLayoutData(btnData);
    editBtn.setLayoutData(btnData);
    deleteBtn.setLayoutData(btnData);
    Map<String, String> comboTip = new HashMap<String, String>();
    comboTip.put(QAConstant.QA_NONTRANS_NAME, Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    comboViewer = new ComboViewer(buttonCmp, SWT.NONE);
    comboViewer.setContentProvider(new ArrayContentProvider());
    comboViewer.setLabelProvider(new NonTransElementCmbProvider());
    comboViewer.getCombo().setToolTipText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    comboViewer.setInput(internalElementList);
    comboViewer.getCombo().setText(Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"));
    GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).grab(false, false).applyTo(comboViewer.getCombo());
    // ---------------------下面是非译元素展示框---------------------------------
    tableViewer = new TableViewer(instalGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
    String[] columnNames = new String[] { Messages.getString("qa.preference.NonTranslationQAPage.tipColumn"), Messages.getString("qa.preference.NonTranslationQAPage.contentColumn"), Messages.getString("qa.preference.NonTranslationQAPage.regularColumn") };
    tableViewer.setLabelProvider(new NonTransElementTableProvider());
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableViewerColumn column = new TableViewerColumn(tableViewer, columnAlignments[i]);
        column.getColumn().setText(columnNames[i]);
        column.getColumn().setWidth(50);
        column.setLabelProvider(new NonTransElementTableProvider(i));
        if (i == 0) {
            column.getColumn().addSelectionListener(new SelectionAdapter() {

                boolean asc = true;

                public void widgetSelected(SelectionEvent e) {
                    tableViewer.setSorter(asc ? TableSorter.name_ASC : TableSorter.name_DESC);
                    asc = !asc;
                }
            });
        }
        if (i == 1) {
            column.getColumn().addSelectionListener(new SelectionAdapter() {

                boolean asc = true;

                public void widgetSelected(SelectionEvent e) {
                    tableViewer.setSorter(asc ? TableSorter.content_ASC : TableSorter.content_DESC);
                    asc = !asc;
                }
            });
        }
    }
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    tableViewer.setInput(dataList);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    // 让列表列宽动态变化
    table.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            final Table table = ((Table) event.widget);
            final TableColumn[] columns = table.getColumns();
            event.widget.getDisplay().syncExec(new Runnable() {

                public void run() {
                    double[] columnWidths = new double[] { 0.2, 0.2, 0.58 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    instalLbl.computeSize();
    initListener();
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) HashMap(java.util.HashMap) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)134 TableViewer (org.eclipse.jface.viewers.TableViewer)72 Composite (org.eclipse.swt.widgets.Composite)53 GridData (org.eclipse.swt.layout.GridData)52 SelectionEvent (org.eclipse.swt.events.SelectionEvent)45 TableColumn (org.eclipse.swt.widgets.TableColumn)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 GridLayout (org.eclipse.swt.layout.GridLayout)32 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)28 Table (org.eclipse.swt.widgets.Table)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 Point (org.eclipse.swt.graphics.Point)15 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)14 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 Button (org.eclipse.swt.widgets.Button)14 Image (org.eclipse.swt.graphics.Image)13 Text (org.eclipse.swt.widgets.Text)11