use of com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider in project cubrid-manager by CUBRID.
the class EditVirtualTableDialog 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);
createTableInformationGroup(compositeGenaral);
if (database == null) {
return;
}
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();
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(60);
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(75);
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(50);
sharedColumn.setResizable(false);
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);
}
if (erSchema.isPhysicModel()) {
final TableColumn descColumn = new TableColumn(columnsTable, SWT.NONE);
descColumn.setWidth(180);
descColumn.setText(Messages.tblColumnColumnDesc);
descColumn.setAlignment(SWT.LEFT);
}
boolean canEdit = true;
if (!this.isNewTableFlag() && !this.isSupportChange()) {
canEdit = false;
}
attrContentProvider = new AttributeContentProvider();
attrLabelProvider = new ERAttributeLabelProvider(database.getDatabaseInfo(), getNewSchemaInfo(), canEdit, editorAdaptor, erSchema.isPhysicModel());
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++] = erSchema.isPhysicModel() ? new TextCellEditor(columnsTable) : null;
}
columnTableView.setCellEditors(cellEditor);
ERAttributeCellModifier modifier = new ERAttributeCellModifier(editorAdaptor, erSchema.isPhysicModel());
columnTableView.setCellModifier(modifier);
loadColumnData();
// 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();
}
use of com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider in project cubrid-manager by CUBRID.
the class SetPhysicalLogicaMapDialog method createTableComposite.
private void createTableComposite(Composite composite, Group group, PhysicalLogicRelation.MapType type) {
group.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
group.setLayout(layout);
ScrolledComposite scrolledComposite = new ScrolledComposite(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
final TableViewer tableViewer = new TableViewer(scrolledComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
columnDataTableView = tableViewer;
tableViewer.setColumnProperties(columnProperites);
final Table widgetTable = tableViewer.getTable();
scrolledComposite.setContent(widgetTable);
scrolledComposite.setMinSize(widgetTable.computeSize(SWT.DEFAULT, SWT.DEFAULT));
final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
widgetTable.setLayoutData(gdFkTable);
widgetTable.setLinesVisible(true);
widgetTable.setHeaderVisible(true);
//empty column
final TableColumn emptyColumn = new TableColumn(widgetTable, SWT.NONE);
emptyColumn.setWidth(0);
//flag column
final TableColumn flagColumn = new TableColumn(widgetTable, SWT.LEFT_TO_RIGHT);
flagColumn.setWidth(20);
//physical column
TableColumn tblCol = new TableColumn(widgetTable, SWT.NONE);
tblCol.setWidth(120);
tblCol.setText(Messages.tblcolumnPhysical);
//logical column
tblCol = new TableColumn(widgetTable, SWT.NONE);
tblCol.setWidth(120);
tblCol.setText(Messages.tblcolumnLogical);
attrContentProvider = new AttributeContentProvider();
attrLabelProvider = new RelationMapColumnLabelProvider(this);
tableViewer.setContentProvider(attrContentProvider);
tableViewer.setLabelProvider(attrLabelProvider);
CellEditor[] cellEditor = new CellEditor[columnProperites.length];
{
int index = 0;
//Empty
cellEditor[index++] = null;
//Flag
cellEditor[index++] = null;
//Physical
cellEditor[index++] = new TextCellEditor(widgetTable);
//Logical
cellEditor[index++] = new TextCellEditor(widgetTable);
}
tableViewer.setCellEditors(cellEditor);
tableViewer.setCellModifier(new ModelRelationCellModifier(this, type));
loadTableInput(type);
final Button delBtn = new Button(group, SWT.PUSH);
delBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
delBtn.setText(Messages.btnDelItem);
delBtn.setData(type);
delBtn.setEnabled(false);
delBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn(delBtn);
}
});
widgetTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleSelectionChangeInTable(widgetTable, delBtn);
}
});
}
Aggregations