Search in sources :

Example 1 with SystemDBOperator

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 2 with SystemDBOperator

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();
    }
}
Also used : SystemDBOperator(net.heartsome.cat.database.SystemDBOperator)

Example 3 with SystemDBOperator

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);
            }
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener)

Example 4 with SystemDBOperator

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();
    }
}
Also used : SystemDBOperator(net.heartsome.cat.database.SystemDBOperator)

Example 5 with SystemDBOperator

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Aggregations

SystemDBOperator (net.heartsome.cat.database.SystemDBOperator)17 IStatus (org.eclipse.core.runtime.IStatus)6 ISelection (org.eclipse.jface.viewers.ISelection)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 SQLException (java.sql.SQLException)4 DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)4 MetaData (net.heartsome.cat.common.bean.MetaData)4 DatabaseManagerDbListBean (net.heartsome.cat.database.ui.bean.DatabaseManagerDbListBean)4 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 Point (org.eclipse.swt.graphics.Point)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)4 Group (org.eclipse.swt.widgets.Group)4