use of org.eclipse.core.databinding.observable.list.WritableList in project translationstudio8 by heartsome.
the class ReverseConversionWizardPage method createFilesGroup.
/**
* 创建文件列表区域
* @param contents
* ;
*/
private Composite createFilesGroup(Composite contents) {
Composite filesComposite = new Composite(contents, SWT.NONE);
filesComposite.setLayout(new GridLayout(1, false));
filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
tableData.heightHint = 100;
filesTable.setLayoutData(tableData);
filesTable.setLinesVisible(true);
filesTable.setHeaderVisible(true);
filesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] selected = filesTable.getSelection();
if (selected.length == 0) {
return;
}
//$NON-NLS-1$
String strTgtEnc = "";
for (int i = 0; i < selected.length; i++) {
String curTgtEnc = selected[i].getText(2);
if (i == 0) {
strTgtEnc = curTgtEnc;
} else {
if (!strTgtEnc.equals(curTgtEnc)) {
//$NON-NLS-1$
strTgtEnc = "";
break;
}
}
}
if (!"".equals(strTgtEnc)) {
//$NON-NLS-1$
tgtEncCombo.setText(strTgtEnc);
} else {
tgtEncCombo.deselectAll();
}
}
});
tableViewer = new TableViewer(filesTable);
lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn"));
tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn"));
targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
//$NON-NLS-1$
targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn"));
IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "targetEncoding", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"target" });
ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
filesComposite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent arg0) {
int width = filesTable.getClientArea().width;
lineNumberColumn.setWidth(width * 1 / 10);
targetColumn.setWidth(width * 4 / 10);
tgtEncColumn.setWidth(width * 1 / 10);
xliffColumn.setWidth(width * 4 / 10);
}
});
return filesComposite;
}
use of org.eclipse.core.databinding.observable.list.WritableList in project translationstudio8 by heartsome.
the class TmDbManagerDialog method createPageContainer.
/**
* 创建右侧页面内容
* @param parent
* 页面容器
* @return ;
*/
protected Composite createPageContainer(Composite parent) {
Composite outer = new Composite(parent, SWT.NONE);
GridData outerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
outerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
outer.setLayout(new GridLayout());
outer.setLayoutData(outerData);
// Create an outer composite for spacing
ScrolledComposite scrolled = new ScrolledComposite(outer, SWT.V_SCROLL | SWT.H_SCROLL);
// always show the focus control
scrolled.setShowFocusedControl(true);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
GridLayout gld = new GridLayout(1, false);
gld.marginWidth = 0;
gld.marginHeight = 0;
scrolled.setLayout(gld);
Composite result = new Composite(scrolled, SWT.NONE);
GridData resultData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
result.setLayoutData(resultData);
GridLayout gl_result = new GridLayout(1, false);
gl_result.marginWidth = 0;
gl_result.marginHeight = 0;
result.setLayout(gl_result);
Group parameterGroup = new Group(result, SWT.NONE);
parameterGroup.setText(Messages.getString("dialog.TmDbManagerDialog.parameterGroup"));
GridLayout parameterLayout = new GridLayout(4, false);
parameterGroup.setLayout(parameterLayout);
GridData parameterGridData = new GridData(GridData.FILL_HORIZONTAL);
parameterGroup.setLayoutData(parameterGridData);
Label label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblHost"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
hostText = new Text(parameterGroup, SWT.BORDER);
hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblPort"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
portText = new Text(parameterGroup, SWT.BORDER);
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblInstance"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
instanceText = new Text(parameterGroup, SWT.BORDER);
instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(parameterGroup, SWT.NONE);
new Label(parameterGroup, SWT.NONE);
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblLocation"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
locationText = new Text(parameterGroup, SWT.BORDER);
locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
borwserBtn = new Button(parameterGroup, SWT.NONE);
borwserBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
borwserBtn.setText(Messages.getString("dialog.TmDbManagerDialog.borwserBtn"));
borwserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
String path = dlg.open();
if (path != null) {
locationText.setText(path);
}
}
});
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblUsername"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
usernameText = new Text(parameterGroup, SWT.BORDER);
usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TmDbManagerDialog.lblPwd"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
passwordText = new Text(parameterGroup, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Composite btnComposite = new Composite(parameterGroup, SWT.NONE);
btnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
GridLayout btnCompositeLayout = new GridLayout(1, false);
btnCompositeLayout.marginHeight = 0;
btnCompositeLayout.marginWidth = 0;
btnComposite.setLayout(btnCompositeLayout);
// remenmberBtn = new Button(btnComposite, SWT.CHECK|SWT.BORDER);
// remenmberBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
// remenmberBtn.setText("将本次连接信息添加到数据库类型的快捷连接方式(&R)");
// remenmberBtn.setSelection(true);
searchBtn = new Button(btnComposite, SWT.NONE);
searchBtn.setText(Messages.getString("dialog.TmDbManagerDialog.searchBtn"));
searchBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
// 输入合法性检查
IStatus status = validator();
if (status.getSeverity() != IStatus.OK) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), status.getMessage());
return;
}
SystemDBOperator sysDbOp = getCurrSysDbOp();
if (sysDbOp == null) {
return;
}
// 连接检查
if (!sysDbOp.checkDbConnection()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg1"));
return;
}
// if (remenmberBtn.getSelection() == true) {
// 当前数据库类型下的所有服务器
List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(getCurrDbType());
if (currServer.getId().equals("")) {
addServerWithExistCheck(currServer, currDbTypeServers);
getTreeViewer().refresh();
// 在树上选择当前操作的节点
selectSaveItem();
}
// ISelection selection = getTreeViewer().getSelection();
// if (selection.isEmpty()) {
// return;
// }
// } else { // 不记住信息
executeSearch(sysDbOp);
// }
}
});
}
});
Group tableComposite = new Group(result, SWT.NONE);
tableComposite.setText(Messages.getString("dialog.TmDbManagerDialog.tableComposite"));
tableComposite.setLayout(new GridLayout(1, false));
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
dbTableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = dbTableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
tableGd.heightHint = 180;
table.setLayoutData(tableGd);
createColumn(dbTableViewer);
if (getDialogUseFor() == TYPE_DBSELECTED) {
dbTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
}
dbTableViewer.setContentProvider(new ArrayContentProvider());
currServerdbListInput = new WritableList(currServerdbList, DatabaseManagerDbListBean.class);
dbTableViewer.setInput(currServerdbListInput);
Composite composite = new Composite(tableComposite, SWT.NONE);
GridLayout gl_composite = new GridLayout(3, false);
gl_composite.marginHeight = 0;
gl_composite.marginWidth = 0;
composite.setLayout(gl_composite);
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
Button btnc = new Button(composite, SWT.NONE);
btnc.setText(Messages.getString("dialog.TmDbManagerDialog.btnc"));
btnc.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createNewDatabase();
}
});
Button btnd_1 = new Button(composite, SWT.NONE);
btnd_1.setText(Messages.getString("dialog.TmDbManagerDialog.btnd_1"));
btnd_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
ISelection selection = getDbTableViewer().getSelection();
if (selection.isEmpty()) {
return;
}
if (MessageDialog.openConfirm(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg2"))) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@SuppressWarnings("unchecked") List<DatabaseManagerDbListBean> needDeletes = structuredSelection.toList();
SystemDBOperator dbop = getCurrSysDbOp();
for (int i = 0; i < needDeletes.size(); i++) {
try {
String dbName = needDeletes.get(i).getDbName();
dbop.dropDb(dbName);
dbop.removeSysDb(dbName);
} catch (Exception e1) {
logger.error(Messages.getString("dialog.TmDbManagerDialog.logger1"), e1);
MessageDialog.openError(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg3") + e1.getMessage());
break;
}
currServerdbListInput.remove(needDeletes.get(i));
}
}
}
});
}
});
Button importBtn = new Button(composite, SWT.NONE);
importBtn.setText(Messages.getString("dialog.TmDbManagerDialog.importBtn"));
importBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = getDbTableViewer().getSelection();
if (selection.isEmpty()) {
MessageDialog.openError(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg4"));
return;
}
IStructuredSelection stcSel = (IStructuredSelection) selection;
DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) stcSel.getFirstElement();
DatabaseModelBean dbModelBean = new DatabaseModelBean();
currServer.copyToOtherIntance(dbModelBean);
dbModelBean.setDbName(dbBean.getDbName());
ImportTmxWizard wizard = new ImportTmxWizard(dbModelBean);
ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard) {
// robert help 2012-09-06
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 记忆库管理-导入TMX
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html#create-tm-wizard-import-tmx", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
};
dlg.setHelpAvailable(true);
if (dlg.open() == 0) {
// 重新加载内容
executeSearch(getCurrSysDbOp());
}
}
});
Point searchPoint = searchBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point createPoint = btnc.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point remPoint = btnd_1.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point importPoint = importBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(searchPoint.x, createPoint.x)));
GridData btnData = new GridData();
btnData.widthHint = width + 10;
btnc.setLayoutData(btnData);
btnd_1.setLayoutData(btnData);
importBtn.setLayoutData(btnData);
searchBtn.getLayoutData();
GridData searchData = new GridData(SWT.RIGHT, SWT.CENTER, true, true, 4, 1);
searchData.widthHint = width + 10;
searchBtn.setLayoutData(searchData);
scrolled.setContent(result);
scrolled.setMinSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
return result;
}
use of org.eclipse.core.databinding.observable.list.WritableList in project translationstudio8 by heartsome.
the class TermDbManagerDialog method createPageContainer.
/**
* 创建右侧页面内容
* @param parent
* 页面容器
* @return ;
*/
protected Composite createPageContainer(Composite parent) {
Composite outer = new Composite(parent, SWT.NONE);
GridData outerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
outerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
outer.setLayout(new GridLayout());
outer.setLayoutData(outerData);
// Create an outer composite for spacing
ScrolledComposite scrolled = new ScrolledComposite(outer, SWT.V_SCROLL | SWT.H_SCROLL);
// always show the focus control
scrolled.setShowFocusedControl(true);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
GridLayout gld = new GridLayout(1, false);
gld.marginWidth = 0;
gld.marginHeight = 0;
scrolled.setLayout(gld);
Composite result = new Composite(scrolled, SWT.NONE);
GridData resultData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
result.setLayoutData(resultData);
GridLayout gl_result = new GridLayout(1, false);
gl_result.marginWidth = 0;
gl_result.marginHeight = 0;
result.setLayout(gl_result);
Group parameterGroup = new Group(result, SWT.NONE);
parameterGroup.setText(Messages.getString("dialog.TermDbManagerDialog.parameterGroup"));
GridLayout parameterLayout = new GridLayout(4, false);
parameterGroup.setLayout(parameterLayout);
GridData parameterGridData = new GridData(GridData.FILL_HORIZONTAL);
parameterGroup.setLayoutData(parameterGridData);
Label label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblHost"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
hostText = new Text(parameterGroup, SWT.BORDER);
hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblPort"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
portText = new Text(parameterGroup, SWT.BORDER);
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblInstance"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
instanceText = new Text(parameterGroup, SWT.BORDER);
instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(parameterGroup, SWT.NONE);
new Label(parameterGroup, SWT.NONE);
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblLocation"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
locationText = new Text(parameterGroup, SWT.BORDER);
locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
borwserBtn = new Button(parameterGroup, SWT.NONE);
borwserBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
borwserBtn.setText(Messages.getString("dialog.TermDbManagerDialog.borwserBtn"));
borwserBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
String path = dlg.open();
if (path != null) {
locationText.setText(path);
}
}
});
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblUsername"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
usernameText = new Text(parameterGroup, SWT.BORDER);
usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label = new Label(parameterGroup, SWT.RIGHT);
label.setText(Messages.getString("dialog.TermDbManagerDialog.lblPwd"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
passwordText = new Text(parameterGroup, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Composite btnComposite = new Composite(parameterGroup, SWT.NONE);
btnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
GridLayout btnCompositeLayout = new GridLayout(1, false);
btnCompositeLayout.marginHeight = 0;
btnCompositeLayout.marginWidth = 0;
btnComposite.setLayout(btnCompositeLayout);
// remenmberBtn = new Button(btnComposite, SWT.CHECK|SWT.BORDER);
// remenmberBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
// remenmberBtn.setText("将本次连接信息添加到数据库类型的快捷连接方式(&R)");
// remenmberBtn.setSelection(true);
searchBtn = new Button(btnComposite, SWT.NONE);
searchBtn.setText(Messages.getString("dialog.TermDbManagerDialog.searchBtn"));
searchBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
// 输入合法性检查
IStatus status = validator();
if (status.getSeverity() != IStatus.OK) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), status.getMessage());
return;
}
SystemDBOperator sysDbOp = getCurrSysDbOp();
if (sysDbOp == null) {
return;
}
// 连接检查
if (!sysDbOp.checkDbConnection()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg1"));
return;
}
// if (remenmberBtn.getSelection() == true) {
// 当前数据库类型下的所有服务器
List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(getCurrDbType());
if (currServer.getId().equals("")) {
addServerWithExistCheck(currServer, currDbTypeServers);
getTreeViewer().refresh();
// 在树上选择当前操作的节点
selectSaveItem();
}
// ISelection selection = getTreeViewer().getSelection();
// if (selection.isEmpty()) {
// return;
// }
// } else { // 不记住信息
executeSearch(sysDbOp);
// }
}
});
}
});
Group tableComposite = new Group(result, SWT.NONE);
tableComposite.setText(Messages.getString("dialog.TermDbManagerDialog.tableComposite"));
tableComposite.setLayout(new GridLayout(1, false));
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
dbTableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = dbTableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
tableGd.heightHint = 180;
table.setLayoutData(tableGd);
createColumn(dbTableViewer);
if (getDialogUseFor() == TYPE_DBSELECTED) {
dbTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
}
dbTableViewer.setContentProvider(new ArrayContentProvider());
currServerdbListInput = new WritableList(currServerdbList, DatabaseManagerDbListBean.class);
dbTableViewer.setInput(currServerdbListInput);
Composite composite = new Composite(tableComposite, SWT.NONE);
GridLayout gl_composite = new GridLayout(3, false);
gl_composite.marginHeight = 0;
gl_composite.marginWidth = 0;
composite.setLayout(gl_composite);
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
Button btnc = new Button(composite, SWT.NONE);
btnc.setText(Messages.getString("dialog.TermDbManagerDialog.btnc"));
btnc.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createNewDatabase();
}
});
Button btnd_1 = new Button(composite, SWT.NONE);
btnd_1.setText(Messages.getString("dialog.TermDbManagerDialog.btnd_1"));
btnd_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
ISelection selection = getDbTableViewer().getSelection();
if (selection.isEmpty()) {
return;
}
if (MessageDialog.openConfirm(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg2"))) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@SuppressWarnings("unchecked") List<DatabaseManagerDbListBean> needDeletes = structuredSelection.toList();
SystemDBOperator dbop = getCurrSysDbOp();
for (int i = 0; i < needDeletes.size(); i++) {
try {
String dbName = needDeletes.get(i).getDbName();
dbop.dropDb(dbName);
dbop.removeSysDb(dbName);
} catch (Exception e1) {
logger.error(Messages.getString("dialog.TermDbManagerDialog.logger1"), e1);
MessageDialog.openError(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg3") + e1.getMessage());
break;
}
currServerdbListInput.remove(needDeletes.get(i));
}
}
}
});
}
});
Button importBtn = new Button(composite, SWT.NONE);
importBtn.setText(Messages.getString("dialog.TermDbManagerDialog.importBtn"));
importBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = getDbTableViewer().getSelection();
if (selection.isEmpty()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg4"));
return;
}
IStructuredSelection stcSel = (IStructuredSelection) selection;
DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) stcSel.getFirstElement();
DatabaseModelBean dbModelBean = new DatabaseModelBean();
currServer.copyToOtherIntance(dbModelBean);
dbModelBean.setDbName(dbBean.getDbName());
TbxImportWizard wizard = new TbxImportWizard(dbModelBean);
TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
// 重新加载内容
executeSearch(getCurrSysDbOp());
}
}
});
Point searchPoint = searchBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point createPoint = btnc.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point remPoint = btnd_1.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point importPoint = importBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(searchPoint.x, createPoint.x)));
GridData btnData = new GridData();
btnData.widthHint = width + 10;
btnc.setLayoutData(btnData);
btnd_1.setLayoutData(btnData);
importBtn.setLayoutData(btnData);
searchBtn.getLayoutData();
GridData searchData = new GridData(SWT.RIGHT, SWT.CENTER, true, true, 4, 1);
searchData.widthHint = width + 10;
searchBtn.setLayoutData(searchData);
scrolled.setContent(result);
scrolled.setMinSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
return result;
}
use of org.eclipse.core.databinding.observable.list.WritableList in project translationstudio8 by heartsome.
the class ConversionWizardPage method createFilesGroup.
/**
* 创建文件列表区域
* @param contents
* ;
*/
private Composite createFilesGroup(Composite contents) {
Composite filesComposite = new Composite(contents, SWT.NONE);
GridLayout gd = new GridLayout(2, false);
gd.marginWidth = 0;
filesComposite.setLayout(gd);
filesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
tableData.heightHint = 100;
filesTable.setLayoutData(tableData);
filesTable.setLinesVisible(true);
filesTable.setHeaderVisible(true);
filesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doSelectedEvent();
}
});
tableViewer = new TableViewer(filesTable);
lineNumColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
lineNumColumn.setText(Messages.getString("wizard.ConversionWizardPage.lineNumColumn"));
sourceColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
sourceColumn.setText(Messages.getString("wizard.ConversionWizardPage.sourceColumn"));
formatColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
formatColumn.setText(Messages.getString("wizard.ConversionWizardPage.formatColumn"));
srcEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
srcEncColumn.setText(Messages.getString("wizard.ConversionWizardPage.srcEncColumn"));
IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "fileType", "srcEncoding" });
ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
filesComposite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent arg0) {
int width = filesTable.getClientArea().width;
lineNumColumn.setWidth(width * 1 / 10);
sourceColumn.setWidth(width * 5 / 10);
formatColumn.setWidth(width * 3 / 10);
srcEncColumn.setWidth(width * 1 / 10);
}
});
Composite opComp = new Composite(filesComposite, SWT.NONE);
GridLayout opCompGl = new GridLayout();
opCompGl.marginWidth = 0;
opCompGl.marginLeft = 0;
opCompGl.marginTop = 0;
opCompGl.marginHeight = 0;
opComp.setLayout(opCompGl);
GridData gd_opComp = new GridData();
gd_opComp.verticalAlignment = SWT.TOP;
opComp.setLayoutData(gd_opComp);
Button addBt = new Button(opComp, SWT.NONE);
addBt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addBt.setText(Messages.getString("wizard.ConversionWizardPage.addbutton"));
addBt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), true, IResource.FILE) {
// 打开对话框时展开树形目录
public void create() {
super.create();
super.getTreeViewer().expandAll();
}
};
dialog.setMessage(Messages.getString("wizard.ConversionWizardPage.selectfiledialog.message"));
dialog.setTitle(Messages.getString("wizard.ConversionWizardPage.selectfiledialog.title"));
dialog.setDoubleClickSelects(true);
try {
dialog.setInput(EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()));
} catch (CoreException e1) {
LOGGER.error("", e1);
e1.printStackTrace();
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof LocalFile) {
LocalFile folder = (LocalFile) element;
if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata")) {
return false;
}
String projectPath = currentProject.getLocation().toOSString();
if (projectPath.equals(folder.toString())) {
return true;
}
String xliffFolderPath = folder.toString();
String path1 = projectPath + File.separator + Constant.FOLDER_SRC;
if (xliffFolderPath.startsWith(path1)) {
for (ConversionConfigBean bean : conversionConfigBeans) {
if (xliffFolderPath.indexOf(bean.getSource()) != -1) {
return false;
}
}
return true;
}
}
return false;
}
});
dialog.create();
dialog.open();
if (dialog.getResult() != null) {
Object[] selectFiles = dialog.getResult();
for (Object selectedFile : selectFiles) {
LocalFile folder = (LocalFile) selectedFile;
ConverterViewModel model = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_POSITIVE);
Object adapter = Platform.getAdapterManager().getAdapter(ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(folder.toString())), IConversionItem.class);
IConversionItem sourceItem = null;
if (adapter instanceof IConversionItem) {
sourceItem = (IConversionItem) adapter;
}
// 记住所选择的文件
model.setConversionItem(sourceItem);
ConversionConfigBean bean = model.getConfigBean();
// 初始化源文件路径
bean.setSource(ResourceUtils.toWorkspacePath(folder.toString()));
// 初始化源语言
bean.setSrcLang(srcLang);
bean.setTgtLangList(targetlanguage);
if (targetlanguage != null && targetlanguage.size() > 0) {
List<Language> lang = new ArrayList<Language>();
lang.add(targetlanguage.get(0));
bean.setHasSelTgtLangList(lang);
}
bean.setReplaceTarget(isReplaceTarget);
bean.setInitSegmenter(srxFile.getText());
conversionConfigBeans.add(bean);
converterViewModels.add(model);
}
loadFiles();
validate();
tableViewer.refresh();
}
}
});
Button removeBt = new Button(opComp, SWT.NONE);
removeBt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeBt.setText(Messages.getString("wizard.ConversionWizardPage.removebutton"));
removeBt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (conversionConfigBeans.size() == 0) {
return;
}
ISelection sel = tableViewer.getSelection();
if (sel.isEmpty()) {
MessageDialog.openError(getShell(), Messages.getString("wizard.ConversionWizardPage.removebutton.msg1.title"), Messages.getString("wizard.ConversionWizardPage.removebutton.msg1"));
return;
}
if (sel instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) sel;
Object[] objs = ssel.toArray();
int index = conversionConfigBeans.indexOf(ssel.getFirstElement());
index -= ssel.size();
index = index < 0 ? 0 : index;
for (Object obj : objs) {
int i = conversionConfigBeans.indexOf(obj);
conversionConfigBeans.remove(i);
converterViewModels.remove(i);
}
loadFiles();
tableViewer.refresh();
if (!conversionConfigBeans.isEmpty()) {
tableViewer.getTable().select(index);
doSelectedEvent();
}
validate();
}
}
});
return filesComposite;
}
Aggregations