/** * Returns the default {@link View}. * * @return the {@link View} instance if found, null otherwise */ public synchronized View getDefaultView() { final String defaultView = m_surveillanceViewConfiguration.getDefaultView(); return getView(defaultView); }
private List<View> getViewList() { return m_config.getViews(); }
/** * This method loads the configuration data from disk. */ public synchronized void load() { LOG.debug("Loading surveillance view configuration."); if (m_cfgFile == null) { try { m_cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); } catch (final IOException e) { LOG.error("Unable to load {}", ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME)); m_cfgFile = new File(System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "surveillance-views.xml"); } } LOG.debug("Using surveillance view file: {}", m_cfgFile); if (!m_cfgFile.exists()) { LOG.warn("Surveillance view configuration {} does not exist!", m_cfgFile); m_surveillanceViewConfiguration = new SurveillanceViewConfiguration(); } else { m_surveillanceViewConfiguration = JaxbUtils.unmarshal(SurveillanceViewConfiguration.class, m_cfgFile); } LOG.debug("Surveillance view configuration loaded: {}", m_surveillanceViewConfiguration); }
/** * This method loads the configuration data from disk. */ public synchronized void load() { LOG.debug("Loading surveillance view configuration."); if (m_cfgFile == null) { try { m_cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); } catch (final IOException e) { LOG.error("Unable to load {}", ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME)); m_cfgFile = new File(System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "surveillance-views.xml"); } } LOG.debug("Using surveillance view file: {}", m_cfgFile); if (!m_cfgFile.exists()) { LOG.warn("Surveillance view configuration {} does not exist!", m_cfgFile); m_surveillanceViewConfiguration = new SurveillanceViewConfiguration(); } else { m_surveillanceViewConfiguration = JaxbUtils.unmarshal(SurveillanceViewConfiguration.class, m_cfgFile); } LOG.debug("Surveillance view configuration loaded: {}", m_surveillanceViewConfiguration); }
/** * Checks whether this object contains a given {@link View} instance. * * @param view the {@link View} instance to search for * @return true, if the {@link View} exists, false otherwise */ public synchronized boolean containsView(View view) { return m_surveillanceViewConfiguration.getViews().contains(view); }
/** * Returns the default {@link View}. * * @return the {@link View} instance if found, null otherwise */ public synchronized View getDefaultView() { final String defaultView = m_surveillanceViewConfiguration.getDefaultView(); return getView(defaultView); }
/** * Checks whether this object contains a given {@link View} instance. * * @param view the {@link View} instance to search for * @return true, if the {@link View} exists, false otherwise */ public synchronized boolean containsView(View view) { return m_surveillanceViewConfiguration.getViews().contains(view); }
/** * <p>getDefaultView</p> * * @return a {@link org.opennms.netmgt.config.surveillanceViews.View} object. */ @Override public View getDefaultView() { String defaultView = getContainer().getObject().getConfig().getDefaultView(); return getView(defaultView); }
/** * Returns the {@link View} for the given title. * * @param name the title to search for * @return the {@link View} instance if found, null otherwise */ public synchronized View getView(String name) { for (final View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(name)) { return view; } } return null; }
public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Surveillance View configuration the default"); final View view = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getDefaultView().equals(view.getName())); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().setDefaultView(view.getName()); } m_table.refreshRowCache(); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Default surveillance view"); } }); return checkBox; } }
/** * Checks whether this object contains {@link View} data concerning the given title. * * @param name the title to search for * @return true, if a {@link View} with the given name exists, false otherwise */ public synchronized boolean containsView(String name) { for (View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(name)) { return true; } } return false; }
public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Surveillance View configuration the default"); final View view = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getDefaultView().equals(view.getName())); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().setDefaultView(view.getName()); } m_table.refreshRowCache(); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Default surveillance view"); } }); return checkBox; } }
/** * Checks whether this object contains {@link View} data concerning the given title. * * @param name the title to search for * @return true, if a {@link View} with the given name exists, false otherwise */ public synchronized boolean containsView(String name) { for (View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(name)) { return true; } } return false; }
/** * Returns the {@link View} for the given title. * * @param name the title to search for * @return the {@link View} instance if found, null otherwise */ public synchronized View getView(String name) { for (final View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(name)) { return view; } } return null; }
/** * Replaces a {@link View} with a new one. * * @param oldView the old view to be replaced * @param newView the new view */ public synchronized void replaceView(View oldView, View newView) { View viewFound = null; for (View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(oldView.getName())) { viewFound = view; break; } } if (viewFound != null) { int index = getSurveillanceViewConfiguration().getViews().indexOf(viewFound); getSurveillanceViewConfiguration().getViews().set(index, newView); } }
/** * This method removes a {@link View} from this provider. * * @param view the {@link View} instance to be removed */ public synchronized void removeView(View view) { if (m_surveillanceViewConfiguration == null) { load(); } m_surveillanceViewConfiguration.getViews().remove(view); save(); } }
/** * This method adds a {@link View} to this provider. * * @param view the {@link View} instance to be added */ public synchronized void addView(View view) { if (m_surveillanceViewConfiguration == null) { load(); } m_surveillanceViewConfiguration.getViews().add(view); save(); }
/** * This method removes a {@link View} from this provider. * * @param view the {@link View} instance to be removed */ public synchronized void removeView(View view) { if (m_surveillanceViewConfiguration == null) { load(); } m_surveillanceViewConfiguration.getViews().remove(view); save(); } }
/** * This method adds a {@link View} to this provider. * * @param view the {@link View} instance to be added */ public synchronized void addView(View view) { if (m_surveillanceViewConfiguration == null) { load(); } m_surveillanceViewConfiguration.getViews().add(view); save(); }
/** * Replaces a {@link View} with a new one. * * @param oldView the old view to be replaced * @param newView the new view */ public synchronized void replaceView(View oldView, View newView) { View viewFound = null; for (View view : m_surveillanceViewConfiguration.getViews()) { if (view.getName().equals(oldView.getName())) { viewFound = view; break; } } if (viewFound != null) { int index = getSurveillanceViewConfiguration().getViews().indexOf(viewFound); getSurveillanceViewConfiguration().getViews().set(index, newView); } }