use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class ExportDashboardDialog method exportTableList.
/**
* export dashboard table list
* @return boolean sucess
*/
public boolean exportTableList() throws Exception {
WritableWorkbook wwb = null;
WritableSheet ws = null;
String fileName = saveExcelPath.getText() + saveExcelName.getText() + ".xls";
try {
WritableCellFormat normalCellStyle = getNormalCell();
WorkbookSettings workbookSettings = new WorkbookSettings();
workbookSettings.setEncoding(fileCharsetCombo.getText());
wwb = Workbook.createWorkbook(new File(fileName), workbookSettings);
for (int i = 0; i < exportTableList.size(); i++) {
ws = wwb.createSheet(sheetNames[i], i);
Table table = exportTableList.get(i);
int rowIndex = 0;
//title
for (int j = 0; j < table.getColumnCount(); j++) {
String cellString = table.getColumn(j).getText();
ws.addCell(new jxl.write.Label(j, rowIndex, cellString, normalCellStyle));
ws.setColumnView(j, 30);
}
rowIndex++;
//row
for (int j = 0; j < table.getItemCount(); j++) {
TableItem tableItem = table.getItem(j);
for (int k = 0; k < table.getColumnCount(); k++) {
String cellString = tableItem.getText(k);
ws.addCell(new jxl.write.Label(k, rowIndex, cellString, normalCellStyle));
}
rowIndex++;
}
}
wwb.write();
return true;
} catch (Exception e) {
LOGGER.error(e.getMessage());
throw e;
} finally {
if (wwb != null) {
try {
wwb.close();
} catch (Exception ex) {
LOGGER.error("close excel stream error", ex);
}
}
}
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class LogEditorPart method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
* @param parent the parent control
* @see IWorkbenchPart
*/
public void createPartControl(Composite parent) {
final Composite compositeLog = new Composite(parent, SWT.NONE);
{
GridLayout gridLayoutLog = new GridLayout();
gridLayoutLog.verticalSpacing = 0;
gridLayoutLog.marginWidth = 0;
gridLayoutLog.marginHeight = 0;
gridLayoutLog.horizontalSpacing = 5;
gridLayoutLog.numColumns = 8;
compositeLog.setLayout(gridLayoutLog);
}
final String type = this.cubridNode.getType();
table = new Table(compositeLog, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
{
table.setHeaderVisible(true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 8;
gridData.verticalSpan = 10;
gridData.heightHint = 600;
table.setLayoutData(gridData);
table.setLinesVisible(true);
}
// fill in context menu
if (CubridNodeType.BROKER_SQL_LOG.equals(type) || CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
//Create the context menu
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
buildPopupMenu(manager, type);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(table);
table.setMenu(contextMenu);
//Add listener
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
copyDataToClipboard(type);
}
}
});
}
table.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
if (CubridNodeType.BROKER_SQL_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(1);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
} else if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(4);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
} else if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(cubridNode.getType())) {
TableItem[] items = table.getSelection();
if (items != null && items.length == 1) {
final String content = items[0].getText(6);
new LogContentDetailDialog(getSite().getShell(), content).open();
}
}
}
});
// add bottom composite for page
Label labelCharset = new Label(compositeLog, SWT.NONE);
{
labelCharset.setText(Messages.labelCharset);
charsetCombo = new Combo(compositeLog, SWT.BORDER);
final GridData gdCharsetText = CommonUITool.createGridData(1, 1, -1, -1);
charsetCombo.setLayoutData(gdCharsetText);
charsetCombo.setItems(QueryOptions.getAllCharset(null));
charsetCombo.setText(charsetName);
}
Button viewLogBtn = new Button(compositeLog, SWT.NONE);
{
viewLogBtn.setText(Messages.viewLogJobName);
viewLogBtn.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
viewLogBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String charsetName = charsetCombo.getText();
try {
"".getBytes(charsetName);
} catch (UnsupportedEncodingException e) {
CommonUITool.openErrorBox(Messages.errCharset);
charsetCombo.setFocus();
return;
}
setCharsetName(charsetName);
if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
connect(false);
}
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
managerConnect();
updateManagerLogTable();
}
}
});
}
// page button
if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
pageText = new Text(compositeLog, SWT.BORDER);
{
pageText.setVisible(true);
pageText.setEditable(false);
GridData gridData = createPageBtnGridData(150);
gridData.grabExcessHorizontalSpace = true;
pageText.setLayoutData(gridData);
}
buttonFirst = new Button(compositeLog, SWT.NONE);
{
buttonFirst.setVisible(true);
buttonFirst.setText("|<");
buttonFirst.setLayoutData(createPageBtnGridData(60));
buttonFirst.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart = 1;
lineEnd = 100;
connect(false);
}
});
}
buttonPrev = new Button(compositeLog, SWT.NONE);
{
buttonPrev.setVisible(true);
buttonPrev.setText("<");
buttonPrev.setLayoutData(createPageBtnGridData(60));
buttonPrev.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart -= 100;
if (lineStart < 1) {
lineStart = 1;
}
lineEnd = lineStart + 99;
connect(false);
}
});
}
buttonNext = new Button(compositeLog, SWT.NONE);
{
buttonNext.setVisible(true);
buttonNext.setText(">");
buttonNext.setLayoutData(createPageBtnGridData(60));
buttonNext.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineStart += 100;
if (lineStart > lineTot) {
lineStart = lineTot;
}
lineEnd = lineStart + 99;
if (lineEnd > lineTot) {
lineEnd = lineTot;
}
connect(false);
}
});
}
buttonEnd = new Button(compositeLog, SWT.NONE);
{
buttonEnd.setVisible(true);
buttonEnd.setText(">|");
buttonEnd.setLayoutData(createPageBtnGridData(60));
buttonEnd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
lineEnd = lineTot;
lineStart = lineEnd - lineTot % 100 + 1;
connect(false);
}
});
}
}
// manager log page button
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
pageText = new Text(compositeLog, SWT.BORDER);
{
pageText.setVisible(true);
pageText.setEditable(false);
GridData gridData = createPageBtnGridData(150);
gridData.grabExcessHorizontalSpace = true;
pageText.setLayoutData(gridData);
}
buttonFirst = new Button(compositeLog, SWT.NONE);
buttonFirst.setVisible(true);
buttonFirst.setText("|<");
buttonFirst.setLayoutData(createPageBtnGridData(60));
buttonFirst.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(1);
updateManagerLogTable();
}
});
buttonPrev = new Button(compositeLog, SWT.NONE);
buttonPrev.setVisible(true);
buttonPrev.setText("<");
buttonPrev.setLayoutData(createPageBtnGridData(60));
buttonPrev.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getCurrentPage() - 1);
updateManagerLogTable();
}
});
buttonNext = new Button(compositeLog, SWT.NONE);
buttonNext.setVisible(true);
buttonNext.setText(">");
buttonNext.setLayoutData(createPageBtnGridData(60));
buttonNext.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getCurrentPage() + 1);
updateManagerLogTable();
}
});
buttonEnd = new Button(compositeLog, SWT.NONE);
buttonEnd.setVisible(true);
buttonEnd.setText(">|");
buttonEnd.setLayoutData(createPageBtnGridData(60));
buttonEnd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
pageInfo.setCurrentPage(pageInfo.getPages());
updateManagerLogTable();
}
});
}
compositeLog.pack();
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class AddIndexDialog method createColumnTable.
/**
* Create the column table
*
*/
private void createColumnTable() {
columnTable = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.CHECK);
{
columnTable.setHeaderVisible(true);
GridData gdColumnTable = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gdColumnTable.heightHint = 200;
columnTable.setLayoutData(gdColumnTable);
columnTable.setLinesVisible(true);
}
columnTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
final TableItem item = (TableItem) event.item;
if (event.detail == SWT.CHECK) {
if (item.getChecked()) {
item.setForeground(ResourceManager.getColor(0, 0, 0));
} else {
item.setForeground(ResourceManager.getColor(128, 128, 128));
}
columnTable.setSelection(new TableItem[] { item });
}
setBtnEnable();
setHintMessage();
}
});
CommonUITool.hackForYosemite(columnTable);
TableColumn tblCol = new TableColumn(columnTable, SWT.LEFT);
tblCol.setWidth(83);
tblCol.setText(Messages.colUseColumn);
tblCol = new TableColumn(columnTable, SWT.LEFT);
tblCol.setWidth(123);
tblCol.setText(Messages.colColumnName);
tblCol = new TableColumn(columnTable, SWT.LEFT);
tblCol.setWidth(196);
tblCol.setText(Messages.colDataType);
tblCol = new TableColumn(columnTable, SWT.LEFT);
tblCol.setWidth(86);
tblCol.setText(Messages.colOrder);
if (isSupportPrefixLength) {
tblCol = new TableColumn(columnTable, SWT.LEFT);
tblCol.setWidth(196);
tblCol.setText(Messages.colPrefixLength);
}
setTableEditor();
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class TableDashboardComposite method createColumnsTable.
/**
* Create the column information table
*
*/
private void createColumnsTable(Composite topComposite) {
columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
Table columnsTable = columnTableView.getTable();
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.heightHint = 189;
columnsTable.setLayoutData(gdColumnsTable);
// 0 PK
TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(WIDTH_PKCOLUMN);
tblCol.setText(Messages.tblColumnPK);
// 1 NAME
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NAMECOLUMN);
tblCol.setText(Messages.tblColumnName);
// 2 MEMO
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NAMECOLUMN);
tblCol.setText(Messages.tblColumnMemo);
// 3 DATATYPE
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_DATATYPECOLUMN);
tblCol.setText(Messages.tblColumnDataType);
// 4 DEFAULT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(98);
tblCol.setText(Messages.tblColumnDefault);
// 5 AUTO INCREMENT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnAutoIncr);
// 6 NOT NULL
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
tblCol.setText(Messages.tblColumnNotNull);
tblCol.setAlignment(SWT.CENTER);
// 7 UK
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_UNIQUECOLUMN);
tblCol.setText(Messages.tblColumnUnique);
tblCol.setAlignment(SWT.CENTER);
// 8 SHARED
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_SHAREDCOLUMN);
tblCol.setResizable(true);
tblCol.setText(Messages.tblColumnShared);
tblCol.setAlignment(SWT.CENTER);
labelProvider = new TableDashboardDetailLabelProvider(null, null);
columnTableView.setContentProvider(new TableDashboardDetailContentProvider());
columnTableView.setLabelProvider(labelProvider);
columnTableView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
copyTablesDetailToClipboard();
} else if (event.keyCode == SWT.CR) {
showEditDialog(columnTableView.getTable(), columnTableView.getTable().getSelectionIndex());
}
}
});
registerContextMenu();
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class SchemaInfoEditorPart method createColumnsTable.
/**
* Create the column information table
*
*/
private void createColumnsTable() {
Label colslabel = new Label(topComposite, SWT.LEFT | SWT.WRAP);
colslabel.setText(Messages.lblColumns);
colslabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.SIMPLE | SWT.BORDER);
Table columnsTable = columnTableView.getTable();
{
createContextMenu(columnsTable);
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.heightHint = 189;
columnsTable.setLayoutData(gdColumnsTable);
// PK
TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(WIDTH_PKCOLUMN);
tblCol.setText(Messages.tblColumnPK);
// NAME
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NAMECOLUMN);
tblCol.setText(Messages.tblColumnName);
// DATATYPE
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_DATATYPECOLUMN);
tblCol.setText(Messages.tblColumnDataType);
// DEFAULT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(98);
tblCol.setText(Messages.tblColumnDefault);
// AUTO INCREMENT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnAutoIncr);
// NOT NULL
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
tblCol.setText(Messages.tblColumnNotNull);
tblCol.setAlignment(SWT.CENTER);
// UK
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_UNIQUECOLUMN);
tblCol.setText(Messages.tblColumnUnique);
tblCol.setAlignment(SWT.CENTER);
// SHARED
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_SHAREDCOLUMN);
tblCol.setResizable(true);
tblCol.setText(Messages.tblColumnShared);
tblCol.setAlignment(SWT.CENTER);
// INHERIT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(90);
tblCol.setResizable(true);
tblCol.setText(Messages.tblColumnInherit);
// CLASS
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(90);
tblCol.setResizable(true);
tblCol.setText(Messages.tblColumnClass);
tblCol.setAlignment(SWT.CENTER);
}
columnTableView.setContentProvider(new AttributeTableViewerContentProvider());
columnTableView.setLabelProvider(new AttributeTableViewerLabelProvider(database, schemaInfo));
CommonUITool.hackForYosemite(columnTableView.getTable());
columnTableView.setInput(schemaInfo);
setTableEditor(columnsTable, 1);
setTableEditor(columnsTable, 2);
}
Aggregations