Search in sources :

Example 21 with JobFamily

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

the class CopyDatabaseDialog method okPressed.

/**
	 * When ok button press,call this method
	 */
protected void okPressed() {
    if (!verify()) {
        return;
    }
    destDbName = destinationDBNameText.getText();
    if (!CommonUITool.openConfirmBox(parentComp.getShell(), Messages.warnYesNoCopyDb)) {
        return;
    }
    SocketTask checkTask = getCheckDirsTask();
    SocketTask copyTask = getCopyDbTask();
    TaskJobExecutor taskExec = new CommonTaskJobExec(this);
    taskExec.addTask(checkTask);
    taskExec.addTask(copyTask);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    jobName = Messages.msgCopyDbRearJobName + " - " + dbName + "@" + serverName;
    taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) SocketTask(com.cubrid.cubridmanager.core.common.socket.SocketTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 22 with JobFamily

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

the class ServiceDashboardEditor method executeTask.

/**
	 * Execute Task Job
	 */
private void executeTask(TaskJobExecutor taskJobExec, String serverName, String jobName) {
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 23 with JobFamily

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

the class StartServiceAction method doRun.

/**
	 * Perform do run
	 * 
	 * @param servers
	 */
public void doRun(CubridServer[] servers) {
    CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    final TreeViewer viewer = view.getViewer();
    if (servers.length > 0) {
        CubridServer server = servers[0];
        if (isSupported(server)) {
            final JobFamily jobFamily = new JobFamily();
            final String serverName = server.getName();
            String dbName = JobFamily.ALL_DB;
            jobFamily.setServerName(serverName);
            jobFamily.setDbName(dbName);
            Job[] jobs = Job.getJobManager().find(jobFamily);
            if (jobs.length > 0) {
                CommonUITool.openWarningBox(Messages.bind(Messages.msgStartServiceWithJob, serverName));
                return;
            }
            TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(), viewer);
            ServerInfo serverInfo = server.getServerInfo();
            GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
            taskExcutor.addTask(task);
            new ExecTaskWithProgress(taskExcutor).exec();
        }
    }
//		for(CubridServer server : servers) {
//			final JobFamily jobFamily = new JobFamily();
//			final String serverName = server.getName();
//			String dbName = JobFamily.ALL_DB;
//			jobFamily.setServerName(serverName);
//			jobFamily.setDbName(dbName);
//			Job[] jobs = Job.getJobManager().find(jobFamily);
//			if (jobs.length > 0) {
//				CommonUITool.openWarningBox(Messages.bind(
//						Messages.msgStartServiceWithJob, serverName));
//				return;
//			}
//
//			TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(),
//					viewer);
//			ServerInfo serverInfo = server.getServerInfo();
//			GetCubridConfParameterTask task = new GetCubridConfParameterTask(
//					serverInfo);
//			taskExcutor.addTask(task);
//			new ExecTaskWithProgress(taskExcutor).exec();
//		}
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Job(org.eclipse.core.runtime.jobs.Job)

Example 24 with JobFamily

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

the class QuitAction method run.

/**
	 * Quit CUBRID Manager
	 */
public void run() {
    boolean hasJobRunning = false;
    final JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(JobFamily.ALL_SERVER);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    if (jobs.length > 0) {
        hasJobRunning = true;
    }
    boolean isExit = false;
    if (hasJobRunning) {
        isExit = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.msgExistConfirmWithJob);
        if (isExit) {
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    try {
                        Job.getJobManager().cancel(jobFamily);
                    } catch (Exception ignored) {
                        LOGGER.error(ignored.getMessage(), ignored);
                    }
                }
            });
        }
    } else {
        isExit = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.msgExistConfirm);
    }
    if (isExit) {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().close();
    }
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job)

Example 25 with JobFamily

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

the class DBSpaceLabelProvider method loadVolumeData.

public void loadVolumeData() {
    //if no database on this server ,don't get volumn data
    if (serverInfo.getAllDatabaseList().size() == 0 || databaseInfoList == null) {
        return;
    }
    final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
    if (serverInfo.getAllDatabaseList() != null) {
        for (String dbName : serverInfo.getAllDatabaseList()) {
            for (DatabaseInfo databaseInfo : databaseInfoList) {
                // only load start database volumn data
                if (dbName.equals(databaseInfo.getDbName()) && databaseInfo.getRunningType() == DbRunningType.CS) {
                    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
                    task.setDbName(dbName);
                    getVolumnTaskList.add(task);
                    break;
                }
            }
        }
    }
    //if no start database don't get volumn data
    if (getVolumnTaskList.size() == 0) {
        return;
    }
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            List<DBVolumeSpaceInfo> dbVolumeSpaceInfoList = new ArrayList<DBVolumeSpaceInfo>();
            for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
                DbSpaceInfoList dbSpaceInfoList = task.getResultModel();
                freespaceOnStorage = ((long) dbSpaceInfoList.getFreespace()) * 1024l * 1024l;
                DBVolumeSpaceInfo dbSpaceInfo = new DBVolumeSpaceInfo(dbSpaceInfoList.getDbname());
                dbSpaceInfo.setPageSize(dbSpaceInfoList.getPagesize());
                dbVolumeSpaceInfoList.add(dbSpaceInfo);
                if (dbSpaceInfoList != null) {
                    for (DbSpaceInfo spaceInfo : dbSpaceInfoList.getSpaceinfo()) {
                        dbSpaceInfo.addVolumeSpaceInfo(spaceInfo);
                    }
                }
            }
            setVolumeData(dbVolumeSpaceInfoList);
            finishedCount++;
            updateToolBar();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        taskJobExec.addTask(task);
    }
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetVolumeInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.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) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)

Aggregations

JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)44 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)24 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)19 ITask (com.cubrid.common.core.task.ITask)14 Job (org.eclipse.core.runtime.jobs.Job)14 ArrayList (java.util.ArrayList)12 IStatus (org.eclipse.core.runtime.IStatus)12 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)7 List (java.util.List)7 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)4