Changeset 9c3eac5


Ignore:
Timestamp:
May 21, 2009 1:25:04 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d7122cda
Parents:
79954ce (diff), f10bfda (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

propagate from branch 'i2p.i2p.zzz.test' (head 97efbce521018c26030e229181a53adce5774ab6)

to branch 'i2p.i2p' (head e9c81b8ce06374554965eacae3ae64df995b26df)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form

    r79954ce r9c3eac5  
    8282            <Property name="name" type="java.lang.String" value="cancel" noResource="true"/>
    8383          </Properties>
     84          <Events>
     85            <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cancelMouseClicked"/>
     86          </Events>
    8487        </Component>
    8588        <Component class="javax.swing.JToggleButton" name="ok">
     
    8891            <Property name="name" type="java.lang.String" value="ok" noResource="true"/>
    8992          </Properties>
     93          <Events>
     94            <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="okMouseClicked"/>
     95          </Events>
    9096        </Component>
    9197      </SubComponents>
     
    142148              </Properties>
    143149              <Events>
    144                 <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedKeyTyped"/>
     150                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedKeyReleased"/>
    145151              </Events>
    146152              <Constraints>
     
    156162              </Properties>
    157163              <Events>
    158                 <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedKeyTyped"/>
     164                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedKeyReleased"/>
    159165              </Events>
    160166              <Constraints>
     
    202208              </Constraints>
    203209            </Component>
    204             <Component class="javax.swing.JLabel" name="jLabel3">
    205               <Properties>
    206                 <Property name="text" type="java.lang.String" resourceKey="jLabel3.text"/>
    207                 <Property name="name" type="java.lang.String" value="jLabel3" noResource="true"/>
     210            <Component class="javax.swing.JLabel" name="uploadUsageLabel">
     211              <Properties>
     212                <Property name="text" type="java.lang.String" resourceKey="uploadUsageLabel.text"/>
     213                <Property name="name" type="java.lang.String" value="uploadUsageLabel" noResource="true"/>
    208214              </Properties>
    209215              <Constraints>
     
    213219              </Constraints>
    214220            </Component>
    215             <Component class="javax.swing.JLabel" name="jLabel4">
    216               <Properties>
    217                 <Property name="text" type="java.lang.String" resourceKey="jLabel4.text"/>
    218                 <Property name="name" type="java.lang.String" value="jLabel4" noResource="true"/>
     221            <Component class="javax.swing.JLabel" name="downloadUsageLabel">
     222              <Properties>
     223                <Property name="text" type="java.lang.String" resourceKey="downloadUsageLabel.text"/>
     224                <Property name="name" type="java.lang.String" value="downloadUsageLabel" noResource="true"/>
    219225              </Properties>
    220226              <Constraints>
     
    230236              </Properties>
    231237              <Events>
    232                 <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="uploadgbKeyTyped"/>
     238                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="monthKeyReleased"/>
    233239              </Events>
    234240              <Constraints>
     
    244250              </Properties>
    245251              <Events>
    246                 <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="downloadgbKeyTyped"/>
     252                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="monthKeyReleased"/>
    247253              </Events>
    248254              <Constraints>
     
    252258              </Constraints>
    253259            </Component>
    254             <Component class="javax.swing.JLabel" name="jLabel5">
    255               <Properties>
    256                 <Property name="text" type="java.lang.String" resourceKey="jLabel5.text"/>
    257                 <Property name="name" type="java.lang.String" value="jLabel5" noResource="true"/>
     260            <Component class="javax.swing.JLabel" name="gbUploadLabel">
     261              <Properties>
     262                <Property name="text" type="java.lang.String" resourceKey="gbUploadLabel.text"/>
     263                <Property name="name" type="java.lang.String" value="gbUploadLabel" noResource="true"/>
    258264              </Properties>
    259265              <Constraints>
     
    263269              </Constraints>
    264270            </Component>
    265             <Component class="javax.swing.JLabel" name="jLabel6">
    266               <Properties>
    267                 <Property name="text" type="java.lang.String" resourceKey="jLabel6.text"/>
    268                 <Property name="name" type="java.lang.String" value="jLabel6" noResource="true"/>
     271            <Component class="javax.swing.JLabel" name="gbDownloadLabel">
     272              <Properties>
     273                <Property name="text" type="java.lang.String" resourceKey="gbDownloadLabel.text"/>
     274                <Property name="name" type="java.lang.String" value="gbDownloadLabel" noResource="true"/>
    269275              </Properties>
    270276              <Constraints>
     
    274280              </Constraints>
    275281            </Component>
    276             <Component class="javax.swing.JLabel" name="jLabel7">
    277               <Properties>
    278                 <Property name="text" type="java.lang.String" resourceKey="jLabel7.text"/>
    279                 <Property name="name" type="java.lang.String" value="jLabel7" noResource="true"/>
     282            <Component class="javax.swing.JLabel" name="uploadDownloadExplanation">
     283              <Properties>
     284                <Property name="text" type="java.lang.String" resourceKey="uploadDownloadExplanation.text"/>
     285                <Property name="name" type="java.lang.String" value="uploadDownloadExplanation" noResource="true"/>
    280286              </Properties>
    281287              <Constraints>
  • apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java

    r79954ce r9c3eac5  
    88
    99import net.i2p.desktopgui.router.configuration.SpeedHelper;
     10import javax.swing.JComboBox;
     11import javax.swing.JTextField;
     12import net.i2p.desktopgui.router.configuration.SpeedHandler;
    1013
    1114/**
     
    2427   
    2528    private void extraInitComponents() {
    26         downloadspeed.setText(SpeedHelper.getInboundBandwidth());
     29        initSpeedTab();
     30    }
     31
     32    private void initSpeedTab() {
     33        try {
     34            String inbound = SpeedHelper.getInboundBandwidth();
     35            String outbound = SpeedHelper.getOutboundBandwidth();
     36
     37            initSpeeds(inbound, outbound);
     38            initUsage("" + Integer.parseInt(inbound)/8, "" + Integer.parseInt(outbound)/8);
     39        }
     40        catch(Exception e) {
     41            e.printStackTrace();
     42            System.out.println("Exception noticed, probably running desktopgui in a debugger instead of along with I2P!?");
     43            initSpeeds("100", "100");
     44            initUsage("12", "12");
     45        }
    2746    }
    2847
     
    4867        uploadkbps = new javax.swing.JComboBox();
    4968        downloadkbps = new javax.swing.JComboBox();
    50         jLabel3 = new javax.swing.JLabel();
    51         jLabel4 = new javax.swing.JLabel();
     69        uploadUsageLabel = new javax.swing.JLabel();
     70        downloadUsageLabel = new javax.swing.JLabel();
    5271        uploadgb = new javax.swing.JTextField();
    5372        downloadgb = new javax.swing.JTextField();
    54         jLabel5 = new javax.swing.JLabel();
    55         jLabel6 = new javax.swing.JLabel();
    56         jLabel7 = new javax.swing.JLabel();
     73        gbUploadLabel = new javax.swing.JLabel();
     74        gbDownloadLabel = new javax.swing.JLabel();
     75        uploadDownloadExplanation = new javax.swing.JLabel();
    5776        updatesPanel = new javax.swing.JPanel();
    5877        updateMethod = new javax.swing.JLabel();
     
    81100        cancel.setText(resourceMap.getString("cancel.text")); // NOI18N
    82101        cancel.setName("cancel"); // NOI18N
     102        cancel.addMouseListener(new java.awt.event.MouseAdapter() {
     103            public void mouseClicked(java.awt.event.MouseEvent evt) {
     104                cancelMouseClicked(evt);
     105            }
     106        });
    83107
    84108        ok.setText(resourceMap.getString("ok.text")); // NOI18N
    85109        ok.setName("ok"); // NOI18N
     110        ok.addMouseListener(new java.awt.event.MouseAdapter() {
     111            public void mouseClicked(java.awt.event.MouseEvent evt) {
     112                okMouseClicked(evt);
     113            }
     114        });
    86115
    87116        javax.swing.GroupLayout applyPanelLayout = new javax.swing.GroupLayout(applyPanel);
     
    123152        uploadspeed.setName("uploadspeed"); // NOI18N
    124153        uploadspeed.addKeyListener(new java.awt.event.KeyAdapter() {
    125             public void keyTyped(java.awt.event.KeyEvent evt) {
    126                 speedKeyTyped(evt);
     154            public void keyReleased(java.awt.event.KeyEvent evt) {
     155                speedKeyReleased(evt);
    127156            }
    128157        });
     
    133162        downloadspeed.setName("downloadspeed"); // NOI18N
    134163        downloadspeed.addKeyListener(new java.awt.event.KeyAdapter() {
    135             public void keyTyped(java.awt.event.KeyEvent evt) {
    136                 speedKeyTyped(evt);
     164            public void keyReleased(java.awt.event.KeyEvent evt) {
     165                speedKeyReleased(evt);
    137166            }
    138167        });
     
    160189        downloadkbps.setBounds(240, 60, 68, 27);
    161190
    162         jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
    163         jLabel3.setName("jLabel3"); // NOI18N
    164         speedPanel.add(jLabel3);
    165         jLabel3.setBounds(330, 20, 97, 30);
    166 
    167         jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
    168         jLabel4.setName("jLabel4"); // NOI18N
    169         speedPanel.add(jLabel4);
    170         jLabel4.setBounds(330, 60, 97, 30);
     191        uploadUsageLabel.setText(resourceMap.getString("uploadUsageLabel.text")); // NOI18N
     192        uploadUsageLabel.setName("uploadUsageLabel"); // NOI18N
     193        speedPanel.add(uploadUsageLabel);
     194        uploadUsageLabel.setBounds(330, 20, 97, 30);
     195
     196        downloadUsageLabel.setText(resourceMap.getString("downloadUsageLabel.text")); // NOI18N
     197        downloadUsageLabel.setName("downloadUsageLabel"); // NOI18N
     198        speedPanel.add(downloadUsageLabel);
     199        downloadUsageLabel.setBounds(330, 60, 97, 30);
    171200
    172201        uploadgb.setText(resourceMap.getString("uploadgb.text")); // NOI18N
    173202        uploadgb.setName("uploadgb"); // NOI18N
    174203        uploadgb.addKeyListener(new java.awt.event.KeyAdapter() {
    175             public void keyTyped(java.awt.event.KeyEvent evt) {
    176                 uploadgbKeyTyped(evt);
     204            public void keyReleased(java.awt.event.KeyEvent evt) {
     205                monthKeyReleased(evt);
    177206            }
    178207        });
     
    183212        downloadgb.setName("downloadgb"); // NOI18N
    184213        downloadgb.addKeyListener(new java.awt.event.KeyAdapter() {
    185             public void keyTyped(java.awt.event.KeyEvent evt) {
    186                 downloadgbKeyTyped(evt);
     214            public void keyReleased(java.awt.event.KeyEvent evt) {
     215                monthKeyReleased(evt);
    187216            }
    188217        });
     
    190219        downloadgb.setBounds(440, 60, 60, 27);
    191220
    192         jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
    193         jLabel5.setName("jLabel5"); // NOI18N
    194         speedPanel.add(jLabel5);
    195         jLabel5.setBounds(510, 20, 19, 30);
    196 
    197         jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
    198         jLabel6.setName("jLabel6"); // NOI18N
    199         speedPanel.add(jLabel6);
    200         jLabel6.setBounds(510, 60, 19, 30);
    201 
    202         jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
    203         jLabel7.setName("jLabel7"); // NOI18N
    204         speedPanel.add(jLabel7);
    205         jLabel7.setBounds(20, 100, 520, 70);
     221        gbUploadLabel.setText(resourceMap.getString("gbUploadLabel.text")); // NOI18N
     222        gbUploadLabel.setName("gbUploadLabel"); // NOI18N
     223        speedPanel.add(gbUploadLabel);
     224        gbUploadLabel.setBounds(510, 20, 19, 30);
     225
     226        gbDownloadLabel.setText(resourceMap.getString("gbDownloadLabel.text")); // NOI18N
     227        gbDownloadLabel.setName("gbDownloadLabel"); // NOI18N
     228        speedPanel.add(gbDownloadLabel);
     229        gbDownloadLabel.setBounds(510, 60, 19, 30);
     230
     231        uploadDownloadExplanation.setText(resourceMap.getString("uploadDownloadExplanation.text")); // NOI18N
     232        uploadDownloadExplanation.setName("uploadDownloadExplanation"); // NOI18N
     233        speedPanel.add(uploadDownloadExplanation);
     234        uploadDownloadExplanation.setBounds(20, 100, 520, 70);
    206235
    207236        settingsPanel.addTab(resourceMap.getString("speedPanel.TabConstraints.tabTitle"), speedPanel); // NOI18N
     
    378407    }// </editor-fold>//GEN-END:initComponents
    379408
    380 private void speedKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedKeyTyped
     409    private void speedKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedKeyReleased
    381410    try {
    382411        String upload = "";
     
    396425        return;
    397426    }
    398 }//GEN-LAST:event_speedKeyTyped
     427}//GEN-LAST:event_speedKeyReleased
    399428
    400429private void uploadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadkbpsActionPerformed
    401     // TODO add your handling code here:
     430    kbpsSwitchPerformed(uploadkbps, uploadspeed);
    402431}//GEN-LAST:event_uploadkbpsActionPerformed
    403432
    404433private void downloadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadkbpsActionPerformed
    405     // TODO add your handling code here:
     434    kbpsSwitchPerformed(downloadkbps, downloadspeed);
    406435}//GEN-LAST:event_downloadkbpsActionPerformed
    407436
    408 private void uploadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_uploadgbKeyTyped
    409     // TODO add your handling code here:
    410 }//GEN-LAST:event_uploadgbKeyTyped
    411 
    412 private void downloadgbKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_downloadgbKeyTyped
    413     // TODO add your handling code here:
    414 }//GEN-LAST:event_downloadgbKeyTyped
     437private void monthKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthKeyReleased
     438    try {
     439        int uploadMonthValue = Integer.parseInt(uploadgb.getText());
     440        int downloadMonthValue = Integer.parseInt(downloadgb.getText());
     441
     442        String upload = "";
     443        String burstUpload = "";
     444        String download = "";
     445        String burstDownload = "";
     446
     447        if(uploadkbps.getSelectedIndex() == KILOBIT)
     448            upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue)*8; //kbit
     449        else
     450            upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue); //kbyte
     451
     452        if(downloadkbps.getSelectedIndex() == KILOBIT)
     453            download = "" + SpeedHelper.calculateSpeed(downloadMonthValue)*8; //kbit
     454        else
     455            download = "" + SpeedHelper.calculateSpeed(downloadMonthValue); //kbyte
     456
     457        initSpeeds(upload, download);
     458    }
     459    catch(NumberFormatException e) {
     460        e.printStackTrace();
     461        return;
     462    }
     463}//GEN-LAST:event_monthKeyReleased
     464
     465private void cancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cancelMouseClicked
     466    this.dispose();
     467}//GEN-LAST:event_cancelMouseClicked
     468
     469private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okMouseClicked
     470    saveSpeeds();
     471    this.dispose();
     472}//GEN-LAST:event_okMouseClicked
    415473
    416474    protected void initUsage(String upload, String download) {
    417475        uploadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(upload)));
    418476        downloadgb.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(download)));
     477    }
     478
     479    protected void initSpeeds(String upload, String download) {
     480        uploadspeed.setText(upload);
     481        downloadspeed.setText(download);
     482    }
     483
     484    private void kbpsSwitchPerformed(JComboBox kbps, JTextField speed) {
     485        int index = kbps.getSelectedIndex();
     486        int previous = Integer.parseInt(speed.getText());
     487        if(index == KILOBIT) {
     488            speed.setText("" + previous*8);
     489        }
     490        else {
     491            speed.setText("" + previous/8);
     492        }
     493    }
     494
     495    protected void saveSpeeds() {
     496        int maxDownload = Integer.parseInt(downloadspeed.getText());
     497        int maxUpload = Integer.parseInt(uploadspeed.getText());
     498        if(uploadkbps.getSelectedIndex() == KILOBIT) {
     499            SpeedHandler.setOutboundBandwidth(maxUpload/8);
     500            SpeedHandler.setOutboundBurstBandwidth(maxUpload/8);
     501        }
     502        else {
     503            SpeedHandler.setOutboundBandwidth(maxUpload);
     504            SpeedHandler.setOutboundBurstBandwidth(maxUpload);
     505        }
     506        if(downloadkbps.getSelectedIndex() == KILOBIT) {
     507            SpeedHandler.setInboundBandwidth(maxDownload/8);
     508            SpeedHandler.setInboundBurstBandwidth(maxDownload/8);
     509        }
     510        else {
     511            SpeedHandler.setInboundBandwidth(maxDownload);
     512            SpeedHandler.setInboundBurstBandwidth(maxDownload);
     513        }
    419514    }
    420515
     
    429524    private javax.swing.JLabel clientTunnelLabel;
    430525    private javax.swing.JLabel downloadSpeedLabel;
     526    private javax.swing.JLabel downloadUsageLabel;
    431527    private javax.swing.JTextField downloadgb;
    432528    private javax.swing.JComboBox downloadkbps;
    433529    private javax.swing.JTextField downloadspeed;
    434     private javax.swing.JLabel jLabel3;
    435     private javax.swing.JLabel jLabel4;
    436     private javax.swing.JLabel jLabel5;
    437     private javax.swing.JLabel jLabel6;
    438     private javax.swing.JLabel jLabel7;
     530    private javax.swing.JLabel gbDownloadLabel;
     531    private javax.swing.JLabel gbUploadLabel;
    439532    private javax.swing.JPanel networkPanel;
    440533    private javax.swing.JToggleButton ok;
     
    451544    private javax.swing.JToggleButton updateNow;
    452545    private javax.swing.JPanel updatesPanel;
     546    private javax.swing.JLabel uploadDownloadExplanation;
    453547    private javax.swing.JLabel uploadSpeedLabel;
     548    private javax.swing.JLabel uploadUsageLabel;
    454549    private javax.swing.JTextField uploadgb;
    455550    private javax.swing.JComboBox uploadkbps;
  • apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java

    r79954ce r9c3eac5  
    171171       
    172172        config.add(speedConfig);
    173         //config.add(generalConfig);
     173        config.add(generalConfig);
    174174        config.add(advancedConfig);
    175175        popup.add(config);
  • apps/desktopgui/src/net/i2p/desktopgui/gui/resources/GeneralConfiguration.properties

    r79954ce r9c3eac5  
    11cancel.text=Cancel
    22ok.text=OK
    3 jLabel3.text=Monthly usage:
    4 jLabel4.text=Monthly usage:
    5 jLabel5.text=GB
    6 jLabel6.text=GB
    7 jLabel7.text=Explanation ...
    83Form.title=General Configuration
    94speedPanel.TabConstraints.tabTitle=Speed
     
    2823serverTunnelLabel.text=Server tunnels:
    2924tunnelsExplanation.text=Tunnel explanation
     25uploadUsageLabel.text=Monthly usage:
     26downloadUsageLabel.text=Monthly usage:
     27gbUploadLabel.text=GB
     28gbDownloadLabel.text=GB
     29uploadDownloadExplanation.text=Explanation ...
  • apps/desktopgui/src/net/i2p/desktopgui/router/configuration/SpeedHelper.java

    r79954ce r9c3eac5  
    3737        return RouterHelper.getContext().router().getConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH);
    3838    }
     39
     40    public static String getOutboundBandwidth() {
     41        return RouterHelper.getContext().router().getConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH);
     42    }
    3943}
  • history.txt

    r79954ce r9c3eac5  
     12009-05-20 Mathiasdm
     2    * General configuration enabled by default
     3    * General configuration speed tab works completely
     4
    152009-05-17 zzz
    26    * Merge i2p.i2p.zzz.upnp branch
Note: See TracChangeset for help on using the changeset viewer.