Search in sources :

Example 16 with TableViewerSorter

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

the class CommonUITool method createCheckBoxTableViewer.

/**
	 *
	 * Create the common checkbox table viewer that can be sorted by
	 * TableViewerSorter object,this viewer's input object must be
	 * List<Map<String,Object>> and Map's key must be column index,Map's value
	 * of the column must be String.
	 *
	 * @param parent the parent composite
	 * @param sorter the table sorter
	 * @param columnNameArr the column name array
	 * @param gridData the gridData layout object
	 * @return the TableViewer object
	 */
public static TableViewer createCheckBoxTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, GridData gridData) {
    final CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(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);
        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();
                    packTable(tableViewer);
                }
            });
        }
        tblColumn.pack();
    }
    return tableViewer;
}
Also used : TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) 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) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Example 17 with TableViewerSorter

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

the class JdbcManageComposite method createJdbcTableGroup.

/**
	 * 
	 * Create JDBC table group
	 * 
	 * @param composite the composite
	 */
private void createJdbcTableGroup(Composite composite) {
    final String[] columnNameArr = new String[] { Messages.tblColDriverVersion, Messages.tblColJarPath };
    TableViewerSorter sorter = new TableViewerSorter();
    sorter.setColumnComparator(0, new Comparator<Object>() {

        public int compare(Object o1, Object o2) {
            if (o1 instanceof String && o2 instanceof String) {
                String s1 = (String) o1;
                String s2 = (String) o2;
                String[] version1Tokens = s1.substring(s1.lastIndexOf('-') + 1).split("\\.");
                String[] version2Tokens = s2.substring(s2.lastIndexOf('-') + 1).split("\\.");
                int size = Math.min(version1Tokens.length, version2Tokens.length);
                for (int i = 0; i < size; i++) {
                    Integer first = Integer.parseInt(version1Tokens[i]);
                    Integer second = Integer.parseInt(version2Tokens[i]);
                    if (first != second) {
                        return first - second;
                    }
                }
                return version1Tokens.length - version2Tokens.length;
            } else {
                return 0;
            }
        }
    });
    sorter.setAsc(false);
    jdbcInfoTv = CommonUITool.createCommonTableViewer(composite, sorter, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    jdbcInfoTv.setInput(jdbcListData);
    jdbcInfoTv.getTable().setSortColumn(jdbcInfoTv.getTable().getColumn(0));
    jdbcInfoTv.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
    TableLayout tableLayout = new TableLayout();
    jdbcInfoTv.getTable().setLayout(tableLayout);
    tableLayout.addColumnData(new ColumnWeightData(35, true));
    tableLayout.addColumnData(new ColumnWeightData(65, true));
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 18 with TableViewerSorter

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

the class UserAuthDbInfoPage method createTable.

/**
	 * 
	 * Create authoration information table area
	 * 
	 * @param parent the parent composite
	 */
private void createTable(Composite parent) {
    Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.msgDbAuthList);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    tipLabel.setLayoutData(gridData);
    columnNameArr = new String[] { Messages.tblColumnDbName, Messages.tblColumnConnected, Messages.tblColumnDbUser, Messages.tblColumnBrokerIP, Messages.tblColumnBrokerPort };
    authTableViewer = CommonUITool.createCommonTableViewer(parent, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    initialBrokerPorts(server.getHostAddress());
    initialTableModel();
    authTableViewer.setInput(databaseAuthInfoTableList);
    authTableViewer.setColumnProperties(columnNameArr);
    packTable();
    setCellEditors();
    setCellModifier();
}
Also used : TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 19 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter 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 20 with TableViewerSorter

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

the class UserEditor method createPartControl.

/**
	 * Create the page content
	 * 
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 5;
    gridLayout.marginWidth = 5;
    GridData gridData = new GridData();
    gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
    Composite top = new Composite(parent, SWT.NONE);
    top.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    top.setLayout(gridLayout);
    CLabel lblUser = new CLabel(top, SWT.NONE);
    lblUser.setFont(new Font(top.getDisplay(), lblUser.getFont().toString(), 14, SWT.BOLD));
    lblUser.setBackground(top.getBackground());
    lblUser.setLayoutData(gridData);
    lblUser.setText(userName);
    lblUserGroup = new Label(top, SWT.NONE);
    lblUserGroup.setBackground(top.getBackground());
    lblUserGroup.setText("");
    lblUserGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    lblUserMember = new Label(top, SWT.NONE);
    lblUserMember.setBackground(top.getBackground());
    lblUserMember.setText("");
    lblUserMember.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
    gridData1.heightHint = 4;
    CLabel lbl = new CLabel(top, SWT.SHADOW_IN);
    lbl.setLayoutData(gridData1);
    lbl = new CLabel(top, SWT.NONE);
    lbl.setBackground(top.getBackground());
    lbl.setText(Messages.lblOwnerClassList);
    Composite ownerComp = new Composite(top, SWT.NONE);
    ownerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 1;
    ownerComp.setLayout(layout);
    final String[] columnNameArr = new String[] { Messages.tblColOwnerClassName, Messages.tblColOwnerClassSchema, Messages.tblColOwnerClassType };
    ownerClassTableViewer = CommonUITool.createCommonTableViewer(ownerComp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    ownerClassTableViewer.setInput(ownerClassListData);
    lbl = new CLabel(top, SWT.SHADOW_IN);
    lbl.setLayoutData(gridData1);
    lbl = new CLabel(top, SWT.NONE);
    lbl.setBackground(top.getBackground());
    lbl.setText(Messages.lblAuthorizationList);
    Composite authComp = new Composite(top, SWT.NONE);
    authComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    layout = new GridLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 1;
    authComp.setLayout(layout);
    authComp.setBackground(top.getBackground());
    if (DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
        CLabel clbl = new CLabel(authComp, SWT.NONE);
        clbl.setBackground(top.getBackground());
        clbl.setText(Messages.lblDbaAllAuth);
    } else {
        final String[] authColumnNameArr = new String[] { Messages.tblColAuthTable, Messages.tblColAuthSelect, Messages.tblColAuthInsert, Messages.tblColAuthUpdate, Messages.tblColAuthDelete, Messages.tblColAuthAlter, Messages.tblColAuthIndex, Messages.tblColAuthExecute, Messages.tblColAuthGrantselect, Messages.tblColAuthGrantinsert, Messages.tblColAuthGrantupdate, Messages.tblColAuthGrantdelete, Messages.tblColAuthGrantalter, Messages.tblColAuthGrantindex, Messages.tblColAuthGrantexecute };
        authTableViewer = createCommonTableViewer(authComp, authColumnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
        authTableViewer.setLabelProvider(new ExTableLabelProvider());
        authTableViewer.setInput(authListData);
    }
    loadData();
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font)

Aggregations

TableViewerSorter (com.cubrid.common.ui.spi.TableViewerSorter)30 GridData (org.eclipse.swt.layout.GridData)20 GridLayout (org.eclipse.swt.layout.GridLayout)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 Label (org.eclipse.swt.widgets.Label)12 TableViewer (org.eclipse.jface.viewers.TableViewer)11 Composite (org.eclipse.swt.widgets.Composite)11 Group (org.eclipse.swt.widgets.Group)10 TableContentProvider (com.cubrid.common.ui.spi.TableContentProvider)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Button (org.eclipse.swt.widgets.Button)5 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)4 Table (org.eclipse.swt.widgets.Table)4 CellEditor (org.eclipse.jface.viewers.CellEditor)3 CLabel (org.eclipse.swt.custom.CLabel)3 Point (org.eclipse.swt.graphics.Point)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2