use of org.eclipse.jface.viewers.ArrayContentProvider 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;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class QAInstalPage method createTableCombo.
private void createTableCombo(TableComboViewer tCmbViewer) {
TableCombo tableCombo = tCmbViewer.getTableCombo();
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(2);
GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(tableCombo);
tCmbViewer.setLabelProvider(new QATipsLabelProvider());
tCmbViewer.setContentProvider(new ArrayContentProvider());
tCmbViewer.setInput(CONSTANT_COMBOVALUE);
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class SpellPage method createAspellCmp.
/**
* 创建 aspell 的配置界面
*/
private void createAspellCmp() {
isInit = true;
Composite groupParent = new Composite(tabFolder, SWT.NONE);
groupParent.setLayout(new GridLayout());
groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
// Group groupParent = new Group(tparent, SWT.None);
// groupParent.setLayout(new GridLayout());
// groupParent.setLayoutData(new GridData(GridData.FILL_BOTH));
// groupParent.setText(Messages.getString("qa.preference.SpellPage.groupParent"));
HsImageLabel imageLabel = new HsImageLabel(Messages.getString("qa.preference.SpellPage.imageLabel"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_ASPELL_DIC));
Composite cmp = imageLabel.createControl(groupParent);
cmp.setLayout(new GridLayout());
Composite cmpTemp = (Composite) imageLabel.getControl();
cmpTemp.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite cmpContent = new Composite(cmpTemp, SWT.None);
cmpContent.setLayout(new GridLayout(3, false));
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
cmpContent.setLayoutData(data);
Label lbl = new Label(cmpContent, SWT.NONE);
lbl.setText(Messages.getString("qa.preference.SpellPage.lblPath"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
txtCommandPath = new Text(cmpContent, SWT.BORDER);
txtCommandPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txtCommandPath.setEditable(false);
btnBrowse = new Button(cmpContent, SWT.NONE);
btnBrowse.setText(Messages.getString("qa.preference.SpellPage.btnBrowse"));
// GridData btnData = new GridData();
// btnData.widthHint = 70;
// btnBrowse.setLayoutData(btnData);
new Label(cmpContent, SWT.NONE);
btnUTF8 = new Button(cmpContent, SWT.CHECK);
btnUTF8.setText(Messages.getString("qa.preference.SpellPage.btnUTF8"));
new Label(cmpContent, SWT.NONE);
lbl = new Label(cmpContent, SWT.NONE);
lbl.setText(Messages.getString("qa.preference.SpellPage.lblDic"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
cmbDefaultDic = new ComboViewer(cmpContent);
cmbDefaultDic.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnRefresh = new Button(cmpContent, SWT.NONE);
btnRefresh.setText(Messages.getString("qa.preference.SpellPage.btnRefresh"));
lbl = new Label(cmpContent, SWT.NONE);
lbl.setText(Messages.getString("qa.preference.SpellPage.lblLang"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
cmbLang = new TableComboViewer(cmpContent, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = cmbLang.getTableCombo();
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
cmbLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
cmbLang.setLabelProvider(new LanguageLabelProvider());
cmbLang.setContentProvider(new ArrayContentProvider());
cmbLang.setInput(languages);
cmbLang.getTableCombo().select(0);
new Label(cmpContent, SWT.NONE);
Composite cmpTableBtn = new Composite(cmpContent, SWT.NONE);
GridLayout btnLayout = new GridLayout(2, false);
btnLayout.marginWidth = 0;
cmpTableBtn.setLayout(btnLayout);
GridData btnData1 = new GridData(GridData.FILL_BOTH);
btnData1.horizontalSpan = 3;
cmpTableBtn.setLayoutData(btnData1);
btnAdd = new Button(cmpTableBtn, SWT.NONE);
btnAdd.setText(Messages.getString("qa.preference.SpellPage.btnAdd"));
btnRemove = new Button(cmpTableBtn, SWT.NONE);
btnRemove.setText(Messages.getString("qa.preference.SpellPage.btnRemove"));
Point browsePoint = btnBrowse.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point refreshPoint = btnRefresh.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point addPoint = btnAdd.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point remPoint = btnRemove.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
GridData btnData = new GridData();
int width = Math.max(refreshPoint.x, Math.max(browsePoint.x, Math.max(addPoint.x, remPoint.x)));
btnData.widthHint = width + 10;
btnBrowse.setLayoutData(btnData);
btnRefresh.setLayoutData(btnData);
btnAdd.setLayoutData(btnData);
btnRemove.setLayoutData(btnData);
table = new Table(cmpTableBtn, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
String[] arrTableHeader = new String[] { Messages.getString("qa.preference.SpellPage.arrTableHeader1"), "", Messages.getString("qa.preference.SpellPage.arrTableHeader2") };
int[] arrWidth = new int[] { 195, 40, 195 };
for (int i = 0; i < arrTableHeader.length; i++) {
int style = SWT.NONE;
if (i == 1) {
style = SWT.CENTER;
}
TableColumn col = new TableColumn(table, style);
col.setText(arrTableHeader[i]);
col.setWidth(arrWidth[i]);
}
GridData dataTable = new GridData(GridData.FILL_BOTH);
dataTable.horizontalSpan = 2;
table.setLayoutData(dataTable);
table.setHeaderVisible(true);
table.setLinesVisible(true);
initProperty();
initListener();
imageLabel.computeSize();
aspellTabItem.setControl(groupParent);
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class AddTermToTBDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().extendedMargins(5, 5, 10, 0).numColumns(2).equalWidth(true).applyTo(tparent);
GridData parentData = new GridData(GridData.FILL_BOTH);
tparent.setLayoutData(parentData);
Composite cmpTerm = new Composite(tparent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(cmpTerm);
GridDataFactory.swtDefaults().applyTo(cmpTerm);
Label lblSource = new Label(cmpTerm, SWT.NONE);
lblSource.setText(Messages.getString("dialog.AddTermToTBDialog.lblSource"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSource);
txtSrc = new Text(cmpTerm, SWT.BORDER);
GridData txtData = new GridData();
// 解决在 Windows 下文本框高度太小的问题
txtData.widthHint = 290;
txtSrc.setLayoutData(txtData);
Label lblTarget = new Label(cmpTerm, SWT.NONE);
lblTarget.setText(Messages.getString("dialog.AddTermToTBDialog.lblTarget"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTarget);
txtTgt = new Text(cmpTerm, SWT.BORDER);
txtTgt.setLayoutData(txtData);
Composite cmpLang = new Composite(tparent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(cmpLang);
GridDataFactory.fillDefaults().applyTo(cmpLang);
Label lblSrcLang = new Label(cmpLang, SWT.NONE);
lblSrcLang.setText(Messages.getString("dialog.AddTermToTBDialog.lblSrcLang"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSrcLang);
cmbSrcLang = new TableComboViewer(cmpLang, SWT.READ_ONLY | SWT.BORDER);
cmbSrcLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
cmbSrcLang.setContentProvider(new ArrayContentProvider());
Label lblTgtLang = new Label(cmpLang, SWT.NONE);
lblTgtLang.setText(Messages.getString("dialog.AddTermToTBDialog.lblTgtLang"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTgtLang);
cmbTgtLang = new TableComboViewer(cmpLang, SWT.READ_ONLY | SWT.BORDER);
cmbTgtLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
cmbTgtLang.setContentProvider(new ArrayContentProvider());
Composite cmpProperty = new Composite(tparent, SWT.None);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(cmpProperty);
GridDataFactory.fillDefaults().span(2, 1).applyTo(cmpProperty);
Label lblProperty = new Label(cmpProperty, SWT.None);
lblProperty.setText(Messages.getString("dialog.AddTermToTBDialog.lblProperty"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblProperty);
txtProperty = new Text(cmpProperty, SWT.BORDER);
txtProperty.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
initProperty();
tparent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
return tparent;
}
use of org.eclipse.jface.viewers.ArrayContentProvider 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;
}
Aggregations