Changeset 3208b72


Ignore:
Timestamp:
May 21, 2009 10:32:34 PM (11 years ago)
Author:
mathiasdm <mathiasdm@…>
Branches:
master
Children:
eac45256
Parents:
b4336fde
Message:
  • desktopgui:
    • Updating works in general config
    • Switched to Swingworker threads for improved responsiveness
    • version increase to 0.1.3
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • LICENSE.txt

    rb4336fde r3208b72  
    180180   Public domain
    181181
     182   Desktopgui
     183   Copyright (c) Mathias De Maré
     184   See apps/desktopgui/LICENSE
     185
    182186   SAM C Library:
    183187   Copyright (c) 2004, Matthew P. Cashdollar <mpc@innographx.com>
  • apps/desktopgui/build.xml

    rb4336fde r3208b72  
    7777    <property name="build_lib" location="lib"/>
    7878    <property name="build_i2pref" location="../../build"/>
     79    <property name="build_routerconsole" location="../routerconsole/java/build/"/>
    7980       
    8081    <path id="build_classpath">
    8182        <fileset dir="${build_lib}" includes="**/*.jar"/>
    8283        <fileset dir="${build_i2pref}" includes="**/*.jar"/>
     84        <fileset dir="${build_routerconsole}" includes="**/*.jar"/>
    8385    </path>
    8486    <target name="build_init">
  • apps/desktopgui/nbproject/project.properties

    rb4336fde r3208b72  
    2424file.reference.i2p.jar=../../core/java/build/i2p.jar
    2525file.reference.router.jar=../../router/java/build/router.jar
     26file.reference.routerconsole.jar=../routerconsole/java/build/routerconsole.jar
    2627file.reference.swing-worker.jar=lib/swing-worker.jar
    2728includes=**
     
    3132    ${file.reference.appframework.jar}:\
    3233    ${file.reference.swing-worker.jar}:\
    33     ${file.reference.i2p.jar}
     34    ${file.reference.i2p.jar}:\
     35    ${file.reference.routerconsole.jar}
    3436# Space-separated list of extra javac options
    3537javac.compilerargs=
  • apps/desktopgui/src/net/i2p/desktopgui/desktopgui/GUIVersion.java

    rb4336fde r3208b72  
    1111 */
    1212public class GUIVersion {
    13     public static final String VERSION = "0.0.1.2";
     13    public static final String VERSION = "0.0.1.3";
    1414}
  • apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.form

    rb4336fde r3208b72  
    33<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
    44  <NonVisualComponents>
    5     <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
     5    <Component class="javax.swing.ButtonGroup" name="updateButtonGroup">
    66    </Component>
    77  </NonVisualComponents>
     
    372372              <Properties>
    373373                <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
    374                   <ComponentRef name="buttonGroup1"/>
     374                  <ComponentRef name="updateButtonGroup"/>
    375375                </Property>
    376376                <Property name="text" type="java.lang.String" resourceKey="updateInform.text"/>
     
    381381              <Properties>
    382382                <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
    383                   <ComponentRef name="buttonGroup1"/>
     383                  <ComponentRef name="updateButtonGroup"/>
    384384                </Property>
    385385                <Property name="text" type="java.lang.String" resourceKey="updateDownload.text"/>
     
    390390              <Properties>
    391391                <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
    392                   <ComponentRef name="buttonGroup1"/>
     392                  <ComponentRef name="updateButtonGroup"/>
    393393                </Property>
    394394                <Property name="text" type="java.lang.String" resourceKey="updateDownloadRestart.text"/>
     
    401401                <Property name="name" type="java.lang.String" value="checkUpdates" noResource="true"/>
    402402              </Properties>
     403              <Events>
     404                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkUpdatesActionPerformed"/>
     405              </Events>
    403406            </Component>
    404407            <Component class="javax.swing.JToggleButton" name="updateNow">
     
    407410                <Property name="name" type="java.lang.String" value="updateNow" noResource="true"/>
    408411              </Properties>
     412              <Events>
     413                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="updateNowActionPerformed"/>
     414              </Events>
    409415            </Component>
    410416            <Component class="javax.swing.JToggleButton" name="advancedUpdateConfig">
     
    413419                <Property name="name" type="java.lang.String" value="advancedUpdateConfig" noResource="true"/>
    414420              </Properties>
     421              <Events>
     422                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="advancedUpdateConfigActionPerformed"/>
     423              </Events>
    415424            </Component>
    416425          </SubComponents>
  • apps/desktopgui/src/net/i2p/desktopgui/gui/GeneralConfiguration.java

    rb4336fde r3208b72  
    77package net.i2p.desktopgui.gui;
    88
     9import java.awt.Desktop;
     10import java.io.IOException;
     11import java.net.URI;
     12import java.net.URISyntaxException;
     13import java.util.logging.Level;
     14import java.util.logging.Logger;
    915import net.i2p.desktopgui.router.configuration.SpeedHelper;
    1016import javax.swing.JComboBox;
     17import javax.swing.ButtonModel;
    1118import javax.swing.JTextField;
     19import net.i2p.desktopgui.router.RouterHelper;
    1220import net.i2p.desktopgui.router.configuration.SpeedHandler;
     21import net.i2p.desktopgui.router.configuration.UpdateHelper;
     22import net.i2p.router.web.NewsFetcher;
     23import net.i2p.desktopgui.router.configuration.UpdateHandler;
     24import java.util.Date;
     25import javax.swing.SwingWorker;
    1326
    1427/**
     
    2336        extraInitComponents();
    2437        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
     38        this.setLocationRelativeTo(null);
     39        this.requestFocus();
    2540        this.setVisible(true);
    2641    }
     
    2843    private void extraInitComponents() {
    2944        initSpeedTab();
     45        initUpdateTab();
    3046    }
    3147
     
    3551            String outbound = SpeedHelper.getOutboundBandwidth();
    3652
    37             initSpeeds(inbound, outbound);
    38             initUsage("" + Integer.parseInt(inbound)/8, "" + Integer.parseInt(outbound)/8);
     53            initSpeeds("" + Integer.parseInt(inbound)*8, "" + Integer.parseInt(outbound)*8);
     54            initUsage("" + Integer.parseInt(inbound), "" + Integer.parseInt(outbound));
    3955        }
    4056        catch(Exception e) {
     
    4359            initSpeeds("100", "100");
    4460            initUsage("12", "12");
     61        }
     62    }
     63
     64    private void initUpdateTab() {
     65        //Set update policy
     66        String updatePolicy = UpdateHelper.getUpdatePolicy();
     67        if(updatePolicy.equals(UpdateHelper.NOTIFY_UPDATE_POLICY)) {
     68            updateButtonGroup.setSelected(updateInform.getModel(), true);
     69        }
     70        else if(updatePolicy.equals(UpdateHelper.DOWNLOAD_UPDATE_POLICY)) {
     71            updateButtonGroup.setSelected(updateDownload.getModel(), true);
     72        }
     73        else if(updatePolicy.equals(UpdateHelper.INSTALL_UPDATE_POLICY)) {
     74            updateButtonGroup.setSelected(updateDownloadRestart.getModel(), true);
     75        }
     76        else {
     77            System.out.println("desktopgui: no updates for you!");
     78        }
     79
     80        //Check if an update is available
     81        //TODO: move this method out of the routerconsole so desktopgui doesn't depend on routerconsole!!!
     82        if(NewsFetcher.getInstance(RouterHelper.getContext()).updateAvailable()) {
     83            updateNow.setVisible(true);
     84        }
     85        else {
     86            updateNow.setVisible(false);
    4587        }
    4688    }
     
    5597    private void initComponents() {
    5698
    57         buttonGroup1 = new javax.swing.ButtonGroup();
     99        updateButtonGroup = new javax.swing.ButtonGroup();
    58100        applyPanel = new javax.swing.JPanel();
    59101        cancel = new javax.swing.JToggleButton();
     
    241283        updateMethod.setName("updateMethod"); // NOI18N
    242284
    243         buttonGroup1.add(updateInform);
     285        updateButtonGroup.add(updateInform);
    244286        updateInform.setText(resourceMap.getString("updateInform.text")); // NOI18N
    245287        updateInform.setName("updateInform"); // NOI18N
    246288
    247         buttonGroup1.add(updateDownload);
     289        updateButtonGroup.add(updateDownload);
    248290        updateDownload.setText(resourceMap.getString("updateDownload.text")); // NOI18N
    249291        updateDownload.setName("updateDownload"); // NOI18N
    250292
    251         buttonGroup1.add(updateDownloadRestart);
     293        updateButtonGroup.add(updateDownloadRestart);
    252294        updateDownloadRestart.setText(resourceMap.getString("updateDownloadRestart.text")); // NOI18N
    253295        updateDownloadRestart.setName("updateDownloadRestart"); // NOI18N
     
    255297        checkUpdates.setText(resourceMap.getString("checkUpdates.text")); // NOI18N
    256298        checkUpdates.setName("checkUpdates"); // NOI18N
     299        checkUpdates.addActionListener(new java.awt.event.ActionListener() {
     300            public void actionPerformed(java.awt.event.ActionEvent evt) {
     301                checkUpdatesActionPerformed(evt);
     302            }
     303        });
    257304
    258305        updateNow.setText(resourceMap.getString("updateNow.text")); // NOI18N
    259306        updateNow.setName("updateNow"); // NOI18N
     307        updateNow.addActionListener(new java.awt.event.ActionListener() {
     308            public void actionPerformed(java.awt.event.ActionEvent evt) {
     309                updateNowActionPerformed(evt);
     310            }
     311        });
    260312
    261313        advancedUpdateConfig.setText(resourceMap.getString("advancedUpdateConfig.text")); // NOI18N
    262314        advancedUpdateConfig.setName("advancedUpdateConfig"); // NOI18N
     315        advancedUpdateConfig.addActionListener(new java.awt.event.ActionListener() {
     316            public void actionPerformed(java.awt.event.ActionEvent evt) {
     317                advancedUpdateConfigActionPerformed(evt);
     318            }
     319        });
    263320
    264321        javax.swing.GroupLayout updatesPanelLayout = new javax.swing.GroupLayout(updatesPanel);
     
    469526private void okMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okMouseClicked
    470527    saveSpeeds();
     528    saveUpdatePolicy();
    471529    this.dispose();
    472530}//GEN-LAST:event_okMouseClicked
     531
     532private void checkUpdatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkUpdatesActionPerformed
     533    long current = new Date().getTime();
     534    if(current < newsLastFetched + 5*60*1000) {
     535        return;
     536    }
     537    checkUpdates.setText("Checking for updates");
     538    checkUpdates.setEnabled(false);
     539    newsLastFetched = current;
     540    SwingWorker sw = new SwingWorker() {
     541
     542            @Override
     543            protected Object doInBackground() throws Exception {
     544                NewsFetcher.getInstance(RouterHelper.getContext()).fetchNews();
     545                return null;
     546            }
     547
     548            @Override
     549            protected void done() {
     550                checkUpdates.setText("Check for updates now");
     551                checkUpdates.setEnabled(true);
     552                if(NewsFetcher.getInstance(RouterHelper.getContext()).updateAvailable()) {
     553                    updateNow.setVisible(true);
     554                }
     555            }
     556
     557    };
     558}//GEN-LAST:event_checkUpdatesActionPerformed
     559
     560private void updateNowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateNowActionPerformed
     561    SwingWorker sw = new SwingWorker() {
     562
     563            @Override
     564            protected Object doInBackground() throws Exception {
     565                new net.i2p.router.web.UpdateHandler().update();
     566                return null;
     567            }
     568       
     569    };
     570    updateNow.setEnabled(false);
     571    updateNow.setText("Updating...");
     572    checkUpdates.setEnabled(false);
     573
     574}//GEN-LAST:event_updateNowActionPerformed
     575
     576private void advancedUpdateConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_advancedUpdateConfigActionPerformed
     577    try {
     578        Desktop.getDesktop().browse(new URI("http://127.0.0.1:7657/configupdate.jsp"));
     579    } catch (URISyntaxException ex) {
     580        Logger.getLogger(GeneralConfiguration.class.getName()).log(Level.SEVERE, null, ex);
     581    }
     582    catch (IOException ex) {
     583            Logger.getLogger(GeneralConfiguration.class.getName()).log(Level.SEVERE, null, ex);
     584    }
     585}//GEN-LAST:event_advancedUpdateConfigActionPerformed
    473586
    474587    protected void initUsage(String upload, String download) {
     
    514627    }
    515628
     629    protected void saveUpdatePolicy() {
     630        ButtonModel policyButton = updateButtonGroup.getSelection();
     631        if(policyButton.equals(updateInform.getModel())) {
     632            UpdateHandler.setUpdatePolicy(UpdateHelper.NOTIFY_UPDATE_POLICY);
     633        }
     634        else if(policyButton.equals(updateDownload.getModel())) {
     635            UpdateHandler.setUpdatePolicy(UpdateHelper.DOWNLOAD_UPDATE_POLICY);
     636        }
     637        else if(policyButton.equals(updateDownloadRestart.getModel())) {
     638            UpdateHandler.setUpdatePolicy(UpdateHelper.INSTALL_UPDATE_POLICY);
     639        }
     640    }
     641
    516642    // Variables declaration - do not modify//GEN-BEGIN:variables
    517643    private javax.swing.JPanel advancedPanel;
    518644    private javax.swing.JToggleButton advancedUpdateConfig;
    519645    private javax.swing.JPanel applyPanel;
    520     private javax.swing.ButtonGroup buttonGroup1;
    521646    private javax.swing.JToggleButton cancel;
    522647    private javax.swing.JToggleButton checkUpdates;
     
    538663    private javax.swing.JPanel tunnelPanel;
    539664    private javax.swing.JLabel tunnelsExplanation;
     665    private javax.swing.ButtonGroup updateButtonGroup;
    540666    private javax.swing.JRadioButton updateDownload;
    541667    private javax.swing.JRadioButton updateDownloadRestart;
     
    554680    public static final int KILOBIT = 0;
    555681    public static final int KILOBYTE = 1;
     682
     683    private long newsLastFetched = 0;
    556684}
  • apps/desktopgui/src/net/i2p/desktopgui/gui/Tray.java

    rb4336fde r3208b72  
    152152                RouterHandler.setStatus(RouterHandler.SHUTDOWN_GRACEFULLY);
    153153                long shutdownTime = RouterHelper.getGracefulShutdownTimeRemaining();
    154                 System.out.println(shutdownTime);
     154                System.out.println("Shutdowntime remaining: " + shutdownTime);
    155155                if(shutdownTime>0) {
    156156                    trayIcon.displayMessage("Shutting down...", "Shutdown time remaining: " + shutdownTime/1000 + " seconds."
  • build.xml

    rb4336fde r3208b72  
    525525        <echo message="Findbugs output stored in findbugs.xml" />
    526526    </target>
    527     <target name="buildWithDesktopgui" depends="buildrouter">
     527    <target name="buildWithDesktopgui" depends="buildrouter,builddepSmall">
    528528        <ant dir="apps/desktopgui" target="build_jar" />
    529529    </target>
  • history.txt

    rb4336fde r3208b72  
     12009-05-22 Mathiasdm
     2    * desktopgui:
     3      - Updating works in general config
     4      - Switched to Swingworker threads for improved responsiveness
     5
    162009-05-21 zzz
    27    * Router Watchdog:
Note: See TracChangeset for help on using the changeset viewer.