Search in sources :

Example 1 with ServerFileLabelProvider

use of org.netxms.ui.eclipse.filemanager.dialogs.helpers.ServerFileLabelProvider in project netxms by netxms.

the class SelectServerFileDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    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);
    final String[] names = { Messages.get().SelectServerFileDialog_ColName, Messages.get().SelectServerFileDialog_ColSize, Messages.get().SelectServerFileDialog_ColModTime };
    final int[] widths = { 200, 100, 150 };
    viewer = new SortableTableViewer(dialogArea, names, widths, 0, SWT.DOWN, SWT.FULL_SELECTION | SWT.BORDER | (multiSelect ? SWT.MULTI : 0));
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ServerFileLabelProvider());
    viewer.setComparator(new ServerFileComparator());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 450;
    viewer.getControl().setLayoutData(gd);
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SelectServerFileDialog_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final ServerFile[] files = session.listServerFiles();
            runInUIThread(new Runnable() {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().SelectServerFileDialog_JobError;
        }
    }.start();
    return dialogArea;
}
Also used : NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ServerFileLabelProvider(org.netxms.ui.eclipse.filemanager.dialogs.helpers.ServerFileLabelProvider) ServerFileComparator(org.netxms.ui.eclipse.filemanager.dialogs.helpers.ServerFileComparator) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)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 ServerFileComparator (org.netxms.ui.eclipse.filemanager.dialogs.helpers.ServerFileComparator)1 ServerFileLabelProvider (org.netxms.ui.eclipse.filemanager.dialogs.helpers.ServerFileLabelProvider)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1