use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class DatabaseStatusEditor method execTask.
/**
*
* Execute the tasks
*
* @param buttonId the button id
* @param tasks the tasks array
* @param cancelable whether can be cancelled
*/
public void execTask(final int buttonId, final SocketTask[] tasks, boolean cancelable) {
final Shell shell = parentComp.getShell();
final Display display = shell.getDisplay();
isRunning = false;
try {
new ProgressMonitorDialog(shell).run(true, cancelable, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(com.cubrid.common.ui.spi.Messages.msgRunning, IProgressMonitor.UNKNOWN);
if (monitor.isCanceled()) {
return;
}
isRunning = true;
Thread thread = new Thread() {
public void run() {
while (!monitor.isCanceled() && isRunning) {
try {
sleep(1);
} catch (InterruptedException e) {
}
}
if (monitor.isCanceled()) {
for (SocketTask t : tasks) {
if (t != null) {
t.cancel();
}
}
}
}
};
thread.start();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
for (SocketTask task : tasks) {
if (task != null) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(shell, msg);
}
});
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
isRunning = false;
monitor.done();
}
});
} catch (InvocationTargetException e) {
LOGGER.error(e.getMessage(), e);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class VolumeInformationEditor method execTask.
/**
* execute the task
*
* @param buttonId int
* @param tasks SocketTask[]
* @param cancelable boolean
*/
public void execTask(final int buttonId, final SocketTask[] tasks, boolean cancelable) {
final Shell shell = parentComp.getShell();
final Display display = shell.getDisplay();
isRunning = false;
try {
new ProgressMonitorDialog(shell).run(true, cancelable, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(com.cubrid.common.ui.spi.Messages.msgRunning, IProgressMonitor.UNKNOWN);
if (monitor.isCanceled()) {
return;
}
isRunning = true;
Thread thread = new Thread() {
public void run() {
while (!monitor.isCanceled() && isRunning) {
try {
sleep(1);
} catch (InterruptedException e) {
}
}
if (monitor.isCanceled()) {
for (SocketTask t : tasks) {
if (t != null) {
t.cancel();
}
}
}
}
};
thread.start();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
for (SocketTask task : tasks) {
if (task != null) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(shell, msg);
}
});
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
isRunning = false;
monitor.done();
}
});
} catch (InvocationTargetException e) {
LOGGER.error(e.getMessage(), e);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method loadData.
/**
* load edit data
*/
public void loadData() {
if (editorInput.getTaskCountValue() == 0) {
return;
}
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(getSite().getShell());
progress.setCancelable(false);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.unifyHostConfigEditorLoadingDataMsg, editorInput.getTaskCountValue());
unifyHostConfigUtil = new UnifyHostConfigUtil();
for (CubridServer cubridServer : editorInput.getCubridServers()) {
if (editorInput.isEditCubridConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid.conf", cubridServer.getName()));
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(cubridServer.getServerInfo());
getCubridConfParameterTask.execute();
if (getCubridConfParameterTask.isSuccess()) {
List<String> contentsList = getCubridConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridConfConfig cubridConfConfig = unifyHostConfigUtil.parseStringLineToCubridConfConfig(contentBuilder.toString());
cubridConfConfigDataMap.put(cubridServer.getName(), cubridConfConfig);
monitor.worked(1);
}
}
if (editorInput.isEditBrokerConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "broker", cubridServer.getName()));
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(cubridServer.getServerInfo());
getBrokerConfParameterTask.execute();
if (getBrokerConfParameterTask.isSuccess()) {
List<String> contentsList = getBrokerConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = cubridBrokerConfUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
cubridBrokerConfigDataMap.put(cubridServer.getName(), cubridBrokerConfig);
monitor.worked(1);
}
}
if (editorInput.isEditCMConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cm.conf", cubridServer.getName()));
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(cubridServer.getServerInfo());
getCMConfParameterTask.execute();
if (getCMConfParameterTask.isSuccess()) {
List<String> contentsList = getCMConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridCMConfConfig cubridCMConfConfig = unifyHostConfigUtil.parseStringLineToCubridCMConfConfig(contentBuilder.toString());
cubridConfCMConfigDataMap.put(cubridServer.getName(), cubridCMConfConfig);
// System.out.println(contentBuilder.toString());
}
monitor.worked(1);
}
if (editorInput.isEditHAConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid_ha.conf", cubridServer.getName()));
monitor.worked(1);
}
if (editorInput.isEditACLConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "acl", cubridServer.getName()));
monitor.worked(1);
}
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class BackupErrLogDialog method connect.
/**
* connect
*
* @param buttonId int
* @param tasks SocketTask[]
* @param cancelable boolean
* @param shell Shell
*/
public void connect(final int buttonId, final SocketTask[] tasks, boolean cancelable, Shell shell) {
final Display display = shell.getDisplay();
isRunning = false;
try {
new ProgressMonitorDialog(getShell()).run(true, cancelable, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(com.cubrid.common.ui.spi.Messages.msgRunning, IProgressMonitor.UNKNOWN);
if (monitor.isCanceled()) {
return;
}
isRunning = true;
Thread thread = new Thread() {
public void run() {
while (!monitor.isCanceled() && isRunning) {
try {
sleep(1);
} catch (InterruptedException e) {
}
}
if (monitor.isCanceled()) {
for (SocketTask t : tasks) {
if (t != null) {
t.cancel();
}
}
}
}
};
thread.start();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
for (SocketTask task : tasks) {
if (task != null) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
isRunning = false;
return;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(msg);
}
});
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
}
if (monitor.isCanceled()) {
isRunning = false;
return;
}
if (!monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
if (buttonId > 0) {
setReturnCode(buttonId);
close();
}
}
});
}
isRunning = false;
monitor.done();
}
});
} catch (InvocationTargetException e) {
LOGGER.error(e.getMessage(), e);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project dbeaver by serge-rider.
the class DBeaverUI method runInProgressDialog.
/**
* Runs task in Eclipse progress dialog.
* NOTE: this call can't be canceled if it will block in IO
*/
public static void runInProgressDialog(final DBRRunnableWithProgress runnable) throws InvocationTargetException {
try {
IRunnableContext runnableContext;
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (workbenchWindow != null) {
runnableContext = new ProgressMonitorDialog(workbench.getActiveWorkbenchWindow().getShell());
} else {
runnableContext = workbench.getProgressService();
}
runnableContext.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
runnable.run(RuntimeUtils.makeMonitor(monitor));
}
});
} catch (InterruptedException e) {
// do nothing
}
}
Aggregations