use of com.cubrid.common.ui.common.dialog.JdbcManageDialog in project cubrid-manager by CUBRID.
the class ConnectionComposite method createBrokerInfoGroup.
private void createBrokerInfoGroup(Composite composite) {
Group brokerInfoGroup = new Group(composite, SWT.NONE);
brokerInfoGroup.setText(Messages.grpBrokerInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
brokerInfoGroup.setLayoutData(gridData);
brokerInfoGroup.setLayout(createGridLayout(3));
Label brokerIpLabel = new Label(brokerInfoGroup, SWT.LEFT);
brokerIpLabel.setText(Messages.lblLoginServerName);
brokerIpLabel.setLayoutData(createGridData(1, 1, -1, -1));
brokerIpText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
brokerIpText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
brokerIpText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
brokerIpText.selectAll();
}
});
Label brokerPortLabel = new Label(brokerInfoGroup, SWT.LEFT);
brokerPortLabel.setText(Messages.lblLoginBrokerPort);
brokerPortLabel.setLayoutData(createGridData(1, 1, -1, -1));
VerifyListener verifyListener = new VerifyListener() {
public void verifyText(VerifyEvent event) {
Pattern pattern = Pattern.compile("[0-9]*");
Matcher matcher = pattern.matcher(event.text);
if (matcher.matches()) {
event.doit = true;
} else if (event.text.length() > 0) {
event.doit = false;
} else {
event.doit = true;
}
}
};
Composite portAndShardComp = new Composite(brokerInfoGroup, SWT.NONE);
portAndShardComp.setLayout(createGridLayout(3, 0, 0));
portAndShardComp.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, -1, -1));
if (isMultiBroker) {
brokerPortCombo = new Combo(portAndShardComp, SWT.LEFT | SWT.BORDER);
brokerPortCombo.setLayoutData(createGridData(GridData.BEGINNING, 1, 1, 100, -1));
brokerPortCombo.addVerifyListener(verifyListener);
} else {
brokerPortText = new Text(portAndShardComp, SWT.LEFT | SWT.BORDER);
brokerPortText.setLayoutData(createGridData(BEGINNING, 1, 1, 100, -1));
brokerPortText.addVerifyListener(verifyListener);
}
btnShard = new Button(portAndShardComp, SWT.CHECK);
btnShard.setLayoutData(createGridData(BEGINNING, 1, 1, -1, -1));
btnShard.setText(com.cubrid.common.ui.query.Messages.shardBrokerLabel);
btnShard.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (btnShard.getSelection()) {
openWarningBox(shardBrokerAlert);
}
btnShardId.setEnabled(btnShard.getSelection());
}
});
btnShardId = new Button(portAndShardComp, SWT.PUSH);
btnShardId.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
btnShardId.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(getShell());
dialog.setDatabaseInfo(dbInfo);
dialog.setShardId(curShardId);
dialog.setShardVal(curShardVal);
dialog.setShardQueryType(shardQueryType);
if (dialog.open() == OK_ID) {
curShardId = dialog.getShardId();
curShardVal = dialog.getShardVal();
shardQueryType = dialog.getShardQueryType();
if (dbInfo != null) {
dbInfo.setCurrentShardId(curShardId);
dbInfo.setCurrentShardVal(curShardVal);
dbInfo.setShardQueryType(shardQueryType);
}
updateShardIdButtonText();
}
}
});
updateShardIdButtonText();
Label charsetLabel = new Label(brokerInfoGroup, SWT.LEFT);
charsetLabel.setText(com.cubrid.common.ui.query.Messages.lblCharSet);
charsetLabel.setLayoutData(createGridData(1, 1, -1, -1));
charsetCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
charsetCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, 100, -1));
Label jdbcLabel = new Label(brokerInfoGroup, SWT.LEFT);
jdbcLabel.setText(Messages.lblDbJdbcVersion);
jdbcLabel.setLayoutData(createGridData(1, 1, -1, -1));
jdbcCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.READ_ONLY | SWT.BORDER);
jdbcCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
Button btnOpen = new Button(brokerInfoGroup, SWT.NONE);
btnOpen.setText(Messages.btnBrowse);
btnOpen.setLayoutData(createGridData(1, 1, 80, -1));
btnOpen.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
JdbcManageDialog dialog = new JdbcManageDialog(getShell());
if (dialog.open() == OK_ID) {
String jdbcVersion = dialog.getSelectedJdbcVersion();
if (isBlank(jdbcVersion)) {
jdbcVersion = jdbcCombo.getText();
}
resetJdbcCombo(jdbcVersion);
}
}
});
// JDBC attributes
Label attrLabel = new Label(brokerInfoGroup, SWT.LEFT);
attrLabel.setText(Messages.lblJdbcAttr);
attrLabel.setLayoutData(createGridData(1, 1, -1, -1));
attrText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
attrText.setEditable(false);
attrText.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
Button btnAttr = new Button(brokerInfoGroup, SWT.NONE);
btnAttr.setText(Messages.btnJdbcAttr);
btnAttr.setLayoutData(createGridData(1, 1, 80, -1));
btnAttr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
JdbcOptionDialog dialog = new JdbcOptionDialog(getShell(), attrText.getText());
if (dialog.open() == OK_ID) {
attrText.setText(dialog.getJdbcOptions());
}
}
});
}
use of com.cubrid.common.ui.common.dialog.JdbcManageDialog in project cubrid-manager by CUBRID.
the class HostDialog method createDialogArea.
/**
* Create dialog area content
*
* @param parent the parent composite
* @return the control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
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 hostNameLabel = new Label(composite, SWT.LEFT);
hostNameLabel.setText(Messages.lblHostName);
hostNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
hostNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
if (server != null) {
hostNameText.setText(server.getLabel());
}
hostNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
hostNameText.addModifyListener(this);
Label addressNameLabel = new Label(composite, SWT.LEFT);
addressNameLabel.setText(Messages.lblAddress);
addressNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
addressText = new Text(composite, SWT.LEFT | SWT.BORDER);
if (server != null) {
addressText.setText(server.getHostAddress());
} else {
addressText.setText("localhost");
}
addressText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
addressText.addModifyListener(this);
Label portNameLabel = new Label(composite, SWT.LEFT);
portNameLabel.setText(Messages.lblPort);
portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
portText = new Text(composite, SWT.LEFT | SWT.BORDER);
portText.setTextLimit(5);
if (server != null) {
portText.setText(server.getMonPort());
} else {
portText.setText("8001");
}
portText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
portText.selectAll();
portText.setFocus();
}
});
portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
portText.addModifyListener(this);
Label userNameLabel = new Label(composite, SWT.LEFT);
userNameLabel.setText(Messages.lblUserName);
userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
userNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
if (server != null) {
userNameText.setText(server.getUserName());
} else {
userNameText.setText("admin");
}
userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
userNameText.addModifyListener(this);
Label passwordLabel = new Label(composite, SWT.LEFT);
passwordLabel.setText(Messages.lblPassword);
passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
passwordText = new Text(composite, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
if (server != null && server.getPassword() != null && server.isAutoSavePassword()) {
passwordText.setText(server.getPassword());
}
passwordText.addModifyListener(this);
new Label(composite, SWT.NONE);
Label passHelp = new Label(composite, SWT.None);
passHelp.setText(Messages.msgPasswordHelp);
passHelp.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
new Label(composite, SWT.NONE).setLayoutData(CommonUITool.createGridData(1, 1, 0, 0));
Composite btnComposite = new Composite(composite, SWT.NONE);
btnComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
layout = new GridLayout();
layout.numColumns = 4;
btnComposite.setLayout(layout);
Button btnSavePassword = new Button(btnComposite, SWT.CHECK);
btnSavePassword.setLayoutData(CommonUITool.createGridData(SWT.LEFT, 1, 1, -1, -1));
btnSavePassword.setText(Messages.btnSavePassword);
if (server == null) {
btnSavePassword.setSelection(true);
isSavePassword = true;
} else {
btnSavePassword.setSelection(server.isAutoSavePassword());
isSavePassword = server.isAutoSavePassword();
}
btnSavePassword.addSelectionListener(new SelectionAdapter() {
/**
* Sent when selection occurs in the control. The default behavior
* is to do nothing.
*
* @param e an event containing information about the selection
*/
public void widgetSelected(SelectionEvent event) {
isSavePassword = !isSavePassword;
}
});
btnAutoCommit = new Button(btnComposite, SWT.CHECK);
btnAutoCommit.setLayoutData(CommonUITool.createGridData(SWT.LEFT, 1, 1, -1, -1));
btnAutoCommit.setText(com.cubrid.common.ui.query.Messages.autoCommitLabel);
boolean useAutoCommit = QueryOptions.getAutoCommit(server == null ? null : server.getServerInfo());
btnAutoCommit.setSelection(useAutoCommit);
btnUseTimeOut = new Button(btnComposite, SWT.CHECK);
btnUseTimeOut.setLayoutData(CommonUITool.createGridData(SWT.LEFT, 1, 1, -1, -1));
btnUseTimeOut.setText(Messages.btnSetTimeOut);
btnUseTimeOut.setSelection(false);
timeOutCombo = new Combo(btnComposite, SWT.READ_ONLY);
timeOutCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
timeOutCombo.setItems(soTimeOutMsgs);
timeOutCombo.setEnabled(false);
btnUseTimeOut.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
timeOutCombo.setEnabled(btnUseTimeOut.getSelection());
timeOutCombo.select(0);
}
});
if (server != null && server.getServerInfo() != null) {
int soTimeOut = server.getServerInfo().getSoTimeOut();
if (soTimeOut != SocketTask.SOCKET_IO_TIMEOUT_MSEC) {
int index = 0;
for (int i = 0; i < soTimeOutValues.length; i++) {
if (soTimeOutValues[i] == soTimeOut) {
index = i;
break;
}
}
btnUseTimeOut.setSelection(true);
timeOutCombo.setEnabled(true);
timeOutCombo.select(index);
}
}
Label jdbcLabel = new Label(composite, SWT.LEFT);
jdbcLabel.setText(Messages.lblJdbcVersion);
jdbcLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
jdbcVersionCombo = new Combo(composite, SWT.LEFT | SWT.READ_ONLY);
jdbcVersionCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
resetJdbcCombo();
jdbcVersionCombo.addModifyListener(this);
Button btnOpen = new Button(composite, SWT.NONE);
{
btnOpen.setText(Messages.btnBrowse);
btnOpen.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
btnOpen.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
JdbcManageDialog dialog = new JdbcManageDialog(getShell());
if (IDialogConstants.OK_ID == dialog.open()) {
resetJdbcCombo();
}
}
});
}
if (isNewHost && server != null) {
hostNameText.selectAll();
hostNameText.setFocus();
} else if (server != null) {
passwordText.selectAll();
passwordText.setFocus();
}
if (isNewHost) {
setTitle(Messages.titleAddHostDialog);
setMessage(Messages.msgAddHostDialog);
} else {
if (actionIsConnect) {
setTitle(Messages.titleConnectHostDialog);
setMessage(Messages.msgConnectHostDialog);
} else {
setTitle(Messages.titleEditHostDialog);
setMessage(Messages.msgEditHostDialog);
}
}
if (actionIsConnect) {
hostNameText.setEnabled(false);
portText.setEnabled(false);
passwordText.setEnabled(false);
jdbcVersionCombo.setEnabled(false);
userNameText.setEnabled(false);
addressText.setEnabled(false);
btnSavePassword.setEnabled(false);
btnAutoCommit.setEnabled(false);
btnUseTimeOut.setEnabled(false);
timeOutCombo.setEnabled(false);
btnOpen.setEnabled(false);
passHelp.setVisible(false);
}
return parentComp;
}
Aggregations