use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TermDbManagerDialog method initTreePopMenu.
/**
* 初始化树右键菜单 ;
*/
private void initTreePopMenu() {
MenuManager menuManager = new MenuManager("");
menuManager.add(new Action(Messages.getString("dialog.TermDbManagerDialog.deleteAction")) {
@Override
public void run() {
ISelection selection = getTreeViewer().getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof DatabaseModelBean) {
List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
configer.deleteServerById(((DatabaseModelBean) obj).getId());
int i = currDbTypeServers.indexOf(obj);
currDbTypeServers.remove(i);
getTreeViewer().refresh();
if (currDbTypeServers.size() != 0) {
if (i > currDbTypeServers.size() - 1) {
setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
} else {
setLastSelectedServer(currDbTypeServers.get(i).getId());
}
initUI(false);
} else {
setLastSelectedServer(null);
initUI(true);
}
selectSaveItem();
}
}
});
Tree tree = treeViewer.getTree();
this.treePopMenu = menuManager.createContextMenu(tree);
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TermDbManagerDialog method executeSelectDatabase.
/**
* 当使用该对话框作为数据库选择时 ;
*/
private void executeSelectDatabase() {
ISelection selection = getDbTableViewer().getSelection();
if (selection.isEmpty()) {
return;
}
hasSelected = new HashMap<DatabaseModelBean, String>();
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Iterator<?> it = structuredSelection.iterator();
while (it.hasNext()) {
DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) it.next();
DatabaseModelBean dbModelBean = new DatabaseModelBean();
currServer.copyToOtherIntance(dbModelBean);
dbModelBean.setDbName(dbBean.getDbName());
// Fix Bug #3290 导出TMX/TBX--导出内容异常 去掉语言前后的空格
hasSelected.put(dbModelBean, dbBean.getLangs().replace(" ", ""));
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TermBaseSearchHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
if (!isEnabled()) {
return null;
}
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof IXliffEditor) {
IXliffEditor xliffEditor = (IXliffEditor) editor;
IProject project = ((FileEditorInput) editor.getEditorInput()).getFile().getProject();
ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(project);
List<DatabaseModelBean> lstDatabase = projectConfig.getTermBaseDbs(false);
if (lstDatabase == null || lstDatabase.size() == 0) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.TermBaseSearchHandler.msgTitle"), Messages.getString("handler.TermBaseSearchHandler.msg"));
return null;
}
String selectText = xliffEditor.getSelectPureText();
if ((selectText == null || selectText.equals("")) && xliffEditor.getSelectedRowIds().size() == 1) {
selectText = xliffEditor.getXLFHandler().getSrcPureText(xliffEditor.getSelectedRowIds().get(0));
selectText = resetCeanString(selectText);
}
String srcLang = xliffEditor.getSrcColumnName();
String tgtLang = xliffEditor.getTgtColumnName();
TermBaseSearchDialog dialog = new TermBaseSearchDialog(editor.getSite().getShell(), project, srcLang, tgtLang, selectText.trim());
Language srcLangL = LocaleService.getLanguageConfiger().getLanguageByCode(srcLang);
Language tgtLangL = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLang);
dialog.open();
if (srcLangL.isBidi() || tgtLangL.isBidi()) {
dialog.getShell().setOrientation(SWT.RIGHT_TO_LEFT);
}
if (selectText != null && !selectText.trim().equals("")) {
dialog.search();
}
}
return null;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class NewProjectTbPage method addToCurrDbList.
private void addToCurrDbList(List<DatabaseModelBean> hasSelection) {
StringBuffer dbNames = new StringBuffer();
for (int i = 0; i < hasSelection.size(); i++) {
DatabaseModelBean dbModel = hasSelection.get(i);
checkDbHashMatch(dbModel);
if (!checkDbIsExist(curDbList, dbModel)) {
// 判断当前是否已经存在了
if (curDbList.size() == 0) {
// 第一个添加的库为默认库
dbModel.setDefault(true);
}
curDbList.add(dbModel);
this.tableViewer.refresh();
} else {
dbNames.append(dbModel.getDbName());
dbNames.append("\n");
}
}
if (dbNames.length() != 0) {
MessageDialog.openInformation(getShell(), Messages.getString("newproject.NewProjectTbPage.msgTitle"), Messages.getString("newproject.NewProjectTbPage.msg2") + dbNames.toString());
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class NewProjectTbPage method createColumn.
/**
* 创建Table列
* @param viewer
* ;
*/
private void createColumn(final TableViewer viewer) {
String[] clmnTitles = { Messages.getString("newproject.NewProjectTbPage.clmnTitles1"), Messages.getString("newproject.NewProjectTbPage.clmnTitles2"), Messages.getString("newproject.NewProjectTbPage.clmnTitles3"), Messages.getString("newproject.NewProjectTbPage.clmnTitles4"), Messages.getString("newproject.NewProjectTbPage.clmnTitles5") };
int[] clmnBounds = { 100, 100, 200, 90, 70 };
TableViewerColumn col = createTableViewerColumn(viewer, clmnTitles[0], clmnBounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
return dbModel.getDbName();
}
});
col = createTableViewerColumn(viewer, clmnTitles[1], clmnBounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.getDbType().equals(Constants.DBTYPE_SQLITE)) {
return Messages.getString("tb.dbtype.sqlite");
}
return dbModel.getDbType();
}
});
col = createTableViewerColumn(viewer, clmnTitles[2], clmnBounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.getDbType().equals(Constants.DBTYPE_INTERNALDB) || dbModel.getDbType().equals(Constants.DBTYPE_SQLITE)) {
return dbModel.getItlDBLocation();
}
return dbModel.getHost();
}
});
col = createTableViewerColumn(viewer, clmnTitles[3], clmnBounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isHasMatch()) {
return Messages.getString("newproject.NewProjectTbPage.yes");
} else {
return Messages.getString("newproject.NewProjectTbPage.no");
}
}
});
col = createTableViewerColumn(viewer, clmnTitles[4], clmnBounds[4], 4);
col.setLabelProvider(new ColumnLabelProvider() {
public Image getImage(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isDefault()) {
return checkedImage;
} else {
return uncheckedImage;
}
}
public String getText(Object element) {
return null;
}
});
col.setEditingSupport(new ReadableEditingSupport(viewer));
}
Aggregations