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.dbconnect.composite.SQLiteLoginComposite.java
License:Open Source License
@Override protected void crateComposite() { GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 2;/*from w ww . j a v a 2 s.c o m*/ gridLayout.horizontalSpacing = 2; gridLayout.marginHeight = 2; gridLayout.marginWidth = 2; setLayout(gridLayout); setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeBody = new Composite(this, SWT.NONE); compositeBody.setLayout(new GridLayout(1, false)); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); preDBInfo = new PreConnectionInfoGroup(compositeBody, SWT.NONE, listGroupName); preDBInfo.setText(Messages.MSSQLLoginComposite_preDBInfo_text); preDBInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); Group grpConnectionType = new Group(compositeBody, SWT.NONE); grpConnectionType.setLayout(new GridLayout(3, false)); grpConnectionType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); grpConnectionType.setText(Messages.MSSQLLoginComposite_grpConnectionType_text); chkBtnFileUpload = new Button(grpConnectionType, SWT.RADIO); chkBtnFileUpload.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { uiInit(false); } }); chkBtnFileUpload.setText(Messages.SQLiteLoginComposite_btnFileUpload_text); fileNameLabel = new Text(grpConnectionType, SWT.BORDER); fileNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); fileNameLabel.setEnabled(false); fileNameLabel.setEditable(false); fileNameLabel.setText(INITIAL_TEXT); final String url = startUploadReceiver(); pushSession = new ServerPushSession(); fileUpload = new FileUpload(grpConnectionType, SWT.NONE); fileUpload.setText(Messages.SQLiteLoginComposite_14); fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fileUpload.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fileName = fileUpload.getFileName(); if ("".equals(fileName) || null == fileName) return; if (!MessageDialog.openConfirm(null, Messages.SQLiteLoginComposite_16, Messages.SQLiteLoginComposite_17)) return; fileNameLabel.setText(fileName == null ? "" : fileName); //$NON-NLS-1$ pushSession.start(); fileUpload.submit(url); } }); chkBtnCreationDb = new Button(grpConnectionType, SWT.RADIO); chkBtnCreationDb.setSelection(true); chkBtnCreationDb.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { uiInit(true); } }); chkBtnCreationDb.setText(Messages.SQLiteLoginComposite_btnCreationDb_text); textCreationDB = new Text(grpConnectionType, SWT.BORDER); textCreationDB.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); othersConnectionInfo = new OthersConnectionRDBWithoutTunnelingGroup(this, SWT.NONE, getSelectDB()); othersConnectionInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); init(); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.CubridLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; final String dbUrl = String.format(DBDefine.CUBRID_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.CUBRID_DEFAULT.getDBToString()); userDB.setUrl(dbUrl);//from w w w .j a va2 s .co m userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setLocale(comboLocale.getText().trim()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { // db ??? ? try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List showTables = sqlClient.queryForList("tableList", textDatabase.getText()); } catch (Exception e) { logger.error("Cubrid DB Connection", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_10, //$NON-NLS-1$ errStatus); return false; } try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("cubrid db preference save", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_11, //$NON-NLS-1$ errStatus); } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MongoDBLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; final String dbUrl = String.format(DBDefine.MONGODB_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.MONGODB_DEFAULT.getDBToString()); userDB.setUrl(dbUrl);// w ww . j a v a2 s. c o m userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setLocale(comboLocale.getText().trim()); userDB.setUsers(textUser.getText()); userDB.setExt1(textReplicaSet.getText().trim()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { // db ??? ? try { MongoConnectionManager.getInstance(userDB); } catch (MongoDBNotFoundException mdbfe) { if (MessageDialog.openConfirm(null, "Confirm", userDB.getDb() + Messages.MongoDBLoginComposite_9)) { //$NON-NLS-1$ try { MongoDBQuery.createDB(userDB); } catch (Exception e) { logger.error("MongoDB Connection error", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_10, //$NON-NLS-1$ errStatus); return false; } } else { return false; } } catch (Exception e) { logger.error("MongoDB Connection error", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_10, //$NON-NLS-1$ errStatus); return false; } try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("MongoDB info save", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", "MongoDB", errStatus); //$NON-NLS-1$ //$NON-NLS-2$ } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MSSQLLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; String dbUrl = ""; String strHost = textHost.getText(); if (StringUtils.contains(strHost, "\\")) { String strIp = StringUtils.substringBefore(strHost, "\\"); String strInstance = StringUtils.substringAfter(strHost, "\\"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else if (StringUtils.contains(strHost, "/")) { String strIp = StringUtils.substringBefore(strHost, "/"); String strInstance = StringUtils.substringAfter(strHost, "/"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else {/*www . j av a2 s .c o m*/ dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); } if (logger.isDebugEnabled()) logger.debug("[db url]" + dbUrl); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.MSSQL_DEFAULT.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { int intVersion = 0; try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); // ? . DBInfoDAO dbInfo = (DBInfoDAO) sqlClient.queryForObject("findDBInfo"); //$NON-NLS-1$ intVersion = Integer.parseInt(StringUtils.substringBefore(dbInfo.getProductversion(), ".")); } catch (Exception e) { logger.error("MSSQL Connection", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_8, //$NON-NLS-1$ errStatus); return false; } try { if (intVersion <= 8) { userDB.setTypes(DBDefine.MSSQL_8_LE_DEFAULT.getDBToString()); } TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("MSSQL", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_10, //$NON-NLS-1$ errStatus); } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MySQLLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; String dbUrl = ""; String locale = comboLocale.getText().trim(); if (locale.equals("") || DBLocaleUtils.NONE_TXT.equals(locale)) { dbUrl = String.format(DBDefine.MYSQL_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); } else {/*from w w w .j a v a 2s .c o m*/ String selectLocale = StringUtils.substringBefore(comboLocale.getText(), "|"); dbUrl = String.format(DBDefine.MYSQL_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText() + "?useUnicode=false&characterEncoding=" + selectLocale.trim()); } if (logger.isDebugEnabled()) logger.debug("[db url]" + dbUrl); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.MYSQL_DEFAULT.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setLocale(comboLocale.getText()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } return true; // ?? . } else { // ? ? . if (!connectValidate(userDB)) return false; try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.MySQLLoginComposite_0, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MySQLLoginComposite_2, //$NON-NLS-1$ errStatus); } return true; } }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.OracleLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; String dbUrl = ""; if (comboConnType.getText().equals("SID")) { dbUrl = String.format(DBDefine.ORACLE_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); } else if (comboConnType.getText().equals("Service Name")) { dbUrl = String.format("jdbc:oracle:thin:@%s:%s/%s", textHost.getText(), textPort.getText(), textDatabase.getText()); }/*w w w.j av a 2s . c om*/ userDB = new UserDBDAO(); userDB.setTypes(DBDefine.ORACLE_DEFAULT.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); // userDB.setLocale(comboLocale.getText().trim()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { // db ??? ? try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List showTables = sqlClient.queryForList("tableList", textDatabase.getText()); } catch (Exception e) { logger.error(Messages.OracleLoginComposite_7, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_10, //$NON-NLS-1$ errStatus); return false; } try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("Oracle db info save", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.OracleLoginComposite_11, //$NON-NLS-1$ errStatus); } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.PostgresLoginComposite.java
License:Open Source License
@Override public boolean connection() { if (!isValidate()) return false; final String dbUrl = String.format(DB_DEFINE.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText());// www . ja v a2s . c o m userDB = new UserDBDAO(); userDB.setTypes(DB_DEFINE.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setLocale(comboLocale.getText().trim()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { // db ??? ? try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List showTables = sqlClient.queryForList("tableList", textDatabase.getText()); } catch (Exception e) { logger.error("PostgreSQL DB Connection", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", "PostgreSQL Connection Exception", errStatus); return false; } try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("PostgreSQL db preference save", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", "PostgreSQL Connection Exception", //$NON-NLS-1$ errStatus); } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.SQLiteLoginComposite.java
License:Open Source License
@Override protected boolean connection() { String strFile = StringUtils.trimToEmpty(textFile.getText()); if ("".equals(comboGroup.getText().trim())) { MessageDialog.openError(null, Messages.SQLiteLoginComposite_6, "Group" + Messages.MySQLLoginComposite_10); return false; } else if ("".equals(strFile)) { //$NON-NLS-1$ MessageDialog.openError(null, Messages.SQLiteLoginComposite_6, Messages.SQLiteLoginComposite_7); return false; } else if ("".equals(StringUtils.trimToEmpty(textDisplayName.getText()))) { //$NON-NLS-1$ MessageDialog.openError(null, Messages.SQLiteLoginComposite_6, Messages.SQLiteLoginComposite_12); return false; }/* www .ja v a2 s . com*/ if (!new File(strFile).exists()) { if (!MessageDialog.openConfirm(null, Messages.SQLiteLoginComposite_6, Messages.SQLiteLoginComposite_9)) return false; } userDB = new UserDBDAO(); userDB.setTypes(DBDefine.SQLite_DEFAULT.getDBToString()); userDB.setUrl(String.format(DBDefine.SQLite_DEFAULT.getDB_URL_INFO(), textFile.getText())); userDB.setDb(textFile.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setPasswd(""); //$NON-NLS-1$ userDB.setUsers(""); //$NON-NLS-1$ // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { // ? ? . if (!connectValidate(userDB)) return false; try { TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.driver.JDBCDriverManageDialog.java
License:Open Source License
/** * Create contents of the dialog./*from w w w .j a v a 2 s . c o m*/ * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; SashForm sashForm = new SashForm(container, SWT.NONE); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeLeft = new Composite(sashForm, SWT.NONE); compositeLeft.setLayout(new GridLayout(1, false)); Label lblDriverList = new Label(compositeLeft, SWT.NONE); lblDriverList.setText(Messages.get().JDBCDriverSetting_DriverList); lvDB = new ListViewer(compositeLeft, SWT.BORDER | SWT.V_SCROLL); lvDB.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) lvDB.getSelection(); if (ss.isEmpty()) return; DBDefine dbDefine = (DBDefine) ss.getFirstElement(); jdbc_dir = ApplicationArgumentUtils.JDBC_RESOURCE_DIR + dbDefine.getExt() + PublicTadpoleDefine.DIR_SEPARATOR; lblRealFullPath.setText(jdbc_dir); initDBFileList(); } }); List list = lvDB.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); lvDB.setContentProvider(new ArrayContentProvider()); lvDB.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { DBDefine dbDefine = (DBDefine) element; return dbDefine.getDBToString(); } }); lvDB.setInput(DBDefine.getDriver()); Composite compositeBody = new Composite(sashForm, SWT.NONE); compositeBody.setLayout(new GridLayout(3, false)); Label lblDumy = new Label(compositeBody, SWT.NONE); lblDumy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); Label lblPath = new Label(compositeBody, SWT.NONE); lblPath.setText(Messages.get().JDBCDriverSetting_Path); lblRealFullPath = new Text(compositeBody, SWT.NONE | SWT.READ_ONLY); lblRealFullPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label txtFileList = new Label(compositeBody, SWT.NONE); txtFileList.setText(Messages.get().JDBCDriverSetting_FileList); new Label(compositeBody, SWT.NONE); new Label(compositeBody, SWT.NONE); lvDriverFile = new ListViewer(compositeBody, SWT.BORDER | SWT.V_SCROLL); lvDriverFile.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { btnDelete.setEnabled(true); } }); lvDriverFile.setContentProvider(new ArrayContentProvider()); lvDriverFile.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String str = element.toString(); return str; } }); List listDriver = lvDriverFile.getList(); listDriver.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Composite compositeBodyBtn = new Composite(compositeBody, SWT.NONE); compositeBodyBtn.setLayout(new GridLayout(1, false)); compositeBodyBtn.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1)); btnDelete = new Button(compositeBodyBtn, SWT.NONE); btnDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { StructuredSelection ss = (StructuredSelection) lvDriverFile.getSelection(); if (ss.isEmpty()) return; String strFile = (String) ss.getFirstElement(); if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().Delete)) return; if (logger.isDebugEnabled()) logger.debug("File delete : " + jdbc_dir + strFile); try { FileUtils.forceDelete(new File(jdbc_dir + strFile)); initDBFileList(); } catch (IOException e1) { logger.error("File delete", e1); MessageDialog.openError(getShell(), Messages.get().Error, "File deleteing: " + e1.getMessage()); } } }); btnDelete.setText(Messages.get().Delete); final String url = startUploadReceiver(); pushSession = new ServerPushSession(); fileUpload = new FileUpload(compositeBodyBtn, SWT.NONE); fileUpload.setText(Messages.get().JDBCDriverSetting_JARUpload); fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fileUpload.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fileName = fileUpload.getFileName(); if ("".equals(fileName) || null == fileName) //$NON-NLS-1$ return; if (!MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().SQLiteLoginComposite_17)) return; if (logger.isDebugEnabled()) logger.debug("=[file name]==> " + fileName); pushSession.start(); fileUpload.submit(url); } }); Button btnRefresh = new Button(compositeBodyBtn, SWT.NONE); btnRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initDBFileList(); } }); btnRefresh.setText(Messages.get().Refresh); sashForm.setWeights(new int[] { 3, 7 }); initManager(); return container; }
From source file:com.hangum.tadpole.rdb.core.dialog.resource.ResourceDetailDialog.java
License:Open Source License
/** * Create contents of the dialog.//from w w w . ja v a 2s . c o m * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; Composite compositeHead = new Composite(container, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeHead.setLayout(new GridLayout(3, false)); Label lblTitle = new Label(compositeHead, SWT.NONE); lblTitle.setText(Messages.get().Title); textTitle = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY); textTitle.setEditable(true); textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textTitle.setText(resourceManagerDao.getName()); new Label(compositeHead, SWT.NONE); Label lblDescription = new Label(compositeHead, SWT.NONE); lblDescription.setText(Messages.get().Description); textDescription = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); textDescription.setEditable(true); GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_textDescription.heightHint = 40; textDescription.setLayoutData(gd_textDescription); textDescription.setText(resourceManagerDao.getDescription()); Button btnModify = new Button(compositeHead, SWT.NONE); btnModify.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if ("".equals(textTitle.getText().trim())) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().ResourceDetailDialog_name_empty); textTitle.setFocus(); return; } if (MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().ResourceDetailDialog_delete)) { resourceManagerDao.setName(textTitle.getText()); resourceManagerDao.setDescription(textDescription.getText()); try { TadpoleSystem_UserDBResource.userDbResourceHeadUpdate(resourceManagerDao); // tree refresh if (originalResourceDB != null) { originalResourceDB.setName(textTitle.getText()); originalResourceDB.setDescription(textDescription.getText()); ManagerViewer mv = (ManagerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(ManagerViewer.ID); mv.refreshResource(originalResourceDB); } } catch (Exception ee) { logger.error("Resource title, desc saveing", ee); MessageDialog.openError(getShell(), Messages.get().Confirm, "Save exception." + ee.getMessage()); } } } }); btnModify.setText(Messages.get().Modified); Composite compositeHeaderUser = new Composite(compositeHead, SWT.NONE); compositeHeaderUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); compositeHeaderUser.setLayout(new GridLayout(4, false)); Label lblUser = new Label(compositeHeaderUser, SWT.NONE); lblUser.setText(Messages.get().User); textUser = new Text(compositeHeaderUser, SWT.BORDER | SWT.READ_ONLY); textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textUser.setText(resourceManagerDao.getUser_name()); Label lblCreateTime = new Label(compositeHeaderUser, SWT.NONE); lblCreateTime.setText(Messages.get().CreatTime); textCreateTime = new Text(compositeHeaderUser, SWT.BORDER | SWT.READ_ONLY); textCreateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textCreateTime.setText(resourceManagerDao.getCreate_time()); SashForm sashForm = new SashForm(container, SWT.BORDER | SWT.VERTICAL); sashForm.setLayout(new GridLayout(1, false)); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tvHistory = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); tvHistory.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection sss = (StructuredSelection) tvHistory.getSelection(); if (sss.isEmpty()) return; UserDBResourceDataDAO userDBResource = (UserDBResourceDataDAO) sss.getFirstElement(); compareWidget.changeDiff(userDBResource.getDatas(), ""); } }); Table table = tvHistory.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TableViewerColumn tvcDate = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnDate = tvcDate.getColumn(); tblclmnDate.setWidth(100); tblclmnDate.setText(Messages.get().Date); TableViewerColumn tvcUser = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnUser = tvcUser.getColumn(); tblclmnUser.setWidth(100); tblclmnUser.setText(Messages.get().User); TableViewerColumn tvcSQL = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnSql = tvcSQL.getColumn(); tblclmnSql.setWidth(500); tblclmnSql.setText(Messages.get().SQL); tvHistory.setContentProvider(new ArrayContentProvider()); tvHistory.setLabelProvider(new ResourceHistoryLabelProvider()); // SashForm compositeCompare = new SashForm(sashForm, SWT.NONE); // compositeCompare.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // compositeCompare.setLayout(new GridLayout(2, false)); compareWidget = new TadpoleCompareWidget(sashForm, SWT.BORDER); compareWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // textLeft = new TadpoleEditorWidget(compositeCompare, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", ""); // textLeft.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // // textRight = new TadpoleEditorWidget(compositeCompare, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", ""); // textRight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); sashForm.setWeights(new int[] { 6, 4 }); initUIData(); return container; }