@Override public void init() { if (oldUserDB != null) { selGroupName = oldUserDB.getGroup_name(); preDBInfo.setTextDisplayName(oldUserDB.getDisplay_name()); preDBInfo .getComboOperationType() .setText( PublicTadpoleDefine.DBOperationType.valueOf(oldUserDB.getOperation_type()) .getTypeName()); textHost.setText(oldUserDB.getHost()); textPort.setText(oldUserDB.getPort()); textDatabase.setText(oldUserDB.getDb()); textUser.setText(oldUserDB.getUsers()); textPassword.setText(oldUserDB.getPasswd()); textJDBCOptions.setText(oldUserDB.getUrl_user_parameter()); } else if (ApplicationArgumentUtils.isTestMode() || ApplicationArgumentUtils.isTestDBMode()) { preDBInfo.setTextDisplayName(getDisplayName()); textHost.setText("127.0.0.1"); textPort.setText("10002"); textDatabase.setText("default"); textUser.setText(""); textPassword.setText(""); } else { textPort.setText("10002"); } Combo comboGroup = preDBInfo.getComboGroup(); if (comboGroup.getItems().length == 0) { comboGroup.add(strOtherGroupName); comboGroup.select(0); } else { if ("".equals(selGroupName)) { comboGroup.setText(strOtherGroupName); } else { // 콤보 선택 for (int i = 0; i < comboGroup.getItemCount(); i++) { if (selGroupName.equals(comboGroup.getItem(i))) comboGroup.select(i); } } } // Initialize otherConnectionComposite othersConnectionInfo.callBackUIInit(textHost.getText()); textHost.setFocus(); }
@Override public void crateComposite() { GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 2; gridLayout.horizontalSpacing = 2; gridLayout.marginHeight = 2; gridLayout.marginWidth = 0; setLayout(gridLayout); setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeBody = new Composite(this, SWT.NONE); GridLayout gl_compositeBody = new GridLayout(1, false); gl_compositeBody.verticalSpacing = 2; gl_compositeBody.horizontalSpacing = 2; gl_compositeBody.marginHeight = 2; gl_compositeBody.marginWidth = 2; compositeBody.setLayout(gl_compositeBody); 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(5, false)); grpConnectionType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); grpConnectionType.setText(Messages.MSSQLLoginComposite_grpConnectionType_text); Label lblDriverType = new Label(grpConnectionType, SWT.NONE); lblDriverType.setText(Messages.HiveLoginComposite_lblDriverType_text); comboDriverType = new Combo(grpConnectionType, SWT.READ_ONLY); comboDriverType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1)); // comboDriverType.add("Hive Server 1"); // comboDriverType.setData("Hive Server 1", DBDefine.HIVE_DEFAULT); comboDriverType.add("Hive Server 2"); comboDriverType.setData("Hive Server 2", DBDefine.HIVE2_DEFAULT); comboDriverType.select(0); // comboDriverType.setEnabled(false); Label lblHost = new Label(grpConnectionType, SWT.NONE); lblHost.setText(Messages.DBLoginDialog_1); textHost = new Text(grpConnectionType, SWT.BORDER); textHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabelPort = new Label(grpConnectionType, SWT.NONE); lblNewLabelPort.setText(Messages.DBLoginDialog_5); textPort = new Text(grpConnectionType, SWT.BORDER); textPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnPing = new Button(grpConnectionType, SWT.NONE); btnPing.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String host = StringUtils.trimToEmpty(textHost.getText()); String port = StringUtils.trimToEmpty(textPort.getText()); if ("".equals(host) || "".equals(port)) { // $NON-NLS-1$ //$NON-NLS-2$ MessageDialog.openError(null, Messages.DBLoginDialog_10, Messages.DBLoginDialog_11); return; } try { if (isPing(host, port)) { MessageDialog.openInformation( null, Messages.DBLoginDialog_12, Messages.DBLoginDialog_13); } else { MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.DBLoginDialog_15); } } catch (NumberFormatException nfe) { MessageDialog.openError( null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4); } } }); btnPing.setText(Messages.DBLoginDialog_btnPing_text); Label lblNewLabelDatabase = new Label(grpConnectionType, SWT.NONE); lblNewLabelDatabase.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1)); lblNewLabelDatabase.setText(Messages.DBLoginDialog_4); textDatabase = new Text(grpConnectionType, SWT.BORDER); textDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1)); Label lblUser = new Label(grpConnectionType, SWT.NONE); lblUser.setText(Messages.DBLoginDialog_2); textUser = new Text(grpConnectionType, SWT.BORDER); textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblPassword = new Label(grpConnectionType, SWT.NONE); lblPassword.setText(Messages.DBLoginDialog_3); textPassword = new Text(grpConnectionType, SWT.BORDER | SWT.PASSWORD); textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label lblJdbcOptions = new Label(grpConnectionType, SWT.NONE); lblJdbcOptions.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblJdbcOptions.setText(Messages.MySQLLoginComposite_lblJdbcOptions_text); textJDBCOptions = new Text(grpConnectionType, SWT.BORDER); textJDBCOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1)); othersConnectionInfo = new OthersConnectionBigDataGroup(this, SWT.NONE, getSelectDB()); othersConnectionInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); init(); }
@Override public boolean makeUserDBDao(boolean isTest) { if (!isValidateInput(isTest)) return false; DBDefine selectDB = (DBDefine) comboDriverType.getData(comboDriverType.getText()); String dbUrl = String.format( selectDB.getDB_URL_INFO(), StringUtils.trimToEmpty(textHost.getText()), StringUtils.trimToEmpty(textPort.getText()), StringUtils.trimToEmpty(textDatabase.getText())); if (!"".equals(textJDBCOptions.getText())) { dbUrl += "?" + textJDBCOptions.getText(); } userDB = new UserDBDAO(); userDB.setDbms_type(selectDB.getDBToString()); userDB.setUrl(dbUrl); userDB.setUrl_user_parameter(textJDBCOptions.getText()); userDB.setDb(StringUtils.trimToEmpty(textDatabase.getText())); userDB.setGroup_name(StringUtils.trimToEmpty(preDBInfo.getComboGroup().getText())); userDB.setDisplay_name(StringUtils.trimToEmpty(preDBInfo.getTextDisplayName().getText())); userDB.setOperation_type( PublicTadpoleDefine.DBOperationType.getNameToType( preDBInfo.getComboOperationType().getText()) .toString()); userDB.setHost(StringUtils.trimToEmpty(textHost.getText())); userDB.setPort(StringUtils.trimToEmpty(textPort.getText())); userDB.setUsers(StringUtils.trimToEmpty(textUser.getText())); userDB.setPasswd(StringUtils.trimToEmpty(textPassword.getText())); // others connection 정보를 입력합니다. // setOtherConnectionInfo(); OthersConnectionInfoDAO otherConnectionDAO = othersConnectionInfo.getOthersConnectionInfo(); userDB.setIs_readOnlyConnect( otherConnectionDAO.isReadOnlyConnection() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); userDB.setIs_autocommit( otherConnectionDAO.isAutoCommit() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); userDB.setIs_showtables( otherConnectionDAO.isShowTables() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); // // userDB.setIs_table_filter(otherConnectionDAO.isTableFilter()?PublicTadpoleDefine.YES_NO.YES.name():PublicTadpoleDefine.YES_NO.NO.name()); // userDB.setTable_filter_include(otherConnectionDAO.getStrTableFilterInclude()); // userDB.setTable_filter_exclude(otherConnectionDAO.getStrTableFilterExclude()); userDB.setIs_profile( otherConnectionDAO.isProfiling() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); userDB.setQuestion_dml( otherConnectionDAO.isDMLStatement() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); userDB.setIs_external_browser( otherConnectionDAO.isExterBrowser() ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); // 처음 등록자는 권한이 어드민입니다. userDB.setRole_id(PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString()); return true; }