use of org.eclipse.jface.viewers.CellEditor in project cubrid-manager by CUBRID.
the class SettingCubridConfPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingCubridPage);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(3, 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(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(3, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostLabel = new Label(leftComposite, SWT.None);
masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
masterViewer.getTable().setLinesVisible(true);
masterViewer.getTable().setHeaderVisible(true);
masterViewer.setContentProvider(new TableContentProvider());
masterViewer.setLabelProvider(new CubridConfTableProvider());
masterViewer.setColumnProperties(PROPS);
CellEditor[] editorsA = new CellEditor[2];
editorsA[0] = null;
editorsA[1] = new TextCellEditor(masterViewer.getTable());
masterViewer.setCellEditors(editorsA);
masterViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
masterViewer.refresh(model);
updateHAModel(masterViewer, model, false);
}
});
TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
keyAColumn.setText(Messages.lblKey);
keyAColumn.setWidth(160);
TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
valueAColumn.setText(Messages.lblValue);
valueAColumn.setWidth(200);
Label masterDBLabel = new Label(leftComposite, SWT.None);
masterDBLabel.setText(Messages.lblDatabase);
masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
HAModel haModel = getConfigHAWizard().getHaModel();
/*Init table data*/
initTableData(haModel.getMasterServer(), true);
HAServer haServer = haModel.getSlaveServer();
initTableData(haServer, false);
}
});
ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
addItemA.setToolTipText(Messages.itemAddParameter);
addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(masterViewer);
}
});
ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
editItemA.setToolTipText(Messages.itemEditParameter);
editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(masterViewer);
}
});
ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
dropItemA.setToolTipText(Messages.itemDeleteParameter);
dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(masterViewer);
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostLabel = new Label(rightComposite, SWT.None);
slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
slaveViewer.getTable().setLinesVisible(true);
slaveViewer.getTable().setHeaderVisible(true);
slaveViewer.setContentProvider(new TableContentProvider());
slaveViewer.setLabelProvider(new CubridConfTableProvider());
slaveViewer.setColumnProperties(PROPS);
CellEditor[] editorsB = new CellEditor[2];
editorsB[0] = null;
editorsB[1] = new TextCellEditor(slaveViewer.getTable());
slaveViewer.setCellEditors(editorsB);
slaveViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
slaveViewer.refresh(model);
updateHAModel(slaveViewer, model, false);
}
});
TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
keyBColumn.setText(Messages.lblKey);
keyBColumn.setWidth(160);
TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
valueBColumn.setText(Messages.lblValue);
valueBColumn.setWidth(200);
ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 1, -1, -1));
ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
addItemB.setToolTipText(Messages.itemAddParameter);
addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(slaveViewer);
}
});
ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
editItemB.setToolTipText(Messages.itemEditParameter);
editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(slaveViewer);
}
});
ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
dropItemB.setToolTipText(Messages.itemDeleteParameter);
dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(slaveViewer);
}
});
}
use of org.eclipse.jface.viewers.CellEditor 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.CellEditor 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();
}
use of org.eclipse.jface.viewers.CellEditor in project cubrid-manager by CUBRID.
the class ColumnDirectEditPolicy method revertOldEditValue.
@Override
protected void revertOldEditValue(DirectEditRequest request) {
CellEditor cellEditor = request.getCellEditor();
cellEditor.setValue(oldValue);
ColumnPart columnPart = (ColumnPart) getHost();
columnPart.revertNameChange(oldValue);
}
use of org.eclipse.jface.viewers.CellEditor in project cubrid-manager by CUBRID.
the class TableDirectEditPolicy method storeOldEditValue.
@Override
protected void storeOldEditValue(DirectEditRequest request) {
CellEditor cellEditor = request.getCellEditor();
oldValue = (String) cellEditor.getValue();
}
Aggregations