use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ForceDciPoll method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
if (objects == null)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final Set<DCI> dciToPoll = objects;
new ConsoleJob(Messages.get().ForceDciPoll_TaskName, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask(Messages.get(getDisplay()).ForceDciPoll_TaskName, dciToPoll.size());
for (DCI d : dciToPoll) {
session.forceDCIPoll(d.nodeId, d.dciId);
monitor.worked(1);
}
monitor.done();
}
@Override
protected String getErrorMessage() {
return Messages.get().ForceDciPoll_ErrorText;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CreateSnmpDci method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (objects.size() == 0)
return;
MibObject mibObject = MibCache.findObject(objects.get(0).getName(), false);
String description = (mibObject != null) ? mibObject.getName() : objects.get(0).getName();
if (objects.size() > 1)
// $NON-NLS-1$
description += " @@instance@@";
final CreateSnmpDciDialog dlg = new CreateSnmpDciDialog(shell, description);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final List<SnmpValue> values = new ArrayList<SnmpValue>(objects);
// Get set of nodes
final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
for (SnmpValue v : values) {
AbstractNode node = (AbstractNode) session.findObjectById(v.getNodeId(), AbstractNode.class);
if (node != null) {
nodes.add(node);
}
}
// Check what nodes requires DCI list lock
final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (AbstractNode n : nodes) {
IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
}
new ConsoleJob(Messages.get().CreateSnmpDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().CreateSnmpDci_ErrorMessage;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask(Messages.get(getDisplay()).CreateSnmpDci_TaskTitle, values.size());
for (SnmpValue v : values) {
// $NON-NLS-1$
final String description = dlg.getDescription().replaceAll("@@instance@@", Long.toString(v.getObjectId().getIdFromPos(v.getObjectId().getLength() - 1)));
createDci(session, v, description, dlg.getPollingInterval(), dlg.getRetentionTime(), dlg.getDeltaCalculation(), lockRequired);
monitor.worked(1);
}
monitor.done();
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CreateTemplateGroup 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().CreateTemplateGroup_TemplateGroup);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateTemplateGroup_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_TEMPLATEGROUP, dlg.getObjectName(), parentId);
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateTemplateGroup_JobError, dlg.getObjectName());
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class TableComparisonChartElement method refreshData.
/**
* Refresh graph's data
*/
protected void refreshData() {
if (updateInProgress)
return;
updateInProgress = true;
ConsoleJob job = new ConsoleJob(Messages.get().TableComparisonChartElement_JobTitle, viewPart, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Table data = session.getTableLastValues(config.getNodeId(), config.getDciId());
runInUIThread(new Runnable() {
@Override
public void run() {
if (!((Widget) chart).isDisposed())
updateChart(data);
updateInProgress = false;
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().TableComparisonChartElement_JobError;
}
@Override
protected void jobFailureHandler() {
updateInProgress = false;
super.jobFailureHandler();
}
};
job.setUser(false);
job.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class EventProcessingPolicyEditor method savePolicy.
/**
* Save policy to server
*/
private void savePolicy() {
actionSave.setEnabled(false);
new ConsoleJob(Messages.get().EventProcessingPolicyEditor_SaveJob_Title, this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
EventProcessingPolicy newPolicy = new EventProcessingPolicy(ruleEditors.size());
for (RuleEditor editor : ruleEditors) newPolicy.addRule(editor.getRule());
session.saveEventProcessingPolicy(policy);
runInUIThread(new Runnable() {
@Override
public void run() {
modified = false;
firePropertyChange(PROP_DIRTY);
}
});
}
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
actionSave.setEnabled(modified);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().EventProcessingPolicyEditor_SaveJob_Error;
}
}.start();
}
Aggregations