New application for I2P: desktopgui. Should eventually replace systray, and have more functionality.

To use the application, you need to (by default) add the following to clients.config :
# desktopgui
clientApp.6.args=
clientApp.6.delay=5
clientApp.6.main=desktopgui.Main
clientApp.6.name=desktopgui
clientApp.6.startOnLoad=true
This commit is contained in:
mathiasdm
2009-04-06 17:53:32 +00:00
parent 884663d077
commit 495558a949
33 changed files with 2750 additions and 0 deletions

View File

@@ -0,0 +1 @@
desktopgui.Main

View File

@@ -0,0 +1,109 @@
package desktopgui;
/*
* Main.java
*/
import gui.Tray;
import gui.SpeedSelector;
import java.awt.SystemTray;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import persistence.PropertyManager;
/**
* The main class of the application.
*/
public class Main extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
Properties props = PropertyManager.loadProps();
//First load: present screen with information (to help choose I2P settings)
if(props.getProperty(FIRSTLOAD).equals("true")) {
props.setProperty(FIRSTLOAD, "false");
PropertyManager.saveProps(props);
new SpeedSelector(); //Start speed selector GUI
}
if(SystemTray.isSupported()) {
tray = new Tray();
}
else { //Alternative if SystemTray is not supported on the platform
}
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of Main
*/
public static Main getApplication() {
return Application.getInstance(Main.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
System.setProperty("java.awt.headless", "false"); //Make sure I2P is running in GUI mode for our application
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
Main main = getApplication();
main.launchForeverLoop();
main.startup();
}
/**
* Avoids the app terminating because no Window is opened anymore.
* More info: http://java.sun.com/javase/6/docs/api/java/awt/doc-files/AWTThreadIssues.html#Autoshutdown
*/
public void launchForeverLoop() {
Runnable r = new Runnable() {
public void run() {
try {
Object o = new Object();
synchronized (o) {
o.wait();
}
} catch (InterruptedException ie) {
}
}
};
Thread t = new Thread(r);
t.setDaemon(false);
t.start();
}
private Tray tray = null;
///Indicates if this is the first time the application loads
///(is only true at the very start of loading the first time!)
private static final String FIRSTLOAD = "firstLoad";
}

View File

@@ -0,0 +1,11 @@
# Application global resources
Application.name = desktopgui
Application.title = I2P Desktop GUI
Application.version = 0.7.1
Application.vendor = I2P Developers
Application.homepage = http://www.i2p2.de
Application.description = An anonymous communication network.
Application.vendorId = I2P
Application.id = ${Application.name}
Application.lookAndFeel = system

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" resourceKey="Form.title"/>
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="downloadLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="uploadLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="downloadChoice" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="kbps2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="1">
<Component id="uploadChoice" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="kbps1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="nextButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="67" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="uploadLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="uploadChoice" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="kbps1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="downloadLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadChoice" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="kbps2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="173" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="271" max="32767" attributes="0"/>
<Component id="nextButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="nextButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="nextButton.text"/>
<Property name="name" type="java.lang.String" value="nextButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="nextButtonMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="uploadLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadLabel.text"/>
<Property name="name" type="java.lang.String" value="uploadLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="downloadLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadLabel.text"/>
<Property name="name" type="java.lang.String" value="downloadLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="uploadChoice">
<Properties>
<Property name="editable" type="boolean" value="true"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="11">
<StringItem index="0" value="100"/>
<StringItem index="1" value="200"/>
<StringItem index="2" value="500"/>
<StringItem index="3" value="1000"/>
<StringItem index="4" value="2000"/>
<StringItem index="5" value="4000"/>
<StringItem index="6" value="8000"/>
<StringItem index="7" value="10000"/>
<StringItem index="8" value="20000"/>
<StringItem index="9" value="50000"/>
<StringItem index="10" value="100000"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="3"/>
<Property name="name" type="java.lang.String" value="uploadChoice" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="downloadChoice">
<Properties>
<Property name="editable" type="boolean" value="true"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="11">
<StringItem index="0" value="100"/>
<StringItem index="1" value="200"/>
<StringItem index="2" value="500"/>
<StringItem index="3" value="1000"/>
<StringItem index="4" value="2000"/>
<StringItem index="5" value="4000"/>
<StringItem index="6" value="8000"/>
<StringItem index="7" value="10000"/>
<StringItem index="8" value="20000"/>
<StringItem index="9" value="50000"/>
<StringItem index="10" value="100000"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="3"/>
<Property name="name" type="java.lang.String" value="downloadChoice" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="kbps1">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="kbps1.text"/>
<Property name="name" type="java.lang.String" value="kbps1" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="kbps2">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="kbps2.text"/>
<Property name="name" type="java.lang.String" value="kbps2" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,176 @@
/*
* ProfileSelector.java
*
* Created on 3 april 2009, 13:57
*/
package gui;
import java.awt.Dimension;
import java.awt.Point;
import java.util.Properties;
import javax.swing.JTextField;
import persistence.PropertyManager;
import util.IntegerVerifier;
/**
*
* @author mathias
*/
public class SpeedSelector extends javax.swing.JFrame {
/** Creates new form ProfileSelector */
public SpeedSelector() {
this.props = PropertyManager.getProps();
initComponents();
initComponentsCustom();
initSpeeds(props);
this.setVisible(true);
}
public SpeedSelector(Point point, Dimension dimension) {
this();
this.setLocation(point);
this.setSize(dimension);
}
public void initComponentsCustom() {
((JTextField)uploadChoice.getEditor().getEditorComponent()).setInputVerifier(new IntegerVerifier());
((JTextField)downloadChoice.getEditor().getEditorComponent()).setInputVerifier(new IntegerVerifier());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
nextButton = new javax.swing.JButton();
uploadLabel = new javax.swing.JLabel();
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();
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
setName("Form"); // NOI18N
nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N
nextButton.setName("nextButton"); // NOI18N
nextButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
nextButtonMouseClicked(evt);
}
});
uploadLabel.setText(resourceMap.getString("uploadLabel.text")); // NOI18N
uploadLabel.setName("uploadLabel"); // NOI18N
downloadLabel.setText(resourceMap.getString("downloadLabel.text")); // NOI18N
downloadLabel.setName("downloadLabel"); // NOI18N
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
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
kbps1.setText(resourceMap.getString("kbps1.text")); // NOI18N
kbps1.setName("kbps1"); // NOI18N
kbps2.setText(resourceMap.getString("kbps2.text")); // NOI18N
kbps2.setName("kbps2"); // NOI18N
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())
);
pack();
}// </editor-fold>//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());
PropertyManager.saveProps(props);
new SpeedSelector2(this.getLocationOnScreen(), this.getSize());
this.dispose();
}//GEN-LAST:event_nextButtonMouseClicked
private void initSpeeds(Properties props) {
String up = props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE);
String down = props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE);
if(up == null)
props.setProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE, "1000");
if(down == null)
props.setProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE, "1000");
uploadChoice.setSelectedItem(props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE));
downloadChoice.setSelectedItem(props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE));
}
// 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.JButton nextButton;
private javax.swing.JComboBox uploadChoice;
private javax.swing.JLabel uploadLabel;
// End of variables declaration//GEN-END:variables
Properties props;
}

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" resourceKey="Form.title"/>
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="406" max="32767" attributes="0"/>
<Component id="returnButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="nextButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="74" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="questionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="12" pref="12" max="12" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="downloadButton" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="browseButton" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="32" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
<Component id="questionLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="browseButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="downloadButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="120" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="nextButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="returnButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="nextButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="nextButton.text"/>
<Property name="name" type="java.lang.String" value="nextButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="nextButtonMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="returnButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="returnButton.text"/>
<Property name="name" type="java.lang.String" value="returnButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="returnButtonMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="questionLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="questionLabel.text"/>
<Property name="name" type="java.lang.String" value="questionLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="browseButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" resourceKey="browseButton.text"/>
<Property name="name" type="java.lang.String" value="browseButton" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="downloadButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" resourceKey="downloadButton.text"/>
<Property name="name" type="java.lang.String" value="downloadButton" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,174 @@
/*
* ProfileSelector2.java
*
* Created on 3 april 2009, 14:36
*/
package gui;
import java.awt.Dimension;
import java.awt.Point;
import java.util.Enumeration;
import java.util.Properties;
import javax.swing.AbstractButton;
import persistence.PropertyManager;
/**
*
* @author mathias
*/
public class SpeedSelector2 extends javax.swing.JFrame {
Properties props;
/** Creates new form ProfileSelector2 */
public SpeedSelector2(Point point, Dimension dimension) {
this.props = PropertyManager.getProps();
initComponents();
this.setLocation(point);
this.setSize(dimension);
loadButtonSelection();
this.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
nextButton = new javax.swing.JButton();
returnButton = new javax.swing.JButton();
questionLabel = new javax.swing.JLabel();
browseButton = new javax.swing.JRadioButton();
downloadButton = new javax.swing.JRadioButton();
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
setName("Form"); // NOI18N
nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N
nextButton.setName("nextButton"); // NOI18N
nextButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
nextButtonMouseClicked(evt);
}
});
returnButton.setText(resourceMap.getString("returnButton.text")); // NOI18N
returnButton.setName("returnButton"); // NOI18N
returnButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
returnButtonMouseClicked(evt);
}
});
questionLabel.setText(resourceMap.getString("questionLabel.text")); // NOI18N
questionLabel.setName("questionLabel"); // NOI18N
buttonGroup1.add(browseButton);
browseButton.setText(resourceMap.getString("browseButton.text")); // NOI18N
browseButton.setName("browseButton"); // NOI18N
buttonGroup1.add(downloadButton);
downloadButton.setText(resourceMap.getString("downloadButton.text")); // NOI18N
downloadButton.setName("downloadButton"); // NOI18N
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())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void returnButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_returnButtonMouseClicked
saveButtonSelection();
PropertyManager.saveProps(props);
new SpeedSelector(this.getLocationOnScreen(), this.getSize()).setVisible(true);
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);
this.dispose();
}//GEN-LAST:event_nextButtonMouseClicked
private void loadButtonSelection() {
Enumeration<AbstractButton> elements = buttonGroup1.getElements();
while(elements.hasMoreElements()) {
AbstractButton button = elements.nextElement();
if(button == null)
continue;
if(props.getProperty(SpeedSelectorConstants.USERTYPE) == null)
break;
String type = button.getText().split(":")[0];
if(type.equals(props.getProperty(SpeedSelectorConstants.USERTYPE))) {
button.setSelected(true);
break;
}
}
}
private void saveButtonSelection() {
Enumeration<AbstractButton> elements = buttonGroup1.getElements();
while(elements.hasMoreElements()) {
AbstractButton button = elements.nextElement();
if(button == null)
continue;
if(button.isSelected()) {
String type = button.getText().split(":")[0];
props.setProperty(SpeedSelectorConstants.USERTYPE, type);
break;
}
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton browseButton;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JRadioButton downloadButton;
private javax.swing.JButton nextButton;
private javax.swing.JLabel questionLabel;
private javax.swing.JButton returnButton;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" resourceKey="Form.title"/>
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="uploadLabel" min="-2" max="-2" attributes="0"/>
<Component id="uploadBurstLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="uploadUsageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="uploadBurstField" alignment="0" max="32767" attributes="1"/>
<Component id="uploadField" alignment="0" max="32767" attributes="1"/>
<Component id="uploadMonth" alignment="0" max="32767" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="46" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="downloadLabel" min="-2" max="-2" attributes="0"/>
<Component id="downloadBurstLabel" min="-2" max="-2" attributes="0"/>
<Component id="downloadUsageLabel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="downloadField" max="32767" attributes="1"/>
<Component id="downloadMonth" alignment="0" max="32767" attributes="1"/>
<Component id="downloadBurstField" alignment="0" max="32767" attributes="1"/>
</Group>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="previousButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="finishButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="400" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="81" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="uploadLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="uploadField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="uploadBurstLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadBurstLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadBurstField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="uploadBurstField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="uploadUsageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadUsageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="uploadMonth" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="downloadMonth" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="48" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="previousButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="finishButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="finishButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="finishButton.text"/>
<Property name="name" type="java.lang.String" value="finishButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="finishButtonMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="previousButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="previousButton.text"/>
<Property name="name" type="java.lang.String" value="previousButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="previousButtonMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel1.text"/>
<Property name="name" type="java.lang.String" value="jLabel1" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="uploadLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadLabel.text"/>
<Property name="name" type="java.lang.String" value="uploadLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="downloadLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadLabel.text"/>
<Property name="name" type="java.lang.String" value="downloadLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="uploadBurstLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadBurstLabel.text"/>
<Property name="name" type="java.lang.String" value="uploadBurstLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="downloadBurstLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadBurstLabel.text"/>
<Property name="name" type="java.lang.String" value="downloadBurstLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="uploadUsageLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadUsageLabel.text"/>
<Property name="name" type="java.lang.String" value="uploadUsageLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="downloadUsageLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadUsageLabel.text"/>
<Property name="name" type="java.lang.String" value="downloadUsageLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="uploadField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadField.text"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 27]"/>
</Property>
<Property name="name" type="java.lang.String" value="uploadField" noResource="true"/>
</Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedFieldKeyReleased"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="uploadBurstField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadBurstField.text"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 27]"/>
</Property>
<Property name="name" type="java.lang.String" value="uploadBurstField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="downloadField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadField.text"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 27]"/>
</Property>
<Property name="name" type="java.lang.String" value="downloadField" noResource="true"/>
</Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="speedFieldKeyReleased"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="downloadBurstField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadBurstField.text"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 27]"/>
</Property>
<Property name="name" type="java.lang.String" value="downloadBurstField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="uploadMonth">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="uploadMonth.text"/>
<Property name="name" type="java.lang.String" value="uploadMonth" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="downloadMonth">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="downloadMonth.text"/>
<Property name="name" type="java.lang.String" value="downloadMonth" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,286 @@
/*
* ProfileSelector3.java
*
* Created on 3 april 2009, 15:17
*/
package gui;
import java.awt.Dimension;
import java.awt.Point;
import java.util.Properties;
import persistence.PropertyManager;
import router.configuration.SpeedHandler;
import router.configuration.SpeedHelper;
/**
*
* @author mathias
*/
public class SpeedSelector3 extends javax.swing.JFrame {
Properties props;
/** Creates new form ProfileSelector3 */
public SpeedSelector3(Point point, Dimension dimension) {
this.props = PropertyManager.getProps();
initComponents();
this.setLocation(point);
this.setSize(dimension);
initSpeeds();
this.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
finishButton = new javax.swing.JButton();
previousButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
uploadLabel = new javax.swing.JLabel();
downloadLabel = new javax.swing.JLabel();
uploadBurstLabel = new javax.swing.JLabel();
downloadBurstLabel = new javax.swing.JLabel();
uploadUsageLabel = new javax.swing.JLabel();
downloadUsageLabel = new javax.swing.JLabel();
uploadField = new javax.swing.JTextField();
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();
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
setName("Form"); // NOI18N
finishButton.setText(resourceMap.getString("finishButton.text")); // NOI18N
finishButton.setName("finishButton"); // NOI18N
finishButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
finishButtonMouseClicked(evt);
}
});
previousButton.setText(resourceMap.getString("previousButton.text")); // NOI18N
previousButton.setName("previousButton"); // NOI18N
previousButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
previousButtonMouseClicked(evt);
}
});
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
uploadLabel.setText(resourceMap.getString("uploadLabel.text")); // NOI18N
uploadLabel.setName("uploadLabel"); // NOI18N
downloadLabel.setText(resourceMap.getString("downloadLabel.text")); // NOI18N
downloadLabel.setName("downloadLabel"); // NOI18N
uploadBurstLabel.setText(resourceMap.getString("uploadBurstLabel.text")); // NOI18N
uploadBurstLabel.setName("uploadBurstLabel"); // NOI18N
downloadBurstLabel.setText(resourceMap.getString("downloadBurstLabel.text")); // NOI18N
downloadBurstLabel.setName("downloadBurstLabel"); // NOI18N
uploadUsageLabel.setText(resourceMap.getString("uploadUsageLabel.text")); // NOI18N
uploadUsageLabel.setName("uploadUsageLabel"); // NOI18N
downloadUsageLabel.setText(resourceMap.getString("downloadUsageLabel.text")); // NOI18N
downloadUsageLabel.setName("downloadUsageLabel"); // NOI18N
uploadField.setText(resourceMap.getString("uploadField.text")); // NOI18N
uploadField.setMinimumSize(new java.awt.Dimension(77, 27));
uploadField.setName("uploadField"); // NOI18N
uploadField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
speedFieldKeyReleased(evt);
}
});
uploadBurstField.setText(resourceMap.getString("uploadBurstField.text")); // NOI18N
uploadBurstField.setMinimumSize(new java.awt.Dimension(77, 27));
uploadBurstField.setName("uploadBurstField"); // NOI18N
downloadField.setText(resourceMap.getString("downloadField.text")); // NOI18N
downloadField.setMinimumSize(new java.awt.Dimension(77, 27));
downloadField.setName("downloadField"); // NOI18N
downloadField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
speedFieldKeyReleased(evt);
}
});
downloadBurstField.setText(resourceMap.getString("downloadBurstField.text")); // NOI18N
downloadBurstField.setMinimumSize(new java.awt.Dimension(77, 27));
downloadBurstField.setName("downloadBurstField"); // NOI18N
uploadMonth.setText(resourceMap.getString("uploadMonth.text")); // NOI18N
uploadMonth.setName("uploadMonth"); // NOI18N
downloadMonth.setText(resourceMap.getString("downloadMonth.text")); // NOI18N
downloadMonth.setName("downloadMonth"); // NOI18N
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())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void previousButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_previousButtonMouseClicked
saveSpeeds();
PropertyManager.saveProps(props);
new SpeedSelector2(this.getLocationOnScreen(), this.getSize()).setVisible(true);
this.dispose();
}//GEN-LAST:event_previousButtonMouseClicked
private void finishButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_finishButtonMouseClicked
saveSpeeds();
PropertyManager.saveProps(props);
int maxDownload = Integer.parseInt(props.getProperty(SpeedSelectorConstants.MAXDOWNLOAD));
int maxUpload = Integer.parseInt(props.getProperty(SpeedSelectorConstants.MAXUPLOAD));
int maxUploadBurst = Integer.parseInt(props.getProperty(SpeedSelectorConstants.MAXUPLOADBURST));
int maxDownloadBurst = Integer.parseInt(props.getProperty(SpeedSelectorConstants.MAXDOWNLOADBURST));
//Working in kB, not kb!
SpeedHandler.setInboundBandwidth(maxDownload/8);
SpeedHandler.setOutboundBandwidth(maxUpload/8);
SpeedHandler.setInboundBurstBandwidth(maxDownloadBurst);
SpeedHandler.setOutboundBurstBandwidth(maxUploadBurst/8);
this.dispose();
}//GEN-LAST:event_finishButtonMouseClicked
private void speedFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_speedFieldKeyReleased
try {
initUsage(uploadField.getText(), downloadField.getText());
}
catch(NumberFormatException e) {
return;
}
}//GEN-LAST:event_speedFieldKeyReleased
protected void initSpeeds() {
String up = "" + SpeedHelper.calculateSpeed(
props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE));
String upBurst = "" + SpeedHelper.calculateSpeed(
props.getProperty(SpeedSelectorConstants.MAXUPLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE));
String down = "" + SpeedHelper.calculateSpeed(
props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE));
String downBurst = "" + SpeedHelper.calculateSpeed(
props.getProperty(SpeedSelectorConstants.MAXDOWNLOADCAPABLE), props.getProperty(SpeedSelectorConstants.USERTYPE));
String userType = props.getProperty(SpeedSelectorConstants.USERTYPE);
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());
}
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");
}
// 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 downloadLabel;
private javax.swing.JLabel downloadMonth;
private javax.swing.JLabel downloadUsageLabel;
private javax.swing.JButton finishButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton previousButton;
private javax.swing.JTextField uploadBurstField;
private javax.swing.JLabel uploadBurstLabel;
private javax.swing.JTextField uploadField;
private javax.swing.JLabel uploadLabel;
private javax.swing.JLabel uploadMonth;
private javax.swing.JLabel uploadUsageLabel;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,25 @@
package gui;
/**
*
* @author mathias
*/
public class SpeedSelectorConstants {
///Maximum upload speed for the internet connection
public static final String MAXUPLOADCAPABLE = "maxUploadCapable";
///Maximum download speed for the internet connection
public static final String MAXDOWNLOADCAPABLE = "maxDownloadCapable";
//User profile type: what behaviour does this user have while using IP2?
public static final String USERTYPE = "userType";
//Maximum upload speed for I2P
public static final String MAXUPLOAD = "maxUpload";
//Maximum upload burst speed for I2P
public static final String MAXUPLOADBURST = "maxUploadBurst";
//Maximum download speed for I2P
public static final String MAXDOWNLOAD = "maxDownload";
//Maximum download burst speed for I2P
public static final String MAXDOWNLOADBURST = "maxDownloadBurst";
}

View File

@@ -0,0 +1,138 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gui;
import desktopgui.*;
import java.awt.AWTException;
import java.awt.Desktop;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.Menu;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import router.RouterHandler;
/**
*
* @author mathias
*/
public class Tray {
public Tray() {
tray = SystemTray.getSystemTray();
loadSystemTray();
}
private void loadSystemTray() {
Image image = Toolkit.getDefaultToolkit().getImage("desktopgui/resources/logo/logo.jpg");
PopupMenu popup = new PopupMenu();
//Create menu items to put in the popup menu
MenuItem browserLauncher = new MenuItem("Launch browser");
browserLauncher.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI("http://localhost:7657"));
} catch (URISyntaxException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch(IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
MenuItem howto = new MenuItem("How to use I2P");
howto.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
File f = new File("desktopgui/resources/howto/howto.html");
desktop.browse(new URI("file://" + f.getAbsolutePath()));
} catch (URISyntaxException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch(IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
Menu config = new Menu("Configuration");
MenuItem speedConfig = new MenuItem("Speed");
speedConfig.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
(new SpeedSelector()).setVisible(true);
}
});
MenuItem advancedConfig = new MenuItem("Advanced Configuration");
advancedConfig.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI("http://localhost:7657/config.jsp"));
} catch (URISyntaxException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch(IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
MenuItem shutdown = new MenuItem("Shutdown I2P");
shutdown.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
RouterHandler.setStatus(RouterHandler.SHUTDOWN_GRACEFULLY);
}
});
//Add menu items to popup menu
popup.add(browserLauncher);
popup.add(howto);
config.add(speedConfig);
config.add(advancedConfig);
popup.add(config);
popup.add(shutdown);
//Add tray icon
trayIcon = new TrayIcon(image, "I2P: the anonymous network", popup);
try {
tray.add(trayIcon);
} catch (AWTException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
private SystemTray tray = null;
private TrayIcon trayIcon = null;
}

View File

@@ -0,0 +1,7 @@
Form.title=I2P Configuration
nextButton.text=Next
uploadLabel.text=What is your maximum upload speed?
downloadLabel.text=What is your maximum download speed?
kbps1.text=kbit/second
kbps2.text=kbit/second

View File

@@ -0,0 +1,6 @@
returnButton.text=Previous
Form.title=I2P 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

View File

@@ -0,0 +1,16 @@
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:
uploadField.text=jTextField1
uploadBurstField.text=jTextField2
uploadMonth.text=jLabel8
downloadMonth.text=jLabel9
downloadField.text=jTextField4
downloadBurstField.text=jTextField5

View File

@@ -0,0 +1,72 @@
package persistence;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author mathias
*/
public class PropertyManager {
public static void setProps(Properties props) {
PropertyManager.props = props;
}
public static Properties getProps() {
return props;
}
public static Properties loadProps() {
Properties defaultProps = new Properties();
defaultProps.setProperty("firstLoad", "true");
// create application properties with default
Properties applicationProps = new Properties(defaultProps);
// now load properties from last invocation
FileInputStream in;
try {
in = new FileInputStream(PROPSLOCATION);
applicationProps.load(in);
in.close();
} catch (FileNotFoundException ex) {
//Nothing serious, just means it's being loaded for the first time.
} catch(IOException ex) {
Logger.getLogger(PropertyManager.class.getName()).log(Level.INFO, null, ex);
}
props = applicationProps;
return applicationProps;
}
public static void saveProps(Properties props) {
FileOutputStream out;
try {
File d = new File(PROPSDIRECTORY);
if(!d.exists())
d.mkdir();
File f = new File(PROPSLOCATION);
if(!f.exists())
f.createNewFile();
out = new FileOutputStream(f);
props.store(out, PROPSLOCATION);
} catch (FileNotFoundException ex) {
Logger.getLogger(PropertyManager.class.getName()).log(Level.SEVERE, null, ex);
} catch(IOException ex) {
Logger.getLogger(PropertyManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static Properties props;
///Location where we store the Application Properties
public static final String PROPSDIRECTORY = "desktopgui";
public static final String PROPSFILENAME = "appProperties";
public static final String PROPSLOCATION = PROPSDIRECTORY + File.separator + PROPSFILENAME;
}

View File

@@ -0,0 +1,38 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package router;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.i2p.router.RouterContext;
/**
*
* @author mathias
*/
public class RouterHandler {
public static final int SHUTDOWN_GRACEFULLY = 0;
public static void setStatus(int status) {
if(status == SHUTDOWN_GRACEFULLY) {
Thread t = new Thread(new Runnable() {
public void run() {
RouterContext context = RouterHelper.getContext();
context.router().shutdownGracefully();
while(context.router().getShutdownTimeRemaining()>0)
try {
Thread.sleep(context.router().getShutdownTimeRemaining());
} catch (InterruptedException ex) {
Logger.getLogger(RouterHandler.class.getName()).log(Level.SEVERE, null, ex);
}
System.exit(0);
}
});
t.start();
}
}
}

View File

@@ -0,0 +1,13 @@
package router;
import net.i2p.router.RouterContext;
/**
*
* @author mathias
*/
public class RouterHelper {
public static RouterContext getContext() {
return (RouterContext) RouterContext.listContexts().get(0);
}
}

View File

@@ -0,0 +1,34 @@
package router.configuration;
import net.i2p.router.RouterContext;
import net.i2p.router.transport.FIFOBandwidthRefiller;
import router.RouterHelper;
/**
*
* @author mathias
*/
public class SpeedHandler {
public static void setInboundBandwidth(int kbytes) {
context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, "" + kbytes);
context.router().saveConfig();
}
public static void setOutboundBandwidth(int kbytes) {
context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + kbytes);
context.router().saveConfig();
}
public static void setInboundBurstBandwidth(int kbytes) {
context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + kbytes);
context.router().saveConfig();
}
public static void setOutboundBurstBandwidth(int kbytes) {
context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + kbytes);
context.router().saveConfig();
}
private static final RouterContext context = RouterHelper.getContext();
}

View File

@@ -0,0 +1,28 @@
package router.configuration;
/**
*
* @author mathias
*/
public class SpeedHelper {
public static final String USERTYPE_BROWSING = "Browsing";
public static final String USERTYPE_DOWNLOADING = "Downloading";
public static int calculateSpeed(String capable, String profile) {
int capableSpeed = Integer.parseInt(capable);
int advisedSpeed = capableSpeed;
if(capableSpeed > 1000) {
if(profile.equals(USERTYPE_BROWSING)) //Don't overdo usage for people just wanting to browse (we don't want to drive them away due to resource hogging)
advisedSpeed *= 0.6;
else if(profile.equals(USERTYPE_DOWNLOADING))
advisedSpeed *= 0.8;
}
else
advisedSpeed *= 0.6; //Lower available bandwidth: don't hog all the bandwidth
return advisedSpeed;
}
public static int calculateMonthlyUsage(int kbytes) {
return (kbytes*3600*24*31)/1000000;
}
}

View File

@@ -0,0 +1,32 @@
package util;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JTextField;
/**
*
* @author mathias
*/
public class IntegerVerifier extends InputVerifier {
@Override
public boolean verify(JComponent arg0) {
JTextField jtf = (JTextField) arg0;
return verify(jtf.getText());
}
@Override
public boolean shouldYieldFocus(JComponent input) {
return verify(input);
}
public static boolean verify(String s) {
for(int i=0;i<s.length();i++)
if(s.charAt(i) > '9' || s.charAt(i) < '0')
return false;
return true;
}
}