Search in sources :

Example 1 with MibObjectDetails

use of org.netxms.ui.eclipse.snmp.widgets.MibObjectDetails in project netxms by netxms.

the class MibExplorer method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    // $NON-NLS-1$
    headerFont = new Font(parent.getDisplay(), "Verdana", 11, SWT.BOLD);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    parent.setLayout(layout);
    header = new CLabel(parent, SWT.BORDER);
    header.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    header.setFont(headerFont);
    header.setBackground(SharedColors.getColor(SharedColors.MIB_EXPLORER_HEADER_BACKGROUND, parent.getDisplay()));
    header.setForeground(SharedColors.getColor(SharedColors.MIB_EXPLORER_HEADER_TEXT, parent.getDisplay()));
    // $NON-NLS-1$
    header.setText((currentNode != null) ? currentNode.getObjectName() : "");
    SashForm splitter = new SashForm(parent, SWT.VERTICAL);
    splitter.setLayout(new FillLayout());
    splitter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    SashForm mibViewSplitter = new SashForm(splitter, SWT.HORIZONTAL);
    mibViewSplitter.setLayout(new FillLayout());
    mibBrowser = new MibBrowser(mibViewSplitter, SWT.BORDER);
    mibBrowser.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            MibObject object = mibBrowser.getSelection();
            details.setObject(object);
        }
    });
    details = new MibObjectDetails(mibViewSplitter, SWT.BORDER, true, mibBrowser);
    // Create result area
    resultArea = new Composite(splitter, SWT.BORDER);
    FormLayout formLayout = new FormLayout();
    resultArea.setLayout(formLayout);
    // Create filter area
    filterText = new FilterText(resultArea, SWT.BORDER);
    filterText.addModifyListener(new ModifyListener() {

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

        @Override
        public void run() {
            enableFilter(false);
            actionShowFilter.setChecked(initShowFilter);
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    ;
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    // walk results
    viewer = new TableViewer(resultArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    setupViewerColumns();
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new SnmpValueLabelProvider());
    filter = new SnmpWalkFilter();
    viewer.addFilter(filter);
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // $NON-NLS-1$
            WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "MibExplorer");
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            actionSelect.setEnabled(selection.size() == 1);
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            selectInTree();
        }
    });
    // Setup layout
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    ;
    fd.top = new FormAttachment(filterText, 0, SWT.BOTTOM);
    fd.bottom = new FormAttachment(100, 0);
    fd.right = new FormAttachment(100, 0);
    viewer.getControl().setLayoutData(fd);
    splitter.setWeights(new int[] { 70, 30 });
    createActions();
    contributeToActionBars();
    createTreePopupMenu();
    createResultsPopupMenu();
    activateContext();
    // Set initial focus to filter input line
    if (initShowFilter)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) DisposeListener(org.eclipse.swt.events.DisposeListener) ExportToCsvAction(org.netxms.ui.eclipse.actions.ExportToCsvAction) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Action(org.eclipse.jface.action.Action) SnmpValueLabelProvider(org.netxms.ui.eclipse.snmp.views.helpers.SnmpValueLabelProvider) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) MibObjectDetails(org.netxms.ui.eclipse.snmp.widgets.MibObjectDetails) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) FilterText(org.netxms.ui.eclipse.widgets.FilterText) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) SnmpWalkFilter(org.netxms.ui.eclipse.snmp.views.helpers.SnmpWalkFilter) SashForm(org.eclipse.swt.custom.SashForm) MibBrowser(org.netxms.ui.eclipse.snmp.widgets.MibBrowser) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) MibObject(org.netxms.client.snmp.MibObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with MibObjectDetails

use of org.netxms.ui.eclipse.snmp.widgets.MibObjectDetails in project netxms by netxms.

the class MibSelectionDialog 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.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.numColumns = (nodeId != 0) ? 3 : 2;
    dialogArea.setLayout(layout);
    /* MIB tree */
    Composite mibTreeGroup = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    mibTreeGroup.setLayout(layout);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.verticalSpan = 2;
    mibTreeGroup.setLayoutData(gd);
    Label label = new Label(mibTreeGroup, SWT.NONE);
    label.setText(Messages.get().MibSelectionDialog_MIBTree);
    mibTree = new MibBrowser(mibTreeGroup, SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.widthHint = 500;
    gd.heightHint = 250;
    mibTree.setLayoutData(gd);
    mibTree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            onMibTreeSelectionChanged();
        }
    });
    // $NON-NLS-1$
    oid = WidgetHelper.createLabeledText(dialogArea, SWT.BORDER, 500, Messages.get().MibSelectionDialog_OID, "", WidgetHelper.DEFAULT_LAYOUT_DATA);
    oid.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onManualOidChange();
        }
    });
    if (nodeId != 0) {
        Button button = new Button(dialogArea, SWT.PUSH);
        button.setText(Messages.get().MibSelectionDialog_Walk);
        gd = new GridData();
        gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
        gd.verticalAlignment = SWT.BOTTOM;
        button.setLayoutData(gd);
        button.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                doWalk();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
    }
    details = new MibObjectDetails(dialogArea, SWT.NONE, false, mibTree);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalSpan = (nodeId != 0) ? 2 : 1;
    details.setLayoutData(gd);
    if (initialSelection != null) {
        MibObject object = MibCache.getMibTree().findObject(initialSelection, false);
        if (object != null) {
            mibTree.setSelection(object);
        }
    }
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) MibObjectDetails(org.netxms.ui.eclipse.snmp.widgets.MibObjectDetails) MibBrowser(org.netxms.ui.eclipse.snmp.widgets.MibBrowser) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MibObject(org.netxms.client.snmp.MibObject) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 MibObject (org.netxms.client.snmp.MibObject)2 MibBrowser (org.netxms.ui.eclipse.snmp.widgets.MibBrowser)2 MibObjectDetails (org.netxms.ui.eclipse.snmp.widgets.MibObjectDetails)2 Action (org.eclipse.jface.action.Action)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 CLabel (org.eclipse.swt.custom.CLabel)1 SashForm (org.eclipse.swt.custom.SashForm)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1