Search in sources :

Example 1 with ObjectListLabelProvider

use of org.netxms.webui.mobile.pages.helpers.ObjectListLabelProvider in project netxms by netxms.

the class ObjectBrowser method createContent.

/* (non-Javadoc)
    * @see org.netxms.webui.mobile.pages.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Composite createContent(Composite parent) {
    viewer = new TableViewer(parent, SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ObjectListLabelProvider());
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((AbstractObject) e1).getObjectName().compareToIgnoreCase(((AbstractObject) e2).getObjectName());
        }
    });
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            AbstractObject o = (AbstractObject) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            handleSelection(o);
        }
    });
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    viewer.setInput(session.findObjectById(rootObjectId).getChildsAsArray());
    setTitle(session.getObjectName(rootObjectId));
    return null;
}
Also used : ObjectListLabelProvider(org.netxms.webui.mobile.pages.helpers.ObjectListLabelProvider) NXCSession(org.netxms.client.NXCSession) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) AbstractObject(org.netxms.client.objects.AbstractObject) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) AbstractObject(org.netxms.client.objects.AbstractObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableViewer(org.eclipse.jface.viewers.TableViewer)

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 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 NXCSession (org.netxms.client.NXCSession)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 ObjectListLabelProvider (org.netxms.webui.mobile.pages.helpers.ObjectListLabelProvider)1