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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations