use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode 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.editor.model.HostNode in project cubrid-manager by CUBRID.
the class AddDatabaseMonitorAction method isSupported.
/**
* selection is Host node host is connected
*
* @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) {
if (obj instanceof HostMonitorPart) {
HostMonitorPart hostMonPart = (HostMonitorPart) obj;
HostNode hostNode = (HostNode) hostMonPart.getModel();
if (hostNode == null || hostNode.getServerInfo() == null || hostNode.getServerInfo().getLoginedUserInfo() == null) {
return false;
}
ServerType type = hostNode.getServerInfo().getServerType();
return type == ServerType.BOTH || type == ServerType.DATABASE;
}
return false;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class DbDashboardHistoryAction method run.
/**
* Open monitor host detail windows.
*/
public void run() {
if (getSelectedObj() == null || getSelectedObj().length == 0) {
return;
}
Object obj = getSelectedObj()[0];
if (!(obj instanceof DatabaseMonitorPart)) {
return;
}
DatabaseMonitorPart part = (DatabaseMonitorPart) obj;
DatabaseNode dn = (DatabaseNode) part.getModel();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
HostNode hn = dn.getParent();
String secondaryId = new StringBuffer(dn.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
IViewReference viewReference = page.findViewReference(DbDashboardHistoryViewPart.ID, secondaryId);
if (viewReference == null) {
try {
IViewPart viewPart = page.showView(DbDashboardHistoryViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
} catch (PartInitException ex) {
viewReference = null;
}
} else {
IViewPart viewPart = viewReference.getView(false);
window.getActivePage().bringToTop(viewPart);
((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class DeleteHostMonitorAction method run.
/**
* Delete host and it's databases from dashboard.
*/
public void run() {
if (getSelectedObj() == null || getSelectedObj().length == 0) {
return;
}
HostMonitorPart part = (HostMonitorPart) getSelectedObj()[0];
DashboardPart dashboardPart = (DashboardPart) part.getParent();
Dashboard dashboard = (Dashboard) dashboardPart.getModel();
HostNode hn = (HostNode) part.getModel();
boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteHost, hn.getName()));
if (!isDelete) {
return;
}
dashboard.removeNode(hn);
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.
the class HideHostAction 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) {
if (obj instanceof HostMonitorPart) {
HostMonitorPart hp = (HostMonitorPart) obj;
HostNode hn = (HostNode) hp.getModel();
if (hn.getDbNodeList().isEmpty() && hn.getBrokerNodeList().isEmpty()) {
return false;
}
}
return true;
}
Aggregations