use of com.cubrid.common.ui.spi.progress.TaskJobExecutor 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);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor 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();
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method showLogView.
/**
* show sql log view at broker table
*
* @param type sql type
*/
public void showLogView(String type) {
try {
int i = brokerInfoTable.getSelectionIndex();
if (i < 0) {
return;
}
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String brokerName = brokerInfoTable.getItem(i).getText(0);
String serverId = brokerInfoTable.getItem(i).getText(1);
//get all log infor
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(brokerName);
task.execute();
brokerLogInfos = task.getResultModel();
String logFileName = brokerName + "_" + serverId + "." + type + ".log";
sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
task.finish();
//get the current log
LogInfo logInfo = null;
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfoInlist : logInfoList) {
if (logFileName.equals(logInfoInlist.getName())) {
logInfo = logInfoInlist;
break;
}
}
}
if (logInfo == null) {
String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
LOGGER.error(msg);
//CommonUITool.openErrorBox(msg);
return;
}
final String filePath = logInfo.getPath();
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files == null || files.length == 0) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, filePath));
}
} else if (task instanceof GetLogListTask) {
GetLogListTask getLogListTask = (GetLogListTask) task;
final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
task.finish();
}
return Status.OK_STATUS;
}
};
CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
checkFileTask.setFile(new String[] { filePath });
taskJobExecutor.addTask(checkFileTask);
GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
getLogListTask.setPath(filePath);
getLogListTask.setStart("1");
getLogListTask.setEnd("100");
taskJobExecutor.addTask(getLogListTask);
String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
} catch (Exception e) {
LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
// CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
}
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class AddVolumeDialog method performTask.
/**
* perform the task
*
* @param addVolumeDbInfo AddVolumeDbInfo
*/
private void performTask(AddVolumeDbInfo addVolumeDbInfo) {
// Checks the path
String sPathText = pathText.getText().trim();
ServerInfo serverInfo = selection.getServer().getServerInfo();
CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
checkDirTask.setDirectory(new String[] { sPathText });
CubridDatabase database = selection.getDatabase();
AddVolumeDbTask addVolumeTask = new AddVolumeDbTask(database.getServer().getServerInfo());
addVolumeTask.setDbname(database.getName());
addVolumeTask.setVolname(addVolumeDbInfo.getVolname());
addVolumeTask.setPurpose(addVolumeDbInfo.getPurpose());
addVolumeTask.setPath(addVolumeDbInfo.getPath());
addVolumeTask.setNumberofpages(addVolumeDbInfo.getNumberofpage());
addVolumeTask.setSizeNeedMb(addVolumeDbInfo.getSize_need_mb());
// Gets the database space info
DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
final CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
dbSpaceInfoTask.setDbName(database.getLabel());
JobFamily jobFamily = new JobFamily();
String serverName = selection.getServer().getName();
String dbName = selection.getDatabase().getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
jobName = Messages.msgAddVolRearJobName + " - " + dbName + "@" + serverName;
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
taskExec.addTask(checkDirTask);
taskExec.addTask(addVolumeTask);
taskExec.addTask(dbSpaceInfoTask);
taskExec.schedule(dbName, jobFamily, true, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class VolumeFolderInfoEditor method loadData.
/**
* load the editor data
*
* @return boolean
*/
public boolean loadData() {
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
} else {
final DbSpaceInfoList model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(model);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initialize();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
task.setDbName(database.getName());
taskJobExecutor.addTask(task);
String serverName = database.getServer().getName();
String dbName = database.getName();
String jobName = Messages.viewVolumeInfoJobName + " - " + volumeFolderName + "@" + dbName + "@" + serverName;
taskJobExecutor.schedule(jobName, null, false, Job.LONG);
return true;
}
Aggregations