Package org.gudy.azureus2.core3.config.impl

Examples of org.gudy.azureus2.core3.config.impl.ConfigurationManager


 
  private ArrayList listeners = new ArrayList();

  public void initialize() {
    // Shorten from COConfigurationManager To make code more readable
    final ConfigurationManager config = ConfigurationManager.getInstance();
    boolean overrideLog = System.getProperty("azureus.overridelog") != null;

    for (int i = 0; i < ignoredComponents.length; i++) {
      ignoredComponents[i] = new ArrayList();
    }

    if (!overrideLog) {
      config.addListener(new COConfigurationListener() {
        public void configurationSaved() {
          checkLoggingConfig();
        }
      });
    }

    checkLoggingConfig();
    config.addParameterListener(CFG_ENABLELOGTOFILE, new ParameterListener() {
      public void parameterChanged(String parameterName) {
        FileLogging.this.reloadLogToFileParam();
      }
    });
  }
View Full Code Here


  /**
   *
   */
  protected void reloadLogToFileParam() {
    final ConfigurationManager config = ConfigurationManager.getInstance();
    boolean bNewLogToFile = System.getProperty("azureus.overridelog") != null || config.getBooleanParameter(CFG_ENABLELOGTOFILE);
    if (bNewLogToFile != bLogToFile) {
      bLogToFile = bNewLogToFile;
      if (bLogToFile)
        Logger.addListener(this);
      else{
View Full Code Here

  }

  private void checkLoggingConfig() {
    try {
      // Shorten from COConfigurationManager To make code more readable
      final ConfigurationManager config = ConfigurationManager.getInstance();
     
      String timeStampFormat;

      boolean overrideLog = System.getProperty("azureus.overridelog") != null;
      if (overrideLog) {
       
        // Don't set this - reloadLogToFileParam will do it.
        //bLogToFile = true;
        sLogDir = System.getProperty("azureus.overridelogdir", ".");
        iLogFileMaxMB = 2;
        timeStampFormat = "HH:mm:ss.SSS ";

        for (int i = 0; i < ignoredComponents.length; i++) {
          ignoredComponents[i].clear();
        }
       
        reloadLogToFileParam();
      } else {
        reloadLogToFileParam();

        sLogDir = config.getStringParameter("Logging Dir", "");

        iLogFileMaxMB = config.getIntParameter("Logging Max Size");
       
        timeStampFormat = config.getStringParameter("Logging Timestamp")+" ";

        for (int i = 0; i < ignoredComponents.length; i++) {
          ignoredComponents[i].clear();
          int logType = indexToLogType(i);
          for (int j = 0; j < configurableLOGIDs.length; j++) {
            if (!config.getBooleanParameter("bLog." + logType + "."
                + configurableLOGIDs[j], true))
              ignoredComponents[i].add(configurableLOGIDs[j]);
          }
        }
      }
View Full Code Here

    // temporarily set to true, to log any errors between now and setting
    // bEnabled properly.
    bEventLoggingEnabled = true;
   
    // Shorten from COConfigurationManager To make code more readable
    final ConfigurationManager config = ConfigurationManager.getInstance();

    boolean overrideLog = System.getProperty("azureus.overridelog") != null;
    if (overrideLog) {
      bEventLoggingEnabled = true;
    } else {
      bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");

      config.addParameterListener("Logger.Enabled", new ParameterListener() {
        public void parameterChanged(String parameterName) {
          bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");
        }
      });
    }
  }
View Full Code Here

   * @return The composite containing the legend
   */
  public static Composite createLegendComposite(final Composite panel,
      final Color[] blockColors, final String[] keys, Object layoutData) {
   
    final ConfigurationManager config = ConfigurationManager.getInstance();

    if (blockColors.length != keys.length)
      return null;

    final Color[] defaultColors = new Color[blockColors.length];
    final ParameterListener[] paramListeners = new ParameterListener[keys.length];
    System.arraycopy(blockColors, 0, defaultColors, 0, blockColors.length);

    Composite legend = new Composite(panel, SWT.NONE);
    if (layoutData != null)
      legend.setLayoutData(layoutData);

    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.spacing = 0;
    legend.setLayout(layout);

    RowData data;
    for (int i = 0; i < blockColors.length; i++) {
      int r = config.getIntParameter(keys[i] + ".red", -1);
      if (r >= 0) {
        int g = config.getIntParameter(keys[i] + ".green");
        int b = config.getIntParameter(keys[i] + ".blue");
       
        Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
        blockColors[i] = color;
      }

      Composite colorSet = new Composite(legend, SWT.NONE);

      colorSet.setLayout(new RowLayout(SWT.HORIZONTAL));

      final Canvas cColor = new Canvas(colorSet, SWT.BORDER);
      cColor.setData("Index", new Integer(i));
      // XXX Use paint instead of setBackgrond, because OSX does translucent
      // crap
      cColor.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
          int i = ((Integer)cColor.getData("Index")).intValue();
          e.gc.setBackground(blockColors[i]);
          e.gc.fillRectangle(e.x, e.y, e.width, e.height);
        }
      });

      cColor.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
          Integer iIndex = (Integer)cColor.getData("Index");
          if (iIndex == null)
            return;
          int index = iIndex.intValue();

          if (e.button == 1) {
            ColorDialog cd = new ColorDialog(panel.getShell());
            cd.setRGB(blockColors[index].getRGB());
           
            RGB rgb = cd.open();
            if (rgb != null)
              config.setRGBParameter(keys[index], rgb.red, rgb.green, rgb.blue);
          } else {
            config.removeRGBParameter(keys[index]);
          }
        }
      });

      Label lblDesc = new Label(colorSet, SWT.NULL);
      Messages.setLanguageText(lblDesc, keys[i]);

      data = new RowData();
      data.width = 20;
      data.height = lblDesc.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 3;
      cColor.setLayoutData(data);
     
      // If color changes, update our legend
      config.addParameterListener(keys[i],paramListeners[i] = new ParameterListener() {
        public void parameterChanged(String parameterName) {
          for (int j = 0; j < keys.length; j++) {
            if (keys[j].equals(parameterName)) {
              final int index = j;

              final int r = config.getIntParameter(keys[j] + ".red", -1);
              if (r >= 0) {
                final int g = config.getIntParameter(keys[j] + ".green");
                final int b = config.getIntParameter(keys[j] + ".blue");
               
                final RGB rgb = new RGB(r, g, b);
                if (blockColors[j].isDisposed()
                    || !rgb.equals(blockColors[j].getRGB())) {

                  Utils.execSWTThread(new AERunnable() {
                    public void runSupport() {
                      if (panel == null || panel.isDisposed())
                        return;
                      Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
                      blockColors[index] = color;
                      cColor.redraw();
                    }
                  });
                }
              } else {
                if (blockColors[j].isDisposed()
                    || !blockColors[j].equals(defaultColors[j])) {
                  Utils.execSWTThread(new AERunnable() {
                    public void runSupport() {
                      if (panel == null || panel.isDisposed())
                        return;
                      blockColors[index] = defaultColors[index];
                      cColor.redraw();
                    }
                  });
                }
              }
            }
          }
        }
      });
    }
   
    legend.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
        // We don't want to give them disposed colors
        // Restore defaults in case blockColors is a static or is used
        // afterwards, or if the view wants to dispose of the old colors.
        for (int i = 0; i < blockColors.length; i++)
          blockColors[i] = defaultColors[i];
        for (int i = 0; i < keys.length;i++)
          config.removeParameterListener(keys[i], paramListeners[i]);
      }
    });

    return legend;
  }
View Full Code Here

              String configAutoKey = TransferSpeedValidator.getActiveAutoUploadParameter(globalManager);

              COConfigurationManager.setParameter(configAutoKey, false);
            }

            final int cValue = ((Integer) new TransferSpeedValidator(configKey,
                new Integer(newSpeed)).getValue()).intValue();

            COConfigurationManager.setParameter(configKey, cValue);

            COConfigurationManager.save();
View Full Code Here

                              TransferSpeedValidator.getActiveAutoUploadParameter(globalManager);
              
                            COConfigurationManager.setParameter( configAutoKey, false );
                          }
                         
                          final int cValue = ((Integer)new TransferSpeedValidator(configKey, (Number)items[i].getData("maxkb")).getValue()).intValue();
                          COConfigurationManager.setParameter(configKey, cValue);
                         

                          COConfigurationManager.save();
                      }
View Full Code Here

    List<SelectedContent> listSelected = new ArrayList<SelectedContent>(dataSources.length);
    for (Object ds : dataSources) {
      if (ds instanceof DownloadManager) {
        listSelected.add(new SelectedContent((DownloadManager) ds));
      } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        listSelected.add(new SelectedContent(fileInfo.getDownloadManager(), fileInfo.getIndex()));
      }
    }
    SelectedContent[] content = listSelected.toArray(new SelectedContent[0]);
    SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), content, tv);
  }
View Full Code Here

    if (dms.length == 0 && dataSources.length > 0) {
      List<DiskManagerFileInfo> listFileInfos = new ArrayList<DiskManagerFileInfo>();
      DownloadManager firstFileDM = null;
      for (Object ds : dataSources) {
        if (ds instanceof DiskManagerFileInfo) {
          DiskManagerFileInfo info = (DiskManagerFileInfo) ds;
          // for now, FilesViewMenuUtil.fillmenu can only handle one DM
          if (firstFileDM != null && !firstFileDM.equals(info.getDownloadManager())) {
            break;
          }
          firstFileDM = info.getDownloadManager();
          listFileInfos.add(info);
        }
      }
      if (listFileInfos.size() > 0) {
        FilesViewMenuUtil.fillMenu(tv, menu, firstFileDM,
View Full Code Here

                    sb.append('\n');
                  } catch (TOTorrentException e) {
                  }
                }
              } else if (ds instanceof DiskManagerFileInfo) {
                DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
                DownloadManager dm = fileInfo.getDownloadManager();
                TOTorrent torrent = dm.getTorrent();
                if (torrent != null) {
                  try {
                    sb.append(torrent.getHashWrapper().toBase32String());
                    sb.append(';');
                    sb.append(fileInfo.getIndex());
                    sb.append('\n');
                    onlyDMs = false;
                  } catch (TOTorrentException e) {
                  }
                }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.config.impl.ConfigurationManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.