use of org.netxms.ui.eclipse.objectview.widgets.RackWidget 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();
}
use of org.netxms.ui.eclipse.objectview.widgets.RackWidget 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();
}
}
Aggregations