Search in sources :

Example 1 with SqlRunnerFailed

use of com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed in project cubrid-manager by CUBRID.

the class ViewSQLLogDialog method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.None);
    container.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    container.setLayout(new FormLayout());
    final TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setToolTipText("");
    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
    FormData tableData = new FormData();
    tableData.top = new FormAttachment(0, 0);
    tableData.bottom = new FormAttachment(60, 0);
    tableData.left = new FormAttachment(0, 0);
    tableData.right = new FormAttachment(100, 0);
    tableViewer.getTable().setLayoutData(tableData);
    final TableViewerColumn lineIndex = new TableViewerColumn(tableViewer, SWT.NONE);
    lineIndex.getColumn().setWidth(40);
    lineIndex.getColumn().setText(Messages.failedSQLlineNumber);
    final TableViewerColumn sqlColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    sqlColumn.getColumn().setWidth(400);
    sqlColumn.getColumn().setText(Messages.failedSQL);
    final TableViewerColumn errColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    errColumn.getColumn().setWidth(400);
    errColumn.getColumn().setText(Messages.failedErrorMessage);
    tableViewer.setContentProvider(new ViewFailedSQLTableContentProvider());
    tableViewer.setLabelProvider(new ViewFailedSQLTableLabelProvider());
    tableViewer.setInput(failedList);
    sqlColumn.setLabelProvider(new ColumnLabelProvider() {

        public String getToolTipText(Object element) {
            SqlRunnerFailed failedObj = (SqlRunnerFailed) element;
            return failedObj.getSql();
        }
    });
    errColumn.setLabelProvider(new ColumnLabelProvider() {

        public String getToolTipText(Object element) {
            SqlRunnerFailed failedObj = (SqlRunnerFailed) element;
            return failedObj.getErrorMessage();
        }
    });
    tableViewer.getTable().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TableItem[] items = tableViewer.getTable().getSelection();
            if (items.length == 1) {
                updateDetialInfo((SqlRunnerFailed) items[0].getData());
            }
        }
    });
    detailText = new StyledText(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP);
    detailText.setEditable(false);
    FormData detailData = new FormData();
    detailData.top = new FormAttachment(60, 5);
    detailData.bottom = new FormAttachment(100, -5);
    detailData.left = new FormAttachment(0, 0);
    detailData.right = new FormAttachment(100, 0);
    detailText.setLayoutData(detailData);
    return container;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SqlRunnerFailed(com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) ViewFailedSQLTableContentProvider(com.cubrid.common.ui.common.sqlrunner.ViewFailedSQLTableContentProvider) ViewFailedSQLTableLabelProvider(com.cubrid.common.ui.common.sqlrunner.ViewFailedSQLTableLabelProvider)

Example 2 with SqlRunnerFailed

use of com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed in project cubrid-manager by CUBRID.

the class ExportErrorDataProgress method run.

/* (non-Javadoc)
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
	 */
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // FIXME logic code move to core module
    WritableWorkbook wwb = null;
    try {
        WorkbookSettings workbookSettings = new WorkbookSettings();
        workbookSettings.setEncoding(charset);
        wwb = Workbook.createWorkbook(new File(filePath), workbookSettings);
        int index = 0;
        for (Entry<String, List<SqlRunnerFailed>> entry : failedListMap.entrySet()) {
            WritableSheet ws = wwb.createSheet(entry.getKey(), index++);
            WritableCellFormat normalCellStyle = getNormalCell();
            WritableCellFormat titleCellStyle = getTitleCell();
            jxl.write.Label header = new jxl.write.Label(0, 0, Messages.failedSQLlineNumber, titleCellStyle);
            ws.addCell(header);
            jxl.write.Label header1 = new jxl.write.Label(1, 0, Messages.failedSQL, titleCellStyle);
            ws.addCell(header1);
            jxl.write.Label header2 = new jxl.write.Label(2, 0, Messages.failedErrorMessage, titleCellStyle);
            ws.addCell(header2);
            ws.setColumnView(1, 100);
            ws.setColumnView(2, 80);
            for (int j = 0; j < entry.getValue().size(); j++) {
                SqlRunnerFailed failedInfo = entry.getValue().get(j);
                int row = j + 1;
                jxl.write.Number lineNmuber = new jxl.write.Number(0, row, failedInfo.getLineIndex(), normalCellStyle);
                ws.addCell(lineNmuber);
                jxl.write.Label sql = new jxl.write.Label(1, row, failedInfo.getSql(), normalCellStyle);
                ws.addCell(sql);
                jxl.write.Label errMessage = new jxl.write.Label(2, row, failedInfo.getErrorMessage(), normalCellStyle);
                ws.addCell(errMessage);
            }
        }
        wwb.write();
        success = true;
    } catch (Exception e) {
        LOGGER.error("write excel error", e);
        errMsg = e.getMessage();
    } finally {
        if (wwb != null) {
            try {
                wwb.close();
            } catch (Exception e) {
                LOGGER.error("close excel error", e);
            }
        }
    }
}
Also used : WorkbookSettings(jxl.WorkbookSettings) WritableSheet(jxl.write.WritableSheet) WritableCellFormat(jxl.write.WritableCellFormat) InvocationTargetException(java.lang.reflect.InvocationTargetException) WriteException(jxl.write.WriteException) WritableWorkbook(jxl.write.WritableWorkbook) SqlRunnerFailed(com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed) List(java.util.List) File(java.io.File)

Aggregations

SqlRunnerFailed (com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed)2 ViewFailedSQLTableContentProvider (com.cubrid.common.ui.common.sqlrunner.ViewFailedSQLTableContentProvider)1 ViewFailedSQLTableLabelProvider (com.cubrid.common.ui.common.sqlrunner.ViewFailedSQLTableLabelProvider)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 WorkbookSettings (jxl.WorkbookSettings)1 WritableCellFormat (jxl.write.WritableCellFormat)1 WritableSheet (jxl.write.WritableSheet)1 WritableWorkbook (jxl.write.WritableWorkbook)1 WriteException (jxl.write.WriteException)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 StyledText (org.eclipse.swt.custom.StyledText)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1