Example usage for org.eclipse.jface.viewers TreeViewer TreeViewer

List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer

Introduction

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

Prototype

public TreeViewer(Composite parent, int style) 

Source Link

Document

Creates a tree viewer on a newly-created tree control under the given parent.

Usage

From source file:com.google.gdt.eclipse.designer.util.ui.ResourceSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayoutFactory.create(container).columns(2).equalColumns();
    // create name pattern
    {/*w w w . j ava 2s.  c om*/
        {
            Label label = new Label(container, SWT.NONE);
            GridDataFactory.create(label).spanH(2);
            label.setText("Select a resource (? = any character, * = any string):");
        }
        {
            m_namePatternText = new Text(container, SWT.BORDER);
            GridDataFactory.create(m_namePatternText).spanH(2).grabH().fillH();
            m_namePatternText.addModifyListener(new ModifyListener() {
                public void modifyText(ModifyEvent e) {
                    // prepare name pattern matcher
                    String pattern = m_namePatternText.getText();
                    if (pattern.length() != 0) {
                        pattern = adjustPattern(pattern);
                        m_namePattern = new SearchPattern();
                        m_namePattern.setPattern(pattern);
                    } else {
                        m_namePattern = null;
                    }
                    // refresh viewer
                    refreshViewer();
                }

                private String adjustPattern(String pattern) {
                    pattern = pattern.trim();
                    if (pattern.endsWith("<")) {
                        // the < character indicates an exact match search
                        return pattern.substring(0, pattern.length() - 1);
                    }
                    if (!pattern.equals("") && !pattern.endsWith("*")) {
                        return pattern + "*";
                    }
                    return pattern;
                }
            });
        }
    }
    // create tree viewer group
    {
        Group treeGroup = new Group(container, SWT.NONE);
        GridDataFactory.create(treeGroup).spanV(2).grab().fill().hintHC(55).hintVC(25);
        GridLayoutFactory.create(treeGroup);
        treeGroup.setText("Matching resources");
        // create tree viewer
        {
            m_viewer = new TreeViewer(treeGroup, SWT.BORDER);
            m_viewer.setContentProvider(new ResourceContentProvider());
            m_viewer.setLabelProvider(new ResourceLabelProvider());
            m_viewer.setSorter(new ResourceSorter());
            m_viewer.addFilter(new ResourceViewerFilter());
            //
            m_tree = m_viewer.getTree();
            GridDataFactory.create(m_tree).grab().fill();
            // all listeners
            m_viewer.addSelectionChangedListener(new ISelectionChangedListener() {
                public void selectionChanged(SelectionChangedEvent event) {
                    clearPreviewGroup();
                    //
                    IStructuredSelection selection = (IStructuredSelection) m_viewer.getSelection();
                    AbstractResource resource = (AbstractResource) selection.getFirstElement();
                    if (resource instanceof ResourceFile) {
                        ResourceFile file = (ResourceFile) resource;
                        previewFile(m_previewGroup, file);
                        m_selectedResourcePath = file.getPublicPath();
                    } else {
                        m_selectedResourcePath = null;
                    }
                    // update OK button
                    getButton(IDialogConstants.OK_ID).setEnabled(m_selectedResourcePath != null);
                }
            });
            m_viewer.addDoubleClickListener(new IDoubleClickListener() {
                public void doubleClick(DoubleClickEvent event) {
                    if (m_selectedResourcePath != null) {
                        okPressed();
                    }
                }
            });
        }
    }
    // filters group
    {
        Group filtersGroup = new Group(container, SWT.NONE);
        GridDataFactory.create(filtersGroup).fill();
        GridLayoutFactory.create(filtersGroup);
        filtersGroup.setText("Filters");
        // add "all files" button
        {
            m_allFilesButton = new Button(filtersGroup, SWT.CHECK);
            m_allFilesButton.setText("All Files");
            m_allFilesButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    refreshViewer();
                }
            });
        }
        // add filters
        for (final ResourceFilter filter : m_filters) {
            // create check box
            final Button filterButton = new Button(filtersGroup, SWT.CHECK);
            filterButton.setText(filter.m_title);
            filterButton.setSelection(true);
            m_activeFilters.add(filter);
            // add listener
            filterButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (filterButton.getSelection()) {
                        m_activeFilters.add(filter);
                    } else {
                        m_activeFilters.remove(filter);
                    }
                    refreshViewer();
                }
            });
        }
    }
    //
    createPreviewGroup(container);
    // initialize viewer
    {
        m_viewer.setInput(m_root);
        m_viewer.expandAll();
    }
    //
    return container;
}

From source file:com.google.gwt.eclipse.oophm.views.hierarchical.LaunchConfigurationContent.java

License:Open Source License

private void createViewer(Label launchUrlsCaptionLabel) {
    viewer = new TreeViewer(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    viewer.setLabelProvider(new LabelProvider());
    viewer.setContentProvider(new ContentProvider(launchUrlsCaptionLabel));
    viewer.setInput(launchConfiguration);
    viewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override/* w  w w  . ja v  a2s.c  o m*/
        public void doubleClick(DoubleClickEvent event) {
            browserMenuPopulator.openDefaultBrowser(getProject(launchConfiguration), getSelectedUrl());
        }
    });
}

From source file:com.hangum.tadpole.manager.core.dialogs.auth.AdminComposite.java

License:Open Source License

/**
 * Create the composite.//from ww w.java2 s . c  om
 * @param parent
 * @param style
 */
public AdminComposite(Composite parent, int style) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 2;
    gridLayout.horizontalSpacing = 2;
    gridLayout.marginHeight = 2;
    gridLayout.marginWidth = 2;
    setLayout(gridLayout);

    Composite compositeHead = new Composite(this, SWT.NONE);
    GridLayout gl_compositeHead = new GridLayout(2, false);
    gl_compositeHead.verticalSpacing = 2;
    gl_compositeHead.horizontalSpacing = 2;
    gl_compositeHead.marginHeight = 2;
    gl_compositeHead.marginWidth = 2;
    compositeHead.setLayout(gl_compositeHead);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            treeViewerAdmin.setInput(initData());
        }
    });
    tltmRefresh.setText("Refresh");

    final ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE);
    tltmAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            NewUserDialog dialog = new NewUserDialog(getShell());
            dialog.open();
        }
    });
    tltmAdd.setText("Add");

    ToolItem tltmModify = new ToolItem(toolBar, SWT.NONE);
    tltmModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            IStructuredSelection ss = (IStructuredSelection) treeViewerAdmin.getSelection();
            if (ss != null) {
                ModifyUserDialog dialog = new ModifyUserDialog(getShell(),
                        (UserGroupAUserDAO) ss.getFirstElement());
                if (Dialog.OK == dialog.open())
                    treeViewerAdmin.setInput(initData());
            } // if ss            
        }
    });
    tltmModify.setText("Modify");

    Label lblSearch = new Label(compositeHead, SWT.NONE);
    lblSearch.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSearch.setText("Search");

    textSearch = new Text(compositeHead, SWT.BORDER);
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textSearch.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            filter.setSearchString(textSearch.getText());
            treeViewerAdmin.refresh();
        }
    });

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

    treeViewerAdmin = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
    treeAdmin = treeViewerAdmin.getTree();
    treeAdmin.setLinesVisible(true);
    treeAdmin.setHeaderVisible(true);
    treeAdmin.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TreeViewerColumn colGroupName = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colGroupName.getColumn().setWidth(130);
    colGroupName.getColumn().setText("Group Name");

    TreeViewerColumn colUserType = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colUserType.getColumn().setWidth(100);
    colUserType.getColumn().setText("User/DB Type");

    TreeViewerColumn colEmail = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colEmail.getColumn().setWidth(200);
    colEmail.getColumn().setText("email/DB Name");

    TreeViewerColumn colName = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colName.getColumn().setWidth(150);
    colName.getColumn().setText("Name/DB Info");

    TreeViewerColumn colApproval = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colApproval.getColumn().setWidth(60);
    colApproval.getColumn().setText("Approval");

    TreeViewerColumn colDelete = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colDelete.getColumn().setWidth(60);
    colDelete.getColumn().setText("Delete");

    TreeViewerColumn colCreateTime = new TreeViewerColumn(treeViewerAdmin, SWT.NONE);
    colCreateTime.getColumn().setWidth(120);
    colCreateTime.getColumn().setText("Create tiem");

    treeViewerAdmin.setContentProvider(new AdminUserContentProvider());
    treeViewerAdmin.setLabelProvider(new AdminUserLabelProvider());
    treeViewerAdmin.setInput(initData());
    treeViewerAdmin.expandToLevel(2);

    filter = new AdminCompFilter();
    treeViewerAdmin.addFilter(filter);
}

From source file:com.hangum.tadpole.manager.core.editor.auth.AdminUserListComposite.java

License:Open Source License

/**
 * Create the composite./* w  w  w. ja v  a 2 s.  co  m*/
 * @param parent
 * @param style
 */
public AdminUserListComposite(Composite parent, int style) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    setLayout(gridLayout);

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

    Composite compositeHead = new Composite(composite, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gl_compositeHead = new GridLayout(2, false);
    gl_compositeHead.verticalSpacing = 0;
    gl_compositeHead.horizontalSpacing = 0;
    gl_compositeHead.marginHeight = 0;
    gl_compositeHead.marginWidth = 0;
    compositeHead.setLayout(gl_compositeHead);

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setImage(ImageUtils.getRefresh());
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            initUI();
        }
    });
    tltmRefresh.setToolTipText("Refresh");

    ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE);
    tltmAdd.setImage(ImageUtils.getAdd());
    tltmAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addUser();
        }
    });
    tltmAdd.setToolTipText("Add");

    tltmModify = new ToolItem(toolBar, SWT.NONE);
    tltmModify.setImage(ImageUtils.getModify());
    tltmModify.setEnabled(false);
    tltmModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            modifyUser();
        }
    });
    tltmModify.setToolTipText("Modify");

    tltmQuery = new ToolItem(toolBar, SWT.NONE);
    tltmQuery.setImage(ImageUtils.getQueryHistory());
    tltmQuery.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewQueryHistory();
        }
    });
    tltmQuery.setEnabled(false);
    tltmQuery.setToolTipText("SQL Audit");

    Label lblSearch = new Label(compositeHead, SWT.NONE);
    lblSearch.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSearch.setText("Search");

    textSearch = new Text(compositeHead, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textSearch.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            filter.setSearchString(textSearch.getText());
            userListViewer.refresh();
        }
    });

    Composite compositeBody = new Composite(composite, SWT.NONE);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_compositeBody = new GridLayout(1, false);
    gl_compositeBody.verticalSpacing = 2;
    gl_compositeBody.horizontalSpacing = 2;
    gl_compositeBody.marginHeight = 2;
    gl_compositeBody.marginWidth = 2;
    compositeBody.setLayout(gl_compositeBody);

    userListViewer = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    userListViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            viewQueryHistory();
        }
    });
    userListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (tltmModify != null)
                tltmModify.setEnabled(true);
            tltmQuery.setEnabled(true);
        }
    });
    Tree tree = userListViewer.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    createColumn();

    userListViewer.setContentProvider(new UserContentProvider());
    userListViewer.setLabelProvider(new UserLabelProvider());

    filter = new UserCompFilter();
    userListViewer.addFilter(filter);
    ;

    initUI();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

}

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

License:Open Source License

/**
 * Create the composite./*  ww  w .  j a  va  2s.co m*/
 * @param parent
 * @param style
 */
public DBListComposite(Composite parent, int style) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    setLayout(gridLayout);

    Composite compositeHead = new Composite(this, SWT.NONE);
    GridLayout gl_compositeHead = new GridLayout(3, false);
    gl_compositeHead.verticalSpacing = 0;
    gl_compositeHead.horizontalSpacing = 0;
    gl_compositeHead.marginHeight = 0;
    gl_compositeHead.marginWidth = 0;
    compositeHead.setLayout(gl_compositeHead);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setImage(ImageUtils.getRefresh());
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            treeViewerDBList.setInput(initData());
        }
    });
    tltmRefresh.setToolTipText("Refresh");

    //      // access control
    //      if(PublicTadpoleDefine.USER_TYPE.MANAGER.toString().equals(SessionManager.getRepresentRole()) || 
    //            PublicTadpoleDefine.USER_TYPE.ADMIN.toString().equals(SessionManager.getRepresentRole())
    //            ) {
    final ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE);
    tltmAdd.setImage(ImageUtils.getAdd());
    tltmAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            final DBLoginDialog dialog = new DBLoginDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "");
            final int ret = dialog.open();

            if (ret == Dialog.OK) {
                treeViewerDBList.setInput(initData());
                refreshConnections();
            }
        }
    });
    tltmAdd.setToolTipText("Add");

    tltmDBDelete = new ToolItem(toolBar, SWT.NONE);
    tltmDBDelete.setImage(ImageUtils.getDelete());
    tltmDBDelete.setEnabled(false);
    tltmDBDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteDB();
        }
    });
    tltmDBDelete.setToolTipText("DB Delete");

    tltmModify = new ToolItem(toolBar, SWT.NONE);
    tltmModify.setImage(ImageUtils.getModify());
    tltmModify.setEnabled(false);
    tltmModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            modifyDB();
        }
    });
    tltmModify.setToolTipText("Modify");

    ToolItem tltmDbExport = new ToolItem(toolBar, SWT.NONE);
    tltmDbExport.setImage(ImageUtils.getExport());
    tltmDbExport.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            exportDB();
        }
    });
    tltmDbExport.setToolTipText("DB Export");

    ToolItem tltmDbImport = new ToolItem(toolBar, SWT.NONE);
    tltmDbImport.setImage(ImageUtils.getImport()); //$NON-NLS-1$
    tltmDbImport.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            importDB();
        }
    });
    tltmDbImport.setToolTipText("DB Import");
    //      }

    tltmQueryHistory = new ToolItem(toolBar, SWT.NONE);
    tltmQueryHistory.setImage(ImageUtils.getQueryHistory()); //$NON-NLS-1$
    tltmQueryHistory.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewQueryHistory();
        }
    });
    tltmQueryHistory.setEnabled(false);
    tltmQueryHistory.setToolTipText("Query History");

    tltmSQLEditor = new ToolItem(toolBar, SWT.NONE);
    tltmSQLEditor.setImage(ImageUtils.getSQLEditor()); //$NON-NLS-1$
    tltmSQLEditor.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlEditor();
        }
    });
    tltmSQLEditor.setEnabled(false);
    tltmSQLEditor.setToolTipText("SQL Editor");

    new Label(compositeHead, SWT.NONE);

    Label lblSearch = new Label(compositeHead, SWT.NONE);
    lblSearch.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSearch.setText("Search");

    textSearch = new Text(compositeHead, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    textSearch.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            filter.setSearchString(textSearch.getText());
            treeViewerDBList.refresh();
        }
    });

    // download dumy
    compositeDumy = new Composite(compositeHead, SWT.NONE);
    compositeDumy.setLayout(new GridLayout(1, false));

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

    treeViewerDBList = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
    treeViewerDBList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {

            IStructuredSelection ss = (IStructuredSelection) treeViewerDBList.getSelection();
            if (ss.isEmpty())
                return;
            UserDBDAO userDB = (UserDBDAO) ss.getFirstElement();
            if (userDB.getGroup_seq() == SessionManager.getGroupSeq()) {
                tltmModify.setEnabled(true);
                tltmDBDelete.setEnabled(true);
            } else {
                tltmModify.setEnabled(false);
                tltmDBDelete.setEnabled(false);
            }

            tltmQueryHistory.setEnabled(true);
            tltmSQLEditor.setEnabled(true);
        }
    });
    treeViewerDBList.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            viewQueryHistory();
        }
    });
    Tree treeAdmin = treeViewerDBList.getTree();
    treeAdmin.setLinesVisible(true);
    treeAdmin.setHeaderVisible(true);
    treeAdmin.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TreeViewerColumn colGroupName = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colGroupName.getColumn().setWidth(130);
    colGroupName.getColumn().setText("Group Name");

    TreeViewerColumn colUserType = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colUserType.getColumn().setWidth(100);
    colUserType.getColumn().setText("DB Type");

    TreeViewerColumn colEmail = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colEmail.getColumn().setWidth(150);
    colEmail.getColumn().setText("DB Name");

    TreeViewerColumn colName = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colName.getColumn().setWidth(200);
    colName.getColumn().setText("DB Info");

    TreeViewerColumn colApproval = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colApproval.getColumn().setWidth(70);
    colApproval.getColumn().setText("User");

    TreeViewerColumn colVisible = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colVisible.getColumn().setWidth(40);
    colVisible.getColumn().setText("Visible");

    TreeViewerColumn colCreateTime = new TreeViewerColumn(treeViewerDBList, SWT.NONE);
    colCreateTime.getColumn().setWidth(120);
    colCreateTime.getColumn().setText("Create tiem");

    treeViewerDBList.setContentProvider(new AdminUserContentProvider());
    treeViewerDBList.setLabelProvider(new AdminUserLabelProvider());
    treeViewerDBList.setInput(initData());
    treeViewerDBList.expandToLevel(2);

    filter = new AdminCompFilter();
    treeViewerDBList.addFilter(filter);

    registerServiceHandler();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

}

From source file:com.hangum.tadpole.manager.core.editor.auth.UserListComposite.java

License:Open Source License

/**
 * Create the composite./* ww  w .  ja  va2  s.c om*/
 * @param parent
 * @param style
 */
public UserListComposite(Composite parent, int style) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    setLayout(gridLayout);

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

    Composite compositeHead = new Composite(composite, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gl_compositeHead = new GridLayout(2, false);
    gl_compositeHead.verticalSpacing = 0;
    gl_compositeHead.horizontalSpacing = 0;
    gl_compositeHead.marginHeight = 0;
    gl_compositeHead.marginWidth = 0;
    compositeHead.setLayout(gl_compositeHead);

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setImage(ImageUtils.getRefresh());
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            initUI();
        }
    });
    tltmRefresh.setToolTipText(Messages.UserListComposite_0);

    ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE);
    tltmAdd.setImage(ImageUtils.getAdd());
    tltmAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addUser();
        }
    });
    tltmAdd.setToolTipText(Messages.UserListComposite_1);

    ToolItem tltmDelete = new ToolItem(toolBar, SWT.NONE);
    tltmDelete.setImage(ImageUtils.getDelete());
    tltmDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteUser();
        }
    });
    tltmDelete.setToolTipText(Messages.UserListComposite_2);

    tltmQuery = new ToolItem(toolBar, SWT.NONE);
    tltmQuery.setImage(ImageUtils.getQueryHistory());
    tltmQuery.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewQueryHistory();
        }
    });
    tltmQuery.setEnabled(false);
    tltmQuery.setToolTipText(Messages.UserListComposite_3);

    Label lblSearch = new Label(compositeHead, SWT.NONE);
    lblSearch.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSearch.setText(Messages.UserListComposite_4);

    textSearch = new Text(compositeHead, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textSearch.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            filter.setSearchString(textSearch.getText());
            userListViewer.refresh();
        }
    });

    Composite compositeBody = new Composite(composite, SWT.NONE);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_compositeBody = new GridLayout(1, false);
    gl_compositeBody.verticalSpacing = 2;
    gl_compositeBody.horizontalSpacing = 2;
    gl_compositeBody.marginHeight = 2;
    gl_compositeBody.marginWidth = 2;
    compositeBody.setLayout(gl_compositeBody);

    userListViewer = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    userListViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            viewQueryHistory();
        }
    });
    userListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            //            if(tltmModify != null) tltmModify.setEnabled(true);
            tltmQuery.setEnabled(true);
        }
    });
    Tree tree = userListViewer.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    createColumn();

    userListViewer.setContentProvider(new UserContentProvider());
    userListViewer.setLabelProvider(new UserLabelProvider());

    filter = new UserCompFilter();
    userListViewer.addFilter(filter);
    ;

    initUI();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

}

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

License:Open Source License

/**
 * Create the composite.//from  w  w  w  .  j  av  a 2s  .  c  om
 * @param parent
 * @param style
 * @param userDAO 
 * @param roleType 
 */
public DBListComposite(Composite parent, int style, UserDAO userDAO, USER_ROLE_TYPE roleType) {
    super(parent, style);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    setLayout(gridLayout);
    this.userDAO = userDAO;
    this.roleType = roleType;

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

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setImage(GlobalImageUtils.getRefresh());
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            initData();
        }
    });
    tltmRefresh.setToolTipText(Messages.get().Refresh);

    ToolItem toolItem_0 = new ToolItem(toolBar, SWT.SEPARATOR);

    tltmConfigurationDB = new ToolItem(toolBar, SWT.NONE);
    tltmConfigurationDB.setImage(GlobalImageUtils.getConfigurationDatabase());
    tltmConfigurationDB.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            configurationDB();
        }
    });
    tltmConfigurationDB.setToolTipText(Messages.get().DBListComposite_1);
    tltmConfigurationDB.setEnabled(false);

    tltmOtherInformation = new ToolItem(toolBar, SWT.NONE);
    tltmOtherInformation.setImage(GlobalImageUtils.getOtherInformation());
    tltmOtherInformation.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
            if (ss.isEmpty())
                return;

            DBOthresConfigDialog othersDialog = new DBOthresConfigDialog(getShell(),
                    (UserDBDAO) ss.getFirstElement());
            if (othersDialog.open() == Dialog.OK) {
                tvDBList.refresh(othersDialog.getUserDBDAO());
            }
        }
    });
    tltmOtherInformation.setEnabled(false);
    tltmOtherInformation.setToolTipText(Messages.get().DBListComposite_2);

    ToolItem toolItem_1 = new ToolItem(toolBar, SWT.SEPARATOR);

    tltmAddUser = new ToolItem(toolBar, SWT.NONE);
    tltmAddUser.setImage(GlobalImageUtils.getUserAdd());
    tltmAddUser.setEnabled(false);
    tltmAddUser.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
            if (ss.isEmpty())
                return;

            UserDBDAO userDB = (UserDBDAO) ss.getFirstElement();

            FindUserAndDBRoleDialog dialog = new FindUserAndDBRoleDialog(getShell(),
                    (UserDBDAO) ss.getFirstElement());
            dialog.open();

            userDB.getListChildren().clear();
            try {
                List<TadpoleUserDbRoleDAO> listUser = TadpoleSystem_UserRole.getUserRoleList(userDB);
                if (userDB.getListChildren().isEmpty()) {
                    for (TadpoleUserDbRoleDAO tadpoleUserDbRoleDAO : listUser) {
                        tadpoleUserDbRoleDAO.setParent(userDB);
                    }

                    userDB.setListChildren(listUser);
                    tvDBList.refresh(userDB, true);
                    tvDBList.expandToLevel(3);
                }
            } catch (Exception e3) {
                logger.error(Messages.get().DBListComposite_10, e3);
            }

            //            TadpoleUserDbRoleDAO userRole = dialog.getUserRoleDAO();
            //            userRole.setParent(userDB);
            //            userDB.getListChildren().add(userRole);
            //            
            //            tvDBList.refresh(userDB);

        }
    });
    tltmAddUser.setToolTipText(Messages.get().DBListComposite_3);

    tltmDBAccessCtl = new ToolItem(toolBar, SWT.NONE);
    tltmDBAccessCtl.setImage(GlobalImageUtils.getFiltering());
    tltmDBAccessCtl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
            if (ss.isEmpty())
                return;

            DBAccessControlDialog dbAccessCtlDialog = new DBAccessControlDialog(getShell(),
                    (TadpoleUserDbRoleDAO) ss.getFirstElement());
            dbAccessCtlDialog.open();
        }
    });
    tltmDBAccessCtl.setEnabled(false);
    tltmDBAccessCtl.setToolTipText(Messages.get().DBListComposite_4);

    tltmUserInfo = new ToolItem(toolBar, SWT.NONE);
    tltmUserInfo.setImage(GlobalImageUtils.getUserInfo());
    tltmUserInfo.setEnabled(false);
    tltmUserInfo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            detailUser();
        }
    });
    tltmUserInfo.setToolTipText(Messages.get().DBListComposite_5);

    tltmUserDelete = new ToolItem(toolBar, SWT.NONE);
    tltmUserDelete.setImage(GlobalImageUtils.getUserRemove());
    tltmUserDelete.setEnabled(false);
    tltmUserDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteUser();
        }
    });
    tltmUserDelete.setToolTipText(Messages.get().DBListComposite_6);

    ToolItem toolItem = new ToolItem(toolBar, SWT.SEPARATOR);

    tltmQueryHistory = new ToolItem(toolBar, SWT.NONE);
    tltmQueryHistory.setImage(GlobalImageUtils.getQueryHistory()); //$NON-NLS-1$
    tltmQueryHistory.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewQueryHistory();
        }
    });
    tltmQueryHistory.setEnabled(false);
    tltmQueryHistory.setToolTipText(Messages.get().QueryHistory);

    ToolItem toolItem_2 = new ToolItem(toolBar, SWT.SEPARATOR);
    tltmSQLEditor = new ToolItem(toolBar, SWT.NONE);
    tltmSQLEditor.setImage(GlobalImageUtils.getSQLEditor()); //$NON-NLS-1$
    tltmSQLEditor.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlEditor();
        }
    });
    tltmSQLEditor.setEnabled(false);
    tltmSQLEditor.setToolTipText(Messages.get().DBListComposite_8);

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

    Label lblUser = new Label(compositeHead, SWT.NONE);
    Label lblUserName = new Label(compositeHead, SWT.NONE);
    if (userDAO != null) {
        lblUser.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
        lblUser.setText(Messages.get().DBListComposite_26);

        lblUserName.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
        lblUserName.setText(String.format("%s(%s)", userDAO.getName(), userDAO.getEmail())); //$NON-NLS-1$
    }
    Label lblSearch = new Label(compositeHead, SWT.NONE);
    lblSearch.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSearch.setText(Messages.get().Search);

    textSearch = new Text(compositeHead, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));

    textSearch.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            filter.setSearchString(textSearch.getText());
            tvDBList.refresh();
        }
    });

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

    tvDBList = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
    tvDBList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {

            IStructuredSelection ss = (IStructuredSelection) tvDBList.getSelection();
            if (ss.isEmpty())
                return;

            Object objSelect = ss.getFirstElement();
            if (objSelect instanceof UserDBDAO) {
                UserDBDAO userDB = (UserDBDAO) objSelect;
                try {
                    List<TadpoleUserDbRoleDAO> listUser = TadpoleSystem_UserRole.getUserRoleList(userDB);
                    if (userDB.getListChildren().isEmpty()) {
                        for (TadpoleUserDbRoleDAO tadpoleUserDbRoleDAO : listUser) {
                            tadpoleUserDbRoleDAO.setParent(userDB);
                        }

                        userDB.setListChildren(listUser);
                        tvDBList.refresh(userDB, true);
                        tvDBList.expandToLevel(3);
                    }
                } catch (Exception e) {
                    logger.error(Messages.get().DBListComposite_10, e);
                }

                tltmConfigurationDB.setEnabled(true);
                tltmOtherInformation.setEnabled(true);

                tltmAddUser.setEnabled(true);

                tltmUserDelete.setEnabled(false);
                tltmUserInfo.setEnabled(false);
                tltmDBAccessCtl.setEnabled(false);

                tltmQueryHistory.setEnabled(true);
                tltmSQLEditor.setEnabled(true);
            } else if (objSelect instanceof TadpoleUserDbRoleDAO) {
                TadpoleUserDbRoleDAO userDBRole = (TadpoleUserDbRoleDAO) objSelect;
                if (userDBRole.getParent().getUser_seq() != userDBRole.getUser_seq()) {
                    tltmUserDelete.setEnabled(true);
                    tltmUserInfo.setEnabled(true);
                    tltmDBAccessCtl.setEnabled(true);
                } else {
                    tltmUserDelete.setEnabled(false);
                    tltmUserInfo.setEnabled(false);
                    tltmDBAccessCtl.setEnabled(false);
                }
                tltmAddUser.setEnabled(false);
                tltmConfigurationDB.setEnabled(false);
                tltmOtherInformation.setEnabled(false);

                tltmQueryHistory.setEnabled(false);
                tltmSQLEditor.setEnabled(false);

                // don't use mongodb
                if (userDBRole.getParent().getDBDefine() == DBDefine.MONGODB_DEFAULT) {
                    tltmDBAccessCtl.setEnabled(false);
                }

            } else if (objSelect instanceof ManagerListDTO) {

                tltmConfigurationDB.setEnabled(false);
                tltmOtherInformation.setEnabled(false);

                tltmAddUser.setEnabled(false);
                tltmUserDelete.setEnabled(false);
                tltmUserInfo.setEnabled(false);
                tltmDBAccessCtl.setEnabled(false);
                tltmQueryHistory.setEnabled(false);
                tltmSQLEditor.setEnabled(false);
            }

        }
    });
    tvDBList.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            viewQueryHistory();
        }
    });
    Tree treeAdmin = tvDBList.getTree();
    treeAdmin.setLinesVisible(true);
    treeAdmin.setHeaderVisible(true);
    treeAdmin.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    treeAdmin.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    TreeViewerColumn colGroupName = new TreeViewerColumn(tvDBList, SWT.NONE);
    colGroupName.getColumn().setWidth(250);
    colGroupName.getColumn().setText(Messages.get().DBListComposite_11);

    TreeViewerColumn colRoleName = new TreeViewerColumn(tvDBList, SWT.NONE);
    colRoleName.getColumn().setWidth(80);
    colRoleName.getColumn().setText(Messages.get().Role);

    TreeViewerColumn colName = new TreeViewerColumn(tvDBList, SWT.NONE);
    colName.getColumn().setWidth(330);
    colName.getColumn().setText(Messages.get().DBInfo + "(" + Messages.get().DBListComposite_16 + ")"); //$NON-NLS-1$ //$NON-NLS-2$

    TreeViewerColumn colApproval = new TreeViewerColumn(tvDBList, SWT.NONE);
    colApproval.getColumn().setWidth(70);
    colApproval.getColumn().setText(Messages.get().User);

    TreeViewerColumn colVisible = new TreeViewerColumn(tvDBList, SWT.NONE);
    colVisible.getColumn().setWidth(50);
    colVisible.getColumn().setText(Messages.get().DBListComposite_15);

    tvDBList.setContentProvider(new DBListContentProvider());
    tvDBList.setLabelProvider(new DBListLabelProvider());
    tvDBList.setInput(listUserDBs);
    initData();
    tvDBList.expandToLevel(2);

    filter = new AdminCompFilter();
    tvDBList.addFilter(filter);

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

}

From source file:com.hangum.tadpole.manager.core.editor.resource.ResourceManageEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    GridLayout gl_parent = new GridLayout(1, false);
    gl_parent.verticalSpacing = 1;/*from   w w  w. jav a2 s.c o m*/
    gl_parent.marginHeight = 1;
    gl_parent.horizontalSpacing = 1;
    gl_parent.marginWidth = 1;
    parent.setLayout(gl_parent);

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

    ToolBar toolBar = new ToolBar(compositeToolbar, SWT.FLAT | SWT.RIGHT);
    GridData gd_toolBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_toolBar.widthHint = 267;
    toolBar.setLayoutData(gd_toolBar);

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setToolTipText("Refresh");
    tltmRefresh.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/refresh.png")); //$NON-NLS-1$
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            comboViewer.getCombo().clearSelection();
            textTitle.setText("");
            textDescription.setText("");
            textQuery.setText("");

            initUI();
            //reLoadResource();
        }
    });

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

    columnFilter = new DefaultTableColumnFilter();

    SashForm sashForm_1 = new SashForm(sashForm, SWT.NONE);

    treeViewer = new TreeViewer(sashForm_1, SWT.BORDER);
    Tree treeDatabase = treeViewer.getTree();
    treeDatabase.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    Composite composite_1 = new Composite(sashForm_1, SWT.NONE);
    composite_1.setLayout(new GridLayout(1, false));

    Composite composite_2 = new Composite(composite_1, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    GridData gd_composite_2 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_composite_2.heightHint = 28;
    composite_2.setLayoutData(gd_composite_2);

    Label lblFilter = new Label(composite_2, SWT.NONE);
    lblFilter.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblFilter.setText("Filter");

    textFilter = new Text(composite_2, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SEARCH | SWT.CANCEL);
    textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textFilter.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.Selection) {
                columnFilter.setSearchString(textFilter.getText());
                tableViewer.refresh();
            }
        }
    });

    tableViewer = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION);
    tableResource = tableViewer.getTable();
    tableResource.setHeaderVisible(true);
    tableResource.setLinesVisible(true);
    tableResource.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sashForm_1.setWeights(new int[] { 230, 359 });
    tableViewer.addFilter(columnFilter);

    Group grpQuery = new Group(sashForm, SWT.NONE);
    grpQuery.setText("Query");
    GridLayout gl_grpQuery = new GridLayout(1, false);
    gl_grpQuery.verticalSpacing = 1;
    gl_grpQuery.horizontalSpacing = 1;
    gl_grpQuery.marginHeight = 1;
    gl_grpQuery.marginWidth = 1;
    grpQuery.setLayout(gl_grpQuery);

    Composite composite = new Composite(grpQuery, SWT.NONE);
    GridLayout gl_composite = new GridLayout(6, false);
    gl_composite.marginHeight = 2;
    gl_composite.marginWidth = 2;
    gl_composite.verticalSpacing = 2;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

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

    comboViewer = new ComboViewer(composite, SWT.NONE);
    comboShare = comboViewer.getCombo();
    comboShare.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboShare.setItems(new String[] { "PUBLIC", "PRIVATE" });

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

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

    Button btnSave = new Button(composite, SWT.NONE);
    btnSave.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // TODO : SAVE... ?  .
            if (tableViewer.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            try {
                String share_type = comboShare.getText();
                share_type = (share_type == null || "".equals(share_type)) ? "PUBLIC" : share_type;
                dao.setShared_type(share_type);
                dao.setRes_title(textTitle.getText());
                dao.setDescription(textDescription.getText());
                TadpoleSystem_UserDBResource.updateResourceHeader(dao);
                //reLoadResource();
                addUserResouceData();
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    btnSave.setText("Save");

    Button btnDelete = new Button(composite, SWT.NONE);
    btnDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // TODO : DELYN SET TO 'YES'
            if (tableViewer.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            // ? ?  (?)?   ? ? dao ?   ?
            // .
            UserDBResourceDAO userDBResource = new UserDBResourceDAO();
            userDBResource.setResource_seq((int) dao.getResource_seq());
            userDBResource.setName(dao.getRes_title());
            userDBResource.setParent(userDB);

            try {
                TadpoleSystem_UserDBResource.delete(userDBResource);
            } catch (Exception e1) {
                logger.error("Resource delete " + dao.toString(), e1);
            }
        }
    });
    btnDelete.setText("Delete");

    Label lblDescription = new Label(composite, SWT.NONE);
    lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDescription.setText("Description");

    textDescription = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1);
    gd_textDescription.heightHint = 44;
    textDescription.setLayoutData(gd_textDescription);

    textQuery = new Text(composite,
            SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    textQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 1));
    sashForm.setWeights(new int[] { 179, 242 });

    createTableColumn();

    initUI();

}

From source file:com.hangum.tadpole.manager.core.editor.restfulapi.RESTFulAPIManagerEditor.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(1, false));

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);

    ToolItem tltmRefrsh = new ToolItem(toolBar, SWT.NONE);
    tltmRefrsh.setToolTipText(Messages.get().Refresh);
    tltmRefrsh.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/refresh.png")); //$NON-NLS-1$
    tltmRefrsh.addSelectionListener(new SelectionAdapter() {
        @Override//  w  ww . j a  va 2  s.  c o m
        public void widgetSelected(SelectionEvent e) {
            initUI();
        }
    });

    ToolItem tltmAPIExecute = new ToolItem(toolBar, SWT.NONE);
    tltmAPIExecute.setToolTipText(Messages.get().RESTFulAPIManagerEditor_3);
    tltmAPIExecute.setImage(ResourceManager.getPluginImage(com.hangum.tadpole.manager.core.Activator.PLUGIN_ID,
            "resources/icons/restful_api.png")); //$NON-NLS-1$
    tltmAPIExecute.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            UserAPIServiceDialog dialog = new UserAPIServiceDialog(getSite().getShell());
            dialog.open();
        }
    });

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

    tvAPIList = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    tvAPIList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (tvAPIList.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tvAPIList.getSelection();
            RESTFulAPIDAO dao = (RESTFulAPIDAO) ss.getFirstElement();
            rmDAO = dao.getResourceManagerDao();

            if (rmDAO == null)
                return;

            try {
                userDB = TadpoleSystem_UserDBQuery.getUserDBInstance(Integer.parseInt("" + rmDAO.getDb_seq())); //$NON-NLS-1$

                SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
                List<String> result = sqlClient.queryForList("userDbResourceData", rmDAO); //$NON-NLS-1$

                comboShare.getCombo().select("PUBLIC".equals(rmDAO.getShared_type()) ? 0 : 1); //$NON-NLS-1$
                textTitle.setText(rmDAO.getName());
                textDescription.setText(rmDAO.getDescription());
                comboSupportAPI.setText(rmDAO.getRestapi_yesno());
                textAPIURL.setText(rmDAO.getRestapi_uri() == null ? "" : rmDAO.getRestapi_uri()); //$NON-NLS-1$
                textAPIKey.setText(rmDAO.getRestapi_key());
                textQuery.setText(""); //$NON-NLS-1$
                for (String data : result) {
                    textQuery.append(data);
                }

            } catch (Exception e) {
                logger.error("Resource detail", e); //$NON-NLS-1$
            }
        }
    });
    tvAPIList.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            if (tvAPIList.getSelection().isEmpty())
                return;

            StructuredSelection ss = (StructuredSelection) tvAPIList.getSelection();
            RESTFulAPIDAO dao = (RESTFulAPIDAO) ss.getFirstElement();
            ResourceManagerDAO rmDAO = dao.getResourceManagerDao();

            if (rmDAO == null)
                return;

            try {

                final UserDBDAO userDB = TadpoleSystem_UserDBQuery
                        .getUserDBInstance(Integer.parseInt("" + rmDAO.getDb_seq())); //$NON-NLS-1$

                // TODO :  ??? ??     DAO   ?  .DAO    ?.
                UserDBResourceDAO ad = new UserDBResourceDAO();
                ad.setResource_seq((int) rmDAO.getResource_seq());
                ad.setName(rmDAO.getName());
                ad.setParent(userDB);

                // db object ?  ? ??.
                if (PublicTadpoleDefine.RESOURCE_TYPE.ERD.toString().equals(rmDAO.getResource_types())) {
                    if (userDB != null && DBDefine.MONGODB_DEFAULT == userDB.getDBDefine()) {
                        MongoDBERDViewAction ea = new MongoDBERDViewAction();
                        ea.run(ad);
                    } else {
                        RDBERDViewAction ea = new RDBERDViewAction();
                        ea.run(ad);
                    }
                } else if (PublicTadpoleDefine.RESOURCE_TYPE.SQL.toString().equals(rmDAO.getResource_types())) {
                    QueryEditorAction qea = new QueryEditorAction();
                    qea.run(ad);
                }
            } catch (Exception e) {
                logger.error("select api", e); //$NON-NLS-1$
            }
        }
    });
    Tree tree = tvAPIList.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TreeViewerColumn treeViewerColumn = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnUrl = treeViewerColumn.getColumn();
    trclmnUrl.setWidth(150);
    trclmnUrl.setText(Messages.get().URL);

    TreeViewerColumn tvcName = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnDBName = tvcName.getColumn();
    trclmnDBName.setWidth(150);
    trclmnDBName.setText(Messages.get().APIName);

    TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnName = treeViewerColumn_1.getColumn();
    trclmnName.setWidth(150);
    trclmnName.setText(Messages.get().DBName);

    TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(tvAPIList, SWT.NONE);
    TreeColumn trclmnDescription = treeViewerColumn_2.getColumn();
    trclmnDescription.setWidth(300);
    trclmnDescription.setText(Messages.get().Description);

    tvAPIList.setContentProvider(new APIListContentProvider());
    tvAPIList.setLabelProvider(new APIListLabelProvider());

    /////////////////////////////////////////////////////////////////////////////////////////////
    Group grpQuery = new Group(parent, SWT.NONE);
    grpQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grpQuery.setText(Messages.get().DetailItem);
    GridLayout gl_grpQuery = new GridLayout(1, false);
    gl_grpQuery.verticalSpacing = 1;
    gl_grpQuery.horizontalSpacing = 1;
    gl_grpQuery.marginHeight = 1;
    gl_grpQuery.marginWidth = 1;
    grpQuery.setLayout(gl_grpQuery);

    Composite compositeDetail = new Composite(grpQuery, SWT.NONE | SWT.READ_ONLY);
    GridLayout gl_compositeDetail = new GridLayout(7, false);
    gl_compositeDetail.marginHeight = 2;
    gl_compositeDetail.marginWidth = 2;
    gl_compositeDetail.verticalSpacing = 2;
    compositeDetail.setLayout(gl_compositeDetail);
    compositeDetail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Label lblNewLabel = new Label(compositeDetail, SWT.NONE);
    lblNewLabel.setText(Messages.get().Share);

    comboShare = new ComboViewer(compositeDetail, SWT.NONE | SWT.READ_ONLY);
    Combo cShare = comboShare.getCombo();
    cShare.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cShare.setItems(new String[] { "PUBLIC", "PRIVATE" }); //$NON-NLS-1$ //$NON-NLS-2$

    Label lblNewLabel_1 = new Label(compositeDetail, SWT.NONE);
    lblNewLabel_1.setText(Messages.get().Title);

    textTitle = new Text(compositeDetail, SWT.BORDER);
    textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnSave = new Button(compositeDetail, SWT.NONE);
    btnSave.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (rmDAO == null)
                return;

            if (!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm,
                    Messages.get().RESTFulAPIManagerEditor_22))
                return;

            try {
                String share_type = comboShare.getCombo().getText();
                share_type = (share_type == null || "".equals(share_type)) ? "PUBLIC" : share_type; //$NON-NLS-1$ //$NON-NLS-2$
                rmDAO.setShared_type(share_type);
                rmDAO.setName(textTitle.getText());
                rmDAO.setDescription(textDescription.getText());
                rmDAO.setRestapi_yesno(comboSupportAPI.getText());
                rmDAO.setRestapi_uri(textAPIURL.getText());

                if (!isValid(rmDAO))
                    return;

                try {
                    TadpoleSystem_UserDBResource.userDBResourceDupUpdate(userDB, rmDAO);
                } catch (Exception ee) {
                    logger.error("Resource validate", ee); //$NON-NLS-1$
                    MessageDialog.openError(null, Messages.get().Error, ee.getMessage()); //$NON-NLS-1$
                    return;
                }

                if (comboSupportAPI.getText().equals(PublicTadpoleDefine.YES_NO.YES.name())
                        && "".equals(rmDAO.getRestapi_key())) { //$NON-NLS-1$
                    rmDAO.setRestapi_key(Utils.getUniqueID());
                }

                TadpoleSystem_UserDBResource.updateResourceHeader(rmDAO);
                tvAPIList.refresh(rmDAO, true);

                MessageDialog.openInformation(getSite().getShell(), Messages.get().Confirm,
                        Messages.get().RESTFulAPIManagerEditor_27);
            } catch (Exception e1) {
                logger.error("save resource", e1); //$NON-NLS-1$
                MessageDialog.openError(getSite().getShell(), Messages.get().Error,
                        Messages.get().RESTFulAPIManagerEditor_30 + e1.getMessage());
            }
        }

        /**
         * is valid
         * @return
         */
        private boolean isValid(ResourceManagerDAO dao) {
            int len = StringUtils.trimToEmpty(textTitle.getText()).length();
            if (len < 3) {
                MessageDialog.openWarning(null, Messages.get().Warning,
                        Messages.get().RESTFulAPIManagerEditor_31); //$NON-NLS-1$
                textTitle.setFocus();
                return false;
            }

            // sql type 
            if (dao.getResource_types().equals(RESOURCE_TYPE.SQL.name())) {
                if (PublicTadpoleDefine.YES_NO.YES.name().equals(comboSupportAPI.getText())) {
                    String strAPIURI = textAPIURL.getText().trim();

                    if (strAPIURI.equals("")) { //$NON-NLS-1$
                        MessageDialog.openWarning(getSite().getShell(), Messages.get().Warning,
                                Messages.get().RESTFulAPIManagerEditor_34);
                        textAPIURL.setFocus();
                        return false;
                    }

                    // check valid url. url pattern is must be /{parent}/{child}
                    if (!RESTfulAPIUtils.validateURL(textAPIURL.getText())) {
                        MessageDialog.openWarning(getSite().getShell(), Messages.get().Warning,
                                Messages.get().RESTFulAPIManagerEditor_36);

                        textAPIURL.setFocus();
                        return false;
                    }
                }
            }

            return true;
        }
    });
    btnSave.setText(Messages.get().Save);

    //      Button btnDelete = new Button(composite, SWT.NONE);
    //      btnDelete.addSelectionListener(new SelectionAdapter() {
    //         @Override
    //         public void widgetSelected(SelectionEvent e) {
    //            if (tableViewer.getSelection().isEmpty()) return;
    //
    //            if(!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm, "Do you wont to delete?")) return;
    //            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
    //            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();
    //
    //            // ? ?  (?)?   ? ? dao ?   ?
    //            // .
    //            UserDBResourceDAO userDBResource = new UserDBResourceDAO();
    //            userDBResource.setResource_seq((int) dao.getResource_seq());
    //            userDBResource.setName(dao.getRes_title());
    //            userDBResource.setParent(userDB);
    //
    //            try {
    //               TadpoleSystem_UserDBResource.delete(userDBResource);
    //               addUserResouceData(null);
    //            } catch (Exception e1) {
    //               logger.error("Resource delete " + dao.toString(), e1);
    //            }
    //         }
    //      });
    //      btnDelete.setText("Delete");

    Label lblDescription = new Label(compositeDetail, SWT.NONE);
    lblDescription.setText(Messages.get().Description);

    textDescription = new Text(compositeDetail, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 6, 1);
    gd_textDescription.heightHint = 44;
    textDescription.setLayoutData(gd_textDescription);

    Label lblSupportApi = new Label(compositeDetail, SWT.NONE);
    lblSupportApi.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSupportApi.setText(Messages.get().RESTFulAPIManagerEditor_39);

    comboSupportAPI = new Combo(compositeDetail, SWT.READ_ONLY);
    comboSupportAPI.add("YES"); //$NON-NLS-1$
    comboSupportAPI.add("NO"); //$NON-NLS-1$
    comboSupportAPI.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblApiURI = new Label(compositeDetail, SWT.NONE);
    lblApiURI.setText(Messages.get().APIURL);

    textAPIURL = new Text(compositeDetail, SWT.BORDER);
    textAPIURL.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnShowUrl = new Button(compositeDetail, SWT.NONE);
    btnShowUrl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!"".equals(textAPIURL.getText())) { //$NON-NLS-1$
                String strURL = RESTfulAPIUtils.makeURL(textQuery.getText(), textAPIURL.getText());

                TadpoleSimpleMessageDialog dialog = new TadpoleSimpleMessageDialog(getSite().getShell(),
                        Messages.get().RESTFulAPIManagerEditor_44, strURL);
                dialog.open();
            }
        }
    });
    btnShowUrl.setText(Messages.get().RESTFulAPIManagerEditor_45);
    new Label(compositeDetail, SWT.NONE);
    new Label(compositeDetail, SWT.NONE);

    Label lblApiKey = new Label(compositeDetail, SWT.NONE);
    lblApiKey.setText(Messages.get().RESTFulAPIManagerEditor_46);

    textAPIKey = new Text(compositeDetail, SWT.BORDER);
    textAPIKey.setEditable(false);
    textAPIKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Button btnApiExecute = new Button(compositeDetail, SWT.NONE);
    btnApiExecute.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!"".equals(textAPIURL.getText())) { //$NON-NLS-1$
                if (userDB != null & rmDAO != null) {
                    APIServiceDialog dialog = new APIServiceDialog(getSite().getShell(), userDB,
                            textQuery.getText(), rmDAO);
                    dialog.open();
                }
            }
        }
    });
    btnApiExecute.setText(Messages.get().RESTFulAPIManagerEditor_48);

    textQuery = new Text(compositeDetail,
            SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    textQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 7, 1));
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    initUI();

}

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

License:Open Source License

/**
 * //from ww  w .j a v a  2  s.  co  m
 * @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();
}