Search in sources :

Example 1 with TableEditorAdaptor

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);
    }
}
Also used : ToolTip(org.eclipse.swt.widgets.ToolTip) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) TabFolder(org.eclipse.swt.widgets.TabFolder) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) TableEditorAdaptor(com.cubrid.common.ui.cubrid.table.TableEditorAdaptor)

Aggregations

TableEditorAdaptor (com.cubrid.common.ui.cubrid.table.TableEditorAdaptor)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 TabFolder (org.eclipse.swt.widgets.TabFolder)1 ToolTip (org.eclipse.swt.widgets.ToolTip)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1