use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class DatabaseMonitorPart method performRequest.
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
* @param req Request
*/
public void performRequest(Request req) {
if (req.getType() == RequestConstants.REQ_OPEN) {
DatabaseNode databaseNode = (DatabaseNode) getModel();
if (!databaseNode.isConnected()) {
return;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
HostNode hn = databaseNode.getParent();
String secondaryId = new StringBuffer(databaseNode.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
IViewReference viewReference = page.findViewReference(DatabaseDashboardViewPart.ID, secondaryId);
if (viewReference == null) {
try {
IViewPart viewPart = page.showView(DatabaseDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
((DatabaseDashboardViewPart) viewPart).init(databaseNode);
} catch (PartInitException ex) {
viewReference = null;
}
} else {
IViewPart viewPart = viewReference.getView(false);
window.getActivePage().bringToTop(viewPart);
((DatabaseDashboardViewPart) viewPart).init(databaseNode);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class ShowHostAction method isSupported.
/**
* Always support
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java.lang.Object)
* @param obj Object
* @return boolean support:true;not support:false;
*/
public boolean isSupported(Object obj) {
IStructuredSelection selection = (IStructuredSelection) getSelection();
Iterator<?> iterator = selection.iterator();
boolean isVisible = true;
while (iterator.hasNext()) {
Object objSelected = iterator.next();
if (objSelected instanceof DatabaseMonitorPart) {
DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
DatabaseNode dn = ((DatabaseNode) cmp.getModel());
if (!dn.getParent().isVisible()) {
isVisible = false;
break;
}
} else if (objSelected instanceof BrokerMonitorPart) {
BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
BrokerNode bn = ((BrokerNode) cmp.getModel());
if (!bn.getParent().isVisible()) {
isVisible = false;
break;
}
}
}
setChecked(isVisible);
return true;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class AddHADatabaseDialog 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);
{
GridLayout compLayout = new GridLayout();
compLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
compLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
compLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
compLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(compLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
}
Group cmServerInfoGroup = new Group(composite, SWT.NONE);
cmServerInfoGroup.setText(Messages.grpHostInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
cmServerInfoGroup.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
cmServerInfoGroup.setLayout(layout);
Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
ipLabel.setText(Messages.lblIPAddress);
ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
ipCombo = new Combo(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
ipCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
portNameLabel.setText(Messages.lblPort);
portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
portText.setTextLimit(5);
portText.setText("8001");
portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
portText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
portText.selectAll();
portText.setFocus();
}
});
Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
userNameLabel.setText(Messages.lblUserName);
userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
userNameText.setText("admin");
userNameText.setEnabled(false);
userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
passwordLabel.setText(Messages.lblPassword);
passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
passwordText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
passwordText.selectAll();
passwordText.setFocus();
}
});
Label dbNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
dbNameLabel.setText(Messages.lblDbName);
dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
dbNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Label dbaPasswordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
dbaPasswordLabel.setText(Messages.lblDbaPassword);
dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbaPasswordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Composite btnComposite = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
btnComposite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
btnComposite.setLayoutData(gridData);
addDatabaseButton = new Button(btnComposite, SWT.NONE);
addDatabaseButton.setText(Messages.btnAddDb);
addDatabaseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//check this database whether already be added
String dbName = dbNameText.getText();
if (isDbExist()) {
setErrorMessage(Messages.bind(Messages.errDbExist, dbName));
return;
}
//connect server
String address = ipCombo.getText();
String port = portText.getText();
String userName = userNameText.getText();
String password = passwordText.getText();
ServerInfo serverInfo = ServerManager.getInstance().getServer(address, Integer.parseInt(port), userName);
if (serverInfo == null) {
serverInfo = new ServerInfo();
serverInfo.setServerName(address);
serverInfo.setHostAddress(address);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
}
String dbaPassword = dbaPasswordText.getText();
TaskExecutor executor = null;
VerifyDbUserPasswordTask verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
verifyDbUserPasswordTask.setDbName(dbName);
verifyDbUserPasswordTask.setDbUser("dba");
verifyDbUserPasswordTask.setDbPassword(dbaPassword);
if (serverInfo.isConnected()) {
DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
if (dbInfo == null) {
setErrorMessage(Messages.errDbNoExist);
return;
}
executor = new CommonTaskExec(null);
if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
String pwd = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (!dbaPassword.equals(pwd)) {
CommonUITool.openErrorBox(Messages.errDbaPassowrd);
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
return;
}
} else {
executor.addTask(verifyDbUserPasswordTask);
}
} else {
executor = new ConnectHostExecutor(getShell(), serverInfo, true);
executor.addTask(verifyDbUserPasswordTask);
}
//get this database status
HAHostStatusInfo haHostStatusInfo = null;
HADatabaseStatusInfo haDbStatusInfo = null;
GetDbModeTask getDbModeTask = new GetDbModeTask(serverInfo);
List<String> dbList = new ArrayList<String>();
dbList.add(dbNameText.getText());
getDbModeTask.setDbList(dbList);
executor.addTask(getDbModeTask);
new ExecTaskWithProgress(executor).exec(true, true);
if (!executor.isSuccess()) {
if (verifyDbUserPasswordTask != null && verifyDbUserPasswordTask.getErrorMsg() != null && verifyDbUserPasswordTask.getErrorMsg().length() > 0) {
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
}
return;
}
if (getDbModeTask.getDbModes() != null && getDbModeTask.getDbModes().size() > 0) {
List<HADatabaseStatusInfo> dbModeList = getDbModeTask.getDbModes();
haDbStatusInfo = dbModeList.get(0);
haHostStatusInfo = getHAHostStatusInfo(serverInfo.getHostAddress());
if (haHostStatusInfo != null) {
haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
}
}
if (haDbStatusInfo == null) {
haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbNameText.getText(), haHostStatusInfo, serverInfo);
}
if (haHostStatusInfo == null) {
haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
}
DatabaseNode dbNode = new DatabaseNode();
dbNode.setDbName(dbNameText.getText());
dbNode.setDbUser("dba");
dbNode.setDbPassword(dbaPassword);
dbNode.setName(dbNameText.getText());
dbNode.setConnected(true);
dbNode.setHaDatabaseStatus(haDbStatusInfo);
HostNode hostNode = new HostNode();
hostNode.setName(ipCombo.getText() + ":" + portText.getText());
hostNode.setIp(ipCombo.getText());
hostNode.setPort(portText.getText());
hostNode.setUserName(userNameText.getText());
hostNode.setPassword(passwordText.getText());
hostNode.setHostStatusInfo(haHostStatusInfo);
hostNode.setConnected(true);
dbNode.setParent(hostNode);
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", dbNode.getDbName());
map.put("1", DBStatusType.getShowText(dbNode.getDbStatusType()));
map.put("2", dbNode.getParent().getIp());
map.put("3", dbNode.getParent().getPort());
map.put("4", HostStatusType.getShowText(haHostStatusInfo.getStatusType()));
map.put("5", dbNode);
if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
dbNodeList.add(0, map);
} else {
dbNodeList.add(map);
}
dbTableViewer.refresh();
for (int i = 0; i < dbTable.getColumnCount(); i++) {
dbTable.getColumn(i).pack();
}
verify();
}
});
addDatabaseButton.setEnabled(false);
createTable(composite);
setTitle(Messages.titleAddHADbDialog);
initial();
return parentComp;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class AddHADatabaseDialog method isDbExist.
/**
*
* Check whether the database already exist
*
* @return boolean
*/
private boolean isDbExist() {
String ip = ipCombo.getText();
String port = portText.getText();
String userName = userNameText.getText();
String dbName = dbNameText.getText();
for (int i = 0; i < dbNodeList.size(); i++) {
DatabaseNode dbNode = (DatabaseNode) dbNodeList.get(i).get("5");
HostNode hostNode = dbNode.getParent();
if (ip.equals(hostNode.getIp()) && port.equals(hostNode.getPort()) && userName.equals(hostNode.getUserName()) && dbName.equals(dbNode.getDbName())) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class OpenApplyLogDBLogAction method isSupported.
/**
*
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java.lang.Object)
* @param obj Object
* @return is supported.
*/
public boolean isSupported(Object obj) {
if (obj instanceof DatabaseMonitorPart) {
DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) obj;
DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
HostNode hostNode = dbNode.getParent();
if (hostNode != null && hostNode.isConnected() && (dbNode.getDbStatusType() == DBStatusType.STANDBY || dbNode.getDbStatusType() == DBStatusType.MAINTENANCE) && hostNode.getHostStatusInfo() != null && hostNode.getHostStatusInfo().getMasterHostStatusInfo() != null) {
return true;
}
}
return false;
}
Aggregations