use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class NewProjectTmPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer.setContentProvider(new ArrayContentProvider());
createColumn(tableViewer);
tableViewer.setInput(curDbList);
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
DatabaseModelBean dbModel = (DatabaseModelBean) selection.getFirstElement();
if (dbModel != null && !dbModel.isHasMatch()) {
setMessage(Messages.getString("newproject.NewProjectTmPage.msg1"));
} else {
setMessage(null);
}
}
});
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
composite.setLayout(new GridLayout(5, false));
new Label(composite, SWT.NONE);
HSDropDownButton addBtn = new HSDropDownButton(composite, SWT.NONE);
addBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.addBtn"));
Menu addMenu = addBtn.getMenu();
MenuItem item = new MenuItem(addMenu, SWT.PUSH);
item.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddFileTm"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialg = new FileDialog(getShell());
fileDialg.setFilterExtensions(new String[] { "*.hstm", "*.*" });
String result = fileDialg.open();
if (result == null) {
return;
}
File f = new File(result);
if (!f.exists()) {
return;
}
Map<DatabaseModelBean, String> r = null;
try {
r = Utils.convertFile2TmModel(f, false);
} catch (Exception e1) {
MessageDialog.openError(getShell(), Messages.getString("tm.dialog.addFileTm.errorTitle"), e1.getMessage());
}
if (r == null) {
return;
}
Iterator<DatabaseModelBean> it = r.keySet().iterator();
if (it.hasNext()) {
DatabaseModelBean selectedVal = it.next();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
dbList.add(selectedVal);
addToCurrDbList(dbList);
}
}
});
MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
serverItem.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddServerTm"));
serverItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TmDbManagerDialog dialog = new TmDbManagerDialog(getShell());
dialog.setDialogUseFor(TmDbManagerDialog.TYPE_DBSELECTED);
if (dialog.open() == Window.OK) {
Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
while (it.hasNext()) {
dbList.add(it.next());
}
addToCurrDbList(dbList);
}
}
});
Button createBtn = new Button(composite, SWT.NONE);
createBtn.setText(Messages.getString("newproject.NewProjectTmPage.createBtn"));
createBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
NewTmDbWizard wizard = new NewTmDbWizard();
ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
DatabaseModelBean dbModel = wizard.getCreateDb();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>(1);
dbList.add(dbModel);
addToCurrDbList(dbList);
}
}
});
Button removeBtn = new Button(composite, SWT.NONE);
removeBtn.setText(Messages.getString("newproject.NewProjectTmPage.removeBtn"));
removeBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
removeForCurrDbList((IStructuredSelection) tableViewer.getSelection());
}
});
Button importTmxBtn = new Button(composite, SWT.NONE);
importTmxBtn.setText(Messages.getString("newproject.NewProjectTmPage.importTmxBtn"));
importTmxBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
Iterator<?> it = selection.iterator();
if (it.hasNext()) {
DatabaseModelBean dbModel = (DatabaseModelBean) it.next();
ImportTmxWizard wizard = new ImportTmxWizard(dbModel);
ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
checkDbHashMatch(dbModel, "M");
tableViewer.refresh();
}
} else {
MessageDialog.openInformation(getShell(), Messages.getString("newproject.NewProjectTmPage.msgTitle"), Messages.getString("newproject.NewProjectTmPage.msg3"));
}
}
});
addBtn.setFocus();
setControl(container);
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class UpdateTMWizardPage method createContent.
public void createContent(Composite parent) {
TableViewer tableViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
tableData.heightHint = 160;
table.setLayoutData(tableData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn columnNumber = new TableColumn(table, SWT.LEFT);
columnNumber.setText(Messages.getString("wizard.UpdateTMWizardPage.columnNumber"));
columnNumber.setWidth(50);
TableColumn columnPath = new TableColumn(table, SWT.LEFT);
columnPath.setText(Messages.getString("wizard.UpdateTMWizardPage.columnPath"));
columnPath.setWidth(400);
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(getTableInfo());
Group groupStatus = new Group(parent, SWT.None);
groupStatus.setLayout(new GridLayout());
groupStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
groupStatus.setText(Messages.getString("dialog.UpdateTMDialog.lbl"));
btnDraft = new Button(groupStatus, SWT.CHECK);
btnDraft.setText(Messages.getString("dialog.UpdateTMDialog.btnDraft"));
btnTranslated = new Button(groupStatus, SWT.CHECK);
btnTranslated.setText(Messages.getString("dialog.UpdateTMDialog.btnTranslated"));
btnTranslated.setSelection(true);
btnApproved = new Button(groupStatus, SWT.CHECK);
btnApproved.setText(Messages.getString("dialog.UpdateTMDialog.btnApproved"));
btnApproved.setSelection(true);
btnSignedOff = new Button(groupStatus, SWT.CHECK);
btnSignedOff.setText(Messages.getString("dialog.UpdateTMDialog.btnSignedOff"));
btnSignedOff.setSelection(true);
btnLocked = new Button(groupStatus, SWT.CHECK);
btnLocked.setText(Messages.getString("dialog.UpdateTMWizardPage.btnLocked"));
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class PreMachineTranslationResultDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
Composite composite = new Composite(container, SWT.NONE);
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.verticalSpacing = 0;
gl_composite.marginWidth = 0;
gl_composite.marginHeight = 0;
composite.setLayout(gl_composite);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
Table table = tableViewer.getTable();
GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
tableGd.heightHint = 220;
table.setLayoutData(tableGd);
table.setLinesVisible(true);
table.setHeaderVisible(true);
String[] clmnTitles = new String[] { Messages.getString("dialog.PreTranslationResultDialog.clmnTitles1"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles2"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles3"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles4"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles5"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles6") };
int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
for (int i = 0; i < clmnTitles.length; i++) {
createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
}
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(this.getTableViewerInput());
return container;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class SplitXliffWizardPage method createSplitInfo.
/**
* 创建分割文件段的相关信息
* @param tparent
*/
public void createSplitInfo(Composite tparent) {
tableViewer = new TableViewer(tparent, 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("wizard.SplitXliffWizardPage.columnNames1"), Messages.getString("wizard.SplitXliffWizardPage.columnNames2"), Messages.getString("wizard.SplitXliffWizardPage.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]);
}
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(splitXliff.getSplitTableInfos());
// 让列表列宽动态变化
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.5, 0.29 };
for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
}
});
}
});
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class LockRepeatedSegmentResultDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
Composite composite = new Composite(container, SWT.NONE);
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.verticalSpacing = 0;
gl_composite.marginWidth = 0;
gl_composite.marginHeight = 0;
composite.setLayout(gl_composite);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
Table table = tableViewer.getTable();
GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
tableGd.heightHint = 220;
table.setLayoutData(tableGd);
table.setLinesVisible(true);
table.setHeaderVisible(true);
String[] clmnTitles = new String[] { Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles1"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles2"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles3"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles4"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles5"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles6") };
int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
for (int i = 0; i < clmnTitles.length; i++) {
createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
}
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(this.getTableViewerInput());
return container;
}
Aggregations