use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.
the class TBXMakerDialog method openFile.
/**
* 打开 CSV 文件 ;
*/
private void openFile() {
String[] templates = TBXTemplateUtil.getTemplateFiles(PluginUtil.getCataloguePath(), PluginUtil.getTemplatePath());
CSVSettingDialog dialog = new CSVSettingDialog(getShell(), true, imagePath, templates);
if (dialog.open() == IDialogConstants.OK_ID) {
csvPath = dialog.getCsvPath();
colSeparator = dialog.getColSeparator();
textDelimiter = dialog.getTextDelimiter();
encoding = dialog.getEncoding();
lang = dialog.getLang();
xcsTemplate = dialog.getXcsTemplate();
try {
template = new TBXTemplateUtil(xcsTemplate, PluginUtil.getTemplatePath(), "");
cols = maxColumns();
if (cols < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg1"));
return;
}
rows = 0;
int width = (table.getClientArea().width - table.getBorderWidth() * 2 - table.getVerticalBar().getSize().x) / cols;
if (width < 100) {
width = 100;
}
table.removeAll();
int count = table.getColumnCount();
for (int i = 0; i < count; i++) {
table.getColumn(0).dispose();
}
for (int i = 0; i < cols; i++) {
TableColumn col = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
col.setData(new ColProperties("" + (i + 1)));
table.getColumn(i).setWidth(width);
//$NON-NLS-1$
table.getColumn(i).setText("" + (i + 1));
}
fillTable();
table.layout(true);
lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), rows));
lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), cols));
} catch (IOException e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger1"), e);
} catch (Exception e) {
LOGGER.error(Messages.getString("dialog.TBXMakerDialog.logger1"), e);
}
}
}
use of org.eclipse.swt.widgets.TableColumn 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]));
}
});
}
});
}
use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.
the class CSV2TMXConverterDialog method removeColumn.
/**
* 删除列 ;
*/
private void removeColumn() {
if (cols < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.CSV2TMXConverterDialog.msgTitle"), Messages.getString("dialog.CSV2TMXConverterDialog.msg2"));
return;
}
Vector<String> columns = new Vector<String>();
int count = table.getColumnCount();
for (int i = 0; i < count; i++) {
columns.add(table.getColumn(i).getText());
}
ColumnRemoveDialog removeDialog = new ColumnRemoveDialog(getShell(), columns, imagePath);
if (removeDialog.open() == IDialogConstants.OK_ID) {
Vector<String> columnVector = removeDialog.getColumnVector();
if (columnVector.size() == columns.size()) {
return;
}
for (int i = 0; i < count; i++) {
TableColumn col = table.getColumn(i);
boolean found = false;
for (int j = 0; j < columnVector.size(); j++) {
if (col.getText().equals(columnVector.get(j))) {
found = true;
break;
}
}
if (!found) {
table.getColumn(i).dispose();
count--;
i--;
}
}
cols = table.getColumnCount();
lblColCount.setText(MessageFormat.format(Messages.getString("dialog.CSV2TMXConverterDialog.lblColCount"), //$NON-NLS-1$
cols));
int width = (table.getClientArea().width - table.getBorderWidth() * 2 - table.getVerticalBar().getSize().x) / cols;
if (width < 100) {
width = 100;
}
for (int i = 0; i < cols; i++) {
TableColumn column = table.getColumn(i);
column.setWidth(width);
}
}
}
use of org.eclipse.swt.widgets.TableColumn in project translationstudio8 by heartsome.
the class TBXMakerDialog method setColumnType.
/**
* 设置列属性 ;
*/
private void setColumnType() {
if (cols < 2) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg2"));
return;
}
Vector<ColProperties> colTypes = new Vector<ColProperties>(cols);
for (int i = 0; i < cols; i++) {
colTypes.add((ColProperties) table.getColumn(i).getData());
}
ColumnTypeDialog selector = new ColumnTypeDialog(getShell(), colTypes, template, imagePath);
if (selector.open() == IDialogConstants.OK_ID) {
for (int i = 0; i < cols; i++) {
TableColumn col = table.getColumn(i);
ColProperties type = colTypes.get(i);
if (!type.getColName().equals("") && !type.getLanguage().equals("")) {
//$NON-NLS-1$ //$NON-NLS-2$
col.setText(type.getColName());
}
}
}
}
use of org.eclipse.swt.widgets.TableColumn 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"));
}
}
Aggregations