use of org.netxms.client.objects.Interface in project netxms by netxms.
the class CreateInterfraceDci method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
final CreateInterfaceDciDialog dlg = new CreateInterfaceDciDialog(shell, (objects.size() == 1) ? objects.get(0) : null);
if (dlg.open() == Window.OK) {
final List<Interface> ifaces = new ArrayList<Interface>(objects);
// Get set of nodes
final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
for (Interface iface : ifaces) {
AbstractNode node = iface.getParentNode();
if (node != null) {
nodes.add(node);
}
}
// Check what nodes requires DCI list lock
final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (AbstractNode n : nodes) {
IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateInterfraceDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().CreateInterfraceDci_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
InterfaceDciInfo[] dciInfo = dlg.getDciInfo();
monitor.beginTask(Messages.get(getDisplay()).CreateInterfraceDci_TaskName, ifaces.size() * dciInfo.length);
for (int i = 0; i < ifaces.size(); i++) {
for (int j = 0; j < dciInfo.length; j++) {
if (dciInfo[j].enabled) {
createInterfaceDci(session, ifaces.get(i), j, dciInfo[j], dlg.getPollingInterval(), dlg.getRetentionTime(), ifaces.size() > 1, lockRequired);
}
monitor.worked(1);
}
}
monitor.done();
}
}.start();
}
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class ObjectSearchResultLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
if (!(element instanceof AbstractObject))
return null;
AbstractObject object = (AbstractObject) element;
switch(columnIndex) {
case ObjectFinder.COL_CLASS:
return object.getObjectClassName();
case ObjectFinder.COL_ID:
return Long.toString(object.getObjectId());
case ObjectFinder.COL_IP_ADDRESS:
if (object instanceof AbstractNode) {
InetAddressEx addr = ((AbstractNode) object).getPrimaryIP();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof AccessPoint) {
InetAddressEx addr = ((AccessPoint) object).getIpAddress();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof Interface) {
return ((Interface) object).getIpAddressListAsString();
}
return null;
case ObjectFinder.COL_NAME:
return wbLabelProvider.getText(element);
case ObjectFinder.COL_PARENT:
return getParentNames((AbstractObject) element);
case ObjectFinder.COL_ZONE:
if (object instanceof AbstractNode) {
long zoneId = ((AbstractNode) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
} else if (object instanceof Interface) {
long zoneId = ((Interface) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
}
return null;
}
return null;
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class ApplyPolicy method selectionChanged.
@Override
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() != 0)) {
selectedObjects = new ArrayList<AbstractObject>();
for (Object s : ((IStructuredSelection) selection).toList()) {
if ((s instanceof Node) || (s instanceof Interface) || (s instanceof AccessPoint)) {
action.setEnabled(true);
selectedObjects.add(((AbstractObject) s));
}
}
} else {
action.setEnabled(false);
selectedObjects = null;
}
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class IPAddressSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
// Label label = new Label(dialogArea, SWT.NONE);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
gd.widthHint = 250;
viewer.getControl().setLayoutData(gd);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ComparatorHelper.compareInetAddresses(((AddressListElement) e1).address, ((AddressListElement) e2).address);
}
});
viewer.setLabelProvider(new AddressListLabelProvider());
final Table table = viewer.getTable();
table.setHeaderVisible(true);
TableColumn tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.get().IPAddressSelectionDialog_IPAddress);
tc.setWidth(90);
tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.get().IPAddressSelectionDialog_Interface);
tc.setWidth(150);
Set<AddressListElement> addrList = new HashSet<AddressListElement>();
for (AbstractObject o : node.getChildsAsArray()) {
if (o instanceof Interface) {
for (InetAddressEx a : ((Interface) o).getIpAddressList()) {
if (a.isValidUnicastAddress()) {
addrList.add(new AddressListElement((Interface) o, a.getAddress()));
}
}
}
}
viewer.setInput(addrList.toArray());
return dialogArea;
}
use of org.netxms.client.objects.Interface in project netxms by netxms.
the class Connection method onObjectChange.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#onObjectChange()
*/
@Override
protected void onObjectChange() {
if ((getObject() == null) || !(getObject() instanceof Interface))
return;
Interface iface = (Interface) getObject();
long peerNodeId = iface.getPeerNodeId();
if (peerNodeId != 0) {
AbstractObject node = session.findObjectById(peerNodeId);
// $NON-NLS-1$ //$NON-NLS-2$
nodeLabel.setText((node != null) ? node.getObjectName() : "<" + peerNodeId + ">");
nodeLabel.setImage(labelProvider.getImage(node));
} else {
nodeLabel.setText(Messages.get().Connection_NA);
}
long peerInterfaceId = iface.getPeerInterfaceId();
if (peerInterfaceId != 0) {
AbstractObject peerIface = session.findObjectById(peerInterfaceId);
// $NON-NLS-1$ //$NON-NLS-2$
interfaceLabel.setText((peerIface != null) ? peerIface.getObjectName() : "<" + peerInterfaceId + ">");
interfaceLabel.setImage(labelProvider.getImage(peerIface));
protocolLabel.setText(iface.getPeerDiscoveryProtocol().toString());
} else {
interfaceLabel.setText(Messages.get().Connection_NA);
// $NON-NLS-1$
protocolLabel.setText("");
}
}
Aggregations