Search in sources :

Example 1 with SoftwareInventoryNode

use of org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryNode 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

ArrayList (java.util.ArrayList)1 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 SoftwareInventoryNode (org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryNode)1