Search in sources :

Example 1 with EventGroup

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

the class EventObjectList method createNewEventGroup.

/**
 * Create new Event group
 */
protected void createNewEventGroup() {
    EventGroup group = new EventGroup();
    EditEventGroupDialog dlg = new EditEventGroupDialog(getShell().getShell(), group);
    if (dlg.open() == Window.OK)
        modifyEventObject(group, true);
}
Also used : EditEventGroupDialog(org.netxms.ui.eclipse.eventmanager.dialogs.EditEventGroupDialog) EventGroup(org.netxms.client.events.EventGroup)

Example 2 with EventGroup

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

the class EventObjectList method refreshView.

/**
 * Refresh view
 */
private void refreshView() {
    new ConsoleJob(Messages.get().EventConfigurator_OpenJob_Title, null, Activator.PLUGIN_ID, JOB_FAMILY) {

        /* (non-Javadoc)
          * @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
          */
        @Override
        protected String getErrorMessage() {
            return Messages.get().EventConfigurator_OpenJob_Error;
        }

        /* (non-Javadoc)
          * @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
          */
        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<EventObject> list = session.getEventObjects();
            runInUIThread(new Runnable() {

                /* (non-Javadoc)
                * @see java.lang.Runnable#run()
                */
                @Override
                public void run() {
                    eventObjects = new HashMap<Long, EventObject>(list.size());
                    for (final EventObject o : list) {
                        if ((o instanceof EventGroup) && !showGroups)
                            continue;
                        eventObjects.put(o.getCode(), o);
                    }
                    viewer.setInput(eventObjects.values().toArray());
                }
            });
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) EventObject(org.netxms.client.events.EventObject) EventGroup(org.netxms.client.events.EventGroup)

Example 3 with EventGroup

use of org.netxms.client.events.EventGroup 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 4 with EventGroup

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

the class EventObjectList method removeFromGroup.

/**
 * Remove event object from group
 */
@SuppressWarnings("unchecked")
protected void removeFromGroup() {
    ITreeSelection selection = (ITreeSelection) viewer.getSelection();
    List<EventObject> list = selection.toList();
    for (int i = 0; i < selection.size(); i++) {
        EventGroup parent = (EventGroup) selection.getPathsFor(list.get(i))[0].getParentPath().getLastSegment();
        EventObject child = list.get(i);
        parent.removeChild(child.getCode());
        modifyEventObject(parent, false);
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) EventObject(org.netxms.client.events.EventObject) EventGroup(org.netxms.client.events.EventGroup)

Example 5 with EventGroup

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

the class EventObjectList method enableDropSupport.

/**
 * Enable drop support
 */
public void enableDropSupport() {
    final Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new ViewerDropAdapter(viewer) {

        @Override
        public boolean performDrop(Object data) {
            TreeSelection selection = (TreeSelection) data;
            List<?> movableSelection = selection.toList();
            for (int i = 0; i < movableSelection.size(); i++) {
                if (((EventObject) movableSelection.get(i)).getCode() != ((EventGroup) getCurrentTarget()).getCode())
                    ((EventGroup) getCurrentTarget()).addChild(((EventObject) movableSelection.get(i)).getCode());
            }
            modifyEventObject((EventGroup) getCurrentTarget(), false);
            return true;
        }

        @Override
        public boolean validateDrop(Object target, int operation, TransferData transferType) {
            if ((target == null) || !LocalSelectionTransfer.getTransfer().isSupportedType(transferType))
                return false;
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            if (selection.isEmpty())
                return false;
            if (!(target instanceof EventGroup))
                return false;
            return true;
        }
    });
}
Also used : TransferData(org.eclipse.swt.dnd.TransferData) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) ViewerDropAdapter(org.eclipse.jface.viewers.ViewerDropAdapter) EventObject(org.netxms.client.events.EventObject) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EventObject(org.netxms.client.events.EventObject) EventGroup(org.netxms.client.events.EventGroup)

Aggregations

EventGroup (org.netxms.client.events.EventGroup)7 EventObject (org.netxms.client.events.EventObject)4 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)3 List (java.util.List)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 EditEventGroupDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EditEventGroupDialog)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 ViewerDropAdapter (org.eclipse.jface.viewers.ViewerDropAdapter)1 Transfer (org.eclipse.swt.dnd.Transfer)1 TransferData (org.eclipse.swt.dnd.TransferData)1 EventTemplate (org.netxms.client.events.EventTemplate)1 EditEventTemplateDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EditEventTemplateDialog)1 EventSelectionDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EventSelectionDialog)1