Search in sources :

Example 1 with DatabaseUIWrapper

use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.

the class ImportExportConnectionDialog method parseFile.

protected List<DatabaseUIWrapper> parseFile(String fileName) {
    if (methodCache.size() == 0) {
        initMethodCache();
    }
    counterMap.clear();
    savedServer.clear();
    savedServer.addAll(CQBDBNodePersistManager.getInstance().getAllDatabase());
    servers.clear();
    File file = new File(fileName);
    if (!file.exists()) {
        return null;
    }
    List<CubridDatabase> list = CQBDBNodePersistManager.getInstance().parseDatabaseFromXML(file);
    for (CubridDatabase server : list) {
        DatabaseUIWrapper wrapper = new DatabaseUIWrapper(server);
        servers.put(server.getId(), wrapper);
    }
    for (DatabaseUIWrapper wrapper : servers.values()) {
        handleDuplicateServer(wrapper);
    }
    return new ArrayList<DatabaseUIWrapper>(servers.values());
}
Also used : ArrayList(java.util.ArrayList) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper) File(java.io.File)

Example 2 with DatabaseUIWrapper

use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.

the class ImportExportConnectionDialog method handleSelectAll.

@SuppressWarnings("unchecked")
private void handleSelectAll(boolean selected) {
    List<DatabaseUIWrapper> input = (List<DatabaseUIWrapper>) hostListView.getInput();
    for (DatabaseUIWrapper check : input) {
        if (check.isSeleted() != selected)
            check.setSeleted(selected);
    }
    hostListView.setAllChecked(selected);
    updateWidgetStatus();
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper)

Example 3 with DatabaseUIWrapper

use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.

the class DatabaseInfoTableViewerContentProvider method inputChanged.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    if (newInput instanceof List) {
        List<DatabaseUIWrapper> outputs = new ArrayList<DatabaseUIWrapper>();
        List list = (List) newInput;
        for (Object obj : list) {
            if (obj instanceof DatabaseUIWrapper) {
                break;
            } else if (obj instanceof CubridDatabase) {
                DatabaseUIWrapper wrapper = new DatabaseUIWrapper((CubridDatabase) obj);
                outputs.add(list.indexOf(obj), wrapper);
            }
        }
        if (!outputs.isEmpty()) {
            list.clear();
            list.addAll(outputs);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 4 with DatabaseUIWrapper

use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper 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)

Example 5 with DatabaseUIWrapper

use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.

the class ImportExportConnectionDialog method isContainSameHost.

public boolean isContainSameHost(CubridDatabase server) {
    SimpleDateFormat format = new SimpleDateFormat(IMPORT_DUPLICATED_HOST_SUFFIX_FORMAT);
    for (int i = 0; i < savedServer.size(); i++) {
        CubridDatabase serv = savedServer.get(i);
        if (serv.getId().equals(server.getId())) {
            setMessage(Messages.msgInfoChangeName, IMessageProvider.WARNING);
            //check name has a time pattern
            String oldId = server.getId();
            updateTimePart(server, format);
            servers.put(oldId, new DatabaseUIWrapper(server));
        }
    }
    return false;
}
Also used : CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

DatabaseUIWrapper (com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper)6 ArrayList (java.util.ArrayList)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 List (java.util.List)3 DatabaseInfoTableViewerContentProvider (com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerContentProvider)1 DatabaseInfoTableViewerLabelProvider (com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerLabelProvider)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)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