コード例 #1
0
  private JPanel getRemoveOptionsPanel() {

    if (pnlRemoveOptions == null) {
      pnlRemoveOptions = new JPanel(new BorderLayout());
      DefaultBeanInfoResolver resolver = new DefaultBeanInfoResolver();

      BeanInfo beanInfo = resolver.getBeanInfo(options);

      PropertySheetPanel sheet = new PropertySheetPanel();
      sheet.setMode(PropertySheet.VIEW_AS_CATEGORIES);
      sheet.setProperties(beanInfo.getPropertyDescriptors());
      sheet.readFromObject(options);
      sheet.setDescriptionVisible(true);
      sheet.setSortingCategories(true);
      sheet.setSortingProperties(true);
      pnlRemoveOptions.add(sheet, BorderLayout.CENTER);

      // everytime a property change, update the button with it
      PropertyChangeListener listener =
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              Property prop = (Property) evt.getSource();
              prop.writeToObject(options);
            }
          };
      sheet.addPropertySheetChangeListener(listener);
    }

    return pnlRemoveOptions;
  }
コード例 #2
0
  public PropertySheetApplicationStats() {
    setLayout(LookAndFeelTweaks.createVerticalPercentLayout());

    final Bean data = new Bean();

    TimeSpan timespan = null;

    // counts of objects
    long discCount = HibernateDao.countAll(Disc.class);
    data.setCountArtists(Long.toString(HibernateDao.countAll(Artist.class)));
    data.setCountDiscs(Long.toString(discCount));
    data.setCountTracks(Long.toString(HibernateDao.countAll(Track.class)));

    // time stats
    long totalTime = 0;
    long totalSize = 0;
    long avgTimePerDisc = 0;
    long avgSizePerDisc = 0;
    try {
      totalTime = HibernateDao.sum(Disc.class, Disc.PROPERTYNAME_DURATION);
      totalSize = HibernateDao.sum(Track.class, Track.PROPERTYNAME_TRACK_SIZE);
      avgTimePerDisc = (totalTime / discCount) * 1000;
      avgSizePerDisc = (totalSize / discCount);
    } catch (RuntimeException ex) {
      totalTime = 0;
    }

    // calculate time fields to display properly
    timespan = new TimeSpan(totalTime * 1000);
    data.setTimeTotal(timespan.toString());
    timespan = new TimeSpan(avgTimePerDisc);
    data.setTimeAveragePerDisc(timespan.toString());

    // file stats
    data.setFileTotal(FileUtils.byteCountToDisplaySize(totalSize));
    data.setFileAveragePerDisc(FileUtils.byteCountToDisplaySize(avgSizePerDisc));

    DefaultBeanInfoResolver resolver = new DefaultBeanInfoResolver();
    BeanInfo beanInfo = resolver.getBeanInfo(data);

    PropertySheetPanel sheet = new PropertySheetPanel();
    sheet.setMode(PropertySheet.VIEW_AS_CATEGORIES);
    sheet.setProperties(beanInfo.getPropertyDescriptors());
    sheet.readFromObject(data);
    sheet.setDescriptionVisible(true);
    sheet.setSortingCategories(true);
    sheet.setSortingProperties(true);
    add(sheet, "*");

    // everytime a property change, update the button with it
    PropertyChangeListener listener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            Property prop = (Property) evt.getSource();
            prop.writeToObject(data);
          }
        };
    sheet.addPropertySheetChangeListener(listener);
  }
コード例 #3
0
  private <T> PropertySheetPanel createPropertiesPanelForClass(PropertiesProvider funcClass) {
    initEditorRegistry();
    initRenderRegistry();
    final PropertySheetPanel propertiesPanel = new PropertySheetPanel();
    propertiesPanel.setEditorFactory(pEditorRegistry);
    propertiesPanel.setRendererFactory(pRenderRegistry);
    propertiesPanel.setMode(PropertySheet.VIEW_AS_CATEGORIES);
    propertiesPanel.setSortingCategories(true);
    propertiesPanel.setDescriptionVisible(true);
    propertiesPanel.setSorting(true);
    propertiesPanel.setToolBarVisible(false);

    NeptusProperty neptusProperty = null;
    LEVEL userLevel;
    //        for (Field f : funcClass.getClass().getFields()) {
    for (Field f : funcClass.getClass().getDeclaredFields()) {
      neptusProperty = f.getAnnotation(NeptusProperty.class);
      if (neptusProperty == null) continue;

      f.setAccessible(true); // To be able to access private and protected NeptusProperties

      // CLIENT / DEVELOPER
      if (clientConsole && neptusProperty.distribution() == DistributionEnum.DEVELOPER) continue;
      // ADVANCED / REGULAR
      userLevel = neptusProperty.userLevel();
      if (permissionLvl.getLevel() < userLevel.getLevel()) continue;
      PluginProperty pp;
      try {
        pp = extractPluginProperty(f, funcClass);
      } catch (Exception e) {
        NeptusLog.pub().error(funcClass.getClass().getSimpleName() + "." + f.getName(), e);
        throw e;
      }
      if (pp != null) propertiesPanel.addProperty(pp);
    }
    return propertiesPanel;
  }