Search in sources :

Example 1 with VisibilityValidator

use of org.netxms.ui.eclipse.tools.VisibilityValidator in project netxms by netxms.

the class AlarmTab method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    initShowFilter = settings.getBoolean("AlarmTab.showFilter");
    alarmList = new AlarmList(getViewPart(), parent, SWT.NONE, getConfigPrefix(), new VisibilityValidator() {

        @Override
        public boolean isVisible() {
            return isActive();
        }
    });
    alarmList.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            settings.put("AlarmTab.showFilter", alarmList.isFilterEnabled());
        }
    });
    // Force update of "show colors" menu item in object tabbed view
    // when settings changes in any alarm viewer
    propertyChangeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (// $NON-NLS-1$
            event.getProperty().equals("SHOW_ALARM_STATUS_COLORS")) {
                ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
                service.refreshElements("org.netxms.ui.eclipse.alarmviewer.commands.show_status_colors", null);
            }
        }
    };
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
    alarmList.setFilterCloseAction(new Action() {

        @Override
        public void run() {
            alarmList.enableFilter(false);
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            // $NON-NLS-1$
            Command command = service.getCommand("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list");
            // $NON-NLS-1$
            State state = command.getState("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list.state");
            state.setValue(false);
            service.refreshElements(command.getId(), null);
        }
    });
    alarmList.enableFilter(initShowFilter);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Action(org.eclipse.jface.action.Action) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) AlarmList(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmList) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 2 with VisibilityValidator

use of org.netxms.ui.eclipse.tools.VisibilityValidator in project netxms by netxms.

the class PerformanceTab method update.

/**
 * Update tab with received DCIs
 *
 * @param items Performance tab items
 */
private void update(final PerfTabDci[] items) {
    if (waitingImage != null) {
        waitingImage.dispose();
        waitingImage = null;
    }
    for (PerfTabGraph chart : charts.values()) chart.dispose();
    charts.clear();
    List<PerfTabGraphSettings> settings = new ArrayList<PerfTabGraphSettings>(items.length);
    for (int i = 0; i < items.length; i++) {
        try {
            PerfTabGraphSettings s = PerfTabGraphSettings.createFromXml(items[i].getPerfTabSettings());
            if (s.isEnabled()) {
                s.setRuntimeDciInfo(items[i]);
                settings.add(s);
            }
        } catch (Exception e) {
        }
    }
    // Sort DCIs: by group name, then by order number, then alphabetically
    Collections.sort(settings, new Comparator<PerfTabGraphSettings>() {

        @Override
        public int compare(PerfTabGraphSettings o1, PerfTabGraphSettings o2) {
            int result = Integer.signum(o1.getOrder() - o2.getOrder());
            if (result == 0)
                result = o1.getGroupName().compareToIgnoreCase(o2.getGroupName());
            if (result == 0) {
                // Sort top-level DCI's by chart title, and attached DCIs by legend name
                if (o1.getGroupName().isEmpty())
                    result = o1.getRuntimeTitle().compareToIgnoreCase(o2.getRuntimeTitle());
                else
                    result = o1.getRuntimeName().compareToIgnoreCase(o2.getRuntimeName());
            }
            return result;
        }
    });
    for (PerfTabGraphSettings s : settings) {
        String groupName = s.getGroupName();
        PerfTabGraph chart = groupName.isEmpty() ? null : charts.get(groupName);
        if (chart == null) {
            chart = new PerfTabGraph(chartArea, getObject().getObjectId(), s.getRuntimeDciInfo(), s, getViewPart(), new VisibilityValidator() {

                @Override
                public boolean isVisible() {
                    return isActive();
                }
            });
            charts.put(groupName.isEmpty() ? "##" + Long.toString(s.getRuntimeDciInfo().getId()) : groupName, chart);
            final GridData gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            gd.heightHint = 320;
            chart.setLayoutData(gd);
        } else {
            chart.addItem(s.getRuntimeDciInfo(), s);
        }
    }
    for (PerfTabGraph chart : charts.values()) chart.start();
    updateChartAreaLayout();
}
Also used : VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) PerfTabGraphSettings(org.netxms.ui.eclipse.perfview.PerfTabGraphSettings) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) PerfTabGraph(org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph) MalformedURLException(java.net.MalformedURLException)

Example 3 with VisibilityValidator

use of org.netxms.ui.eclipse.tools.VisibilityValidator in project netxms by netxms.

the class AddressMap method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    addressMap = new SubnetAddressMap(scroller, SWT.NONE, getViewPart(), new VisibilityValidator() {

        @Override
        public boolean isVisible() {
            return isActive();
        }
    });
    scroller.setContent(addressMap);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            scroller.setMinSize(addressMap.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    });
}
Also used : VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SubnetAddressMap(org.netxms.ui.eclipse.topology.widgets.SubnetAddressMap) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 4 with VisibilityValidator

use of org.netxms.ui.eclipse.tools.VisibilityValidator in project netxms by netxms.

the class LastValues method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    initShowFilter = safeCast(settings.get("LastValuesTab.showFilter"), settings.getBoolean("LastValuesTab.showFilter"), initShowFilter);
    dataView = new LastValuesWidget(getViewPart(), parent, SWT.NONE, getObject(), "LastValuesTab", new // $NON-NLS-1$
    VisibilityValidator() {

        @Override
        public boolean isVisible() {
            return isActive();
        }
    });
    dataView.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            settings.put("LastValuesTab.showFilter", dataView.isFilterEnabled());
        }
    });
    dataView.setAutoRefreshEnabled(true);
    dataView.setFilterCloseAction(new Action() {

        @Override
        public void run() {
            dataView.enableFilter(false);
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            // $NON-NLS-1$
            Command command = service.getCommand("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter");
            // $NON-NLS-1$
            State state = command.getState("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter.state");
            state.setValue(false);
            service.refreshElements(command.getId(), null);
        }
    });
    dataView.enableFilter(initShowFilter);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) Action(org.eclipse.jface.action.Action) LastValuesWidget(org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

VisibilityValidator (org.netxms.ui.eclipse.tools.VisibilityValidator)4 Command (org.eclipse.core.commands.Command)2 State (org.eclipse.core.commands.State)2 Action (org.eclipse.jface.action.Action)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 ICommandService (org.eclipse.ui.commands.ICommandService)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 GridData (org.eclipse.swt.layout.GridData)1 AlarmList (org.netxms.ui.eclipse.alarmviewer.widgets.AlarmList)1 LastValuesWidget (org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget)1 PerfTabGraphSettings (org.netxms.ui.eclipse.perfview.PerfTabGraphSettings)1 PerfTabGraph (org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph)1