Search in sources :

Example 31 with IViewReference

use of org.eclipse.ui.IViewReference 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)

Example 32 with IViewReference

use of org.eclipse.ui.IViewReference in project netxms by netxms.

the class CreateInterfraceDci method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    final CreateInterfaceDciDialog dlg = new CreateInterfaceDciDialog(shell, (objects.size() == 1) ? objects.get(0) : null);
    if (dlg.open() == Window.OK) {
        final List<Interface> ifaces = new ArrayList<Interface>(objects);
        // Get set of nodes
        final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
        for (Interface iface : ifaces) {
            AbstractNode node = iface.getParentNode();
            if (node != null) {
                nodes.add(node);
            }
        }
        // Check what nodes requires DCI list lock
        final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        for (AbstractNode n : nodes) {
            IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
            lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
        }
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().CreateInterfraceDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {

            @Override
            protected String getErrorMessage() {
                return Messages.get().CreateInterfraceDci_JobError;
            }

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                InterfaceDciInfo[] dciInfo = dlg.getDciInfo();
                monitor.beginTask(Messages.get(getDisplay()).CreateInterfraceDci_TaskName, ifaces.size() * dciInfo.length);
                for (int i = 0; i < ifaces.size(); i++) {
                    for (int j = 0; j < dciInfo.length; j++) {
                        if (dciInfo[j].enabled) {
                            createInterfaceDci(session, ifaces.get(i), j, dciInfo[j], dlg.getPollingInterval(), dlg.getRetentionTime(), ifaces.size() > 1, lockRequired);
                        }
                        monitor.worked(1);
                    }
                }
                monitor.done();
            }
        }.start();
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateInterfaceDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.CreateInterfaceDciDialog) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Interface(org.netxms.client.objects.Interface) HashSet(java.util.HashSet)

Example 33 with IViewReference

use of org.eclipse.ui.IViewReference in project netxms by netxms.

the class CreateSnmpDci method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    if (objects.size() == 0)
        return;
    MibObject mibObject = MibCache.findObject(objects.get(0).getName(), false);
    String description = (mibObject != null) ? mibObject.getName() : objects.get(0).getName();
    if (objects.size() > 1)
        // $NON-NLS-1$
        description += " @@instance@@";
    final CreateSnmpDciDialog dlg = new CreateSnmpDciDialog(shell, description);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final List<SnmpValue> values = new ArrayList<SnmpValue>(objects);
    // Get set of nodes
    final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
    for (SnmpValue v : values) {
        AbstractNode node = (AbstractNode) session.findObjectById(v.getNodeId(), AbstractNode.class);
        if (node != null) {
            nodes.add(node);
        }
    }
    // Check what nodes requires DCI list lock
    final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
    final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    for (AbstractNode n : nodes) {
        IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
        lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
    }
    new ConsoleJob(Messages.get().CreateSnmpDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {

        @Override
        protected String getErrorMessage() {
            return Messages.get().CreateSnmpDci_ErrorMessage;
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            monitor.beginTask(Messages.get(getDisplay()).CreateSnmpDci_TaskTitle, values.size());
            for (SnmpValue v : values) {
                // $NON-NLS-1$
                final String description = dlg.getDescription().replaceAll("@@instance@@", Long.toString(v.getObjectId().getIdFromPos(v.getObjectId().getLength() - 1)));
                createDci(session, v, description, dlg.getPollingInterval(), dlg.getRetentionTime(), dlg.getDeltaCalculation(), lockRequired);
                monitor.worked(1);
            }
            monitor.done();
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SnmpValue(org.netxms.client.snmp.SnmpValue) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) MibObject(org.netxms.client.snmp.MibObject) CreateSnmpDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.CreateSnmpDciDialog) HashSet(java.util.HashSet)

Example 34 with IViewReference

use of org.eclipse.ui.IViewReference 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)

Example 35 with IViewReference

use of org.eclipse.ui.IViewReference in project hale by halestudio.

the class TransformationReportPage method onDoubleClick.

@Override
protected void onDoubleClick(Message m) {
    if (m instanceof TransformationMessage) {
        TransformationMessage tm = (TransformationMessage) m;
        AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
        if (as != null && as.getAlignment().getCell(tm.getCellId()) != null) {
            IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            // pin the property sheet if possible
            IViewReference ref = activeWindow.getActivePage().findViewReference(IPageLayout.ID_PROP_SHEET);
            if (ref != null) {
                IViewPart part = ref.getView(false);
                if (part instanceof PropertySheet) {
                    PropertySheet sheet = (PropertySheet) part;
                    if (!sheet.isPinned()) {
                        sheet.setPinned(true);
                    }
                }
            }
            // show cell in mapping view
            try {
                IViewPart part = activeWindow.getActivePage().showView(MappingView.ID);
                if (part instanceof MappingView) {
                    ((MappingView) part).selectCell(tm.getCellId());
                }
            } catch (PartInitException e) {
            // ignore
            }
        }
    }
    super.onDoubleClick(m);
}
Also used : TransformationMessage(eu.esdihumboldt.hale.common.align.transformation.report.TransformationMessage) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) IViewReference(org.eclipse.ui.IViewReference) MappingView(eu.esdihumboldt.hale.ui.views.mapping.MappingView) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IViewReference (org.eclipse.ui.IViewReference)66 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)48 IViewPart (org.eclipse.ui.IViewPart)37 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)23 PartInitException (org.eclipse.ui.PartInitException)23 IFile (org.eclipse.core.resources.IFile)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 ArrayList (java.util.ArrayList)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)8 CubridViewPart (com.cubrid.common.ui.spi.part.CubridViewPart)7 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)7 IOException (java.io.IOException)6 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)4 ParseException (java.text.ParseException)4 IProject (org.eclipse.core.resources.IProject)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4