use of org.netxms.ui.eclipse.agentmanager.views.AgentConfigEditorView in project netxms by netxms.
the class OpenAgentConfig method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
IViewReference vr = window.getActivePage().findViewReference(AgentConfigEditorView.ID, Long.toString(nodeId));
if (vr != null) {
AgentConfigEditorView view = (AgentConfigEditorView) vr.getView(true);
if (view != null) {
window.getActivePage().activate(view);
}
} else {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().OpenAgentConfig_GetConfig, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String config = session.getAgentConfig(nodeId);
runInUIThread(new Runnable() {
@Override
public void run() {
try {
AgentConfigEditorView view = (AgentConfigEditorView) window.getActivePage().showView(AgentConfigEditorView.ID, Long.toString(nodeId), IWorkbenchPage.VIEW_ACTIVATE);
view.setConfig(config);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().OpenAgentConfig_Error, Messages.get().OpenAgentConfig_OpenErrorPrefix + e.getLocalizedMessage());
}
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().OpenAgentConfig_OpenError;
}
}.start();
}
}
Aggregations