Search in sources :

Example 1 with AgentParameterFilter

use of org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterFilter in project netxms by netxms.

the class AbstractSelectParamDlg 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.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    Label label = new Label(dialogArea, SWT.NONE);
    label.setText(selectTables ? Messages.get().AbstractSelectParamDlg_AvailTables : Messages.get().AbstractSelectParamDlg_AvailableParameters);
    filterText = new Text(dialogArea, SWT.BORDER);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    filterText.setLayoutData(gd);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            filter.setFilter(filterText.getText());
            viewer.refresh(false);
        }
    });
    final String[] names = { Messages.get().AbstractSelectParamDlg_Name, selectTables ? Messages.get().AbstractSelectParamDlg_InstanceColumn : Messages.get().AbstractSelectParamDlg_Type, Messages.get().AbstractSelectParamDlg_Description };
    final int[] widths = { 150, selectTables ? 150 : 100, 350 };
    viewer = new SortableTableViewer(dialogArea, names, widths, 0, SWT.UP, SWT.FULL_SELECTION | SWT.BORDER);
    // $NON-NLS-1$
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), getConfigurationPrefix() + ".viewer");
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(selectTables ? new AgentTableLabelProvider() : new AgentParameterLabelProvider());
    viewer.setComparator(selectTables ? new AgentTableComparator() : new AgentParameterComparator());
    filter = new AgentParameterFilter();
    viewer.addFilter(filter);
    viewer.getTable().addMouseListener(new MouseListener() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            okPressed();
        }

        @Override
        public void mouseDown(MouseEvent e) {
        }

        @Override
        public void mouseUp(MouseEvent e) {
        }
    });
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // $NON-NLS-1$
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), getConfigurationPrefix() + ".viewer");
        }
    });
    createPopupMenu();
    gd = new GridData();
    gd.heightHint = 250;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    viewer.getControl().setLayoutData(gd);
    fillParameterList();
    return dialogArea;
}
Also used : AgentTableComparator(org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentTableComparator) AgentParameterLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterLabelProvider) DisposeListener(org.eclipse.swt.events.DisposeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) AgentTableLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentTableLabelProvider) Label(org.eclipse.swt.widgets.Label) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) AgentParameterFilter(org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterFilter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) AgentParameterComparator(org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterComparator) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseListener (org.eclipse.swt.events.MouseListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 AgentParameterComparator (org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterComparator)1 AgentParameterFilter (org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterFilter)1 AgentParameterLabelProvider (org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentParameterLabelProvider)1 AgentTableComparator (org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentTableComparator)1 AgentTableLabelProvider (org.netxms.ui.eclipse.datacollection.dialogs.helpers.AgentTableLabelProvider)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1