Search in sources :

Example 46 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class DBAuthComparator method createAuthTable.

private void createAuthTable(Composite parent) {
    authTableViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    authTableViewer.getTable().setHeaderVisible(true);
    authTableViewer.getTable().setLinesVisible(true);
    final TableViewerColumn tableColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    tableColumn.getColumn().setWidth(120);
    tableColumn.getColumn().setText(Messages.tblColAuthTable);
    final TableViewerColumn ownerColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    ownerColumn.getColumn().setWidth(70);
    ownerColumn.getColumn().setText(Messages.lblOWner);
    final TableViewerColumn authSelectColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authSelectColumn.getColumn().setWidth(70);
    authSelectColumn.getColumn().setText(Messages.tblColAuthSelect);
    final TableViewerColumn authInsertColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authInsertColumn.getColumn().setWidth(70);
    authInsertColumn.getColumn().setText(Messages.tblColAuthInsert);
    final TableViewerColumn authUpdateColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authUpdateColumn.getColumn().setWidth(70);
    authUpdateColumn.getColumn().setText(Messages.tblColAuthUpdate);
    final TableViewerColumn authDeleteColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authDeleteColumn.getColumn().setWidth(70);
    authDeleteColumn.getColumn().setText(Messages.tblColAuthDelete);
    final TableViewerColumn authAlterColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authAlterColumn.getColumn().setWidth(70);
    authAlterColumn.getColumn().setText(Messages.tblColAuthAlter);
    final TableViewerColumn authIndexColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authIndexColumn.getColumn().setWidth(70);
    authIndexColumn.getColumn().setText(Messages.tblColAuthIndex);
    final TableViewerColumn authExecuteColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authExecuteColumn.getColumn().setWidth(70);
    authExecuteColumn.getColumn().setText(Messages.tblColAuthExecute);
    final TableViewerColumn authGrantSelectColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantSelectColumn.getColumn().setWidth(90);
    authGrantSelectColumn.getColumn().setText(Messages.tblColAuthGrantselect);
    final TableViewerColumn authGrantInsertColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantInsertColumn.getColumn().setWidth(90);
    authGrantInsertColumn.getColumn().setText(Messages.tblColAuthGrantinsert);
    final TableViewerColumn authGrantUpdateColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantUpdateColumn.getColumn().setWidth(90);
    authGrantUpdateColumn.getColumn().setText(Messages.tblColAuthGrantupdate);
    final TableViewerColumn authGrantDeleteColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantDeleteColumn.getColumn().setWidth(90);
    authGrantDeleteColumn.getColumn().setText(Messages.tblColAuthGrantdelete);
    final TableViewerColumn authGrantAlterColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantAlterColumn.getColumn().setWidth(90);
    authGrantAlterColumn.getColumn().setText(Messages.tblColAuthGrantalter);
    final TableViewerColumn authGrantIndexColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantIndexColumn.getColumn().setWidth(90);
    authGrantIndexColumn.getColumn().setText(Messages.tblColAuthGrantindex);
    final TableViewerColumn authGrantExecuteColumn = new TableViewerColumn(authTableViewer, SWT.LEFT);
    authGrantExecuteColumn.getColumn().setWidth(90);
    authGrantExecuteColumn.getColumn().setText(Messages.tblColAuthGrantexecute);
    authTableViewer.setLabelProvider(new AuthLabelProvider());
    authTableViewer.setContentProvider(new AuthContentProvider());
}
Also used : TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 47 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class ExportDataViewPart method createPartControl.

/**
	 * Create part controls
	 * 
	 * @param parent of the controls
	 * 
	 */
public void createPartControl(Composite parent) {
    Composite backPanel = new Composite(parent, SWT.NONE);
    backPanel.setLayout(new GridLayout(1, false));
    backPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Composite progressPanel = new Composite(backPanel, SWT.NONE);
    progressPanel.setLayout(new GridLayout(2, false));
    progressPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    progressIndicator = new ProgressIndicator(progressPanel, SWT.NONE);
    progressIndicator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    btnStop = new Button(progressPanel, SWT.NONE);
    btnStop.setText(com.cubrid.common.ui.common.Messages.btnStop);
    btnStop.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_stop.png"));
    btnStop.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            processStop();
        }
    });
    tvProgress = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
    tvProgress.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    tvProgress.getTable().setLinesVisible(true);
    tvProgress.getTable().setHeaderVisible(true);
    final TableViewerColumn tableName = new TableViewerColumn(tvProgress, SWT.NONE);
    final TableViewerColumn totalCount = new TableViewerColumn(tvProgress, SWT.NONE);
    final TableViewerColumn parseCount = new TableViewerColumn(tvProgress, SWT.NONE);
    final TableViewerColumn status = new TableViewerColumn(tvProgress, SWT.NONE);
    final TableViewerColumn elapsedTime = new TableViewerColumn(tvProgress, SWT.NONE);
    tableName.getColumn().setWidth(250);
    tableName.getColumn().setText(Messages.exportMonitorPartColumnFileName);
    totalCount.getColumn().setWidth(100);
    totalCount.getColumn().setText(Messages.exportMonitorPartColumnTotalcount);
    parseCount.getColumn().setWidth(100);
    parseCount.getColumn().setText(Messages.exportMonitorPartColumnParsecount);
    status.getColumn().setWidth(100);
    status.getColumn().setText(com.cubrid.common.ui.common.Messages.columnStatus);
    elapsedTime.getColumn().setWidth(130);
    elapsedTime.getColumn().setText(com.cubrid.common.ui.common.Messages.columnElapsedTime);
    tvProgress.setContentProvider(new TableContentProvider());
    tvProgress.setLabelProvider(new TableLabelProvider());
    Composite historyComposite = new Composite(backPanel, SWT.NONE);
    historyComposite.setLayout(new GridLayout(4, false));
    historyComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    historyLabel = new Label(historyComposite, SWT.NONE);
    historyLabel.setText(Messages.exportMonitorPartSaveLabel);
    historyText = new Text(historyComposite, SWT.BORDER);
    historyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    saveButton = new Button(historyComposite, SWT.NONE);
    saveButton.setText(Messages.exportMonitorPartSaveButton);
    saveButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (StringUtil.isEmpty(historyText.getText())) {
                CommonUITool.openErrorBox(Messages.exportMonitorPartSaveErrMsg1);
                return;
            }
            if (ExportConfigManager.getInstance().getConfig(historyText.getText()) != null) {
                CommonUITool.openErrorBox(Messages.exportMonitorPartSaveErrMsg2);
                return;
            }
            exportConfig.setName(historyText.getText().trim());
            ExportConfigManager.getInstance().addConfig(exportConfig);
            close();
        }
    });
    closeButton = new Button(historyComposite, SWT.NONE);
    closeButton.setText(Messages.closeButtonName);
    closeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            close();
        }
    });
    setHistroyWidgetStatus(false);
    init();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ProgressIndicator(org.eclipse.jface.dialogs.ProgressIndicator) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 48 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method createFkIndexTabItem.

/**
	 * Create foreign key/Index tab item.
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createFkIndexTabItem(final TabFolder tabFolder) {
    final TabItem foreignKeyTabItem = new TabItem(tabFolder, SWT.NONE);
    foreignKeyTabItem.setText(Messages.infoIndexesTab);
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    composite.setLayout(gridLayout);
    foreignKeyTabItem.setControl(composite);
    // create the fk table viewer
    final Label fkLabel = new Label(composite, SWT.NONE);
    fkLabel.setText(Messages.lblFK);
    fkTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    fkTable = fkTableView.getTable();
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    fkTable.setLayoutData(gdFkTable);
    fkTable.setLinesVisible(true);
    fkTable.setHeaderVisible(true);
    TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnFK);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(119);
    tblCol.setText(Messages.tblColumnColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(93);
    tblCol.setText(Messages.tblColumnForeignTable);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(143);
    tblCol.setText(Messages.tblColumnForeignColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(84);
    tblCol.setText(Messages.tblColumnUpdateRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(86);
    tblCol.setText(Messages.tblColumnDeleteRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnCacheColumn);
    FKTableViewerContentProvider fkContentProvider = new FKTableViewerContentProvider();
    FKTableViewerLabelProvider fkLabelProvider = new FKTableViewerLabelProvider(database.getDatabaseInfo(), erSchema);
    fkTableView.setContentProvider(fkContentProvider);
    fkTableView.setLabelProvider(fkLabelProvider);
    fkTableView.setInput(getNewSchemaInfo());
    final Composite fkBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    fkBtnComposite.setLayoutData(gdBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    fkBtnComposite.setLayout(gridLayout);
    final GridData gdFKBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addFKBTN = new Button(fkBtnComposite, SWT.NONE);
    addFKBTN.setLayoutData(gdFKBTN);
    addFKBTN.setText(Messages.btnAddFk);
    addFKBTN.addSelectionListener(new AddFkBtnListenerOnFkIndexTab());
    final Button editFKBTN = new Button(fkBtnComposite, SWT.NONE);
    editFKBTN.setLayoutData(gdFKBTN);
    editFKBTN.setEnabled(false);
    editFKBTN.setText(Messages.btnEditFk);
    editFKBTN.addSelectionListener(new EditFkBtnListenerOnFkIndexTab());
    final Button deleteFKBTN = new Button(fkBtnComposite, SWT.NONE);
    deleteFKBTN.setLayoutData(gdFKBTN);
    deleteFKBTN.setEnabled(false);
    deleteFKBTN.setText(Messages.btnDelFk);
    deleteFKBTN.addSelectionListener(new DelFkBtnListenerOnFkIndexTab());
    fkTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            SchemaInfo newSchemaInfo = getNewSchemaInfo();
            if (database == null || database.getDatabaseInfo() == null || newSchemaInfo == null) {
                return;
            }
            TableItem[] items = fkTable.getSelection();
            if (items == null || items.length == 0) {
                deleteFKBTN.setEnabled(false);
                editFKBTN.setEnabled(false);
            } else {
                deleteFKBTN.setEnabled(true);
                editFKBTN.setEnabled(items.length == 1);
                for (TableItem item : items) {
                    String fkName = item.getText(0);
                    List<SchemaInfo> superList = SuperClassUtil.getSuperClasses(database.getDatabaseInfo(), newSchemaInfo.getSuperClasses());
                    if (newSchemaInfo.isInSuperClasses(superList, fkName)) {
                        deleteFKBTN.setEnabled(false);
                        editFKBTN.setEnabled(false);
                    }
                }
            }
        }
    });
    // create index table view
    final Label indexLabel = new Label(composite, SWT.NONE);
    indexLabel.setText(Messages.lblIndexes);
    indexTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    indexTable = indexTableView.getTable();
    indexTable.setLinesVisible(true);
    indexTable.setHeaderVisible(true);
    final GridData gdIndexTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    indexTable.setLayoutData(gdIndexTable);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(150);
    tblCol.setText(Messages.tblColumnIndexName);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(78);
    tblCol.setText(Messages.tblColumnIndexType);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(218);
    tblCol.setText(Messages.tblColumnOnColumns);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(282);
    tblCol.setText(Messages.tblColumnIndexRule);
    IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
    IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
    indexTableView.setContentProvider(indexContentProvider);
    indexTableView.setLabelProvider(indexLabelProvider);
    indexTableView.setInput(getNewSchemaInfo());
    indexTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection selected = (StructuredSelection) event.getSelection();
            if (selected == null) {
                return;
            }
            Constraint constraint = (Constraint) selected.getFirstElement();
            openEditIndexDialog(constraint);
        }
    });
    final Composite indexBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdIndexBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    indexBtnComposite.setLayoutData(gdIndexBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    indexBtnComposite.setLayout(gridLayout);
    final GridData gdIndexBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    addIndexBTN.setLayoutData(gdIndexBTN);
    addIndexBTN.setText(Messages.btnAddIndex);
    addIndexBTN.addSelectionListener(new AddIndexBtnListenerOnFkIndexTab());
    final Button editIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    editIndexBTN.setLayoutData(gdIndexBTN);
    editIndexBTN.setEnabled(false);
    editIndexBTN.setText(Messages.btnEditIndex);
    editIndexBTN.addSelectionListener(new EditIndexBtnListenerOnFkIndexTab());
    final Button deleteIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    deleteIndexBTN.setLayoutData(gdIndexBTN);
    deleteIndexBTN.setEnabled(false);
    deleteIndexBTN.setText(Messages.btnDelIndex);
    deleteIndexBTN.addSelectionListener(new DelIndexBtnListenerOnFkIndexTab());
    indexTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem[] items = indexTable.getSelection();
            if (items == null || items.length == 0) {
                deleteIndexBTN.setEnabled(false);
                editIndexBTN.setEnabled(false);
            } else {
                deleteIndexBTN.setEnabled(true);
                editIndexBTN.setEnabled(items.length == 1);
            }
        }
    });
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) FKTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IndexTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerContentProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) IndexTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) FKTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 49 with TableViewer

use of org.eclipse.jface.viewers.TableViewer 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();
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) ERAttributeLabelProvider(com.cubrid.common.ui.er.editor.ERAttributeLabelProvider) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) DataTypeCellEditor(com.cubrid.common.ui.cubrid.table.editor.DataTypeCellEditor) AutoIncrementCellEditor(com.cubrid.common.ui.cubrid.table.editor.AutoIncrementCellEditor) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AttributeContentProvider(com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider) AutoIncrementCellEditor(com.cubrid.common.ui.cubrid.table.editor.AutoIncrementCellEditor) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) ERAttributeCellModifier(com.cubrid.common.ui.er.editor.ERAttributeCellModifier) TableColumn(org.eclipse.swt.widgets.TableColumn) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TabItem(org.eclipse.swt.widgets.TabItem) GridData(org.eclipse.swt.layout.GridData) DataTypeCellEditor(com.cubrid.common.ui.cubrid.table.editor.DataTypeCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 50 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class SetPhysicalLogicaMapDialog method deleteColumn.

private void deleteColumn(Button delBtn) {
    if (!CommonUITool.openConfirmBox(com.cubrid.common.ui.cubrid.table.Messages.msgDeleteColumnConfirm)) {
        return;
    }
    PhysicalLogicRelation.MapType type = (PhysicalLogicRelation.MapType) delBtn.getData();
    TableViewer tableViewer = getCurrentTableView(type);
    TableItem[] tblItems = tableViewer.getTable().getSelection();
    if (tblItems == null || tblItems.length == 0) {
        return;
    }
    for (int i = 0; i < tblItems.length; i++) {
        String key = tblItems[i].getText(2);
        Map<String, String> mapData = getMapData(type);
        mapData.remove(key);
    }
    loadTableInput(type);
    handleSelectionChangeInTable(tableViewer.getTable(), delBtn);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) PhysicalLogicRelation(com.cubrid.common.ui.er.logic.PhysicalLogicRelation) MapType(com.cubrid.common.ui.er.logic.PhysicalLogicRelation.MapType) TableViewer(org.eclipse.jface.viewers.TableViewer) MapType(com.cubrid.common.ui.er.logic.PhysicalLogicRelation.MapType)

Aggregations

TableViewer (org.eclipse.jface.viewers.TableViewer)273 GridData (org.eclipse.swt.layout.GridData)161 Composite (org.eclipse.swt.widgets.Composite)152 Table (org.eclipse.swt.widgets.Table)128 GridLayout (org.eclipse.swt.layout.GridLayout)111 SelectionEvent (org.eclipse.swt.events.SelectionEvent)105 TableColumn (org.eclipse.swt.widgets.TableColumn)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)79 Label (org.eclipse.swt.widgets.Label)72 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)70 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)61 Button (org.eclipse.swt.widgets.Button)61 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)60 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)56 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)52 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)37 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)37 ArrayList (java.util.ArrayList)28 Point (org.eclipse.swt.graphics.Point)26 Event (org.eclipse.swt.widgets.Event)26