Search in sources :

Example 1 with ObjectWrapper

use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.

the class SummaryTableWidget method showObjectDetails.

/**
 * Show details for selected object
 */
private void showObjectDetails() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    AbstractObject object = ((ObjectWrapper) selection.getFirstElement()).getObject();
    if (object != null) {
        try {
            TabbedObjectView view = (TabbedObjectView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(TabbedObjectView.ID);
            view.setObject(object);
        } catch (PartInitException e) {
            MessageDialogHelper.openError(getShell(), Messages.get().SummaryTableWidget_Error, String.format(Messages.get().SummaryTableWidget_CannotOpenObjectDetails, e.getLocalizedMessage()));
        }
    }
}
Also used : TabbedObjectView(org.netxms.ui.eclipse.objectview.views.TabbedObjectView) AbstractObject(org.netxms.client.objects.AbstractObject) ObjectWrapper(org.netxms.ui.eclipse.objects.ObjectWrapper) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with ObjectWrapper

use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.

the class ObjectToolsDynamicMenu method buildNodeSet.

/**
 * Build node set from selection
 *
 * @param selection
 * @return
 */
private Set<ObjectContext> buildNodeSet(IStructuredSelection selection) {
    final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    for (Object o : selection.toList()) {
        if (o instanceof AbstractNode) {
            nodes.add(new ObjectContext((AbstractNode) o, null));
        } else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster)) {
            for (AbstractObject n : ((AbstractObject) o).getAllChilds(AbstractObject.OBJECT_NODE)) nodes.add(new ObjectContext((AbstractNode) n, null));
        } else if (o instanceof Alarm) {
            AbstractNode n = (AbstractNode) session.findObjectById(((Alarm) o).getSourceObjectId(), AbstractNode.class);
            if (n != null)
                nodes.add(new ObjectContext(n, (Alarm) o));
        } else if (o instanceof ObjectWrapper) {
            AbstractObject n = ((ObjectWrapper) o).getObject();
            if ((n != null) && (n instanceof AbstractNode))
                nodes.add(new ObjectContext((AbstractNode) n, null));
        }
    }
    return nodes;
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) Cluster(org.netxms.client.objects.Cluster) ServiceRoot(org.netxms.client.objects.ServiceRoot) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Alarm(org.netxms.client.events.Alarm) ObjectWrapper(org.netxms.ui.eclipse.objects.ObjectWrapper) AbstractObject(org.netxms.client.objects.AbstractObject) ObjectContext(org.netxms.ui.eclipse.objects.ObjectContext) Subnet(org.netxms.client.objects.Subnet) HashSet(java.util.HashSet)

Example 3 with ObjectWrapper

use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.

the class SetObjectManagementState method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    final Object[] objects = ((IStructuredSelection) selection).toArray();
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (Object o : objects) {
                if (o instanceof AbstractObject)
                    session.setObjectManaged(((AbstractObject) o).getObjectId(), managed);
                else if (o instanceof ObjectWrapper)
                    session.setObjectManaged(((ObjectWrapper) o).getObjectId(), managed);
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().SetObjectManagementState_JobError;
        }
    }.start();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NXCSession(org.netxms.client.NXCSession) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) ObjectWrapper(org.netxms.ui.eclipse.objects.ObjectWrapper) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 4 with ObjectWrapper

use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.

the class SetObjectMaintenanceState method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    final Object[] objects = ((IStructuredSelection) selection).toArray();
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (Object o : objects) {
                if (o instanceof AbstractObject)
                    session.setObjectMaintenance(((AbstractObject) o).getObjectId(), maintained);
                else if (o instanceof ObjectWrapper)
                    session.setObjectMaintenance(((ObjectWrapper) o).getObjectId(), maintained);
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().SetObjectManagementState_JobError;
        }
    }.start();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NXCSession(org.netxms.client.NXCSession) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) ObjectWrapper(org.netxms.ui.eclipse.objects.ObjectWrapper) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)4 ObjectWrapper (org.netxms.ui.eclipse.objects.ObjectWrapper)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 NXCSession (org.netxms.client.NXCSession)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 HashSet (java.util.HashSet)1 PartInitException (org.eclipse.ui.PartInitException)1 Alarm (org.netxms.client.events.Alarm)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 Cluster (org.netxms.client.objects.Cluster)1 Container (org.netxms.client.objects.Container)1 ServiceRoot (org.netxms.client.objects.ServiceRoot)1 Subnet (org.netxms.client.objects.Subnet)1 ObjectContext (org.netxms.ui.eclipse.objects.ObjectContext)1 TabbedObjectView (org.netxms.ui.eclipse.objectview.views.TabbedObjectView)1