Search in sources :

Example 31 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class TableColumns method queryColumns.

/**
 * Query columns from agent
 */
private void queryColumns() {
    if (!MessageDialogHelper.openQuestion(getShell(), "Warning", "Current column definition will be replaced by definition provided by agent. Continue?"))
        return;
    AbstractObject object = ConsoleSharedData.getSession().findObjectById(dci.getNodeId());
    if ((editor.getSourceNode() == 0) && ((object instanceof Template) || (object instanceof Cluster))) {
        ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
        if (dlg.open() != Window.OK)
            return;
        object = dlg.getSelectedObjects().get(0);
    }
    updateColumnsFromAgent(dci.getName(), true, object);
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) Template(org.netxms.client.objects.Template)

Example 32 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class DataCollectionEditor method copyItems.

/**
 * Copy items to another node
 */
private void copyItems(final boolean doMove) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeAndTemplateSelectionFilter(true));
    if (dlg.open() != Window.OK)
        return;
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    Iterator<?> it = selection.iterator();
    final long[] dciList = new long[selection.size()];
    for (int i = 0; (i < dciList.length) && it.hasNext(); i++) dciList[i] = ((DataCollectionObject) it.next()).getId();
    new ConsoleJob(Messages.get().DataCollectionEditor_CopyJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (AbstractObject o : dlg.getSelectedObjects(AbstractNode.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Template.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Cluster.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(MobileDevice.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Sensor.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            if (doMove) {
                for (long id : dciList) dciConfig.deleteObject(id);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(dciConfig.getItems());
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_CopyJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) Cluster(org.netxms.client.objects.Cluster) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) Template(org.netxms.client.objects.Template) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Sensor(org.netxms.client.objects.Sensor)

Example 33 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class RuleEditor method createConditionControl.

/**
 * Create condition summary control
 *
 * @param parent
 * @param rule
 * @return
 */
private Control createConditionControl(Composite parent, final EventProcessingPolicyRule rule) {
    Composite clientArea = new Composite(parent, SWT.NONE);
    clientArea.setBackground(SharedColors.getColor(SharedColors.RULE_EDITOR_BACKGROUND, getDisplay()));
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    clientArea.setLayout(layout);
    boolean needAnd = false;
    if (((rule.getSources().size() > 0) && rule.isSourceInverted()) || ((rule.getSources().size() == 0) && (rule.getEvents().size() > 0) && rule.isEventsInverted()))
        createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF_NOT, null);
    else
        createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF, null);
    /* source */
    if (rule.getSources().size() > 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSourceObjects#0");
        addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SourceIs, needAnd, rule.isSourceInverted(), listener);
        for (Long id : rule.getSources()) {
            CLabel clabel = createCLabel(clientArea, 2, false);
            clabel.addMouseListener(listener);
            AbstractObject object = session.findObjectById(id);
            if (object != null) {
                clabel.setText(object.getObjectName());
                clabel.setImage(labelProvider.getImage(object));
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                clabel.setText("[" + id.toString() + "]");
                clabel.setImage(SharedIcons.IMG_UNKNOWN_OBJECT);
            }
        }
        needAnd = true;
    }
    /* events */
    if (rule.getEvents().size() > 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleEvents#10");
        addConditionGroupLabel(clientArea, Messages.get().RuleEditor_EventIs, needAnd, rule.isEventsInverted(), listener);
        List<EventObject> sortedEvents = new ArrayList<EventObject>(rule.getEvents().size());
        for (Long code : rule.getEvents()) {
            EventObject event = session.findEventObjectByCode(code);
            if (event == null) {
                event = new EventTemplate(code);
                ((EventTemplate) event).setSeverity(Severity.UNKNOWN);
                // $NON-NLS-1$ //$NON-NLS-2$
                event.setName("<" + code.toString() + ">");
            }
            sortedEvents.add(event);
        }
        Collections.sort(sortedEvents, new Comparator<EventObject>() {

            @Override
            public int compare(EventObject t1, EventObject t2) {
                return t1.getName().compareToIgnoreCase(t2.getName());
            }
        });
        for (EventObject e : sortedEvents) {
            CLabel clabel = createCLabel(clientArea, 2, false);
            clabel.addMouseListener(listener);
            clabel.setText(e.getName());
            if (e instanceof EventTemplate)
                clabel.setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) e).getSeverity()));
            else
                clabel.setImage(SharedIcons.IMG_CONTAINER);
        }
        needAnd = true;
    }
    /* severity */
    if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_ANY) != EventProcessingPolicyRule.SEVERITY_ANY) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSeverityFilter#20");
        addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SeverityIs, needAnd, false, listener);
        if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_NORMAL) != 0)
            addSeverityLabel(clientArea, Severity.NORMAL, listener);
        if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_WARNING) != 0)
            addSeverityLabel(clientArea, Severity.WARNING, listener);
        if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MINOR) != 0)
            addSeverityLabel(clientArea, Severity.MINOR, listener);
        if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MAJOR) != 0)
            addSeverityLabel(clientArea, Severity.MAJOR, listener);
        if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_CRITICAL) != 0)
            addSeverityLabel(clientArea, Severity.CRITICAL, listener);
        needAnd = true;
    }
    /* script */
    if ((rule.getScript() != null) && !rule.getScript().isEmpty()) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleFilterScript#30");
        addConditionGroupLabel(clientArea, Messages.get().RuleEditor_ScriptIs, needAnd, false, listener);
        ScriptEditor scriptEditor = new ScriptEditor(clientArea, SWT.BORDER, SWT.NONE);
        GridData gd = new GridData();
        gd.horizontalIndent = INDENT * 2;
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        scriptEditor.setLayoutData(gd);
        scriptEditor.setText(rule.getScript());
        scriptEditor.getTextWidget().setEditable(false);
        scriptEditor.getTextWidget().addMouseListener(listener);
    }
    return clientArea;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) EventTemplate(org.netxms.client.events.EventTemplate) ArrayList(java.util.ArrayList) EventObject(org.netxms.client.events.EventObject) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData)

Example 34 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class ObjectGeoLocationViewer method mouseHover.

/* (non-Javadoc)
    * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
    */
@Override
public void mouseHover(MouseEvent e) {
    if (// ignore hover if tooltip already open
    objectTooltipRectangle == null) {
        AbstractObject object = getObjectAtPoint(new Point(e.x, e.y));
        if (object != currentObject) {
            objectToolTipLocation = (object != null) ? new Point(e.x, e.y) : null;
            setCurrentObject(object);
        }
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Point(org.eclipse.swt.graphics.Point)

Example 35 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class PackageManager method deployPackage.

/**
 * Deploy package on managed nodes
 */
private void deployPackage() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
    dlg.enableMultiSelection(true);
    if (dlg.open() != Window.OK)
        return;
    final Set<Long> objects = new HashSet<Long>();
    for (AbstractObject o : dlg.getSelectedObjects()) {
        objects.add(o.getObjectId());
    }
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {

                private PackageDeploymentMonitor monitor = null;

                @Override
                public void statusUpdate(long nodeId, int status, String message) {
                    if (monitor != null)
                        monitor.viewStatusUpdate(nodeId, status, message);
                }

                @Override
                public void deploymentStarted() {
                    final Object sync = new Object();
                    synchronized (sync) {
                        runInUIThread(new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
                                    monitor.setPackageId(pkg.getId());
                                } catch (PartInitException e) {
                                    MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
                                }
                                synchronized (sync) {
                                    sync.notify();
                                }
                            }
                        });
                        try {
                            sync.wait();
                        } catch (InterruptedException e) {
                        }
                    }
                }

                @Override
                public void deploymentComplete() {
                    runInUIThread(new Runnable() {

                        @Override
                        public void run() {
                            MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
                        }
                    });
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().PackageManager_DepStartError;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) PackageInfo(org.netxms.client.packages.PackageInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PackageDeploymentListener(org.netxms.client.packages.PackageDeploymentListener) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractObject(org.netxms.client.objects.AbstractObject) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) HashSet(java.util.HashSet)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)216 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)55 NXCSession (org.netxms.client.NXCSession)51 AbstractNode (org.netxms.client.objects.AbstractNode)31 PartInitException (org.eclipse.ui.PartInitException)27 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)25 Cluster (org.netxms.client.objects.Cluster)22 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)22 ArrayList (java.util.ArrayList)20 Node (org.netxms.client.objects.Node)20 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)18 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)18 GridLayout (org.eclipse.swt.layout.GridLayout)15 Container (org.netxms.client.objects.Container)15 Interface (org.netxms.client.objects.Interface)12 Template (org.netxms.client.objects.Template)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Point (org.eclipse.swt.graphics.Point)11