Search in sources :

Example 1 with VlanView

use of org.netxms.ui.eclipse.topology.views.VlanView in project netxms by netxms.

the class ShowVlans 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(VlanView.ID, Long.toString(objectId));
    if (vr != null) {
        VlanView view = (VlanView) vr.getView(true);
        if (view != null) {
            window.getActivePage().activate(view);
        }
    } else {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().ShowVlans_JobTitle, null, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                final List<VlanInfo> vlans = session.getVlans(objectId);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            VlanView view = (VlanView) window.getActivePage().showView(VlanView.ID, Long.toString(objectId), IWorkbenchPage.VIEW_ACTIVATE);
                            view.setVlans(vlans);
                        } catch (PartInitException e) {
                            MessageDialogHelper.openError(window.getShell(), Messages.get().ShowVlans_Error, Messages.get().ShowVlans_CannotOpenView + e.getLocalizedMessage());
                        }
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get().ShowVlans_JobError;
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) IViewReference(org.eclipse.ui.IViewReference) VlanView(org.netxms.ui.eclipse.topology.views.VlanView) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

List (java.util.List)1 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 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 VlanView (org.netxms.ui.eclipse.topology.views.VlanView)1