Search in sources :

Example 51 with ExecTaskWithProgress

use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.

the class ERSchemaEditor method compareTableSchemas.

public void compareTableSchemas(final String modelName, final Map<String, TableSchema> tableSchema, final Map<String, SchemaInfo> schemaInfos) {
    final List<TableSchemaCompareModelInputLazy> input = new ArrayList<TableSchemaCompareModelInputLazy>();
    ITask reportBugTask = new AbstractUITask() {

        private boolean success = false;

        public void cancel() {
        }

        public void finish() {
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return success;
        }

        public void execute(IProgressMonitor monitor) {
            CubridDatabase database = erSchema.getCubridDatabase();
            List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(database);
            final CubridDatabase virtualDb = new CubridDatabase(modelName, modelName);
            virtualDb.setVirtual(true);
            DatabaseInfo info = database.getDatabaseInfo();
            virtualDb.setDatabaseInfo(info);
            WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info);
            wrappedDatabaseInfo.addSchemaInfos(schemaInfos);
            wrappedDatabaseInfo.addTableSchemas(tableSchema);
            ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
            TableSchemaModel leftModel = TableSchemaCompareUtil.createTableSchemaModel(leftDbTableInfoList);
            TableSchemaModel rightModel = new TableSchemaModel();
            rightModel.getTableSchemaMap().putAll(tableSchema);
            TableSchemaComparator comparator = new TableSchemaComparator(database, virtualDb);
            TableSchemaCompareModel model = comparator.compare(leftModel, rightModel);
            model.setSourceDB(database);
            model.setTargetDB(virtualDb);
            input.add(new TableSchemaCompareModelInputLazy(model));
            success = true;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.common.ui.common.Messages.titleSchemaComparison);
    taskExecutor.addTask(reportBugTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input.get(0), TableSchemaCompareInfoPart.ID);
        } catch (Exception e) {
        }
    }
}
Also used : TableSchemaCompareModelInputLazy(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) ERVirtualDatabaseInfo(com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) TableSchemaComparator(com.cubrid.common.ui.compare.schema.TableSchemaComparator) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaModel(com.cubrid.common.ui.compare.schema.model.TableSchemaModel) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 52 with ExecTaskWithProgress

use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.

the class ERSchemaEditor method syncComments.

/**
	 * sync table comments to db tables.
	* 
	* @return void
	 */
public void syncComments() {
    DatabaseInfo info = database.getDatabaseInfo();
    if (info == null) {
        CommonUITool.openErrorBox(Messages.errNoDatabase);
        return;
    }
    if (!info.isLogined()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    ServerInfo serverInfo = info.getServerInfo();
    if (serverInfo != null && !serverInfo.isConnected()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    boolean isSupportTableComment = false;
    Connection conn = null;
    try {
        conn = JDBCConnectionManager.getConnection(info, false);
        isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(info, conn);
        if (!isSupportTableComment) {
            CommonUITool.openErrorBox(Messages.cannotSyncComments);
            return;
        }
    } catch (Exception e) {
        LOGGER.error("", e);
    } finally {
        QueryUtil.freeQuery(conn);
    }
    if (!CommonUITool.openConfirmBox(getSite().getShell(), Messages.bind(Messages.msgConfirmSyncComments, database.getLabel()))) {
        return;
    }
    CommonTaskExec taskJobExec = new CommonTaskExec(null);
    List<UpdateDescriptionTask> updateDescTasks = getUpdateDescriptionTaskList(info);
    for (UpdateDescriptionTask task : updateDescTasks) {
        taskJobExec.addTask(task);
    }
    if (updateDescTasks.size() == 0) {
        CommonUITool.openInformationBox(Messages.msgNoComments);
        return;
    }
    new ExecTaskWithProgress(taskJobExec).exec();
    Set<String> failTables = new HashSet<String>();
    for (UpdateDescriptionTask task : updateDescTasks) {
        if (!task.isSuccess()) {
            failTables.add(task.getTableName());
        }
    }
    if (failTables.size() == 0) {
        CommonUITool.openInformationBox(Messages.msgSuccessSyncComments);
    } else {
        CommonUITool.openErrorBox(Messages.bind(Messages.errSyncComments, failTables.toString()));
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ERVirtualDatabaseInfo(com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Connection(java.sql.Connection) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) UpdateDescriptionTask(com.cubrid.cubridmanager.core.cubrid.table.task.UpdateDescriptionTask) HashSet(java.util.HashSet)

Example 53 with ExecTaskWithProgress

use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.

the class QueryExecuter method createContextMenuItems.

private void createContextMenuItems() {
    Menu menu = new Menu(queryEditor.getEditorSite().getShell(), SWT.POP_UP);
    final MenuItem itemInsert = new MenuItem(menu, SWT.PUSH);
    itemInsert.setText(Messages.insertRecord);
    itemInsert.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (!getEditable()) {
                CommonUITool.openErrorBox(Display.getDefault().getActiveShell(), Messages.errNotEditable);
                return;
            }
            insertSaveItem.setEnabled(getEditable());
            rollbackModifiedItem.setEnabled(getEditable());
            addNewItem();
        }
    });
    final MenuItem itemCopy = new MenuItem(menu, SWT.PUSH);
    itemCopy.setText(Messages.copyClipBoard);
    final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
    itemDelete.setText(Messages.delete);
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem itemDetail = new MenuItem(menu, SWT.PUSH);
    itemDetail.setText(Messages.detailView);
    itemDetail.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            List<Point> selectedList = selectableSupport.getSelectedLocations();
            Point location = selectedList.get(0);
            if (location == null) {
                CommonUITool.openErrorBox(Messages.errShowDetailFailed);
                return;
            }
            //Bug fixed by Kevin.Qian. FYI. allDataList is a global query result to the current query.
            int pageBeginIndex = (queryInfo.getCurrentPage() - 1) * queryInfo.getPageSize();
            Map<String, CellValue> map = allDataList.get(pageBeginIndex + location.y);
            TableItem item = tblResult.getItem(location.y);
            ColumnInfo colInfo = allColumnList.get(location.x - 1);
            RowDetailDialog dialog = new RowDetailDialog(tblResult.getShell(), allColumnList, map, item, colInfo.getName(), executer);
            dialog.open();
        }
    });
    tblResult.setMenu(menu);
    tblResult.addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            //				Point pt = new Point(event.x, event.y);
            //				itemOid.setEnabled(false);
            int index = tblResult.getSelectionIndex();
            int count = tblResult.getItemCount();
            if (index < 0 || index >= count) {
                return;
            }
        //				final TableItem item = tblResult.getItem(index);
        //				for (int i = 0; i < tblResult.getColumnCount(); i++) {
        //					Rectangle rect = item.getBounds(i);
        //					if (rect.contains(pt)) {
        //						selColumnName = tblResult.getColumn(i).getText();
        ////						Object value = item.getData(i + "");
        ////						String text = item.getText(i);
        ////						if (!DataType.VALUE_NULL.equals(value) && containsOIDs(tblResult.getColumn(i).getText())
        ////							&& !DataType.VALUE_NONE.equals(text)) {
        ////							itemOid.setEnabled(true);
        ////						} else {
        ////							itemOid.setEnabled(false);
        ////						}
        //
        //					}
        //				}
        }
    });
    final MenuItem itemExportAll = new MenuItem(menu, SWT.PUSH);
    itemExportAll.setText(Messages.allExport);
    final MenuItem itemExportSelection = new MenuItem(menu, SWT.PUSH);
    itemExportSelection.setText(Messages.selectExport);
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem itemMakeInsertQuery = new MenuItem(menu, SWT.PUSH);
    itemMakeInsertQuery.setText(Messages.makeInsertFromSelectedRecord);
    itemMakeInsertQuery.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_insert.png"));
    final MenuItem itemMakeUpdateQuery = new MenuItem(menu, SWT.PUSH);
    itemMakeUpdateQuery.setText(Messages.makeUpdateFromSelectedRecord);
    itemMakeUpdateQuery.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_update.png"));
    if (isEmpty()) {
        itemExportAll.setEnabled(false);
        itemExportSelection.setEnabled(false);
        itemDetail.setEnabled(false);
    }
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            List<Point> selectedList = selectableSupport.getSelectedLocations();
            TableItem[] tblItems = selectableSupport.getSelectedTableItems();
            boolean selectedCol = selectableSupport.hasSelected();
            boolean enableItemDetail = (selectedList != null && selectedList.size() == 1);
            itemExportSelection.setEnabled(selectedCol);
            itemCopy.setEnabled(selectedCol);
            if (allDataList.size() > 0) {
                itemExportAll.setEnabled(true);
            } else {
                itemExportAll.setEnabled(false);
            }
            if (executer.getQueryEditor() != null && executer.getQueryEditor().getDatabaseInfo() != null && executer.getQueryEditor().getDatabaseInfo().equals(executer.getDatabaseInfo())) {
                itemInsert.setEnabled(isEditMode());
                itemDetail.setEnabled(enableItemDetail);
                itemDelete.setEnabled(getEditable() && isEditMode());
            } else {
                itemInsert.setEnabled(false);
                itemDetail.setEnabled(false);
                itemDelete.setEnabled(false);
            }
            for (int i = 0; i < tblItems.length; i++) {
                if (isEditMode() && getEditable() && tblItems[i].getText(1).equals(DataType.VALUE_NONE)) {
                    itemDelete.setEnabled(false);
                }
            }
        }
    });
    itemCopy.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            copySelectedItems();
        }
    });
    itemCopy.setAccelerator(SWT.CTRL + 'c');
    itemDelete.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isEditMode()) {
                deleteRecord(tblResult, null);
            }
        }
    });
    itemExportAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            ExportResultDialog dialog = new ExportResultDialog(tblResult.getShell(), database, Messages.msgExportAllResults);
            if (IDialogConstants.OK_ID == dialog.open()) {
                ExportQueryResultTaskExecutor task = new ExportQueryResultTaskExecutor(dialog.getFile(), dialog.getFileCharset(), allColumnList, allDataList, false);
                new ExecTaskWithProgress(task).exec();
            }
        }
    });
    //		itemOid.addSelectionListener(new SelectionAdapter() {
    //			/**
    //			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
    //			 * @param event an event containing information about the
    //			 *        selection
    //			 */
    //			public void widgetSelected(SelectionEvent event) {
    //				openOidNavigator(button2Position);
    //			}
    //
    //		});
    itemExportSelection.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            ExportResultDialog dialog = new ExportResultDialog(tblResult.getShell(), database, Messages.msgExportSelectedResults);
            if (IDialogConstants.OK_ID == dialog.open()) {
                ExportQueryResultTaskExecutor task = new ExportQueryResultTaskExecutor(dialog.getFile(), dialog.getFileCharset(), tblResult, selectableSupport.getSelectedTableItems(), false);
                new ExecTaskWithProgress(task).exec();
            }
        }
    });
    itemMakeInsertQuery.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String text = makeInsertQueryWithSelectedRecords();
            CommonUITool.copyContentToClipboard(text);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    itemMakeUpdateQuery.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String text = makeUpdateQueryWithSelectedRecords();
            CommonUITool.copyContentToClipboard(text);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) PaintListener(org.eclipse.swt.events.PaintListener) Listener(org.eclipse.swt.widgets.Listener) MouseListener(org.eclipse.swt.events.MouseListener) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyListener(org.eclipse.swt.events.KeyListener) RowDetailDialog(com.cubrid.common.ui.query.dialog.RowDetailDialog) ExportResultDialog(com.cubrid.common.ui.query.dialog.ExportResultDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuEvent(org.eclipse.swt.events.MenuEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) Map(java.util.Map) HashMap(java.util.HashMap) MenuEvent(org.eclipse.swt.events.MenuEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 54 with ExecTaskWithProgress

use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.

the class UserManagementWizard method performFinish.

/**
	 * Called when user clicks Finish
	 * 
	 * @return boolean
	 */
public boolean performFinish() {
    final String userId = generalInfoPage.getUserId();
    final String password = generalInfoPage.getPassword();
    final String dbCreationAuth = generalInfoPage.getDbCreationAuth();
    final String brokerAuth = generalInfoPage.getBrokerAuth();
    final String statusMonitorAuth = generalInfoPage.getStatusMonitorAuth();
    final List<DatabaseInfo> authDatabaselist = new ArrayList<DatabaseInfo>();
    final Shell shell = getShell();
    final String taskName = Messages.bind(Messages.updateUserTaskName, userId);
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            ServerUserInfo loginedUserInfo = server.getServerInfo().getLoginedUserInfo();
            if (userInfo == null) {
                userInfo = new ServerUserInfo(userId, password);
            } else {
                userInfo.setPassword(password);
            }
            if (userInfo.getUserName().equals(loginedUserInfo.getUserName())) {
                loginedUserInfo.setPassword(password);
            }
            if (!userInfo.isAdmin()) {
                if (dbCreationAuth.equals(DbCreateAuthType.AUTH_NONE.getText())) {
                    userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_NONE);
                } else if (dbCreationAuth.equals(DbCreateAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_ADMIN);
                }
                if (brokerAuth.equals(CasAuthType.AUTH_NONE.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_NONE);
                } else if (brokerAuth.equals(CasAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_ADMIN);
                } else if (brokerAuth.equals(CasAuthType.AUTH_MONITOR.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_MONITOR);
                }
                if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_NONE.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_NONE);
                } else if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_ADMIN);
                } else if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_MONITOR.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_MONITOR);
                }
                userInfo.removeAllDatabaseInfo();
                userInfo.setDatabaseInfoList(authDatabaselist);
            }
            return true;
        }
    };
    if (userInfo != null && userInfo.isAdmin()) {
        ChangeCMUserPasswordTask changeCMUserPasswordTask = new ChangeCMUserPasswordTask(server.getServerInfo());
        changeCMUserPasswordTask.setUserName(userId);
        changeCMUserPasswordTask.setPassword(password);
        taskExcutor.addTask(changeCMUserPasswordTask);
    } else if (userInfo != null && !userInfo.isAdmin()) {
        DeleteCMUserTask deleteCMUserTask = new DeleteCMUserTask(server.getServerInfo());
        deleteCMUserTask.setUserId(userId);
        taskExcutor.addTask(deleteCMUserTask);
    }
    if (userInfo == null || !userInfo.isAdmin()) {
        AddCMUserTask addCMUserTask = new AddCMUserTask(server.getServerInfo());
        addCMUserTask.setUserId(userId);
        addCMUserTask.setPassword(password);
        addCMUserTask.setDbcreate(dbCreationAuth);
        addCMUserTask.setCasAuth(brokerAuth);
        addCMUserTask.setStautsMonitorAuth(statusMonitorAuth);
        taskExcutor.addTask(addCMUserTask);
    }
    ServerType serverType = server.getServerInfo().getServerType();
    if ((userInfo == null || !userInfo.isAdmin()) && (serverType == ServerType.BOTH || serverType == ServerType.DATABASE)) {
        List<Map<String, Object>> dbAuthInfoList = authDbInfoPage.getDbAuthInfoList();
        List<String> dbNameList = new ArrayList<String>();
        List<String> dbUserList = new ArrayList<String>();
        List<String> dbPasswordList = new ArrayList<String>();
        List<String> dbBrokerPortList = new ArrayList<String>();
        if (dbAuthInfoList != null && !dbAuthInfoList.isEmpty()) {
            int size = dbAuthInfoList.size();
            for (int i = 0; i < size; i++) {
                Map<String, Object> map = dbAuthInfoList.get(i);
                String allowConnectedStr = (String) map.get("1");
                if ("Yes".equals(allowConnectedStr)) {
                    String dbName = (String) map.get("0");
                    dbNameList.add(dbName);
                    String dbUser = (String) map.get("2");
                    dbUserList.add(dbUser);
                    String brokerIP = (String) map.get("3");
                    String brokerPort = (String) map.get("4");
                    String port = "";
                    if (brokerPort.matches("^\\d+$")) {
                        port = brokerPort;
                    } else {
                        port = brokerPort.substring(brokerPort.indexOf("[") + 1, brokerPort.indexOf("/"));
                    }
                    dbBrokerPortList.add(brokerIP + "," + port);
                    dbPasswordList.add("");
                    DatabaseInfo databaseInfo = new DatabaseInfo(dbName, server.getServerInfo());
                    databaseInfo.setBrokerPort(brokerPort);
                    databaseInfo.setBrokerIP(brokerIP);
                    DbUserInfo dbUserInfo = new DbUserInfo();
                    dbUserInfo.setName(dbUser);
                    databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
                    authDatabaselist.add(databaseInfo);
                }
            }
        }
        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 updateTask = new UpdateCMUserTask(server.getServerInfo());
        updateTask.setCmUserName(userId);
        updateTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
        updateTask.setCasAuth(brokerAuth);
        updateTask.setDbCreator(dbCreationAuth);
        updateTask.setStatusMonitorAuth(statusMonitorAuth);
        taskExcutor.addTask(updateTask);
    }
    new ExecTaskWithProgress(taskExcutor).exec(true, true);
    return taskExcutor.isSuccess();
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ChangeCMUserPasswordTask(com.cubrid.cubridmanager.core.common.task.ChangeCMUserPasswordTask) ArrayList(java.util.ArrayList) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DeleteCMUserTask(com.cubrid.cubridmanager.core.common.task.DeleteCMUserTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) Map(java.util.Map) AddCMUserTask(com.cubrid.cubridmanager.core.common.task.AddCMUserTask)

Example 55 with ExecTaskWithProgress

use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.

the class LoginQueryEditDialog method buttonPressed.

/**
	 * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
	 * @param buttonId the id of the button that was pressed (see
	 *        <code>IDialogConstants.*_ID</code> constants)
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID || buttonId == TEST_CONNECT_ID) {
        String brokerIp = connectionComp.getBrokerIpText().getText();
        CubridServer cubridServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
        ServerInfo serverInfo = new ServerInfo();
        serverInfo.setServerName(DatabaseNavigatorMenu.SELF_DATABASE_ID);
        serverInfo.setHostAddress(brokerIp);
        cubridServer.setServerInfo(serverInfo);
        String databaseName = connectionComp.getDatabaseCombo().getText();
        DatabaseInfo dbInfo = new DatabaseInfo(databaseName, cubridServer.getServerInfo());
        dbInfo.setBrokerIP(brokerIp);
        dbInfo.setBrokerPort(connectionComp.getBrokerPortCombo().getText());
        dbInfo.getServerInfo().setJdbcDriverVersion(connectionComp.getJdbcCombo().getText());
        String userName = connectionComp.getUserNameText().getText();
        String password = connectionComp.getPasswordText().getText();
        DbUserInfo userInfo = new DbUserInfo();
        userInfo.setDbName(databaseName);
        userInfo.setName(userName);
        userInfo.setNoEncryptPassword(password);
        dbInfo.setAuthLoginedDbUserInfo(userInfo);
        int currentShardId = connectionComp.getCurShardId();
        dbInfo.setCurrentShardId(currentShardId);
        String charset = connectionComp.getCharsetCombo().getText();
        dbInfo.setCharSet(charset);
        boolean isShard = connectionComp.getBtnShard().getSelection();
        dbInfo.setShard(isShard);
        boolean sureCharset = CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.host.Messages.msgConfirmCharset, charset));
        if (!sureCharset) {
            connectionComp.getCharsetCombo().setFocus();
            return;
        }
        TaskExecutor taskExcutor = new ConnectDatabaseExecutor(dbInfo);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        if (buttonId == TEST_CONNECT_ID) {
            CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, com.cubrid.cubridmanager.ui.host.Messages.msgTestConnSuccess);
            return;
        }
        dbInfo.setLogined(true);
        dbInfo.setRunningType(DbRunningType.CS);
        DatabaseNavigatorMenu.SELF_DATABASE.setDatabaseInfo(dbInfo);
    }
    super.buttonPressed(buttonId);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) ConnectDatabaseExecutor(com.cubrid.common.ui.spi.util.ConnectDatabaseExecutor)

Aggregations

ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)155 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)124 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 TreeViewer (org.eclipse.jface.viewers.TreeViewer)39 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 ITask (com.cubrid.common.core.task.ITask)35 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)30 ArrayList (java.util.ArrayList)29 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)26 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)25 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)23 Shell (org.eclipse.swt.widgets.Shell)15 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 IEditorPart (org.eclipse.ui.IEditorPart)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11