Search in sources :

Example 1 with PortInfo

use of org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo in project netxms by netxms.

the class SlotView method paintControl.

/* (non-Javadoc)
	 * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
	 */
@Override
public void paintControl(PaintEvent e) {
    e.gc.drawText(slotName, HORIZONTAL_MARGIN, (getSize().y - nameSize.y) / 2);
    PortCalculator portCalculator = null;
    switch(numberingScheme) {
        case NDD_PN_DU_LR:
            portCalculator = new PortCalculatorDownUpLeftRight(nameSize.x, rowCount);
            break;
        case NDD_PN_LR_UD:
            portCalculator = new PortCalculatorLeftRightUpDown(nameSize.x, ports.size(), rowCount);
            break;
        case NDD_PN_LR_DU:
            portCalculator = new PortCalculatorLeftRightDownUp(nameSize.x, ports.size(), rowCount);
            break;
        case NDD_PN_CUSTOM:
            break;
        case NDD_PN_UNKNOWN:
        case NDD_PN_UD_LR:
        default:
            portCalculator = new PortCalculatorUpDownLeftRight(nameSize.x, rowCount);
            break;
    }
    for (PortInfo p : ports) {
        drawPort(p, portCalculator.calculateNextPos(), e.gc);
    }
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) PortCalculator(org.netxms.ui.eclipse.topology.widgets.helpers.PortCalculator) PortCalculatorLeftRightDownUp(org.netxms.ui.eclipse.topology.widgets.helpers.PortCalculatorLeftRightDownUp) PortCalculatorLeftRightUpDown(org.netxms.ui.eclipse.topology.widgets.helpers.PortCalculatorLeftRightUpDown) PortCalculatorUpDownLeftRight(org.netxms.ui.eclipse.topology.widgets.helpers.PortCalculatorUpDownLeftRight) PortCalculatorDownUpLeftRight(org.netxms.ui.eclipse.topology.widgets.helpers.PortCalculatorDownUpLeftRight)

Example 2 with PortInfo

use of org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo 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();
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DeviceView(org.netxms.ui.eclipse.topology.widgets.DeviceView) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) PortSelectionListener(org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener) Interface(org.netxms.client.objects.Interface)

Example 3 with PortInfo

use of org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo in project netxms by netxms.

the class SlotView method mouseUp.

/* (non-Javadoc)
	 * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
	 */
@Override
public void mouseUp(MouseEvent e) {
    PortInfo p = finder.findPortInfo(e.x, e.y);
    if (p != null && p != selection) {
        selection = p;
        redraw();
        for (PortSelectionListener listener : selectionListeners) listener.portSelected(p);
    }
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) PortSelectionListener(org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener)

Example 4 with PortInfo

use of org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo in project netxms by netxms.

the class VlanView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);
    final String[] names = { Messages.get().VlanView_ColumnID, Messages.get().VlanView_ColumnName, Messages.get().VlanView_ColumnPorts };
    final int[] widths = { 80, 180, 400 };
    vlanList = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.FULL_SELECTION | SWT.MULTI);
    vlanList.setContentProvider(new ArrayContentProvider());
    final VlanLabelProvider labelProvider = new VlanLabelProvider();
    vlanList.setLabelProvider(labelProvider);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    vlanList.getTable().setLayoutData(gd);
    vlanList.setInput(vlans.toArray());
    vlanList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) vlanList.getSelection();
            VlanInfo vlan = (VlanInfo) selection.getFirstElement();
            if (vlan != null) {
                deviceView.setHighlight(vlan.getPorts());
                actionShowVlanMap.setEnabled(true);
            } else {
                deviceView.clearHighlight(true);
                actionShowVlanMap.setEnabled(false);
            }
            if (labelProvider.setSelectedPort(null)) {
                vlanList.refresh();
            }
        }
    });
    Composite deviceViewArea = new Composite(parent, SWT.NONE);
    deviceViewArea.setLayout(new FillLayout());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    deviceViewArea.setLayoutData(gd);
    scroller = new ScrolledComposite(deviceViewArea, SWT.H_SCROLL | SWT.V_SCROLL);
    deviceView = new DeviceView(scroller, SWT.NONE);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    deviceView.setLayoutData(gd);
    deviceView.setPortStatusVisible(false);
    deviceView.setNodeId(nodeId);
    deviceView.addSelectionListener(new PortSelectionListener() {

        @Override
        public void portSelected(PortInfo port) {
            vlanList.setSelection(null);
            labelProvider.setSelectedPort(port);
            vlanList.refresh();
        }
    });
    scroller.setContent(deviceView);
    scroller.setBackground(deviceView.getBackground());
    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));
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    if (refreshOnStartup)
        refreshVlanList();
}
Also used : VlanLabelProvider(org.netxms.ui.eclipse.topology.views.helpers.VlanLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FillLayout(org.eclipse.swt.layout.FillLayout) VlanInfo(org.netxms.client.topology.VlanInfo) PortSelectionListener(org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener) PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) GridLayout(org.eclipse.swt.layout.GridLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DeviceView(org.netxms.ui.eclipse.topology.widgets.DeviceView) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 5 with PortInfo

use of org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo 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);
    }
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) ArrayList(java.util.ArrayList) Interface(org.netxms.client.objects.Interface)

Aggregations

PortInfo (org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo)5 PortSelectionListener (org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 ControlAdapter (org.eclipse.swt.events.ControlAdapter)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 Interface (org.netxms.client.objects.Interface)2 DeviceView (org.netxms.ui.eclipse.topology.widgets.DeviceView)2 ArrayList (java.util.ArrayList)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 Node (org.netxms.client.objects.Node)1 VlanInfo (org.netxms.client.topology.VlanInfo)1