use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class LoginDatabaseDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
final Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 5;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
Label userNameLabel = new Label(composite, SWT.LEFT);
userNameLabel.setText(Messages.lblDbUserName);
userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
userNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
if (database != null && database.getUserName() != null) {
userNameText.setText(database.getUserName());
}
userNameText.addModifyListener(this);
userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, 100, -1));
userNameText.setFocus();
Label passwordLabel = new Label(composite, SWT.LEFT);
passwordLabel.setText(Messages.lblDbPassword);
passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
passwordText = new Text(composite, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, 100, -1));
if (database != null && database.getPassword() != null && database.isAutoSavePassword()) {
passwordText.setText(database.getPassword());
}
if (database != null && database.getUserName() != null) {
passwordText.selectAll();
passwordText.setFocus();
}
new Composite(composite, SWT.NONE).setLayoutData(CommonUITool.createGridData(1, 1, 0, 0));
Button btnSavePassword = new Button(composite, SWT.CHECK);
btnSavePassword.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 1, -1, -1));
btnSavePassword.setText(Messages.btnSavePassword);
if (database == null) {
btnSavePassword.setSelection(true);
isSavePassword = true;
} else {
btnSavePassword.setSelection(database.isAutoSavePassword());
isSavePassword = database.isAutoSavePassword();
}
btnSavePassword.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
isSavePassword = !isSavePassword;
}
});
Label backgroundLabel = new Label(composite, SWT.None);
backgroundLabel.setText(Messages.lblBackground);
backgroundLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
RGB selectedColor = null;
if (editorConfig != null) {
selectedColor = editorConfig.getBackGround();
} else {
selectedColor = EditorConstance.getDefaultBackground();
}
selectColorCombo = new SelectColorCombo(composite, SWT.BORDER, selectedColor);
selectColorCombo.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, 110, -1));
Label commentLabel = new Label(composite, SWT.None);
commentLabel.setText(Messages.lblComment);
commentLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
commentText = new Text(composite, SWT.BORDER);
commentText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
commentText.setTextLimit(64);
if (editorConfig != null) {
commentText.setText(StringUtil.nvl(editorConfig.getDatabaseComment()));
}
new Label(composite, SWT.None);
Label commentDescLabel = new Label(composite, SWT.None);
commentDescLabel.setText(Messages.lblDescComment);
commentDescLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 4, 1, -1, -1));
final Group brokerGroup = new Group(composite, SWT.NONE);
{
brokerGroup.setText(com.cubrid.common.ui.query.Messages.brokerGrp);
brokerGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 5, 1, -1, -1));
GridLayout brokerLayout = new GridLayout();
brokerLayout.numColumns = 3;
brokerLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
brokerLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
brokerLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
brokerLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
brokerGroup.setLayout(brokerLayout);
final Label labelBrokerIp = new Label(brokerGroup, SWT.NONE);
labelBrokerIp.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
labelBrokerIp.setText(com.cubrid.common.ui.query.Messages.brokerIP);
brokerIpText = new Text(brokerGroup, SWT.BORDER);
brokerIpText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
final Label labelBrokerPort = new Label(brokerGroup, SWT.NONE);
labelBrokerPort.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
labelBrokerPort.setText(com.cubrid.common.ui.query.Messages.brokerPort);
brokerPortCombo = new Combo(brokerGroup, SWT.NONE);
brokerPortCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
BrokerInfoList bis = brokerInfos == null ? null : brokerInfos.getBorkerInfoList();
if (bis != null) {
List<BrokerInfo> brokerInfoList = bis.getBrokerInfoList();
for (BrokerInfo brokerInfo : brokerInfoList) {
if (StringUtil.isEmpty(brokerInfo.getPort())) {
continue;
}
String status = "";
if (!StringUtil.isEqualIgnoreCase(brokerInfos.getBrokerstatus(), "ON")) {
status = "OFF";
} else {
status = !StringUtil.isEqualIgnoreCase(brokerInfo.getState(), "ON") ? "OFF" : "ON";
}
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
brokerPortCombo.add(text);
brokerPortCombo.setData(brokerInfo.getPort(), text);
brokerPortCombo.setData(text, brokerInfo);
}
}
Label charSetLbl = new Label(brokerGroup, SWT.CHECK);
charSetLbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
charSetLbl.setText(com.cubrid.common.ui.query.Messages.lblCharSet);
charsetCombo = new Combo(brokerGroup, SWT.BORDER);
charsetCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Button testConnectionButton = new Button(brokerGroup, SWT.None);
testConnectionButton.setText(com.cubrid.common.ui.query.Messages.btnTestConnection);
testConnectionButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
testConnectionButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
final String dbUser = userNameText.getText();
final String dbPassword = passwordText.getText();
final DatabaseInfo dbInfo = database.getDatabaseInfo();
final String brokerIP = brokerIpText.getText();
final String brokerPort = getBrokerPort();
final String dbName = dbInfo.getDbName();
final ServerInfo serverInfo = dbInfo.getServerInfo();
final String charset = dbInfo.getCharSet();
final String driverVersion = serverInfo.getJdbcDriverVersion();
// advanced jdbc settings
final String jdbcAttrs = attrText.getText();
final boolean isShard = dbInfo.isShard();
TaskExecutor taskExcutor = new ConnectDatabaseExecutor(brokerIP, brokerPort, dbName, dbUser, dbPassword, charset, jdbcAttrs, driverVersion, false, isShard);
new ExecTaskWithProgress(taskExcutor).exec();
if (taskExcutor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgTestConnSuccess);
}
}
});
}
Group advancedOptionGroup = new Group(composite, SWT.NONE);
{
advancedOptionGroup.setText(Messages.grpAdvancedJDBC);
advancedOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 5, 1, -1, -1));
GridLayout brokerInfoGroupLayout = new GridLayout();
brokerInfoGroupLayout.numColumns = 3;
advancedOptionGroup.setLayout(brokerInfoGroupLayout);
// JDBC attributes
Label attrLabel = new Label(advancedOptionGroup, SWT.LEFT);
attrLabel.setText(com.cubrid.common.ui.common.Messages.lblJdbcAttr);
attrLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
attrText = new Text(advancedOptionGroup, SWT.LEFT | SWT.BORDER);
attrText.setEditable(false);
attrText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Button btnAttr = new Button(advancedOptionGroup, SWT.NONE);
{
btnAttr.setText(com.cubrid.common.ui.common.Messages.btnJdbcAttr);
btnAttr.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
btnAttr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
JdbcOptionDialog dialog = new JdbcOptionDialog(getShell(), attrText.getText());
if (IDialogConstants.OK_ID == dialog.open()) {
String jdbcOptions = dialog.getJdbcOptions();
attrText.setText(StringUtil.nvl(jdbcOptions));
}
}
});
}
}
if (database != null && database.getDatabaseInfo() != null) {
String jdbcAttrs = database.getDatabaseInfo().getJdbcAttrs();
attrText.setText(StringUtil.nvl(jdbcAttrs));
String brokerIp = QueryOptions.getBrokerIp(database.getDatabaseInfo());
if (StringUtil.isEmpty(brokerIp)) {
brokerIp = database.getServer().getHostAddress();
}
if (brokerIp != null) {
brokerIpText.setText(brokerIp);
}
String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
brokerPort = (String) brokerPortCombo.getData(brokerPort);
if (brokerPort != null) {
brokerPortCombo.setText(brokerPort);
}
String charset = QueryOptions.getCharset(database.getDatabaseInfo());
charsetCombo.setItems(QueryOptions.getAllCharset(charset));
if (charset != null && charset.trim().length() > 0) {
charsetCombo.setText(charset);
} else {
charsetCombo.select(0);
}
}
setTitle(Messages.titleLoginDbDialog);
setMessage(Messages.msgLoginDbDialog);
return parentComp;
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class LoginDatabaseDialog method getBrokerPort.
/**
* Get the broker port
*
* @return
*/
private String getBrokerPort() {
String text = brokerPortCombo.getText();
if (brokerPortCombo.getData(text) != null) {
Object obj = brokerPortCombo.getData(text);
if (obj != null && obj instanceof BrokerInfo) {
BrokerInfo brokerInfo = (BrokerInfo) obj;
return brokerInfo.getPort();
}
}
int leftBracketIndex = text.indexOf("[");
if (leftBracketIndex >= 0 && leftBracketIndex + 1 < text.length()) {
String subString = text.substring(leftBracketIndex + 1);
int lineIndex = subString.indexOf("/");
if (lineIndex >= 1) {
return subString.substring(0, lineIndex);
}
int rightBracketIndex = subString.indexOf("]");
if (rightBracketIndex >= 1) {
return subString.substring(0, rightBracketIndex);
}
return subString;
}
return text;
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class CasRunnerConfigDialog method init.
/**
* Initials some values.
*
*/
private void init() {
if (execwithFile) {
checkBoxShowQueryResult.setSelection(false);
checkBoxShowQueryResult.setEnabled(false);
}
for (int i = 0, n = allDatabaseList.size(); i < n; i++) {
String dbname = (String) allDatabaseList.get(i);
comboDBName.add(dbname);
}
if ((getDbname().length() == 0) && (getUserName().length() == 0)) {
if (logstring.length() > 0) {
initWithLogString();
}
} else {
comboDBName.setText(getDbname());
textUserName.setText(getUserName());
}
int numbroker = brokerInfos.getBorkerInfoList().getBrokerInfoList().size();
for (int i = 0; i < numbroker; i++) {
BrokerInfo item = (BrokerInfo) brokerInfos.getBorkerInfoList().getBrokerInfoList().get(i);
comboBrokerName.add(item.getName());
}
if (getBrokerName().length() == 0) {
comboBrokerName.setText(targetBroker);
} else {
comboBrokerName.setText(getBrokerName());
}
if (getPassword().length() != 0) {
textPassword.setText(getPassword());
}
if (getNumThread().length() != 0) {
try {
spinnerNumThread.setSelection(Integer.parseInt(getNumThread()));
} catch (NumberFormatException ee) {
spinnerNumThread.setSelection(1);
}
}
{
try {
spinnerRepeatCount.setSelection(Integer.parseInt(getNumRepeatCount()));
} catch (NumberFormatException ee) {
spinnerRepeatCount.setSelection(1);
}
if (!execwithFile) {
checkBoxShowQueryResult.setEnabled(true);
checkBoxShowQueryResult.setSelection(isShowqueryresult());
checkBoxShowQueryPlan.setEnabled(isShowqueryresult());
checkBoxShowQueryPlan.setSelection(isShowqueryplan());
}
}
comboDBName.addModifyListener(this);
comboBrokerName.addModifyListener(this);
textUserName.addModifyListener(this);
textPassword.addModifyListener(this);
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class DatabaseConnectionPropertyPage method performOk.
public boolean performOk() {
if (charsetCombo == null || charsetCombo.isDisposed()) {
return true;
}
if (!checkValid()) {
return false;
}
boolean isChanged = false;
if (!brokerIpText.getText().equals(oldBrokerIp)) {
isChanged = true;
}
String brokerPort = "";
if (database != null) {
String text = brokerPortCombo.getText();
BrokerInfo brokerInfo = null;
if (brokerPortCombo.getData(text) instanceof BrokerInfo) {
brokerInfo = (BrokerInfo) brokerPortCombo.getData(text);
}
if (brokerInfo != null) {
brokerPort = brokerInfo.getPort();
} else {
brokerPort = text;
}
if (brokerPort != null && !brokerPort.equals(this.oldBrokerPort)) {
isChanged = true;
}
}
String charset = charsetCombo.getText();
if (!charset.equals(this.oldCharSet)) {
isChanged = true;
}
if (!isChanged) {
return true;
}
// check the query editor in this database
if (!LayoutUtil.checkAllQueryEditor(database)) {
return false;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
QueryOptions.setCharset(databaseInfo, charset);
if (brokerPort != null) {
QueryOptions.setBrokerPort(databaseInfo, brokerPort);
}
QueryOptions.setBrokerIp(databaseInfo, brokerIpText.getText());
QueryOptions.savePref();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.NODE_REFRESH));
return super.performOk();
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class DatabaseConnectionPropertyPage method createContents.
protected Control createContents(Composite parent) {
Composite top = new Composite(parent, SWT.NONE);
top.setLayout(new GridLayout());
top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final Group group = new Group(top, SWT.NONE);
group.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
group.setLayout(layout);
final Label labelBrokerIp = new Label(group, SWT.NONE);
labelBrokerIp.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
labelBrokerIp.setText(Messages.brokerIP);
brokerIpText = new Text(group, SWT.BORDER);
brokerIpText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
final Label labelBrokerPort = new Label(group, SWT.NONE);
labelBrokerPort.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
labelBrokerPort.setText(Messages.brokerPort);
brokerPortCombo = new Combo(group, SWT.NONE);
brokerPortCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
BrokerInfoList bis = brokerInfos == null ? null : brokerInfos.getBorkerInfoList();
if (bis != null) {
List<BrokerInfo> brokerInfoList = bis.getBrokerInfoList();
for (BrokerInfo brokerInfo : brokerInfoList) {
if (StringUtil.isEmpty(brokerInfo.getPort())) {
continue;
}
String status = "";
if (!StringUtil.isEqualIgnoreCase(brokerInfos.getBrokerstatus(), "ON")) {
status = "OFF";
} else {
status = !StringUtil.isEqualIgnoreCase(brokerInfo.getState(), "ON") ? "OFF" : "ON";
}
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
brokerPortCombo.add(text);
brokerPortCombo.setData(brokerInfo.getPort(), text);
brokerPortCombo.setData(text, brokerInfo);
}
}
Label charSetLbl = new Label(group, SWT.CHECK);
charSetLbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
charSetLbl.setText(Messages.lblCharSet);
charsetCombo = new Combo(group, SWT.BORDER);
charsetCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
loadPreference();
return top;
}
Aggregations