use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method registerContextMenu.
private void registerContextMenu() {
final ActionManager manager = ActionManager.getInstance();
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
tableListView.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
manager.changeFocusProvider(tableListView.getTable());
}
});
Menu menu = new Menu(shell, SWT.POP_UP);
// SELECT GROUP
final Menu makeSelectQueryMenu = new Menu(menu);
{
MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
subMenuItem.setText(com.cubrid.common.ui.spi.Messages.lblMakeSelectQueryGrp);
subMenuItem.setMenu(makeSelectQueryMenu);
}
// SELECT
initializeAction(makeSelectQueryMenu, getMakeQueryAction(MakeSelectQueryAction.ID));
// Parameterized SELECT
initializeAction(makeSelectQueryMenu, getMakeQueryAction(MakeSelectPstmtQueryAction.ID));
// Parameterized INSERT
initializeAction(menu, getMakeQueryAction(MakeInsertQueryAction.ID));
// Parameterized UPDATE
initializeAction(menu, getMakeQueryAction(MakeUpdateQueryAction.ID));
// Parameterized DELETE
initializeAction(menu, getMakeQueryAction(MakeDeleteQueryAction.ID));
// CREATE
initializeAction(menu, getMakeQueryAction(MakeCreateQueryAction.ID));
new MenuItem(menu, SWT.SEPARATOR);
final TableToJavaCodeAction createJavaCodeAction = (TableToJavaCodeAction) manager.getAction(TableToJavaCodeAction.ID);
if (createJavaCodeAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(createJavaCodeAction.getText());
menuItem.setImage(CommonUITool.getImage(createJavaCodeAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
createJavaCodeAction.run(nodes);
}
}
});
}
final TableToPhpCodeAction createPhpCodeAction = (TableToPhpCodeAction) manager.getAction(TableToPhpCodeAction.ID);
if (createPhpCodeAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(createPhpCodeAction.getText());
menuItem.setImage(CommonUITool.getImage(createPhpCodeAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
createPhpCodeAction.run(nodes);
}
}
});
}
final ExportTableDefinitionAction exportTableDefinitionAction = (ExportTableDefinitionAction) manager.getAction(ExportTableDefinitionAction.ID);
if (exportTableDefinitionAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(exportTableDefinitionAction.getText());
menuItem.setImage(CommonUITool.getImage(exportTableDefinitionAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
exportTableDefinitionAction.run(nodes);
}
}
});
}
new MenuItem(menu, SWT.SEPARATOR);
// View data menu
final Menu viewDataMenu = new Menu(menu);
{
final MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
subMenuItem.setText(com.cubrid.common.ui.spi.Messages.viewDataMenuName);
subMenuItem.setMenu(viewDataMenu);
}
final TableSelectAllAction selectAllAction = (TableSelectAllAction) manager.getAction(TableSelectAllAction.ID);
if (selectAllAction != null) {
MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
menuItem.setText(selectAllAction.getText());
menuItem.setImage(CommonUITool.getImage(selectAllAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
selectAllAction.run((ISchemaNode) node);
}
}
});
}
final SelectByOnePstmtDataAction selectPstmtAction = (SelectByOnePstmtDataAction) manager.getAction(SelectByOnePstmtDataAction.ID);
if (selectPstmtAction != null) {
MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
menuItem.setText(selectPstmtAction.getText());
menuItem.setImage(CommonUITool.getImage(selectPstmtAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
selectPstmtAction.run((ISchemaNode) node);
}
}
});
}
final SelectByMultiPstmtDataAction selectMultiPstmtAction = (SelectByMultiPstmtDataAction) manager.getAction(SelectByMultiPstmtDataAction.ID);
if (selectMultiPstmtAction != null) {
MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
menuItem.setText(selectMultiPstmtAction.getText());
menuItem.setImage(CommonUITool.getImage(selectMultiPstmtAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
selectMultiPstmtAction.run((ISchemaNode) node);
}
}
});
}
new MenuItem(viewDataMenu, SWT.SEPARATOR);
final TableSelectCountAction selectCountAction = (TableSelectCountAction) manager.getAction(TableSelectCountAction.ID);
if (selectCountAction != null) {
MenuItem menuItem = new MenuItem(viewDataMenu, SWT.PUSH);
menuItem.setText(selectCountAction.getText());
menuItem.setImage(CommonUITool.getImage(selectAllAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
selectCountAction.run((ISchemaNode) node);
}
}
});
}
// Input data menu
final Menu inputDataMenu = new Menu(menu);
{
MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
subMenuItem.setText(com.cubrid.common.ui.spi.Messages.inputDataMenuName);
subMenuItem.setMenu(inputDataMenu);
}
final InsertOneByPstmtAction insertStmtAction = (InsertOneByPstmtAction) manager.getAction(InsertOneByPstmtAction.ID);
if (insertStmtAction != null) {
MenuItem menuItem = new MenuItem(inputDataMenu, SWT.PUSH);
menuItem.setText(insertStmtAction.getText());
menuItem.setImage(CommonUITool.getImage(insertStmtAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
insertStmtAction.run((ISchemaNode) node);
}
}
});
}
final ImportDataFromFileAction insertMultiStmtAction = (ImportDataFromFileAction) manager.getAction(ImportDataFromFileAction.ID);
if (insertMultiStmtAction != null) {
MenuItem menuItem = new MenuItem(inputDataMenu, SWT.PUSH);
menuItem.setText(insertMultiStmtAction.getText());
menuItem.setImage(CommonUITool.getImage(insertMultiStmtAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
insertMultiStmtAction.run((ISchemaNode) node);
}
}
});
}
new MenuItem(menu, SWT.SEPARATOR);
// Export & Import
final ExportWizardAction exportWizardAction = (ExportWizardAction) manager.getAction(ExportWizardAction.ID);
if (exportWizardAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(exportWizardAction.getText());
menuItem.setImage(CommonUITool.getImage(exportWizardAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
exportWizardAction.run(nodes);
}
}
});
}
final ImportWizardAction importWizardAction = (ImportWizardAction) manager.getAction(ImportWizardAction.ID);
if (importWizardAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(importWizardAction.getText());
menuItem.setImage(CommonUITool.getImage(importWizardAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
importWizardAction.run(nodes);
}
}
});
}
new MenuItem(menu, SWT.SEPARATOR);
final EditTableAction editTableAction = (EditTableAction) manager.getAction(EditTableAction.ID);
if (editTableAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(editTableAction.getText());
menuItem.setImage(CommonUITool.getImage(editTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
editTableAction.run((ISchemaNode) node);
}
}
});
}
final RenameTableAction renameTableAction = (RenameTableAction) manager.getAction(RenameTableAction.ID);
if (renameTableAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(renameTableAction.getText());
menuItem.setImage(CommonUITool.getImage(renameTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
renameTableAction.run(database, (ISchemaNode) node);
}
}
});
}
new MenuItem(menu, SWT.SEPARATOR);
final Menu manageTableMenu = new Menu(menu);
{
final MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
subMenuItem.setText(com.cubrid.common.ui.spi.Messages.tableMoreName);
subMenuItem.setMenu(manageTableMenu);
}
final DeleteTableAction deleteTableAction = (DeleteTableAction) manager.getAction(DeleteTableAction.ID);
if (deleteTableAction != null) {
MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
menuItem.setText(deleteTableAction.getText());
menuItem.setImage(CommonUITool.getImage(deleteTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
deleteTableAction.run(nodes);
}
}
});
}
final DropTableAction dropTableAction = (DropTableAction) manager.getAction(DropTableAction.ID);
if (dropTableAction != null) {
MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
menuItem.setText(dropTableAction.getText());
menuItem.setImage(CommonUITool.getImage(dropTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode[] nodes = getAllSelectedNodes();
if (nodes != null && nodes.length > 0) {
dropTableAction.run(nodes);
}
}
});
}
if (CompatibleUtil.isSupportCreateTableLike(database.getDatabaseInfo())) {
final CreateLikeTableAction createLikeTableAction = (CreateLikeTableAction) manager.getAction(CreateLikeTableAction.ID);
if (createLikeTableAction != null) {
MenuItem menuItem = new MenuItem(manageTableMenu, SWT.PUSH);
menuItem.setText(createLikeTableAction.getText());
menuItem.setImage(CommonUITool.getImage(createLikeTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ICubridNode node = getFirstSelectedNode();
if (node != null) {
createLikeTableAction.run((ISchemaNode) node);
}
}
});
}
}
new MenuItem(menu, SWT.SEPARATOR);
final NewTableAction newTableAction = (NewTableAction) manager.getAction(NewTableAction.ID);
if (newTableAction != null) {
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(newTableAction.getText());
menuItem.setImage(CommonUITool.getImage(newTableAction.getImageDescriptor()));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
newTableAction.run(database);
}
});
}
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem refreshItem = new MenuItem(menu, SWT.PUSH);
refreshItem.setText(Messages.tablesDetailInfoPartRefreshMenu);
refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
refreshItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
refresh();
}
});
tableListView.getTable().setMenu(menu);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class ImportDataFromFileDialog method handleValue.
/**
*
* Handle value modify event
*
* @param item TableItem
*/
protected void handleValue(final TableItem item) {
String[] items = fileColumnList.toArray(new String[] {});
final int editColumn = 2;
final Combo fileColumnCombo = new Combo(parameterTable, SWT.BORDER | SWT.FULL_SELECTION);
fileColumnCombo.setItems(items);
fileColumnCombo.setVisibleItemCount(20);
final String paraName = item.getText(0);
fileColumnCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
validateFileColumn(paraName, fileColumnCombo.getText());
}
});
fileColumnCombo.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent event) {
if (isChanging) {
return;
}
isChanging = true;
if (validateFileColumn(paraName, fileColumnCombo.getText())) {
item.setText(editColumn, fileColumnCombo.getText());
}
fileColumnCombo.dispose();
isChanging = false;
validate();
}
});
//add listener for key pressed
fileColumnCombo.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent event) {
if (event.detail == SWT.TRAVERSE_RETURN) {
if (isChanging) {
return;
}
isChanging = true;
if (validateFileColumn(paraName, fileColumnCombo.getText())) {
item.setText(editColumn, fileColumnCombo.getText());
}
fileColumnCombo.dispose();
isChanging = false;
validate();
event.doit = true;
handleValue(item);
} else if (event.detail == SWT.TRAVERSE_ESCAPE) {
if (isChanging) {
return;
}
isChanging = true;
fileColumnCombo.dispose();
event.doit = false;
isChanging = false;
}
}
});
tableEditor.setEditor(fileColumnCombo, item, editColumn);
fileColumnCombo.setText(item.getText(editColumn));
fileColumnCombo.setFocus();
}
use of org.eclipse.swt.events.FocusEvent 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.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
Composite toolBarComposite = new Composite(this, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 10;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.numColumns = 2;
toolBarComposite.setLayout(gridLayout);
toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
delHistory.setText(Messages.btn_qedit_sql_history_delete);
delHistory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
return;
}
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
messageBox.setMessage(Messages.sql_history_delete_message);
// remove data ,both view and model
int buttonID = messageBox.open();
if (buttonID == SWT.YES) {
deleteHistory();
}
}
});
// help messages
Label helpMsg = new Label(toolBarComposite, SWT.None);
helpMsg.setText(Messages.recentlyUsedSQLHelp);
helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
// create the query result tab folder
recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
recentlyUsedSQLTabFolder.setSimple(false);
recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
//tabContextMenuManager.createContextMenu();
recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
recentlyUsedSQLTabItem.setControl(this);
recentlyUsedSQLTabItem.setShowClose(false);
final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = SASH_WIDTH;
bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
createHistoryTable(bottomSash);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
bottomSash.setWeights(new int[] { 80, 20 });
logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
logMessageArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
bottomSash.setWeights(new int[] { 80, 20 });
}
public void focusGained(FocusEvent e) {
bottomSash.setWeights(new int[] { 20, 80 });
}
});
CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
tabItem.setText(Messages.qedit_sql_history);
tabItem.setControl(bottomSash);
tabItem.setShowClose(false);
recentlyUsedSQLTabFolder.setSelection(tabItem);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class GeneralInfoPage method createGenericVolumeGroup.
/**
* Create generic volume information group
*
* @param parent the parent composite
*/
private void createGenericVolumeGroup(Composite parent) {
Group genericVolumeGroup = new Group(parent, SWT.NONE);
genericVolumeGroup.setText(Messages.grpGenericVolInfo);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
genericVolumeGroup.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
genericVolumeGroup.setLayoutData(gridData);
Label genericSizeLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
genericSizeLabel.setText(Messages.lblVolSize);
gridData = new GridData();
gridData.widthHint = 150;
genericSizeLabel.setLayoutData(gridData);
genericVolumeSizeText = new Text(genericVolumeGroup, SWT.BORDER);
genericVolumeSizeText.setTextLimit(20);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
genericVolumeSizeText.setLayoutData(gridData);
genericVolumeSizeText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
genericVolumeSizeText.addModifyListener(GeneralInfoPage.this);
}
public void focusLost(FocusEvent event) {
genericVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
}
});
Label genericVolumePathLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
genericVolumePathLabel.setText(Messages.lblGenericVolPath);
gridData = new GridData();
gridData.widthHint = 150;
genericVolumePathLabel.setLayoutData(gridData);
genericVolumePathText = new Text(genericVolumeGroup, SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
genericVolumePathText.setLayoutData(gridData);
Button selectDirectoryButton = new Button(genericVolumeGroup, SWT.NONE);
selectDirectoryButton.setText(Messages.btnBrowse);
selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectDirectoryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
if (databasePath != null && databasePath.trim().length() > 0) {
dlg.setFilterPath(databasePath);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
genericVolumePathText.setText(dir);
}
}
});
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo != null && !serverInfo.isLocalServer()) {
selectDirectoryButton.setEnabled(false);
}
}
Aggregations