Search in sources :

Example 1 with TableContentProvider

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

the class EditUserDialog method createCommonTableViewer.

/**
	 * Create common tableViewer
	 * 
	 * @param parent the parent composite
	 * @param columnNameArr the column name array
	 * @param gridData the GridData
	 * @return the tableviewer
	 */
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 AuthTableLabelProvider());
    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);
        if (i != 0) {
            tblColumn.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
        }
        tblColumn.setData(false);
        tblColumn.setText(columnNameArr[i]);
        final int num = i;
        tblColumn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                TableColumn column = (TableColumn) event.widget;
                if (num == 0) {
                    int sortIndex = 0;
                    for (int j = 0; j < columnNameArr.length; j++) {
                        sortIndex = j;
                        if (column.getText().equals(columnNameArr[j])) {
                            break;
                        }
                    }
                    TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
                    if (sorter == null) {
                        return;
                    }
                    sorter.doSort(sortIndex);
                    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;
                }
                if ((Boolean) tblColumn.getData()) {
                    column.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
                    column.setData(false);
                    for (int v = 0; v < column.getParent().getItemCount(); v++) {
                        Map<String, Object> map = authListData.get(v);
                        if (isSystemClass((String) map.get("0"))) {
                            map.put(num + "", false);
                        }
                    }
                } else {
                    column.setImage(CommonUIPlugin.getImage("icons/checked.gif"));
                    column.setData(true);
                    for (int v = 0; v < column.getParent().getItemCount(); v++) {
                        Map<String, Object> map = authListData.get(v);
                        if (isSystemClass((String) map.get("0"))) {
                            map.put(num + "", true);
                        }
                    }
                }
                tableViewer.refresh();
            }
        });
        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) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with TableContentProvider

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

the class SqlmapNavigatorView method createCondView.

/**
	 * Create the main view.
	 *
	 * @param parent {@link Composite} the parent composite
	 */
private void createCondView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapConditions);
    condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
    condView.setColumnProperties(columnNames);
    condView.setContentProvider(new TableContentProvider());
    condView.setLabelProvider(new SqlmapLabelProvider(this));
    condView.setCellModifier(new SqlmapCellModifier(this));
    CellEditor[] cellEditor = new CellEditor[columnNames.length];
    cellEditor[0] = new CheckboxCellEditor(condView.getTable());
    condView.setCellEditors(cellEditor);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(30));
    tableLayout.addColumnData(new ColumnPixelData(160));
    condView.getTable().setLayout(tableLayout);
    condView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == ' ') {
                toggleUsedBySelectedCondition();
            }
            super.keyPressed(e);
        }
    });
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) KeyEvent(org.eclipse.swt.events.KeyEvent) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 3 with TableContentProvider

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

the class SettingCubridConfPage 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.descSettingCubridPage);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout(3, 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(3, 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, 2, 1, -1, -1));
    masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
    masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
    masterViewer.getTable().setLinesVisible(true);
    masterViewer.getTable().setHeaderVisible(true);
    masterViewer.setContentProvider(new TableContentProvider());
    masterViewer.setLabelProvider(new CubridConfTableProvider());
    masterViewer.setColumnProperties(PROPS);
    CellEditor[] editorsA = new CellEditor[2];
    editorsA[0] = null;
    editorsA[1] = new TextCellEditor(masterViewer.getTable());
    masterViewer.setCellEditors(editorsA);
    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 masterDBLabel = new Label(leftComposite, SWT.None);
    masterDBLabel.setText(Messages.lblDatabase);
    masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
    masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterDBCombo.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            HAModel haModel = getConfigHAWizard().getHaModel();
            /*Init table data*/
            initTableData(haModel.getMasterServer(), true);
            HAServer haServer = haModel.getSlaveServer();
            initTableData(haServer, false);
        }
    });
    ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
    toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 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, 2, 1, -1, -1));
    slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
    slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 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);
    ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
    toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 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 : 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) 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) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) TableColumn(org.eclipse.swt.widgets.TableColumn) ToolBar(org.eclipse.swt.widgets.ToolBar) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with TableContentProvider

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

the class CQBUserEditor 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 5 with TableContentProvider

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

the class CreateViewDialog method createCommonTableViewer.

/**
	 * create Common Table Viewer
	 *
	 * @param parent Composite
	 * @param sorter ViewerSorter
	 * @param columnNameArr String[]
	 * @param gridData GridData
	 * @return TableViewer
	 */
public TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, 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 TableLabelProvider());
    if (sorter != null) {
        tableViewer.setSorter(sorter);
    }
    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.LEFT | (isPropertyQuery ? SWT.NULL : SWT.READ_ONLY));
        tblColumn.setText(columnNameArr[i]);
        if (sorter != null) {
            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();
                    }
                }
            });
        }
        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) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

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