use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart 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.BrokerMonitorPart in project cubrid-manager by CUBRID.
the class DeleteBrokerMonitorAction method run.
/**
* Delete host and it's databases from dashboard.
*/
public void run() {
if (getSelectedObj() == null || getSelectedObj().length == 0) {
return;
}
BrokerMonitorPart part = (BrokerMonitorPart) getSelectedObj()[0];
//EditPart dashboardPart = part.getParent();
BrokerNode hn = (BrokerNode) part.getModel();
boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteBroker, hn.getName()));
if (!isDelete) {
return;
}
hn.getParent().removeBrokerNode(hn);
//dashboardPart.refresh();
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart 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.BrokerMonitorPart 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.BrokerMonitorPart in project cubrid-manager by CUBRID.
the class MonitorDashboardEditor method configureGraphicalViewer.
/**
* @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
viewer.setRootEditPart(rootEditPart);
viewer.setEditPartFactory(new MonitorEditPartFacotry());
ZoomManager manager = rootEditPart.getZoomManager();
double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
manager.setZoomLevels(zoomLevels);
getActionRegistry().registerAction(new ZoomInAction(manager));
getActionRegistry().registerAction(new ZoomOutAction(manager));
KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
viewer.setKeyHandler(keyHandler);
//initialize context menu
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
/**
* get menus to show.
*
* @param manager IMenuManager
*/
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
String[] ids = new String[] {};
if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof HostMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof ClientMonitorPart) {
ids = new String[] { EditAliasNameAction.ID };
} else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
ids = new String[] { EditAliasNameAction.ID };
}
for (String id : ids) {
if (id.equals(SEPARATOR)) {
manager.add(new Separator());
} else {
IAction action = ActionManager.getInstance().getAction(id);
((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
ActionManager.addActionToManager(manager, action);
}
}
manager.update(true);
}
});
viewer.setContextMenu(menuManager);
}
Aggregations