Search in sources :

Example 76 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method addTextViewerListener.

/**
	 * Add SQL viewer listener
	 *
	 * @param text
	 */
private void addTextViewerListener(final StyledText text) {
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            ServerInfo serverInfo = getServerInfo();
            boolean isLowerCase = QueryOptions.getKeywordLowercase(serverInfo);
            boolean isNoAutoUpperCase = QueryOptions.getNoAutoUppercaseKeyword(serverInfo);
            if (!isLowerCase && !isNoAutoUpperCase) {
                autoReplaceKeyword();
            }
        }

        // replace keyword to upper case automatically
        public void autoReplaceKeyword() {
            // FIXME extract tokenize code to utility
            if (pendingCompletionsListener) {
                return;
            }
            int pos = text.getCaretOffset() - 1;
            if (pos <= 0) {
                return;
            }
            String currentKey = text.getText(pos, pos);
            if (currentKey == null || currentKey.length() <= 0) {
                return;
            }
            char cur = currentKey.charAt(0);
            if (cur != ' ' && cur != '(' && cur != '\t' && cur != '\n' && cur != '\r' && cur != ',') {
                return;
            }
            pos--;
            if (pos < 0) {
                return;
            }
            int spos = pos - 20;
            if (spos < 0) {
                spos = 0;
            }
            String txt = text.getText(spos, pos);
            spos = pos + 1;
            for (int i = txt.length() - 1; i >= 0; i--) {
                char c = txt.charAt(i);
                if (c == ' ' || c == '\t' || c == '\n' || c == '(') {
                    break;
                }
                spos--;
            }
            int epos = pos;
            if (spos < 0 || epos < 0 || spos > epos) {
                return;
            }
            String currentKeyword = text.getText(spos, epos);
            if (currentKeyword == null) {
                return;
            }
            int len = currentKeyword.length();
            for (int i = 0; i < QuerySyntax.KEYWORDS_AUTO_UPPER.length; i++) {
                String keyword = QuerySyntax.KEYWORDS_AUTO_UPPER[i];
                if (keyword.equalsIgnoreCase(currentKeyword)) {
                    pendingCompletionsListener = true;
                    text.replaceTextRange(spos, len, keyword.toUpperCase());
                    pendingCompletionsListener = false;
                    break;
                }
            }
        }
    });
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.COMMAND) != 0) {
                //for Mac
                if ((event.stateMask & SWT.SHIFT) != 0) {
                    if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                        runQuery();
                        return;
                    }
                }
            }
            if (event.keyCode == SWT.F5 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'e') {
                runQuery();
            } else if (event.keyCode == SWT.F6 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'l') {
                runQueryPlan();
            } else if (event.keyCode == SWT.F3) {
                if ((event.stateMask & SWT.SHIFT) == 0) {
                    TextEditorFindReplaceMediator.findNext();
                } else {
                    TextEditorFindReplaceMediator.findPrevious();
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == ' ') {
                contentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'r') {
                recentlyUsedSQLcontentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0) {
                if (event.keyCode == 'z' || event.keyCode == 'Z') {
                    undoManager.undo();
                } else if (event.keyCode == 'y' || event.keyCode == 'Y') {
                    undoManager.redo();
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) != 0) {
                if (event.keyCode == 'f' || event.keyCode == 'F') {
                    try {
                        formatHandler.execute(null);
                    } catch (Exception ex) {
                        CommonUITool.openErrorBox(ex.getMessage());
                    }
                }
            } else if ((event.stateMask & SWT.ALT) != 0 && event.keyCode == '/') {
                try {
                    contentAssistHandler.execute(null);
                } catch (Exception ex) {
                    CommonUITool.openErrorBox(ex.getMessage());
                }
            }
            if (SQLContentAssistProcessor.isShowProposal(event.character)) {
                contentAssistant.showPossibleCompletions();
                useCompletions = true;
            } else if ((event.character >= 'A' && event.character <= 'Z') || (event.character >= 'a' && event.character <= 'z')) {
                if (useCompletions) {
                    contentAssistant.showPossibleCompletions();
                }
                useCompletions = false;
            } else if (event.character == ' ' || event.character == '\t' || event.keyCode == SWT.KEYPAD_CR || event.keyCode == SWT.CR || event.keyCode == SWT.BS || (text.getText().trim().length() < 1)) {
                useCompletions = true;
            }
        }
    });
    TextEditorFindReplaceMediator editorDialogMediator = new TextEditorFindReplaceMediator();
    text.addFocusListener(editorDialogMediator);
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TextEditorFindReplaceMediator(com.cubrid.tool.editor.TextEditorFindReplaceMediator) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter)

Example 77 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class MonitoringTaskTest method testConnectServer.

public void testConnectServer() {
    MonitoringTask task = new MonitoringTask(new ServerInfo());
    task.cancel();
    task.connectServer("8.2.0", 1000);
    task.cancel();
    task.stopMonitor();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 78 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class DatabaseInfoTest method testGetServerInfo.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getServerInfo()}
	 * .
	 */
public void testGetServerInfo() {
    bean.setServerInfo(new ServerInfo());
    assertEquals(bean.getServerInfo() != null, true);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 79 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class LoginDatabaseTaskTest method testSetDbUser.

public void testSetDbUser() {
    ServerInfo serverInfo = new ServerInfo();
    serverInfo.setServerVersion("8.2.0");
    LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
    task.setDbUser("adf");
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 80 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class LoginDatabaseTaskTest method testSetDbPasswd.

public void testSetDbPasswd() {
    ServerInfo serverInfo = new ServerInfo();
    serverInfo.setServerVersion("8.2.0");
    LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
    task.setDbPassword("adf");
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Aggregations

ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)255 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)40 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)37 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)35 ArrayList (java.util.ArrayList)30 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)29 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)24 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)20 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 ITask (com.cubrid.common.core.task.ITask)15