Search in sources :

Example 1 with AgentConfigEditorView

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();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) IViewReference(org.eclipse.ui.IViewReference) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) AgentConfigEditorView(org.netxms.ui.eclipse.agentmanager.views.AgentConfigEditorView) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IViewReference (org.eclipse.ui.IViewReference)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCSession (org.netxms.client.NXCSession)1 AgentConfigEditorView (org.netxms.ui.eclipse.agentmanager.views.AgentConfigEditorView)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1