use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class ImportResultDialog method createDialogArea.
/**
* Create the dialog area
*
* @param parent Composite
* @return Control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
{
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
}
TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
table = tableViewer.getTable();
{
GridData gdData = new GridData(GridData.FILL_BOTH);
gdData.heightHint = 400;
gdData.widthHint = 500;
table.setLayoutData(gdData);
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText(Messages.importColumnNO);
tableColumn = new TableColumn(table, SWT.LEFT);
tableColumn.setText(Messages.importColumnMessage);
tableViewer.setLabelProvider(new TableLabelProvider(tableViewer, null));
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setInput(errorList);
//Create the context menu
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
//copy action
Action copyAction = new Action(Messages.bind(Messages.contextCopy, "Ctrl+C")) {
public void run() {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
copyDataToClipboard();
}
});
}
};
manager.add(copyAction);
}
});
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();
}
}
});
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn tblColumn = table.getColumn(i);
tblColumn.pack();
if (tblColumn.getWidth() > 400) {
tblColumn.setWidth(400);
}
}
Label label = new Label(composite, SWT.LEFT);
label.setForeground(ResourceManager.getColor(255, 0, 0));
label.setText(message);
return composite;
}
use of org.eclipse.jface.viewers.TableViewer 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);
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class SchemaInfoEditorPart method createFKTable.
/**
* Create foreign key information table
*
*/
private void createFKTable() {
Label fkLabel = new Label(topComposite, SWT.LEFT | SWT.WRAP);
fkLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fkLabel.setText(Messages.lblFK);
fkTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
Table fkTable = fkTableView.getTable();
{
createContextMenu(fkTable);
final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true);
fkTable.setLayoutData(gdFkTable);
fkTable.setLinesVisible(true);
fkTable.setHeaderVisible(true);
CommonUITool.hackForYosemite(fkTable);
TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(160);
tblCol.setText(Messages.tblColumnFK);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(119);
tblCol.setText(Messages.tblColumnColumnName);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(93);
tblCol.setText(Messages.tblColumnForeignTable);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(143);
tblCol.setText(Messages.tblColumnForeignColumnName);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(84);
tblCol.setText(Messages.tblColumnUpdateRule);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(86);
tblCol.setText(Messages.tblColumnDeleteRule);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnCacheColumn);
}
fkTableView.setContentProvider(new FKTableViewerContentProvider());
fkTableView.setLabelProvider(new FKTableViewerLabelProvider(database));
fkTableView.setInput(schemaInfo);
int colNum = fkTable.getColumnCount();
for (int i = 0; i < colNum; i++) {
setTableEditor(fkTable, i);
}
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class TableConfigCellEditor method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(1, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(55, 0);
leftComposite.setLayoutData(leftData);
Group grpButtons = new Group(leftComposite, SWT.NONE);
{
grpButtons.setLayout(new GridLayout(4, false));
grpButtons.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
grpButtons.setText(Messages.grpAddRemove);
}
Button sqlSchemaFileButton = new Button(grpButtons, SWT.NONE);
sqlSchemaFileButton.setText(Messages.btnAddSchemaFile);
sqlSchemaFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlSchemaFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_SCHEMA);
}
});
Button sqlDataFileButton = new Button(grpButtons, SWT.NONE);
sqlDataFileButton.setText(Messages.btnAddDataFile);
sqlDataFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlDataFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_DATA);
}
});
Button sqlIndexFileButton = new Button(grpButtons, SWT.NONE);
sqlIndexFileButton.setText(Messages.btnAddIndexFile);
sqlIndexFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlIndexFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_INDEX);
}
});
delFileButton = new Button(grpButtons, SWT.NONE);
delFileButton.setText(Messages.btnDelFiles);
delFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
delFileButton.setEnabled(false);
delFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
deleteSelectedFile();
}
});
sqlFileTableViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
sqlFileTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
sqlFileTableViewer.getTable().setLinesVisible(true);
sqlFileTableViewer.getTable().setHeaderVisible(true);
final TableViewerColumn fileNameCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileNameCol.getColumn().setWidth(300);
fileNameCol.getColumn().setText(Messages.columnImportFileName);
final TableViewerColumn fileTypeCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileTypeCol.getColumn().setWidth(100);
fileTypeCol.getColumn().setText(Messages.columnImportFileType);
CellEditor[] editors = new CellEditor[4];
editors[0] = new TextCellEditor(sqlFileTableViewer.getTable());
editors[1] = new ComboBoxCellEditor(sqlFileTableViewer.getTable(), TYPE_ITEMS, SWT.READ_ONLY);
sqlFileTableViewer.setColumnProperties(PROPS);
sqlFileTableViewer.setContentProvider(new SQLFileTableContentProvider());
sqlFileTableViewer.setLabelProvider(new SQLFileTableLabelProvider());
sqlFileTableViewer.setCellModifier(new TableConfigCellEditor(sqlFileTableViewer, this));
sqlFileTableViewer.setCellEditors(editors);
sqlFileTableViewer.getTable().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
delFileButton.setEnabled(delCanEnable());
}
});
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(55, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
enCodingOptionGroup.setText(Messages.grpEncodingOption);
enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
enCodingOptionGroup.setLayout(new GridLayout(4, false));
Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblDBCharset);
dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
fileCharsetCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
getImportDataWizard().getImportConfig().setFilesCharset(fileCharsetCombo.getText());
}
});
Group importOptionGroup = new Group(rightComposite, SWT.None);
importOptionGroup.setText(Messages.grpImportOptions);
importOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
importOptionGroup.setLayout(new GridLayout(2, false));
Label threadCountLabel = new Label(importOptionGroup, SWT.None);
threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
threadCountLabel.setText(Messages.lblThreadNum);
threadCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
threadCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_THREAD_COUNT);
threadCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_THREAD_COUNT);
threadCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_THREAD_COUNT);
threadCountSpinner.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
Label commitCountLabel = new Label(importOptionGroup, SWT.None);
commitCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
commitCountLabel.setText(Messages.lblCommitCount);
commitCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
commitCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
commitCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_COMMIT_COUNT);
commitCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_COMMIT_COUNT);
commitCountSpinner.setIncrement(ImportConfig.IMPORT_COMMIT_STEP);
commitCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_COMMIT_COUNT);
final Button haModeButton = new Button(rightComposite, SWT.CHECK);
haModeButton.setText(Messages.btnInHaMode);
haModeButton.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
haModeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ImportConfig importConfig = getImportDataWizard().getImportConfig();
importConfig.setHaMode(haModeButton.getSelection());
Collections.sort(fileList, new TableConfigComparator(getImportDataWizard().getImportConfig()));
sqlFileTableViewer.refresh();
}
});
registerContextMenu();
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class TableEditorPart method createGeneralTabItem.
/**
* Create general tab item
*
* @param tabFolder the object of TabFolder
*/
private void createGeneralTabItem(final TabFolder tabFolder) {
final TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE);
generalTabItem.setText(Messages.infoGeneralTab);
final Composite compositeGenaral = new Composite(tabFolder, SWT.NONE);
GridLayout gridLayout = new GridLayout();
compositeGenaral.setLayout(gridLayout);
generalTabItem.setControl(compositeGenaral);
final Group group = new Group(compositeGenaral, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
gridLayout = new GridLayout();
gridLayout.numColumns = 2;
group.setLayout(gridLayout);
group.setText(Messages.lblTableInfo);
final Label tableNameLabel = new Label(group, SWT.NONE);
tableNameLabel.setData(Messages.dataNewKey, null);
tableNameLabel.setText(Messages.lblTableName);
tableNameComp = new Composite(group, SWT.NONE);
{
GridLayout gl = new GridLayout();
gl.numColumns = 5;
gl.marginWidth = 0;
tableNameComp.setLayout(gl);
tableNameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tableNameText = new Text(tableNameComp, SWT.BORDER);
tableNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 200;
tableNameText.setLayoutData(gd);
}
tableNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
if (tableNameText.getText().length() == 0) {
CommonUITool.hideErrorBaloon(errorBaloon);
} else if (verifyTableName()) {
String tableName = tableNameText.getText();
newSchemaInfo.setClassname(tableName);
}
}
});
tableNameText.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
CommonUITool.hideErrorBaloon(errorBaloon);
}
});
final Label ownerLabel = new Label(tableNameComp, SWT.NONE);
ownerLabel.setText(Messages.lblOwner);
ownerCombo = new Combo(tableNameComp, SWT.READ_ONLY);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 100;
ownerCombo.setLayoutData(gd);
}
ownerCombo.setVisibleItemCount(10);
fillOwnerCombo();
if (supportCharset) {
final Label collationLabel = new Label(tableNameComp, SWT.NONE);
collationLabel.setText(Messages.lblCollation);
collationCombo = new Combo(tableNameComp, SWT.READ_ONLY);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 100;
collationCombo.setLayoutData(gd);
}
collationCombo.setVisibleItemCount(10);
fillCollationCombo();
String collation = collationCombo.getText();
newSchemaInfo.setCollation(collation);
collationCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String collation = collationCombo.getText();
newSchemaInfo.setCollation(collation);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
if (!isNewTableFlag && newSchemaInfo.getCollation() != null) {
collationCombo.setText(newSchemaInfo.getCollation());
}
} else {
new Label(tableNameComp, SWT.NONE);
new Label(tableNameComp, SWT.NONE);
}
}
final Label tableDescLabel = new Label(group, SWT.NONE);
tableDescLabel.setText(Messages.lblTableDesc);
tableDescText = new Text(group, SWT.BORDER);
tableDescText.setTextLimit(512);
tableDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (newSchemaInfo != null && newSchemaInfo.getDescription() != null) {
tableDescText.setText(newSchemaInfo.getDescription());
}
tableDescText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
if (!isSupportTableComment) {
CommonUITool.showErrorBaloon(group, tableDescText, errorBaloon, "", Messages.errNotSupportTableCommentNotice);
tableDescText.setFocus();
}
}
public void focusLost(FocusEvent e) {
CommonUITool.hideErrorBaloon(errorBaloon);
}
});
tableDescText.setEditable(isSupportTableComment);
if (database == null) {
return;
}
if (CompatibleUtil.isSupportReuseOID(database.getDatabaseInfo())) {
reuseOIDBtn = new Button(group, SWT.CHECK);
reuseOIDBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
reuseOIDBtn.setText(Messages.btnReuseOid);
if (!isNewTableFlag) {
reuseOIDBtn.setEnabled(false);
}
}
final Label columnsLabel = new Label(compositeGenaral, SWT.NONE);
columnsLabel.setText(Messages.lblColumn);
// create attribute table
columnTableView = new TableViewer(compositeGenaral, SWT.FULL_SELECTION | SWT.BORDER);
columnTableView.setUseHashlookup(true);
columnTableView.setColumnProperties(columnProperites);
columnsTable = columnTableView.getTable();
//columnsTable.pack();
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.heightHint = 189;
columnsTable.setLayoutData(gdColumnsTable);
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
// The empty column
final TableColumn emptyColumn = new TableColumn(columnsTable, SWT.NONE);
emptyColumn.setWidth(0);
// The flag column
final TableColumn flagColumn = new TableColumn(columnsTable, SWT.RIGHT_TO_LEFT);
flagColumn.setWidth(28);
// NAME
final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
nameColumn.setWidth(140);
nameColumn.setText(Messages.tblColumnName);
// DATATYPE
final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
dataTypeColumn.setWidth(120);
dataTypeColumn.setText(Messages.tblColumnDataType);
// DEFAULT
final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
defaultColumn.setWidth(98);
defaultColumn.setText(Messages.tblColumnDefault);
defaultColumn.setToolTipText(Messages.tblColumnDefaultHint);
// AUTO INCREMENT
final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
autoIncrTableColumn.setAlignment(SWT.LEFT);
autoIncrTableColumn.setWidth(100);
autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
autoIncrTableColumn.setToolTipText(Messages.tblColumnAutoIncrHint);
// NOT NULL
final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
notNullColumn.setWidth(65);
notNullColumn.setText(Messages.tblColumnNotNull);
notNullColumn.setAlignment(SWT.LEFT);
notNullColumn.setToolTipText(Messages.tblColumnNotNullHint);
// PK
final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
pkColumn.setAlignment(SWT.CENTER);
pkColumn.setWidth(90);
pkColumn.setText(Messages.tblColumnPK);
// UK
final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
uniqueColumn.setWidth(55);
uniqueColumn.setText(Messages.tblColumnUnique);
uniqueColumn.setAlignment(SWT.LEFT);
uniqueColumn.setToolTipText(Messages.tblColumnUniqueHint);
// SHARED
sharedColumn = new TableColumn(columnsTable, SWT.NONE);
sharedColumn.setWidth(65);
sharedColumn.setText(Messages.tblColumnShared);
sharedColumn.setAlignment(SWT.LEFT);
sharedColumn.setToolTipText(Messages.tblColumnSharedHint);
if (supportCharset) {
final TableColumn collationColumn = new TableColumn(columnsTable, SWT.NONE);
collationColumn.setWidth(120);
collationColumn.setText(Messages.tblColumnColumnCollation);
collationColumn.setAlignment(SWT.LEFT);
}
final TableColumn descColumn = new TableColumn(columnsTable, SWT.NONE);
descColumn.setWidth(180);
descColumn.setText(Messages.tblColumnColumnDesc);
descColumn.setAlignment(SWT.LEFT);
boolean canEdit = true;
if (!editor.isNewTableFlag() && !editor.isSupportChange()) {
canEdit = false;
}
attrContentProvider = new AttributeContentProvider();
attrLabelProvider = new AttributeLabelProvider(database.getDatabaseInfo(), newSchemaInfo, canEdit, editorAdaptor);
columnTableView.setContentProvider(attrContentProvider);
columnTableView.setLabelProvider(attrLabelProvider);
CellEditor[] cellEditor = new CellEditor[columnProperites.length];
{
int index = 0;
// Empty
cellEditor[index++] = null;
// Flag
cellEditor[index++] = null;
// NAME
cellEditor[index++] = new TextCellEditor(columnsTable);
// DATATYPE
cellEditor[index++] = new DataTypeCellEditor((Composite) columnsTable, listDataTypes(), editorAdaptor);
// DEFAULT
cellEditor[index++] = new TextCellEditor(columnsTable);
// AUTO INCREMENT
cellEditor[index++] = new AutoIncrementCellEditor(columnsTable, editorAdaptor);
// NOT NULL
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// PK
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// UK
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// SHARD
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// COLLATION
if (supportCharset) {
cellEditor[index++] = new ComboBoxCellEditor(columnsTable, getCollationArray(), SWT.READ_ONLY);
}
// MEMO
cellEditor[index++] = new TextCellEditor(columnsTable);
}
columnTableView.setCellEditors(cellEditor);
columnTableView.setCellModifier(new AttributeCellModifier(editorAdaptor));
loadColumnData();
CommonUITool.hackForYosemite(columnsTable);
// Create button
final Composite btnRowComposite = new Composite(compositeGenaral, SWT.NONE);
btnRowComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
{
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 5;
btnRowComposite.setLayout(layout);
}
final Composite optComposite = new Composite(btnRowComposite, SWT.NONE);
optComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
{
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 0;
optComposite.setLayout(layout);
}
final Composite btnComposite = new Composite(btnRowComposite, SWT.NONE);
btnComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
{
GridLayout layout = new GridLayout();
layout.marginRight = 0;
layout.numColumns = 6;
layout.marginWidth = 0;
btnComposite.setLayout(layout);
}
final Button setPkButton = new Button(btnComposite, SWT.NONE);
setPkButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
setPkButton.setText(Messages.btnPK);
setPkButton.addSelectionListener(new PkBtnListenerOnGeneTab(isNewTableFlag));
final GridData gdUpDown = new GridData(60, SWT.DEFAULT);
upColumnBtn = new Button(btnComposite, SWT.NONE);
upColumnBtn.setLayoutData(gdUpDown);
upColumnBtn.setEnabled(false);
upColumnBtn.setText(Messages.btnUp);
upColumnBtn.addSelectionListener(new UpBtnListenerOnGeneTab());
downColumnBtn = new Button(btnComposite, SWT.DOWN);
downColumnBtn.setLayoutData(gdUpDown);
downColumnBtn.setEnabled(false);
downColumnBtn.setText(Messages.btnDown);
downColumnBtn.addSelectionListener(new DownBtnListenerOnGeneTab());
final Button addButton = new Button(btnComposite, SWT.NONE);
final GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gdAddButton.horizontalIndent = 10;
addButton.setLayoutData(gdAddButton);
addButton.setText(Messages.btnAddColumn);
addButton.addSelectionListener(new AddBtnListenerOnGeneTab());
deleteColumnBtn = new Button(btnComposite, SWT.NONE);
final GridData gdDeleteButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gdDeleteButton.horizontalIndent = 10;
deleteColumnBtn.setLayoutData(gdDeleteButton);
deleteColumnBtn.setEnabled(false);
deleteColumnBtn.setText(Messages.btnDelColumn);
deleteColumnBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn();
}
});
columnsTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleSelectionChangeInColumnTable();
}
});
buildColumnTableMenu();
}
Aggregations