Search in sources :

Example 16 with TableContentProvider

use of com.cubrid.common.ui.spi.TableContentProvider in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method createVolumnInfoItem.

private void createVolumnInfoItem(ExpandBar bar, int index) {
    /* Database volume information */
    ExpandItem volumeInfoItem = new ExpandItem(bar, SWT.NONE, index);
    volumeInfoItem.setText(Messages.titleVolumeInfo);
    Composite volumeComposite = new Composite(bar, SWT.None);
    volumeComposite.setLayout(new FillLayout());
    volumeTableViewer = new TableViewer(volumeComposite, SWT.BORDER | SWT.FULL_SELECTION);
    volumeTableViewer.getTable().setHeaderVisible(true);
    volumeTableViewer.getTable().setLinesVisible(true);
    volumeTableViewer.setLabelProvider(new DBSpaceLabelProvider());
    volumeTableViewer.setContentProvider(new TableContentProvider());
    TableColumn dbNameColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    dbNameColumn.setText(Messages.columnDB);
    dbNameColumn.setToolTipText(Messages.columnDB);
    dbNameColumn.setWidth(150);
    TableColumn dataColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    dataColumn.setText(Messages.columnData);
    dataColumn.setToolTipText(Messages.columnDataTip);
    dataColumn.setWidth(150);
    TableColumn indexColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    indexColumn.setText(Messages.columnIndex);
    indexColumn.setToolTipText(Messages.columnIndexTip);
    indexColumn.setWidth(150);
    TableColumn tempColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    tempColumn.setText(Messages.columnTemp);
    tempColumn.setToolTipText(Messages.columnTempTip);
    tempColumn.setWidth(150);
    TableColumn genericColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    genericColumn.setText(Messages.columnGeneric);
    genericColumn.setToolTipText(Messages.columnGenericTip);
    genericColumn.setWidth(150);
    TableColumn activeLogColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    activeLogColumn.setText(Messages.columnActiveLog);
    activeLogColumn.setToolTipText(Messages.columnActiveLog);
    activeLogColumn.setWidth(90);
    TableColumn archiveLogColumn = new TableColumn(volumeTableViewer.getTable(), SWT.LEFT);
    archiveLogColumn.setText(Messages.columnArchiveLog);
    archiveLogColumn.setToolTipText(Messages.columnArchiveLog);
    archiveLogColumn.setWidth(90);
    volumeInfoItem.setControl(volumeComposite);
    volumeInfoItem.setHeight(100);
    volumeInfoItem.setExpanded(true);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) FillLayout(org.eclipse.swt.layout.FillLayout) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 17 with TableContentProvider

use of com.cubrid.common.ui.spi.TableContentProvider in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method createServerStatusItem.

private void createServerStatusItem(ExpandBar bar, int index) {
    /* Server information */
    ExpandItem serverInfoItem = new ExpandItem(bar, SWT.NONE, index);
    serverInfoItem.setText(Messages.titleSystemInfo);
    Composite serverComposite = new Composite(bar, SWT.None);
    serverComposite.setLayout(new FillLayout());
    serverTableViewer = new TableViewer(serverComposite, SWT.BORDER | SWT.FULL_SELECTION);
    serverTableViewer.getTable().setHeaderVisible(true);
    serverTableViewer.getTable().setLinesVisible(true);
    serverTableViewer.setContentProvider(new TableContentProvider());
    serverTableViewer.setLabelProvider(new ServerStatusLabelProvider());
    TableColumn cpuTypeColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    cpuTypeColumn.setText(Messages.columnType);
    cpuTypeColumn.setToolTipText(Messages.columnType);
    cpuTypeColumn.setWidth(90);
    TableColumn memoryColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    memoryColumn.setText(Messages.columnMemmory);
    memoryColumn.setToolTipText(Messages.columnMemmory);
    memoryColumn.setWidth(120);
    TableColumn freespaceColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    freespaceColumn.setText(Messages.columnFreespace);
    freespaceColumn.setToolTipText(Messages.tipFreespace);
    freespaceColumn.setWidth(100);
    TableColumn cpuColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    cpuColumn.setText(Messages.columnCpu);
    cpuColumn.setToolTipText(Messages.columnCpu);
    cpuColumn.setWidth(80);
    TableColumn tpsColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    tpsColumn.setText(Messages.columnTps);
    tpsColumn.setToolTipText(Messages.tipTps);
    tpsColumn.setWidth(100);
    TableColumn qpsColumn = new TableColumn(serverTableViewer.getTable(), SWT.LEFT);
    qpsColumn.setText(Messages.columnQps);
    qpsColumn.setToolTipText(Messages.tipQps);
    qpsColumn.setWidth(100);
    serverInfoItem.setHeight(80);
    serverInfoItem.setExpanded(true);
    serverInfoItem.setControl(serverComposite);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) FillLayout(org.eclipse.swt.layout.FillLayout) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 18 with TableContentProvider

use of com.cubrid.common.ui.spi.TableContentProvider in project cubrid-manager by CUBRID.

the class UserEditor method createCommonTableViewer.

/**
	 * Create common tableViewer
	 * 
	 * @param parent the parent composite
	 * @param columnNameArr the column name array
	 * @param gridData the grid data
	 * @return the table viewer
	 */
public TableViewer createCommonTableViewer(Composite parent, final String[] columnNameArr, GridData gridData) {
    final TableViewer tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new TableContentProvider());
    tableViewer.setLabelProvider(new ExTableLabelProvider());
    tableViewer.setSorter(new TableViewerSorter());
    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLayoutData(gridData);
    for (int i = 0; i < columnNameArr.length; i++) {
        final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.CHECK);
        tblColumn.setData(false);
        tblColumn.setText(columnNameArr[i]);
        tblColumn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                TableColumn column = (TableColumn) event.widget;
                int j = 0;
                for (j = 0; j < columnNameArr.length; j++) {
                    if (column.getText().equals(columnNameArr[j])) {
                        break;
                    }
                }
                TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
                if (sorter == null) {
                    return;
                }
                sorter.doSort(j);
                tableViewer.getTable().setSortColumn(column);
                tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
                tableViewer.refresh();
                for (int k = 0; k < tableViewer.getTable().getColumnCount(); k++) {
                    tableViewer.getTable().getColumn(k).pack();
                }
                return;
            }
        });
        tblColumn.pack();
    }
    return tableViewer;
}
Also used : TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 19 with TableContentProvider

use of com.cubrid.common.ui.spi.TableContentProvider in project cubrid-manager by CUBRID.

the class SettingCubridHAConfPage method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setControl(container);
    setDescription(Messages.descSettingCubridHAPage);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout(4, false));
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 5);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 5);
    leftData.right = new FormAttachment(50, -5);
    leftComposite.setLayoutData(leftData);
    Label separator = new Label(container, SWT.SEPARATOR);
    FormData separatorData = new FormData();
    separatorData.top = new FormAttachment(0, 5);
    separatorData.bottom = new FormAttachment(100, -5);
    separatorData.left = new FormAttachment(50, -5);
    separatorData.right = new FormAttachment(50, 5);
    separator.setLayoutData(separatorData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    rightComposite.setLayout(new GridLayout(4, false));
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(50, 5);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    /*Create left widget*/
    Label hostALabel = new Label(leftComposite, SWT.None);
    hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostALabel.setText(Messages.lblMaster);
    masterHostLabel = new Label(leftComposite, SWT.None);
    masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
    masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
    masterViewer.getTable().setLinesVisible(true);
    masterViewer.getTable().setHeaderVisible(true);
    masterViewer.setContentProvider(new TableContentProvider());
    masterViewer.setLabelProvider(new CubridConfTableProvider());
    masterViewer.setColumnProperties(PROPS);
    CellEditor[] editors = new CellEditor[2];
    editors[0] = null;
    editors[1] = new TextCellEditor(masterViewer.getTable());
    masterViewer.setCellEditors(editors);
    masterViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            masterViewer.refresh(model);
            updateHAModel(masterViewer, model, false);
        }
    });
    TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    keyAColumn.setText(Messages.lblKey);
    keyAColumn.setWidth(160);
    TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    valueAColumn.setText(Messages.lblValue);
    valueAColumn.setWidth(200);
    Label masterUserLabel = new Label(leftComposite, SWT.None);
    masterUserLabel.setText(Messages.lblUser);
    masterUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterUserCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
    masterUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterUserCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            initMasterTableData();
        }
    });
    ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
    toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
    ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
    addItemA.setToolTipText(Messages.itemAddParameter);
    addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(masterViewer);
        }
    });
    ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
    editItemA.setToolTipText(Messages.itemEditParameter);
    editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(masterViewer);
        }
    });
    ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
    dropItemA.setToolTipText(Messages.itemDeleteParameter);
    dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(masterViewer);
        }
    });
    /*Create right widget*/
    Label hostBLabel = new Label(rightComposite, SWT.None);
    hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostBLabel.setText(Messages.lblSlave);
    slaveHostLabel = new Label(rightComposite, SWT.None);
    slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
    slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
    slaveViewer.getTable().setLinesVisible(true);
    slaveViewer.getTable().setHeaderVisible(true);
    slaveViewer.setContentProvider(new TableContentProvider());
    slaveViewer.setLabelProvider(new CubridConfTableProvider());
    slaveViewer.setColumnProperties(PROPS);
    CellEditor[] editorsB = new CellEditor[2];
    editorsB[0] = null;
    editorsB[1] = new TextCellEditor(slaveViewer.getTable());
    slaveViewer.setCellEditors(editorsB);
    slaveViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            slaveViewer.refresh(model);
            updateHAModel(slaveViewer, model, false);
        }
    });
    TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    keyBColumn.setText(Messages.lblKey);
    keyBColumn.setWidth(160);
    TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    valueBColumn.setText(Messages.lblValue);
    valueBColumn.setWidth(200);
    Label slaveUserLabel = new Label(rightComposite, SWT.None);
    slaveUserLabel.setText(Messages.lblUser);
    slaveUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    slaveUserCombo = new Combo(rightComposite, SWT.BORDER | SWT.READ_ONLY);
    slaveUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    slaveUserCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            initSlaveTableData();
        }
    });
    ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
    toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
    ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
    addItemB.setToolTipText(Messages.itemAddParameter);
    addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(slaveViewer);
        }
    });
    ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
    editItemB.setToolTipText(Messages.itemEditParameter);
    editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(slaveViewer);
        }
    });
    ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
    dropItemB.setToolTipText(Messages.itemDeleteParameter);
    dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(slaveViewer);
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) ICellModifier(org.eclipse.jface.viewers.ICellModifier) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

TableContentProvider (com.cubrid.common.ui.spi.TableContentProvider)19 TableViewer (org.eclipse.jface.viewers.TableViewer)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)11 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)10 Composite (org.eclipse.swt.widgets.Composite)9 TableViewerSorter (com.cubrid.common.ui.spi.TableViewerSorter)7 FillLayout (org.eclipse.swt.layout.FillLayout)6 ExpandItem (org.eclipse.swt.widgets.ExpandItem)6 Label (org.eclipse.swt.widgets.Label)5 Menu (org.eclipse.swt.widgets.Menu)5 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 CellEditor (org.eclipse.jface.viewers.CellEditor)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2