Search in sources :

Example 26 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn 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 27 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project AutoRefactor by JnRouvignac.

the class ChooseRefactoringWizardPage method createColumns.

private void createColumns(final TableViewer tableViewer) {
    TableViewerColumn refactoringColumn = createTableViewerColumn(tableViewer);
    refactoringColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((RefactoringRule) element).getName();
        }
    });
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) StyledString(org.eclipse.jface.viewers.StyledString) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 28 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerHostPage method initUIMainContainer.

private void initUIMainContainer(Composite mainContainer) {
    dockerImageNameTextField.setText(dockerImageDescription.dockerImageName);
    dockerImageNameTextField.setToolTipText(AzureDockerValidationUtils.getDockerImageNameTip());
    dockerImageNameTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            if (AzureDockerValidationUtils.validateDockerImageName(((Text) event.getSource()).getText())) {
                errDispatcher.removeMessage("dockerImageNameTextField", dockerImageNameTextField);
                setErrorMessage(null);
                setPageComplete(doValidate());
            } else {
                errDispatcher.addMessage("dockerImageNameTextField", AzureDockerValidationUtils.getDockerImageNameTip(), null, IMessageProvider.ERROR, dockerImageNameTextField);
                setErrorMessage("Invalid Docker image name");
                setPageComplete(false);
            }
        }
    });
    String artifactPath;
    if (project != null) {
        try {
            String projectName = project.getName();
            artifactPath = project.getLocation() + "/" + projectName + ".war";
        } catch (Exception ignored) {
            artifactPath = "";
        }
    } else {
        artifactPath = "";
    }
    if (artifactPath == null || artifactPath.isEmpty() || !Files.isRegularFile(Paths.get(artifactPath))) {
        errDispatcher.addMessage("dockerArtifactPathTextField", AzureDockerValidationUtils.getDockerArtifactPathTip(), null, IMessageProvider.ERROR, dockerArtifactPathTextField);
        setErrorMessage("Invalid artifact path");
    } else {
        dockerArtifactPathTextField.setText(artifactPath);
    }
    dockerArtifactPathTextField.setToolTipText(AzureDockerValidationUtils.getDockerArtifactPathTip());
    dockerArtifactPathTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            if (AzureDockerValidationUtils.validateDockerArtifactPath(((Text) event.getSource()).getText())) {
                errDispatcher.removeMessage("dockerArtifactPathTextField", dockerArtifactPathTextField);
                String artifactFileName = new File(((Text) event.getSource()).getText()).getName();
                wizard.setPredefinedDockerfileOptions(artifactFileName);
                setErrorMessage(null);
                setPageComplete(doValidate());
            } else {
                errDispatcher.addMessage("dockerArtifactPathTextField", AzureDockerValidationUtils.getDockerArtifactPathTip(), null, IMessageProvider.ERROR, dockerArtifactPathTextField);
                setErrorMessage("Invalid artifact path");
                setPageComplete(false);
            }
        }
    });
    dockerArtifactPathBrowseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialog = new FileDialog(dockerArtifactPathBrowseButton.getShell(), SWT.OPEN);
            fileDialog.setText("Select Artifact .WAR or .JAR");
            fileDialog.setFilterPath(System.getProperty("user.home"));
            fileDialog.setFilterExtensions(new String[] { "*.war;*.jar", "*.jar", "*.*" });
            String path = fileDialog.open();
            if (path == null || (!path.toLowerCase().contains(".war") && !path.toLowerCase().contains(".jar"))) {
                return;
            }
            dockerArtifactPathTextField.setText(path);
            String artifactFileName = new File(path).getName();
            wizard.setPredefinedDockerfileOptions(artifactFileName);
            setPageComplete(doValidate());
        }
    });
    TableViewerColumn colHostName = createTableViewerColumn(dockerHostsTableViewer, "Name", 150, 1);
    colHostName.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DockerHost) element).name;
        }
    });
    TableViewerColumn colHostState = createTableViewerColumn(dockerHostsTableViewer, "State", 80, 2);
    colHostState.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            DockerHost dockerHost = (DockerHost) element;
            return dockerHost.hostVM.state != null ? dockerHost.hostVM.state.toString() : "TO_BE_CREATED";
        }
    });
    TableViewerColumn colHostOS = createTableViewerColumn(dockerHostsTableViewer, "OS", 200, 3);
    colHostOS.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DockerHost) element).hostOSType.toString();
        }
    });
    TableViewerColumn colHostApiUrl = createTableViewerColumn(dockerHostsTableViewer, "API URL", 250, 4);
    colHostApiUrl.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DockerHost) element).apiUrl.toString();
        }
    });
    dockerHostsTableViewer.setContentProvider(new ArrayContentProvider());
    dockerHostsList = new ArrayList<>();
    dockerHostsTableViewer.setInput(dockerHostsList);
    refreshDockerHostsTable(mainContainer);
    if (!dockerHostsList.isEmpty()) {
        if (dockerHostsTableSelection == null) {
            dockerHostsTable.select(0);
            dockerHostsTable.getItem(0).setChecked(true);
            dockerHostsTableSelection = new DockerHostsTableSelection();
            dockerHostsTableSelection.row = 0;
            dockerHostsTableSelection.host = (DockerHost) dockerHostsTable.getItem(0).getData();
        } else {
            dockerHostsTable.select(dockerHostsTableSelection.row);
            dockerHostsTable.getItem(dockerHostsTableSelection.row).setChecked(true);
        }
    } else {
        dockerHostsTableSelection = null;
        setPageComplete(false);
    }
    dockerHostsTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                DockerHost dockerHost = (DockerHost) ((TableItem) e.item).getData();
                if (dockerHostsTableSelection == null || dockerHostsTableSelection.host != dockerHost) {
                    dockerHostsTableSelection = new DockerHostsTableSelection();
                    dockerHostsTableSelection.row = dockerHostsTable.indexOf((TableItem) e.item);
                    dockerHostsTableSelection.host = dockerHost;
                    for (TableItem tableItem : dockerHostsTable.getItems()) {
                        if (tableItem != ((TableItem) e.item) && tableItem.getChecked()) {
                            tableItem.setChecked(false);
                        }
                    }
                    dockerHostsTable.redraw();
                } else {
                    dockerHostsTableSelection = null;
                }
                setPageComplete(doValidate());
            }
        }
    });
    dockerHostsRefreshButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AzureDockerUIResources.updateAzureResourcesWithProgressDialog(mainContainer.getShell(), project);
            refreshDockerHostsTable(mainContainer);
            setPageComplete(doValidate());
            sendButtonClickedTelemetry(REFRESH);
        }
    });
    dockerHostsViewButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int idx = dockerHostsTable.getSelectionIndex();
            if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
                DockerHost dockerHost = (DockerHost) dockerHostsTable.getItem(dockerHostsTable.getSelectionIndex()).getData();
                if (dockerHost != null) {
                    AzureViewDockerDialog viewDockerDialog = new AzureViewDockerDialog(mainContainer.getShell(), project, dockerHost, dockerManager);
                    viewDockerDialog.open();
                    if (viewDockerDialog.getInternalExitCode() == AzureViewDockerDialog.UPDATE_EXIT_CODE) {
                        if (dockerHost != null && !dockerHost.isUpdating) {
                            AzureDockerUIResources.updateDockerHost(PluginUtil.getParentShell(), project, new EditableDockerHost(dockerHost), dockerManager, true);
                        } else {
                            PluginUtil.displayErrorDialog(mainContainer.getShell(), "Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
                        }
                    }
                    setPageComplete(doValidate());
                }
            }
            sendButtonClickedTelemetry(VIEW);
        }
    });
    dockerHostsAddButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AzureNewDockerWizard newDockerWizard = new AzureNewDockerWizard(project, dockerManager);
            WizardDialog createNewDockerHostDialog = new AzureWizardDialog(mainContainer.getShell(), newDockerWizard);
            if (createNewDockerHostDialog.open() == Window.OK) {
                DockerHost host = newDockerWizard.getDockerHost();
                dockerImageDescription.host = host;
                dockerImageDescription.hasNewDockerHost = true;
                dockerImageDescription.sid = host.sid;
                AzureDockerPreferredSettings dockerPrefferedSettings = dockerManager.getDockerPreferredSettings();
                if (dockerPrefferedSettings == null) {
                    dockerPrefferedSettings = new AzureDockerPreferredSettings();
                }
                dockerPrefferedSettings.region = host.hostVM.region;
                dockerPrefferedSettings.vmSize = host.hostVM.vmSize;
                dockerPrefferedSettings.vmOS = host.hostOSType.name();
                dockerManager.setDockerPreferredSettings(dockerPrefferedSettings);
                dockerHostsList.add(0, host);
                dockerHostsTable.setEnabled(false);
                dockerHostsRefreshButton.setEnabled(false);
                dockerHostsAddButton.setEnabled(false);
                dockerHostsDeleteButton.setEnabled(false);
                dockerHostsEditButton.setEnabled(false);
                dockerHostsTableViewer.refresh();
                dockerHostsTable.getItem(0).setChecked(true);
                dockerHostsTable.select(0);
            }
            setPageComplete(doValidate());
            sendButtonClickedTelemetry(ADD);
        }
    });
    dockerHostsDeleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            //dockerHostsList
            int idx = dockerHostsTable.getSelectionIndex();
            if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
                DockerHost deleteHost = (DockerHost) dockerHostsTable.getItem(idx).getData();
                if (deleteHost != null) {
                    Azure azureClient = dockerManager.getSubscriptionsMap().get(deleteHost.sid).azureClient;
                    int option = AzureDockerUIResources.deleteAzureDockerHostConfirmationDialog(mainContainer.getShell(), azureClient, deleteHost);
                    if (option != 1 && option != 2) {
                        if (AzureDockerUtils.DEBUG)
                            System.out.format("User canceled delete Docker host op: %d\n", option);
                        return;
                    }
                    dockerHostsList.remove(deleteHost);
                    if (dockerHostsTableSelection != null && dockerHostsTableSelection.row == idx) {
                        dockerHostsTableSelection = null;
                    }
                    dockerHostsTableViewer.refresh();
                    AzureDockerUIResources.deleteDockerHost(mainContainer.getShell(), project, azureClient, deleteHost, option, new Runnable() {

                        @Override
                        public void run() {
                            dockerManager.getDockerHostsList().remove(deleteHost);
                            dockerManager.refreshDockerHostDetails();
                            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    refreshDockerHostsTable(mainContainer);
                                }
                            });
                        }
                    });
                }
                setPageComplete(doValidate());
            }
            sendButtonClickedTelemetry(DELETE);
        }
    });
    dockerHostsEditButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int idx = dockerHostsTable.getSelectionIndex();
            if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
                DockerHost updateHost = (DockerHost) dockerHostsTable.getItem(idx).getData();
                if (updateHost != null && !updateHost.isUpdating) {
                    AzureDockerUIResources.updateDockerHost(PluginUtil.getParentShell(), project, new EditableDockerHost(updateHost), dockerManager, true);
                } else {
                    PluginUtil.displayErrorDialog(mainContainer.getShell(), "Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
                }
            }
            setPageComplete(doValidate());
            sendButtonClickedTelemetry(EDIT);
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) TableItem(org.eclipse.swt.widgets.TableItem) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ModifyEvent(org.eclipse.swt.events.ModifyEvent) AzureWizardDialog(com.microsoft.azuretools.core.components.AzureWizardDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Azure(com.microsoft.azure.management.Azure) AzureNewDockerWizard(com.microsoft.azuretools.docker.ui.wizards.createhost.AzureNewDockerWizard) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) AzureDockerPreferredSettings(com.microsoft.azure.docker.model.AzureDockerPreferredSettings) AzureViewDockerDialog(com.microsoft.azuretools.docker.ui.dialogs.AzureViewDockerDialog) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DockerHost(com.microsoft.azure.docker.model.DockerHost) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) File(java.io.File) FileDialog(org.eclipse.swt.widgets.FileDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AzureWizardDialog(com.microsoft.azuretools.core.components.AzureWizardDialog)

Example 29 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method createBrokerComposite.

/**
	 * craete broker composite
	 *
	 * @param bar
	 * @param bar index
	 *
	 */
public void createBrokerComposite(ExpandBar bar, int index) {
    ExpandItem brokerItem = new ExpandItem(bar, SWT.NONE, index);
    brokerItem.setText(Messages.exportDashboardBrokerTableTitle);
    Composite brokerComposite = new Composite(bar, SWT.None);
    brokerComposite.setLayout(new FillLayout());
    brokerInfoTableViewer = new TableViewer(brokerComposite, SWT.BORDER | SWT.FULL_SELECTION);
    brokerInfoTable = brokerInfoTableViewer.getTable();
    brokerInfoTable.setHeaderVisible(true);
    brokerInfoTable.setLinesVisible(true);
    final TableViewerColumn columnVolumn = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnVolumn.getColumn().setWidth(100);
    columnVolumn.getColumn().setText("Broker");
    columnVolumn.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipBrokerName);
    final TableViewerColumn columnType = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnType.getColumn().setWidth(80);
    columnType.getColumn().setText("ID");
    columnType.getColumn().setToolTipText(Messages.brokerTableIDColumnTip);
    final TableViewerColumn columnSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnSize.getColumn().setWidth(100);
    columnSize.getColumn().setText("PID");
    columnSize.getColumn().setToolTipText(Messages.brokerTablePIDColumnTip);
    final TableViewerColumn columnQPS = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnQPS.getColumn().setWidth(100);
    columnQPS.getColumn().setText("QPS");
    columnQPS.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipQps);
    final TableViewerColumn columnFreeSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnFreeSize.getColumn().setWidth(100);
    columnFreeSize.getColumn().setText("LQS");
    columnFreeSize.getColumn().setToolTipText(Messages.brokerTableLQSColumnTip);
    final TableViewerColumn columnTotalSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnTotalSize.getColumn().setWidth(80);
    columnTotalSize.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
    columnTotalSize.getColumn().setToolTipText(Messages.multiDatabaseLoginDialogColumnStatus);
    final TableViewerColumn columnLocation = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnLocation.getColumn().setWidth(140);
    columnLocation.getColumn().setText(Messages.brokerTableLastConnectTimeColumnLabel);
    columnLocation.getColumn().setToolTipText(Messages.brokerTableLastConnectTimeColumnLabel);
    brokerInfoTableViewer.setContentProvider(new TableContentProvider());
    brokerInfoTableViewer.setLabelProvider(new TableLabelProvider());
    brokerInfoTableViewer.setInput(brokerInfoListData);
    brokerItem.setControl(brokerComposite);
    brokerItem.setHeight(140);
    brokerItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemRestartCAS = new MenuItem(menu, SWT.PUSH);
    itemRestartCAS.setText(Messages.exportDashboardMenuRestartServer);
    itemRestartCAS.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String brokerName = brokerInfoTable.getItem(i).getText(0);
            String serverId = brokerInfoTable.getItem(i).getText(1);
            if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerMsg, serverId))) {
                return;
            }
            ServerInfo serverInfo = database.getServer().getServerInfo();
            RestartBrokerTask restartTask = new RestartBrokerTask(serverInfo);
            restartTask.setBrokerName(brokerName);
            restartTask.setApplyServerNum(serverId);
            TaskExecutor taskExecutor = new CommonTaskExec(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerTaskName, serverId));
            taskExecutor.addTask(restartTask);
            new ExecTaskWithProgress(taskExecutor).exec();
            if (taskExecutor.isSuccess()) {
                // refresh
                brokerInfoListData.clear();
                asinfoLst.clear();
                brokerInfoTable.remove(i);
                loadBrokerInfo();
                //recompute database's qps
                long qps = 0;
                for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
                    for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                        ApplyServerInfo applyServerInfo = entry.getValue();
                        qps += Long.valueOf(applyServerInfo.getAs_num_query());
                    }
                }
                Map<String, String> dbInfoMap = brokerInfoListData.get(0);
                dbInfoMap.put("2", Long.toString(qps));
                if (CompatibleUtil.isSupportGetCPUAndMemoryInfo(database.getDatabaseInfo())) {
                    dbInfoTableViewer.refresh();
                }
                brokerInfoTableViewer.refresh();
            }
        }
    });
    final MenuItem itemShowSqlLog = new MenuItem(menu, SWT.PUSH);
    itemShowSqlLog.setText(Messages.exportDashboardMenuShowSQLLog);
    itemShowSqlLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("sql");
        }
    });
    final MenuItem itemShowSlowQueryLog = new MenuItem(menu, SWT.PUSH);
    itemShowSlowQueryLog.setText(Messages.exportDashboardMenuShowSlowQueryLog);
    itemShowSlowQueryLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("slow");
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    brokerInfoTable.setMenu(menu);
    tableViewOnBarIndexMap.put(brokerInfoTableViewer, index);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DbLotEntry(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry) Entry(java.util.Map.Entry) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RestartBrokerTask(com.cubrid.cubridmanager.core.broker.task.RestartBrokerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 30 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method createLockAndTransactionComposite.

/**
	 * create lock and transaction composite
	 *
	 * @param bar ExpandBar
	 * @param bar index
	 *
	 */
public void createLockAndTransactionComposite(ExpandBar bar, int index) {
    ExpandItem lockAndTransactionItem = new ExpandItem(bar, SWT.NONE, index);
    lockAndTransactionItem.setText(Messages.exportDashboardLockTableTitle);
    Composite lockAndTransactionComposite = new Composite(bar, SWT.NONE);
    lockAndTransactionComposite.setLayout(new FillLayout());
    lockAndTransactionTableViewer = new TableViewer(lockAndTransactionComposite, SWT.BORDER | SWT.FULL_SELECTION);
    lockAndTransactionTable = lockAndTransactionTableViewer.getTable();
    lockAndTransactionTable.setHeaderVisible(true);
    lockAndTransactionTable.setLinesVisible(true);
    final TableViewerColumn columnTranIndex = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnTranIndex.getColumn().setWidth(80);
    columnTranIndex.getColumn().setText(Messages.tblColTranInfoTranIndex);
    columnTranIndex.getColumn().setToolTipText(Messages.tblColTranInfoTranIndex);
    final TableViewerColumn columnUserName = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnUserName.getColumn().setWidth(80);
    columnUserName.getColumn().setText(Messages.tblColTranInfoUserName);
    columnUserName.getColumn().setToolTipText(Messages.tblColTranInfoUserName);
    final TableViewerColumn columnHost = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnHost.getColumn().setWidth(130);
    columnHost.getColumn().setText(Messages.tblColTranInfoHost);
    columnHost.getColumn().setToolTipText(Messages.tblColTranInfoHost);
    final TableViewerColumn columnPid = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnPid.getColumn().setWidth(80);
    columnPid.getColumn().setText(Messages.tblColTranInfoProcessId);
    columnPid.getColumn().setToolTipText(Messages.tblColTranInfoProcessId);
    final TableViewerColumn columnType = new TableViewerColumn(lockAndTransactionTableViewer, SWT.BEGINNING);
    columnType.getColumn().setWidth(320);
    columnType.getColumn().setText(Messages.tblColLockInfoObjectType);
    columnType.getColumn().setToolTipText(Messages.tblColLockInfoObjectType);
    columnPid.getColumn().setAlignment(SWT.CENTER);
    final TableViewerColumn columnMode = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnMode.getColumn().setWidth(100);
    columnMode.getColumn().setText(Messages.tblColLockInfoMode);
    columnMode.getColumn().setToolTipText(Messages.tblColLockInfoMode);
    lockAndTransactionTableViewer.setContentProvider(new TableContentProvider());
    lockAndTransactionTableViewer.setLabelProvider(new TableLabelProvider());
    lockAndTransactionTableViewer.setInput(lockAndTransactionListData);
    lockAndTransactionItem.setControl(lockAndTransactionComposite);
    lockAndTransactionItem.setHeight(140);
    lockAndTransactionItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemKillTran = new MenuItem(menu, SWT.PUSH);
    itemKillTran.setText(Messages.menuKillTransaction);
    itemKillTran.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = lockAndTransactionTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String pid = lockAndTransactionTable.getItem(i).getText(3);
            if (i >= 0 && dbTransactionList != null && dbTransactionList.getTransationInfo() != null && dbTransactionList.getTransationInfo().getTransactionList() != null) {
                KillTransactionDialog dlg = new KillTransactionDialog(Display.getCurrent().getActiveShell());
                Transaction bean = null;
                for (Transaction t : dbTransactionList.getTransationInfo().getTransactionList()) {
                    if (pid.equals(t.getPid())) {
                        bean = t;
                    }
                }
                dlg.setTransationInfo(bean);
                dlg.setDatabase(database);
                if (dlg.open() == IDialogConstants.CANCEL_ID) {
                    return;
                }
                dbTransactionList.getTransationInfo().setTransactionList(dlg.getKillTransactionList().getTransationInfo().getTransactionList());
                lockAndTransactionListData.clear();
                lockAndTransactionTableViewer.getTable().clearAll();
                loadTransactionInfo();
                lockAndTransactionTableViewer.refresh();
            }
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = lockAndTransactionTableViewer.getTable().getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    lockAndTransactionTable.setMenu(menu);
    tableViewOnBarIndexMap.put(lockAndTransactionTableViewer, index);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) KillTransactionDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.KillTransactionDialog) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) Transaction(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)134 TableViewer (org.eclipse.jface.viewers.TableViewer)72 Composite (org.eclipse.swt.widgets.Composite)53 GridData (org.eclipse.swt.layout.GridData)52 SelectionEvent (org.eclipse.swt.events.SelectionEvent)45 TableColumn (org.eclipse.swt.widgets.TableColumn)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 GridLayout (org.eclipse.swt.layout.GridLayout)32 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)28 Table (org.eclipse.swt.widgets.Table)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 Point (org.eclipse.swt.graphics.Point)15 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)14 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 Button (org.eclipse.swt.widgets.Button)14 Image (org.eclipse.swt.graphics.Image)13 Text (org.eclipse.swt.widgets.Text)11