Search in sources :

Example 26 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class CubridTitleLineContrItem method getTitleForNavigator.

/**
	 * 
	 * Get title of CUBRID manager application for navigator
	 * 
	 * @param cubridNode the ICubridNode object
	 * @return the title
	 */
protected String getTitleForNavigator(ICubridNode cubridNode) {
    if (cubridNode == null) {
        return "";
    }
    String title = cubridNode.getLabel();
    CubridServer server = cubridNode.getServer();
    String serverTitle = server == null ? null : server.getLabel();
    if (server != null && server.isConnected()) {
        ServerInfo serverInfo = server.getServerInfo();
        ServerUserInfo userInfo = serverInfo == null ? null : serverInfo.getLoginedUserInfo();
        if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
            serverTitle = userInfo.getUserName() + "@" + serverTitle;
        }
        String monPort = server.getMonPort();
        if (monPort != null && monPort.trim().length() > 0) {
            serverTitle = serverTitle + ":" + monPort;
        }
    }
    StringBuffer dbTitleBuffer = new StringBuffer("");
    CubridDatabase database = cubridNode instanceof ISchemaNode ? ((ISchemaNode) cubridNode).getDatabase() : null;
    if (database != null && database.getDatabaseInfo() != null) {
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
        String userName = dbUserInfo == null ? null : dbUserInfo.getName();
        dbTitleBuffer = (userName != null && userName.trim().length() > 0) ? dbTitleBuffer.append(userName).append("@").append(dbInfo.getDbName()) : dbTitleBuffer;
        String brokerPort = QueryOptions.getBrokerPort(dbInfo);
        BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
        List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        boolean isExist = false;
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            if (brokerPort != null && brokerPort.equals(brokerInfo.getPort())) {
                isExist = true;
                String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
                String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
                dbTitleBuffer.append(":").append(text);
                break;
            }
        }
        if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
            dbTitleBuffer.append(":").append(brokerPort);
        }
        String charset = database.getDatabaseInfo().getCharSet();
        if (charset != null && charset.trim().length() > 0) {
            dbTitleBuffer.append(":charset=").append(charset);
        }
    }
    if (serverTitle != null && serverTitle.trim().length() > 0) {
        title = serverTitle;
    }
    if (dbTitleBuffer != null && dbTitleBuffer.toString().trim().length() > 0) {
        title = serverTitle + " / " + dbTitleBuffer.toString();
    }
    return title;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 27 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class LoginDatabaseDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    final Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 5;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label userNameLabel = new Label(composite, SWT.LEFT);
    userNameLabel.setText(Messages.lblDbUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
    if (database != null && database.getUserName() != null) {
        userNameText.setText(database.getUserName());
    }
    userNameText.addModifyListener(this);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, 100, -1));
    userNameText.setFocus();
    Label passwordLabel = new Label(composite, SWT.LEFT);
    passwordLabel.setText(Messages.lblDbPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(composite, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, 100, -1));
    if (database != null && database.getPassword() != null && database.isAutoSavePassword()) {
        passwordText.setText(database.getPassword());
    }
    if (database != null && database.getUserName() != null) {
        passwordText.selectAll();
        passwordText.setFocus();
    }
    new Composite(composite, SWT.NONE).setLayoutData(CommonUITool.createGridData(1, 1, 0, 0));
    Button btnSavePassword = new Button(composite, SWT.CHECK);
    btnSavePassword.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 1, -1, -1));
    btnSavePassword.setText(Messages.btnSavePassword);
    if (database == null) {
        btnSavePassword.setSelection(true);
        isSavePassword = true;
    } else {
        btnSavePassword.setSelection(database.isAutoSavePassword());
        isSavePassword = database.isAutoSavePassword();
    }
    btnSavePassword.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            isSavePassword = !isSavePassword;
        }
    });
    Label backgroundLabel = new Label(composite, SWT.None);
    backgroundLabel.setText(Messages.lblBackground);
    backgroundLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
    RGB selectedColor = null;
    if (editorConfig != null) {
        selectedColor = editorConfig.getBackGround();
    } else {
        selectedColor = EditorConstance.getDefaultBackground();
    }
    selectColorCombo = new SelectColorCombo(composite, SWT.BORDER, selectedColor);
    selectColorCombo.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, 110, -1));
    Label commentLabel = new Label(composite, SWT.None);
    commentLabel.setText(Messages.lblComment);
    commentLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    commentText = new Text(composite, SWT.BORDER);
    commentText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
    commentText.setTextLimit(64);
    if (editorConfig != null) {
        commentText.setText(StringUtil.nvl(editorConfig.getDatabaseComment()));
    }
    new Label(composite, SWT.None);
    Label commentDescLabel = new Label(composite, SWT.None);
    commentDescLabel.setText(Messages.lblDescComment);
    commentDescLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 4, 1, -1, -1));
    final Group brokerGroup = new Group(composite, SWT.NONE);
    {
        brokerGroup.setText(com.cubrid.common.ui.query.Messages.brokerGrp);
        brokerGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 5, 1, -1, -1));
        GridLayout brokerLayout = new GridLayout();
        brokerLayout.numColumns = 3;
        brokerLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        brokerLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        brokerLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        brokerLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        brokerGroup.setLayout(brokerLayout);
        final Label labelBrokerIp = new Label(brokerGroup, SWT.NONE);
        labelBrokerIp.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        labelBrokerIp.setText(com.cubrid.common.ui.query.Messages.brokerIP);
        brokerIpText = new Text(brokerGroup, SWT.BORDER);
        brokerIpText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
        final Label labelBrokerPort = new Label(brokerGroup, SWT.NONE);
        labelBrokerPort.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        labelBrokerPort.setText(com.cubrid.common.ui.query.Messages.brokerPort);
        brokerPortCombo = new Combo(brokerGroup, SWT.NONE);
        brokerPortCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
        BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
        BrokerInfoList bis = brokerInfos == null ? null : brokerInfos.getBorkerInfoList();
        if (bis != null) {
            List<BrokerInfo> brokerInfoList = bis.getBrokerInfoList();
            for (BrokerInfo brokerInfo : brokerInfoList) {
                if (StringUtil.isEmpty(brokerInfo.getPort())) {
                    continue;
                }
                String status = "";
                if (!StringUtil.isEqualIgnoreCase(brokerInfos.getBrokerstatus(), "ON")) {
                    status = "OFF";
                } else {
                    status = !StringUtil.isEqualIgnoreCase(brokerInfo.getState(), "ON") ? "OFF" : "ON";
                }
                String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
                brokerPortCombo.add(text);
                brokerPortCombo.setData(brokerInfo.getPort(), text);
                brokerPortCombo.setData(text, brokerInfo);
            }
        }
        Label charSetLbl = new Label(brokerGroup, SWT.CHECK);
        charSetLbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        charSetLbl.setText(com.cubrid.common.ui.query.Messages.lblCharSet);
        charsetCombo = new Combo(brokerGroup, SWT.BORDER);
        charsetCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
        Button testConnectionButton = new Button(brokerGroup, SWT.None);
        testConnectionButton.setText(com.cubrid.common.ui.query.Messages.btnTestConnection);
        testConnectionButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        testConnectionButton.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                widgetDefaultSelected(e);
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                final String dbUser = userNameText.getText();
                final String dbPassword = passwordText.getText();
                final DatabaseInfo dbInfo = database.getDatabaseInfo();
                final String brokerIP = brokerIpText.getText();
                final String brokerPort = getBrokerPort();
                final String dbName = dbInfo.getDbName();
                final ServerInfo serverInfo = dbInfo.getServerInfo();
                final String charset = dbInfo.getCharSet();
                final String driverVersion = serverInfo.getJdbcDriverVersion();
                // advanced jdbc settings
                final String jdbcAttrs = attrText.getText();
                final boolean isShard = dbInfo.isShard();
                TaskExecutor taskExcutor = new ConnectDatabaseExecutor(brokerIP, brokerPort, dbName, dbUser, dbPassword, charset, jdbcAttrs, driverVersion, false, isShard);
                new ExecTaskWithProgress(taskExcutor).exec();
                if (taskExcutor.isSuccess()) {
                    CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgTestConnSuccess);
                }
            }
        });
    }
    Group advancedOptionGroup = new Group(composite, SWT.NONE);
    {
        advancedOptionGroup.setText(Messages.grpAdvancedJDBC);
        advancedOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 5, 1, -1, -1));
        GridLayout brokerInfoGroupLayout = new GridLayout();
        brokerInfoGroupLayout.numColumns = 3;
        advancedOptionGroup.setLayout(brokerInfoGroupLayout);
        // JDBC attributes
        Label attrLabel = new Label(advancedOptionGroup, SWT.LEFT);
        attrLabel.setText(com.cubrid.common.ui.common.Messages.lblJdbcAttr);
        attrLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        attrText = new Text(advancedOptionGroup, SWT.LEFT | SWT.BORDER);
        attrText.setEditable(false);
        attrText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
        Button btnAttr = new Button(advancedOptionGroup, SWT.NONE);
        {
            btnAttr.setText(com.cubrid.common.ui.common.Messages.btnJdbcAttr);
            btnAttr.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
            btnAttr.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    JdbcOptionDialog dialog = new JdbcOptionDialog(getShell(), attrText.getText());
                    if (IDialogConstants.OK_ID == dialog.open()) {
                        String jdbcOptions = dialog.getJdbcOptions();
                        attrText.setText(StringUtil.nvl(jdbcOptions));
                    }
                }
            });
        }
    }
    if (database != null && database.getDatabaseInfo() != null) {
        String jdbcAttrs = database.getDatabaseInfo().getJdbcAttrs();
        attrText.setText(StringUtil.nvl(jdbcAttrs));
        String brokerIp = QueryOptions.getBrokerIp(database.getDatabaseInfo());
        if (StringUtil.isEmpty(brokerIp)) {
            brokerIp = database.getServer().getHostAddress();
        }
        if (brokerIp != null) {
            brokerIpText.setText(brokerIp);
        }
        String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
        brokerPort = (String) brokerPortCombo.getData(brokerPort);
        if (brokerPort != null) {
            brokerPortCombo.setText(brokerPort);
        }
        String charset = QueryOptions.getCharset(database.getDatabaseInfo());
        charsetCombo.setItems(QueryOptions.getAllCharset(charset));
        if (charset != null && charset.trim().length() > 0) {
            charsetCombo.setText(charset);
        } else {
            charsetCombo.select(0);
        }
    }
    setTitle(Messages.titleLoginDbDialog);
    setMessage(Messages.msgLoginDbDialog);
    return parentComp;
}
Also used : Group(org.eclipse.swt.widgets.Group) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Label(org.eclipse.swt.widgets.Label) SelectColorCombo(com.cubrid.common.ui.common.control.SelectColorCombo) Combo(org.eclipse.swt.widgets.Combo) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) JdbcOptionDialog(com.cubrid.common.ui.common.dialog.JdbcOptionDialog) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) RGB(org.eclipse.swt.graphics.RGB) SelectColorCombo(com.cubrid.common.ui.common.control.SelectColorCombo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GridData(org.eclipse.swt.layout.GridData) ConnectDatabaseExecutor(com.cubrid.common.ui.spi.util.ConnectDatabaseExecutor) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 28 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class DatabaseConnectionPropertyPage method createContents.

protected Control createContents(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout());
    top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final Group group = new Group(top, SWT.NONE);
    group.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    group.setLayout(layout);
    final Label labelBrokerIp = new Label(group, SWT.NONE);
    labelBrokerIp.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    labelBrokerIp.setText(Messages.brokerIP);
    brokerIpText = new Text(group, SWT.BORDER);
    brokerIpText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    final Label labelBrokerPort = new Label(group, SWT.NONE);
    labelBrokerPort.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    labelBrokerPort.setText(Messages.brokerPort);
    brokerPortCombo = new Combo(group, SWT.NONE);
    brokerPortCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
    BrokerInfoList bis = brokerInfos == null ? null : brokerInfos.getBorkerInfoList();
    if (bis != null) {
        List<BrokerInfo> brokerInfoList = bis.getBrokerInfoList();
        for (BrokerInfo brokerInfo : brokerInfoList) {
            if (StringUtil.isEmpty(brokerInfo.getPort())) {
                continue;
            }
            String status = "";
            if (!StringUtil.isEqualIgnoreCase(brokerInfos.getBrokerstatus(), "ON")) {
                status = "OFF";
            } else {
                status = !StringUtil.isEqualIgnoreCase(brokerInfo.getState(), "ON") ? "OFF" : "ON";
            }
            String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
            brokerPortCombo.add(text);
            brokerPortCombo.setData(brokerInfo.getPort(), text);
            brokerPortCombo.setData(text, brokerInfo);
        }
    }
    Label charSetLbl = new Label(group, SWT.CHECK);
    charSetLbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    charSetLbl.setText(Messages.lblCharSet);
    charsetCombo = new Combo(group, SWT.BORDER);
    charsetCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    loadPreference();
    return top;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 29 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class SqlLogAnalyzeResultDialog method createGroupQuery.

/**
	 * This method initializes groupQuery
	 */
private void createGroupQuery() {
    GridData gridData22 = new GridData(GridData.FILL_HORIZONTAL);
    gridData22.heightHint = 26;
    gridData22.widthHint = 122;
    GridData gridData21 = new GridData(GridData.FILL_BOTH);
    gridData21.horizontalSpan = 3;
    gridData21.widthHint = 432;
    gridData21.heightHint = 150;
    GridData gridData11 = new GridData(GridData.FILL_BOTH);
    gridData11.horizontalSpan = 3;
    gridData11.widthHint = 432;
    gridData11.heightHint = 250;
    GridLayout gridLayout2 = new GridLayout();
    gridLayout2.numColumns = 3;
    gridLayout2.horizontalSpacing = 45;
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.verticalSpan = 2;
    Group groupQuery = new Group(composite, SWT.NONE);
    groupQuery.setText("");
    groupQuery.setLayout(gridLayout2);
    groupQuery.setLayoutData(gridData);
    Label label1 = new Label(groupQuery, SWT.NONE);
    label1.setText(Messages.labelLogContents);
    textQuery = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    textQuery.setEditable(true);
    textQuery.setLayoutData(gridData11);
    Label label2 = new Label(groupQuery, SWT.NONE);
    label2.setText(Messages.labelExecuteResult);
    textQueryResult = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    textQueryResult.setLayoutData(gridData21);
    buttonRunOriginalQuery = new Button(groupQuery, SWT.NONE);
    buttonRunOriginalQuery.setEnabled(false);
    buttonRunOriginalQuery.setText(Messages.buttonExecuteOriginalQuery);
    Label dummy5 = new Label(groupQuery, SWT.NONE);
    dummy5.setLayoutData(gridData22);
    buttonRunOriginalQuery.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String queryString = textQuery.getText();
            LogInfo logInfo = null;
            String targetBroker = null;
            if (node.getId().indexOf("Sql log/") < 0) {
                targetBroker = node.getParent().getLabel();
            } else {
                targetBroker = node.getParent().getParent().getLabel();
            }
            logInfo = (LogInfo) node.getAdapter(LogInfo.class);
            List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
            BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
            CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
            casRunnerConfigDialog.setLogstring(queryString);
            casRunnerConfigDialog.setBrokerInfos(brokerInfos);
            casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
            casRunnerConfigDialog.setLogInfo(logInfo);
            casRunnerConfigDialog.setTargetBroker(targetBroker);
            casRunnerConfigDialog.create();
            if (casRunnerConfigDialog.open() == Dialog.OK) {
                final GetExecuteCasRunnerContentResultTask task = new GetExecuteCasRunnerContentResultTask(node.getServer().getServerInfo());
                task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
                task.setUserName(CasRunnerConfigDialog.getUserName());
                task.setPasswd(CasRunnerConfigDialog.getPassword());
                task.setNumThread(CasRunnerConfigDialog.getNumThread());
                task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
                String isShowqueryresult = "";
                String isShowqueryplan = "";
                if (casRunnerConfigDialog.isShowqueryresult()) {
                    isShowqueryresult = "yes";
                    isShowqueryplan = casRunnerConfigDialog.isShowqueryresult() ? "yes" : "no";
                } else {
                    isShowqueryresult = "no";
                    isShowqueryplan = "no";
                }
                task.setShowQueryResult(isShowqueryresult);
                task.setShowQueryResult(isShowqueryplan);
                task.setDbName(CasRunnerConfigDialog.getDbname());
                task.setExecuteLogFile("no");
                String[] queryStringArr = queryString.split("\\r\\n");
                task.setLogstring(queryStringArr);
                TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
                taskExecutor.addTask(task);
                new ExecTaskWithProgress(taskExecutor).exec();
                if (taskExecutor.isSuccess()) {
                    GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
                    StringBuffer result = new StringBuffer("");
                    for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
                        result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
                    }
                    String logPath = null;
                    String totalResultNum = null;
                    logPath = getExecuteCasRunnerResultInfo.getQueryResultFile();
                    totalResultNum = getExecuteCasRunnerResultInfo.getQueryResultFileNum();
                    if (queryString.length() > 0) {
                        textQueryResult.setText(result.toString());
                        if (casRunnerConfigDialog.isShowqueryresult()) {
                            CasRunnerResultViewDialog casRunnerResultViewDialog = new CasRunnerResultViewDialog(getShell());
                            casRunnerResultViewDialog.create();
                            casRunnerResultViewDialog.connectInit(logPath, CasRunnerConfigDialog.getDbname(), node);
                            casRunnerResultViewDialog.setTotalResultNum(Integer.parseInt(totalResultNum));
                            casRunnerResultViewDialog.getShell().setSize(665, 555);
                            casRunnerResultViewDialog.open();
                        }
                    }
                }
            }
        }
    });
    buttonSaveToFile = new Button(groupQuery, SWT.NONE);
    buttonSaveToFile.setEnabled(false);
    buttonSaveToFile.setText(Messages.buttonSaveLogString);
    buttonSaveToFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String savedFilename = saveAsFile();
            if (isBlank(savedFilename)) {
                return;
            }
            if (analyzeCasLogResultList == null || analyzeCasLogResultList.getLogFileInfoList() == null) {
                return;
            }
            AnalyzeCasLogResultInfo analyzeCasLogResultInfo = (AnalyzeCasLogResultInfo) (analyzeCasLogResultList.getLogFileInfoList().get(currentResultIndex));
            if (savedFilename.length() > 0) {
                analyzeCasLogResultInfo.setSavedFileName(savedFilename);
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) GetExecuteCasRunnerResultInfo(com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GetExecuteCasRunnerContentResultTask(com.cubrid.cubridmanager.core.logs.task.GetExecuteCasRunnerContentResultTask) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AnalyzeCasLogResultInfo(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogResultInfo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AnalyzeCasLogResultList(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogResultList) List(java.util.List)

Example 30 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class GetBrokerInfoTaskTest method testExecute.

public void testExecute() {
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    task.execute();
    task.setUsingSpecialDelimiter(false);
    brokerInfos = task.getResultModel();
    assertTrue(brokerInfos != null && brokerInfos.getBrokerstatus() != null);
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)30 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)16 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)13 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)12 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 List (java.util.List)7 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)6 ITask (com.cubrid.common.core.task.ITask)5 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)5 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)5 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)5 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)5