Search in sources :

Example 1 with AlarmCommentsEditor

use of org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor in project netxms by netxms.

the class AlarmDetails method refresh.

/**
 * Refresh view
 */
private void refresh() {
    new ConsoleJob(Messages.get().AlarmDetails_RefreshJobTitle, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Alarm alarm = session.getAlarm(alarmId);
            final List<AlarmComment> comments = session.getAlarmComments(alarmId);
            List<EventInfo> _events = null;
            try {
                _events = session.getAlarmEvents(alarmId);
            } catch (NXCException e) {
                if (e.getErrorCode() != RCC.ACCESS_DENIED)
                    throw e;
            }
            final List<EventInfo> events = _events;
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    updateAlarmDetails(alarm);
                    for (AlarmCommentsEditor e : editors.values()) e.dispose();
                    for (AlarmComment n : comments) editors.put(n.getId(), createEditor(n));
                    if (lastValuesWidget == null) {
                        AbstractObject object = session.findObjectById(alarm.getSourceObjectId());
                        if (object != null) {
                            // $NON-NLS-1$
                            lastValuesWidget = new LastValuesWidget(AlarmDetails.this, dataArea, SWT.BORDER, object, "AlarmDetails.LastValues", null);
                            lastValuesWidget.refresh();
                        }
                    }
                    if (events != null) {
                        eventViewer.setInput(events);
                        eventViewer.expandAll();
                        if (labelAccessDenied != null) {
                            labelAccessDenied.dispose();
                            labelAccessDenied = null;
                        }
                    } else if (labelAccessDenied == null) {
                        labelAccessDenied = new CLabel(eventViewer.getControl().getParent(), SWT.NONE);
                        toolkit.adapt(labelAccessDenied);
                        labelAccessDenied.setImage(StatusDisplayInfo.getStatusImage(Severity.CRITICAL));
                        labelAccessDenied.setText(Messages.get().AlarmDetails_RelatedEvents_AccessDenied);
                        labelAccessDenied.moveAbove(null);
                        labelAccessDenied.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                    }
                    updateLayout();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().AlarmDetails_RefreshJobError;
        }
    }.start();
}
Also used : AlarmCommentsEditor(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor) CLabel(org.eclipse.swt.custom.CLabel) LastValuesWidget(org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget) AlarmComment(org.netxms.client.events.AlarmComment) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 2 with AlarmCommentsEditor

use of org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor in project netxms by netxms.

the class AlarmDetails method createEditor.

/**
 * Create comment editor widget
 *
 * @param note alarm note associated with this widget
 * @return
 */
private AlarmCommentsEditor createEditor(final AlarmComment note) {
    HyperlinkAdapter editAction = new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            editComment(note.getId(), note.getText());
        }
    };
    HyperlinkAdapter deleteAction = new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            deleteComment(note.getId());
        }
    };
    final AlarmCommentsEditor e = new AlarmCommentsEditor(editorsArea, toolkit, imageCache, note, editAction, deleteAction);
    toolkit.adapt(e);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    e.setLayoutData(gd);
    e.moveBelow(linkAddComment);
    return e;
}
Also used : AlarmCommentsEditor(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) GridData(org.eclipse.swt.layout.GridData) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 3 with AlarmCommentsEditor

use of org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor in project netxms by netxms.

the class AlarmComments method createEditor.

/**
 * Create comment editor widget
 *
 * @param note alarm note associated with this widget
 * @return
 */
private AlarmCommentsEditor createEditor(final AlarmComment note) {
    HyperlinkAdapter editAction = new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            editComment(note.getId(), note.getText());
        }
    };
    HyperlinkAdapter deleteAction = new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            deleteComment(note.getId());
        }
    };
    final AlarmCommentsEditor e = new AlarmCommentsEditor(editorsArea, toolkit, imageCache, note, editAction, deleteAction);
    toolkit.adapt(e);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    e.setLayoutData(gd);
    e.moveBelow(linkAddComment);
    return e;
}
Also used : AlarmCommentsEditor(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) GridData(org.eclipse.swt.layout.GridData) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 4 with AlarmCommentsEditor

use of org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor in project netxms by netxms.

the class AlarmComments method refresh.

/**
 * Refresh view
 */
private void refresh() {
    new ConsoleJob(Messages.get().AlarmComments_GetComments, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Alarm alarm = session.getAlarm(alarmId);
            final List<AlarmComment> comments = session.getAlarmComments(alarmId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    updateAlarmDetails(alarm);
                    for (AlarmCommentsEditor e : editors.values()) e.dispose();
                    for (AlarmComment c : comments) editors.put(c.getId(), createEditor(c));
                    updateLayout();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().AlarmComments_GetError;
        }
    }.start();
}
Also used : AlarmCommentsEditor(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Alarm(org.netxms.client.events.Alarm) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) AlarmComment(org.netxms.client.events.AlarmComment) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

AlarmCommentsEditor (org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCommentsEditor)4 GridData (org.eclipse.swt.layout.GridData)3 List (java.util.List)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 PartInitException (org.eclipse.ui.PartInitException)2 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)2 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)2 Alarm (org.netxms.client.events.Alarm)2 AlarmComment (org.netxms.client.events.AlarmComment)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 CLabel (org.eclipse.swt.custom.CLabel)1 NXCException (org.netxms.client.NXCException)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 LastValuesWidget (org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget)1