Search in sources :

Example 1 with ServerJobComparator

use of org.netxms.ui.eclipse.serverjobmanager.views.helpers.ServerJobComparator in project netxms by netxms.

the class ServerJobManager method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    final String[] names = { Messages.get().ServerJobManager_ColStatus, Messages.get().ServerJobManager_ColInitiator, Messages.get().ServerJobManager_ColNode, Messages.get().ServerJobManager_ColDescription, Messages.get().ServerJobManager_ColProgress, Messages.get().ServerJobManager_ColMessage };
    final int[] widths = { 80, 100, 150, 250, 100, 300 };
    viewer = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SortableTableViewer.DEFAULT_STYLE);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ServerJobLabelProvider());
    viewer.setComparator(new ServerJobComparator());
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    session = (NXCSession) ConsoleSharedData.getSession();
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionCancelJob.setEnabled(selection.size() > 0);
                actionHoldJob.setEnabled(selection.size() > 0);
                actionUnholdJob.setEnabled(selection.size() > 0);
            }
        }
    });
    // Create listener for notifications received from server via client library
    clientListener = new SessionListener() {

        @Override
        public void notificationHandler(SessionNotification n) {
            if (n.getCode() != SessionNotification.JOB_CHANGE)
                return;
            refreshJobList(false);
        }
    };
    session.addListener(clientListener);
    refreshJobList(false);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ServerJobLabelProvider(org.netxms.ui.eclipse.serverjobmanager.views.helpers.ServerJobLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SessionListener(org.netxms.client.SessionListener) ServerJobComparator(org.netxms.ui.eclipse.serverjobmanager.views.helpers.ServerJobComparator) SessionNotification(org.netxms.client.SessionNotification)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 SessionListener (org.netxms.client.SessionListener)1 SessionNotification (org.netxms.client.SessionNotification)1 ServerJobComparator (org.netxms.ui.eclipse.serverjobmanager.views.helpers.ServerJobComparator)1 ServerJobLabelProvider (org.netxms.ui.eclipse.serverjobmanager.views.helpers.ServerJobLabelProvider)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1