use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart in project cubrid-manager by CUBRID.
the class ShowHostAction method run.
/**
* Create a new figure in dashboard.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IStructuredSelection selection = (IStructuredSelection) getSelection();
Iterator<?> iterator = selection.iterator();
List<HostNode> hosts = new ArrayList<HostNode>();
EditPart root = null;
while (iterator.hasNext()) {
Object objSelected = iterator.next();
if (objSelected instanceof DatabaseMonitorPart) {
DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
DatabaseNode dn = ((DatabaseNode) cmp.getModel());
if (!hosts.contains(dn.getParent())) {
hosts.add(dn.getParent());
}
root = cmp.getParent();
} else if (objSelected instanceof BrokerMonitorPart) {
BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
BrokerNode bn = ((BrokerNode) cmp.getModel());
if (!hosts.contains(bn.getParent())) {
hosts.add(bn.getParent());
}
root = cmp.getParent();
}
}
for (HostNode host : hosts) {
if (host.isVisible() == isChecked()) {
continue;
}
host.setVisible(isChecked());
}
if (root != null) {
root.refresh();
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart 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.parts.DatabaseMonitorPart in project cubrid-manager by CUBRID.
the class MonitorDetailAction method run.
/**
* Open monitor detail windows.
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
HANodePart part = null;
if (objArr[0] instanceof HostMonitorPart) {
part = (HostMonitorPart) objArr[0];
} else if (objArr[0] instanceof DatabaseMonitorPart) {
part = (DatabaseMonitorPart) objArr[0];
} else if (objArr[0] instanceof BrokerMonitorPart) {
part = (BrokerMonitorPart) objArr[0];
}
if (part != null) {
SelectionRequest sr = new SelectionRequest();
sr.setType(RequestConstants.REQ_OPEN);
part.performRequest(sr);
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart in project cubrid-manager by CUBRID.
the class MonitorDetailAction 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) {
HostNode hostNode = null;
if (obj instanceof HostMonitorPart) {
hostNode = (HostNode) ((HostMonitorPart) obj).getModel();
} else if (obj instanceof BrokerMonitorPart) {
BrokerNode brokerNode = (BrokerNode) ((BrokerMonitorPart) obj).getModel();
hostNode = brokerNode.getParent();
}
if (hostNode != null) {
return hostNode.isConnected();
}
if (obj instanceof DatabaseMonitorPart) {
DatabaseNode dbNode = (DatabaseNode) ((DatabaseMonitorPart) obj).getModel();
hostNode = dbNode.getParent();
return hostNode.isConnected() && dbNode.isConnected();
}
return false;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart in project cubrid-manager by CUBRID.
the class OpenApplyLogDBLogAction method run.
/**
* open apply database log
*
* @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;
}
DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) objArr[0];
DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
HostNode hostNode = dbNode.getParent();
ServerInfo serverInfo = hostNode.getServerInfo();
CubridServer server = new CubridServer(serverInfo.getHostAddress(), serverInfo.getHostAddress(), null, null);
server.setServerInfo(serverInfo);
LogInfo logInfo = new LogInfo();
String logPath = serverInfo.getEnvInfo().getRootDir() + serverInfo.getPathSeparator() + "log" + serverInfo.getPathSeparator();
String fileName = dbNode.getDbName() + "@localhost_applylogdb_" + dbNode.getDbName() + "_" + hostNode.getHostStatusInfo().getMasterHostStatusInfo().getHostName() + ".err";
logInfo.setPath(logPath + fileName);
DefaultCubridNode dbLogInfoNode = new DefaultCubridNode(dbNode.getDbName() + ICubridNodeLoader.NODE_SEPARATOR + "apply_database_log", logInfo.getName(), "icons/navigator/log_item.png");
dbLogInfoNode.setType(CubridNodeType.LOGS_APPLY_DATABASE_LOG);
dbLogInfoNode.setModelObj(logInfo);
dbLogInfoNode.setEditorId(LogEditorPart.ID);
dbLogInfoNode.setContainer(false);
dbLogInfoNode.setServer(server);
LogViewAction action = (LogViewAction) ActionManager.getInstance().getAction(LogViewAction.ID);
action.setCubridNode(dbLogInfoNode);
action.run();
}
Aggregations