use of org.netxms.ui.eclipse.objecttools.views.AgentActionResults 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()));
}
}
}
Aggregations