Search in sources :

Example 1 with VlanLabelProvider

use of org.netxms.ui.eclipse.topology.views.helpers.VlanLabelProvider 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)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)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 VlanInfo (org.netxms.client.topology.VlanInfo)1 VlanLabelProvider (org.netxms.ui.eclipse.topology.views.helpers.VlanLabelProvider)1 DeviceView (org.netxms.ui.eclipse.topology.widgets.DeviceView)1 PortInfo (org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo)1 PortSelectionListener (org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1