Search in sources :

Example 1 with PhysicalComponent

use of org.netxms.client.PhysicalComponent in project netxms by netxms.

the class ComponentsTab 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) {
    viewer.setInput(new Object[0]);
    if (object == null)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    ConsoleJob job = new ConsoleJob(Messages.get().ComponentsTab_JobName, getViewPart(), Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            try {
                final PhysicalComponent root = session.getNodePhysicalComponents(object.getObjectId());
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        if (viewer.getTree().isDisposed())
                            return;
                        if ((ComponentsTab.this.getObject() != null) && (ComponentsTab.this.getObject().getObjectId() == object.getObjectId())) {
                            viewer.setInput(new Object[] { root });
                            viewer.expandAll();
                        }
                    }
                });
            } catch (NXCException e) {
                if (e.getErrorCode() != RCC.NO_COMPONENT_DATA)
                    throw e;
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        if (viewer.getTree().isDisposed())
                            return;
                        if ((ComponentsTab.this.getObject() != null) && (ComponentsTab.this.getObject().getObjectId() == object.getObjectId())) {
                            viewer.setInput(new Object[0]);
                        }
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().ComponentsTab_JobError, object.getObjectName());
        }
    };
    job.setUser(false);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) PhysicalComponent(org.netxms.client.PhysicalComponent) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) NXCException(org.netxms.client.NXCException)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 PhysicalComponent (org.netxms.client.PhysicalComponent)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1