Search in sources :

Example 61 with ServerInfo

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

the class StopBrokerEnvAction method run.

/**
	 * Override the run method in order to complete stopping broker environment
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(CONFIRM_CONTENT)) {
        return;
    }
    final Object[] obj = this.getSelectedObj();
    CubridBrokerFolder selection = (CubridBrokerFolder) obj[0];
    if (null == selection) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    StopBrokerEnvTask task = new StopBrokerEnvTask(serverInfo);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.stopBrokerEnvTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    selection.setRunning(false);
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection);
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) StopBrokerEnvTask(com.cubrid.cubridmanager.core.broker.task.StopBrokerEnvTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Example 62 with ServerInfo

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

the class VolumeSizeValidator method createVolumeGroup.

/**
	 * 
	 * Create volume group area
	 * 
	 * @param parent the parent composite
	 */
private void createVolumeGroup(Composite parent) {
    Group volumeGroup = new Group(parent, SWT.NONE);
    volumeGroup.setText(Messages.grpAddtionalVolInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    volumeGroup.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    volumeGroup.setLayout(layout);
    Label volumeNameLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumeNameLabel.setText(Messages.lblVolName);
    volumeNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeNameText = new Text(volumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeNameText.setLayoutData(gridData);
    volumeNameText.setEditable(false);
    Label volumePathLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumePathLabel.setText(Messages.lblVolPath);
    volumePathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumePathText = new Text(volumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    volumePathText.setLayoutData(gridData);
    Button selectDirectoryButton = new Button(volumeGroup, SWT.NONE);
    selectDirectoryButton.setText(Messages.btnBrowse);
    selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    selectDirectoryButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            if (databasePath != null && databasePath.trim().length() > 0) {
                dlg.setFilterPath(databasePath);
            }
            dlg.setText(Messages.msgSelectDir);
            dlg.setMessage(Messages.msgSelectDir);
            String dir = dlg.open();
            if (dir != null) {
                volumePathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = server.getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectDirectoryButton.setEnabled(false);
    }
    Label volumeTypeLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumeTypeLabel.setText(Messages.lblVolType);
    volumeTypeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeTypeCombo = new Combo(volumeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeTypeCombo.setLayoutData(gridData);
    volumeTypeCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changeVolumeName();
        }
    });
    Label sizeOfPageLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    sizeOfPageLabel.setText(Messages.lblVolSize);
    sizeOfPageLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeSizeText = new Text(volumeGroup, SWT.BORDER);
    volumeSizeText.setTextLimit(20);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeSizeText.setLayoutData(gridData);
    volumeSizeText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            volumeSizeText.addModifyListener(VolumeInfoPage.this);
        }

        public void focusLost(FocusEvent event) {
            volumeSizeText.removeModifyListener(VolumeInfoPage.this);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 63 with ServerInfo

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

the class VolumeSizeValidator method initial.

private void initial() {
    volumeTypeCombo.setItems(VOLUME_TYPES);
    volumeTypeCombo.select(0);
    EnvInfo envInfo = server.getServerInfo().getEnvInfo();
    if (envInfo != null) {
        databasePath = envInfo.getDatabaseDir();
        ServerInfo serverInfo = server.getServerInfo();
        if (serverInfo != null) {
            databasePath = FileUtil.changeSeparatorByOS(databasePath, serverInfo.getServerOsInfo());
        }
    }
    volumeNameText.addModifyListener(this);
    volumePathText.addModifyListener(this);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 64 with ServerInfo

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

the class LoginDatabaseTaskExecutor method exec.

/**
	 * Execute to login database
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
public boolean exec(final IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return false;
    }
    String taskName = Messages.bind(Messages.loginDbTaskName, dbName);
    monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
    DbUserInfo dbUserInfo = null;
    DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
    DbUserInfo preDbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
    boolean isOldLogined = dbInfo.isLogined();
    for (ITask task : taskList) {
        if (task instanceof UpdateCMUserTask) {
            UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
            ServerInfo serverInfo = dbInfo.getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
                updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
                updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
                updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
                List<String> dbNameList = new ArrayList<String>();
                List<String> dbUserList = new ArrayList<String>();
                List<String> dbPasswordList = new ArrayList<String>();
                List<String> dbBrokerPortList = new ArrayList<String>();
                List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
                for (int i = 0; authDatabaseList != null && i < authDatabaseList.size(); i++) {
                    DatabaseInfo databaseInfo = authDatabaseList.get(i);
                    dbNameList.add(databaseInfo.getDbName());
                    dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                    dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                    String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                    dbPasswordList.add(password == null ? "" : password);
                }
                String[] dbNameArr = new String[dbNameList.size()];
                String[] dbUserArr = new String[dbUserList.size()];
                String[] dbPasswordArr = new String[dbPasswordList.size()];
                String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
                updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
            }
        }
        task.execute();
        final String msg = task.getErrorMsg();
        if (showErrMsg) {
            if (openErrorBox(shell, msg, monitor)) {
                dbInfo.setLogined(isOldLogined);
                dbInfo.setAuthLoginedDbUserInfo(preDbUserInfo);
                //					LOGGER.error("loggin failed task : " + infoMessage);
                return false;
            }
        } else if (!monitor.isCanceled()) {
            setErrMsg(msg);
            dbInfo.setLogined(isOldLogined);
            dbInfo.setAuthLoginedDbUserInfo(preDbUserInfo);
            return false;
        }
        if (monitor.isCanceled()) {
            return false;
        }
        if (task instanceof LoginDatabaseTask) {
            dbUserInfo = ((LoginDatabaseTask) task).getLoginedDbUserInfo();
            dbInfo.setLogined(true);
            dbUserInfo.setNoEncryptPassword(dbPassword);
            dbInfo.setAuthLoginedDbUserInfo(dbUserInfo);
        }
    }
    return true;
}
Also used : ITask(com.cubrid.common.core.task.ITask) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 65 with ServerInfo

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

the class EditQueryPlanDialog method getConnection.

private Connection getConnection() throws SQLException {
    // Can Check UserInfo
    if (canCheckConnection()) {
        String dbName = database.getDatabaseInfo().getDbName();
        ServerInfo serverInfo = database.getDatabaseInfo().getServerInfo();
        String brokerIP = database.getDatabaseInfo().getBrokerIP();
        String brokerPort = database.getDatabaseInfo().getBrokerPort();
        String charset = database.getDatabaseInfo().getCharSet();
        String driverVersion = serverInfo.getJdbcDriverVersion();
        String jdbcAttrs = database.getDatabaseInfo().getJdbcAttrs();
        boolean isShard = database.getDatabaseInfo().isShard();
        String userName = userText.getText();
        String password = pwdTxt.getText();
        return JDBCConnectionManager.getConnection(brokerIP, brokerPort, dbName, userName, password, charset, jdbcAttrs, driverVersion, false, isShard);
    } else {
        return JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
    }
}
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