Search in sources :

Example 1 with RackSelectionListener

use of org.netxms.ui.eclipse.objectview.widgets.helpers.RackSelectionListener in project netxms by netxms.

the class RackView method createPartControl.

/* (non-Javadoc)
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    rackArea = new Composite(parent, SWT.NONE) {

        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            if ((rackFrontWidget == null) || (rackRearWidget == null) || (hHint == SWT.DEFAULT))
                return super.computeSize(wHint, hHint, changed);
            Point s = rackFrontWidget.computeSize(wHint, hHint, changed);
            return new Point(s.x * 2, s.y);
        }
    };
    rackFrontWidget = new RackWidget(rackArea, SWT.NONE, rack, RackOrientation.FRONT);
    rackRearWidget = new RackWidget(rackArea, SWT.NONE, rack, RackOrientation.REAR);
    rackArea.setBackground(SharedColors.getColor(SharedColors.RACK_BACKGROUND, parent.getDisplay()));
    rackArea.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if ((rackFrontWidget == null) || (rackRearWidget == null))
                return;
            int height = rackArea.getSize().y;
            Point size = rackFrontWidget.computeSize(SWT.DEFAULT, height, true);
            rackFrontWidget.setSize(size);
            rackRearWidget.setSize(size);
            rackRearWidget.setLocation(size.x, 0);
        }
    });
    RackSelectionListener listener = new RackSelectionListener() {

        @Override
        public void objectSelected(AbstractObject object) {
            selection = (object != null) ? new StructuredSelection(object) : new StructuredSelection();
            for (ISelectionChangedListener listener : selectionListeners) listener.selectionChanged(new SelectionChangedEvent(RackView.this, selection));
        }
    };
    rackFrontWidget.addSelectionListener(listener);
    rackRearWidget.addSelectionListener(listener);
    getSite().setSelectionProvider(this);
    createPopupMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) RackSelectionListener(org.netxms.ui.eclipse.objectview.widgets.helpers.RackSelectionListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) RackWidget(org.netxms.ui.eclipse.objectview.widgets.RackWidget) AbstractObject(org.netxms.client.objects.AbstractObject) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 2 with RackSelectionListener

use of org.netxms.ui.eclipse.objectview.widgets.helpers.RackSelectionListener in project netxms by netxms.

the class RackTab method objectChanged.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#objectChanged(org.netxms.client.objects.AbstractObject)
	 */
@Override
public void objectChanged(final AbstractObject object) {
    if (rackFrontWidget != null) {
        rackFrontWidget.dispose();
        rackFrontWidget = null;
    }
    if (rackRearWidget != null) {
        rackRearWidget.dispose();
        rackRearWidget = null;
    }
    if (object != null) {
        RackSelectionListener listener = new RackSelectionListener() {

            @Override
            public void objectSelected(AbstractObject object) {
                selection = (object != null) ? new StructuredSelection(object) : new StructuredSelection();
                for (ISelectionChangedListener listener : selectionListeners) listener.selectionChanged(new SelectionChangedEvent(RackTab.this, selection));
            }
        };
        rackFrontWidget = new RackWidget(content, SWT.NONE, (Rack) object, RackOrientation.FRONT);
        rackFrontWidget.addSelectionListener(listener);
        rackRearWidget = new RackWidget(content, SWT.NONE, (Rack) object, RackOrientation.REAR);
        rackRearWidget.addSelectionListener(listener);
        scroller.setMinSize(content.computeSize(SWT.DEFAULT, scroller.getSize().y));
        updateRackWidgetsSize();
        createPopupMenu();
    }
}
Also used : Rack(org.netxms.client.objects.Rack) RackSelectionListener(org.netxms.ui.eclipse.objectview.widgets.helpers.RackSelectionListener) RackWidget(org.netxms.ui.eclipse.objectview.widgets.RackWidget) AbstractObject(org.netxms.client.objects.AbstractObject) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 RackWidget (org.netxms.ui.eclipse.objectview.widgets.RackWidget)2 RackSelectionListener (org.netxms.ui.eclipse.objectview.widgets.helpers.RackSelectionListener)2 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 Rack (org.netxms.client.objects.Rack)1