Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:com.hangum.tadpole.login.core.dialog.LoginDialog.java

License:Open Source License

/**
 * initialize ui//from   ww  w.  j ava2  s.  co m
 */
private void initUI() {
    initCookieData();
    if ("".equals(textEMail.getText())) {
        textEMail.setFocus();
    } else {
        textPasswd.setFocus();
    }

    // check support browser
    if (!RequestInfoUtils.isSupportBrowser()) {
        String errMsg = LoginDialogMessages.get().LoginDialog_30 + RequestInfoUtils.getUserBrowser() + ".\n" //$NON-NLS-1$
                + LoginDialogMessages.get().UserInformationDialog_5 + "\n" //$NON-NLS-1$
                + LoginDialogMessages.get().LoginDialog_lblNewLabel_text; //$NON-NLS-3$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, errMsg);
    }
}

From source file:com.hangum.tadpole.login.core.otp.GoogleOTPLoginDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String strOTPCode = StringUtils.trim(textOTPCode.getText());
    if (!NumberUtils.isNumber(strOTPCode)) {
        textOTPCode.setFocus();/*from ww w  . java  2  s  . co  m*/
        MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, Messages.get().OTPLoginDialog_3); //$NON-NLS-1$
        return;
    }

    setIntOTPCode(NumberUtils.toInt(strOTPCode));

    super.okPressed();
}

From source file:com.hangum.tadpole.manager.core.dialogs.api.UserAPIServiceDialog.java

License:Open Source License

/**
 * initialize ui/*from w ww .j av  a 2s  .c om*/
 * 
 * @param strArgument
 */
private void initData(String strArgument) {

    try {
        String strAPIKEY = textAPIKey.getText();
        if (strAPIKEY.equals("")) { //$NON-NLS-1$
            MessageDialog.openWarning(getShell(), Messages.get().Warning,
                    Messages.get().UserAPIServiceDialog_10);
            textAPIKey.setFocus();

            return;
        }

        Timestamp timstampStart = new Timestamp(System.currentTimeMillis());
        UserDBDAO userDB = null;
        UserDBResourceDAO userDBResourceDao = TadpoleSystem_UserDBResource.findAPIKey(strAPIKEY);
        if (userDBResourceDao == null) {
            MessageDialog.openInformation(getShell(), Messages.get().Confirm,
                    Messages.get().UserAPIServiceDialog_12);
        } else {

            String strSQL = TadpoleSystem_UserDBResource.getResourceData(userDBResourceDao);
            if (logger.isDebugEnabled())
                logger.debug(userDBResourceDao.getName() + ", " + strSQL); //$NON-NLS-1$

            // find db
            userDB = TadpoleSystem_UserDBQuery.getUserDBInstance(userDBResourceDao.getDb_seq());

            String strReturnResult = ""; //$NON-NLS-1$

            String strSQLs = RESTfulAPIUtils.makeTemplateTOSQL("APIServiceDialog", strSQL, strArgument); //$NON-NLS-1$
            // ? ? .
            for (String strTmpSQL : strSQLs.split(PublicTadpoleDefine.SQL_DELIMITER)) {
                if (StringUtils.trim(strTmpSQL).equals(""))
                    continue;
                NamedParameterDAO dao = NamedParameterUtil.parseParameterUtils(userDB, strTmpSQL, strArgument);
                if (QueryUtils.RESULT_TYPE.JSON.name().equalsIgnoreCase(comboResultType.getText())) {
                    strReturnResult += getSelect(userDB, dao.getStrSQL(), dao.getListParam()) + ","; //$NON-NLS-1$
                } else {
                    strReturnResult += getSelect(userDB, dao.getStrSQL(), dao.getListParam());
                }
            }

            if (QueryUtils.RESULT_TYPE.JSON.name().equalsIgnoreCase(comboResultType.getText())) {
                strReturnResult = "[" + StringUtils.removeEnd(strReturnResult, ",") + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            }

            textResult.setText(strReturnResult);
        }

    } catch (Exception e) {
        logger.error("api exception", e); //$NON-NLS-1$

        MessageDialog.openError(getShell(), Messages.get().Error,
                Messages.get().APIServiceDialog_11 + "\n" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:com.hangum.tadpole.manager.core.dialogs.users.DetailUserAndDBRoleDialog.java

License:Open Source License

@Override
protected void okPressed() {
    if ("NONE".equals(comboRoleType.getText())) { //$NON-NLS-1$
        MessageDialog.openWarning(getShell(), Messages.get().Warning,
                Messages.get().DetailUserAndDBRoleDialog_8);
        comboRoleType.setFocus();// ww w . j  a  v  a  2 s .c o  m
        return;
    }

    // ?  ?  ?  . 
    try {
        if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().FindUserDialog_4))
            return;

        Calendar calStart = Calendar.getInstance();
        calStart.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0);

        Calendar calEnd = Calendar.getInstance();
        calEnd.set(dateTimeEndDay.getYear(), dateTimeEndDay.getMonth(), dateTimeEndDay.getDay(),
                dateTimeEndTime.getHours(), dateTimeEndTime.getMinutes(), 00);

        userDBRole.setRole_id(comboRoleType.getText());
        userDBRole.setTerms_of_use_starttime(new Timestamp(calStart.getTimeInMillis()));
        userDBRole.setTerms_of_use_endtime(new Timestamp(calEnd.getTimeInMillis()));
        TadpoleSystem_UserRole.updateTadpoleUserDBRole(userDBRole);

        MessageDialog.openInformation(getShell(), Messages.get().Confirm,
                Messages.get().DetailUserAndDBRoleDialog_11);

    } catch (Exception e) {
        logger.error("Is DB add role error.", e); //$NON-NLS-1$
        MessageDialog.openError(getShell(), Messages.get().Error,
                Messages.get().DetailUserAndDBRoleDialog_14 + e.getMessage());

        return;
    }

    super.okPressed();
}

From source file:com.hangum.tadpole.manager.core.dialogs.users.FindUserAndDBRoleDialog.java

License:Open Source License

@Override
protected void okPressed() {
    IStructuredSelection iss = (IStructuredSelection) tableViewer.getSelection();
    if (iss.isEmpty())
        return;/*from w  w  w  .jav  a2 s . com*/
    UserDAO userDAO = (UserDAO) iss.getFirstElement();

    if ("NONE".equals(comboRoleType.getText())) { //$NON-NLS-1$
        MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().FindUserAndDBRoleDialog_6);
        comboRoleType.setFocus();
        return;
    }

    // ?  ?  ?  . 
    try {
        boolean isAddDBRole = TadpoleSystem_UserRole.isDBAddRole(userDBDao, userDAO);
        if (isAddDBRole) {
            if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().FindUserDialog_4))
                return;

            Calendar calStart = Calendar.getInstance();
            calStart.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0);

            Calendar calEnd = Calendar.getInstance();
            calEnd.set(dateTimeEndDay.getYear(), dateTimeEndDay.getMonth(), dateTimeEndDay.getDay(),
                    dateTimeEndTime.getHours(), dateTimeEndTime.getMinutes(), 00);

            tadpoleUserRoleDao = TadpoleSystem_UserRole.insertTadpoleUserDBRole(userDAO.getSeq(),
                    userDBDao.getSeq(), comboRoleType.getText(), "*", //$NON-NLS-1$
                    new Timestamp(calStart.getTimeInMillis()), new Timestamp(calEnd.getTimeInMillis()));

            MessageDialog.openInformation(getShell(), Messages.get().Confirm,
                    Messages.get().FindUserAndDBRoleDialog_10);

            //            super.okPressed();
        } else {
            MessageDialog.openWarning(getShell(), Messages.get().Warning,
                    Messages.get().FindUserAndDBRoleDialog_12);
        }
    } catch (Exception e) {
        logger.error(Messages.get().RoleType, e);
        MessageDialog.openError(getShell(), Messages.get().Error,
                Messages.get().FindUserAndDBRoleDialog_15 + e.getMessage());
    }

}

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

License:Open Source License

/**
 * delete user// w ww  .j  ava2 s. c om
 */
private void deleteUser() {
    IStructuredSelection ss = (IStructuredSelection) userListViewer.getSelection();
    if (ss != null) {
        UserGroupAUserDAO userGroupAuser = (UserGroupAUserDAO) ss.getFirstElement();
        if (userGroupAuser.getEmail().equals(SessionManager.getEMAIL())) {
            MessageDialog.openWarning(getShell(), "Warning", Messages.UserListComposite_16); //$NON-NLS-1$
        } else {
            if (MessageDialog.openConfirm(getShell(), Messages.UserListComposite_17,
                    Messages.UserListComposite_18)) {
                try {
                    TadpoleSystem_UserRole.withdrawalUserRole(SessionManager.getGroupSeq(),
                            userGroupAuser.getSeq());
                    initUI();
                } catch (Exception e) {
                    logger.error("withdrawal group user", e); //$NON-NLS-1$
                }
            }
        }
    }
}

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

License:Open Source License

@Override
protected void okPressed() {
    if ("".equals(textTableName.getText())) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning, "Check table name.");
        textTableName.setFocus();//from w  ww. java  2s  .co  m
        return;
    }

    if ("".equals(textColumnNames.getText())) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning, "Check column name.");
        textColumnNames.setFocus();
        return;
    }

    // later check real table name

    // 

    returnObjectDao.setType("SELECT");
    returnObjectDao.setAccess_seq(dbAccessDetail.getSeq());
    returnObjectDao.setObj_name(textTableName.getText());
    if (btnDoNotUseObject.getSelection())
        returnObjectDao.setDontuse_object("YES");
    else
        returnObjectDao.setDontuse_object("NO");

    returnObjectDao.setDetail_obj(textColumnNames.getText());

    super.okPressed();
}

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

License:Open Source License

/**
 * search//from ww  w  . j  a  v a  2  s .  c om
 */
private void search() {
    listSQLHistory.clear();

    // Is user DB empty.
    if ("".equals(comboUserName.getText()) || "".equals(comboDisplayName.getText())) {
        MessageDialog.openWarning(getSite().getShell(), "Warning",
                "If do not have user or database, can't be viewed.");
        return;
    }

    // check all user
    int user_seq;
    if (comboUserName.getEnabled()) {
        user_seq = (Integer) comboUserName.getData(comboUserName.getText());
    } else {
        user_seq = -1;
    }

    // check all db
    int db_seq;
    if (comboDisplayName.getEnabled()) {
        searchUserDBDAO = (UserDBDAO) comboDisplayName.getData(comboDisplayName.getText());
        db_seq = searchUserDBDAO.getSeq();
    } else {
        searchUserDBDAO = null;
        db_seq = -1;
    }

    Calendar cal = Calendar.getInstance();
    cal.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0);
    long startTime = cal.getTimeInMillis();

    cal.set(dateTimeEnd.getYear(), dateTimeEnd.getMonth(), dateTimeEnd.getDay(), 23, 59, 59);
    long endTime = cal.getTimeInMillis();

    int duringExecute = Integer.parseInt(textMillis.getText());

    try {
        listSQLHistory = TadpoleSystem_ExecutedSQL.getExecuteQueryHistoryDetail(user_seq, db_seq, startTime,
                endTime, duringExecute);
        tvList.setInput(listSQLHistory);
        tvList.refresh();
    } catch (Exception ee) {
        logger.error("Executed SQL History call", ee); //$NON-NLS-1$
    }
    btnShowQueryEditor.setEnabled(false);
}

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//ww  w . j  a  v a  2s.  com
        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.preference.dialogs.user.ChangePasswordDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String strPasswdComplexity = GetAdminPreference.getPasswdComplexity();
    int intLengthLimit = Integer.parseInt(GetAdminPreference.getPasswdLengthLimit());

    try {// www. j  av a  2  s.c om
        TadpoleSystem_UserQuery.login(SessionManager.getEMAIL(), textOldPassword.getText());
    } catch (Exception e) {
        textOldPassword.setFocus();
        MessageDialog.openWarning(getShell(), CommonMessages.get().Warning,
                String.format(CommonMessages.get().IsIncorrect, Messages.get().OldPassword));
        return;
    }

    String.format(CommonMessages.get().ValueIsLessThanOrOverThan, Messages.get().Password, intLengthLimit,
            "30");

    String strPasswd = textPassword.getText();
    String strRePasswd = textRePassword.getText();

    if ("".equals(strPasswd)) { //$NON-NLS-1$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                Messages.get().EnterYourPasswd);
        textPassword.setFocus();
        return;
    } else if (!ValidChecker.isPasswordLengthChecker(intLengthLimit, strPasswd)) {
        MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, String.format(
                CommonMessages.get().ValueIsLessThanOrOverThan, Messages.get().Password, intLengthLimit, "30")); //$NON-NLS-1$
        textPassword.setFocus();
        return;
    } else if (!strPasswd.equals(strRePasswd)) {
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                Messages.get().PasswordDoNotMatch);
        textPassword.setFocus();
        return;
    } else if ("YES".equals(strPasswdComplexity)) {
        if (!ValidChecker.isPasswordChecker(strPasswd)) {
            MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                    Messages.get().inValidComplextyPasswd);
            textPassword.setFocus();
            return;
        }
    }

    if (MessageDialog.openConfirm(getShell(), CommonMessages.get().Confirm,
            CommonMessages.get().doYouWantTosave)) {
        UserDAO userDAO = new UserDAO();
        userDAO.setSeq(SessionManager.getUserSeq());
        userDAO.setPasswd(textPassword.getText());

        try {
            TadpoleSystem_UserQuery.updateUserPassword(userDAO);
            MessageDialog.openInformation(null, CommonMessages.get().Confirm, Messages.get().ChangedPassword);
        } catch (Exception e) {
            logger.error("Changing password", e); //$NON-NLS-1$
            MessageDialog.openError(getShell(), CommonMessages.get().Error, e.getMessage()); //$NON-NLS-1$
        }
    }

    super.okPressed();
}