Search in sources :

Example 86 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class PstmtDataDialog method initial.

protected void initial() {
    int n = schemaInfo == null ? 0 : schemaInfo.getAttributes().size();
    for (int i = 0; i < n; i++) {
        DBAttribute da = (DBAttribute) schemaInfo.getAttributes().get(i);
        TableItem item = new TableItem(parameterTable, SWT.NONE);
        item.setText(0, da.getName());
        item.setText(1, DataType.getShownType(da.getType()));
    }
    packTable();
    String sql = "";
    if (tableName != null && isInsert) {
        sql = createInsertPstmtSQL();
    } else if (tableName != null) {
        sql = createSelectPstmtSQL();
    }
    sqlTxt.setText(sql);
}
Also used : DBAttribute(com.cubrid.common.core.common.model.DBAttribute) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point)

Example 87 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class DBAuthComparator method dropUser.

/**
	 * drop User
	 */
public void dropUser() {
    TableItem[] items = userTableViewer.getTable().getSelection();
    if (items.length == 1) {
        TableItem item = items[0];
        UserDetailInfo userInfo = (UserDetailInfo) item.getData();
        String msg = Messages.bind(Messages.msgDoYouWantToDeleteUser, userInfo.getUserName());
        if (!CommonUITool.openConfirmBox(msg)) {
            return;
        }
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.USER);
        ICubridNode userNode = CommonUITool.findNode(database, typeSet, userInfo.getUserName());
        if (userNode != null) {
            DeleteUserAction action = (DeleteUserAction) ActionManager.getInstance().getAction(DeleteUserAction.ID);
            action.doRun((ISchemaNode) userNode);
            refresh();
        }
    } else {
        CommonUITool.openWarningBox(Messages.errNoUserSelected);
    }
}
Also used : DeleteUserAction(com.cubrid.common.ui.cubrid.user.action.DeleteUserAction) TableItem(org.eclipse.swt.widgets.TableItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) UserDetailInfo(com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo) HashSet(java.util.HashSet)

Example 88 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class TriggerDashboardEditorPart method editTrigger.

/**
	 * editTrigger
	 */
public void editTrigger() {
    TableItem[] items = triggersDetailInfoTable.getTable().getSelection();
    if (items.length != 0) {
        TableItem item = items[0];
        Trigger trigger = (Trigger) item.getData();
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.TRIGGER);
        ICubridNode triggerNode = CommonUITool.findNode(database, typeSet, trigger.getName());
        if (triggerNode != null) {
            AlterTriggerAction action = (AlterTriggerAction) ActionManager.getInstance().getAction(AlterTriggerAction.ID);
            if (action.run(database, (ISchemaNode) triggerNode) == IDialogConstants.OK_ID) {
                refresh();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.errTriggerNoSelection);
    }
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) AlterTriggerAction(com.cubrid.common.ui.cubrid.trigger.action.AlterTriggerAction) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 89 with TableItem

use of org.eclipse.swt.widgets.TableItem 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 90 with TableItem

use of org.eclipse.swt.widgets.TableItem 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

TableItem (org.eclipse.swt.widgets.TableItem)475 Point (org.eclipse.swt.graphics.Point)136 Table (org.eclipse.swt.widgets.Table)125 TableColumn (org.eclipse.swt.widgets.TableColumn)79 SelectionEvent (org.eclipse.swt.events.SelectionEvent)73 GridData (org.eclipse.swt.layout.GridData)70 GridLayout (org.eclipse.swt.layout.GridLayout)61 Composite (org.eclipse.swt.widgets.Composite)56 ArrayList (java.util.ArrayList)55 Image (org.eclipse.swt.graphics.Image)55 Button (org.eclipse.swt.widgets.Button)53 Rectangle (org.eclipse.swt.graphics.Rectangle)52 Label (org.eclipse.swt.widgets.Label)51 Shell (org.eclipse.swt.widgets.Shell)49 Color (org.eclipse.swt.graphics.Color)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Text (org.eclipse.swt.widgets.Text)42 FillLayout (org.eclipse.swt.layout.FillLayout)40 Test (org.junit.Test)39 SelectionListener (org.eclipse.swt.events.SelectionListener)36