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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations