use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class TermDbManagerDialog method createNewDatabase.
/**
* 创建新库 ;
*/
private void createNewDatabase() {
// 数据库连接参数输入合法性检查
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;
}
TermDbNameInputDialog inputDbNameialog = new TermDbNameInputDialog(getShell(), Messages.getString("dialog.TermDbManagerDialog.inputDbNameialogTitle"), Messages.getString("dialog.TermDbManagerDialog.inputDbNameialogMsg"), "", new IInputValidator() {
public String isValid(String newText) {
String vRs = DbValidator.valiateDbName(newText);
return vRs;
}
});
inputDbNameialog.setSystemDbOp(sysDbOp);
if (inputDbNameialog.open() == Window.OK) {
// 刷新界面
executeSearch(sysDbOp);
}
}
use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class TermDbNameInputDialog method okPressed.
@Override
protected void okPressed() {
SystemDBOperator dbop = getSystemDbOp();
createNewDatabase(dbop, super.getValue());
if (getReturnCode() == 2) {
super.okPressed();
}
}
use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class TmDbManagerDialog method addListeners.
/**
* Add Selection Listener to tree viewer
* @param viewer
* ;
*/
private void addListeners(final TreeViewer viewer) {
// 选择事件
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof DatabaseModelBean) {
DatabaseModelBean bean = (DatabaseModelBean) obj;
setCurrDbType(bean.getDbType());
bean.copyToOtherIntance(currServer);
SystemDBOperator dbop = getCurrSysDbOp();
if (dbop != null) {
executeSearch(dbop);
}
// 当数据库类型发生改变时重新初始化界面
initUI(false);
} else if (obj instanceof String) {
setCurrDbType((String) obj);
resetInputValue();
currServerdbListInput.clear();
initUI(true);
}
}
});
// 双击展开事件
((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(final SelectionEvent event) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof String) {
String type = (String) obj;
boolean expanded = viewer.getExpandedState(type);
viewer.setExpandedState(type, !expanded);
}
}
});
// 右键菜单事件,判断何时出现右键菜单
viewer.getControl().addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
Tree tree = treeViewer.getTree();
if (obj instanceof DatabaseModelBean) {
// 将菜单挂到树上
tree.setMenu(treePopMenu);
} else {
tree.setMenu(null);
}
}
});
}
use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class DatabaseNameInputDialog method okPressed.
@Override
protected void okPressed() {
SystemDBOperator dbop = getSystemDbOp();
createNewDatabase(dbop, super.getValue());
if (getReturnCode() == 2) {
super.okPressed();
}
}
use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class TmDbManagerDialog method createNewDatabase.
/**
* 创建新库 ;
*/
private void createNewDatabase() {
// 数据库连接参数输入合法性检查
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;
}
DatabaseNameInputDialog inputDbNameialog = new DatabaseNameInputDialog(getShell(), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogTitle"), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogMsg"), "", new IInputValidator() {
public String isValid(String newText) {
String vRs = DbValidator.valiateDbName(newText);
return vRs;
}
});
inputDbNameialog.setSystemDbOp(sysDbOp);
if (inputDbNameialog.open() == Window.OK) {
// 刷新界面
executeSearch(sysDbOp);
}
}
Aggregations