Search in sources :

Example 1 with CreatePartitionWizard

use of com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard in project cubrid-manager by CUBRID.

the class TableEditorPart method createPartitionTabButtons.

/**
	 * Create Partition tab buttons
	 *
	 * @param parent Composite
	 */
private void createPartitionTabButtons(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 5;
        composite.setLayout(gl);
        composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    }
    addPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        addPartitionBtn.setLayoutData(gd);
    }
    addPartitionBtn.setText(Messages.btnAddPartition);
    addPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String tableName = tableNameText.getText();
            if (tableName.trim().length() == 0) {
                CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName);
                return;
            }
            newSchemaInfo.setClassname(tableName);
            Wizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, null);
            CMWizardDialog dialog = new CMWizardDialog(getSite().getShell(), wizard);
            dialog.setPageSize(600, 400);
            if (dialog.open() != IDialogConstants.OK_ID) {
                return;
            }
            partitionTableView.refresh();
            changePartitionTabButtonStatus();
        }
    });
    editPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        editPartitionBtn.setLayoutData(gd);
    }
    editPartitionBtn.setText(Messages.btnEditPartition);
    editPartitionBtn.setEnabled(false);
    editPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editPartition();
        }
    });
    delPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        delPartitionBtn.setLayoutData(gd);
    }
    delPartitionBtn.setText(Messages.btnDelPartition);
    delPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String confirmMsg = Messages.msgDelPartition;
            if (getPartitonType() == PartitionType.HASH) {
                confirmMsg = Messages.msgDelHashPartition;
            }
            boolean deleteConfirm = CommonUITool.openConfirmBox(getSite().getShell(), confirmMsg);
            if (!deleteConfirm) {
                return;
            }
            if (getPartitonType() == PartitionType.HASH) {
                partitionInfoList.clear();
            } else {
                IStructuredSelection selection = (IStructuredSelection) partitionTableView.getSelection();
                if (selection == null || selection.isEmpty()) {
                    return;
                }
                partitionInfoList.removeAll(selection.toList());
                if (getPartitonType() == PartitionType.RANGE) {
                    CreatePartitionWizard.resetRangePartitionInfoList(partitionInfoList);
                }
            }
            partitionTableView.refresh();
            changePartitionTabButtonStatus();
        }
    });
    final Table partitionTable = partitionTableView.getTable();
    partitionTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changePartitionTabButtonStatus();
        }
    });
    changePartitionTabButtonStatus();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Wizard(org.eclipse.jface.wizard.Wizard) CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 2 with CreatePartitionWizard

use of com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard in project cubrid-manager by CUBRID.

the class TableEditorPart method editPartition.

/**
	 * Show the edit dialog for selected partition.
	 */
private void editPartition() {
    if (WidgetUtil.disposed(partitionTableView)) {
        return;
    }
    PartitionInfo partitionInfo = null;
    if (getPartitonType() == PartitionType.HASH) {
        partitionInfo = partitionInfoList.get(0);
    } else {
        IStructuredSelection selection = (IStructuredSelection) partitionTableView.getSelection();
        if (selection == null || selection.isEmpty()) {
            return;
        }
        partitionInfo = (PartitionInfo) selection.getFirstElement();
    }
    String tableName = tableNameText.getText();
    if (WidgetUtil.disposed(tableNameText) || StringUtil.isEmpty(tableName)) {
        CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName);
        return;
    }
    newSchemaInfo.setClassname(tableName);
    CreatePartitionWizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, partitionInfo);
    CMWizardDialog dialog = new CMWizardDialog(getSite().getShell(), wizard);
    dialog.setPageSize(600, 400);
    if (dialog.open() != IDialogConstants.OK_ID) {
        return;
    }
    newSchemaInfo.setPartitionList(partitionInfoList);
    partitionTableView.refresh();
    changePartitionTabButtonStatus();
}
Also used : CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Aggregations

CreatePartitionWizard (com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard)2 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 PartitionInfo (com.cubrid.common.core.common.model.PartitionInfo)1 Wizard (org.eclipse.jface.wizard.Wizard)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 Table (org.eclipse.swt.widgets.Table)1