use of org.eclipse.swt.widgets.ProgressBar in project cubrid-manager by CUBRID.
the class RunSQLFileViewPart method createPartControl.
/**
* Create part controls
*
* @param parent of the controls
*/
public void createPartControl(Composite parent) {
Composite backPanel = new Composite(parent, SWT.NONE);
backPanel.setLayout(new GridLayout(1, false));
backPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Composite progressPanel = new Composite(backPanel, SWT.NONE);
progressPanel.setLayout(new GridLayout(3, false));
progressPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
pbTotal = new ProgressBar(progressPanel, SWT.NONE);
pbTotal.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
btnStop = new Button(progressPanel, SWT.NONE);
btnStop.setText(Messages.btnStop);
btnStop.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_stop.png"));
btnStop.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
processStop();
}
});
openLogFolderButton = new Button(progressPanel, SWT.NONE);
openLogFolderButton.setText(Messages.runSQLOpenBtn);
openLogFolderButton.setEnabled(false);
openLogFolderButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
java.awt.Desktop.getDesktop().open(new File(input.getLogFolderPath()));
} catch (IOException e) {
e.printStackTrace();
}
}
});
Composite textComp = new Composite(backPanel, SWT.NONE);
GridData textCompGd = new GridData(GridData.FILL_HORIZONTAL);
textCompGd.heightHint = 50;
textCompGd.exclude = true;
textComp.setVisible(false);
textComp.setLayoutData(textCompGd);
textComp.setLayout(new GridLayout(1, false));
Text errorText = new Text(textComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
errorText.setLayoutData(new GridData(GridData.FILL_BOTH));
errorText.setEditable(false);
tvProgress = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
tvProgress.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
tvProgress.getTable().setLinesVisible(true);
tvProgress.getTable().setHeaderVisible(true);
final TableViewerColumn fileName = new TableViewerColumn(tvProgress, SWT.NONE);
final TableViewerColumn successCount = new TableViewerColumn(tvProgress, SWT.NONE);
final TableViewerColumn failCount = new TableViewerColumn(tvProgress, SWT.NONE);
final TableViewerColumn status = new TableViewerColumn(tvProgress, SWT.NONE);
final TableViewerColumn elapsedTime = new TableViewerColumn(tvProgress, SWT.NONE);
fileName.getColumn().setWidth(250);
fileName.getColumn().setText(Messages.fileName);
successCount.getColumn().setWidth(100);
successCount.getColumn().setText(Messages.successCount);
failCount.getColumn().setWidth(100);
failCount.getColumn().setText(Messages.failCount);
status.getColumn().setWidth(100);
status.getColumn().setText(Messages.columnStatus);
elapsedTime.getColumn().setWidth(130);
elapsedTime.getColumn().setText(Messages.columnElapsedTime);
tvProgress.setContentProvider(new RunSQLFileTableContentProvider());
tvProgress.setLabelProvider(new RunSQLFileTableLabelProvider());
tvProgress.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
SqlRunnerProgress po = (SqlRunnerProgress) selection.getFirstElement();
new ViewSQLLogDialog(Display.getDefault().getActiveShell(), po.getFileName(), po.getFailList()).open();
}
});
String errorMsg = testConnection();
if (errorMsg != null) {
pbTotal.setEnabled(false);
btnStop.setEnabled(false);
textCompGd.exclude = false;
textComp.setVisible(true);
errorText.setText("Can't get connection : " + errorMsg);
textComp.getParent().layout();
return;
}
initManager();
intiTableView();
}
use of org.eclipse.swt.widgets.ProgressBar in project cubrid-manager by CUBRID.
the class MultiHostConnectionDialog method initTask.
public void initTask() {
if (container == null)
return;
for (ConnectionTaskContainer con : container) {
ServerInfo info = con.getServerInfo();
TableItem item = new TableItem(table, SWT.NONE);
item.setText(1, info.getServerName());
TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
ProgressBar bar = new ProgressBar(table, SWT.NONE);
editor.setEditor(bar, item, 2);
con.setItem(item);
item.setData(KEY_BAR, bar);
item.setData(KEY_CONNECTION, con);
}
}
use of org.eclipse.swt.widgets.ProgressBar in project cubrid-manager by CUBRID.
the class QueryResultComposite method makeProgressBar.
/**
* Make the progress bar
*
* @param runnable
* @param serverInfo
* @param isMultiQuery
*/
public void makeProgressBar(final Runnable runnable, ServerInfo serverInfo, boolean isMultiQuery) {
isCancelling = false;
startMillis = System.currentTimeMillis();
Composite comp = new Composite(queryResultTabFolder, SWT.NONE);
comp.setLayout(new GridLayout(6, true));
ProgressBar runQueryPb = new ProgressBar(comp, SWT.HORIZONTAL | SWT.INDETERMINATE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 5;
runQueryPb.setLayoutData(gridData);
stopButton = new Button(comp, SWT.PUSH);
stopButton.setText(Messages.stopBtn);
stopButton.setToolTipText(Messages.stopBtnTip);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 1;
stopButton.setLayoutData(gridData);
// show elapsed time
Label timeLabel = new Label(comp, SWT.LEFT);
timeLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 6, 1, -1, -1));
timeLabel.setText(getElapsedTimeStr(0));
timeLabel.setForeground(ResourceManager.getColor(255, 0, 0));
setTimer(runQueryPb, timeLabel);
boolean isSupported = false;
if (isMultiQuery) {
isSupported = CompatibleUtil.isSupportJDBCCancel(serverInfo);
} else {
ServerInfo selectedServerInfo = editor.getSelectedServer() == null ? null : editor.getSelectedServer().getServerInfo();
isSupported = CompatibleUtil.isSupportJDBCCancel(selectedServerInfo);
}
stopButton.setEnabled(isSupported);
if (isSupported) {
stopButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (isCancelling) {
if (!CommonUITool.openConfirmBox(Messages.msgDisConnect)) {
return;
}
editor.disconnectAndDisposeResults();
stopButton.setEnabled(false);
} else {
isCancelling = true;
startMillis = System.currentTimeMillis();
stopButton.setEnabled(false);
Thread thread = new Thread(runnable);
thread.start();
}
}
});
}
CTabItem tab = new CTabItem(queryResultTabFolder, SWT.NONE);
tab.setText(Messages.proRunQuery);
tab.setControl(comp);
queryResultTabFolder.setSelection(isMultiQuery ? 1 : 0);
}
use of org.eclipse.swt.widgets.ProgressBar in project azure-tools-for-java by Microsoft.
the class WindowsAzureActivityLogView method addDeployment.
public void addDeployment(String key, String description, Date startDate) {
if (rows.containsKey(key)) {
rows.remove(key);
}
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { description, null, null, dateFormat.format(startDate) });
ProgressBar bar = new ProgressBar(table, SWT.NONE);
bar.setSelection(0);
TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor(bar, item, 1);
Link link = new Link(table, SWT.LEFT);
link.setText("");
link.setBackground(item.getBackground());
rows.put(key, new TableRowDescriptor(item, bar, link));
}
use of org.eclipse.swt.widgets.ProgressBar in project cubrid-manager by CUBRID.
the class FinishTask method call.
public Integer call() {
ProgressBar bar = (ProgressBar) item.getData(MultiHostConnectionDialog.KEY_BAR);
MonitorDashboardPreference monPref = new MonitorDashboardPreference();
boolean isRunUpdateCmUserTask = false;
BrokerInfos brokerInfos = null;
int size = tasks.size();
int taskIdx = 1;
for (ITask task : tasks) {
if (task instanceof MonitoringTask) {
if (!serverInfo.isConnected()) {
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
MonitoringTask monitoringTask = (MonitoringTask) task;
serverInfo = monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
if (serverInfo.isConnected()) {
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
} else {
CMHostNodePersistManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
}
}
} else if ((task instanceof UpdateCMUserTask)) {
updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
} else {
task.execute();
}
final String msg = task.getErrorMsg();
if (msg != null && msg.length() > 0) {
item.setText(3, msg);
disConnect();
isFinished = true;
updateIcon();
return 1;
}
if (task instanceof GetEnvInfoTask) {
GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
serverInfo.setEnvInfo(envInfo);
String clientVersion = getClientVerion();
if (!isClientSupport(clientVersion)) {
item.setText(3, Messages.bind(Messages.errNoSupportServerVersion, clientVersion));
disConnect();
isFinished = true;
updateIcon();
return 2;
}
String jdbcVersion = serverInfo.getJdbcDriverVersion();
if (serverInfo.validateJdbcVersion(jdbcVersion)) {
if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
serverInfo.setJdbcDriverVersion(ServerInfo.getAutoDetectJdbcVersion(serverInfo.getFullServerVersionKey()));
}
} else {
if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
item.setText(3, Messages.errNoSupportDriver);
} else {
item.setText(3, Messages.errSelectSupportDriver);
}
disConnect();
isFinished = true;
updateIcon();
return 3;
}
} else if (task instanceof GetDatabaseListTask) {
GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
if (databaseInfoList != null) {
allDatabaseInfoList.addAll(databaseInfoList);
}
} else if (task instanceof GetCMConfParameterTask) {
GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
ServerType serverType = ServerType.BOTH;
if (confParameters != null) {
String target = confParameters.get(CubridManagerConfParaConstants.CM_TARGET);
if (target != null) {
if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
serverType = ServerType.BOTH;
} else if (target.indexOf("broker") >= 0) {
serverType = ServerType.BROKER;
} else if (target.indexOf("server") >= 0) {
serverType = ServerType.DATABASE;
}
}
}
if (serverInfo != null) {
serverInfo.setServerType(serverType);
}
} else if (task instanceof CommonQueryTask) {
CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
brokerInfos = getBrokerTask.getResultModel();
if (serverInfo != null) {
serverInfo.setBrokerInfos(brokerInfos);
}
} else if (task instanceof GetCMUserListTask) {
if (serverInfo != null && serverInfo.isConnected()) {
GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
serverInfo.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
if (databaseInfoList != null) {
authDatabaseList.addAll(databaseInfoList);
}
isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
if (isRunUpdateCmUserTask) {
serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
}
}
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setCubridConfParaMap(confParas);
}
} else if (task instanceof GetBrokerConfParameterTask) {
GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setBrokerConfParaMap(confParas);
}
} else if (task instanceof FinishTask) {
isSuccess = true;
server.getLoader().setLoaded(false);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
bar.setSelection(taskIdx++ / size * 100);
if (isCanceled()) {
isFinished = true;
updateIcon();
return 4;
}
}
bar.setSelection(100);
item.setText(3, Messages.msgConneted);
isFinished = true;
return 0;
}
Aggregations