use of org.netxms.client.objects.Container 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;
}
use of org.netxms.client.objects.Container in project netxms by netxms.
the class UnbindObject method selectionChanged.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
if ((obj instanceof ServiceRoot) || (obj instanceof Container)) {
action.setEnabled(true);
parentId = ((AbstractObject) obj).getObjectId();
} else {
action.setEnabled(false);
parentId = 0;
}
} else {
action.setEnabled(false);
parentId = 0;
}
}
use of org.netxms.client.objects.Container in project netxms by netxms.
the class ObjectStatusMap method buildSection.
/**
* Build section of the form corresponding to one container
*/
private void buildSection(long rootId, String namePrefix) {
AbstractObject root = session.findObjectById(rootId);
if ((root == null) || !((root instanceof Container) || (root instanceof ServiceRoot) || (root instanceof Cluster)))
return;
List<AbstractObject> objects = new ArrayList<AbstractObject>(Arrays.asList(root.getChildsAsArray()));
Collections.sort(objects, new Comparator<AbstractObject>() {
@Override
public int compare(AbstractObject o1, AbstractObject o2) {
return o1.getObjectName().compareToIgnoreCase(o2.getObjectName());
}
});
Composite section = null;
Composite clientArea = null;
// Add nodes and clusters
for (AbstractObject o : objects) {
if (!((o instanceof AbstractNode) || (o instanceof Cluster)))
continue;
if (!isAcceptedByFilter(o))
continue;
if (section == null) {
section = new Composite(dataArea, SWT.NONE);
section.setBackground(getBackground());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
section.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
section.setLayout(layout);
final Label title = new Label(section, SWT.NONE);
title.setBackground(getBackground());
title.setFont(titleFont);
title.setText(namePrefix + root.getObjectName());
clientArea = new Composite(section, SWT.NONE);
clientArea.setBackground(getBackground());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
clientArea.setLayoutData(gd);
RowLayout clayout = new RowLayout();
clayout.marginBottom = 0;
clayout.marginTop = 0;
clayout.marginLeft = 0;
clayout.marginRight = 0;
clayout.type = SWT.HORIZONTAL;
clayout.wrap = true;
clayout.pack = false;
clientArea.setLayout(clayout);
sections.add(section);
}
addObjectElement(clientArea, o);
}
// Add subcontainers
for (AbstractObject o : objects) {
if (!(o instanceof Container) && !(o instanceof ServiceRoot) && !(o instanceof Cluster))
continue;
// $NON-NLS-1$
buildSection(o.getObjectId(), namePrefix + root.getObjectName() + " / ");
}
}
use of org.netxms.client.objects.Container in project netxms by netxms.
the class NXCSession method createObjectFromMessage.
/**
* Create object from message
*
* @param msg Source NXCP message
* @return NetXMS object
*/
private AbstractObject createObjectFromMessage(NXCPMessage msg) {
final int objectClass = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_CLASS);
AbstractObject object = createCustomObjectFromMessage(objectClass, msg);
if (object != null)
return object;
switch(objectClass) {
case AbstractObject.OBJECT_ACCESSPOINT:
object = new AccessPoint(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY:
object = new AgentPolicy(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
object = new AgentPolicyConfig(msg, this);
break;
case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
object = new AgentPolicyLogParser(msg, this);
break;
case AbstractObject.OBJECT_BUSINESSSERVICE:
object = new BusinessService(msg, this);
break;
case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
object = new BusinessServiceRoot(msg, this);
break;
case AbstractObject.OBJECT_CHASSIS:
object = new Chassis(msg, this);
break;
case AbstractObject.OBJECT_CLUSTER:
object = new Cluster(msg, this);
break;
case AbstractObject.OBJECT_CONDITION:
object = new Condition(msg, this);
break;
case AbstractObject.OBJECT_CONTAINER:
object = new Container(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARDGROUP:
object = new DashboardGroup(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARD:
object = new Dashboard(msg, this);
break;
case AbstractObject.OBJECT_DASHBOARDROOT:
object = new DashboardRoot(msg, this);
break;
case AbstractObject.OBJECT_INTERFACE:
object = new Interface(msg, this);
break;
case AbstractObject.OBJECT_MOBILEDEVICE:
object = new MobileDevice(msg, this);
break;
case AbstractObject.OBJECT_NETWORK:
object = new EntireNetwork(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAP:
object = new NetworkMap(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAPGROUP:
object = new NetworkMapGroup(msg, this);
break;
case AbstractObject.OBJECT_NETWORKMAPROOT:
object = new NetworkMapRoot(msg, this);
break;
case AbstractObject.OBJECT_NETWORKSERVICE:
object = new NetworkService(msg, this);
break;
case AbstractObject.OBJECT_NODE:
object = new Node(msg, this);
break;
case AbstractObject.OBJECT_NODELINK:
object = new NodeLink(msg, this);
break;
case AbstractObject.OBJECT_POLICYGROUP:
object = new PolicyGroup(msg, this);
break;
case AbstractObject.OBJECT_POLICYROOT:
object = new PolicyRoot(msg, this);
break;
case AbstractObject.OBJECT_RACK:
object = new Rack(msg, this);
break;
case AbstractObject.OBJECT_SENSOR:
object = new Sensor(msg, this);
break;
case AbstractObject.OBJECT_SERVICEROOT:
object = new ServiceRoot(msg, this);
break;
case AbstractObject.OBJECT_SLMCHECK:
object = new ServiceCheck(msg, this);
break;
case AbstractObject.OBJECT_SUBNET:
object = new Subnet(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATE:
object = new Template(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATEGROUP:
object = new TemplateGroup(msg, this);
break;
case AbstractObject.OBJECT_TEMPLATEROOT:
object = new TemplateRoot(msg, this);
break;
case AbstractObject.OBJECT_VPNCONNECTOR:
object = new VPNConnector(msg, this);
break;
case AbstractObject.OBJECT_ZONE:
object = new Zone(msg, this);
break;
default:
object = new GenericObject(msg, this);
break;
}
return object;
}
use of org.netxms.client.objects.Container in project netxms by netxms.
the class ApplyTemplate method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if ((parentId == null) || (parentId.isEmpty()))
return;
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(shell, null, ObjectSelectionDialog.createNodeSelectionFilter(true));
if (dlg.open() == Window.OK) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().ApplyTemplate_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().ApplyTemplate_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
List<AbstractObject> objects = dlg.getSelectedObjects();
for (AbstractObject o : objects) if (parentId == null) {
session.applyTemplate(0, o.getObjectId());
} else {
for (Long l : parentId) {
if (o instanceof Container) {
for (AbstractObject obj : ((Container) o).getAllChilds(AbstractObject.OBJECT_NODE)) {
session.applyTemplate(l, obj.getObjectId());
}
} else
session.applyTemplate(l, o.getObjectId());
}
}
}
}.start();
}
}
Aggregations