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.importexport.core.dialogs.CsvToRDBImportDialog.java

License:Open Source License

/**
 * validator//ww w . ja  v  a2  s  .  com
 * 
 * @return
 */
private boolean validate() {
    if ("".equals(textTableName.getText())) { //$NON-NLS-1$
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().CsvToRDBImportDialog_19);
        textTableName.setFocus();
        return false;
    }

    File[] arryFiles = receiver.getTargetFiles();
    if (arryFiles.length == 0) {
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().CsvToRDBImportDialog_21);
        return false;
    }

    if ("".equals(textSeprator.getText())) { //$NON-NLS-1$
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().CsvToRDBImportDialog_24);
        textSeprator.setFocus();
        return false;
    }

    return true;
}

From source file:com.hangum.tadpole.importexport.core.dialogs.SQLToDBImportDialog.java

License:Open Source License

private void insert() throws IOException {
    int ret;/*from w ww  . j  ava  2s. c o m*/
    BOMInputStream bomInputStream = null;

    File[] arryFiles = receiver.getTargetFiles();
    if (arryFiles.length == 0) {
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().CsvToRDBImportDialog_21);
        return;
    }

    if (!MessageDialog.openConfirm(null, Messages.get().Confirm,
            Messages.get().SQLToDBImportDialog_UploadQuestion))
        return;
    bufferBatchResult = new StringBuffer();

    try {
        batchSize = Integer.valueOf(textBatchSize.getText());
    } catch (Exception e) {
        batchSize = 1000;
    }

    File userUploadFile = arryFiles[arryFiles.length - 1];
    try {
        // bom?  charset? ? ?.
        bomInputStream = new BOMInputStream(FileUtils.openInputStream(FileUtils.getFile(userUploadFile)));//`, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE);

        String charsetName = "utf-8"; //$NON-NLS-1$
        String strSQLData = ""; //$NON-NLS-1$
        if (bomInputStream.getBOM() == null) {
            strSQLData = FileUtils.readFileToString(userUploadFile, charsetName);
        } else {
            charsetName = bomInputStream.getBOMCharsetName();
            strSQLData = FileUtils.readFileToString(userUploadFile, charsetName).substring(1);
        }

        String[] strArrySQL = StringUtils.split(strSQLData, textSeprator.getText());
        ret = runSQLExecuteBatch(Arrays.asList(strArrySQL));

        if (ret == 0)
            MessageDialog.openInformation(null, Messages.get().Confirm,
                    Messages.get().SQLToDBImportDialog_StoreData); //$NON-NLS-1$
    } catch (IOException e) {
        logger.error(Messages.get().SQLToDBImportDialog_ReadError, e);
        MessageDialog.openError(null, Messages.get().Confirm,
                Messages.get().SQLToDBImportDialog_LoadException + e.getMessage());

    } catch (Exception e) {
        logger.error(Messages.get().SQLToDBImportDialog_ImportException, e);
        MessageDialog.openError(null, Messages.get().Confirm,
                Messages.get().SQLToDBImportDialog_LoadException + e.getMessage());
    } finally {
        if (bomInputStream != null)
            bomInputStream.close();
    }
}

From source file:com.hangum.tadpole.importexport.core.dialogs.SQLToDBImportDialog.java

License:Open Source License

private void saveLog() {
    try {/*from  w  ww.j a v a  2 s  .com*/
        if (bufferBatchResult == null || "".equals(bufferBatchResult.toString())) { //$NON-NLS-1$
            MessageDialog.openWarning(null, Messages.get().Warning,
                    Messages.get().SQLToDBImportDialog_LogEmpty);
            return;
        }
        String filename = PublicTadpoleDefine.TEMP_DIR + userDB.getDisplay_name() + "_SQLImportResult.log"; //$NON-NLS-1$

        FileOutputStream fos = new FileOutputStream(filename);
        OutputStreamWriter bw = new OutputStreamWriter(fos, "UTF-8"); //$NON-NLS-1$

        bw.write(bufferBatchResult.toString());
        bw.close();

        String strImportResultLogContent = FileUtils.readFileToString(new File(filename));

        downloadExtFile(userDB.getDisplay_name() + "_SQLImportResult.log", strImportResultLogContent);//sbExportData.toString()); //$NON-NLS-1$
    } catch (Exception ee) {
        logger.error("log writer", ee); //$NON-NLS-1$
    }
}

From source file:com.hangum.tadpole.importexport.core.dialogs.SQLToDBImportDialog.java

License:Open Source License

/**
 * select? execute  .//from  www  . j  ava2 s .com
 * 
 * @param listQuery
 * @throws Exception
 */
private int runSQLExecuteBatch(List<String> listQuery) throws Exception {
    java.sql.Connection conn = null;
    Statement statement = null;
    int result = 0;

    try {
        SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
        conn = client.getDataSource().getConnection();
        conn.setAutoCommit(false);
        statement = conn.createStatement();
        int count = 0;

        for (String strQuery : listQuery) {
            if ("".equals(StringUtils.trimToEmpty(strQuery))) //$NON-NLS-1$
                continue;

            statement.addBatch(strQuery);
            if (++count % batchSize == 0) {
                try {
                    statement.executeBatch();
                } catch (SQLException e) {
                    logger.error("Execute Batch error", e); //$NON-NLS-1$
                    bufferBatchResult.append(e.getMessage() + "\n"); //$NON-NLS-1$

                    SQLException ne = e.getNextException();
                    while (ne != null) {
                        logger.error("NEXT SQLException is ", ne);//$NON-NLS-1$
                        bufferBatchResult.append(ne.getMessage() + "\n"); //$NON-NLS-1$
                        ne = ne.getNextException();
                    }

                    if (btnIgnore.getSelection()) {
                        conn.commit();
                        continue;
                    } else {
                        conn.rollback();
                        result = -1;
                        break;
                    }
                }
            }
        }

        statement.executeBatch();
        conn.commit();
        conn.setAutoCommit(true);

        if (result < 0 && !"".equals(bufferBatchResult.toString())) { //$NON-NLS-1$
            MessageDialog.openWarning(null, Messages.get().Warning, bufferBatchResult.toString());
        }
    } catch (SQLException e) {
        logger.error("Execute Batch error", e); //$NON-NLS-1$
        bufferBatchResult.append(e.getMessage() + "\n"); //$NON-NLS-1$
        if (btnIgnore.getSelection()) {
            conn.commit();
        } else {
            conn.rollback();
        }

        SQLException ne = e.getNextException();
        while (ne != null) {
            logger.error("Execute Batch error", e); //$NON-NLS-1$
            bufferBatchResult.append(e.getMessage() + "\n"); //$NON-NLS-1$
            ne = ne.getNextException();
        }
    } catch (Exception e) {
        result = -1;
        logger.error("Execute Batch error", e); //$NON-NLS-1$
        bufferBatchResult.append(e.getMessage() + "\n"); //$NON-NLS-1$
        conn.rollback();
        throw e;
    } finally {
        try {
            if (statement != null)
                statement.close();
        } catch (Exception e) {
        }
        try {
            if (conn != null)
                conn.close();
        } catch (Exception e) {
        }
    }
    return result;
}

From source file:com.hangum.tadpole.importexport.core.editors.mongodb.composite.TableColumnLIstComposite.java

License:Open Source License

public void init(UserDBDAO userDB) {
    if (userDB == null) {
        MessageDialog.openWarning(null, "Data Import", Messages.get().TableColumnLIstComposite_1); //$NON-NLS-1$

        return;//from   www  .  j  a va 2  s  .  co  m
    }
    listTables.clear();
    this.userDB = userDB;

    try {
        if (userDB != null && DBDefine.MONGODB_DEFAULT == userDB.getDBDefine()) {
            List<TableDAO> listCollection = MongoDBQuery.listCollection(userDB);
            for (TableDAO tableDao : listCollection) {
                listTables.add(new ModTableDAO(tableDao.getName()));
            }
        } else {
            SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
            List<TableDAO> showTables = sqlClient.queryForList("tableList", userDB.getDb()); //$NON-NLS-1$
            for (TableDAO tableDAO : showTables) {
                listTables.add(new ModTableDAO(tableDAO.getName()));
            }
        }
    } catch (Exception e) {
        logger.error("DB Connecting... ", e); //$NON-NLS-1$
        MessageDialog.openError(null, "Data Import", e.getMessage()); //$NON-NLS-1$
    }

    tableViewer.setInput(listTables);
    tableViewer.refresh();

    // google analytic
    AnalyticCaller.track("TableColumnLIstComposite");
}

From source file:com.hangum.tadpole.importexport.core.editors.mongodb.MongoDBImportEditor.java

License:Open Source License

/**
 * data import/*www .j a  va  2  s .  c  om*/
 */
private void importData() {
    // ? .
    if (tabFolderQuery.getSelectionIndex() == 0) {
        if (tableColumnListComposite.getSelectListTables().isEmpty())
            return;
    } else if (tabFolderQuery.getSelectionIndex() == 1) {
        if ("".equals(textCollectionName.getText().trim())) { //$NON-NLS-1$
            MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().QueryToMongoDBImport_5);
            return;
        }

        if ("".equals(textQuery.getText().trim())) { //$NON-NLS-1$
            MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().QueryToMongoDBImport_2);
            return;
        }
    }

    // job make
    final UserDBDAO sourceDBDAO = (UserDBDAO) comboDBList.getData(comboDBList.getText());
    Job job = null;
    if (MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().MongoDBImportEditor_1)) { //$NON-NLS-1$
        if (tabFolderQuery.getSelectionIndex() == 0) {

            DBImport dbImport = null;
            if (targetDBDAO != null && DBDefine.MONGODB_DEFAULT == sourceDBDAO.getDBDefine()) {
                dbImport = new MongoDBCollectionToMongodBImport(sourceDBDAO, targetDBDAO,
                        tableColumnListComposite.getSelectListTables());
            } else {
                dbImport = new RDBTableToMongoDBImport(sourceDBDAO, targetDBDAO,
                        tableColumnListComposite.getSelectListTables());
            }
            job = dbImport.workTableImport();
            if (job == null)
                return;

        } else if (tabFolderQuery.getSelectionIndex() == 1) {
            if (targetDBDAO != null && DBDefine.MONGODB_DEFAULT == sourceDBDAO.getDBDefine()) {
                MessageDialog.openInformation(null, Messages.get().Confirm, "Not support MongoDB.");
                return;
            } else {
                QueryToMongoDBImport importData = new QueryToMongoDBImport(sourceDBDAO, targetDBDAO,
                        textCollectionName.getText(), textQuery.getText(), btnExistOnDelete.getSelection());
                job = importData.workTableImport();
                if (job == null)
                    return;
            }
        }
    } else
        return;

    // job listener
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;
            getSite().getShell().getDisplay().asyncExec(new Runnable() {
                public void run() {
                    if (jobEvent.getResult().isOK()) {
                        MessageDialog.openInformation(null, Messages.get().Confirm,
                                Messages.get().MongoDBImportEditor_11); //$NON-NLS-1$
                    } else {
                        ExceptionDetailsErrorDialog.openError(null, Messages.get().Error,
                                Messages.get().MongoDBImportEditor_12, jobEvent.getResult()); //$NON-NLS-1$
                    }
                }
            }); // end display.asyncExec
        } // end done         
    }); // end job

    job.setName(targetDBDAO.getDisplay_name());
    job.setUser(true);
    job.schedule();
}

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

License:Open Source License

/**
 * system message//from w  w w.  j a  v  a2 s.  co m
 */
protected void preLogin() {
    ApplicationContext context = RWT.getApplicationContext();
    Object objValidateMsg = context.getAttribute("LicenseValidation");
    String strValidateMsg = objValidateMsg == null ? "" : (String) objValidateMsg;
    if (StringUtils.isNotEmpty(strValidateMsg)) {
        MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, strValidateMsg);
    }
}

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

License:Open Source License

@Override
protected void okPressed() {
    String strEmail = StringUtils.trimToEmpty(textEmail.getText());
    if (logger.isInfoEnabled())
        logger.info("Find password dialog" + strEmail);

    if (!checkValidation()) {
        MessageDialog.openWarning(getShell(), CommonMessages.get().Confirm,
                Messages.get().FindPasswordDialog_6);
        textEmail.setFocus();//  ww w .  ja v a 2s.  c o  m
        return;
    }

    UserDAO userDao = new UserDAO();
    userDao.setEmail(strEmail);
    String strTmpPassword = Utils.getUniqueDigit(12);
    userDao.setPasswd(strTmpPassword);

    try {
        TadpoleSystem_UserQuery.updateUserPasswordWithID(userDao);
        sendEmailAccessKey(strEmail, strTmpPassword);
        MessageDialog.openInformation(getShell(), CommonMessages.get().Confirm, Messages.get().SendMsg);
    } catch (Exception e) {
        logger.error("password initialize and send email ", e);

        MessageDialog.openError(getShell(), CommonMessages.get().Error,
                String.format(Messages.get().SendMsgErr, e.getMessage()));
    }

    super.okPressed();
}

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

License:Open Source License

@Override
protected void okPressed() {

    String strEmail = StringUtils.trimToEmpty(textEMail.getText());
    String strPass = StringUtils.trimToEmpty(textPasswd.getText());

    if (!validation(strEmail, strPass))
        return;//ww w.  j  a v  a 2  s  .  c o  m

    try {
        UserDAO userDao = TadpoleSystem_UserQuery.login(strEmail, strPass);

        // firsttime email confirm
        if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getIs_email_certification())) {
            InputDialog inputDialog = new InputDialog(getShell(), LoginDialogMessages.get().LoginDialog_10,
                    String.format(LoginDialogMessages.get().LoginDialog_17, strEmail), "", null); //$NON-NLS-3$ //$NON-NLS-1$
            if (inputDialog.open() == Window.OK) {
                if (!userDao.getEmail_key().equals(inputDialog.getValue())) {
                    throw new Exception(LoginDialogMessages.get().LoginDialog_19);
                } else {
                    TadpoleSystem_UserQuery.updateEmailConfirm(strEmail);
                }
            } else {
                throw new Exception(LoginDialogMessages.get().LoginDialog_20);
            }
        }

        if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getApproval_yn())) {
            MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                    LoginDialogMessages.get().LoginDialog_27);

            return;
        }

        // login

        // Check the allow ip
        String strAllowIP = userDao.getAllow_ip();
        String ip_servletRequest = RequestInfoUtils.getRequestIP();
        boolean isAllow = IPUtil.ifFilterString(strAllowIP, ip_servletRequest);
        if (logger.isDebugEnabled())
            logger.debug(LoginDialogMessages.get().LoginDialog_21 + userDao.getEmail()
                    + LoginDialogMessages.get().LoginDialog_22 + strAllowIP
                    + LoginDialogMessages.get().LoginDialog_23 + RequestInfoUtils.getRequestIP());
        if (!isAllow) {
            logger.error(LoginDialogMessages.get().LoginDialog_21 + userDao.getEmail()
                    + LoginDialogMessages.get().LoginDialog_22 + strAllowIP
                    + LoginDialogMessages.get().LoginDialog_26 + RequestInfoUtils.getRequestIP());
            MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                    LoginDialogMessages.get().LoginDialog_28);
            return;
        }

        if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDao.getUse_otp())) {
            GoogleOTPLoginDialog otpDialog = new GoogleOTPLoginDialog(getShell());
            otpDialog.open();

            if (!GoogleAuthManager.getInstance().isValidate(userDao.getOtp_secret(),
                    otpDialog.getIntOTPCode())) {
                throw new Exception(LoginDialogMessages.get().LoginDialog_2);
            }
        }

        // ? .
        registLoginID();

        //
        SessionManager.addSession(userDao, SessionManager.LOGIN_IP_TYPE.SERVLET_REQUEST.name(),
                ip_servletRequest);

        // session 
        preLogin();

        // save login_history
        TadpoleSystem_UserQuery.saveLoginHistory(userDao.getSeq());
    } catch (TadpoleAuthorityException e) {
        logger.error(
                String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage());

        textPasswd.setText("");
        textPasswd.setFocus();
        return;
    } catch (TadpoleRuntimeException e) {
        logger.error(
                String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage());

        textPasswd.setFocus();
        return;
    } catch (Exception e) {
        logger.error(String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage()), //$NON-NLS-1$
                e);
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage());

        textPasswd.setFocus();
        return;
    }

    super.okPressed();
}

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

License:Open Source License

/**
 * validation//w ww. j a v a2  s  . c om
 * 
 * @param strEmail
 * @param strPass
 */
private boolean validation(String strEmail, String strPass) {
    // validation
    if ("".equals(strEmail)) { //$NON-NLS-1$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                LoginDialogMessages.get().LoginDialog_11);
        textEMail.setFocus();
        return false;
    } else if ("".equals(strPass)) { //$NON-NLS-1$
        MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning,
                LoginDialogMessages.get().LoginDialog_14);
        textPasswd.setFocus();
        return false;
    }

    return true;
}