Search in sources :

Example 41 with AbstractNode

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

the class ObjectPolling method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    if (object.containPollerNode())
        md.setPollerNode(pollerNode.getObjectId());
    md.setObjectFlags(collectNodeFlags(), collectNodeFlagsMask());
    if (object.containInterfaces())
        md.setIfXTablePolicy(collectIfXTablePolicy());
    if (object.containAgent())
        md.setAgentCacheMode(collectAgentCacheMode());
    if (object instanceof AbstractNode)
        md.setRequiredPolls(pollCount.getSelection());
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().NodePolling_JobName, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().NodePolling_JobError;
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        ObjectPolling.this.setValid(true);
                    }
                });
            }
        }
    }.start();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 42 with AbstractNode

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

the class ObjectPopupDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    statusLabel = new CLabel(dialogArea, SWT.NONE);
    statusLabel.setText(StatusDisplayInfo.getStatusText(object.getStatus()).toUpperCase());
    statusLabel.setForeground(StatusDisplayInfo.getStatusColor(object.getStatus()));
    statusLabel.setFont(boldFont);
    StringBuilder sb = new StringBuilder();
    if (object instanceof AbstractNode) {
        appendText(sb, ((AbstractNode) object).getPrimaryIP().getHostAddress());
        appendText(sb, ((AbstractNode) object).getPlatformName());
        String sd = ((AbstractNode) object).getSystemDescription();
        if (sd.length() > 127)
            // $NON-NLS-1$
            sd = sd.substring(0, 127) + "...";
        appendText(sb, sd);
        appendText(sb, ((AbstractNode) object).getSnmpSysName());
        appendText(sb, ((AbstractNode) object).getSnmpSysContact());
    }
    if (sb.length() > 0) {
        createSeparator(dialogArea);
        if (sb.charAt(sb.length() - 1) == '\n')
            sb.deleteCharAt(sb.length() - 1);
        CLabel infoText = new CLabel(dialogArea, SWT.MULTI);
        infoText.setText(sb.toString());
    }
    if (object instanceof DataCollectionTarget) {
        List<DciValue> values = ((DataCollectionTarget) object).getTooltipDciData();
        if (!values.isEmpty()) {
            createSeparator(dialogArea);
            Composite group = new Composite(dialogArea, SWT.NONE);
            GridLayout layout = new GridLayout();
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.numColumns = 2;
            group.setLayout(layout);
            StringBuilder leftColumn = new StringBuilder();
            StringBuilder rightColumn = new StringBuilder();
            for (DciValue v : values) {
                if (leftColumn.length() > 0) {
                    leftColumn.append('\n');
                    rightColumn.append('\n');
                }
                leftColumn.append(v.getDescription());
                rightColumn.append(v.getValue());
            }
            new CLabel(group, SWT.MULTI).setText(leftColumn.toString());
            new CLabel(group, SWT.MULTI).setText(rightColumn.toString());
        }
    }
    if (!object.getComments().isEmpty()) {
        createSeparator(dialogArea);
        new CLabel(dialogArea, SWT.MULTI).setText(object.getComments());
    }
    return dialogArea;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) DciValue(org.netxms.client.datacollection.DciValue)

Example 43 with AbstractNode

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

the class Commands method onObjectChange.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#onObjectChange()
	 */
@Override
protected void onObjectChange() {
    commandBox.deleteAll(false);
    if (getObject() instanceof AbstractNode) {
        ObjectTool[] tools = ObjectToolsCache.getInstance().getTools();
        for (final ObjectTool tool : tools) {
            if (!tool.isVisibleInCommands() || !tool.isEnabled() || !tool.isApplicableForNode((AbstractNode) getObject()))
                continue;
            final Set<ObjectContext> nodes = new HashSet<ObjectContext>(1);
            nodes.add(new ObjectContext((AbstractNode) getObject(), null));
            if (!ObjectToolExecutor.isToolAllowed(tool, nodes))
                continue;
            final Action action = new Action(tool.getCommandDisplayName()) {

                @Override
                public void run() {
                    ObjectToolExecutor.execute(nodes, tool);
                }
            };
            ImageDescriptor icon = ObjectToolsCache.getInstance().findIcon(tool.getId());
            if (icon != null)
                action.setImageDescriptor(icon);
            commandBox.add(action, false);
        }
    } else if (getObject() instanceof Interface) {
        commandBox.add(actionWakeup, false);
    }
    commandBox.rebuild();
}
Also used : Action(org.eclipse.jface.action.Action) AbstractNode(org.netxms.client.objects.AbstractNode) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ObjectContext(org.netxms.ui.eclipse.objects.ObjectContext) Interface(org.netxms.client.objects.Interface) ObjectTool(org.netxms.client.objecttools.ObjectTool) HashSet(java.util.HashSet)

Example 44 with AbstractNode

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

the class ObjectStatusRadialWidget method paintControl.

/* (non-Javadoc)
	 * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
	 */
@Override
public void paintControl(PaintEvent e) {
    GC gc = e.gc;
    gc.setAdvanced(true);
    if (!gc.getAdvanced()) {
        gc.drawText("Advanced graphics not supported", 30, 30, true);
        return;
    }
    objectMap.clear();
    leafObjectCount = calculateMaxLVLAndObjCount(rootObject, 1);
    leafObjectSize = 360 / (float) leafObjectCount;
    Rectangle rect = getClientArea();
    rect.width--;
    rect.height--;
    gc.setAntialias(SWT.ON);
    gc.setTextAntialias(SWT.ON);
    gc.setForeground(SharedColors.getColor(SharedColors.TEXT_NORMAL, getDisplay()));
    gc.setLineWidth(1);
    // calculate values
    int rectSide = Math.min(rect.width, rect.height);
    diameter = rectSide / (maxLvl + 1);
    centerX = rect.x + (rectSide / 2);
    centerY = rect.y + (rectSide / 2);
    // draw objects
    drawParts(gc, rootObject, 2, 0);
    // draw general oval with
    // draw white oval
    gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    gc.setAlpha(255);
    gc.fillOval(centerX - diameter / 2 - 3, centerY - diameter / 2 - 3, diameter + 6, diameter + 6);
    gc.setBackground(StatusDisplayInfo.getStatusColor(rootObject.getStatus()));
    gc.setAlpha(255);
    gc.fillOval(centerX - diameter / 2, centerY - diameter / 2, diameter, diameter);
    final String text = (rootObject instanceof AbstractNode) ? // $NON-NLS-1$
    (rootObject.getObjectName() + "\n" + ((AbstractNode) rootObject).getPrimaryIP().getHostAddress()) : rootObject.getObjectName();
    gc.setClipping(rect);
    int h = gc.textExtent(text).y;
    int l = gc.textExtent(text).x;
    gc.setForeground(ColorConverter.selectTextColorByBackgroundColor(StatusDisplayInfo.getStatusColor(rootObject.getStatus()), cCache));
    gc.drawText(text, rect.x + (rectSide / 2) - l / 2, rect.y + (rectSide / 2) - h / 2, SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER);
    objectMap.add(new ObjectPosition(0, 360, 1, rootObject));
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) Rectangle(org.eclipse.swt.graphics.Rectangle) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point)

Example 45 with AbstractNode

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

the class SoftwareInventory method refresh.

/**
 * Refresh list
 */
public void refresh() {
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SoftwareInventory_JobName, viewPart, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            AbstractObject object = session.findObjectById(rootObjectId);
            if (object instanceof AbstractNode) {
                final List<SoftwarePackage> packages = session.getNodeSoftwarePackages(rootObjectId);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(packages.toArray());
                    }
                });
            } else {
                final List<SoftwareInventoryNode> nodes = new ArrayList<SoftwareInventoryNode>();
                for (final AbstractObject o : object.getAllChilds(AbstractObject.OBJECT_NODE)) {
                    try {
                        List<SoftwarePackage> packages = session.getNodeSoftwarePackages(o.getObjectId());
                        nodes.add(new SoftwareInventoryNode((Node) o, packages));
                    } catch (NXCException e) {
                        if (e.getErrorCode() != RCC.NO_SOFTWARE_PACKAGE_DATA)
                            throw e;
                    }
                }
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(nodes);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().SoftwareInventory_JobError;
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SoftwareInventoryNode(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryNode) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

AbstractNode (org.netxms.client.objects.AbstractNode)47 AbstractObject (org.netxms.client.objects.AbstractObject)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 NXCSession (org.netxms.client.NXCSession)13 ArrayList (java.util.ArrayList)12 Cluster (org.netxms.client.objects.Cluster)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Composite (org.eclipse.swt.widgets.Composite)6 PartInitException (org.eclipse.ui.PartInitException)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 NXCException (org.netxms.client.NXCException)5 Interface (org.netxms.client.objects.Interface)5 Sensor (org.netxms.client.objects.Sensor)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)4 Subnet (org.netxms.client.objects.Subnet)4 ISelection (org.eclipse.jface.viewers.ISelection)3