Search in sources :

Example 1 with CommonTaskJobExec

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

the class PstmtSQLDialog method updateData.

/**
	 * Update the data
	 *
	 * @param parameterList List<PstmtParameter>
	 */
private void updateData(List<List<PstmtParameter>> jobList) {
    beginTimestamp = System.currentTimeMillis();
    String jobName = Messages.executeSqlJobName;
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getServerInfo().getServerName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    TaskJobExecutor taskExec = new CommonTaskJobExec(this);
    for (int i = 0; i < jobList.size(); i++) {
        List<PstmtParameter> parameterList = jobList.get(i);
        PstmtDataTask task = new PstmtDataTask(sqlTxt.getText(), database, parameterList, null, i + 1);
        taskExec.addTask(task);
    }
    taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Point(org.eclipse.swt.graphics.Point)

Example 2 with CommonTaskJobExec

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

the class ObjectInfoComposite method init.

public void init() {
    /*Tool bar composite*/
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    toolBarComposite.setLayout(rowLayout);
    toolBarComposite.setLayoutData(CommonUITool.createGridData(-1, -1, -1, 25));
    dataTabButton = new Button(toolBarComposite, SWT.None);
    dataTabButton.setText(Messages.tabTitleData);
    dataTabButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(0);
        }
    });
    ddlTabButton = new Button(toolBarComposite, SWT.None);
    ddlTabButton.setText(Messages.tabTitleDDL);
    ddlTabButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(1);
        }
    });
    columnTabButton = new Button(toolBarComposite, SWT.None);
    columnTabButton.setText(Messages.tabTitleColumn);
    columnTabButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(2);
        }
    });
    indexTabButton = new Button(toolBarComposite, SWT.None);
    indexTabButton.setText(Messages.tabTitleIndex);
    indexTabButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(3);
        }
    });
    new Label(toolBarComposite, SWT.None).setText("  ");
    /*Select * button*/
    selectButton = new Button(toolBarComposite, SWT.None);
    selectButton.setText(Messages.txtSelect);
    selectButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            processSelectAction();
        }
    });
    /*Select column button*/
    selectColumnButton = new Button(toolBarComposite, SWT.None);
    selectColumnButton.setText(Messages.txtSelectColumn);
    selectColumnButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            processSelectColumnAction();
        }
    });
    /*Insert Button*/
    insertButton = new Button(toolBarComposite, SWT.None);
    insertButton.setText(Messages.txtInsert);
    insertButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            processInsertAction();
        }
    });
    /*Update button*/
    updateButton = new Button(toolBarComposite, SWT.None);
    updateButton.setText(Messages.txtUpdate);
    updateButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            processUpdateAction();
        }
    });
    /*Delete button*/
    deleteButton = new Button(toolBarComposite, SWT.None);
    deleteButton.setText(Messages.txtDelete);
    deleteButton.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            processDeleteAction();
        }
    });
    /*Database object information*/
    objInfoFolder = new CTabFolder(this, SWT.BOTTOM);
    objInfoFolder.setSimple(false);
    objInfoFolder.setUnselectedImageVisible(true);
    objInfoFolder.setUnselectedCloseVisible(true);
    objInfoFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    objInfoFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    objInfoFolder.setLayout(new GridLayout(1, true));
    objInfoFolder.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, -1, -1, -1, -1));
    /*Demo data tab item*/
    initDataTabItem();
    /*DDL tab item*/
    initDDLTabItem();
    /*Column tab item*/
    initColumnTabItem();
    /*If is table, create index tab item*/
    if (isTable) {
        initIndexTabItem();
    }
    /*Initial the data*/
    TaskJobExecutor taskExec = new CommonTaskJobExec() {

        public IStatus exec(IProgressMonitor monitor) {
            IStatus status = super.exec(monitor);
            if (Status.CANCEL_STATUS == status) {
                return status;
            }
            return Status.OK_STATUS;
        }

        public void done(IJobChangeEvent event) {
            getInfoDataTask = null;
        }
    };
    GetInfoDataTask getInfoDataTask = new GetInfoDataTask(Messages.getInfoJobName, this, schemaNode, isTable);
    taskExec.addTask(getInfoDataTask);
    /*Get data job*/
    TaskJob job = new TaskJob(Messages.bind(Messages.getInfoJobName, schemaNode.getName()), taskExec);
    job.setPriority(Job.LONG);
    job.setUser(false);
    job.schedule();
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) IStatus(org.eclipse.core.runtime.IStatus) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) TaskJob(com.cubrid.common.ui.spi.progress.TaskJob) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Button(org.eclipse.swt.widgets.Button) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with CommonTaskJobExec

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

the class CheckDatabaseDialog method buttonPressed.

/**
	 * When press button in button bar,call this method
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!verify()) {
            return;
        }
        CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.CHECK_DATABASE_TASK_NAME, database.getServer().getServerInfo(), CommonSendMsg.getCheckDbSendMsg());
        task.setDbName(database.getName());
        task.setRepairDb(repairButton.getSelection() ? YesNoType.Y : YesNoType.N);
        String serverName = database.getServer().getName();
        String dbName = database.getName();
        jobName = Messages.msgCheckDbRearName + " - " + dbName + "@" + serverName;
        TaskJobExecutor taskExec = new CommonTaskJobExec(this);
        taskExec.addTask(task);
        JobFamily jobFamily = new JobFamily();
        jobFamily.setServerName(serverName);
        jobFamily.setDbName(dbName);
        taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
        return;
    }
    super.buttonPressed(buttonId);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 4 with CommonTaskJobExec

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

the class CompactDatabaseDialog method buttonPressed.

/**
	 * When press button in button bar,call this method
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!verify()) {
            return;
        }
        if (CommonUITool.openConfirmBox(parentComp.getShell(), Messages.msgCompactConfirm)) {
            CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.COMPACT_DATABASE_TASK_NANE, database.getServer().getServerInfo(), CommonSendMsg.getCompactDbSendMsg());
            task.setDbName(database.getName());
            if (verboseBtn != null) {
                task.setVerbose(verboseBtn.getSelection() ? YesNoType.Y : YesNoType.N);
            }
            String serverName = database.getServer().getName();
            String dbName = database.getName();
            jobName = Messages.msgCompactDbRearJobName + " - " + dbName + "@" + serverName;
            TaskJobExecutor taskExec = new CommonTaskJobExec(this);
            taskExec.addTask(task);
            JobFamily jobFamily = new JobFamily();
            jobFamily.setServerName(serverName);
            jobFamily.setDbName(dbName);
            taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
            return;
        } else {
            return;
        }
    }
    super.buttonPressed(buttonId);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 5 with CommonTaskJobExec

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

the class DeleteTableAction method doRun.

/**
	 * Do run
	 * 
	 * @param obj
	 */
private void doRun(Object[] obj) {
    StringBuilder sb = new StringBuilder();
    final List<String> tableList = new ArrayList<String>();
    CubridDatabase database = null;
    for (int i = 0; i < obj.length; i++) {
        DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
        database = table.getDatabase();
        final String tableName = table.getName();
        tableList.add(tableName);
        if (i < 100) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(tableName);
        }
    }
    if (obj.length > 100) {
        sb.append("...");
    }
    String message = Messages.bind(Messages.confirmTableDeleteWarn, sb.toString());
    if (!CommonUITool.openConfirmBox(message)) {
        return;
    }
    final DelAllRecordsTask task = new DelAllRecordsTask(database.getDatabaseInfo());
    TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            int[] rowCount = task.getDeleteRecordsCount();
            List<String> rowCountList = new ArrayList<String>();
            for (int i = 0; i < rowCount.length; i++) {
                rowCountList.add(String.valueOf(rowCount[i]));
            }
            String message = Messages.bind(Messages.resultTableDeleteInformantion, tableList, rowCountList);
            CommonUITool.openInformationBox(Messages.msg_information, message);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    String[] tableNames = new String[tableList.size()];
    tableNames = tableList.toArray(tableNames);
    task.setTableName(tableNames);
    taskExec.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.msgDeleteTableDataJobName + " - " + tableList.toString() + "@" + dbName + "@" + serverName;
    taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) ArrayList(java.util.ArrayList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DelAllRecordsTask(com.cubrid.cubridmanager.core.cubrid.table.task.DelAllRecordsTask) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) ArrayList(java.util.ArrayList) List(java.util.List) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)25 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)24 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)19 IStatus (org.eclipse.core.runtime.IStatus)14 ITask (com.cubrid.common.core.task.ITask)12 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)12 ArrayList (java.util.ArrayList)9 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)7 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)6 List (java.util.List)6 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 TaskJob (com.cubrid.common.ui.spi.progress.TaskJob)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)2 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)2