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

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

Introduction

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

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

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  2s . co  m*/
        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();
}

From source file:com.hangum.tadpole.preference.dialogs.user.ChangeUsePersonalToGrouprDialog.java

License:Open Source License

@Override
protected void okPressed() {
    String strEmail = StringUtils.trimToEmpty(textEMail.getText());
    String passwd = StringUtils.trimToEmpty(textPasswd.getText());
    String rePasswd = StringUtils.trimToEmpty(textRePasswd.getText());
    String name = StringUtils.trimToEmpty(textName.getText());
    String strIp = StringUtils.trimToEmpty(textAllowIP.getText());

    if (!validation(strEmail, passwd, rePasswd, name, strIp))
        return;/*from w  w  w  .  ja  v a  2  s .c  om*/

    if (MessageDialog.openConfirm(getShell(), Messages.get().Confirm,
            Messages.get().ChangeUsePersonalToGrouprDialog_7)) {
        UserDAO user = new UserDAO();
        user.setSeq(userDAO.getSeq());
        user.setEmail(strEmail);
        user.setPasswd(passwd);
        user.setName(name);
        user.setAllow_ip(strIp);

        try {
            TadpoleSystem_UserQuery.updateUserPersonToGroup(user);
            TadpoleSystemQuery.updateSystemInformation(PublicTadpoleDefine.SYSTEM_USE_GROUP.GROUP.name());

            MessageDialog.openInformation(getShell(), Messages.get().Confirm,
                    Messages.get().ChangeUsePersonalToGrouprDialog_9);
            TadpoleApplicationContextManager.initSystem();
            SessionManager.logout();

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

            Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$
            ExceptionDetailsErrorDialog.openError(getShell(), Messages.get().Error, "User Info update", //$NON-NLS-1$
                    errStatus); //$NON-NLS-2$

            return;
        }

        super.okPressed();
    } else {
        return;
    }
}

From source file:com.hangum.tadpole.preference.ui.SecurityCredentialPreference.java

License:Open Source License

/**
 * Create contents of the preference page.
 * @param parent/*from  w w  w  .j  a  v  a2s .  c o m*/
 */
@Override
public Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(2, false));

    Label lblUse = new Label(container, SWT.NONE);
    lblUse.setText(Messages.get().SecurityCredentialPreference_0);

    comboIsUse = new Combo(container, SWT.READ_ONLY);
    comboIsUse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (PublicTadpoleDefine.YES_NO YESNO : PublicTadpoleDefine.YES_NO.values()) {
        comboIsUse.add(YESNO.name());
    }
    comboIsUse.select(0);

    Label lblAccesskey = new Label(container, SWT.NONE);
    lblAccesskey.setText(Messages.get().SecurityCredentialPreference_1);

    textAccessKey = new Text(container, SWT.BORDER);
    textAccessKey.setEditable(false);
    textAccessKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblSecretKey = new Label(container, SWT.NONE);
    lblSecretKey.setText(Messages.get().SecurityCredentialPreference_2);

    textSecretKey = new Text(container, SWT.BORDER);
    textSecretKey.setEditable(false);
    textSecretKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(container, SWT.NONE);

    Button btnGenerateKey = new Button(container, SWT.NONE);
    btnGenerateKey.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            if (!MessageDialog.openConfirm(getShell(), Messages.get().SecurityCredentialPreference_3,
                    Messages.get().SecurityCredentialPreference_4))
                return;

            textAccessKey.setText(Utils.getUniqueID());
            textSecretKey.setText(Utils.getUniqueID());
        }
    });
    btnGenerateKey.setText(Messages.get().SecurityCredentialPreference_5);

    initDefaultValue();

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

    return container;
}

From source file:com.hangum.tadpole.preference.ui.UserInfoPerference.java

License:Open Source License

/**
 * Create contents of the preference page.
 * @param parent/*from ww w  . j ava2 s . c  o m*/
 */
@Override
public Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(2, false));

    //      Label lblGroupName = new Label(container, SWT.NONE);
    //      lblGroupName.setText(Messages.UserInfoPerference_1);
    //      
    //      textGroupName = new Text(container, SWT.BORDER);
    //      textGroupName.setEnabled(false);
    //      textGroupName.setEditable(false);
    //      textGroupName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    //      textGroupName.setText(SessionManager.getGroupName());

    Label lblEmail = new Label(container, SWT.NONE);
    lblEmail.setText(Messages.UserInfoPerference_2);

    textEmail = new Text(container, SWT.BORDER);
    textEmail.setEnabled(false);
    textEmail.setEditable(false);
    textEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textEmail.setText(SessionManager.getEMAIL());

    Label lblName = new Label(container, SWT.NONE);
    lblName.setText(Messages.UserInfoPerference_5);

    textName = new Text(container, SWT.BORDER);
    textName.setEnabled(false);
    textName.setEditable(false);
    textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textName.setText(SessionManager.getName());

    Label lblPassword = new Label(container, SWT.NONE);
    lblPassword.setText(Messages.UserInfoPerference_3);

    textPassword = new Text(container, SWT.BORDER | SWT.PASSWORD);
    textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textPassword.setText(SessionManager.getPassword());
    // Because existed password do not decode, to save new password must clear text.
    textPassword.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent event) {
        }

        @Override
        public void focusGained(FocusEvent event) {
            textPassword.setText(""); //$NON-NLS-1$
            textRePassword.setText(""); //$NON-NLS-1$
        }
    });

    Label lblRePassword = new Label(container, SWT.NONE);
    lblRePassword.setText(Messages.UserInfoPerference_4);

    textRePassword = new Text(container, SWT.BORDER | SWT.PASSWORD);
    textRePassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textRePassword.setText(SessionManager.getPassword());
    // Because existed password do not decode, to save new password must clear text.
    textRePassword.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent event) {
        }

        @Override
        public void focusGained(FocusEvent event) {
            textRePassword.setText(""); //$NON-NLS-1$
        }
    });

    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    Label lblPasswordDescription = new Label(container, SWT.NONE);
    lblPasswordDescription.setText(Messages.UserInfoPerference_11);
    lblPasswordDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Label lblQuestion = new Label(container, SWT.NONE);
    lblQuestion.setText(Messages.UserInfoPerference_12);

    comboQuestion = new Combo(container, SWT.READ_ONLY);
    comboQuestion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (SecurityHint q : PublicTadpoleDefine.SecurityHint.values()) {
        comboQuestion.add(q.toString(), q.getOrderIndex());
        comboQuestion.setData(q.getOrderIndex() + q.toString(), q.getKey());
    }

    Label lblAnswer = new Label(container, SWT.NONE);
    lblAnswer.setText(Messages.UserInfoPerference_13);

    textAnswer = new Text(container, SWT.BORDER);
    textAnswer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textAnswer.setText(CipherManager.getInstance().decryption(SessionManager.getSecurityAnswer()));

    // because of reference of textAnswer
    comboQuestion.select(0);

    // google auth
    Group grpGoogleAuth = new Group(container, SWT.NONE);
    grpGoogleAuth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    grpGoogleAuth.setText(Messages.UserInfoPerference_grpGoogleAuth_text);
    grpGoogleAuth.setLayout(new GridLayout(2, false));

    btnGetOptCode = new Button(grpGoogleAuth, SWT.CHECK);
    btnGetOptCode.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            generateGoogleOTP();
        }
    });
    if (PublicTadpoleDefine.YES_NO.YES.toString().equals(SessionManager.getUseOTP())) {
        btnGetOptCode.setSelection(true);
    }
    btnGetOptCode.setText(Messages.UserInfoPerference_btnGoogleOtp_text_1);
    new Label(grpGoogleAuth, SWT.NONE);

    Label lblSecretKey = new Label(grpGoogleAuth, SWT.NONE);
    lblSecretKey.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSecretKey.setText(Messages.UserInfoPerference_lblSecretKey_text_1);

    textSecretKey = new Text(grpGoogleAuth, SWT.BORDER);
    textSecretKey.setText(SessionManager.getOTPSecretKey());
    textSecretKey.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblQrcodeUrl = new Label(grpGoogleAuth, SWT.NONE);
    lblQrcodeUrl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblQrcodeUrl.setText("<a href='https://code.google.com/p/google-authenticator/' target='_blank'>" //$NON-NLS-1$
            + Messages.UserInfoPerference_lblQrcodeUrl_text + "</a>"); //$NON-NLS-1$
    lblQrcodeUrl.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    textQRCodeURL = new Text(grpGoogleAuth, SWT.BORDER | SWT.WRAP | SWT.MULTI);
    GridData gd_textQRCodeURL = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_textQRCodeURL.heightHint = 50;
    textQRCodeURL.setLayoutData(gd_textQRCodeURL);

    if (btnGetOptCode.getSelection()) {
        String strEmail = textEmail.getText();
        String[] strUserDomain = StringUtils.split(strEmail, "@"); //$NON-NLS-1$
        String strURL = GoogleAuthManager.getInstance().getURL(strUserDomain[0], strUserDomain[1], secretKey);

        textQRCodeURL.setText(strURL);
    }

    Label lblOptCode = new Label(grpGoogleAuth, SWT.NONE);
    lblOptCode.setText("OTP Code");
    lblOptCode.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));

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

    Button buttonWithdrawal = new Button(container, SWT.NONE);
    buttonWithdrawal.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (MessageDialog.openConfirm(null, "Confirm", Messages.UserInfoPerference_9)) { //$NON-NLS-1$
                try {
                    TadpoleSystem_UserRole.withdrawal(SessionManager.getSeq());

                    TadpoleSQLTransactionManager.executeRollback(SessionManager.getEMAIL());
                    SessionManager.logout();
                } catch (Exception e1) {
                    logger.error("user withdrawal", e1); //$NON-NLS-1$
                }
            }

        }
    });
    buttonWithdrawal.setText(Messages.UserInfoPerference_button_text);
    new Label(container, SWT.NONE);

    String questionKey = CipherManager.getInstance().decryption(SessionManager.getSecurityQuestion());
    if (null != questionKey && !"".equals(questionKey.trim())) { //$NON-NLS-1$
        try {
            SecurityHint question = PublicTadpoleDefine.SecurityHint.valueOf(questionKey);
            comboQuestion.select(question.getOrderIndex());
        } catch (IllegalStateException e) {
            // skip
        }
    }

    return container;
}

From source file:com.hangum.tadpole.rdb.core.actions.connections.DeleteDBAction.java

License:Open Source License

@Override
public void run(IAction action) {

    final UserDBDAO userDB = (UserDBDAO) sel.getFirstElement();

    if (!MessageDialog.openConfirm(null, "Confirm", //$NON-NLS-1$
            "[" + userDB.getDisplay_name() + "] " + Messages.DeleteDBAction_1))
        return;/*from   ww w.j a  v a 2s.  co  m*/

    // editor 
    MainEditorInput mei = new MainEditorInput(userDB);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editroRefreence = page.getEditorReferences();

    String titleName = mei.getName();
    for (IEditorReference iEditorReference : editroRefreence) {
        if (iEditorReference.getTitle().indexOf(titleName) != -1) {
            page.closeEditor(iEditorReference.getEditor(false), true);
        }
    }

    // connection view  .
    final ManagerViewer managerView = (ManagerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().findView(ManagerViewer.ID);
    Display.getCurrent().asyncExec(new Runnable() {
        @Override
        public void run() {
            try {
                managerView.init();
            } catch (Exception e) {
            }
        }
    }); // end display

    // object view .
    final ExplorerViewer explorerView = (ExplorerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().findView(ExplorerViewer.ID);
    Display.getCurrent().asyncExec(new Runnable() {
        @Override
        public void run() {
            explorerView.initObjectHead(null);
        }
    }); // end display

    // realdb disconnect
    try {
        TadpoleSystem_UserDBQuery.removeUserDB(userDB.getSeq());
        TadpoleSQLManager.removeInstance(userDB);
    } catch (Exception e) {
        logger.error("disconnection exception", e);

        Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$
        ExceptionDetailsErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "Error", "Disconnection Exception", errStatus); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:com.hangum.tadpole.rdb.core.actions.connections.ext.DownloadSQLiteDBAction.java

License:Open Source License

@Override
public void run(IAction action) {
    final UserDBDAO userDB = (UserDBDAO) sel.getFirstElement();

    if (!MessageDialog.openConfirm(null, "Confirm", //$NON-NLS-1$
            "[" + userDB.getDisplay_name() + "] " + "Do you want download?"))
        return;//from w  ww .  j  a v  a  2 s.  co m

    ManagerViewer view = (ManagerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .findView(ManagerViewer.ID);
    view.download(userDB);
}

From source file:com.hangum.tadpole.rdb.core.actions.erd.ERDDeleteAction.java

License:Open Source License

@Override
public void run(IAction action) {
    UserDBResourceDAO userDB = (UserDBResourceDAO) sel.getFirstElement();

    if (MessageDialog.openConfirm(null, Messages.ERDDeleteAction_0, Messages.ERDDeleteAction_1))
        run(userDB);//from  w  w w. jav  a  2 s .  c o  m
}

From source file:com.hangum.tadpole.rdb.core.actions.global.DeleteResourceAction.java

License:Open Source License

@Override
public void run() {
    UserDBResourceDAO userResourceDB = (UserDBResourceDAO) iss.getFirstElement();
    if (!MessageDialog.openConfirm(window.getShell(), Messages.DeleteResourceAction_3,
            Messages.DeleteResourceAction_4))
        return;//from  ww  w  .  j  av  a 2s . co  m

    RDBERDDeleteAction erdDelete = new RDBERDDeleteAction();
    erdDelete.run(userResourceDB);
}

From source file:com.hangum.tadpole.rdb.core.actions.global.ExitAction.java

License:Open Source License

@Override
public void run() {

    if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ExitAction_2, Messages.ExitAction_3)) {

        // https://github.com/hangum/TadpoleForDBTools/issues/157 ( ? ?? ?  ?? .)
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorReference[] references = page.getEditorReferences();
        for (IEditorReference iEditorReference : references) {
            page.closeEditor(iEditorReference.getEditor(false), true);
        }/*from   w  w w . j  ava  2  s.  c o m*/

        //         // standalone ??  .
        //         if(ApplicationArgumentUtils.isStandaloneMode()) {
        //            beforeLogoutAction();
        //            System.exit(0);
        //         //  ?   .
        //         } else {
        beforeLogoutAction();
        SessionManager.logout();
        //         }
    }
}

From source file:com.hangum.tadpole.rdb.core.actions.object.mongodb.ObjectMongodbReIndexAction.java

License:Open Source License

@Override
public void run(IStructuredSelection selection, UserDBDAO userDB, DB_ACTION actionType) {
    String originalName = selection.getFirstElement().toString();

    if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Confirm", //$NON-NLS-1$
            Messages.ObjectMongodbReIndexAction_2)) {
        try {/*ww  w  .ja v  a 2 s  .co m*/
            MongoDBQuery.reIndexCollection(userDB, originalName);

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

            Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$
            ExceptionDetailsErrorDialog.openError(null, "Error", "Rename Collection", errStatus); //$NON-NLS-1$ //$NON-NLS-2$
        }

    }

}