Search in sources :

Example 1 with LastValuesWidget

use of org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget 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 LastValuesWidget

use of org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget in project netxms by netxms.

the class LastValues method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    FormLayout formLayout = new FormLayout();
    parent.setLayout(formLayout);
    // $NON-NLS-1$
    dataView = new LastValuesWidget(this, parent, SWT.NONE, dcTarget, "LastValuesWidget", null);
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    dataView.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    dataView.setFilterCloseAction(actionShowFilter);
    dataView.enableFilter(initShowFilter);
    dataView.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            settings.put("LastValuesView", dataView.isFilterEnabled());
        }
    });
    activateContext();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) DisposeListener(org.eclipse.swt.events.DisposeListener) LastValuesWidget(org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with LastValuesWidget

use of org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget in project netxms by netxms.

the class LastValues method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    initShowFilter = safeCast(settings.get("LastValuesTab.showFilter"), settings.getBoolean("LastValuesTab.showFilter"), initShowFilter);
    dataView = new LastValuesWidget(getViewPart(), parent, SWT.NONE, getObject(), "LastValuesTab", new // $NON-NLS-1$
    VisibilityValidator() {

        @Override
        public boolean isVisible() {
            return isActive();
        }
    });
    dataView.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            settings.put("LastValuesTab.showFilter", dataView.isFilterEnabled());
        }
    });
    dataView.setAutoRefreshEnabled(true);
    dataView.setFilterCloseAction(new Action() {

        @Override
        public void run() {
            dataView.enableFilter(false);
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            // $NON-NLS-1$
            Command command = service.getCommand("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter");
            // $NON-NLS-1$
            State state = command.getState("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter.state");
            state.setValue(false);
            service.refreshElements(command.getId(), null);
        }
    });
    dataView.enableFilter(initShowFilter);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) Action(org.eclipse.jface.action.Action) LastValuesWidget(org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

LastValuesWidget (org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 List (java.util.List)1 Command (org.eclipse.core.commands.Command)1 State (org.eclipse.core.commands.State)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Action (org.eclipse.jface.action.Action)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 CLabel (org.eclipse.swt.custom.CLabel)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 PartInitException (org.eclipse.ui.PartInitException)1 ICommandService (org.eclipse.ui.commands.ICommandService)1 NXCException (org.netxms.client.NXCException)1 Alarm (org.netxms.client.events.Alarm)1 AlarmComment (org.netxms.client.events.AlarmComment)1 AbstractObject (org.netxms.client.objects.AbstractObject)1