Search in sources :

Example 1 with Interface

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();
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateInterfaceDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.CreateInterfaceDciDialog) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Interface(org.netxms.client.objects.Interface) HashSet(java.util.HashSet)

Example 2 with Interface

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;
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) InetAddressEx(org.netxms.base.InetAddressEx) Zone(org.netxms.client.objects.Zone) AbstractObject(org.netxms.client.objects.AbstractObject) AccessPoint(org.netxms.client.objects.AccessPoint) Interface(org.netxms.client.objects.Interface)

Example 3 with Interface

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;
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) AccessPoint(org.netxms.client.objects.AccessPoint) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Interface(org.netxms.client.objects.Interface)

Example 4 with Interface

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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) AddressListLabelProvider(org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.AddressListLabelProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TableColumn(org.eclipse.swt.widgets.TableColumn) AddressListElement(org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.AddressListElement) GridLayout(org.eclipse.swt.layout.GridLayout) InetAddressEx(org.netxms.base.InetAddressEx) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) AbstractObject(org.netxms.client.objects.AbstractObject) TableViewer(org.eclipse.jface.viewers.TableViewer) Interface(org.netxms.client.objects.Interface) HashSet(java.util.HashSet)

Example 5 with Interface

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("");
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Interface(org.netxms.client.objects.Interface)

Aggregations

Interface (org.netxms.client.objects.Interface)23 AbstractObject (org.netxms.client.objects.AbstractObject)12 AbstractNode (org.netxms.client.objects.AbstractNode)6 AccessPoint (org.netxms.client.objects.AccessPoint)6 Node (org.netxms.client.objects.Node)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)3 Sensor (org.netxms.client.objects.Sensor)3 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)3 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)3 SuppressLint (android.annotation.SuppressLint)2 InetAddress (java.net.InetAddress)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Action (org.eclipse.jface.action.Action)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 InetAddressEx (org.netxms.base.InetAddressEx)2 NXCSession (org.netxms.client.NXCSession)2 GenericObject (org.netxms.client.objects.GenericObject)2 NetworkService (org.netxms.client.objects.NetworkService)2