Search in sources :

Example 6 with EventTemplate

use of org.netxms.client.events.EventTemplate in project netxms by netxms.

the class ThresholdLabelProvider method getColumnText.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
	 */
@Override
public String getColumnText(Object element, int columnIndex) {
    switch(columnIndex) {
        case Thresholds.COLUMN_OPERATION:
            int f = ((Threshold) element).getFunction();
            StringBuilder text = new StringBuilder(FUNCTIONS[f]);
            text.append(((Threshold) element).getSampleCount());
            // $NON-NLS-1$
            text.append(") ");
            if (f != Threshold.F_SCRIPT) {
                text.append(OPERATIONS[((Threshold) element).getOperation()]);
                text.append(' ');
                text.append(((Threshold) element).getValue());
            }
            return text.toString();
        case Thresholds.COLUMN_EVENT:
            final EventTemplate event = (EventTemplate) session.findEventObjectByCode(((Threshold) element).getFireEvent());
            return eventLabelProvider.getText(event);
    }
    return null;
}
Also used : EventTemplate(org.netxms.client.events.EventTemplate) Threshold(org.netxms.client.datacollection.Threshold)

Example 7 with EventTemplate

use of org.netxms.client.events.EventTemplate in project netxms by netxms.

the class EventObjectList method editEventTemplate.

/**
 * Edit currently selected event template
 */
protected void editEventTemplate() {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    if (selection.getFirstElement() instanceof EventGroup) {
        final EventGroup group = new EventGroup((EventGroup) selection.getFirstElement());
        EditEventGroupDialog dlg = new EditEventGroupDialog(getShell().getShell(), group);
        if (dlg.open() == Window.OK)
            modifyEventObject(group, false);
        else
            return;
    }
    final EventTemplate etmpl = new EventTemplate((EventTemplate) selection.getFirstElement());
    EditEventTemplateDialog dlg = new EditEventTemplateDialog(getShell().getShell(), etmpl, false);
    if (dlg.open() == Window.OK)
        modifyEventObject(etmpl, false);
}
Also used : EventTemplate(org.netxms.client.events.EventTemplate) EditEventTemplateDialog(org.netxms.ui.eclipse.eventmanager.dialogs.EditEventTemplateDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EditEventGroupDialog(org.netxms.ui.eclipse.eventmanager.dialogs.EditEventGroupDialog) EventGroup(org.netxms.client.events.EventGroup)

Example 8 with EventTemplate

use of org.netxms.client.events.EventTemplate in project netxms by netxms.

the class EventSelector method setEventCode.

/**
 * Set event code
 * @param eventCode
 */
public void setEventCode(long eventCode) {
    if (this.eventCode == eventCode)
        // nothing to change
        return;
    this.eventCode = eventCode;
    if (eventCode != 0) {
        EventObject object = ((NXCSession) ConsoleSharedData.getSession()).findEventObjectByCode(eventCode);
        if (object != null) {
            setText(object.getName());
            if (object instanceof EventTemplate)
                setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) object).getSeverity()));
            else
                setImage(SharedIcons.IMG_CONTAINER);
            getTextControl().setToolTipText(generateToolTipText(object));
        } else {
            setText(Messages.get().EventSelector_Unknown);
            setImage(null);
            getTextControl().setToolTipText(null);
        }
    } else {
        setText(Messages.get().EventSelector_None);
        setImage(null);
        getTextControl().setToolTipText(null);
    }
    fireModifyListeners();
}
Also used : NXCSession(org.netxms.client.NXCSession) EventTemplate(org.netxms.client.events.EventTemplate) EventObject(org.netxms.client.events.EventObject)

Example 9 with EventTemplate

use of org.netxms.client.events.EventTemplate in project netxms by netxms.

the class ExportFileBuilder method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    // Initiate loading of required plugins if they was not loaded yet
    try {
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter");
    } catch (Exception e) {
    }
    toolkit = new FormToolkit(getSite().getShell().getDisplay());
    form = toolkit.createScrolledForm(parent);
    form.setText(Messages.get().ExportFileBuilder_FormTitle);
    TableWrapLayout layout = new TableWrapLayout();
    layout.numColumns = 3;
    form.getBody().setLayout(layout);
    createFileSection();
    createTemplateSection();
    createEventSection();
    createTrapSection();
    createRuleSection();
    createScriptSection();
    createToolsSection();
    createSummaryTablesSection();
    createActionsSection();
    form.reflow(true);
    activateContext();
    createActions();
    contributeToActionBars();
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) EventTemplate(org.netxms.client.events.EventTemplate)

Example 10 with EventTemplate

use of org.netxms.client.events.EventTemplate in project netxms by netxms.

the class Thresholds method createContents.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    // Initiate loading of event manager plugin if it was not loaded before
    // $NON-NLS-1$
    Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
    Composite dialogArea = (Composite) super.createContents(parent);
    dci = editor.getObjectAsItem();
    thresholds = new ArrayList<Threshold>(dci.getThresholds().size());
    for (Threshold t : dci.getThresholds()) thresholds.add(new Threshold(t));
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    instance = new LabeledText(dialogArea, SWT.NONE);
    instance.setLabel(Messages.get().Thresholds_Instance);
    instance.setText(dci.getInstance());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    instance.setLayoutData(gd);
    if (// DCI created by instance discovery
    dci.getTemplateId() == dci.getNodeId())
        instance.getTextControl().setEditable(false);
    checkAllThresholds = new Button(dialogArea, SWT.CHECK);
    checkAllThresholds.setText(Messages.get().Thresholds_ProcessAll);
    checkAllThresholds.setSelection(dci.isProcessAllThresholds());
    Composite thresholdArea = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    thresholdArea.setLayoutData(gd);
    layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    thresholdArea.setLayout(layout);
    new Label(thresholdArea, SWT.NONE).setText(Messages.get().Thresholds_Thresholds);
    thresholdList = new TableViewer(thresholdArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    thresholdList.getControl().setLayoutData(gd);
    setupThresholdList();
    thresholdList.setInput(thresholds.toArray());
    Composite leftButtons = new Composite(thresholdArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    leftButtons.setLayoutData(gd);
    RowLayout buttonsLayout = new RowLayout(SWT.HORIZONTAL);
    buttonsLayout.marginBottom = 0;
    buttonsLayout.marginLeft = 0;
    buttonsLayout.marginRight = 0;
    buttonsLayout.marginTop = 0;
    buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
    buttonsLayout.fill = true;
    buttonsLayout.pack = false;
    leftButtons.setLayout(buttonsLayout);
    upButton = new Button(leftButtons, SWT.PUSH);
    upButton.setText(Messages.get().Thresholds_Up);
    upButton.setEnabled(false);
    upButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    downButton = new Button(leftButtons, SWT.PUSH);
    downButton.setText(Messages.get().Thresholds_Down);
    downButton.setEnabled(false);
    downButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    Composite buttons = new Composite(thresholdArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gd);
    buttonsLayout = new RowLayout(SWT.HORIZONTAL);
    buttonsLayout.marginBottom = 0;
    buttonsLayout.marginLeft = 0;
    buttonsLayout.marginRight = 0;
    buttonsLayout.marginTop = 0;
    buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
    buttonsLayout.fill = true;
    buttonsLayout.pack = false;
    buttons.setLayout(buttonsLayout);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().Thresholds_Add);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addThreshold();
        }
    });
    duplicateButton = new Button(buttons, SWT.PUSH);
    duplicateButton.setText("Duplicate");
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    duplicateButton.setLayoutData(rd);
    duplicateButton.setEnabled(false);
    duplicateButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            duplicateThreshold();
        }
    });
    modifyButton = new Button(buttons, SWT.PUSH);
    modifyButton.setText(Messages.get().Thresholds_Edit);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    modifyButton.setLayoutData(rd);
    modifyButton.setEnabled(false);
    modifyButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editThreshold();
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().Thresholds_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteThresholds();
        }
    });
    /**
     * Selection change listener for thresholds list **
     */
    thresholdList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            int index = thresholds.indexOf(selection.getFirstElement());
            upButton.setEnabled((selection.size() == 1) && (index > 0));
            downButton.setEnabled((selection.size() == 1) && (index >= 0) && (index < thresholds.size() - 1));
            modifyButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
            duplicateButton.setEnabled(selection.size() > 0);
        }
    });
    thresholdList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editThreshold();
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) EventTemplate(org.netxms.client.events.EventTemplate) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) Threshold(org.netxms.client.datacollection.Threshold) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

EventTemplate (org.netxms.client.events.EventTemplate)11 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 EventObject (org.netxms.client.events.EventObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 GridData (org.eclipse.swt.layout.GridData)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 RowData (org.eclipse.swt.layout.RowData)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Button (org.eclipse.swt.widgets.Button)2 Label (org.eclipse.swt.widgets.Label)2 Threshold (org.netxms.client.datacollection.Threshold)2 EditEventTemplateDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EditEventTemplateDialog)2 EventSelectionDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EventSelectionDialog)2