List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:com.hangum.tadpole.rdb.core.dialog.table.mysql.MySQLTaableCreateDialog.java
License:Open Source License
@Override protected void okPressed() { String strTableName = StringUtils.trimToEmpty(textTableName.getText()); if ("".equals(strTableName)) { MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().TableCreationNameAlter); textTableName.setFocus();/* w w w .j a v a 2 s . com*/ return; } tableCreateDao = new TableCreateDAO(); tableCreateDao.setName(strTableName); Map<Integer, Object> selEncodingData = (Map<Integer, Object>) comboTableEncoding .getData(comboTableEncoding.getText()); tableCreateDao.setEncoding("" + selEncodingData.get(0)); tableCreateDao.setCollation("" + comboTableCollation.getData(comboTableCollation.getText())); tableCreateDao.setType("" + comboTableType.getData(comboTableType.getText())); if (MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().TableCreationWantToCreate)) { String strCreateTable = String.format(MySQLDMLTemplate.TMP_DIALOG_CREATE_TABLE, tableCreateDao.getName(), tableCreateDao.getEncoding(), tableCreateDao.getCollation(), tableCreateDao.getType()); try { ExecuteDDLCommand.executSQL(userDB, strCreateTable); ExplorerViewer ev = (ExplorerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().findView(ExplorerViewer.ID); if (ev != null) ev.refreshTable(true, strTableName); super.okPressed(); } catch (Exception e) { logger.error("table create exception", e); //$NON-NLS-1$ TDBErroDialog errDialog = new TDBErroDialog(null, Messages.get().ObjectDeleteAction_25, Messages.get().TableCreationError + e.getMessage()); errDialog.open(); textTableName.setFocus(); } } }
From source file:com.hangum.tadpole.rdb.core.editors.dbinfos.composites.PropertyComposite.java
License:Open Source License
/** * Download a CSV file. /* w ww . j av a 2 s .c o m*/ */ private void downloadCSVFile() { if (propertyViewer.getTable().getItemCount() == 0) return; if (!MessageDialog.openConfirm(null, CommonMessages.get().Confirm, Messages.get().TablesComposite_3)) return; List<String[]> listCsvData = new ArrayList<String[]>(); // add header Table tbl = propertyViewer.getTable(); TableColumn[] tcs = tbl.getColumns(); String[] strArryHeader = new String[tcs.length]; for (int i = 0; i < strArryHeader.length; i++) { strArryHeader[i] = tcs[i].getText(); } listCsvData.add(strArryHeader); String[] strArryData = new String[tcs.length]; for (int i = 0; i < tbl.getItemCount(); i++) { strArryData = new String[tbl.getColumnCount()]; TableItem gi = tbl.getItem(i); for (int intCnt = 0; intCnt < tcs.length; intCnt++) { strArryData[intCnt] = Utils.convHtmlToLine(gi.getText(intCnt)); } listCsvData.add(strArryData); } try { String strCVSContent = CSVFileUtils.makeData(listCsvData); downloadExtFile(userDB.getDisplay_name() + "_Properties.csv", strCVSContent); //$NON-NLS-1$ MessageDialog.openInformation(null, CommonMessages.get().Information, Messages.get().TablesComposite_5); } catch (Exception e) { logger.error("An exception occurred while writing into a csv file.", e); //$NON-NLS-1$ } }
From source file:com.hangum.tadpole.rdb.core.editors.main.composite.ResultMainComposite.java
License:Open Source License
/** * execute command//w w w . j a v a 2 s . c o m * @param reqQuery */ public void executeCommand(final RequestQuery reqQuery) { if (logger.isDebugEnabled()) logger.debug("==> executeQuery user query is " + reqQuery.getOriginalSql()); try { // ? ?? . if (compositeResultSet.getJobQueryManager() != null) { if (Job.RUNNING == compositeResultSet.getJobQueryManager().getState()) { if (logger.isDebugEnabled()) logger.debug("\t\t================= return already running query job "); return; } } // . if (StringUtils.isEmpty(reqQuery.getSql())) return; this.reqQuery = reqQuery; // ? ? . if (PublicTadpoleDefine.YES_NO.YES.toString().equals(getUserDB().getQuestion_dml())) { boolean isDMLQuestion = false; if (reqQuery.getType() == EditorDefine.EXECUTE_TYPE.ALL) { for (String strSQL : reqQuery.getOriginalSql().split(PublicTadpoleDefine.SQL_DELIMITER)) { if (!SQLUtil.isStatement(strSQL)) { isDMLQuestion = true; break; } } } else { if (!SQLUtil.isStatement(reqQuery.getSql())) isDMLQuestion = true; } if (isDMLQuestion) if (!MessageDialog.openConfirm(null, "Confirm", Messages.MainEditor_56)) //$NON-NLS-1$ return; } // . compositeResultSet.executeCommand(reqQuery); } catch (Exception e) { logger.error("execute query", e); } finally { // ? ? ???? . // browserEvaluate(EditorFunctionService.EXECUTE_DONE); } }
From source file:com.hangum.tadpole.rdb.core.editors.main.MainEditor.java
License:Open Source License
/** * init auto commit button/* w w w. ja va 2 s. c om*/ * * @param isFirst * @param isRiseEvent */ private void initAutoCommitAction(boolean isFirst, boolean isRiseEvent) { if (isAutoCommit()) { tiAutoCommitCommit.setEnabled(false); tiAutoCommitRollback.setEnabled(false); if (!isFirst) { if (MessageDialog.openConfirm(null, Messages.MainEditor_30, Messages.MainEditor_47)) { TadpoleSQLTransactionManager.commit(getUserEMail(), userDB); } else { TadpoleSQLTransactionManager.rollback(getUserEMail(), userDB); } } } else { tiAutoCommitCommit.setEnabled(true); tiAutoCommitRollback.setEnabled(true); } if (isRiseEvent) { // auto commit? ? ?? db ?? . PlatformUI.getPreferenceStore().setValue(PublicTadpoleDefine.AUTOCOMMIT_USE, userDB.getSeq() + "||" + tiAutoCommit.getSelection() + "||" + System.currentTimeMillis()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
From source file:com.hangum.tadpole.rdb.core.editors.objectmain.ObjectEditor.java
License:Open Source License
/** * execute query/*from w w w .j a va 2s. co m*/ * * @param reqQuery */ public void executeCommand(final RequestQuery reqQuery) { // . if (StringUtils.isEmpty(reqQuery.getSql())) return; if (reqQuery.getExecuteType() == EXECUTE_TYPE.BLOCK) { resultMainComposite.executeCommand(reqQuery); } else { try { if (!GrantCheckerUtils.ifExecuteQuery(getUserDB(), reqQuery)) return; } catch (Exception e1) { logger.error("if execute query?", e1); return; } if (!MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().ObjectEditor_3)) { setOrionTextFocus(); return; } RequestResultDAO reqResultDAO = new RequestResultDAO(); try { reqResultDAO = ExecuteDDLCommand.executSQL(userDB, reqQuery.getOriginalSql()); //$NON-NLS-1$ } catch (Exception e) { logger.error("execute ddl", e); //$NON-NLS-1$ reqResultDAO.setResult(PublicTadpoleDefine.SUCCESS_FAIL.F.name()); reqResultDAO.setMesssage(e.getMessage()); } finally { if (PublicTadpoleDefine.SUCCESS_FAIL.F.name().equals(reqResultDAO.getResult())) { afterProcess(reqQuery, reqResultDAO, ""); //$NON-NLS-1$ if (getUserDB().getDBDefine() == DBDefine.MYSQL_DEFAULT | getUserDB().getDBDefine() == DBDefine.MARIADB_DEFAULT) { mysqlAfterProcess(reqResultDAO, reqQuery); } else if (getUserDB().getDBDefine() == DBDefine.MSSQL_DEFAULT | getUserDB().getDBDefine() == DBDefine.MSSQL_8_LE_DEFAULT) { mssqlAfterProcess(reqResultDAO, reqQuery); } } else { String retMsg = ObjectCompileUtil.validateObject(userDB, reqQuery.getSqlDDLType(), reqQuery.getSqlObjectName()); if (!"".equals(retMsg)) { //$NON-NLS-1$ retMsg = Messages.get().ObjectEditor_7 + retMsg; reqResultDAO.setMesssage(retMsg); } afterProcess(reqQuery, reqResultDAO, Messages.get().ObjectEditor_2); } setDirty(false); browserEvaluate(IEditorFunction.SAVE_DATA); setOrionTextFocus(); } } // google analytic AnalyticCaller.track(ObjectEditor.ID, "executeCommandObject"); //$NON-NLS-1$ }
From source file:com.hangum.tadpole.rdb.core.editors.objectmain.ObjectEditor.java
License:Open Source License
/** * mysql .//from w w w. ja va2 s. c o m * * @param reqResultDAO * @param reqQuery * @param e */ private void mysqlAfterProcess(RequestResultDAO reqResultDAO, RequestQuery reqQuery) { if (reqResultDAO.getException() == null) return; String strSQLState = ""; int intSQLErrorCode = -1; Throwable cause = reqResultDAO.getException(); ; if (cause instanceof SQLException) { try { SQLException sqlException = (SQLException) cause; strSQLState = sqlException.getSQLState(); intSQLErrorCode = sqlException.getErrorCode(); if (logger.isDebugEnabled()) logger.debug("==========> SQLState : " + strSQLState + "\t SQLErrorCode : " + intSQLErrorCode); } catch (Exception e) { logger.error("SQLException to striing", e); //$NON-NLS-1$ } } if (strSQLState.equals("42000") && intSQLErrorCode == 1304) { //$NON-NLS-1$ String cmd = String.format("DROP %s %s", reqQuery.getSqlDDLType(), reqQuery.getSqlObjectName()); //$NON-NLS-1$ if (MessageDialog.openConfirm(null, Messages.get().Confirm, String.format(Messages.get().ObjectEditor_13, reqQuery.getSqlObjectName()))) { RequestResultDAO reqReResultDAO = new RequestResultDAO(); try { reqReResultDAO = ExecuteDDLCommand.executSQL(userDB, cmd); //$NON-NLS-1$ afterProcess(reqQuery, reqReResultDAO, Messages.get().ObjectEditor_2); reqReResultDAO = ExecuteDDLCommand.executSQL(userDB, reqQuery.getOriginalSql()); //$NON-NLS-1$ afterProcess(reqQuery, reqReResultDAO, Messages.get().ObjectEditor_2); } catch (Exception ee) { afterProcess(reqQuery, reqResultDAO, ""); //$NON-NLS-1$ } } // 1064 ? ?. // } else if(strSQLState.equals("42000") && intSQLErrorCode == 1064) { //$NON-NLS-1$ } }
From source file:com.hangum.tadpole.rdb.core.editors.objectmain.ObjectEditor.java
License:Open Source License
/** * mssql after process//ww w .j a va2s.co m * @param reqResultDAO * @param reqQuery */ private void mssqlAfterProcess(RequestResultDAO reqResultDAO, RequestQuery reqQuery) { if (reqResultDAO.getException() == null) return; String strSQLState = ""; int intSQLErrorCode = -1; Throwable cause = reqResultDAO.getException(); ; if (cause instanceof SQLException) { try { SQLException sqlException = (SQLException) cause; strSQLState = sqlException.getSQLState(); intSQLErrorCode = sqlException.getErrorCode(); if (logger.isDebugEnabled()) logger.debug("==========> SQLState : " + strSQLState + "\t SQLErrorCode : " + intSQLErrorCode); } catch (Exception e) { logger.error("SQLException to striing", e); //$NON-NLS-1$ } } if (strSQLState.equals("S0001") && intSQLErrorCode == 2714) { //$NON-NLS-1$ String cmd = String.format("DROP %s %s", reqQuery.getSqlDDLType(), reqQuery.getSqlObjectName()); //$NON-NLS-1$ if (MessageDialog.openConfirm(null, Messages.get().Confirm, String.format(Messages.get().ObjectEditor_13, reqQuery.getSqlObjectName()))) { RequestResultDAO reqReResultDAO = new RequestResultDAO(); try { reqReResultDAO = ExecuteDDLCommand.executSQL(userDB, cmd); //$NON-NLS-1$ afterProcess(reqQuery, reqReResultDAO, Messages.get().ObjectEditor_2); reqReResultDAO = ExecuteDDLCommand.executSQL(userDB, reqQuery.getOriginalSql()); //$NON-NLS-1$ afterProcess(reqQuery, reqReResultDAO, Messages.get().ObjectEditor_2); } catch (Exception ee) { afterProcess(reqQuery, reqResultDAO, ""); //$NON-NLS-1$ } } } }
From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TableDirectEditorComposite.java
License:Open Source License
/** * default composite/*from ww w . j a va2 s .c o m*/ * * @param parent * @param style * @param userDB * @param initTableNameStr * @param columnList * @param primaryKEYListString */ public TableDirectEditorComposite(Composite parent, int style, final UserDBDAO userDB, final TableDAO tableDao, List<TableColumnDAO> columnList, Map<String, Boolean> primaryKEYListString) { super(parent, style); GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 2; gridLayout.horizontalSpacing = 2; gridLayout.marginHeight = 2; gridLayout.marginWidth = 2; setLayout(gridLayout); // start initialize value this.userDB = userDB; this.tableDao = tableDao; this.columnList = columnList; this.primaryKEYListString = primaryKEYListString; // end initialize value Composite compositeBase = new Composite(this, SWT.NONE); compositeBase.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); GridLayout gl_compositeBase = new GridLayout(1, false); gl_compositeBase.verticalSpacing = 3; gl_compositeBase.horizontalSpacing = 3; gl_compositeBase.marginHeight = 3; gl_compositeBase.marginWidth = 3; compositeBase.setLayout(gl_compositeBase); toolBar = new ToolBar(compositeBase, SWT.NONE | SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tltmRefresh = new ToolItem(toolBar, SWT.NONE); tltmRefresh.setImage(ImageUtils.getRefresh()); tltmRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (tltmSave.getEnabled()) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.TableDirectEditorComposite_1)) //$NON-NLS-1$ return; } refreshEditor(); } }); tltmRefresh.setToolTipText(Messages.TableDirectEditorComposite_tltmRefersh_text); tltmSave = new ToolItem(toolBar, SWT.NONE); tltmSave.setImage(ImageUtils.getSave()); tltmSave.setEnabled(false); tltmSave.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { saveTableData(); } }); tltmSave.setToolTipText(Messages.TableEditPart_0); tltmInsert = new ToolItem(toolBar, SWT.NONE); tltmInsert.setImage(ImageUtils.getAdd()); tltmInsert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { insertRow(); } }); tltmInsert.setToolTipText(Messages.TableEditPart_tltmInsert_text); tltmDelete = new ToolItem(toolBar, SWT.NONE); tltmDelete.setImage(ImageUtils.getDelete()); tltmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) sqlResultTableViewer.getSelection(); if (!is.isEmpty()) { deleteRow(is.getFirstElement()); } } }); tltmDelete.setEnabled(false); tltmDelete.setToolTipText(Messages.TableEditPart_1); Composite compositeBody = new Composite(compositeBase, SWT.NONE); GridLayout gl_compositeBody = new GridLayout(2, false); gl_compositeBody.horizontalSpacing = 3; gl_compositeBody.verticalSpacing = 3; gl_compositeBody.marginHeight = 3; gl_compositeBody.marginWidth = 3; compositeBody.setLayout(gl_compositeBody); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Label lblWhere = new Label(compositeBody, SWT.NONE); lblWhere.setText(Messages.TableEditPart_lblWhere_text); textWhere = new Text(compositeBody, SWT.BORDER); textWhere.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) initBusiness(); } }); textWhere.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblOrderBy = new Label(compositeBody, SWT.NONE); lblOrderBy.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblOrderBy.setText(Messages.TableDirectEditorComposite_lblOrderBy_text); textOrderBy = new Text(compositeBody, SWT.BORDER); textOrderBy.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) initBusiness(); } }); textOrderBy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel = new Label(compositeBody, SWT.NONE); lblNewLabel.setText(Messages.TableEditPart_3); textFilter = new Text(compositeBody, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); textFilter.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.Selection) setFilter(); } }); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); sqlResultTableViewer = new TableViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION); sqlResultTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { tltmDelete.setEnabled(true); } }); tableResult = sqlResultTableViewer.getTable(); tableResult.setHeaderVisible(true); tableResult.setLinesVisible(true); tableResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); // table markup-enable tableResult.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); sqlFilter.setTable(tableResult); compositeTail = new Composite(compositeBase, SWT.NONE); GridLayout gl_compositeTail = new GridLayout(1, false); gl_compositeTail.verticalSpacing = 2; gl_compositeTail.horizontalSpacing = 2; gl_compositeTail.marginHeight = 2; gl_compositeTail.marginWidth = 2; compositeTail.setLayout(gl_compositeTail); compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnDdlSourceView = new Button(compositeTail, SWT.NONE); btnDdlSourceView.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { DDLScriptManager scriptManager = new DDLScriptManager(userDB, PublicTadpoleDefine.DB_ACTION.TABLES); FindEditorAndWriteQueryUtil.run(userDB, scriptManager.getScript(tableDao), PublicTadpoleDefine.DB_ACTION.TABLES); } catch (Exception ee) { MessageDialog.openError(null, "Confirm", ee.getMessage()); //$NON-NLS-1$ } } }); btnDdlSourceView.setText(Messages.TableDirectEditorComposite_btnDdlSourceView_text); initBusiness(); // google analytic AnalyticCaller.track(this.getClass().getName()); }
From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TableDirectEditorComposite.java
License:Open Source License
/** * save table data//from w w w . jav a 2 s . c o m */ private void saveTableData() { String strQuery = getChangeQuery(); if ("".equals(strQuery)) //$NON-NLS-1$ return; String[] querys = SQLTextUtil.delLineChar(strQuery).split(";"); //$NON-NLS-1$ // save ? . java.sql.Connection javaConn = null; Statement stmt = null; String lastExeQuery = ""; //$NON-NLS-1$ try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); // sqlite? forward cursor ? stmt = javaConn.createStatement();//ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); javaConn.setAutoCommit(false); boolean isUpdateOrDelete = false; for (int i = 0; i < querys.length; i++) { logger.info("exe query [" + querys[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ if (StringUtils.startsWithIgnoreCase(querys[i], "update") || //$NON-NLS-1$ StringUtils.startsWithIgnoreCase(querys[i], "delete")) //$NON-NLS-1$ isUpdateOrDelete = true; lastExeQuery = querys[i]; stmt.addBatch(querys[i]); } boolean isUpdateed = false; if (isUpdateOrDelete) { DBDefine selectDB = userDB.getDBDefine(); if (selectDB == DBDefine.SQLite_DEFAULT || selectDB == DBDefine.CUBRID_DEFAULT || selectDB == DBDefine.MSSQL_DEFAULT || selectDB == DBDefine.MSSQL_8_LE_DEFAULT) { isUpdateed = MessageDialog.openConfirm(null, "Confirm", Messages.TableDirectEditorComposite_17); //$NON-NLS-1$ } else { isUpdateed = MessageDialog.openConfirm(null, "Confirm", Messages.TableDirectEditorComposite_19); //$NON-NLS-1$ } } else { isUpdateed = MessageDialog.openConfirm(null, "Confirm", Messages.TableDirectEditorComposite_19); //$NON-NLS-1$ } if (isUpdateed) { stmt.executeBatch(); javaConn.commit(); // ?? . initBusiness(); initButtonCtrl(); } } catch (Exception e) { try { if (javaConn != null) javaConn.rollback(); } catch (SQLException sqe) { } ; logger.error(Messages.TableViewerEditPart_7, e); // ? . MessageDialog.openError(null, Messages.TableViewerEditPart_3, lastExeQuery + Messages.TableViewerEditPart_10 + e.getMessage()); //$NON-NLS-2$ } finally { // connection? ? ? . try { javaConn.setAutoCommit(true); } catch (Exception ee) { } try { if (stmt != null) stmt.close(); } catch (Exception ee) { } try { if (javaConn != null) javaConn.close(); } catch (Exception ee) { } } }
From source file:com.hangum.tadpole.rdb.core.editors.sessionlist.SessionListEditor.java
License:Open Source License
/** * kill process// w w w. ja v a 2s . c o m */ private void killProcess() { StructuredSelection ss = (StructuredSelection) tableViewerSessionList.getSelection(); SessionListDAO sl = (SessionListDAO) ss.getFirstElement(); if (!MessageDialog.openConfirm(null, "Confirm", "Do you want kill process?")) return; try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); if (DBDefine.getDBDefine(userDB) == DBDefine.POSTGRE_DEFAULT) { client.queryForObject("killProcess", Integer.parseInt(sl.getId())); } else { client.queryForObject("killProcess", sl.getId()); } initSessionListData(); } catch (Exception e) { logger.error("killprocess exception", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getSite().getShell(), "Error", Messages.MainEditor_19, errStatus); //$NON-NLS-1$ } }