use of org.netxms.client.NXCSession in project netxms by netxms.
the class ObjectToolExecutor method executeAgentAction.
/**
* @param node
* @param tool
* @param inputValues
*/
private static void executeAgentAction(final ObjectContext node, final ObjectTool tool, final Map<String, String> inputValues) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
if ((tool.getFlags() & ObjectTool.GENERATES_OUTPUT) == 0) {
new ConsoleJob(String.format(Messages.get().ObjectToolsDynamicMenu_ExecuteOnNode, node.object.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ObjectToolsDynamicMenu_CannotExecuteOnNode, node.object.getObjectName());
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String action = session.executeActionWithExpansion(node.object.getObjectId(), node.getAlarmId(), tool.getData(), inputValues);
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(null, Messages.get().ObjectToolsDynamicMenu_ToolExecution, String.format(Messages.get().ObjectToolsDynamicMenu_ExecSuccess, action, node.object.getObjectName()));
}
});
}
}.start();
} else {
// $NON-NLS-1$
final String secondaryId = Long.toString(node.object.getObjectId()) + "&" + Long.toString(tool.getId());
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
AgentActionResults view = (AgentActionResults) window.getActivePage().showView(AgentActionResults.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
view.executeAction(tool.getData(), node.getAlarmId(), inputValues);
} catch (Exception e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ObjectToolsDynamicMenu_Error, String.format(Messages.get().ObjectToolsDynamicMenu_ErrorOpeningView, e.getLocalizedMessage()));
}
}
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class RackPassiveElements method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (!isModified)
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCObjectModificationData md = new NXCObjectModificationData(rack.getObjectId());
try {
md.setPassiveElements(passiveElements.createXml());
} catch (Exception e) {
MessageDialogHelper.openError(getShell(), "Rack attribute error", "Unable to save rack attribute configuration" + e.getMessage());
}
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Update rack attributes", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
isModified = false;
}
@Override
protected String getErrorMessage() {
return "Rack attribute update error";
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
isModified = true;
}
});
}
}
}.start();
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class SNMP method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(node.getObjectId());
if (isApply)
setValid(false);
md.setSnmpVersion(snmpIndexToVersion(snmpVersion.getSelectionIndex()));
try {
md.setSnmpPort(Integer.parseInt(snmpPort.getText(), 10));
} catch (NumberFormatException e) {
MessageDialog.openWarning(getShell(), Messages.get().Communication_Warning, Messages.get().Communication_WarningInvalidSNMPPort);
if (isApply)
setValid(true);
return false;
}
md.setSnmpProxy(snmpProxy.getObjectId());
md.setSnmpAuthMethod(snmpAuth.getSelectionIndex());
md.setSnmpPrivMethod(snmpPriv.getSelectionIndex());
md.setSnmpAuthName(snmpAuthName.getText());
md.setSnmpAuthPassword(snmpAuthPassword.getText());
md.setSnmpPrivPassword(snmpPrivPassword.getText());
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format("Updating SNMP settings for node %s", node.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot update SNMP settings for node %s", node.getObjectName());
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
SNMP.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class TrustedNodes method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (!isModified)
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
Set<Long> idList = trustedNodes.keySet();
long[] nodes = new long[idList.size()];
int i = 0;
for (long id : idList) nodes[i++] = id;
md.setTrustedNodes(nodes);
new ConsoleJob(String.format(Messages.get().TrustedNodes_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
TrustedNodes.this.setValid(true);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().TrustedNodes_JobError;
}
}.schedule();
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class ZoneCommunications method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
if (isApply)
setValid(false);
final NXCObjectModificationData md = new NXCObjectModificationData(zone.getObjectId());
md.setZoneProxy(agentProxy.getObjectId());
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format(Messages.get().ZoneCommunications_JobName, zone.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().ZoneCommunications_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
ZoneCommunications.this.setValid(true);
}
});
}
}
}.start();
return true;
}
Aggregations