From 977d6eec88b6197aeeddeb57aa0ab098623b250f Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Thu, 9 Apr 2009 20:36:22 +0000 Subject: [PATCH] Dropdown available for kb versus kB issues. Bandwidth calculation available from 2 directions (added from GB -> kbps). Layout manager switched for easier development. --- apps/desktopgui/build.xml | 150 +++++--- apps/desktopgui/nbproject/project.properties | 2 + .../resources/Main_nl_BE.properties | 11 + apps/desktopgui/src/gui/SpeedSelector.form | 143 ++++---- apps/desktopgui/src/gui/SpeedSelector.java | 135 ++++---- apps/desktopgui/src/gui/SpeedSelector2.form | 88 ++--- apps/desktopgui/src/gui/SpeedSelector2.java | 70 ++-- apps/desktopgui/src/gui/SpeedSelector3.form | 290 +++++++++++----- apps/desktopgui/src/gui/SpeedSelector3.java | 325 +++++++++++++----- .../gui/resources/SpeedSelector.properties | 7 +- .../gui/resources/SpeedSelector2.properties | 5 +- .../gui/resources/SpeedSelector3.properties | 11 +- .../src/router/configuration/SpeedHelper.java | 4 + build.xml | 4 +- 14 files changed, 809 insertions(+), 436 deletions(-) create mode 100644 apps/desktopgui/src/desktopgui/resources/Main_nl_BE.properties diff --git a/apps/desktopgui/build.xml b/apps/desktopgui/build.xml index cf262b2ec..77bd6d778 100644 --- a/apps/desktopgui/build.xml +++ b/apps/desktopgui/build.xml @@ -1,51 +1,115 @@ - - - A desktopgui for I2P - - - - - - - - - - - - + + + + + + + + + + + Builds, tests, and runs the project desktopgui. + + - - - - + There exist several targets which are by default empty and which can be + used for execution of your tasks. These targets are usually executed + before and after some main targets. They are: - + + + + + + For list of available properties check the imported + nbproject/build-impl.xml file. + + + Another way to customize the build is by overriding existing main targets. + The targets of interest are: + + -init-macrodef-javac: defines macro for javac compilation + -init-macrodef-junit: defines macro for junit execution + -init-macrodef-debug: defines macro for class debugging + -init-macrodef-java: defines macro for class execution + -do-jar-with-manifest: JAR building (if you are using a manifest) + -do-jar-without-manifest: JAR building (if you are not using a manifest) + run: execution of project + -javadoc-build: Javadoc generation + test-report: JUnit report generation + + An example of overriding the target for project execution could look like this: + + + + + + + + Notice that the overridden target depends on the jar target and not only on + the compile target as the regular run target does. Again, for a list of available + properties which you can use, check the target you are overriding in the + nbproject/build-impl.xml file. + + --> + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + - - + + - - - + + + - - - - - + + + + diff --git a/apps/desktopgui/nbproject/project.properties b/apps/desktopgui/nbproject/project.properties index b5bf07f64..b7a05f8ed 100644 --- a/apps/desktopgui/nbproject/project.properties +++ b/apps/desktopgui/nbproject/project.properties @@ -44,6 +44,7 @@ javac.test.classpath=\ javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} +javadoc.encoding.used=${javadoc.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false @@ -53,6 +54,7 @@ javadoc.use=true javadoc.version=false javadoc.windowtitle= jnlp.codebase.type=local +jnlp.codebase.url=file:/home/mathias/Documenten/Programmeren/i2p_monotone/repo/i2p.i2p/apps/desktopgui/dist/ jnlp.enabled=false jnlp.offline-allowed=false jnlp.signed=false diff --git a/apps/desktopgui/src/desktopgui/resources/Main_nl_BE.properties b/apps/desktopgui/src/desktopgui/resources/Main_nl_BE.properties new file mode 100644 index 000000000..81107aca9 --- /dev/null +++ b/apps/desktopgui/src/desktopgui/resources/Main_nl_BE.properties @@ -0,0 +1,11 @@ +# Application global resources + +Application.name = desktopgui +Application.title = I2P Desktop GUI +Application.version = 0.7.1 +Application.vendor = I2P Ontwikkelaars +Application.homepage = http://www.i2p2.de +Application.description = Een anoniem communicatienetwerk. +Application.vendorId = I2P +Application.id = desktopgui +Application.lookAndFeel = system diff --git a/apps/desktopgui/src/gui/SpeedSelector.form b/apps/desktopgui/src/gui/SpeedSelector.form index b256265de..6ccf414b5 100644 --- a/apps/desktopgui/src/gui/SpeedSelector.form +++ b/apps/desktopgui/src/gui/SpeedSelector.form @@ -4,7 +4,11 @@ + + + + @@ -20,85 +24,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -121,6 +91,11 @@ + + + + + @@ -143,18 +118,60 @@ + + + + + - + - - + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/desktopgui/src/gui/SpeedSelector.java b/apps/desktopgui/src/gui/SpeedSelector.java index 19f487534..bce18621f 100644 --- a/apps/desktopgui/src/gui/SpeedSelector.java +++ b/apps/desktopgui/src/gui/SpeedSelector.java @@ -9,6 +9,7 @@ package gui; import java.awt.Dimension; import java.awt.Point; import java.util.Properties; +import javax.swing.JComboBox; import javax.swing.JTextField; import persistence.PropertyManager; import util.IntegerVerifier; @@ -26,12 +27,13 @@ public class SpeedSelector extends javax.swing.JFrame { initComponentsCustom(); initSpeeds(props); this.setVisible(true); + this.setLocationRelativeTo(null); + this.requestFocus(); } - public SpeedSelector(Point point, Dimension dimension) { + public SpeedSelector(Point point) { this(); this.setLocation(point); - this.setSize(dimension); } public void initComponentsCustom() { @@ -53,101 +55,115 @@ public class SpeedSelector extends javax.swing.JFrame { downloadLabel = new javax.swing.JLabel(); uploadChoice = new javax.swing.JComboBox(); downloadChoice = new javax.swing.JComboBox(); - kbps1 = new javax.swing.JLabel(); - kbps2 = new javax.swing.JLabel(); + speedExplanation = new javax.swing.JLabel(); + uploadkbps = new javax.swing.JComboBox(); + downloadkbps = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopgui.Main.class).getContext().getResourceMap(SpeedSelector.class); setTitle(resourceMap.getString("Form.title")); // NOI18N + setMinimumSize(new java.awt.Dimension(610, 330)); setName("Form"); // NOI18N + setResizable(false); + getContentPane().setLayout(null); nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N + nextButton.setMaximumSize(new java.awt.Dimension(72, 29)); + nextButton.setMinimumSize(new java.awt.Dimension(72, 29)); nextButton.setName("nextButton"); // NOI18N nextButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { nextButtonMouseClicked(evt); } }); + getContentPane().add(nextButton); + nextButton.setBounds(440, 250, 90, 29); uploadLabel.setText(resourceMap.getString("uploadLabel.text")); // NOI18N uploadLabel.setName("uploadLabel"); // NOI18N + getContentPane().add(uploadLabel); + uploadLabel.setBounds(20, 60, 246, 30); downloadLabel.setText(resourceMap.getString("downloadLabel.text")); // NOI18N downloadLabel.setName("downloadLabel"); // NOI18N + getContentPane().add(downloadLabel); + downloadLabel.setBounds(20, 110, 263, 30); uploadChoice.setEditable(true); uploadChoice.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "100", "200", "500", "1000", "2000", "4000", "8000", "10000", "20000", "50000", "100000" })); uploadChoice.setSelectedIndex(3); uploadChoice.setName("uploadChoice"); // NOI18N + getContentPane().add(uploadChoice); + uploadChoice.setBounds(300, 60, 154, 27); downloadChoice.setEditable(true); downloadChoice.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "100", "200", "500", "1000", "2000", "4000", "8000", "10000", "20000", "50000", "100000" })); downloadChoice.setSelectedIndex(3); downloadChoice.setName("downloadChoice"); // NOI18N + getContentPane().add(downloadChoice); + downloadChoice.setBounds(300, 110, 154, 27); - kbps1.setText(resourceMap.getString("kbps1.text")); // NOI18N - kbps1.setName("kbps1"); // NOI18N + speedExplanation.setText(resourceMap.getString("speedExplanation.text")); // NOI18N + speedExplanation.setName("speedExplanation"); // NOI18N + getContentPane().add(speedExplanation); + speedExplanation.setBounds(20, 160, 570, 60); - kbps2.setText(resourceMap.getString("kbps2.text")); // NOI18N - kbps2.setName("kbps2"); // NOI18N + uploadkbps.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + uploadkbps.setName("uploadKbit"); // NOI18N + uploadkbps.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + uploadkbpsActionPerformed(evt); + } + }); + getContentPane().add(uploadkbps); + uploadkbps.setBounds(470, 60, 68, 27); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(49, 49, 49) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(downloadLabel) - .addComponent(uploadLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(downloadChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(kbps2)) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addComponent(uploadChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(kbps1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(nextButton) - .addGap(34, 34, 34)))) - .addGap(40, 40, 40)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(67, 67, 67) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(uploadLabel) - .addComponent(uploadChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(kbps1)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(downloadLabel) - .addComponent(downloadChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(kbps2)) - .addContainerGap(173, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(271, Short.MAX_VALUE) - .addComponent(nextButton) - .addContainerGap()) - ); + downloadkbps.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + downloadkbps.setName("downloadKbit"); // NOI18N + downloadkbps.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + downloadkbpsActionPerformed(evt); + } + }); + getContentPane().add(downloadkbps); + downloadkbps.setBounds(470, 110, 68, 27); pack(); }// //GEN-END:initComponents private void nextButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nextButtonMouseClicked - props.setProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE, uploadChoice.getSelectedItem().toString()); - props.setProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE, downloadChoice.getSelectedItem().toString()); + if(uploadkbps.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE, uploadChoice.getSelectedItem().toString()); + else + props.setProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE, "" + Integer.parseInt(uploadChoice.getSelectedItem().toString())*8); + if(downloadkbps.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE, downloadChoice.getSelectedItem().toString()); + else + props.setProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE, "" + Integer.parseInt(downloadChoice.getSelectedItem().toString())*8); PropertyManager.saveProps(props); - new SpeedSelector2(this.getLocationOnScreen(), this.getSize()); + new SpeedSelector2(this.getLocationOnScreen()); this.dispose(); }//GEN-LAST:event_nextButtonMouseClicked +private void uploadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadkbpsActionPerformed + kbpsSwitchPerformed(uploadkbps, uploadChoice); +}//GEN-LAST:event_uploadkbpsActionPerformed + +private void downloadkbpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadkbpsActionPerformed + kbpsSwitchPerformed(downloadkbps, downloadChoice); +}//GEN-LAST:event_downloadkbpsActionPerformed + +private void kbpsSwitchPerformed(JComboBox kbps, JComboBox speed) { + int index = kbps.getSelectedIndex(); + int previous = Integer.parseInt(speed.getSelectedItem().toString()); + if(index == KILOBIT) { + speed.setSelectedItem("" + previous*8); + } + else { + speed.setSelectedItem("" + previous/8); + } +} + private void initSpeeds(Properties props) { String up = props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE); String down = props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE); @@ -165,12 +181,15 @@ private void initSpeeds(Properties props) { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox downloadChoice; private javax.swing.JLabel downloadLabel; - private javax.swing.JLabel kbps1; - private javax.swing.JLabel kbps2; + private javax.swing.JComboBox downloadkbps; private javax.swing.JButton nextButton; + private javax.swing.JLabel speedExplanation; private javax.swing.JComboBox uploadChoice; private javax.swing.JLabel uploadLabel; + private javax.swing.JComboBox uploadkbps; // End of variables declaration//GEN-END:variables Properties props; + private static final int KILOBIT = 0; + private static final int KILOBYTE = 1; } diff --git a/apps/desktopgui/src/gui/SpeedSelector2.form b/apps/desktopgui/src/gui/SpeedSelector2.form index 2f0abc786..215d407f0 100644 --- a/apps/desktopgui/src/gui/SpeedSelector2.form +++ b/apps/desktopgui/src/gui/SpeedSelector2.form @@ -8,7 +8,11 @@ + + + + @@ -24,50 +28,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -78,6 +40,11 @@ + + + + + @@ -87,12 +54,22 @@ + + + + + + + + + + @@ -100,8 +77,14 @@ + + + + + + @@ -109,8 +92,25 @@ + + + + + + + + + + + + + + + + + diff --git a/apps/desktopgui/src/gui/SpeedSelector2.java b/apps/desktopgui/src/gui/SpeedSelector2.java index a02ef9b53..d929e4ccd 100644 --- a/apps/desktopgui/src/gui/SpeedSelector2.java +++ b/apps/desktopgui/src/gui/SpeedSelector2.java @@ -21,13 +21,13 @@ public class SpeedSelector2 extends javax.swing.JFrame { Properties props; /** Creates new form ProfileSelector2 */ - public SpeedSelector2(Point point, Dimension dimension) { + public SpeedSelector2(Point point) { this.props = PropertyManager.getProps(); initComponents(); this.setLocation(point); - this.setSize(dimension); loadButtonSelection(); this.setVisible(true); + this.requestFocus(); } /** This method is called from within the constructor to @@ -45,11 +45,15 @@ public class SpeedSelector2 extends javax.swing.JFrame { questionLabel = new javax.swing.JLabel(); browseButton = new javax.swing.JRadioButton(); downloadButton = new javax.swing.JRadioButton(); + jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopgui.Main.class).getContext().getResourceMap(SpeedSelector2.class); setTitle(resourceMap.getString("Form.title")); // NOI18N + setMinimumSize(new java.awt.Dimension(610, 330)); setName("Form"); // NOI18N + setResizable(false); + getContentPane().setLayout(null); nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N nextButton.setName("nextButton"); // NOI18N @@ -58,6 +62,8 @@ public class SpeedSelector2 extends javax.swing.JFrame { nextButtonMouseClicked(evt); } }); + getContentPane().add(nextButton); + nextButton.setBounds(440, 250, 90, 29); returnButton.setText(resourceMap.getString("returnButton.text")); // NOI18N returnButton.setName("returnButton"); // NOI18N @@ -66,54 +72,32 @@ public class SpeedSelector2 extends javax.swing.JFrame { returnButtonMouseClicked(evt); } }); + getContentPane().add(returnButton); + returnButton.setBounds(336, 250, 90, 29); questionLabel.setText(resourceMap.getString("questionLabel.text")); // NOI18N questionLabel.setName("questionLabel"); // NOI18N + getContentPane().add(questionLabel); + questionLabel.setBounds(30, 40, 265, 17); buttonGroup1.add(browseButton); browseButton.setText(resourceMap.getString("browseButton.text")); // NOI18N + browseButton.setActionCommand(resourceMap.getString("browseButton.actionCommand")); // NOI18N browseButton.setName("browseButton"); // NOI18N + getContentPane().add(browseButton); + browseButton.setBounds(40, 130, 520, 40); buttonGroup1.add(downloadButton); downloadButton.setText(resourceMap.getString("downloadButton.text")); // NOI18N + downloadButton.setActionCommand(resourceMap.getString("downloadButton.actionCommand")); // NOI18N downloadButton.setName("downloadButton"); // NOI18N + getContentPane().add(downloadButton); + downloadButton.setBounds(40, 80, 499, 40); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(406, Short.MAX_VALUE) - .addComponent(returnButton) - .addGap(18, 18, 18) - .addComponent(nextButton) - .addGap(74, 74, 74)) - .addGroup(layout.createSequentialGroup() - .addGap(42, 42, 42) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(questionLabel) - .addGroup(layout.createSequentialGroup() - .addGap(12, 12, 12) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(downloadButton) - .addComponent(browseButton)))) - .addContainerGap(32, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(54, 54, 54) - .addComponent(questionLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(browseButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(downloadButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 120, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(nextButton) - .addComponent(returnButton)) - .addContainerGap()) - ); + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + getContentPane().add(jLabel1); + jLabel1.setBounds(30, 190, 530, 50); pack(); }// //GEN-END:initComponents @@ -121,18 +105,19 @@ public class SpeedSelector2 extends javax.swing.JFrame { private void returnButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_returnButtonMouseClicked saveButtonSelection(); PropertyManager.saveProps(props); - new SpeedSelector(this.getLocationOnScreen(), this.getSize()).setVisible(true); + new SpeedSelector(this.getLocationOnScreen()); this.dispose(); }//GEN-LAST:event_returnButtonMouseClicked private void nextButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nextButtonMouseClicked saveButtonSelection(); PropertyManager.saveProps(props); - new SpeedSelector3(this.getLocationOnScreen(), this.getSize()).setVisible(true); + new SpeedSelector3(this.getLocationOnScreen(), this.getSize()); this.dispose(); }//GEN-LAST:event_nextButtonMouseClicked private void loadButtonSelection() { + Enumeration elements = buttonGroup1.getElements(); while(elements.hasMoreElements()) { AbstractButton button = elements.nextElement(); @@ -140,7 +125,7 @@ private void loadButtonSelection() { continue; if(props.getProperty(SpeedSelectorConstants.USERTYPE) == null) break; - String type = button.getText().split(":")[0]; + String type = button.getActionCommand(); if(type.equals(props.getProperty(SpeedSelectorConstants.USERTYPE))) { button.setSelected(true); break; @@ -155,7 +140,7 @@ private void saveButtonSelection() { if(button == null) continue; if(button.isSelected()) { - String type = button.getText().split(":")[0]; + String type = button.getActionCommand(); props.setProperty(SpeedSelectorConstants.USERTYPE, type); break; } @@ -166,6 +151,7 @@ private void saveButtonSelection() { private javax.swing.JRadioButton browseButton; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JRadioButton downloadButton; + private javax.swing.JLabel jLabel1; private javax.swing.JButton nextButton; private javax.swing.JLabel questionLabel; private javax.swing.JButton returnButton; diff --git a/apps/desktopgui/src/gui/SpeedSelector3.form b/apps/desktopgui/src/gui/SpeedSelector3.form index 419a22fc1..ec2697221 100644 --- a/apps/desktopgui/src/gui/SpeedSelector3.form +++ b/apps/desktopgui/src/gui/SpeedSelector3.form @@ -4,7 +4,11 @@ + + + + @@ -18,91 +22,11 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -113,6 +37,11 @@ + + + + + @@ -122,48 +51,88 @@ + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -176,6 +145,11 @@ + + + + + @@ -185,6 +159,11 @@ + + + + + @@ -197,6 +176,11 @@ + + + + + @@ -206,18 +190,148 @@ + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/desktopgui/src/gui/SpeedSelector3.java b/apps/desktopgui/src/gui/SpeedSelector3.java index e226f7422..8115acb2b 100644 --- a/apps/desktopgui/src/gui/SpeedSelector3.java +++ b/apps/desktopgui/src/gui/SpeedSelector3.java @@ -9,6 +9,8 @@ package gui; import java.awt.Dimension; import java.awt.Point; import java.util.Properties; +import javax.swing.JComboBox; +import javax.swing.JTextField; import persistence.PropertyManager; import router.configuration.SpeedHandler; import router.configuration.SpeedHelper; @@ -27,7 +29,9 @@ public class SpeedSelector3 extends javax.swing.JFrame { this.setLocation(point); this.setSize(dimension); initSpeeds(); + initUsage(); this.setVisible(true); + this.requestFocus(); } /** This method is called from within the constructor to @@ -41,7 +45,7 @@ public class SpeedSelector3 extends javax.swing.JFrame { finishButton = new javax.swing.JButton(); previousButton = new javax.swing.JButton(); - jLabel1 = new javax.swing.JLabel(); + settingsInfo = new javax.swing.JLabel(); uploadLabel = new javax.swing.JLabel(); downloadLabel = new javax.swing.JLabel(); uploadBurstLabel = new javax.swing.JLabel(); @@ -52,13 +56,23 @@ public class SpeedSelector3 extends javax.swing.JFrame { uploadBurstField = new javax.swing.JTextField(); downloadField = new javax.swing.JTextField(); downloadBurstField = new javax.swing.JTextField(); - uploadMonth = new javax.swing.JLabel(); - downloadMonth = new javax.swing.JLabel(); + kbpsBurstDownload = new javax.swing.JComboBox(); + kbpsUpload = new javax.swing.JComboBox(); + kbpsBurstUpload = new javax.swing.JComboBox(); + kbpsDownload = new javax.swing.JComboBox(); + uploadGB = new javax.swing.JLabel(); + uploadMonth = new javax.swing.JTextField(); + downloadMonth = new javax.swing.JTextField(); + downloadGB = new javax.swing.JLabel(); + explanation = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopgui.Main.class).getContext().getResourceMap(SpeedSelector3.class); setTitle(resourceMap.getString("Form.title")); // NOI18N + setMinimumSize(new java.awt.Dimension(670, 330)); setName("Form"); // NOI18N + setResizable(false); + getContentPane().setLayout(null); finishButton.setText(resourceMap.getString("finishButton.text")); // NOI18N finishButton.setName("finishButton"); // NOI18N @@ -67,6 +81,8 @@ public class SpeedSelector3 extends javax.swing.JFrame { finishButtonMouseClicked(evt); } }); + getContentPane().add(finishButton); + finishButton.setBounds(440, 250, 90, 29); previousButton.setText(resourceMap.getString("previousButton.text")); // NOI18N previousButton.setName("previousButton"); // NOI18N @@ -75,27 +91,43 @@ public class SpeedSelector3 extends javax.swing.JFrame { previousButtonMouseClicked(evt); } }); + getContentPane().add(previousButton); + previousButton.setBounds(336, 250, 90, 29); - jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N - jLabel1.setName("jLabel1"); // NOI18N + settingsInfo.setText(resourceMap.getString("settingsInfo.text")); // NOI18N + settingsInfo.setName("settingsInfo"); // NOI18N + getContentPane().add(settingsInfo); + settingsInfo.setBounds(20, 30, 532, 17); uploadLabel.setText(resourceMap.getString("uploadLabel.text")); // NOI18N uploadLabel.setName("uploadLabel"); // NOI18N + getContentPane().add(uploadLabel); + uploadLabel.setBounds(20, 70, 140, 30); downloadLabel.setText(resourceMap.getString("downloadLabel.text")); // NOI18N downloadLabel.setName("downloadLabel"); // NOI18N + getContentPane().add(downloadLabel); + downloadLabel.setBounds(340, 70, 160, 30); uploadBurstLabel.setText(resourceMap.getString("uploadBurstLabel.text")); // NOI18N uploadBurstLabel.setName("uploadBurstLabel"); // NOI18N + getContentPane().add(uploadBurstLabel); + uploadBurstLabel.setBounds(20, 110, 140, 30); downloadBurstLabel.setText(resourceMap.getString("downloadBurstLabel.text")); // NOI18N downloadBurstLabel.setName("downloadBurstLabel"); // NOI18N + getContentPane().add(downloadBurstLabel); + downloadBurstLabel.setBounds(340, 110, 160, 30); uploadUsageLabel.setText(resourceMap.getString("uploadUsageLabel.text")); // NOI18N uploadUsageLabel.setName("uploadUsageLabel"); // NOI18N + getContentPane().add(uploadUsageLabel); + uploadUsageLabel.setBounds(20, 150, 141, 30); downloadUsageLabel.setText(resourceMap.getString("downloadUsageLabel.text")); // NOI18N downloadUsageLabel.setName("downloadUsageLabel"); // NOI18N + getContentPane().add(downloadUsageLabel); + downloadUsageLabel.setBounds(340, 150, 162, 30); uploadField.setText(resourceMap.getString("uploadField.text")); // NOI18N uploadField.setMinimumSize(new java.awt.Dimension(77, 27)); @@ -105,10 +137,14 @@ public class SpeedSelector3 extends javax.swing.JFrame { speedFieldKeyReleased(evt); } }); + getContentPane().add(uploadField); + uploadField.setBounds(160, 70, 77, 27); uploadBurstField.setText(resourceMap.getString("uploadBurstField.text")); // NOI18N uploadBurstField.setMinimumSize(new java.awt.Dimension(77, 27)); uploadBurstField.setName("uploadBurstField"); // NOI18N + getContentPane().add(uploadBurstField); + uploadBurstField.setBounds(160, 110, 77, 27); downloadField.setText(resourceMap.getString("downloadField.text")); // NOI18N downloadField.setMinimumSize(new java.awt.Dimension(77, 27)); @@ -118,84 +154,89 @@ public class SpeedSelector3 extends javax.swing.JFrame { speedFieldKeyReleased(evt); } }); + getContentPane().add(downloadField); + downloadField.setBounds(500, 70, 77, 27); downloadBurstField.setText(resourceMap.getString("downloadBurstField.text")); // NOI18N downloadBurstField.setMinimumSize(new java.awt.Dimension(77, 27)); downloadBurstField.setName("downloadBurstField"); // NOI18N + getContentPane().add(downloadBurstField); + downloadBurstField.setBounds(500, 110, 77, 27); + + kbpsBurstDownload.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + kbpsBurstDownload.setName("kbpsBurstDownload"); // NOI18N + kbpsBurstDownload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + kbpsBurstDownloadActionPerformed(evt); + } + }); + getContentPane().add(kbpsBurstDownload); + kbpsBurstDownload.setBounds(580, 110, 68, 27); + + kbpsUpload.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + kbpsUpload.setName("kbpsUpload"); // NOI18N + kbpsUpload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + kbpsUploadActionPerformed(evt); + } + }); + getContentPane().add(kbpsUpload); + kbpsUpload.setBounds(240, 70, 68, 27); + + kbpsBurstUpload.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + kbpsBurstUpload.setName("kbpsBurstUpload"); // NOI18N + kbpsBurstUpload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + kbpsBurstUploadActionPerformed(evt); + } + }); + getContentPane().add(kbpsBurstUpload); + kbpsBurstUpload.setBounds(240, 110, 68, 27); + + kbpsDownload.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "kbps", "kBps" })); + kbpsDownload.setName("kbpsDownload"); // NOI18N + kbpsDownload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + kbpsDownloadActionPerformed(evt); + } + }); + getContentPane().add(kbpsDownload); + kbpsDownload.setBounds(580, 70, 68, 27); + + uploadGB.setText(resourceMap.getString("uploadUsageLabel.text")); // NOI18N + uploadGB.setName("uploadUsageLabel"); // NOI18N + getContentPane().add(uploadGB); + uploadGB.setBounds(240, 150, 45, 30); uploadMonth.setText(resourceMap.getString("uploadMonth.text")); // NOI18N uploadMonth.setName("uploadMonth"); // NOI18N + uploadMonth.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + monthKeyReleased(evt); + } + }); + getContentPane().add(uploadMonth); + uploadMonth.setBounds(160, 150, 77, 27); downloadMonth.setText(resourceMap.getString("downloadMonth.text")); // NOI18N downloadMonth.setName("downloadMonth"); // NOI18N + downloadMonth.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + monthKeyReleased(evt); + } + }); + getContentPane().add(downloadMonth); + downloadMonth.setBounds(500, 150, 77, 27); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel1) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(uploadLabel) - .addComponent(uploadBurstLabel) - .addComponent(uploadUsageLabel)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(uploadBurstField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(uploadField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(uploadMonth, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(46, 46, 46) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(downloadLabel) - .addComponent(downloadBurstLabel) - .addComponent(downloadUsageLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(downloadField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(downloadMonth, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(downloadBurstField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - .addGap(18, 18, 18)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(previousButton) - .addGap(18, 18, 18) - .addComponent(finishButton) - .addGap(33, 33, 33))) - .addGap(400, 400, 400)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGap(81, 81, 81) - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(uploadLabel) - .addComponent(downloadLabel) - .addComponent(uploadField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(downloadField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(uploadBurstLabel) - .addComponent(downloadBurstLabel) - .addComponent(downloadBurstField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(uploadBurstField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(uploadUsageLabel) - .addComponent(downloadUsageLabel) - .addComponent(uploadMonth) - .addComponent(downloadMonth)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(previousButton) - .addComponent(finishButton)) - .addContainerGap()) - ); + downloadGB.setText(resourceMap.getString("downloadUsageLabel.text")); // NOI18N + downloadGB.setName("downloadUsageLabel"); // NOI18N + getContentPane().add(downloadGB); + downloadGB.setBounds(580, 150, 19, 30); + + explanation.setText(resourceMap.getString("explanation.text")); // NOI18N + explanation.setName("explanation"); // NOI18N + getContentPane().add(explanation); + explanation.setBounds(20, 200, 600, 40); pack(); }// //GEN-END:initComponents @@ -203,7 +244,7 @@ public class SpeedSelector3 extends javax.swing.JFrame { private void previousButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_previousButtonMouseClicked saveSpeeds(); PropertyManager.saveProps(props); - new SpeedSelector2(this.getLocationOnScreen(), this.getSize()).setVisible(true); + new SpeedSelector2(this.getLocationOnScreen()); this.dispose(); }//GEN-LAST:event_previousButtonMouseClicked @@ -219,7 +260,7 @@ private void finishButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRS //Working in kB, not kb! SpeedHandler.setInboundBandwidth(maxDownload/8); SpeedHandler.setOutboundBandwidth(maxUpload/8); - SpeedHandler.setInboundBurstBandwidth(maxDownloadBurst); + SpeedHandler.setInboundBurstBandwidth(maxDownloadBurst/8); SpeedHandler.setOutboundBurstBandwidth(maxUploadBurst/8); this.dispose(); @@ -227,13 +268,88 @@ private void finishButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRS private void speedFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedFieldKeyReleased try { - initUsage(uploadField.getText(), downloadField.getText()); + String upload = ""; + if(kbpsUpload.getSelectedIndex() == KILOBIT) + upload = uploadField.getText(); + else + upload = "" + Integer.parseInt(uploadField.getText())*8; + String download = ""; + if(kbpsDownload.getSelectedIndex() == KILOBIT) + download = downloadField.getText(); + else + download = "" + Integer.parseInt(downloadField.getText())*8; + initUsage(upload, download); } catch(NumberFormatException e) { return; } }//GEN-LAST:event_speedFieldKeyReleased +private void kbpsUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kbpsUploadActionPerformed + kbpsSwitchPerformed(kbpsUpload, uploadField); +}//GEN-LAST:event_kbpsUploadActionPerformed + +private void kbpsBurstUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kbpsBurstUploadActionPerformed + kbpsSwitchPerformed(kbpsBurstUpload, uploadBurstField); +}//GEN-LAST:event_kbpsBurstUploadActionPerformed + +private void kbpsDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kbpsDownloadActionPerformed + kbpsSwitchPerformed(kbpsDownload, downloadField); +}//GEN-LAST:event_kbpsDownloadActionPerformed + +private void kbpsBurstDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kbpsBurstDownloadActionPerformed + kbpsSwitchPerformed(kbpsBurstDownload, downloadBurstField); +}//GEN-LAST:event_kbpsBurstDownloadActionPerformed + +private void monthKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthKeyReleased + try { + int uploadMonthValue = Integer.parseInt(uploadMonth.getText()); + int downloadMonthValue = Integer.parseInt(downloadMonth.getText()); + + String upload = ""; + String burstUpload = ""; + String download = ""; + String burstDownload = ""; + + if(kbpsUpload.getSelectedIndex() == KILOBIT) + upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue)*8; //kbit + else + upload = "" + SpeedHelper.calculateSpeed(uploadMonthValue); //kbyte + + if(kbpsBurstUpload.getSelectedIndex() == KILOBIT) + burstUpload = "" + SpeedHelper.calculateSpeed(uploadMonthValue)*8; //kbit + else + burstUpload = "" + SpeedHelper.calculateSpeed(uploadMonthValue); //kbyte + + if(kbpsDownload.getSelectedIndex() == KILOBIT) + download = "" + SpeedHelper.calculateSpeed(downloadMonthValue)*8; //kbit + else + download = "" + SpeedHelper.calculateSpeed(downloadMonthValue); //kbyte + + if(kbpsBurstDownload.getSelectedIndex() == KILOBIT) + burstDownload = "" + SpeedHelper.calculateSpeed(downloadMonthValue)*8; //kbit + else + burstDownload = "" + SpeedHelper.calculateSpeed(downloadMonthValue); //kbyte + + initSpeeds(upload, burstUpload, download, burstDownload); + } + catch(NumberFormatException e) { + e.printStackTrace(); + return; + } +}//GEN-LAST:event_monthKeyReleased + +private void kbpsSwitchPerformed(JComboBox kbps, JTextField speed) { + int index = kbps.getSelectedIndex(); + int previous = Integer.parseInt(speed.getText()); + if(index == KILOBIT) { + speed.setText("" + previous*8); + } + else { + speed.setText("" + previous/8); + } +} + protected void initSpeeds() { String up = "" + SpeedHelper.calculateSpeed( props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE)); @@ -245,42 +361,79 @@ private void speedFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:eve props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE)); String userType = props.getProperty(SpeedSelectorConstants.USERTYPE); + initSpeeds(up, upBurst, down, downBurst); + } + + protected void initSpeeds(String up, String upBurst, String down, String downBurst) { uploadField.setText(up); uploadBurstField.setText(upBurst); downloadField.setText(down); downloadBurstField.setText(downBurst); - - initUsage(up, down); } protected void saveSpeeds() { - props.setProperty(SpeedSelectorConstants.MAXUPLOAD, uploadField.getText()); - props.setProperty(SpeedSelectorConstants.MAXUPLOADBURST, uploadBurstField.getText()); - props.setProperty(SpeedSelectorConstants.MAXDOWNLOAD, downloadField.getText()); - props.setProperty(SpeedSelectorConstants.MAXDOWNLOADBURST, downloadBurstField.getText()); + if(kbpsUpload.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXUPLOAD, uploadField.getText()); + else + props.setProperty(SpeedSelectorConstants.MAXUPLOAD, "" + Integer.parseInt(uploadField.getText())*8); + if(kbpsBurstUpload.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXUPLOADBURST, uploadBurstField.getText()); + else + props.setProperty(SpeedSelectorConstants.MAXUPLOADBURST, "" + Integer.parseInt(uploadBurstField.getText())*8); + if(kbpsDownload.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXDOWNLOAD, downloadField.getText()); + else + props.setProperty(SpeedSelectorConstants.MAXDOWNLOAD, "" + Integer.parseInt(downloadField.getText())*8); + if(kbpsBurstDownload.getSelectedIndex() == KILOBIT) + props.setProperty(SpeedSelectorConstants.MAXDOWNLOADBURST, downloadBurstField.getText()); + else + props.setProperty(SpeedSelectorConstants.MAXDOWNLOADBURST, "" + Integer.parseInt(downloadBurstField.getText())*8); } protected void initUsage(String upload, String download) { - uploadMonth.setText(SpeedHelper.calculateMonthlyUsage(Integer.parseInt(upload)/8) + " GB"); - downloadMonth.setText(SpeedHelper.calculateMonthlyUsage(Integer.parseInt(download)/8) + " GB"); + uploadMonth.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(upload)/8)); + downloadMonth.setText("" + SpeedHelper.calculateMonthlyUsage(Integer.parseInt(download)/8)); + } + + protected void initUsage() { + String upload = ""; + if(kbpsUpload.getSelectedIndex() == KILOBIT) + upload = uploadField.getText(); + else + upload = "" + Integer.parseInt(uploadField.getText())/8; + String download = ""; + if(kbpsDownload.getSelectedIndex() == KILOBIT) + download = downloadField.getText(); + else + download = "" + Integer.parseInt(downloadField.getText())/8; + initUsage(upload, download); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField downloadBurstField; private javax.swing.JLabel downloadBurstLabel; private javax.swing.JTextField downloadField; + private javax.swing.JLabel downloadGB; private javax.swing.JLabel downloadLabel; - private javax.swing.JLabel downloadMonth; + private javax.swing.JTextField downloadMonth; private javax.swing.JLabel downloadUsageLabel; + private javax.swing.JLabel explanation; private javax.swing.JButton finishButton; - private javax.swing.JLabel jLabel1; + private javax.swing.JComboBox kbpsBurstDownload; + private javax.swing.JComboBox kbpsBurstUpload; + private javax.swing.JComboBox kbpsDownload; + private javax.swing.JComboBox kbpsUpload; private javax.swing.JButton previousButton; + private javax.swing.JLabel settingsInfo; private javax.swing.JTextField uploadBurstField; private javax.swing.JLabel uploadBurstLabel; private javax.swing.JTextField uploadField; + private javax.swing.JLabel uploadGB; private javax.swing.JLabel uploadLabel; - private javax.swing.JLabel uploadMonth; + private javax.swing.JTextField uploadMonth; private javax.swing.JLabel uploadUsageLabel; // End of variables declaration//GEN-END:variables + private static final int KILOBIT = 0; + private static final int KILOBYTE = 1; } diff --git a/apps/desktopgui/src/gui/resources/SpeedSelector.properties b/apps/desktopgui/src/gui/resources/SpeedSelector.properties index 1a476d874..03b04286f 100644 --- a/apps/desktopgui/src/gui/resources/SpeedSelector.properties +++ b/apps/desktopgui/src/gui/resources/SpeedSelector.properties @@ -1,7 +1,6 @@ -Form.title=I2P Configuration +Form.title=I2P Speed Configuration nextButton.text=Next -uploadLabel.text=What is your maximum upload speed? +uploadLabel.text=What is your maximum upload speed? downloadLabel.text=What is your maximum download speed? -kbps1.text=kbit/second -kbps2.text=kbit/second +speedExplanation.text=Explanation about speeds... diff --git a/apps/desktopgui/src/gui/resources/SpeedSelector2.properties b/apps/desktopgui/src/gui/resources/SpeedSelector2.properties index 704d9909e..54424ed05 100644 --- a/apps/desktopgui/src/gui/resources/SpeedSelector2.properties +++ b/apps/desktopgui/src/gui/resources/SpeedSelector2.properties @@ -1,6 +1,9 @@ returnButton.text=Previous -Form.title=I2P Configuration +Form.title=I2P Speed Configuration questionLabel.text=Which of these descriptions fits you best? browseButton.text=Browsing: I want to use I2P to browse websites anonymously, no heavy usage. downloadButton.text=Downloading: I want to use I2P for downloads and filesharing, heavy usage. nextButton.text=Next +browseButton.actionCommand=Browsing +downloadButton.actionCommand=Downloading +jLabel1.text=Text explaining ... diff --git a/apps/desktopgui/src/gui/resources/SpeedSelector3.properties b/apps/desktopgui/src/gui/resources/SpeedSelector3.properties index 49ee18ba0..9d0718f8d 100644 --- a/apps/desktopgui/src/gui/resources/SpeedSelector3.properties +++ b/apps/desktopgui/src/gui/resources/SpeedSelector3.properties @@ -1,16 +1,17 @@ Form.title=I2P Configuration -jLabel1.text=The profile information your entered, indicates that these are your optimal settings: previousButton.text=Previous finishButton.text=Finish uploadLabel.text=Upload Speed: uploadBurstLabel.text=Burst Upload Speed: downloadLabel.text=Download Speed: downloadBurstLabel.text=Burst Download Speed: -uploadUsageLabel.text=Monthy upload usage: -downloadUsageLabel.text=Monthy Download Usage: +uploadUsageLabel.text=GB +downloadUsageLabel.text=GB uploadField.text=jTextField1 uploadBurstField.text=jTextField2 -uploadMonth.text=jLabel8 -downloadMonth.text=jLabel9 downloadField.text=jTextField4 downloadBurstField.text=jTextField5 +uploadMonth.text=jTextField1 +downloadMonth.text=jTextField2 +settingsInfo.text=The profile information your entered, indicates that these are your optimal settings: +explanation.text=Text explaining ... diff --git a/apps/desktopgui/src/router/configuration/SpeedHelper.java b/apps/desktopgui/src/router/configuration/SpeedHelper.java index aec782533..acad2adb1 100644 --- a/apps/desktopgui/src/router/configuration/SpeedHelper.java +++ b/apps/desktopgui/src/router/configuration/SpeedHelper.java @@ -25,4 +25,8 @@ public class SpeedHelper { public static int calculateMonthlyUsage(int kbytes) { return (int) ((((long)kbytes)*3600*24*31)/1000000); } + + public static int calculateSpeed(int gigabytes) { + return (int) (((long)gigabytes)*1000000/31/24/3600); + } } diff --git a/build.xml b/build.xml index f306a71b3..3a30ff8e7 100644 --- a/build.xml +++ b/build.xml @@ -488,7 +488,7 @@ - + @@ -513,6 +513,6 @@ - +