Search in sources :

Example 76 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class OpenHistoryMap method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
    Object obj;
    if ((selection instanceof IStructuredSelection) && ((obj = ((IStructuredSelection) selection).getFirstElement()) instanceof AbstractObject)) {
        object = (AbstractObject) obj;
    } else {
        object = null;
    }
    action.setEnabled((object != null) && (object.getGeolocation().getType() != GeoLocation.UNSET));
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 77 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class AbstractGeolocationView method fillContextMenu.

/**
 * Fill context menu
 *
 * @param manager
 *           Menu manager
 */
protected void fillContextMenu(final IMenuManager manager) {
    AbstractObject object = map.getObjectAtPoint(map.getCurrentPoint());
    selection = (object != null) ? new StructuredSelection(object) : new StructuredSelection();
    if (!selection.isEmpty()) {
        ObjectContextMenu.fill(manager, getSite(), this);
    } else {
        manager.add(actionZoomIn);
        manager.add(actionZoomOut);
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 78 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class ObjectGeoLocationViewer method drawContent.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.osm.widgets.AbstractGeoMapViewer#drawContent(org.eclipse.swt.graphics.GC, org.netxms.base.GeoLocation, int, int)
    */
@Override
protected void drawContent(GC gc, GeoLocation currentLocation, int imgW, int imgH) {
    objectIcons.clear();
    final Point centerXY = GeoLocationCache.coordinateToDisplay(currentLocation, accessor.getZoom());
    for (AbstractObject object : objects) {
        final Point virtualXY = GeoLocationCache.coordinateToDisplay(object.getGeolocation(), accessor.getZoom());
        final int dx = virtualXY.x - centerXY.x;
        final int dy = virtualXY.y - centerXY.y;
        drawObject(gc, imgW / 2 + dx, imgH / 2 + dy, object);
    }
    if (objectToolTipLocation != null)
        drawObjectToolTip(gc);
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 79 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class ChildObjectListDialog 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);
    AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(parentObject);
    AbstractObject[] sourceObjects = (object != null) ? object.getChildsAsArray() : new AbstractObject[0];
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    dialogArea.setLayout(layout);
    // Create filter area
    Composite filterArea = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    filterArea.setLayout(layout);
    filterArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label filterLabel = new Label(filterArea, SWT.NONE);
    filterLabel.setText(Messages.get().ChildObjectListDialog_Filter);
    filterText = new Text(filterArea, SWT.BORDER);
    filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            filter.setFilterString(filterText.getText());
            objectList.refresh(false);
            AbstractObject obj = filter.getLastMatch();
            if (obj != null) {
                objectList.setSelection(new StructuredSelection(obj), true);
                objectList.reveal(obj);
            }
        }
    });
    // Create object list
    objectList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    TableColumn tc = new TableColumn(objectList.getTable(), SWT.LEFT);
    tc.setText(Messages.get().ChildObjectListDialog_Name);
    tc.setWidth(280);
    objectList.getTable().setHeaderVisible(false);
    objectList.setContentProvider(new ArrayContentProvider());
    objectList.setLabelProvider(new WorkbenchLabelProvider());
    objectList.setComparator(new ViewerComparator());
    filter = new ObjectFilter(null, sourceObjects, classFilter);
    objectList.addFilter(filter);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    objectList.getControl().setLayoutData(gd);
    objectList.getTable().addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            Table table = objectList.getTable();
            int w = table.getSize().x - table.getBorderWidth() * 2;
            ScrollBar sc = table.getVerticalBar();
            if ((sc != null) && sc.isVisible())
                w -= sc.getSize().x;
            table.getColumn(0).setWidth(w);
        }
    });
    if (object != null)
        objectList.setInput(sourceObjects);
    filterText.setFocus();
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) NXCSession(org.netxms.client.NXCSession) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Text(org.eclipse.swt.widgets.Text) ObjectFilter(org.netxms.ui.eclipse.objectbrowser.widgets.internal.ObjectFilter) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 80 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class ChildObjectListDialog method okPressed.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
@SuppressWarnings("rawtypes")
@Override
protected void okPressed() {
    IStructuredSelection selection = (IStructuredSelection) objectList.getSelection();
    selectedObjects = new ArrayList<AbstractObject>(selection.size());
    Iterator it = selection.iterator();
    while (it.hasNext()) selectedObjects.add((AbstractObject) it.next());
    saveSettings();
    super.okPressed();
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)216 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)55 NXCSession (org.netxms.client.NXCSession)51 AbstractNode (org.netxms.client.objects.AbstractNode)31 PartInitException (org.eclipse.ui.PartInitException)27 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)25 Cluster (org.netxms.client.objects.Cluster)22 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)22 ArrayList (java.util.ArrayList)20 Node (org.netxms.client.objects.Node)20 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)18 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)18 GridLayout (org.eclipse.swt.layout.GridLayout)15 Container (org.netxms.client.objects.Container)15 Interface (org.netxms.client.objects.Interface)12 Template (org.netxms.client.objects.Template)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Point (org.eclipse.swt.graphics.Point)11