Search in sources :

Example 1 with ZoneSelectionDialogComparator

use of org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.ZoneSelectionDialogComparator in project netxms by netxms.

the class ZoneSelectionDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    dialogArea.setLayout(layout);
    filterText = new FilterText(dialogArea, SWT.NONE, null, false);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    filterText.setLayoutData(gd);
    // $NON-NLS-1$
    final String filterString = settings.get("SelectZone.Filter");
    if (filterString != null)
        filterText.setText(filterString);
    final String[] names = { "Name" };
    final int[] widths = { 200 };
    zoneList = new SortableTableViewer(dialogArea, names, widths, 0, SWT.UP, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL);
    zoneList.setContentProvider(new ArrayContentProvider());
    zoneList.setComparator(new ZoneSelectionDialogComparator());
    zoneList.setLabelProvider(new WorkbenchLabelProvider());
    filter = new ZoneSelectionDialogFilter();
    if (filterString != null)
        filter.setFilterString(filterString);
    zoneList.addFilter(filter);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    zoneList.getTable().setLayoutData(gd);
    zoneList.setInput(session.getAllZones());
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            filter.setFilterString(filterText.getText());
            zoneList.refresh();
        }
    });
    zoneList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            ZoneSelectionDialog.this.okPressed();
        }
    });
    filterText.setFocus();
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ZoneSelectionDialogComparator(org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.ZoneSelectionDialogComparator) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) FilterText(org.netxms.ui.eclipse.widgets.FilterText) ZoneSelectionDialogFilter(org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.ZoneSelectionDialogFilter)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)1 NXCSession (org.netxms.client.NXCSession)1 ZoneSelectionDialogComparator (org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.ZoneSelectionDialogComparator)1 ZoneSelectionDialogFilter (org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.ZoneSelectionDialogFilter)1 FilterText (org.netxms.ui.eclipse.widgets.FilterText)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1