use of org.eclipse.jface.viewers.CheckboxCellEditor in project cubrid-manager by CUBRID.
the class DataCompareEditorPart method createContent.
private void createContent(Composite parent) {
compareTableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
compareTableViewer.setUseHashlookup(true);
compareTableViewer.setColumnProperties(columnNames);
CommonUITool.createGridLayout(compareTableViewer.getTable(), 1, 0, 10, 0, 10, 0, 0, 0, 0);
compareTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
compareTableViewer.getTable().setLinesVisible(true);
compareTableViewer.getTable().setHeaderVisible(true);
sorter = new DataCompareSchemaListViewSorter();
sorter.setSortType(DataCompareSchemaListViewSorter.SORT_TABLE);
compareTableViewer.setSorter(sorter);
makeContextMenu(compareTableViewer);
final TableViewerColumn firstCol = new TableViewerColumn(compareTableViewer, SWT.NONE);
firstCol.getColumn().setWidth(30);
firstCol.getColumn().setResizable(false);
firstCol.getColumn().setAlignment(SWT.CENTER);
firstCol.getColumn().setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
firstCol.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = compareTableViewer.getTable().getItems();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(isSelectAll);
}
compareTableViewer.refresh();
Image image = null;
if (isSelectAll) {
image = CommonUIPlugin.getImage("icons/checked.gif");
} else {
image = CommonUIPlugin.getImage("icons/unchecked.gif");
}
firstCol.getColumn().setImage(image);
isSelectAll = !isSelectAll;
}
});
TableViewerColumn col = new TableViewerColumn(compareTableViewer, SWT.NONE);
col.getColumn().setWidth(200);
col.getColumn().setText(Messages.lblDataCompareTable);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TABLE);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordSource);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_SOURCE_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordTarget);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TARGET_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordProgress);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_PROGRESS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNoMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNotExist);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_EXISTS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(300);
col.getColumn().setText(Messages.lblDataCompareRecordError);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_ERROR);
CellEditor[] cellEditor = new CellEditor[1];
cellEditor[0] = new CheckboxCellEditor(compareTableViewer.getTable());
compareTableViewer.setCellEditors(cellEditor);
compareTableViewer.setCellModifier(new DataCompareCellModifier(this));
compareTableViewer.setContentProvider(new DataCompareSchemaListContentProvider());
compareTableViewer.setLabelProvider(new DataCompareSchemaListLabelProvider());
compareList = new ArrayList<DataCompare>();
compareTableViewer.setInput(compareList);
txtProgress = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
txtProgress.setEditable(false);
txtProgress.setWordWrap(true);
txtProgress.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 100));
txtProgress.setBackground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_BLACK));
txtProgress.setForeground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_GREEN));
compareTableViewer.getTable().setToolTipText(Messages.msgYouCanSeeDetailDblclick);
compareTableViewer.getTable().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.character == ' ') {
TableItem[] items = compareTableViewer.getTable().getSelection();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(!dataCompare.isUse());
}
compareTableViewer.refresh();
}
}
});
compareTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
if (!refreshedRecordCounts) {
CommonUITool.openWarningBox(Messages.msgClickRefreshToEsimateDiff);
return;
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
DataCompare model = (DataCompare) selection.getFirstElement();
if (!model.isSameSchema()) {
CommonUITool.openWarningBox(Messages.msgTheSchemaDiff);
return;
}
if (model.getRecordsTarget() == -1) {
CommonUITool.openWarningBox(Messages.msgTargetNotFound);
return;
}
if (model.getRecordsSource() == 0 && model.getRecordsTarget() > 0) {
CommonUITool.openWarningBox(Messages.msgTargetNoData);
return;
}
if (model.getRecordsSource() == 0) {
CommonUITool.openWarningBox(Messages.msgNoDataToCompare);
return;
}
if (model.getProgressPosition() == 0) {
CommonUITool.openWarningBox(Messages.msgNotYetCompared);
return;
}
if (model.getNotMatches() == 0 && model.getNotExists() == 0) {
CommonUITool.openWarningBox(Messages.msgSameData);
return;
}
showDataCompareDetailEditor(model.getSchemaInfo());
}
});
}
use of org.eclipse.jface.viewers.CheckboxCellEditor in project cubrid-manager by CUBRID.
the class EditUserDialog method createAuthComposite.
/**
* Create auth composite
*
* @return the composite
*/
private Composite createAuthComposite() {
final Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
composite.setLayout(layout);
Label classTableDescLabel = new Label(composite, SWT.NONE);
classTableDescLabel.setText(Messages.lblUnAuthorizedTable);
final String[] columnNameArr = new String[] { Messages.tblColClassName, Messages.tblColClassSchematype, Messages.tblColClassOwner, Messages.tblColClassType };
classTableViewer = CommonUITool.createCommonTableViewer(composite, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
classTableViewer.setInput(classListData);
classTable = classTableViewer.getTable();
classTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setAuthBtnEnableDisable();
}
});
final Composite cmpControl = new Composite(composite, SWT.NONE);
final GridData gdCmpControl = new GridData(SWT.CENTER, SWT.FILL, false, false);
cmpControl.setLayoutData(gdCmpControl);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
cmpControl.setLayout(gridLayout);
grantButton = new Button(cmpControl, SWT.LEFT);
grantButton.setEnabled(false);
grantButton.setText(Messages.addClassButtonName);
grantButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
int[] idx = classTable.getSelectionIndices();
if (idx.length < 0) {
return;
}
for (int i : idx) {
String className = classTable.getItem(i).getText(0);
for (Map<String, String> map : classListData) {
if (map.get("0").equals(className)) {
classListData.remove(map);
break;
}
}
ClassAuthorizations classAuthorizations = classGrantMap.get(className);
if (classAuthorizations == null) {
classAuthorizations = new ClassAuthorizations();
classAuthorizations.setClassName(className);
classAuthorizations.setSelectPriv(true);
}
authListData.add(getItemAuthMap(classAuthorizations));
}
classTableViewer.refresh();
authTableViewer.refresh();
if (authTableViewer.getTable().getColumn(0) != null) {
authTableViewer.getTable().getColumn(0).pack();
}
setAuthBtnEnableDisable();
}
});
revokeButton = new Button(cmpControl, SWT.NONE);
revokeButton.setEnabled(false);
revokeButton.setText(Messages.deleteClassButtonName);
revokeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
int[] idx = authTable.getSelectionIndices();
if (idx.length < 0) {
return;
}
for (int id : idx) {
String tableName = authTable.getItem(id).getText(0);
for (ClassInfo bean : allClassInfoList) {
if (tableName.equals(bean.getClassName())) {
if (bean.isSystemClass()) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errRemoveSysClass);
return;
} else {
Map<String, String> map = new HashMap<String, String>();
map.put("0", bean.getClassName());
map.put("1", bean.isSystemClass() ? Messages.msgSystemSchema : Messages.msgUserSchema);
map.put("2", bean.getOwnerName());
map.put("3", bean.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass);
classListData.add(map);
}
}
}
for (Map<String, Object> map : authListData) {
String className = (String) map.get("0");
if (tableName.equals(className)) {
authListData.remove(map);
break;
}
}
}
authTableViewer.refresh();
classTableViewer.refresh();
setAuthBtnEnableDisable();
}
});
Label authTableDescLabel = new Label(composite, SWT.NONE);
authTableDescLabel.setText(Messages.lblAuthorizedTable);
final String[] authColumnNameArr = new String[] { Messages.tblColAuthTable, Messages.tblColAuthSelect, Messages.tblColAuthInsert, Messages.tblColAuthUpdate, Messages.tblColAuthDelete, Messages.tblColAuthAlter, Messages.tblColAuthIndex, Messages.tblColAuthExecute, Messages.tblColAuthGrantselect, Messages.tblColAuthGrantinsert, Messages.tblColAuthGrantupdate, Messages.tblColAuthGrantdelete, Messages.tblColAuthGrantalter, Messages.tblColAuthGrantindex, Messages.tblColAuthGrantexecute };
authTableViewer = createCommonTableViewer(composite, authColumnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
authTableViewer.setLabelProvider(new AuthTableLabelProvider());
authTableViewer.setInput(authListData);
authTable = authTableViewer.getTable();
CellEditor[] editors = new CellEditor[15];
editors[0] = null;
for (int i = 1; i < 15; i++) {
editors[i] = new CheckboxCellEditor(authTable, SWT.READ_ONLY);
}
authTableViewer.setColumnProperties(authColumnNameArr);
authTableViewer.setCellEditors(editors);
authTableViewer.setCellModifier(new ICellModifier() {
@SuppressWarnings("unchecked")
public boolean canModify(Object element, String property) {
Map<String, Object> map = (Map<String, Object>) element;
boolean isDbaAuthority = database.getDatabaseInfo().getAuthLoginedDbUserInfo().isDbaAuthority();
if (isDbaAuthority) {
return true;
}
/*Can't grant/revoke for current login user*/
if (StringUtil.isEqual(userName, currentUserInfo.getName())) {
return false;
}
String name = (String) map.get("0");
for (ClassInfo bean : allClassInfoList) {
if (name.equals(bean.getClassName())) {
if (bean.isSystemClass()) {
return false;
} else if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) {
return true;
}
}
}
ClassAuthorizations authorizations = currentUserAuthorizations.get(name);
if (authorizations == null || authorizations.isAllPriv() || authorizations.isPriv(property)) {
return true;
} else {
return false;
}
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, Object> map = (Map<String, Object>) element;
for (int i = 1; i < 15; i++) {
if (property.equals(authColumnNameArr[i])) {
return Boolean.valueOf((Boolean) map.get("" + i));
}
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object elementData;
elementData = element;
if (element instanceof Item) {
elementData = ((Item) element).getData();
}
String key = "";
Map<String, Object> map = (Map<String, Object>) elementData;
for (int i = 1; i < 15; i++) {
if (property.equals(authColumnNameArr[i])) {
key = "" + i;
break;
}
}
if (value instanceof Boolean) {
map.put(key, ((Boolean) value).booleanValue());
}
authTableViewer.refresh();
}
});
authTable.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
}
public void widgetSelected(SelectionEvent event) {
setAuthBtnEnableDisable();
}
});
authTable.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
setAuthBtnEnableDisable();
}
});
return composite;
}
use of org.eclipse.jface.viewers.CheckboxCellEditor 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 org.eclipse.jface.viewers.CheckboxCellEditor in project cubrid-manager by CUBRID.
the class SqlmapNavigatorView method createCondView.
/**
* Create the main view.
*
* @param parent {@link Composite} the parent composite
*/
private void createCondView(Composite parent) {
String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
Label lblCondTitle = new Label(parent, SWT.NONE);
lblCondTitle.setText(Messages.lblSqlmapConditions);
condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
condView.setColumnProperties(columnNames);
condView.setContentProvider(new TableContentProvider());
condView.setLabelProvider(new SqlmapLabelProvider(this));
condView.setCellModifier(new SqlmapCellModifier(this));
CellEditor[] cellEditor = new CellEditor[columnNames.length];
cellEditor[0] = new CheckboxCellEditor(condView.getTable());
condView.setCellEditors(cellEditor);
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnPixelData(30));
tableLayout.addColumnData(new ColumnPixelData(160));
condView.getTable().setLayout(tableLayout);
condView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == ' ') {
toggleUsedBySelectedCondition();
}
super.keyPressed(e);
}
});
}
use of org.eclipse.jface.viewers.CheckboxCellEditor 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