use of com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard in project cubrid-manager by CUBRID.
the class AddDatabaseMonitorAction method run.
/**
* open add database monitor dialog.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
HostMonitorPart hostMonPart = (HostMonitorPart) objArr[0];
HostNode hostNode = (HostNode) hostMonPart.getModel();
Dashboard dashboard = (Dashboard) hostMonPart.getParent().getModel();
if (hostNode != null && dashboard != null) {
AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, dashboard.getHostNodeList(), 1);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(dashboard, addedHostNodeList);
HAUtil.calcLocation(dashboard.getHostNodeList());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard in project cubrid-manager by CUBRID.
the class AddDashboardDialog method createDbTree.
/**
*
* Create table area
*
* @param parent the parent composite
*/
private void createDbTree(Composite parent) {
Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.lblDashboardInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
tipLabel.setLayoutData(gridData);
dbTv = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
{
dbTree = dbTv.getTree();
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
gridData.heightHint = 200;
dbTree.setLayoutData(gridData);
dbTree.setHeaderVisible(true);
dbTree.setLinesVisible(true);
TreeColumn column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colIP);
column.setWidth(120);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colPort);
column.setWidth(50);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colServerType);
column.setWidth(100);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colServerStatus);
column.setWidth(100);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colName);
column.setWidth(150);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colStatus);
column.setWidth(150);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colType);
column.setWidth(60);
dbTv.setContentProvider(new DatabaseProvider());
dbTv.setLabelProvider(new DatabaseProvider());
dbTv.setInput(hostNodeList);
dbTree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
}
});
}
Composite composite = new Composite(parent, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
composite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
composite.setLayoutData(gridData);
Button addButton = new Button(composite, SWT.NONE);
addButton.setText(Messages.btnAdd);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
HostNode hostNode = null;
int addType = 0;
if (selection != null && !selection.isEmpty()) {
Object obj = selection.getFirstElement();
if (obj instanceof HostNode) {
hostNode = (HostNode) obj;
addType = 0;
} else if (obj instanceof DatabaseNode) {
hostNode = ((DatabaseNode) obj).getParent();
addType = 1;
} else if (obj instanceof BrokerNode) {
hostNode = ((BrokerNode) obj).getParent();
addType = 2;
}
}
AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, hostNodeList, addType);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
if (IDialogConstants.OK_ID == dialog.open()) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(hostNodeList, addedHostNodeList);
dbTv.refresh();
}
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
verify();
}
});
deleteButton = new Button(composite, SWT.NONE);
deleteButton.setText(Messages.btnDelete);
deleteButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
if (selection != null && !selection.isEmpty()) {
Object[] objs = selection.toArray();
for (int i = 0; i < objs.length; i++) {
Object obj = objs[i];
if (obj instanceof HostNode) {
hostNodeList.remove((HostNode) obj);
} else if (obj instanceof DatabaseNode) {
((DatabaseNode) obj).getParent().getCopyedHaNodeList().remove((DatabaseNode) obj);
} else if (obj instanceof BrokerNode) {
((BrokerNode) obj).getParent().getCopyedHaNodeList().remove((BrokerNode) obj);
}
}
dbTv.refresh();
}
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
verify();
}
});
deleteButton.setEnabled(false);
}
use of com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard in project cubrid-manager by CUBRID.
the class AddBrokerMonitorAction method run.
/**
* open add broker monitor dialog.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
HostMonitorPart hostMonPart = (HostMonitorPart) objArr[0];
HostNode hostNode = (HostNode) hostMonPart.getModel();
Dashboard dashboard = (Dashboard) hostMonPart.getParent().getModel();
if (hostNode != null && dashboard != null) {
AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, dashboard.getHostNodeList(), 2);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(dashboard, addedHostNodeList);
HAUtil.calcLocation(dashboard.getHostNodeList());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard in project cubrid-manager by CUBRID.
the class AddHostMonitorAction method run.
/**
* Open add host monitor dialog.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
DashboardPart dp = (DashboardPart) objArr[0];
Dashboard dashboard = (Dashboard) dp.getModel();
if (dashboard != null) {
AddHostAndDbWizard wizard = new AddHostAndDbWizard(null, dashboard.getHostNodeList(), 0);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(dashboard, addedHostNodeList);
HAUtil.calcLocation(dashboard.getHostNodeList());
}
}
}
Aggregations