Search in sources :

Example 6 with TableLabelProvider

use of com.cubrid.common.ui.spi.TableLabelProvider 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)

Example 7 with TableLabelProvider

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

the class CommonUITool method createCommonTableViewer.

/**
	 *
	 * Create the common 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 columnwidthArr the column width array
	 * @param gridData the gridData layout object
	 * @return the TableViewer object
	 */
public static TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, int[] columnwidthArr, 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);
        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);
                }
            });
        }
        if (columnwidthArr != null) {
            tblColumn.setWidth(columnwidthArr[i]);
        } else {
            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) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Example 8 with TableLabelProvider

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

the class SqlmapNavigatorView method createParamView.

private void createParamView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapName, Messages.lblSqlmapValue, Messages.lblSqlmapType };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapParameters);
    paramView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 120));
    paramView.setColumnProperties(columnNames);
    paramView.setContentProvider(new TableContentProvider());
    paramView.setLabelProvider(new TableLabelProvider());
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(100));
    tableLayout.addColumnData(new ColumnPixelData(80));
    tableLayout.addColumnData(new ColumnPixelData(70));
    paramView.getTable().setLayout(tableLayout);
    paramView.addDoubleClickListener(new IDoubleClickListener() {

        @SuppressWarnings("unchecked")
        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            Map<String, String> data = (Map<String, String>) sel.getFirstElement();
            modifyParam(data);
        }
    });
    Menu menu = new Menu(paramView.getTable().getShell(), SWT.POP_UP);
    paramView.getTable().setMenu(menu);
    final MenuItem addMenuItem = new MenuItem(menu, SWT.PUSH);
    addMenuItem.setText(Messages.mnuSqlmapAdd);
    addMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            addParameter();
        }
    });
    final MenuItem modifyMenuItem = new MenuItem(menu, SWT.PUSH);
    modifyMenuItem.setText(Messages.mnuSqlmapModify);
    modifyMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            modifyParameterByCurrentSelected();
        }
    });
    final MenuItem delMenuItem = new MenuItem(menu, SWT.PUSH);
    delMenuItem.setText(Messages.mnuSqlmapRemove);
    delMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.msgSqlmapRemove)) {
                removeParameterByCurrentSelected();
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableLayout(org.eclipse.jface.viewers.TableLayout) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with TableLabelProvider

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

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

the class ObjectInfoComposite method initViewColumn.

/**
	 * Initial view column setting
	 * 
	 * @param composite
	 */
private void initViewColumn(Composite composite) {
    viewColTableViewer = new TableViewer(composite, SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    viewColTableViewer.setContentProvider(new TableContentProvider());
    viewColTableViewer.setLabelProvider(new TableLabelProvider());
    viewColTableViewer.getTable().setLinesVisible(true);
    viewColTableViewer.getTable().setHeaderVisible(true);
    final TableColumn nameColumn = new TableColumn(viewColTableViewer.getTable(), SWT.NONE);
    nameColumn.setText(Messages.tblColViewName);
    nameColumn.pack();
    final TableColumn dataTypeColumn = new TableColumn(viewColTableViewer.getTable(), SWT.NONE);
    dataTypeColumn.setText(Messages.tblColViewDataType);
    dataTypeColumn.pack();
    final TableColumn defaultColumn = new TableColumn(viewColTableViewer.getTable(), SWT.NONE);
    defaultColumn.setText(Messages.tblColViewDefaultType);
    defaultColumn.pack();
    final TableColumn defaultValueColumn = new TableColumn(viewColTableViewer.getTable(), SWT.NONE);
    defaultValueColumn.setText(Messages.tblColViewDefaultValue);
    defaultValueColumn.pack();
}
Also used : TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) 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)10 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)10 TableViewer (org.eclipse.jface.viewers.TableViewer)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 TableColumn (org.eclipse.swt.widgets.TableColumn)5 TableViewerSorter (com.cubrid.common.ui.spi.TableViewerSorter)4 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 ExpandItem (org.eclipse.swt.widgets.ExpandItem)4 Menu (org.eclipse.swt.widgets.Menu)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)2 MenuEvent (org.eclipse.swt.events.MenuEvent)2