Search in sources :

Example 6 with ProgressBar

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();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SqlRunnerProgress(com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerProgress) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RunSQLFileTableContentProvider(com.cubrid.common.ui.common.sqlrunner.RunSQLFileTableContentProvider) Text(org.eclipse.swt.widgets.Text) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IOException(java.io.IOException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RunSQLFileTableLabelProvider(com.cubrid.common.ui.common.sqlrunner.RunSQLFileTableLabelProvider) ProgressBar(org.eclipse.swt.widgets.ProgressBar) File(java.io.File) TableViewer(org.eclipse.jface.viewers.TableViewer) ViewSQLLogDialog(com.cubrid.common.ui.common.sqlrunner.dialog.ViewSQLLogDialog) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 7 with ProgressBar

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);
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TableItem(org.eclipse.swt.widgets.TableItem) TableEditor(org.eclipse.swt.custom.TableEditor) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Example 8 with ProgressBar

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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ProgressBar(org.eclipse.swt.widgets.ProgressBar) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 9 with ProgressBar

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));
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ProgressBar(org.eclipse.swt.widgets.ProgressBar) TableEditor(org.eclipse.swt.custom.TableEditor) Link(org.eclipse.swt.widgets.Link)

Example 10 with ProgressBar

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;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ProgressBar(org.eclipse.swt.widgets.ProgressBar) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Aggregations

ProgressBar (org.eclipse.swt.widgets.ProgressBar)10 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 TableEditor (org.eclipse.swt.custom.TableEditor)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Label (org.eclipse.swt.widgets.Label)2 TableItem (org.eclipse.swt.widgets.TableItem)2 ITask (com.cubrid.common.core.task.ITask)1 RunSQLFileTableContentProvider (com.cubrid.common.ui.common.sqlrunner.RunSQLFileTableContentProvider)1 RunSQLFileTableLabelProvider (com.cubrid.common.ui.common.sqlrunner.RunSQLFileTableLabelProvider)1 ViewSQLLogDialog (com.cubrid.common.ui.common.sqlrunner.dialog.ViewSQLLogDialog)1 SqlRunnerProgress (com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerProgress)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)1 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)1 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)1