use of org.netxms.client.NXCSession in project netxms by netxms.
the class SelectAgentParamDlg method fillParameterList.
/*
* (non-Javadoc)
*
* @see org.netxms.ui.eclipse.datacollection.dialogs.AbstractSelectParamDlg#fillParameterList()
*/
@Override
protected void fillParameterList() {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SelectAgentParamDlg_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().SelectAgentParamDlg_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
if (selectTables) {
final List<AgentTable> tables = session.getSupportedTables(object.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tables.toArray());
}
});
} else {
final List<AgentParameter> parameters = session.getSupportedParameters(object.getObjectId(), origin);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(parameters.toArray());
}
});
}
}
}.start();
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class TestTransformationDlg method runScript.
/**
* Run script
*/
private void runScript() {
getButton(RUN).setEnabled(false);
final String input = inputValue.getText();
inputValue.getTextControl().setEditable(false);
status.setText(Messages.get().TestTransformationDlg_Running);
status.setImage(imageWaiting);
// $NON-NLS-1$
result.setText("");
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().TestTransformationDlg_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final TransformationTestResult r = session.testTransformationScript(nodeId, script, input);
runInUIThread(new Runnable() {
@Override
public void run() {
if ((getShell() == null) || getShell().isDisposed())
return;
if (r.success) {
status.setText(Messages.get().TestTransformationDlg_Success);
status.setImage(StatusDisplayInfo.getStatusImage(Severity.NORMAL));
} else {
status.setText(Messages.get().TestTransformationDlg_Failure);
status.setImage(StatusDisplayInfo.getStatusImage(Severity.CRITICAL));
}
result.setText(r.result);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().TestTransformationDlg_JobError;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
*/
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
if ((getShell() == null) || getShell().isDisposed())
return;
getButton(RUN).setEnabled(true);
inputValue.getTextControl().setEditable(true);
inputValue.getTextControl().setFocus();
}
});
}
}.start();
}
use of org.netxms.client.NXCSession 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.client.NXCSession in project netxms by netxms.
the class DataCollectionObjectPropertyTester method test.
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof DataCollectionObject))
return false;
if (// $NON-NLS-1$
property.equals("isClusterObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
if (owner instanceof Cluster)
return true;
if (owner instanceof AbstractNode) {
for (AbstractObject o : owner.getParentsAsArray()) {
if (o instanceof Cluster)
return true;
}
}
return false;
}
if (// $NON-NLS-1$
property.equals("isTemplateObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
return (owner instanceof Template);
}
return false;
}
use of org.netxms.client.NXCSession 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();
}
Aggregations