Search in sources :

Example 11 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class IdMatchingDialog method updateDciMapping.

/**
 * Update mapping for all DCIs of given node after node mapping change
 *
 * @param objData
 */
private void updateDciMapping(final ObjectIdMatchingData objData) {
    if (objData.dcis.size() == 0)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().IdMatchingDialog_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final DciValue[] dciValues = session.getLastValues(objData.dstId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (DciIdMatchingData d : objData.dcis) {
                        d.dstNodeId = objData.dstId;
                        d.dstDciId = 0;
                        d.dstName = null;
                        for (DciValue v : dciValues) {
                            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                                d.dstDciId = v.getId();
                                d.dstName = v.getDescription();
                                break;
                            }
                        }
                    }
                    viewer.refresh(true);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().IdMatchingDialog_JobErrorText;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 12 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class CreateDashboard method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateDashboard_Dashboard);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateDashboard_Error, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 13 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class SnmpTrapMonitorElement method dispose.

@Override
public void dispose() {
    ConsoleJob job = new ConsoleJob(String.format("Unsuscribing from channel ", NXCSession.CHANNEL_SNMP_TRAPS), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.unsubscribe(NXCSession.CHANNEL_SNMP_TRAPS);
        }

        @Override
        protected String getErrorMessage() {
            return String.format("Cannot unsubscribe from channel ", NXCSession.CHANNEL_SNMP_TRAPS);
        }
    };
    job.setUser(false);
    job.setSystem(true);
    job.start();
    super.dispose();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 14 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class RepositoryManager method addRepository.

/**
 * Add repository
 */
private void addRepository() {
    RepositoryPropertiesDlg dlg = new RepositoryPropertiesDlg(getSite().getShell(), null);
    if (dlg.open() != Window.OK)
        return;
    final Repository repository = new Repository(dlg.getUrl(), dlg.getToken(), dlg.getDescription());
    new ConsoleJob("Add repository", this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.addRepository(repository);
            runInUIThread(new Runnable() {

                @SuppressWarnings("unchecked")
                @Override
                public void run() {
                    ArrayList<RepositoryRuntimeInfo> repositories = (ArrayList<RepositoryRuntimeInfo>) viewer.getInput();
                    repositories.add(new RepositoryRuntimeInfo(repository));
                    viewer.refresh();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot add repository";
        }
    }.start();
}
Also used : RepositoryPropertiesDlg(org.netxms.ui.eclipse.market.dialogs.RepositoryPropertiesDlg) Repository(org.netxms.client.market.Repository) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) RepositoryRuntimeInfo(org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo)

Example 15 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class AlarmDetails method refresh.

/**
 * Refresh view
 */
private void refresh() {
    new ConsoleJob(Messages.get().AlarmDetails_RefreshJobTitle, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Alarm alarm = session.getAlarm(alarmId);
            final List<AlarmComment> comments = session.getAlarmComments(alarmId);
            List<EventInfo> _events = null;
            try {
                _events = session.getAlarmEvents(alarmId);
            } catch (NXCException e) {
                if (e.getErrorCode() != RCC.ACCESS_DENIED)
                    throw e;
            }
            final List<EventInfo> events = _events;
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    updateAlarmDetails(alarm);
                    for (AlarmCommentsEditor e : editors.values()) e.dispose();
                    for (AlarmComment n : comments) editors.put(n.getId(), createEditor(n));
                    if (lastValuesWidget == null) {
                        AbstractObject object = session.findObjectById(alarm.getSourceObjectId());
                        if (object != null) {
                            // $NON-NLS-1$
                            lastValuesWidget = new LastValuesWidget(AlarmDetails.this, dataArea, SWT.BORDER, object, "AlarmDetails.LastValues", null);
                            lastValuesWidget.refresh();
                        }
                    }
                    if (events != null) {
                        eventViewer.setInput(events);
                        eventViewer.expandAll();
                        if (labelAccessDenied != null) {
                            labelAccessDenied.dispose();
                            labelAccessDenied = null;
                        }
                    } else if (labelAccessDenied == null) {
                        labelAccessDenied = new CLabel(eventViewer.getControl().getParent(), SWT.NONE);
                        toolkit.adapt(labelAccessDenied);
                        labelAccessDenied.setImage(StatusDisplayInfo.getStatusImage(Severity.CRITICAL));
                        labelAccessDenied.setText(Messages.get().AlarmDetails_RelatedEvents_AccessDenied);
                        labelAccessDenied.moveAbove(null);
                        labelAccessDenied.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                    }
                    updateLayout();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().AlarmDetails_RefreshJobError;
        }
    }.start();
}
Also used : AlarmCommentsEditor(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor) CLabel(org.eclipse.swt.custom.CLabel) LastValuesWidget(org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget) AlarmComment(org.netxms.client.events.AlarmComment) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)330 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)329 NXCSession (org.netxms.client.NXCSession)163 PartInitException (org.eclipse.ui.PartInitException)113 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)81 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)45 NXCException (org.netxms.client.NXCException)44 List (java.util.List)38 ArrayList (java.util.ArrayList)34 AbstractObject (org.netxms.client.objects.AbstractObject)33 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 IOException (java.io.IOException)27 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)16 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)13 File (java.io.File)12 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)10 Script (org.netxms.client.Script)10 Table (org.netxms.client.Table)10 CoreException (org.eclipse.core.runtime.CoreException)9 GridData (org.eclipse.swt.layout.GridData)9