use of com.cubrid.common.ui.cubrid.table.TableEditorAdaptor in project cubrid-manager by CUBRID.
the class TableEditorPart method createPartControl.
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
{
final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 500;
gd.widthHint = 800;
composite.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 1;
composite.setLayout(gl);
}
tabFolder = new TabFolder(composite, SWT.NONE);
{
final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 469;
gd.widthHint = 621;
tabFolder.setLayoutData(gd);
}
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
TabItem[] tabItems = tabFolder.getSelection();
if (tabItems == null || tabItems.length == 0 || tabItems[0] == null) {
return;
}
String tabTitle = tabItems[0].getText();
if (!StringUtil.isEqual(tabTitle, Messages.infoSQLScriptTab)) {
return;
}
String tableName = tableNameText.getText();
newSchemaInfo.setClassname(tableName);
String owner = ownerCombo.getText();
newSchemaInfo.setOwner(owner);
if (reuseOIDBtn != null) {
newSchemaInfo.setReuseOid(reuseOIDBtn.getSelection());
}
StringBuilder sql = new StringBuilder();
if (oldSchemaInfo != null) {
sql.append(schemaDDL.getSchemaDDL(oldSchemaInfo));
for (int i = 0; i < 3; i++) {
sql.append(StringUtil.NEWLINE);
}
}
String alterSql = schemaDDL.getSchemaDDL(oldSchemaInfo, newSchemaInfo);
if (alterSql != null) {
sql.append(alterSql);
}
sql.append(getChangeOwnerDDL());
sqlText.setText(sql.toString());
}
});
editorAdaptor = new TableEditorAdaptor(this);
createGeneralTabItem(tabFolder);
createFkIndexTabItem(tabFolder);
createPartitionTabItem(tabFolder);
createSqlScriptTabItem(tabFolder);
toolTip = new ToolTip(columnsTable.getShell(), SWT.NONE);
toolTip.setAutoHide(true);
errorBaloon = new ToolTip(tabFolder.getShell(), SWT.NONE);
errorBaloon.setAutoHide(true);
init();
if (isNewTableFlag) {
tableNameText.setFocus();
}
Composite btnComposite = new Composite(composite, SWT.NONE);
{
GridLayout gl = new GridLayout();
gl.numColumns = 2;
btnComposite.setLayout(gl);
btnComposite.setLayoutData(new GridData(SWT.END, SWT.FILL, true, false));
}
okBtn = new Button(btnComposite, SWT.NONE);
{
GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
gd.minimumWidth = 80;
gd.widthHint = 80;
okBtn.setLayoutData(gd);
}
okBtn.setText(Messages.btnOK);
okBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
okPressed();
}
});
Button cancelBtn = new Button(btnComposite, SWT.NONE);
{
GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
gd.minimumWidth = 80;
gd.widthHint = 80;
cancelBtn.setLayoutData(gd);
}
cancelBtn.setText(Messages.btnCancel);
cancelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
if (!CommonUITool.openConfirmBox(Messages.msgCancelEditTableConfirm)) {
return;
}
IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
if (page != null) {
page.closeEditor(editor, false);
}
}
});
addNewColumn();
if (showDefaultType == EditTableAction.MODE_INDEX_EDIT) {
tabFolder.setSelection(1);
}
}
Aggregations