Search in sources :

Example 1 with DatabaseModelBean

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);
}
Also used : Action(org.eclipse.jface.action.Action) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) MenuManager(org.eclipse.jface.action.MenuManager) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) WritableList(org.eclipse.core.databinding.observable.list.WritableList) List(java.util.List) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with DatabaseModelBean

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(" ", ""));
    }
}
Also used : DatabaseManagerDbListBean(net.heartsome.cat.database.ui.bean.DatabaseManagerDbListBean) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with DatabaseModelBean

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;
}
Also used : Language(net.heartsome.cat.common.locale.Language) ProjectConfiger(net.heartsome.cat.ts.core.file.ProjectConfiger) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) TermBaseSearchDialog(net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog) IEditorPart(org.eclipse.ui.IEditorPart) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor) IProject(org.eclipse.core.resources.IProject)

Example 4 with DatabaseModelBean

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());
    }
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean)

Example 5 with DatabaseModelBean

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));
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Image(org.eclipse.swt.graphics.Image) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)71 ArrayList (java.util.ArrayList)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 SQLException (java.sql.SQLException)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 MenuItem (org.eclipse.swt.widgets.MenuItem)12 List (java.util.List)11 Point (org.eclipse.swt.graphics.Point)11 File (java.io.File)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 Button (org.eclipse.swt.widgets.Button)10 Composite (org.eclipse.swt.widgets.Composite)10 Label (org.eclipse.swt.widgets.Label)10 Menu (org.eclipse.swt.widgets.Menu)10 Iterator (java.util.Iterator)8 Map (java.util.Map)8 MetaData (net.heartsome.cat.common.bean.MetaData)8 HSDropDownButton (net.heartsome.cat.common.ui.HSDropDownButton)8