use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class DashboardsDynamicMenu method fill.
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
*/
@Override
public void fill(Menu menu, int index) {
final Object selection = evalService.getCurrentState().getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if ((selection == null) || !(selection instanceof IStructuredSelection))
return;
final AbstractObject object = (AbstractObject) ((IStructuredSelection) selection).getFirstElement();
if (!(object instanceof Container) && !(object instanceof Cluster) && !(object instanceof Node) && !(object instanceof MobileDevice) && !(object instanceof ServiceRoot) && !(object instanceof Subnet) && !(object instanceof Zone) && !(object instanceof Condition) && !(object instanceof EntireNetwork) && !(object instanceof Sensor))
return;
List<AbstractObject> dashboards = object.getDashboards(true);
if (dashboards.isEmpty())
return;
Collections.sort(dashboards, new Comparator<AbstractObject>() {
@Override
public int compare(AbstractObject o1, AbstractObject o2) {
return o1.getObjectName().compareToIgnoreCase(o2.getObjectName());
}
});
final Menu dashboardsMenu = new Menu(menu);
for (AbstractObject d : dashboards) {
final MenuItem item = new MenuItem(dashboardsMenu, SWT.PUSH);
item.setText(d.getObjectName());
item.setData(d.getObjectId());
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
window.getActivePage().showView(DashboardView.ID, item.getData().toString(), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException ex) {
MessageDialogHelper.openError(window.getShell(), Messages.get().OpenDashboard_Error, Messages.get().OpenDashboard_ErrorText + ex.getMessage());
}
}
});
}
MenuItem dashboardsMenuItem = new MenuItem(menu, SWT.CASCADE, index);
dashboardsMenuItem.setText(Messages.get().DashboardsDynamicMenu_Dashboards);
dashboardsMenuItem.setMenu(dashboardsMenu);
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class ServiceDependency method addParentServices.
/**
* Add parent services for given object
*
* @param object
*/
private void addParentServices(AbstractObject object, long parentElementId) {
Iterator<Long> it = object.getParents();
while (it.hasNext()) {
long objectId = it.next();
AbstractObject parent = session.findObjectById(objectId);
if ((parent != null) && ((parent instanceof Container) || (parent instanceof Cluster))) {
long elementId = mapPage.createElementId();
mapPage.addElement(new NetworkMapObject(elementId, objectId));
mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, parentElementId, elementId));
addParentServices(parent, elementId);
}
}
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class ObjectBrowser method registerActionValidators.
/**
* Register object action validators
*/
private void registerActionValidators() {
List<ActionValidatorData> list = new ArrayList<ActionValidatorData>();
// Read all registered extensions and create validators
final IExtensionRegistry reg = Platform.getExtensionRegistry();
// $NON-NLS-1$
IConfigurationElement[] elements = reg.getConfigurationElementsFor("org.netxms.ui.eclipse.objectbrowser.objectActionValidators");
for (int i = 0; i < elements.length; i++) {
try {
final ActionValidatorData v = new ActionValidatorData();
// $NON-NLS-1$
v.validator = (ObjectActionValidator) elements[i].createExecutableExtension("class");
// $NON-NLS-1$
v.priority = safeParseInt(elements[i].getAttribute("priority"));
list.add(v);
} catch (CoreException e) {
e.printStackTrace();
}
}
// Sort handlers by priority
Collections.sort(list, new Comparator<ActionValidatorData>() {
@Override
public int compare(ActionValidatorData arg0, ActionValidatorData arg1) {
return arg0.priority - arg1.priority;
}
});
actionValidators = new ObjectActionValidator[list.size() + 1];
int i = 0;
for (ActionValidatorData v : list) actionValidators[i++] = v.validator;
// Default validator
actionValidators[i] = new ObjectActionValidator() {
@Override
public int isValidSelectionForMove(SubtreeType subtree, AbstractObject currentObject, AbstractObject parentObject) {
switch(subtree) {
case INFRASTRUCTURE:
return ((currentObject instanceof Node) || (currentObject instanceof Cluster) || (currentObject instanceof Subnet) || (currentObject instanceof Condition) || (currentObject instanceof Rack) || (currentObject instanceof MobileDevice) || (currentObject instanceof Container) || (currentObject instanceof Sensor)) && ((parentObject instanceof Container) || (parentObject instanceof ServiceRoot)) ? APPROVE : REJECT;
case TEMPLATES:
return ((currentObject instanceof Template) || (currentObject instanceof TemplateGroup)) && ((parentObject instanceof TemplateGroup) || (parentObject instanceof TemplateRoot)) ? APPROVE : REJECT;
case BUSINESS_SERVICES:
return (currentObject instanceof BusinessService) && ((parentObject instanceof BusinessService) || (parentObject instanceof BusinessServiceRoot)) ? APPROVE : REJECT;
case MAPS:
return ((currentObject instanceof NetworkMap) || (currentObject instanceof NetworkMapGroup)) && ((parentObject instanceof NetworkMapGroup) || (parentObject instanceof NetworkMapRoot)) ? APPROVE : REJECT;
case DASHBOARDS:
return (((currentObject instanceof Dashboard) || (currentObject instanceof DashboardGroup)) && ((parentObject instanceof DashboardRoot) || (parentObject instanceof DashboardGroup) || (parentObject instanceof Dashboard))) ? APPROVE : REJECT;
case POLICIES:
return ((currentObject instanceof AgentPolicy) || (currentObject instanceof PolicyGroup)) && ((parentObject instanceof PolicyGroup) || (parentObject instanceof PolicyRoot)) ? APPROVE : REJECT;
default:
return REJECT;
}
}
};
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class BindObjectTo method selectionChanged.
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() > 0)) {
objects = new HashSet<Long>();
for (Object o : ((IStructuredSelection) selection).toList()) {
if ((o instanceof AbstractNode) || (o instanceof Subnet) || (o instanceof MobileDevice) || (o instanceof Rack) || (o instanceof Cluster) || (o instanceof Sensor))
objects.add(((AbstractObject) o).getObjectId());
}
} else {
action.setEnabled(false);
objects = null;
}
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class ObjectToolsDynamicMenu method buildNodeSet.
/**
* Build node set from selection
*
* @param selection
* @return
*/
private Set<ObjectContext> buildNodeSet(IStructuredSelection selection) {
final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Object o : selection.toList()) {
if (o instanceof AbstractNode) {
nodes.add(new ObjectContext((AbstractNode) o, null));
} else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster)) {
for (AbstractObject n : ((AbstractObject) o).getAllChilds(AbstractObject.OBJECT_NODE)) nodes.add(new ObjectContext((AbstractNode) n, null));
} else if (o instanceof Alarm) {
AbstractNode n = (AbstractNode) session.findObjectById(((Alarm) o).getSourceObjectId(), AbstractNode.class);
if (n != null)
nodes.add(new ObjectContext(n, (Alarm) o));
} else if (o instanceof ObjectWrapper) {
AbstractObject n = ((ObjectWrapper) o).getObject();
if ((n != null) && (n instanceof AbstractNode))
nodes.add(new ObjectContext((AbstractNode) n, null));
}
}
return nodes;
}
Aggregations