Search in sources :

Example 1 with ActionSelectionDialogLabelProvider

use of org.netxms.ui.eclipse.actionmanager.dialogs.helpers.ActionSelectionDialogLabelProvider in project netxms by netxms.

the class ActionSelectionDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    dialogArea.setLayout(layout);
    viewer = new TableViewer(dialogArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ActionSelectionDialogLabelProvider());
    viewer.setComparator(new ViewerComparator() {

        /* (non-Javadoc)
          * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
          */
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((ServerAction) e1).getName().compareToIgnoreCase(((ServerAction) e2).getName());
        }
    });
    final NXCSession session = ConsoleSharedData.getSession();
    new ConsoleJob("Get server actions", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<ServerAction> list = session.getActions();
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    viewer.setInput(list.toArray());
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot get server actions";
        }
    }.start();
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 400;
    viewer.getControl().setLayoutData(gd);
    return dialogArea;
}
Also used : ActionSelectionDialogLabelProvider(org.netxms.ui.eclipse.actionmanager.dialogs.helpers.ActionSelectionDialogLabelProvider) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) TableViewer(org.eclipse.jface.viewers.TableViewer) ServerAction(org.netxms.client.ServerAction)

Aggregations

List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 NXCSession (org.netxms.client.NXCSession)1 ServerAction (org.netxms.client.ServerAction)1 ActionSelectionDialogLabelProvider (org.netxms.ui.eclipse.actionmanager.dialogs.helpers.ActionSelectionDialogLabelProvider)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1