Search in sources :

Example 11 with TableViewer

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

the class SrxLanguageRulesManageDialog method createTable.

private void createTable(Composite tparent) {
    tableViewer = new TableViewer(tparent, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(table);
    tableViewer.setLabelProvider(new TViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    String[] columnNames = new String[] { Messages.getString("srx.SrxLanguageRulesManageDialog.columnNames1"), Messages.getString("srx.SrxLanguageRulesManageDialog.columnNames2"), Messages.getString("srx.SrxLanguageRulesManageDialog.columnNames3") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    // 让列表列宽动态变化
    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.37, 0.37 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editLangRule();
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Table(org.eclipse.swt.widgets.Table) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 12 with TableViewer

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

the class ExportExternalDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
    final Group groupFile = new Group(tparent, SWT.NONE);
    groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
    groupFile.setLayout(new GridLayout(1, false));
    groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
    final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    final Table table = tbv.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
    tableLayout.addColumnData(new ColumnWeightData(1));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
    tableLayout.addColumnData(new ColumnWeightData(10));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
    tbv.setLabelProvider(new TableViewLabelProvider());
    tbv.setContentProvider(new ArrayContentProvider());
    tbv.setInput(xlfBeans);
    final Group groupExportType = new Group(tparent, SWT.NONE);
    groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
    groupExportType.setLayout(new GridLayout(3, false));
    groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Label lblExportType = new Label(groupExportType, SWT.NONE);
    lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
    cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
    GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
    for (String type : ExportExternal.getExportTypes()) {
        cmb.add(type);
    }
    cmb.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
            btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
            btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
            btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
            if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
                btnNotrans.setSelection(false);
            }
        }
    });
    final Label lblR8State = new Label(groupExportType, SWT.NONE);
    lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
    btnHsproofState = new Button(groupExportType, SWT.CHECK);
    btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
    btnHsproofNote = new Button(groupExportType, SWT.CHECK);
    btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
    final Group groupFilter = new Group(tparent, SWT.NONE);
    groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
    groupFilter.setLayout(new GridLayout(3, false));
    groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
    // 过滤大类
    btnAllTrans = new Button(groupFilter, SWT.RADIO);
    btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
    btnAllTrans.setSelection(true);
    btnAllTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnAllTrans.getSelection()) {
                setFilterDefaultValue();
            }
        }
    });
    btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
    btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
    btnOnlySpecial.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnOnlySpecial.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
    btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
    btnFilterWhenState.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnFilterWhenState.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    // 大类细节
    cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
    cmpFilterAllTrans.setLayout(new GridLayout(1, false));
    cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
    btnExceptLocked.setEnabled(true);
    btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
    btnExceptContextMatch.setEnabled(true);
    btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
    cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
    cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
    btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
    btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
    cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
    cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterWhenState.setLayout(new GridLayout(1, false));
    btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
    btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
    btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
    btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
    Composite cmpSaveas = new Composite(tparent, SWT.NONE);
    cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
    cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
    lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
    txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
    txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtSaveas.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
        }
    });
    Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
    btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
    btnSaveas.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            dialog.setFilterPath(dialogSetting.get("defaultPath"));
            String path = dialog.open();
            if (path != null) {
                txtSaveas.setText(path);
                dialogSetting.put("defaultPath", path);
            }
        }
    });
    setDefaultValue();
    return parent;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 13 with TableViewer

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

the class JavaPropertiesViewerDialog method createTableViewer.

private void createTableViewer(Composite tparent) {
    tableViewer = new TableViewer(tparent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    String[] columnNames = new String[] { Messages.getString("dialog.JavaPropertiesViewerDialog.columnNames1"), Messages.getString("dialog.JavaPropertiesViewerDialog.columnNames2") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    // 让列表列宽动态变化
    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.48, 0.48 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) Table(org.eclipse.swt.widgets.Table) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerLabelProvider(net.heartsome.cat.ts.ui.plugin.TableViewerLabelProvider) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 14 with TableViewer

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

the class BatchQADialog method createFileDataGroup.

/**
	 * @param parent
	 */
public void createFileDataGroup(Composite parent) {
    Composite parentCmp = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(9, 9, 0, 0).numColumns(1).applyTo(parentCmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parentCmp);
    tableViewer = new TableViewer(parentCmp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 50;
    table.setLayoutData(tableData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] columnNames = new String[] { Messages.getString("qa.all.dialog.index"), Messages.getString("qa.dialogs.BatchQADialog.name2") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(getQATableInfo());
    // 让列表列宽动态变化
    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.1, 0.8 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    //如果是合并打开的文件,那么创建一个 LABLE 进行提示
    if (isMultiFile) {
        Label remarkLbl = new Label(parentCmp, SWT.WRAP);
        remarkLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        remarkLbl.setText(Messages.getString("qa.dialogs.BatchQADialog.tip1"));
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 15 with TableViewer

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

TableViewer (org.eclipse.jface.viewers.TableViewer)215 GridData (org.eclipse.swt.layout.GridData)135 Composite (org.eclipse.swt.widgets.Composite)126 Table (org.eclipse.swt.widgets.Table)103 GridLayout (org.eclipse.swt.layout.GridLayout)102 SelectionEvent (org.eclipse.swt.events.SelectionEvent)99 TableColumn (org.eclipse.swt.widgets.TableColumn)85 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)77 Label (org.eclipse.swt.widgets.Label)59 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)50 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)48 Button (org.eclipse.swt.widgets.Button)48 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)47 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)45 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)44 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)33 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)33 Event (org.eclipse.swt.widgets.Event)26 Listener (org.eclipse.swt.widgets.Listener)26 Point (org.eclipse.swt.graphics.Point)25