Search in sources :

Example 1 with RunSQLFileTableLabelProvider

use of com.cubrid.common.ui.common.sqlrunner.RunSQLFileTableLabelProvider 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)

Aggregations

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 File (java.io.File)1 IOException (java.io.IOException)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 ProgressBar (org.eclipse.swt.widgets.ProgressBar)1 Text (org.eclipse.swt.widgets.Text)1