FileDocCategorySizeDatePackage
ConfigSectionTransferAutoSpeedBeta.javaAPI DocAzureus 3.0.3.416644Mon Aug 06 11:44:00 BST 2007org.gudy.azureus2.ui.swt.views.configsections

ConfigSectionTransferAutoSpeedBeta

public class ConfigSectionTransferAutoSpeedBeta extends Object implements org.gudy.azureus2.ui.swt.plugins.UISWTConfigSection
Created on May 15, 2007 Created by Alan Snyder Copyright (C) 2007 Aelitis, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

AELITIS, SAS au capital de 63.529,40 euros 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.

Fields Summary
IntParameter
downMaxLim
IntParameter
uploadMaxLim
StringListParameter
confDownload
StringListParameter
confUpload
Group
commentGroup
Group
uploadCapGroup
Group
dhtGroup
IntParameter
dGood
IntParameter
dGoodTol
IntParameter
dBad
IntParameter
dBadTol
IntParameter
adjustmentInterval
BooleanParameter
skipAfterAdjustment
Button
reset
IntListParameter
downloadModeUsedCap
IntListParameter
seedModeUsedCap
Constructors Summary
Methods Summary
public CompositeconfigSectionCreate(Composite parent)


        GridData gridData;

        Composite cSection = new Composite(parent, SWT.NULL);

        gridData = new GridData(GridData.VERTICAL_ALIGN_FILL|GridData.HORIZONTAL_ALIGN_FILL);
        cSection.setLayoutData(gridData);
        GridLayout subPanel = new GridLayout();
        subPanel.numColumns = 3;
        cSection.setLayout(subPanel);

        //add a comment to the debug log.
        ///////////////////////////////////
        // Comment group
        ///////////////////////////////////
        //comment grouping.
        commentGroup = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(commentGroup,"ConfigTransferAutoSpeed.add.comment.to.log.group");
        GridLayout commentLayout = new GridLayout();
        commentLayout.numColumns = 3;
        commentGroup.setLayout(commentLayout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        commentGroup.setLayoutData(gridData);

        //Label
        Label commentLabel = new Label(commentGroup,SWT.NULL);
        Messages.setLanguageText(commentLabel,"ConfigTransferAutoSpeed.add.comment.to.log");
        gridData = new GridData();
        gridData.widthHint = 70;
        gridData.horizontalSpan=1;
        commentLabel.setLayoutData(gridData);

        //Text-Box
        final Text commentBox = new Text(commentGroup, SWT.BORDER);
        gridData = new GridData(GridData.BEGINNING);
        gridData.widthHint = 200;
        gridData.horizontalSpan=1;
        commentBox.setText("");
        commentBox.setLayoutData(gridData);


        //button
        Button commentButton = new Button( commentGroup, SWT.PUSH);
        //Messages.
        gridData = new GridData();
        gridData.widthHint = 70;
        gridData.horizontalSpan=1;
        commentButton.setLayoutData(gridData);
        Messages.setLanguageText(commentButton,"ConfigTransferAutoSpeed.log.button");
        commentButton.addListener(SWT.Selection, new Listener(){
            public void handleEvent(Event event){
                //Add a file to the log.
                AEDiagnosticsLogger dLog = AEDiagnostics.getLogger("AutoSpeed");
                String comment = commentBox.getText();
                if(comment!=null){
                    if( comment.length()>0){
                        dLog.log( "user-comment:"+comment );
                        commentBox.setText("");
                    }
                }
            }
        });

        //spacer
        Label commentSpacer = new Label(cSection, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=3;
        commentSpacer.setLayoutData(gridData);

                

        ///////////////////////////
        // Upload Capacity used settings.
        ///////////////////////////
        uploadCapGroup = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(uploadCapGroup,"ConfigTransferAutoSpeed.upload.capacity.usage");

        GridLayout uCapLayout = new GridLayout();
        uCapLayout.numColumns = 2;
        uploadCapGroup.setLayout(uCapLayout);

        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        uploadCapGroup.setLayoutData(gridData);

        //Label column
        Label upCapModeLbl = new Label(uploadCapGroup, SWT.NULL);
        gridData = new GridData();
        gridData.widthHint = 80;
        upCapModeLbl.setLayoutData(gridData);
        Messages.setLanguageText(upCapModeLbl,"ConfigTransferAutoSpeed.mode");


        Label ucSetLbl = new Label(uploadCapGroup, SWT.NULL);
        gridData = new GridData();
        gridData.widthHint = 80;
        gridData.horizontalSpan = 2;
        Messages.setLanguageText(ucSetLbl,"ConfigTransferAutoSpeed.capacity.used");

        Label dlModeLbl = new Label(uploadCapGroup, SWT.NULL);
        gridData = new GridData();
        gridData.widthHint = 80;
        Messages.setLanguageText(dlModeLbl,"ConfigTransferAutoSpeed.while.downloading");

        //add a drop down.
        String[] downloadModeNames = {
                " 80%",
                " 70%",
                " 60%",
                " 50%"
        };

        int[] downloadModeValues = {
                80,
                70,
                60,
                50
        };

        downloadModeUsedCap = new IntListParameter(uploadCapGroup,
                SpeedLimitMonitor.USED_UPLOAD_CAPACITY_DOWNLOAD_MODE,
                downloadModeNames, downloadModeValues);


        //spacer
        Label cSpacer = new Label(cSection, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=4;
        cSpacer.setLayoutData(gridData);

        //////////////////////////
        // DHT Ping Group
        //////////////////////////

        dhtGroup = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(dhtGroup,"ConfigTransferAutoSpeed.data.update.frequency");
        dhtGroup.setLayout(subPanel);

        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        dhtGroup.setLayoutData(gridData);

//        //label column for Vivaldi limits
//        Label dhtSetting = new Label(dhtGroup, SWT.NULL);
//        gridData = new GridData();
//        gridData.widthHint=80;
//        //dhtSetting.setText("DHT Ping Settings: ");
//        Messages.setLanguageText(dhtSetting,"ConfigTransferAutoSpeed.set.dht.ping");
//
//        Label dSet = new Label(dhtGroup,SWT.NULL);
//        gridData = new GridData();
//        dSet.setLayoutData(gridData);
//        //dSet.setText("set point (ms)");
//        Messages.setLanguageText(dSet,"ConfigTransferAutoSpeed.set.point");
//
//        Label dTol = new Label(dhtGroup, SWT.NULL);
//        gridData = new GridData();
//        dTol.setLayoutData(gridData);
//        //dTol.setText("tolerance (ms)");
//        Messages.setLanguageText(dTol,"ConfigTransferAutoSpeed.set.tolerance");
//
//        //good
//        Label dGoodLbl = new Label(dhtGroup, SWT.NULL);
//        gridData = new GridData();
//        dGoodLbl.setLayoutData(gridData);
//        //dGoodLbl.setText("Good: ");
//        Messages.setLanguageText(dGoodLbl,"ConfigTransferAutoSpeed.ping.time.good");
//
//
//        gridData = new GridData();
//        gridData.widthHint = 50;
//        dGood = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_DHT_GOOD_SET_POINT);
//        dGood.setLayoutData( gridData );
//
//        gridData = new GridData();
//        gridData.widthHint = 50;
//        dGoodTol = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_DHT_GOOD_TOLERANCE);
//        dGoodTol.setLayoutData( gridData );
//
//        //bad
//        Label dBadLbl = new Label(dhtGroup, SWT.NULL);
//        gridData = new GridData();
//        dBadLbl.setLayoutData(gridData);
//        //dBadLbl.setText("Bad: ");
//        Messages.setLanguageText(dBadLbl,"ConfigTransferAutoSpeed.ping.time.bad"); 
//
//
//        gridData = new GridData();
//        gridData.widthHint = 50;
//        dBad = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_DHT_BAD_SET_POINT);
//        dBad.setLayoutData( gridData );
//
//
//        gridData = new GridData();
//        gridData.widthHint = 50;
//        dBadTol = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_DHT_BAD_TOLERANCE);
//        dBadTol.setLayoutData( gridData );
//
//        //spacer
//        cSpacer = new Label(cSection, SWT.NULL);
//        gridData = new GridData();
//        gridData.horizontalSpan=1;
//        cSpacer.setLayoutData(gridData);

        //how much data to accumulate before making an adjustment.
        Label iCount = new Label(dhtGroup, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=2;
        gridData.horizontalAlignment=GridData.BEGINNING;
        iCount.setLayoutData(gridData);
        //iCount.setText("Adjustment interval: ");
        Messages.setLanguageText(iCount,"ConfigTransferAutoSpeed.adjustment.interval");

        adjustmentInterval = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_INTERVALS_BETWEEN_ADJUST);
        gridData = new GridData();
        gridData.widthHint = 50;
        adjustmentInterval.setLayoutData(gridData);

        //spacer
        cSpacer = new Label(cSection, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=1;
        cSpacer.setLayoutData(gridData);

        //how much data to accumulate before making an adjustment.
        Label skip = new Label(dhtGroup, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=2;
        gridData.horizontalAlignment=GridData.BEGINNING;
        skip.setLayoutData(gridData);
        //skip.setText("Skip after adjustment: ");
        Messages.setLanguageText(skip,"ConfigTransferAutoSpeed.skip.after.adjust");

        skipAfterAdjustment = new BooleanParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_WAIT_AFTER_ADJUST);
        gridData = new GridData();
        gridData.widthHint = 50;
        skipAfterAdjustment.setLayoutData(gridData);

        //spacer
        cSpacer = new Label(cSection, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan=3;
        cSpacer.setLayoutData(gridData);

        return cSection;
    
public voidconfigSectionDelete()
Config view is closing


    
public java.lang.StringconfigSectionGetName()
In order for the plugin to display its section correctly, a key in the Plugin language file will need to contain ConfigView.section.<configSectionGetName() result>=The Section name.

return
The name of the configuration section

        return "transfer.select.v2";
    
public java.lang.StringconfigSectionGetParentSection()
Returns section you want your configuration panel to be under. See SECTION_* constants. To add a subsection to your own ConfigSection, return the configSectionGetName result of your parent.

        return "transfer.select";
    
public voidconfigSectionSave()
User selected Save. All saving of non-plugin tabs have been completed, as well as saving of plugins that implement org.gudy.azureus2.plugins.ui.config parameters.

        
    
voidenableGroups(java.lang.String strategyListValue)

        if(strategyListValue==null){
            return;
        }

        //only enable the comment section if the beta is enabled.
        boolean isBothEnabled = COConfigurationManager.getBooleanParameter( TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY );
        boolean isSeedingEnabled = COConfigurationManager.getBooleanParameter( TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY );
        long version = COConfigurationManager.getLongParameter( SpeedManagerImpl.CONFIG_VERSION );

        boolean isV2Enabled = false;
        if( (isBothEnabled || isSeedingEnabled) && version==2 ){
            isV2Enabled = true;
        }

        if( commentGroup!=null){
            if( isV2Enabled ){
                //make this section visible.
                commentGroup.setEnabled(true);
                commentGroup.setVisible(true);
            }else{
                //make it invisible.
                commentGroup.setEnabled(false);
                commentGroup.setVisible(false);
            }
        }