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;
}
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);
}
}
}
}
Aggregations