Example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty

List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection isEmpty.

Prototype

public boolean isEmpty();

Source Link

Document

Returns whether this selection is empty.

Usage

From source file:com.hangum.tadpole.manager.core.editor.db.DBListComposite.java

License:Open Source License

/**
 * modify db/*w  ww  .j  a  v  a 2s .  com*/
 */
private void configurationDB() {
    IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
    if (ss.isEmpty())
        return;

    if (ss.getFirstElement() instanceof UserDBDAO) {
        UserDBDAO userDB = (UserDBDAO) ss.getFirstElement();

        final ModifyDBDialog dialog = new ModifyDBDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), userDB);
        if (dialog.open() == Dialog.OK) {
            initData();
            tvDBList.setSelection(new StructuredSelection(dialog.getDTO()), true);
        }
    }
}

From source file:com.hangum.tadpole.manager.core.editor.db.DBListComposite.java

License:Open Source License

/**
 * detail user information// w ww  .  j a v a  2  s  . c  o  m
 */
private void detailUser() {
    IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
    if (ss.isEmpty())
        return;

    TadpoleUserDbRoleDAO userDBRole = (TadpoleUserDbRoleDAO) ss.getFirstElement();
    DetailUserAndDBRoleDialog dialog = new DetailUserAndDBRoleDialog(getShell(), userDBRole);
    if (Dialog.OK == dialog.open()) {
        tvDBList.refresh(dialog.getUserDBRole(), true);
    }
}

From source file:com.hangum.tadpole.manager.core.editor.db.DBListComposite.java

License:Open Source License

/**
 * delete user//  w w  w . j  a v  a 2 s. c om
 */
private void deleteUser() {
    IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
    if (ss.isEmpty())
        return;

    TadpoleUserDbRoleDAO userDBRole = (TadpoleUserDbRoleDAO) ss.getFirstElement();
    if (userDBRole.getParent().getUser_seq() == userDBRole.getUser_seq())
        return;

    if (!MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().DBListComposite_18))
        return;

    try {
        TadpoleSystem_UserDBQuery.removeUserRoleDB(userDBRole.getSeq());
        UserDBDAO userDB = userDBRole.getParent();
        userDB.getListChildren().remove(userDBRole);

        tvDBList.refresh(userDB);

    } catch (Exception e) {
        logger.error("delete user exception", e); //$NON-NLS-1$
        Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
        ExceptionDetailsErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.get().Error, Messages.get().DBListComposite_6, errStatus);
    }
}

From source file:com.hangum.tadpole.manager.core.editor.db.DBListComposite.java

License:Open Source License

/**
 * ?  ? ?  ./*from  ww w .j a  va  2s  .  c om*/
 */
private void viewQueryHistory() {
    IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
    if (ss.isEmpty())
        return;

    Object objSelect = ss.getFirstElement();
    if (objSelect instanceof UserDBDAO) {
        try {
            SQLAuditEditorInput esei = new SQLAuditEditorInput(userDAO, (UserDBDAO) ss.getFirstElement(),
                    roleType);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(esei,
                    SQLAuditEditor.ID, false);
        } catch (Exception e) {
            logger.error("Query History open", e); //$NON-NLS-1$

            Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
            ExceptionDetailsErrorDialog.openError(null, Messages.get().Error, Messages.get().QueryHistory,
                    errStatus);
        }
    }
}

From source file:com.hangum.tadpole.manager.core.editor.db.DBListComposite.java

License:Open Source License

/**
 * SQL editor/*  ww w .  j  av a 2s. c om*/
 */
private void sqlEditor() {
    IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
    if (ss.isEmpty())
        return;

    try {
        MainEditorInput esei = new MainEditorInput((UserDBDAO) ss.getFirstElement());
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(esei, MainEditor.ID,
                false);
    } catch (Exception e) {
        logger.error("SQL Editor open", e); //$NON-NLS-1$

        Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
        ExceptionDetailsErrorDialog.openError(null, Messages.get().Error, Messages.get().DBListComposite_24,
                errStatus);
    }
}

From source file:com.hangum.tadpole.manager.core.editor.db.dialogs.DBAccessControlDialog.java

License:Open Source License

/**
 * Create contents of the dialog.//from   w  w  w  .j ava 2  s . c o  m
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) container.getLayout();
    gridLayout.verticalSpacing = 5;
    gridLayout.horizontalSpacing = 5;
    gridLayout.marginHeight = 5;
    gridLayout.marginWidth = 5;

    Composite compositeHead = new Composite(container, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeHead.setLayout(new GridLayout(2, false));

    Label lblDbName = new Label(compositeHead, SWT.NONE);
    lblDbName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDbName.setText(Messages.get().DBName);

    textDBName = new Text(compositeHead, SWT.BORDER);
    textDBName.setEditable(false);
    textDBName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textDBName.setText(userDB.getDisplay_name());

    Label lblUser = new Label(compositeHead, SWT.NONE);
    lblUser.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblUser.setText(Messages.get().User);

    comboUser = new Combo(compositeHead, SWT.READ_ONLY);
    comboUser.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            initData();
        }
    });
    comboUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    List<TadpoleUserDbRoleDAO> listUser = userDB.getListChildren();
    for (int i = 0; i < listUser.size(); i++) {
        TadpoleUserDbRoleDAO tadpoleUserDbRoleDAO = listUser.get(i);
        comboUser
                .add(String.format("%s (%s)", tadpoleUserDbRoleDAO.getName(), tadpoleUserDbRoleDAO.getEmail())); //$NON-NLS-1$
        comboUser.setData("" + i, tadpoleUserDbRoleDAO); //$NON-NLS-1$
    }
    comboUser.select(0);

    Composite compositeBody = new Composite(container, SWT.NONE);
    compositeBody.setLayout(new GridLayout(1, false));
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Group grpAuthority = new Group(compositeBody, SWT.NONE);
    grpAuthority.setLayout(new GridLayout(2, false));
    grpAuthority.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grpAuthority.setText(Messages.get().Authority);

    btnSelect = new Button(grpAuthority, SWT.CHECK);
    btnSelect.setEnabled(false);
    btnSelect.setSelection(true);
    btnSelect.setText(Messages.get().SELECT);

    Composite compositeSelectBtn = new Composite(grpAuthority, SWT.NONE);
    compositeSelectBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeSelectBtn.setLayout(new GridLayout(3, false));

    btnSelectAdd = new Button(compositeSelectBtn, SWT.NONE);
    btnSelectAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TableColumnFilterDialog tableColumnDialog = new TableColumnFilterDialog(getShell(), dbAccessDetail);
            if (Dialog.OK == tableColumnDialog.open()) {
                listTableColumn.add(tableColumnDialog.getUpdateData());
                tvSelect.refresh();
            }
        }
    });
    btnSelectAdd.setText(Messages.get().Add);
    btnSelect.setEnabled(false);
    //      if(userDB.getDBDefine() == DBDefine.MYSQL_DEFAULT) btnSelect.setEnabled(true);

    btnSelectDelete = new Button(compositeSelectBtn, SWT.NONE);
    btnSelectDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection iss = (IStructuredSelection) tvSelect.getSelection();
            if (!iss.isEmpty()) {
                if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm,
                        Messages.get().DBAccessControlDialog_9))
                    return;

                AccessCtlObjectDAO dao = (AccessCtlObjectDAO) iss.getFirstElement();

                listTableColumn.remove(dao);
                tvSelect.refresh();
            }
        }
    });
    btnSelectDelete.setText(Messages.get().Delete);
    btnSelectDelete.setEnabled(false);
    new Label(compositeSelectBtn, SWT.NONE);

    new Label(grpAuthority, SWT.NONE);

    tvSelect = new TableViewer(grpAuthority, SWT.BORDER | SWT.FULL_SELECTION);
    tvSelect.addPostSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            btnSelectDelete.setEnabled(true);
        }
    });
    tvSelect.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection iss = (IStructuredSelection) event.getSelection();
            if (!iss.isEmpty()) {
                AccessCtlObjectDAO acObject = (AccessCtlObjectDAO) iss.getFirstElement();

                TableColumnFilterDialog tableColumnDialog = new TableColumnFilterDialog(getShell(),
                        dbAccessDetail, acObject);
                if (Dialog.OK == tableColumnDialog.open()) {
                    //                  listTableColumn.add(tableColumnDialog.getUpdateData());
                    tvSelect.refresh();
                }
            }

        }
    });
    Table table = tvSelect.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TableViewerColumn tvColumnName = new TableViewerColumn(tvSelect, SWT.NONE);
    TableColumn tblclmnTable = tvColumnName.getColumn();
    tblclmnTable.setWidth(150);
    tblclmnTable.setText(Messages.get().Table);

    TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tvSelect, SWT.NONE);
    TableColumn tblclmnDoNotUse = tableViewerColumn_2.getColumn();
    tblclmnDoNotUse.setWidth(60);
    tblclmnDoNotUse.setText(Messages.get().DBAccessControlDialog_12);

    TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tvSelect, SWT.NONE);
    TableColumn tblclmnColumn = tableViewerColumn_1.getColumn();
    tblclmnColumn.setWidth(500);
    tblclmnColumn.setText(Messages.get().Column);

    tvSelect.setContentProvider(new ArrayContentProvider());
    tvSelect.setLabelProvider(new SelectTableFilterLabelprovider());
    tvSelect.setInput(listTableColumn);

    btnInsert = new Button(grpAuthority, SWT.CHECK);
    btnInsert.setText("INSERT"); //$NON-NLS-1$
    new Label(grpAuthority, SWT.NONE);

    btnUpdate = new Button(grpAuthority, SWT.CHECK);
    btnUpdate.setText("UPDATE"); //$NON-NLS-1$
    new Label(grpAuthority, SWT.NONE);

    btnDelete = new Button(grpAuthority, SWT.CHECK);
    btnDelete.setText("DELETE"); //$NON-NLS-1$
    new Label(grpAuthority, SWT.NONE);

    btnDdl = new Button(grpAuthority, SWT.CHECK);
    btnDdl.setText("DDL"); //$NON-NLS-1$
    new Label(grpAuthority, SWT.NONE);

    firstInit();
    initData();

    return container;
}

From source file:com.hangum.tadpole.manager.core.editor.executedsql.ExecutedSQLEditor.java

License:Open Source License

/**
 * show query editor//ww  w  .  j a  v a2s .  c  o  m
 */
private void showQueryEditor() {
    IStructuredSelection ss = (IStructuredSelection) tvList.getSelection();
    if (!ss.isEmpty()) {
        SQLHistoryDAO sqlHistoryDAO = (SQLHistoryDAO) ss.getFirstElement();

        try {
            UserDBDAO dbDao;
            if (null != searchUserDBDAO) {
                dbDao = searchUserDBDAO;
            } else {
                dbDao = userDBDaoCache.get(sqlHistoryDAO.getDbSeq());
                if (null == dbDao) {
                    dbDao = TadpoleSystem_UserDBQuery.getUserDBInstance(sqlHistoryDAO.getDbSeq());
                    userDBDaoCache.put(sqlHistoryDAO.getDbSeq(), dbDao);
                }
            }

            FindEditorAndWriteQueryUtil.run(dbDao,
                    sqlHistoryDAO.getStrSQLText() + PublicTadpoleDefine.SQL_DELIMITER, DB_ACTION.TABLES);
        } catch (Exception e) {
            logger.error("find editor and write query", e);
        }
    }
}

From source file:com.hangum.tadpole.manager.core.editor.schemahistory.SchemaHistoryEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));

    Composite compositeHead = new Composite(parent, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeHead.setLayout(new GridLayout(6, false));

    Label lblDb = new Label(compositeHead, SWT.NONE);
    lblDb.setText("DB");

    comboDisplayName = new Combo(compositeHead, SWT.READ_ONLY);
    comboDisplayName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblWorkType = new Label(compositeHead, SWT.NONE);
    lblWorkType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblWorkType.setText("Work Type");

    textWorkType = new Combo(compositeHead, SWT.BORDER);
    textWorkType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textWorkType.add("");
    textWorkType.add("CREATE");
    textWorkType.add("ALTER");
    textWorkType.add("DROP");

    Label lblObjectType = new Label(compositeHead, SWT.NONE);
    lblObjectType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblObjectType.setText("Object Type");

    textObjectType = new Combo(compositeHead, SWT.BORDER);
    textObjectType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textObjectType.setVisibleItemCount(7);

    textObjectType.add("");
    textObjectType.add("TABLE");
    textObjectType.add("VIEW");
    textObjectType.add("INDEX");
    textObjectType.add("PROCEDURE");
    textObjectType.add("FUNCTION");
    textObjectType.add("TRIGGER");

    Label lblObjectId = new Label(compositeHead, SWT.NONE);
    lblObjectId.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblObjectId.setText("Object Name");

    textObjectID = new Text(compositeHead, SWT.BORDER);
    textObjectID.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Composite composite = new Composite(compositeHead, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    GridLayout gl_composite = new GridLayout(4, false);
    gl_composite.verticalSpacing = 1;//www .j  av  a  2 s.  c  om
    gl_composite.horizontalSpacing = 1;
    gl_composite.marginWidth = 1;
    gl_composite.marginHeight = 1;
    composite.setLayout(gl_composite);

    Label lblStart = new Label(composite, SWT.NONE);
    lblStart.setText("Date");

    dateTimeStart = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN);

    Label label = new Label(composite, SWT.NONE);
    label.setText("~");

    dateTimeEnd = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN);

    Button btnSearch = new Button(compositeHead, SWT.NONE);
    btnSearch.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            search();
        }
    });
    btnSearch.setImage(
            ResourceManager.getPluginImage("com.hangum.tadpole.manager.core", "resources/icons/search.png"));
    btnSearch.setText("Search");

    SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Composite compositeList = new Composite(sashForm, SWT.NONE);
    compositeList.setLayout(new GridLayout(1, false));

    tableViewer = new TableViewer(compositeList, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            try {
                IStructuredSelection ss = (IStructuredSelection) tableViewer.getSelection();
                if (!ss.isEmpty()) {
                    SchemaHistoryDAO dao = (SchemaHistoryDAO) ss.getFirstElement();
                    String strSQL = getSQL(dao.getSeq());
                    textDateLeft.setText(dao.getCreate_date().toLocaleString());
                    textLeftSQL.setText(strSQL);

                }
            } catch (Exception e) {
                logger.error("select change tree", e);
            }
        }
    });
    Table table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Button btnCompare = new Button(compositeList, SWT.NONE);
    btnCompare.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            compare();
        }
    });
    btnCompare.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnCompare.setText("Compare");
    createTableColumn();

    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new SchemaHistorLabelProvider());

    // result composite
    Composite compositeDetail = new Composite(sashForm, SWT.NONE);
    compositeDetail.setLayout(new GridLayout(1, false));

    SashForm sashFormDetail = new SashForm(compositeDetail, SWT.NONE);
    sashFormDetail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Composite compositeLeft = new Composite(sashFormDetail, SWT.NONE);
    compositeLeft.setLayout(new GridLayout(2, false));

    Label lblNewLabel = new Label(compositeLeft, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("Date");

    textDateLeft = new Text(compositeLeft, SWT.BORDER);
    textDateLeft.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    textLeftSQL = new Text(compositeLeft, SWT.BORDER | SWT.MULTI);
    textLeftSQL.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    Composite compositeRight = new Composite(sashFormDetail, SWT.NONE);
    compositeRight.setLayout(new GridLayout(2, false));

    Label lblNewLabel_1 = new Label(compositeRight, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel_1.setText("Date");

    textDateRight = new Text(compositeRight, SWT.BORDER);
    textDateRight.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    textSQLRight = new Text(compositeRight, SWT.BORDER | SWT.MULTI);
    textSQLRight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    sashFormDetail.setWeights(new int[] { 1, 1 });

    sashForm.setWeights(new int[] { 4, 6 });

    initUI();
}

From source file:com.hangum.tadpole.manager.core.editor.schemahistory.SchemaHistoryEditor.java

License:Open Source License

/**
 * history compare/*from  ww w.j av a 2 s.  com*/
 */
private void compare() {
    IStructuredSelection ss = (IStructuredSelection) tableViewer.getSelection();
    if (!ss.isEmpty()) {
        Object[] objListSel = ss.toArray();

        try {
            for (int i = 0; i < objListSel.length; i++) {
                if (i == 2)
                    break;

                SchemaHistoryDAO dao = (SchemaHistoryDAO) objListSel[i];
                String strSQL = getSQL(dao.getSeq());
                if (i == 0) {
                    textDateLeft.setText(dao.getCreate_date().toLocaleString());
                    textLeftSQL.setText(strSQL);
                } else {
                    textDateRight.setText(dao.getCreate_date().toLocaleString());
                    textSQLRight.setText(strSQL);
                }
            }
        } catch (Exception e) {
            logger.error("Get detail sql", e);
        }
        if (objListSel.length == 1) {
            textDateRight.setText("");
            textSQLRight.setText("");
        }

    } else {
        textDateLeft.setText("");
        textLeftSQL.setText("");
        textDateRight.setText("");
        textSQLRight.setText("");
    }
}

From source file:com.hangum.tadpole.mongodb.core.composite.result.MongodbResultComposite.java

License:Open Source License

/**
 * /*  ww w . j  a va 2  s.  c om*/
 * @param parent
 * @param style
 * @param userDB
 * @param collectionName
 */
public MongodbResultComposite(Composite parent, int style, final UserDBDAO userDB, final String collectionName,
        final boolean isUserAction) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 1;
    gridLayout.horizontalSpacing = 1;
    gridLayout.marginHeight = 1;
    gridLayout.marginWidth = 1;
    setLayout(gridLayout);

    this.userDB = userDB;
    this.collectionName = collectionName;
    this.isUserAction = isUserAction;

    Composite compositeResult = new Composite(this, SWT.NONE);
    compositeResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_compositeResult = new GridLayout(1, false);
    gl_compositeResult.verticalSpacing = 1;
    gl_compositeResult.horizontalSpacing = 1;
    gl_compositeResult.marginHeight = 1;
    gl_compositeResult.marginWidth = 1;
    compositeResult.setLayout(gl_compositeResult);

    tabFolderMongoDB = new CTabFolder(compositeResult, SWT.NONE);
    tabFolderMongoDB.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (treeViewerMongo == null)
                return;
            selectData();
        }
    });
    tabFolderMongoDB.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tabFolderMongoDB.setSelectionBackground(TadpoleWidgetUtils.getTabFolderBackgroundColor(),
            TadpoleWidgetUtils.getTabFolderPercents());
    CTabItem tbtmTreeView = new CTabItem(tabFolderMongoDB, SWT.NONE);
    tbtmTreeView.setText(Messages.MongodbResultComposite_3);

    Composite compositeTreeView = new Composite(tabFolderMongoDB, SWT.NONE);
    tbtmTreeView.setControl(compositeTreeView);
    GridLayout gl_compositeTreeView = new GridLayout(1, false);
    gl_compositeTreeView.verticalSpacing = 2;
    gl_compositeTreeView.horizontalSpacing = 2;
    gl_compositeTreeView.marginHeight = 2;
    gl_compositeTreeView.marginWidth = 2;
    compositeTreeView.setLayout(gl_compositeTreeView);

    treeViewerMongo = new TreeViewer(compositeTreeView, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION);
    treeViewerMongo.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection iss = (IStructuredSelection) treeViewerMongo.getSelection();
            if (!iss.isEmpty()) {
                MongodbTreeViewDTO rsResult = (MongodbTreeViewDTO) iss.getFirstElement();
                String strKey = rsResult.getKey();

                TadpoleSimpleMessageDialog dlg = new TadpoleSimpleMessageDialog(
                        Display.getCurrent().getActiveShell(), collectionName + " [ " + strKey + " ]", //$NON-NLS-1$//$NON-NLS-2$
                        JSONUtil.getPretty(rsResult.getDbObject().toString()));
                dlg.open();
            }
        }
    });
    Tree tree = treeViewerMongo.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    createTreeColumn();

    treeViewerMongo.setContentProvider(new TreeMongoContentProvider());
    treeViewerMongo.setLabelProvider(new TreeMongoLabelProvider());

    Composite compositeTreeViewTail = new Composite(compositeTreeView, SWT.NONE);
    compositeTreeViewTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeTreeViewTail.setLayout(new GridLayout(6, false));

    if (isUserAction) {
        Button btnTreeInsertDocument = new Button(compositeTreeViewTail, SWT.NONE);
        btnTreeInsertDocument.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                newDocument();
            }
        });
        btnTreeInsertDocument.setText(Messages.MongodbResultComposite_4);

        Button btnTreeDeleteDocument = new Button(compositeTreeViewTail, SWT.NONE);
        btnTreeDeleteDocument.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                deleteDocumentTree();
            }
        });
        btnTreeDeleteDocument.setText(Messages.MongodbResultComposite_5);

        Button btnTreeCreateIndex = new Button(compositeTreeViewTail, SWT.NONE);
        btnTreeCreateIndex.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                createIndex();
            }
        });
        btnTreeCreateIndex.setText(Messages.MongodbResultComposite_6);

        Label labelTreeViewDumy = new Label(compositeTreeViewTail, SWT.NONE);
        labelTreeViewDumy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    }

    lblTreeViewCount = new Label(compositeTreeViewTail, SWT.NONE);
    lblTreeViewCount.setText(Messages.MongodbResultComposite_7);

    CTabItem tbtmTableView = new CTabItem(tabFolderMongoDB, SWT.NONE);
    tbtmTableView.setText(Messages.MongodbResultComposite_8);

    sashFormCollectionResult = new SashForm(tabFolderMongoDB, SWT.VERTICAL);
    tbtmTableView.setControl(sashFormCollectionResult);

    Composite compositeBodyTable = new Composite(sashFormCollectionResult, SWT.VERTICAL);
    GridLayout gl_compositeBodyTable = new GridLayout(2, false);
    gl_compositeBodyTable.marginWidth = 2;
    gl_compositeBodyTable.marginHeight = 2;
    gl_compositeBodyTable.verticalSpacing = 2;
    gl_compositeBodyTable.horizontalSpacing = 2;
    compositeBodyTable.setLayout(gl_compositeBodyTable);

    Label lblFilter = new Label(compositeBodyTable, SWT.NONE);
    lblFilter.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblFilter.setText(Messages.MongodbResultComposite_11);

    textFilter = new Text(compositeBodyTable, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textFilter.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.Selection)
                setFilter();
        }
    });
    textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    resultTableViewer = new TableViewer(compositeBodyTable, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION);
    resultTableViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection iss = (IStructuredSelection) resultTableViewer.getSelection();
            if (!iss.isEmpty()) {
                HashMap<Integer, Object> rsResult = (HashMap<Integer, Object>) iss.getFirstElement();
                String jsonString = rsResult.get(MongoDBDefine.PRIMARY_ID_KEY).toString();

                DBObject dbObject = (DBObject) rsResult.get(MongoDBDefine.PRIMARY_ID_KEY);

                FindOneDetailDialog dlg = new FindOneDetailDialog(null, userDB, collectionName, dbObject);
                dlg.open();
            }
        }
    });
    Table table = resultTableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    sqlFilter.setTable(table);

    Composite compositeTail = new Composite(compositeBodyTable, SWT.NONE);
    compositeTail.setLayout(new GridLayout(10, false));
    compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    if (isUserAction) {
        Button btnInsertDocument = new Button(compositeTail, SWT.NONE);
        btnInsertDocument.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                newDocument();
            }
        });
        btnInsertDocument.setText(Messages.MongodbResultComposite_13);

        Button btnDeleteDocument = new Button(compositeTail, SWT.NONE);
        btnDeleteDocument.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                deleteDocumentTable();
            }
        });
        btnDeleteDocument.setText(Messages.MongodbResultComposite_14);

        Button btnCreateIndex = new Button(compositeTail, SWT.NONE);
        btnCreateIndex.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                createIndex();
            }
        });
        btnCreateIndex.setText(Messages.MongodbResultComposite_15);

        Label labelTableDumy = new Label(compositeTail, SWT.NONE);
        GridData gd_labelTableDumy = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gd_labelTableDumy.widthHint = 5;
        labelTableDumy.setLayoutData(gd_labelTableDumy);
    }

    Button btnExportCSV = new Button(compositeTail, SWT.NONE);
    btnExportCSV.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuffer sbExportDataBody = new StringBuffer();

            // fixed : https://github.com/hangum/TadpoleForDBTools/issues/284
            // column ?.
            String tmpStrHead = "";
            TableColumn[] tcs = resultTableViewer.getTable().getColumns();
            for (TableColumn tableColumn : tcs) {
                tmpStrHead += tableColumn.getText() + ", "; //$NON-NLS-1$
            }
            tmpStrHead = StringUtils.removeEnd(tmpStrHead, ", ");
            tmpStrHead += PublicTadpoleDefine.LINE_SEPARATOR; //$NON-NLS-1$

            // column ?? . 
            for (int i = 0; i < sourceDataList.size(); i++) {
                String tmpData = "";
                Map<Integer, Object> mapColumns = sourceDataList.get(i);
                for (int j = 0; j < tcs.length; j++) {
                    tmpData += mapColumns.get(j) + ", "; //$NON-NLS-1$
                }
                tmpData = StringUtils.removeEnd(tmpData, ", ");
                tmpData += PublicTadpoleDefine.LINE_SEPARATOR;

                sbExportDataBody.append(tmpData); //$NON-NLS-1$
            }

            downloadServiceHandler.setName(userDB.getDisplay_name() + "_ResultSetExport.csv"); //$NON-NLS-1$
            downloadServiceHandler.setByteContent((tmpStrHead + sbExportDataBody.toString()).getBytes());
            DownloadUtils.provideDownload(compositeExternal, downloadServiceHandler.getId());
        }
    });
    btnExportCSV.setText(Messages.MongodbResultComposite_16);

    compositeExternal = new Composite(compositeTail, SWT.NONE);
    compositeExternal.setLayout(new GridLayout(1, false));
    compositeExternal.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    Label lblNewLabel_1 = new Label(compositeTail, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    lblTableViewCount = new Label(compositeTail, SWT.NONE);

    // tabpole message
    CTabItem tbtmTadpoleMessage = new CTabItem(tabFolderMongoDB, SWT.NONE);
    tbtmTadpoleMessage.setText(Messages.MongodbResultComposite_17);

    Composite compositeTadpoleMsg = new Composite(tabFolderMongoDB, SWT.NONE);
    tbtmTadpoleMessage.setControl(compositeTadpoleMsg);
    compositeTadpoleMsg.setLayout(new GridLayout(1, false));

    tableViewerMessage = new TableViewer(compositeTadpoleMsg, SWT.BORDER | SWT.FULL_SELECTION);
    tableViewerMessage.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection is = (IStructuredSelection) event.getSelection();
            Object selElement = is.getFirstElement();
            if (selElement instanceof TadpoleMessageDAO) {
                TadpoleMessageDAO tmd = (TadpoleMessageDAO) selElement;
                TadpoleMessageDialog dlg = new TadpoleMessageDialog(null, "Message", //$NON-NLS-1$
                        SQLHistoryLabelProvider.dateToStr(tmd.getDateExecute()), tmd.getStrMessage());
                dlg.open();
            }
        }
    });
    tableTadpoleMsg = tableViewerMessage.getTable();
    tableTadpoleMsg.setHeaderVisible(true);
    tableTadpoleMsg.setLinesVisible(true);
    tableTadpoleMsg.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tableTadpoleMsg.setSortDirection(SWT.DOWN);
    SQLHistorySorter sorterMessage = new SQLHistorySorter();

    TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewerMessage, SWT.NONE);
    TableColumn tblclmnDate = tableViewerColumn.getColumn();
    tblclmnDate.setWidth(140);
    tblclmnDate.setText(Messages.MongodbResultComposite_18);
    tblclmnDate.addSelectionListener(getSelectionAdapter(tableViewerMessage, sorterMessage, tblclmnDate, 0));

    TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewerMessage, SWT.NONE);
    TableColumn tblclmnSql = tableViewerColumn_1.getColumn();
    tblclmnSql.setWidth(500);
    tblclmnSql.setText(Messages.MongodbResultComposite_19);
    tblclmnSql.addSelectionListener(getSelectionAdapter(tableViewerMessage, sorterMessage, tblclmnSql, 1));

    tableViewerMessage.setLabelProvider(new SQLHistoryLabelProvider());
    tableViewerMessage.setContentProvider(new ArrayContentProvider());
    tableViewerMessage.setInput(listMessage);
    tableViewerMessage.setComparator(sorterMessage);

    Composite composite = new Composite(compositeTadpoleMsg, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    composite.setLayout(new GridLayout(3, false));

    Button btnExportTadpoleMessage = new Button(composite, SWT.NONE);
    btnExportTadpoleMessage.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuffer sbExportData = new StringBuffer();

            for (TadpoleMessageDAO dao : listMessage) {
                sbExportData.append(dao.getStrMessage()).append(PublicTadpoleDefine.LINE_SEPARATOR); //$NON-NLS-1$
            }

            downloadServiceHandler.setName(userDB.getDisplay_name() + "_Message.txt"); //$NON-NLS-1$
            downloadServiceHandler.setByteContent(sbExportData.toString().getBytes());
            DownloadUtils.provideDownload(compositeExternal, downloadServiceHandler.getId());
        }
    });
    btnExportTadpoleMessage.setText(Messages.MongodbResultComposite_20);

    Label label = new Label(composite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button btnClear = new Button(composite, SWT.NONE);
    btnClear.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            listMessage.clear();
            tableViewerMessage.refresh();
        }
    });
    btnClear.setText(Messages.MongodbResultComposite_21);

    registerServiceHandler();
    firstTabInit();
}