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

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

Introduction

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

Prototype

public TreeViewerColumn(TreeViewer viewer, TreeColumn column) 

Source Link

Document

Creates a new viewer column for the given TreeViewer on the given TreeColumn .

Usage

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

License:Open Source License

/**
 * Create the composite.// w  ww .j av  a 2s .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 column//from  w w w.  j av a2s  .  c o m
 */
private void createColumn() {
    String[] colNames = { "Group Name", "Email", "Name", "Role", "Approval", "Delete", "Create Time" };
    int[] colSize = { 130, 200, 150, 80, 60, 60, 120 };

    for (int i = 0; i < colSize.length; i++) {
        TreeViewerColumn treeViewerColumn = new TreeViewerColumn(userListViewer, SWT.NONE);
        TreeColumn treeColumn = treeViewerColumn.getColumn();
        treeColumn.setWidth(colSize[i]);
        treeColumn.setText(colNames[i]);
    }
}

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

License:Open Source License

/**
 * Create the composite./* w  w  w.  j av a 2s.  com*/
 * @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 column//from w  w w . j a  va2 s .  com
 */
private void createColumn() {
    String[] colNames = { "Group Name", "Email", "Name", "Role", "Approval", "Delete", "Create Time" }; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    int[] colSize = { 130, 200, 150, 80, 60, 60, 120 };

    for (int i = 0; i < colSize.length; i++) {
        TreeViewerColumn treeViewerColumn = new TreeViewerColumn(userListViewer, SWT.NONE);
        TreeColumn treeColumn = treeViewerColumn.getColumn();
        treeColumn.setWidth(colSize[i]);
        treeColumn.setText(colNames[i]);
    }
}

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

License:Open Source License

/**
 * Create the composite./*  ww  w.ja  va  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.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/*from w w w. j  a  v  a2s . 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

/**
 * treeview create//from   w w  w .  j av a 2s . co  m
 */
private void createTreeColumn() {
    String[] columnName = { "Key", "Value", "Type" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    int[] columnSize = { 170, 300, 170 };

    try {
        // reset column 
        for (int i = 0; i < columnName.length; i++) {
            final TreeViewerColumn treeColumn = new TreeViewerColumn(treeViewerMongo, SWT.LEFT);
            treeColumn.getColumn().setText(columnName[i]);
            treeColumn.getColumn().setWidth(columnSize[i]);
            treeColumn.getColumn().setResizable(true);
            treeColumn.getColumn().setMoveable(false);
            if (isUserAction) {
                if (i == 1)
                    treeColumn.setEditingSupport(
                            new TreeViewerEditingSupport(userDB, collectionName, treeViewerMongo));
            }
        } // end for

    } catch (Exception e) {
        logger.error("MongoDB Tree view Editor", e); //$NON-NLS-1$
    }
}

From source file:com.hangum.tadpole.mongodb.core.dialogs.collection.index.NewIndexDialog.java

License:Open Source License

/**
 * mongodb collection column/*www.  j a  v a  2  s.co m*/
 * @param treeColumnViewer2
 */
private void createTableMongoColumne() {
    String[] columnName = { "Field", "Type", "Key", "Select Index" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    int[] columnSize = { 200, 170, 40, 100 };

    try {
        // reset column 
        for (int i = 0; i < columnName.length; i++) {
            final TreeViewerColumn tableColumn = new TreeViewerColumn(treeColumnViewer, SWT.LEFT);
            tableColumn.getColumn().setText(columnName[i]);
            tableColumn.getColumn().setWidth(columnSize[i]);
            tableColumn.getColumn().setResizable(true);
            tableColumn.getColumn().setMoveable(false);
            if (i == 3)
                tableColumn.setEditingSupport(new FieldIndexEditorSupport(treeColumnViewer, userDB));
        } // end for

    } catch (Exception e) {
        logger.error("MongoDB Table Editor", e); //$NON-NLS-1$
    }
}

From source file:com.hangum.tadpole.mongodb.core.dialogs.resultview.FindOneDetailComposite.java

License:Open Source License

/**
 * treeview create//from   w  w  w.jav  a  2s .  co  m
 */
private void createTreeColumn() {
    String[] columnName = { "Key", "Value", "Type" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    int[] columnSize = { 170, 200, 140 };

    try {
        int columnViewCnt = 2;
        if (isTypeShowing)
            columnViewCnt = 3;
        for (int i = 0; i < columnViewCnt; i++) {
            int columnAlign = SWT.LEFT;
            if (i == 1)
                columnAlign = SWT.RIGHT;

            final TreeViewerColumn tableColumn = new TreeViewerColumn(treeViewerMongo, columnAlign);
            tableColumn.getColumn().setText(columnName[i]);
            tableColumn.getColumn().setWidth(columnSize[i]);
            tableColumn.getColumn().setResizable(true);
            tableColumn.getColumn().setMoveable(false);
        } // end for

    } catch (Exception e) {
        logger.error("MongoDB Tree view Editor", e); //$NON-NLS-1$
    }
}

From source file:com.hangum.tadpole.mongodb.core.editors.dbInfos.comosites.CollectionInformationComposite.java

License:Open Source License

/**
 * make collection columns//from   www .  j a  va  2s. com
 * 
 */
private void createTableColumn() {
    String[] columnName = { "Name", "Rows", "Size", "Storage", "Index", "Last Extent Size", "AvgObj", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
            "Padding" }; //$NON-NLS-1$
    int[] columnSize = { 200, 100, 100, 100, 100, 100, 100, 100 };
    int[] align = { SWT.LEFT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT };

    try {
        // reset column 
        for (int i = 0; i < columnName.length; i++) {
            final int index = i;
            final TreeViewerColumn tableColumn = new TreeViewerColumn(treeViewerCollections, align[i]);
            tableColumn.getColumn().setText(columnName[i]);
            tableColumn.getColumn().setWidth(columnSize[i]);
            tableColumn.getColumn().setResizable(true);
            tableColumn.getColumn().setMoveable(false);

            tableColumn.getColumn().addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    collectionSorter.setColumn(index);

                    treeViewerCollections.getTree()
                            .setSortDirection(treeViewerCollections.getTree().getSortDirection());
                    treeViewerCollections.getTree().setSortColumn(tableColumn.getColumn());
                    treeViewerCollections.refresh();
                }
            });
        } // end for

    } catch (Exception e) {
        logger.error("MongoDB Table Editor", e); //$NON-NLS-1$
    }
}