Search in sources :

Example 1 with FilterText

use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.

the class RepositoryManager method createPartControl.

/* (non-Javadoc)
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    content.setLayout(new FormLayout());
    // Create filter area
    filterText = new FilterText(content, SWT.NONE);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    filterText.setCloseAction(new Action() {

        @Override
        public void run() {
            enableFilter(false);
        }
    });
    final String[] columnNames = { "Name", "Version", "GUID" };
    final int[] columnWidths = { 300, 120, 150 };
    viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new RepositoryContentProvider(this));
    viewer.setLabelProvider(new RepositoryLabelProvider());
    // viewer.setComparator(new AgentFileComparator());
    filter = new RepositoryFilter();
    viewer.addFilter(filter);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionDelete.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.getTree().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterText);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    viewer.getTree().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    filterText.setCloseAction(actionShowFilter);
    // Set initial focus to filter input line
    if (filterEnabled)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
    refreshRepositoryList();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryLabelProvider(org.netxms.ui.eclipse.market.views.helpers.RepositoryLabelProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) RepositoryContentProvider(org.netxms.ui.eclipse.market.views.helpers.RepositoryContentProvider) RepositoryFilter(org.netxms.ui.eclipse.market.views.helpers.RepositoryFilter) FilterText(org.netxms.ui.eclipse.widgets.FilterText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with FilterText

use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.

the class EventProcessingPolicyEditor method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    // $NON-NLS-1$
    filterEnabled = settings.getBoolean("EventProcessingPolicyEditor.filterEnabled");
    // Initiate loading of required plugins if they was not loaded yet
    try {
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(new ServerAction(0), "org.eclipse.ui.model.IWorkbenchAdapter");
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter");
    } catch (Exception e) {
    }
    // $NON-NLS-1$
    imageStop = Activator.getImageDescriptor("icons/stop.png").createImage();
    // $NON-NLS-1$
    imageAlarm = Activator.getImageDescriptor("icons/alarm.png").createImage();
    // $NON-NLS-1$
    imageSituation = Activator.getImageDescriptor("icons/situation.gif").createImage();
    // $NON-NLS-1$
    imageExecute = Activator.getImageDescriptor("icons/execute.png").createImage();
    // $NON-NLS-1$
    imageTerminate = Activator.getImageDescriptor("icons/terminate.png").createImage();
    imageCollapse = SharedIcons.COLLAPSE.createImage();
    imageExpand = SharedIcons.EXPAND.createImage();
    imageEdit = SharedIcons.EDIT.createImage();
    parent.setLayout(new FormLayout());
    // Create filter area
    filterControl = new FilterText(parent, SWT.NONE);
    filterControl.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    filterControl.setCloseAction(new Action() {

        @Override
        public void run() {
            enableFilter(false);
        }
    });
    scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
    dataArea = new Composite(scroller, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    dataArea.setLayout(layout);
    dataArea.setBackground(BACKGROUND_COLOR);
    scroller.setContent(dataArea);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle r = scroller.getClientArea();
            scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterControl);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    scroller.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterControl.setLayoutData(fd);
    normalFont = JFaceResources.getDefaultFont();
    boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    sessionListener = new SessionListener() {

        @Override
        public void notificationHandler(SessionNotification n) {
            processSessionNotification(n);
        }
    };
    session.addListener(sessionListener);
    selection = new TreeSet<RuleEditor>(new Comparator<RuleEditor>() {

        @Override
        public int compare(RuleEditor arg0, RuleEditor arg1) {
            return arg0.getRuleNumber() - arg1.getRuleNumber();
        }
    });
    createActions();
    contributeToActionBars();
    openEventProcessingPolicy();
    activateContext();
    // Set initial focus to filter input line
    if (filterEnabled)
        filterControl.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ServerAction(org.netxms.client.ServerAction) Action(org.eclipse.jface.action.Action) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) EventTemplate(org.netxms.client.events.EventTemplate) Rectangle(org.eclipse.swt.graphics.Rectangle) Comparator(java.util.Comparator) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FilterText(org.netxms.ui.eclipse.widgets.FilterText) SessionListener(org.netxms.client.SessionListener) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor) ControlEvent(org.eclipse.swt.events.ControlEvent) ServerAction(org.netxms.client.ServerAction) SessionNotification(org.netxms.client.SessionNotification) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with FilterText

use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.

the class AlarmCategorySelectionDialog 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.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    // Create filter area
    filterText = new FilterText(dialogArea, SWT.NONE, null, false);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    filterText.setLayoutData(gd);
    alarmCategoryList = new AlarmCategoryList(dialogArea, SWT.NONE, TABLE_CONFIG_PREFIX, false);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 350;
    alarmCategoryList.setLayoutData(gd);
    alarmCategoryList.getViewer().addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) AlarmCategoryList(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCategoryList) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) FilterText(org.netxms.ui.eclipse.widgets.FilterText) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 4 with FilterText

use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.

the class ServerFileManager method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    content = new Composite(parent, SWT.NONE);
    content.setLayout(new FormLayout());
    // Create filter area
    filterText = new FilterText(content, SWT.NONE);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    final String[] columnNames = { Messages.get().ViewServerFile_FileName, Messages.get().ViewServerFile_FileType, Messages.get().ViewServerFile_FileSize, Messages.get().ViewServerFile_ModificationDate };
    final int[] columnWidths = { 300, 150, 300, 300 };
    viewer = new SortableTableViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ServerFileLabelProvider());
    viewer.setComparator(new ServerFileComparator());
    filter = new ServerFileFilter();
    viewer.addFilter(filter);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionDelete.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterText);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    viewer.getTable().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    session.addListener(this);
    filterText.setCloseAction(actionShowFilter);
    // Set initial focus to filter input line
    if (initShowFilter)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
    refreshFileList();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ServerFileLabelProvider(org.netxms.ui.eclipse.filemanager.views.helpers.ServerFileLabelProvider) ServerFileComparator(org.netxms.ui.eclipse.filemanager.views.helpers.ServerFileComparator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ServerFileFilter(org.netxms.ui.eclipse.filemanager.views.helpers.ServerFileFilter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) FilterText(org.netxms.ui.eclipse.widgets.FilterText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with FilterText

use of org.netxms.ui.eclipse.widgets.FilterText in project netxms by netxms.

the class WorldMap method createPartControl.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.osm.views.AbstractGeolocationView#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    initialZoom = settings.get(ID + "zoom") != null ? settings.getInt(ID + "zoom") : 2;
    if (settings.get(ID + "latitude") != null && settings.get(ID + "longitude") != null)
        initialLocation = new GeoLocation(settings.getDouble(ID + "latitude"), settings.getDouble(ID + "longitude"));
    filterEnabled = settings.get(ID + "filterEnabled") != null ? settings.getBoolean(ID + "filterEnabled") : true;
    super.createPartControl(parent);
    parent.setLayout(new FormLayout());
    // Create filter area
    filterControl = new FilterText(parent, SWT.NONE);
    filterControl.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    filterControl.setCloseAction(new Action() {

        @Override
        public void run() {
            enableFilter(false);
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterControl);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    map.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterControl.setLayoutData(fd);
    // Set initial focus to filter input line
    if (filterEnabled)
        filterControl.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Action(org.eclipse.jface.action.Action) ModifyListener(org.eclipse.swt.events.ModifyListener) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) FilterText(org.netxms.ui.eclipse.widgets.FilterText) GeoLocation(org.netxms.base.GeoLocation) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 ModifyListener (org.eclipse.swt.events.ModifyListener)19 FilterText (org.netxms.ui.eclipse.widgets.FilterText)19 FormAttachment (org.eclipse.swt.layout.FormAttachment)15 FormData (org.eclipse.swt.layout.FormData)15 FormLayout (org.eclipse.swt.layout.FormLayout)15 Composite (org.eclipse.swt.widgets.Composite)15 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)12 Action (org.eclipse.jface.action.Action)11 DisposeEvent (org.eclipse.swt.events.DisposeEvent)11 DisposeListener (org.eclipse.swt.events.DisposeListener)11 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)10 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)10 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)10 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)9 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)8 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)8 GridLayout (org.eclipse.swt.layout.GridLayout)6