use of org.netxms.client.objects.Interface in project netxms by netxms.
the class VlanMap method processVlanPort.
/**
* Process single member port of VLAN. Will add connected switch on other site to the map.
*
* @param page
* @param root
* @param port
* @throws Exception
*/
private void processVlanPort(NetworkMapPage page, Node root, Port port, long rootElementId) throws Exception {
Interface iface = (Interface) session.findObjectById(port.getObjectId(), Interface.class);
if (iface != null) {
Node peerNode = (Node) session.findObjectById(iface.getPeerNodeId(), Node.class);
if ((peerNode != null) && ((peerNode.getCapabilities() & Node.NC_IS_BRIDGE) != 0)) {
try {
long nodeElementId = collectVlanInfo(page, peerNode);
if (nodeElementId != -1) {
Interface peerIf = (Interface) session.findObjectById(iface.getPeerInterfaceId(), Interface.class);
page.addLink(new NetworkMapLink(null, NetworkMapLink.NORMAL, rootElementId, nodeElementId, iface.getObjectName(), (peerIf != null) ? peerIf.getObjectName() : "???", // $NON-NLS-1$ //$NON-NLS-2$
0));
}
} catch (NXCException e) {
// Ignore NetXMS errors for remote bridges
}
}
}
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class FindConnectionPoint method selectionChanged.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && !selection.isEmpty()) {
objects = new ArrayList<AbstractObject>();
for (Object s : ((IStructuredSelection) selection).toList()) {
if ((s instanceof Node) || (s instanceof Interface) || (s instanceof AccessPoint)) {
action.setEnabled(true);
objects.add((AbstractObject) s);
}
}
} else {
action.setEnabled(false);
objects = null;
}
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class Ports method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
deviceView = new DeviceView(scroller, SWT.NONE);
deviceView.addSelectionListener(new PortSelectionListener() {
@Override
public void portSelected(PortInfo port) {
if (port != null) {
Interface iface = (Interface) session.findObjectById(port.getInterfaceObjectId(), Interface.class);
if (iface != null) {
selection = new StructuredSelection(iface);
} else {
selection = new StructuredSelection();
}
} else {
selection = new StructuredSelection();
}
for (ISelectionChangedListener listener : selectionListeners) listener.selectionChanged(new SelectionChangedEvent(Ports.this, selection));
}
});
scroller.setContent(deviceView);
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);
// scroller.getVerticalBar().setIncrement(20);
// scroller.getHorizontalBar().setIncrement(20);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scroller.setMinSize(deviceView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
createPopupMenu();
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class ConnectionPointComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int result;
// $NON-NLS-1$
int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
switch(column) {
case HostSearchResults.COLUMN_SEQUENCE:
result = (Integer) ((ConnectionPoint) e1).getData() - (Integer) ((ConnectionPoint) e2).getData();
break;
case HostSearchResults.COLUMN_NODE:
case HostSearchResults.COLUMN_INTERFACE:
case HostSearchResults.COLUMN_MAC_ADDRESS:
case HostSearchResults.COLUMN_SWITCH:
case HostSearchResults.COLUMN_PORT:
result = labelProvider.getColumnText(e1, column).compareToIgnoreCase(labelProvider.getColumnText(e2, column));
break;
case HostSearchResults.COLUMN_IP_ADDRESS:
Interface iface1 = (Interface) session.findObjectById(((ConnectionPoint) e1).getLocalInterfaceId(), Interface.class);
Interface iface2 = (Interface) session.findObjectById(((ConnectionPoint) e2).getLocalInterfaceId(), Interface.class);
InetAddress a1 = ((ConnectionPoint) e1).getLocalIpAddress();
InetAddress a2 = ((ConnectionPoint) e2).getLocalIpAddress();
if ((a1 == null) && (iface1 != null))
a1 = iface1.getFirstUnicastAddress();
if ((a2 == null) && (iface2 != null))
a2 = iface2.getFirstUnicastAddress();
result = ComparatorHelper.compareInetAddresses(a1, a2);
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class DeviceView method refresh.
/**
* Refresh widget
*/
public void refresh() {
AbstractObject object = session.findObjectById(nodeId);
if ((object == null) || !(object instanceof Node))
return;
for (SlotView s : slots.values()) {
s.setMenu(null);
s.dispose();
}
slots.clear();
ports.clear();
List<Interface> interfaces = new ArrayList<Interface>();
for (AbstractObject o : object.getAllChilds(AbstractObject.OBJECT_INTERFACE)) {
if (((Interface) o).isPhysicalPort())
interfaces.add((Interface) o);
}
Collections.sort(interfaces, new Comparator<Interface>() {
@Override
public int compare(Interface arg0, Interface arg1) {
if (arg0.getSlot() == arg1.getSlot())
return arg0.getPort() - arg1.getPort();
return arg0.getSlot() - arg1.getSlot();
}
});
for (Interface iface : interfaces) {
int slot = iface.getSlot();
SlotView sv = slots.get(slot);
if (sv == null) {
sv = new SlotView(this, SWT.NONE, String.format(Messages.get().DeviceView_SlotName, slot), ((Node) object).getPortRowCount(), ((Node) object).getPortNumberingScheme());
sv.setPortStatusVisible(portStatusVisible);
slots.put(slot, sv);
}
PortInfo p = new PortInfo(iface);
ports.put(iface.getObjectId(), p);
sv.addPort(p);
}
layout();
for (SlotView sv : slots.values()) {
sv.setMenu(getMenu());
sv.addSelectionListener(listener);
}
}
Aggregations