Search in sources :

Example 1 with DatabaseInfoTableViewerContentProvider

use of com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerContentProvider in project cubrid-manager by CUBRID.

the class ImportExportConnectionDialog method createTable.

private void createTable(Composite composite) {
    hostListView = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tblHostList = hostListView.getTable();
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.horizontalSpan = 3;
    gdColumnsTable.heightHint = 189;
    tblHostList.setLayoutData(gdColumnsTable);
    tblHostList.setLinesVisible(true);
    tblHostList.setHeaderVisible(true);
    final TableColumn hostName = new TableColumn(tblHostList, SWT.NONE);
    hostName.setAlignment(SWT.LEFT);
    hostName.setWidth(WIDTH_NAME);
    hostName.setText(Messages.columnHeaderServerInfo);
    if (export) {
        hostName.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
    } else {
        hostName.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
    }
    hostName.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            selectAll = !selectAll;
            hostListView.setAllChecked(selectAll);
            Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
            hostName.setImage(image);
            handleSelectAll(selectAll);
        }
    });
    final TableColumn hostAddress = new TableColumn(tblHostList, SWT.NONE);
    hostAddress.setAlignment(SWT.CENTER);
    hostAddress.setWidth(WIDTH_ADDRESS);
    hostAddress.setText(Messages.columnHeaderServerAddress);
    final TableColumn hostPort = new TableColumn(tblHostList, SWT.NONE);
    hostPort.setAlignment(SWT.CENTER);
    hostPort.setWidth(WIDTH_PORT);
    hostPort.setText(Messages.columnHeaderServerPort);
    final TableColumn jdbcVer = new TableColumn(tblHostList, SWT.NONE);
    jdbcVer.setAlignment(SWT.CENTER);
    jdbcVer.setWidth(WIDTH_JDBC);
    jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
    final TableColumn hostUser = new TableColumn(tblHostList, SWT.NONE);
    hostUser.setAlignment(SWT.CENTER);
    hostUser.setWidth(WIDTH_USER);
    hostUser.setText(Messages.columnHeaderServerUserName);
    final TableColumn savedPass = new TableColumn(tblHostList, SWT.NONE);
    savedPass.setAlignment(SWT.CENTER);
    savedPass.setWidth(WIDTH_SAVEPASS);
    savedPass.setText(Messages.columnHeaderServerAutoSave);
    DatabaseInfoTableViewerContentProvider contentProvider = new DatabaseInfoTableViewerContentProvider();
    DatabaseInfoTableViewerLabelProvider labelProvider = new DatabaseInfoTableViewerLabelProvider();
    hostListView.setContentProvider(contentProvider);
    hostListView.setLabelProvider(labelProvider);
    hostListView.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean isSelect = event.getChecked();
            Object obj = event.getElement();
            if (obj instanceof DatabaseUIWrapper) {
                ((DatabaseUIWrapper) obj).setSeleted(isSelect);
            }
            updateWidgetStatus();
        }
    });
    hostListView.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent arg0) {
            ImportExportConnectionDialog.this.getButton(IDialogConstants.OK_ID).setEnabled(hostListView.getCheckedElements().length > 0);
        }
    });
    if (export) {
        initTableData();
        setSelectAll(true);
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) DatabaseInfoTableViewerContentProvider(com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper) TableColumn(org.eclipse.swt.widgets.TableColumn) DatabaseInfoTableViewerLabelProvider(com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerLabelProvider) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

DatabaseInfoTableViewerContentProvider (com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerContentProvider)1 DatabaseInfoTableViewerLabelProvider (com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerLabelProvider)1 DatabaseUIWrapper (com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Image (org.eclipse.swt.graphics.Image)1 GridData (org.eclipse.swt.layout.GridData)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1