Search in sources :

Example 1 with ImportMonitor

use of com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor in project cubrid-manager by CUBRID.

the class TableContentProvider 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));
    progressIndicator = new ProgressIndicator(progressPanel, SWT.NONE);
    progressIndicator.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(importConfig.getErrorLogFolderPath()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    progressTableViewer = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
    progressTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    progressTableViewer.getTable().setLinesVisible(true);
    progressTableViewer.getTable().setHeaderVisible(true);
    final TableViewerColumn tableName = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn totalCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn parseCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn failedCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn status = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn elapsedTime = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn buttonColumn = new TableViewerColumn(progressTableViewer, SWT.NONE);
    tableName.getColumn().setWidth(250);
    tableName.getColumn().setText(Messages.columnName);
    totalCount.getColumn().setWidth(100);
    totalCount.getColumn().setText(Messages.columnCount);
    parseCount.getColumn().setWidth(100);
    parseCount.getColumn().setText(Messages.columnFinished);
    failedCount.getColumn().setWidth(100);
    failedCount.getColumn().setText(Messages.columnFailed);
    status.getColumn().setWidth(100);
    status.getColumn().setText(Messages.columnStatus);
    elapsedTime.getColumn().setWidth(130);
    elapsedTime.getColumn().setText(Messages.columnTime);
    buttonColumn.getColumn().setWidth(90);
    progressTableViewer.setContentProvider(new TableContentProvider());
    progressTableViewer.setLabelProvider(new TableLabelProvider());
    progressTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ImportMonitor monitor = (ImportMonitor) selection.getFirstElement();
            openViewDialog(monitor);
        }
    });
    Composite historyComposite = new Composite(backPanel, SWT.NONE);
    historyComposite.setLayout(new GridLayout(4, false));
    historyComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    historyLabel = new Label(historyComposite, SWT.NONE);
    historyLabel.setText(Messages.lblHistory);
    historyText = new Text(historyComposite, SWT.BORDER);
    historyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    saveButton = new Button(historyComposite, SWT.NONE);
    saveButton.setText(Messages.btnSaveAndClose);
    saveButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (historyText.getText().trim().length() == 0) {
                CommonUITool.openErrorBox(Messages.errHistoryEmpty);
                return;
            }
            if (ImportConfigManager.getInstance().getConfig(historyText.getText()) != null) {
                CommonUITool.openErrorBox(Messages.errHistoryExist);
                return;
            }
            importConfig.setName(historyText.getText().trim());
            ImportConfigManager.getInstance().addConfig(importConfig);
            close();
        }
    });
    closeButton = new Button(historyComposite, SWT.NONE);
    closeButton.setText(Messages.btnClose);
    closeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            close();
        }
    });
    setHistroyWidgetStatus(false);
    init();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ImportMonitor(com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ProgressIndicator(org.eclipse.jface.dialogs.ProgressIndicator) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) File(java.io.File) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 2 with ImportMonitor

use of com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor in project cubrid-manager by CUBRID.

the class TableContentProvider method initTableView.

/**
	 * intiTableView
	 */
private void initTableView() {
    /*Init the data*/
    for (TableConfig tableConfig : importConfig.getSelectedMap().values()) {
        ImportMonitor monitor = new ImportMonitor(tableConfig.getName());
        monitor.setTotalCount(tableConfig.getLineCount());
        tableList.add(monitor);
    }
    progressTableViewer.setInput(tableList);
}
Also used : ImportMonitor(com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor)

Example 3 with ImportMonitor

use of com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor in project cubrid-manager by CUBRID.

the class TableContentProvider method processStop.

/**
	 * process stop logic
	 */
public void processStop() {
    if (manager != null) {
        if (!btnStop.isDisposed()) {
            btnStop.setEnabled(false);
            progressIndicator.done();
            for (ImportMonitor monitor : tableList) {
                if (monitor.getStatus() == 1) {
                    monitor.setStatus(ImportMonitor.STATUS_STOPED);
                }
            }
            progressTableViewer.refresh(tableList);
        }
        isStoped = true;
        manager.stopProcess();
    }
    if (importDataMonitor.hasError() && !openLogFolderButton.isDisposed()) {
        openLogFolderButton.setEnabled(true);
    }
    setHistroyWidgetStatus(true);
    saveButton.forceFocus();
}
Also used : ImportMonitor(com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor)

Aggregations

ImportMonitor (com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor)3 File (java.io.File)1 IOException (java.io.IOException)1 ProgressIndicator (org.eclipse.jface.dialogs.ProgressIndicator)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)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 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1