=== modified file 'dhis-live/pom.xml'
--- dhis-live/pom.xml 2010-10-08 08:18:53 +0000
+++ dhis-live/pom.xml 2010-11-29 15:11:43 +0000
@@ -1,232 +1,170 @@
-
- 4.0.0
- org.hisp.dhis
- dhis-live
- jar
- 1.0-SNAPSHOT
- DHIS Live
-
- http://maven.apache.org
-
-
- dhis2-live
- install
-
-
-
-
-
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin
-
-
-
- org.hisp.dhis.config
-
-
- generate
-
-
-
-
-
-
-
- maven-assembly-plugin
- 2.2-beta-3
-
-
- jar-with-dependencies
-
-
-
- org.hisp.dhis.TrayApp
-
-
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
-
-
- maven-compiler-plugin
- 2.0.2
-
-
- 1.6
- ${project.build.sourceEncoding}
-
-
-
-
-
- org.bluestemsoftware.open.maven.plugin
- launch4j-plugin
- 1.5.0.0
-
-
- default
- package
-
- launch4j
-
-
- true
- gui
- ${project.build.directory}/dhis2-live.exe
- dhis2-live.jar
- dhis2
- normal
- http://java.com/download
- http://dhis2.org
- false
- 512MB
- 1024MB
- false
-
- ${basedir}/util/launch4j/favicon.ico
-
-
- 1.6.0_14
-
- -XX:MaxPermSize=256M
-
-
-
- ${basedir}/util/launch4j/dhis2-splash.bmp
- false
- 12
- false
-
-
-
-
- embedded
- package
-
- launch4j
-
-
- true
- gui
- ${project.build.directory}/dhis2-live-embedded.exe
- dhis2-live.jar
- dhis2
- normal
- http://java.com/download
- http://dhis2.org
- false
- 512MB
- 1024MB
- false
-
- ${basedir}/util/launch4j/favicon.ico
-
-
- jre6
- 1.6.0_14
-
- -XX:MaxPermSize=256M
-
-
-
- ${basedir}/util/launch4j/dhis2-splash.bmp
- false
- 12
- false
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 2.2
-
- ${project.build.sourceEncoding}
-
-
-
-
-
-
- http://download.java.net/maven/2
- beans-binding
- default
- Repository for library Library[beans-binding]
-
-
-
-
- org.mortbay.jetty
- jetty
- 6.1.15
- jar
-
-
- org.mortbay.jetty
- jsp-2.1
- 6.1.14
-
-
- org.mortbay.jetty
- jetty-util
- 6.1.15
- jar
-
-
- jetty
- servlet-api
- 2.5-6.0.0
- jar
-
-
- commons-logging
- commons-logging
- 1.1
- compile
-
-
- avalon-framework
- avalon-framework
-
-
- logkit
- logkit
-
-
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.1.13
-
-
- org.jdesktop
- beansbinding
- 1.2.1
-
-
-
- UTF-8
-
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ 4.0.0
+ org.hisp.dhis
+ dhis-live
+ jar
+ 1.0-SNAPSHOT
+ DHIS Live
+
+ http://maven.apache.org
+
+
+ dhis2-live
+ install
+
+
+
+
+ maven-assembly-plugin
+ 2.2-beta-3
+
+
+ jar-with-dependencies
+
+
+
+ org.hisp.dhis.TrayApp
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ 2.0.2
+
+ true
+
+
+
+
+
+ org.bluestemsoftware.open.maven.plugin
+ launch4j-plugin
+ 1.5.0.0
+
+
+ default
+ package
+
+ launch4j
+
+
+ true
+ gui
+ ${project.build.directory}/dhis2-live.exe
+ dhis2-live.jar
+ dhis2
+ normal
+ http://java.com/download
+ http://dhis2.org
+ false
+ false
+
+ ${basedir}/util/launch4j/favicon.ico
+
+ dhis-live.mutex
+
+
+
+ 1.6.0_14
+
+
+ ${basedir}/util/launch4j/dhis2-splash.bmp
+ false
+ 10
+ false
+
+
+
+
+ embedded
+ package
+
+ launch4j
+
+
+ true
+ gui
+ ${project.build.directory}/dhis2-live-embedded.exe
+ dhis2-live.jar
+ dhis2
+ normal
+ http://java.com/download
+ http://dhis2.org
+ false
+ false
+
+ ${basedir}/util/launch4j/favicon.ico
+
+ dhis-live.mutex
+
+
+
+ jre6
+ 1.6.0_14
+
+
+ ${basedir}/util/launch4j/dhis2-splash.bmp
+ false
+ 10
+ false
+
+
+
+
+
+
+
+
+
+
+ org.mortbay.jetty
+ jetty
+ 6.1.25
+ jar
+
+
+ org.mortbay.jetty
+ jetty-util
+ 6.1.25
+ jar
+
+
+ jetty
+ servlet-api
+ 2.5-6.0.1
+ jar
+
+
+ commons-logging
+ commons-logging
+ 1.1
+ compile
+
+
+ avalon-framework
+ avalon-framework
+
+
+ logkit
+ logkit
+
+
+
+
+
-
=== removed file 'dhis-live/src/main/java/org/hisp/dhis/LiveMessagingService.java'
--- dhis-live/src/main/java/org/hisp/dhis/LiveMessagingService.java 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/LiveMessagingService.java 1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2004-2010, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.hisp.dhis;
-
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- *
- * @author Jason P. Pickering
- */
-public class LiveMessagingService
-{
-
- private static final Log log = LogFactory.getLog( TrayApp.class );
-
- private static final String defaultLanguage = "en";
-
- private static final String defaultCountry = "GB";
- private static final Locale defaultLocale = new Locale (defaultLanguage, defaultCountry);
- private static final String messageLocation = "messages/messages";
-
- private ResourceBundle getDefaultMessageBundle()
- {
- ResourceBundle messages;
- messages = ResourceBundle.getBundle(messageLocation, defaultLocale);
- return messages;
- }
-
- private ResourceBundle getMessageBundle(Locale currentLocale)
- {
- ResourceBundle messages;
- messages = getDefaultMessageBundle();
- log.debug( "Current locale set to " + currentLocale.toString() );
- try
- {
- messages = ResourceBundle.getBundle( messageLocation, currentLocale );
- } catch ( Exception e )
- {
- //problem loading the desired resource bundle fall back to default
- log.error( "The desired resource bundle could not be loaded." );
-
- }
- return messages;
- }
-
- public String getString( String messageName )
- {
- String currentLanguage = TrayApp.appConfig.getLocaleLanguage();
- String currentCountry = TrayApp.appConfig.getLocaleCountry();
- Locale currentLocale = new Locale(currentLanguage,currentCountry);
- ResourceBundle messages = getMessageBundle(currentLocale);
-
- String returnMessage = messageName;
- if ( messageName.isEmpty() | messageName == null )
- {
- returnMessage = "messageName not valid";
- return returnMessage;
- } else
- {
- if ( messages.containsKey( messageName ) )
- {
- returnMessage = messages.getString( messageName );
-
- if ( returnMessage == null )
- {
- returnMessage = "Message not found";
- }
- } else
- {
- returnMessage = getDefaultMessageBundle().getString( messageName );
- }
- return returnMessage;
- }
- }
-}
=== removed file 'dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form'
--- dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form 2010-09-19 02:08:43 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form 1970-01-01 00:00:00 +0000
@@ -1,612 +0,0 @@
-
-
-
=== removed file 'dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java'
--- dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java 2010-09-19 02:08:43 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java 1970-01-01 00:00:00 +0000
@@ -1,691 +0,0 @@
-/*
- * Copyright (c) 2004-2010, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.hisp.dhis;
-
-
-import java.awt.Component;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import javax.swing.JFileChooser;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.net.URL;
-import java.util.Vector;
-import java.util.jar.JarFile;
-import javax.swing.JComboBox;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.plaf.basic.BasicComboBoxRenderer;
-import javax.swing.table.DefaultTableCellRenderer;
-import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.ConnectionTypes.ConnectionType;
-import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.DatabaseConnections.Connection;
-
-public class SettingsWindow extends JFrame
-{
-
- private static final LiveMessagingService messageService = new LiveMessagingService();
-
- private int selectedLang;
-
- private Vector countryVect = new Vector();
-
- private JComboBox connTypesCombo;
-
- public SettingsWindow()
- {
- try
- {
- UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
- } catch ( Exception ex )
- {
- JOptionPane.showMessageDialog( null, ex.getMessage() );
- }
- Vector connTypesVect = new Vector( TrayApp.databaseConfig.getConnectionTypes().getConnectionType() );
- connTypesCombo = new JComboBox( connTypesVect );
- connTypesCombo.setRenderer( new ConnTypesComboRenderer() );
- initComponents();
- langCombo.setModel( new DefaultComboBoxModel( getSupportedLanguages() ) );
- langCombo.setSelectedIndex( selectedLang );
- setLocationRelativeTo( null );
- }
-
- class ConnTypesComboRenderer extends BasicComboBoxRenderer
- {
-
- @Override
- public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus )
- {
- super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
- if ( value != null )
- {
- ConnectionType item = (ConnectionType) value;
- setText( item.getId() );
- }
- if ( index == -1 )
- {
- ConnectionType item = (ConnectionType) value;
- setText((value == null) ? "" : item.getId());
- }
- return this;
- }
- }
-
- class ConnTypesCellRenderer extends DefaultTableCellRenderer
- {
- @Override
- public void setValue( Object value )
- {
- ConnectionType item = (ConnectionType) value;
- setText((value == null) ? "" : item.getId());
- }
- }
-
- private String getJarfileName()
- {
- // Get the location of the jar file and the jar file name
- URL outputURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
- String[] loc = outputURL.toString().split( "\\/" );
- String jarFilename;
- if ( outputURL.toString().contains( ".jar" ) )
- {
- jarFilename = TrayApp.getInstallDir() + "/" + loc[loc.length - 1];
- } else
- {
- String outputString = outputURL.toString();
- String[] parseString;
- int index1 = outputString.indexOf( ":" );
- int index2 = outputString.lastIndexOf( ":" );
- if ( index1 != index2 ) // Windows/DOS uses C: naming convention
- {
- parseString = outputString.split( "file:/" );
- } else
- {
- parseString = outputString.split( "file:" );
- }
- jarFilename = parseString[1];
- }
- return jarFilename;
- }
-
- private Vector getSupportedLanguages()
- {
- Vector supportedLanguages = new Vector();
- try
- {
- File file = new File( getJarfileName() );
- if ( file.exists() )
- {
- if ( file.getName().contains( ".jar" ) )
- {
- JarFile jarFile = new JarFile( file );
- Enumeration entries = jarFile.entries();
- int i = 0;
- while ( entries.hasMoreElements() )
- {
- JarEntry entry = (JarEntry) entries.nextElement();
- if ( entry.getName().startsWith( "messages" ) && entry.getName().endsWith( ".properties" ) )
- {
- String entryName = entry.getName();
- String lang = entryName.substring( 18, entryName.length() - 11 );
- String arr[] = lang.split( "\\_" );
- if ( arr.length > 1 )
- {
- countryVect.add( lang );
- if ( TrayApp.appConfig.getLocaleLanguage().equals( arr[0] ) )
- {
- selectedLang = i;
- }
- supportedLanguages.add( arr[0] );
- } else
- {
- if ( TrayApp.appConfig.getLocaleLanguage().equals( lang ) )
- {
- selectedLang = i;
- }
- supportedLanguages.add( lang );
- }
- i++;
- }
- }
- } else
- {
- File dir = new File( file, "messages" );
- String[] list = dir.list( new FilenameFilter()
- {
-
- @Override
- public boolean accept( File dir, String name )
- {
- String lowercase = name.toLowerCase();
- if ( lowercase.startsWith( "messages" ) && lowercase.endsWith( ".properties" ) )
- {
- return true;
- } else
- {
- return false;
- }
- }
- } );
- for ( int i = 0; i < list.length; i++ )
- {
- String lang = list[i].substring( 9, list[i].length() - 11 );
- String arr[] = lang.split( "\\_" );
- if ( arr.length > 1 )
- {
- countryVect.add( lang );
- if ( TrayApp.appConfig.getLocaleLanguage().equals( arr[0] ) )
- {
- selectedLang = i;
- }
- supportedLanguages.add( arr[0] );
- } else
- {
- if ( TrayApp.appConfig.getLocaleLanguage().equals( lang ) )
- {
- selectedLang = i;
- }
- supportedLanguages.add( lang );
- }
- }
- }
- }
- } catch ( IOException ex )
- {
- ex.printStackTrace();
- }
- return supportedLanguages;
- }
-
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
- bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
-
- config = TrayApp.config;
- appConfigPanel = new javax.swing.JPanel();
- portLabel = new javax.swing.JLabel();
- portField = new javax.swing.JTextField();
- hostLabel = new javax.swing.JLabel();
- hostField = new javax.swing.JTextField();
- browserPathLabel = new javax.swing.JLabel();
- browserPathField = new javax.swing.JTextField();
- browserPathButton = new javax.swing.JButton();
- langLabel = new javax.swing.JLabel();
- countryLabel = new javax.swing.JLabel();
- maxSizeLabel = new javax.swing.JLabel();
- maxSizeField = new javax.swing.JTextField();
- maxSizeDefaultLabel = new javax.swing.JLabel();
- unitLabel = new javax.swing.JLabel();
- langCombo = new javax.swing.JComboBox();
- countryCombo = new javax.swing.JComboBox();
- databaseConfigPanel = new javax.swing.JPanel();
- connTypePanel = new javax.swing.JPanel();
- connTypePane = new javax.swing.JScrollPane();
- connTypeTable = new javax.swing.JTable();
- connTypeAddButton = new javax.swing.JButton();
- connTypeDelButton = new javax.swing.JButton();
- connPanel = new javax.swing.JPanel();
- connPane = new javax.swing.JScrollPane();
- connTable = new javax.swing.JTable();
- connAddButton = new javax.swing.JButton();
- connDelButton = new javax.swing.JButton();
- saveButton = new javax.swing.JButton();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle(messageService.getString("settings.windowtitle"));
- setAlwaysOnTop(true);
- setResizable(false);
-
- appConfigPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.appconfig")));
-
- portLabel.setText(messageService.getString("settings.port"));
-
- org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.port}"), portField, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "portBinding");
- bindingGroup.addBinding(binding);
-
- hostLabel.setText(messageService.getString("settings.host"));
-
- binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.host}"), hostField, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "hostBinding");
- bindingGroup.addBinding(binding);
-
- browserPathLabel.setText(messageService.getString("settings.browserpath"));
-
- binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.preferredBrowser}"), browserPathField, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "browserPathBinding");
- bindingGroup.addBinding(binding);
-
- browserPathButton.setText(messageService.getString("settings.browse"));
- browserPathButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- browserPathButtonActionPerformed(evt);
- }
- });
-
- langLabel.setText(messageService.getString("settings.language"));
-
- countryLabel.setText(messageService.getString("settings.country"));
-
- maxSizeLabel.setText(messageService.getString("settings.maxformsize"));
-
- binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.maxFormContentSize}"), maxSizeField, org.jdesktop.beansbinding.BeanProperty.create("text"));
- bindingGroup.addBinding(binding);
-
- maxSizeDefaultLabel.setText(messageService.getString("settings.restartinfo"));
-
- unitLabel.setText(messageService.getString("settings.bytes"));
-
- binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.localeLanguage}"), langCombo, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
- bindingGroup.addBinding(binding);
-
- langCombo.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- langComboActionPerformed(evt);
- }
- });
-
- binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${appConfiguration.localeCountry}"), countryCombo, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
- bindingGroup.addBinding(binding);
-
- javax.swing.GroupLayout appConfigPanelLayout = new javax.swing.GroupLayout(appConfigPanel);
- appConfigPanel.setLayout(appConfigPanelLayout);
- appConfigPanelLayout.setHorizontalGroup(
- appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addComponent(browserPathLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(browserPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(browserPathButton)
- .addGap(8, 8, 8))
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, appConfigPanelLayout.createSequentialGroup()
- .addComponent(langLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(langCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, appConfigPanelLayout.createSequentialGroup()
- .addComponent(hostLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(10, 10, 10)
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(countryLabel)
- .addComponent(portLabel))
- .addGap(23, 23, 23)
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(countryCombo, 0, 0, Short.MAX_VALUE)
- .addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(maxSizeDefaultLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addComponent(maxSizeLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(maxSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(unitLabel)))
- .addContainerGap())))
- );
- appConfigPanelLayout.setVerticalGroup(
- appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(maxSizeLabel)
- .addComponent(hostLabel)
- .addComponent(portLabel)
- .addComponent(unitLabel)
- .addComponent(maxSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addGap(1, 1, 1)
- .addComponent(maxSizeDefaultLabel))
- .addGroup(appConfigPanelLayout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(langLabel)
- .addComponent(countryLabel)
- .addComponent(langCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(countryCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGap(18, 18, 18)
- .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(browserPathLabel)
- .addComponent(browserPathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(browserPathButton))
- .addContainerGap())
- );
-
- databaseConfigPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.dbconfig")));
-
- connTypePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.conntypes")));
-
- connTypeTable.setBackground(new java.awt.Color(212, 208, 200));
- connTypeTable.setEnabled(false);
- connTypeTable.getTableHeader().setReorderingAllowed(false);
-
- org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.connectionTypes.connectionType}");
- org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, eLProperty, connTypeTable);
- org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
- columnBinding.setColumnName("Id");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${dialect}"));
- columnBinding.setColumnName("Dialect");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${driverClass}"));
- columnBinding.setColumnName("Driver Class");
- columnBinding.setColumnClass(String.class);
- bindingGroup.addBinding(jTableBinding);
- jTableBinding.bind();
- connTypePane.setViewportView(connTypeTable);
- connTypeTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
- connTypeTable.getColumnModel().getColumn(0).setHeaderValue(messageService.getString("ID"));
-
- connTypeAddButton.setText(messageService.getString("settings.add"));
- connTypeAddButton.setEnabled(false);
- connTypeAddButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- connTypeAddButtonActionPerformed(evt);
- }
- });
-
- connTypeDelButton.setText(messageService.getString("settings.remove"));
- connTypeDelButton.setEnabled(false);
- connTypeDelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- connTypeDelButtonActionPerformed(evt);
- }
- });
-
- javax.swing.GroupLayout connTypePanelLayout = new javax.swing.GroupLayout(connTypePanel);
- connTypePanel.setLayout(connTypePanelLayout);
- connTypePanelLayout.setHorizontalGroup(
- connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(connTypePanelLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(connTypePane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connTypePanelLayout.createSequentialGroup()
- .addComponent(connTypeAddButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(connTypeDelButton)))
- .addContainerGap())
- );
- connTypePanelLayout.setVerticalGroup(
- connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(connTypePanelLayout.createSequentialGroup()
- .addComponent(connTypePane, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(connTypeAddButton)
- .addComponent(connTypeDelButton))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
-
- connPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.connections")));
-
- connTable.getTableHeader().setReorderingAllowed(false);
-
- eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.databaseConnections.connection}");
- jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, eLProperty, connTable);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
- columnBinding.setColumnName("ID");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${type}"));
- columnBinding.setColumnName("Type");
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${name}"));
- columnBinding.setColumnName("Name");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${URL}"));
- columnBinding.setColumnName("URL");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${userName}"));
- columnBinding.setColumnName("Username");
- columnBinding.setColumnClass(String.class);
- columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${password}"));
- columnBinding.setColumnName("Password");
- columnBinding.setColumnClass(String.class);
- bindingGroup.addBinding(jTableBinding);
- jTableBinding.bind();
- connPane.setViewportView(connTable);
- connTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
- connTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(connTypesCombo));
- connTable.getColumnModel().getColumn(1).setCellRenderer(new ConnTypesCellRenderer());
- connTable.getColumnModel().getColumn(3).setPreferredWidth(60);
-
- connAddButton.setText(messageService.getString("settings.add"));
- connAddButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- connAddButtonActionPerformed(evt);
- }
- });
-
- connDelButton.setText(messageService.getString("settings.remove"));
- connDelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- connDelButtonActionPerformed(evt);
- }
- });
-
- javax.swing.GroupLayout connPanelLayout = new javax.swing.GroupLayout(connPanel);
- connPanel.setLayout(connPanelLayout);
- connPanelLayout.setHorizontalGroup(
- connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connPanelLayout.createSequentialGroup()
- .addContainerGap(401, Short.MAX_VALUE)
- .addComponent(connAddButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(connDelButton)
- .addContainerGap())
- .addGroup(connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(connPanelLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(connPane, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
- .addContainerGap()))
- );
- connPanelLayout.setVerticalGroup(
- connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connPanelLayout.createSequentialGroup()
- .addContainerGap(97, Short.MAX_VALUE)
- .addGroup(connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(connDelButton)
- .addComponent(connAddButton))
- .addContainerGap())
- .addGroup(connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(connPanelLayout.createSequentialGroup()
- .addComponent(connPane, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(37, Short.MAX_VALUE)))
- );
-
- javax.swing.GroupLayout databaseConfigPanelLayout = new javax.swing.GroupLayout(databaseConfigPanel);
- databaseConfigPanel.setLayout(databaseConfigPanelLayout);
- databaseConfigPanelLayout.setHorizontalGroup(
- databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, databaseConfigPanelLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(connPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(connTypePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
- );
- databaseConfigPanelLayout.setVerticalGroup(
- databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(databaseConfigPanelLayout.createSequentialGroup()
- .addComponent(connTypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(connPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addContainerGap())
- );
-
- saveButton.setText(messageService.getString("settings.saveclose"));
- saveButton.setToolTipText(messageService.getString("settings.saveclose"));
- saveButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- saveButtonActionPerformed(evt);
- }
- });
-
- 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()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(databaseConfigPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(appConfigPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(saveButton))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(appConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(databaseConfigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(saveButton)
- .addContainerGap())
- );
-
- bindingGroup.bind();
-
- pack();
- }// //GEN-END:initComponents
-
- private void saveButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveButtonActionPerformed
- {//GEN-HEADEREND:event_saveButtonActionPerformed
- TrayApp.getInstance().writeConfigToFile();
- TrayApp.getInstance().updateDatabaseMenus();
- this.dispose();
- }//GEN-LAST:event_saveButtonActionPerformed
-
- private void browserPathButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_browserPathButtonActionPerformed
- {//GEN-HEADEREND:event_browserPathButtonActionPerformed
- final JFileChooser fc = new JFileChooser();
- fc.setFileSelectionMode( JFileChooser.FILES_ONLY );
- int returnVal = fc.showOpenDialog( this );
- if ( returnVal == JFileChooser.APPROVE_OPTION )
- {
- File file = fc.getSelectedFile();
- browserPathField.setText( file.getAbsolutePath() );
- }
- }//GEN-LAST:event_browserPathButtonActionPerformed
-
- private void connTypeAddButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connTypeAddButtonActionPerformed
- {//GEN-HEADEREND:event_connTypeAddButtonActionPerformed
- TrayApp.databaseConfig.getConnectionTypes().getConnectionType().add( new ConnectionType() );
- bindingGroup.unbind();
- bindingGroup.bind();
- }//GEN-LAST:event_connTypeAddButtonActionPerformed
-
- private void connAddButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connAddButtonActionPerformed
- {//GEN-HEADEREND:event_connAddButtonActionPerformed
- TrayApp.databaseConfig.getDatabaseConnections().getConnection().add( new Connection() );
- bindingGroup.unbind();
- bindingGroup.bind();
- }//GEN-LAST:event_connAddButtonActionPerformed
-
- private void connTypeDelButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connTypeDelButtonActionPerformed
- {//GEN-HEADEREND:event_connTypeDelButtonActionPerformed
- if ( connTypeTable.getSelectedRow() != -1 )
- {
- TrayApp.databaseConfig.getConnectionTypes().getConnectionType().remove( connTypeTable.getSelectedRow() );
- }
- bindingGroup.unbind();
- bindingGroup.bind();
- }//GEN-LAST:event_connTypeDelButtonActionPerformed
-
- private void connDelButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connDelButtonActionPerformed
- {//GEN-HEADEREND:event_connDelButtonActionPerformed
- if ( connTable.getSelectedRow() != -1 )
- {
- TrayApp.databaseConfig.getDatabaseConnections().getConnection().remove( connTable.getSelectedRow() );
- }
- bindingGroup.unbind();
- bindingGroup.bind();
- }//GEN-LAST:event_connDelButtonActionPerformed
-
- private void langComboActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_langComboActionPerformed
- {//GEN-HEADEREND:event_langComboActionPerformed
- Vector vect = new Vector();
- for ( int i = 0; i < countryVect.size(); i++ )
- {
- String item = countryVect.get( i ).toString();
- if ( item.split( "\\_" )[0].equals( langCombo.getSelectedItem().toString() ) )
- {
- vect.add( item.split( "\\_" )[1] );
- }
- }
- if ( vect.isEmpty() )
- {
- vect.add( "" );
- }
- countryCombo.setModel( new DefaultComboBoxModel( vect ) );
- }//GEN-LAST:event_langComboActionPerformed
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel appConfigPanel;
- private javax.swing.JButton browserPathButton;
- private javax.swing.JTextField browserPathField;
- private javax.swing.JLabel browserPathLabel;
- private org.hisp.dhis.config.ConfigType config;
- private javax.swing.JButton connAddButton;
- private javax.swing.JButton connDelButton;
- private javax.swing.JScrollPane connPane;
- private javax.swing.JPanel connPanel;
- private javax.swing.JTable connTable;
- private javax.swing.JButton connTypeAddButton;
- private javax.swing.JButton connTypeDelButton;
- private javax.swing.JScrollPane connTypePane;
- private javax.swing.JPanel connTypePanel;
- private javax.swing.JTable connTypeTable;
- private javax.swing.JComboBox countryCombo;
- private javax.swing.JLabel countryLabel;
- private javax.swing.JPanel databaseConfigPanel;
- private javax.swing.JTextField hostField;
- private javax.swing.JLabel hostLabel;
- private javax.swing.JComboBox langCombo;
- private javax.swing.JLabel langLabel;
- private javax.swing.JLabel maxSizeDefaultLabel;
- private javax.swing.JTextField maxSizeField;
- private javax.swing.JLabel maxSizeLabel;
- private javax.swing.JTextField portField;
- private javax.swing.JLabel portLabel;
- private javax.swing.JButton saveButton;
- private javax.swing.JLabel unitLabel;
- private org.jdesktop.beansbinding.BindingGroup bindingGroup;
- // End of variables declaration//GEN-END:variables
-}
=== modified file 'dhis-live/src/main/java/org/hisp/dhis/TrayApp.java'
--- dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2010-09-18 21:17:38 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2010-11-29 15:11:43 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2010, University of Oslo
+ * Copyright (c) 2004-2009, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,46 +24,27 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
package org.hisp.dhis;
-
import java.awt.AWTException;
import java.awt.Desktop;
-import java.awt.EventQueue;
import java.awt.Image;
-import java.awt.Menu;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.util.List;
-import java.util.Properties;
+
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.config.ConfigType;
-import org.hisp.dhis.config.ConfigType.AppConfiguration;
-import org.hisp.dhis.config.ConfigType.DatabaseConfiguration;
-import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.ConnectionTypes.ConnectionType;
-import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.DatabaseConnections.Connection;
import org.mortbay.component.LifeCycle;
/**
@@ -72,373 +53,153 @@
public class TrayApp
implements LifeCycle.Listener
{
-
private static final Log log = LogFactory.getLog( TrayApp.class );
private static final String CONFIG_DIR = "/conf";
-
- private static final String CONFIG_FILE_NAME = "/conf/config.xml";
-
- private static final String CONFIG_DEFAULT = "/defaultConfig.xml";
-
private static final String STOPPED_ICON = "/icons/stopped.png";
-
- private static final String STARTING_ICON = "/icons/starting.gif";
-
+ private static final String STARTING_ICON = "/icons/starting.png";
private static final String FAILED_ICON = "/icons/failed.png";
-
private static final String RUNNING_ICON = "/icons/running.png";
-
- protected static LiveMessagingService messageService = new LiveMessagingService();
-
- private static TrayApp instance;
-
+ private static final String CMD_OPEN = "Open DHIS 2 Live";
+ private static final String CMD_EXIT = "Exit";
+
private WebAppServer appServer;
private TrayIcon trayIcon;
- private SettingsWindow settingsWindow;
-
- private JAXBElement configElement;
-
- private Menu databaseMenu;
-
- public static ConfigType config;
-
- public static DatabaseConfiguration databaseConfig;
-
- public static AppConfiguration appConfig;
-
- public static String installDir;
+ private String installDir;
// -------------------------------------------------------------------------
// Main method
// -------------------------------------------------------------------------
+
public static void main( String[] args )
+ throws Exception
{
log.info( "Environment variable DHIS2_HOME: " + System.getenv( "DHIS2_HOME" ) );
- EventQueue.invokeLater( new Runnable()
+ if ( !SystemTray.isSupported() )
{
+ String message = "SystemTray not supported on this platform";
+ JOptionPane.showMessageDialog( (JFrame) null, message );
+ System.exit( 0 );
+ }
- @Override
- public void run()
- {
- if ( !SystemTray.isSupported() )
- {
- JOptionPane.showMessageDialog( (JFrame) null, messageService.getString( "dialogbox.unsupportedPlatform" ) );
- System.exit( 0 );
- } else
- {
- try
- {
- TrayApp trayApp = TrayApp.getInstance();
- trayApp.init();
- } catch ( Exception ex )
- {
- log.fatal( "TrayApp Initialization failure", ex );
- JOptionPane.showMessageDialog( (JFrame) null, messageService.getString( "dialogbox.initFailure" ) );
- System.exit( 0 );
- }
- }
- }
- } );
+ new TrayApp();
}
- /**
- * TrayApp is singleton - hide constructor
- * Loads all the configurations of the application
- */
- private TrayApp()
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public TrayApp()
+ throws Exception
{
log.info( "Initialising DHIS 2 Live..." );
+
installDir = getInstallDir();
+
if ( installDir == null )
{
+ log.info( "jar not installed, setting installdir to DHIS2_HOME: " + System.getenv( "DHIS2_HOME" ) );
installDir = System.getenv( "DHIS2_HOME" );
- if ( installDir == null )
- {
- log.fatal( "Neither DHIS Live Jar nor DHIS2_HOME could be found." );
- JOptionPane.showMessageDialog( (JFrame) null, messageService.getString( "dialogbox.initFailure" ) );
- System.exit( 0 );
- } else
- {
- log.info( "jar not installed, setting installdir to DHIS2_HOME: " + System.getenv( "DHIS2_HOME" ) );
- installDir = System.getenv( "DHIS2_HOME" );
- }
- }
-
- InputStream configStream = null;
- try
- {
- configStream = new java.io.FileInputStream( installDir + CONFIG_FILE_NAME );
- readConfigFromStream( configStream );
- } catch ( FileNotFoundException ex )
- {
- log.info( "Can't locate external config - falling back to default" );
- configStream = TrayApp.class.getResourceAsStream( CONFIG_DEFAULT );
- readConfigFromStream( configStream );
- writeConfigToFile();
- try
- {
- configStream = new java.io.FileInputStream( installDir + CONFIG_FILE_NAME );
- } catch ( FileNotFoundException fnfex )
- {
- log.info( "Can't locate external config - falling back to default", fnfex );
- JOptionPane.showMessageDialog( null, "Unexpected Error", "File Error", JOptionPane.ERROR_MESSAGE );
- System.exit( 1 );
- }
- }
- databaseConfig = config.getDatabaseConfiguration();
- appConfig = config.getAppConfiguration();
- log.info( "Locale: " + appConfig.getLocaleLanguage() + ":" + appConfig.getLocaleCountry() );
-
- // get the selected database
- Connection conn = (Connection) databaseConfig.getDatabaseConnections().getSelected();
- log.info( "Selected db: " + conn.getName() + "; " + conn.getUserName() + ":" + conn.getPassword() + " " + conn.getURL() );
+ }
System.setProperty( "dhis2.home", installDir + CONFIG_DIR );
System.setProperty( "jetty.home", installDir );
- System.setProperty( "birt.home", installDir + WebAppServer.BIRT_DIR );
- System.setProperty( "birt.context.path", WebAppServer.BIRT_CONTEXT_PATH );
-
- writeHibernateProperties();
- }
-
- public static TrayApp getInstance()
- {
- if ( instance == null )
- {
- instance = new TrayApp();
- }
- return instance;
- }
-
- public void init() throws AWTException, InterruptedException
- {
+
SystemTray tray = SystemTray.getSystemTray();
+
Image image = createImage( STOPPED_ICON, "tray icon" );
+
PopupMenu popup = new PopupMenu();
-
- //
- MenuItem openItem = new MenuItem( messageService.getString( "menuitem.open" ) );
- openItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- launchBrowser();
- }
- } );
+ MenuItem openItem = new MenuItem( CMD_OPEN );
+ MenuItem exitItem = new MenuItem( CMD_EXIT );
popup.add( openItem );
- //
-
- //
- databaseMenu = new Menu( messageService.getString( "menuitem.database" ) );
- updateDatabaseMenus();
- popup.add( databaseMenu );
- //
-
- //
- MenuItem settingsItem = new MenuItem( messageService.getString( "menuitem.settings" ) );
- settingsItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- if ( settingsWindow!= null && settingsWindow.isVisible() )
- {
- settingsWindow.dispose();
- }
- settingsWindow = new SettingsWindow();
- settingsWindow.setVisible( true );
- }
- } );
- popup.add( settingsItem );
- //
-
- //
- MenuItem exitItem = new MenuItem( messageService.getString( "menuitem.exit" ) );
- exitItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- shutdown();
- }
- } );
popup.add( exitItem );
- //
trayIcon = new TrayIcon( image, "DHIS 2 Live", popup );
trayIcon.setImageAutoSize( true );
- tray.add( trayIcon );
-
- new Thread( new Runnable()
- {
- @Override
- public void run()
- {
- appServer = new WebAppServer();
- try
- {
- appServer.init();
- } catch ( Exception e )
- {
- log.fatal( "Application server could not be initialized" );
- }
- try
- {
- appServer.start();
- } catch ( Exception e )
- {
- log.fatal( "Application server could not be started" );
- }
- }
- } ).start();
- }
-
- public void updateDatabaseMenus()
- {
- databaseMenu.removeAll();
-
- MenuItem blankItem = new MenuItem( messageService.getString( "menuitem.blank" ) );
- blankItem.addActionListener( new ActionListener()
- {
- @Override
+
+ ActionListener listener = new ActionListener()
+ {
public void actionPerformed( ActionEvent e )
{
- String s = (String) JOptionPane.showInputDialog( null, "menuitem.dbname", "Blank DB",
- JOptionPane.QUESTION_MESSAGE );
- Connection conn = new Connection();
- conn.setId( s );
- conn.setName( s );
- conn.setType( config.getDatabaseConfiguration().getConnectionTypes().getConnectionType().get( 0 ) );
- conn.setUserName( s );
- conn.setURL( "jdbc:h2:./database/" + s + ";AUTO_SERVER=TRUE" );
- databaseConfig.getDatabaseConnections().getConnection().add( conn );
- databaseConfig.getDatabaseConnections().setSelected( conn );
- writeConfigToFile();
- writeHibernateProperties();
- new Thread( new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- appServer.stop();
- appServer.start();
- } catch ( Exception ex )
- {
- log.error( "Error restarting jetty server: ", ex );
- }
- }
- } ).start();
- MenuItem newItem = new MenuItem( s );
- newItem.addActionListener( new ActionListener()
- {
-
- @Override
- public void actionPerformed( ActionEvent e )
- {
- new Thread( new Runnable()
- {
-
- @Override
- public void run()
- {
- try
- {
- appServer.stop();
- appServer.start();
- } catch ( Exception ex )
- {
- log.error( "Error restarting jetty server: ", ex );
- }
- }
- } ).start();
- }
- } );
- databaseMenu.add( newItem );
- }
- } );
- databaseMenu.add( blankItem );
- databaseMenu.addSeparator();
-
- List dbConns = (List) config.getDatabaseConfiguration().getDatabaseConnections().getConnection();
- for ( final Connection dbConn : dbConns )
- {
- MenuItem connItem = new MenuItem( dbConn.getName() );
- connItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent evt )
- {
- config.getDatabaseConfiguration().getDatabaseConnections().setSelected( dbConn );
- writeConfigToFile();
- writeHibernateProperties();
- new Thread( new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- appServer.stop();
- appServer.start();
- } catch ( Exception ex )
- {
- log.error( "Error restarting jetty server: ", ex );
- }
- }
- } ).start();
- }
- } );
- databaseMenu.add( connItem );
+ String cmd = e.getActionCommand();
+
+ if ( cmd.equals( CMD_OPEN ) )
+ {
+ launchBrowser();
+ }
+ else if ( cmd.equals( CMD_EXIT ) )
+ {
+ shutdown();
+ }
+ };
+ };
+
+ openItem.addActionListener( listener );
+ exitItem.addActionListener( listener );
+
+ try
+ {
+ tray.add( trayIcon );
+ }
+ catch ( AWTException ex )
+ {
+ log.warn( "Oops: " + ex.toString() );
+ }
+
+ appServer = new WebAppServer();
+ appServer.init( installDir, this );
+
+ try
+ {
+ appServer.start();
+ }
+ catch ( Exception ex )
+ {
+ String message = "Web server failed to start: \n" + ex.toString();
+ JOptionPane.showMessageDialog( (JFrame) null, message );
}
}
// -------------------------------------------------------------------------
// Listener implementation
// -------------------------------------------------------------------------
- @Override
+
public void lifeCycleFailure( LifeCycle arg0, Throwable arg1 )
{
log.warn( "Lifecycle: server failed" );
trayIcon.setImage( createImage( FAILED_ICON, "Running icon" ) );
- JOptionPane.showMessageDialog( (JFrame) null, messageService.getString( "dialogbox.webserverFailure" ) );
+ String message = "Web server failed to start - see logs for details";
+ JOptionPane.showMessageDialog( (JFrame) null, message );
shutdown();
}
- @Override
public void lifeCycleStarted( LifeCycle arg0 )
{
log.info( "Lifecycle: server started" );
- trayIcon.displayMessage( messageService.getString( "notification.started" ), messageService.getString( "notification.startedDetails" ) + " " + getUrl() + ".",
+ trayIcon.displayMessage( "Started", "DHIS 2 is running. Your browser will\n be pointed to " + getUrl() + ".",
TrayIcon.MessageType.INFO );
- trayIcon.setToolTip( messageService.getString( "tooltip.running" ) );
- trayIcon.setImage( createImage( RUNNING_ICON, "Running icon" ) );
+ trayIcon.setToolTip( "DHIS 2 Server running" );
+ trayIcon.setImage( createImage( RUNNING_ICON, "Running icon" ) );
launchBrowser();
-
}
- @Override
public void lifeCycleStarting( LifeCycle arg0 )
{
log.info( "Lifecycle: server starting" );
- trayIcon.displayMessage( messageService.getString( "notification.starting" ), messageService.getString( "notification.startingDetails" ), TrayIcon.MessageType.INFO );
+ trayIcon.displayMessage( "Starting", "DHIS 2 is starting.\nPlease be patient.", TrayIcon.MessageType.INFO );
trayIcon.setImage( createImage( STARTING_ICON, "Starting icon" ) );
}
- @Override
public void lifeCycleStopped( LifeCycle arg0 )
{
log.info( "Lifecycle: server stopped" );
- trayIcon.displayMessage( messageService.getString( "notification.stopped" ), messageService.getString( "notification.stoppedDetails" ), TrayIcon.MessageType.INFO );
+ trayIcon.displayMessage( "Stopped", "DHIS 2 has stopped.", TrayIcon.MessageType.INFO );
trayIcon.setImage( createImage( STOPPED_ICON, "Running icon" ) );
}
- @Override
public void lifeCycleStopping( LifeCycle arg0 )
{
log.info( "Lifecycle: server stopping" );
@@ -447,6 +208,7 @@
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
+
/**
* Returns the URL where the application can be accessed.
*
@@ -454,113 +216,24 @@
*/
private String getUrl()
{
- return "http://" + appConfig.getHost() + ":" + appConfig.getPort();
- }
-
- /**
- * Reads the config file for the path of the preferred browser
- *
- * @return the path to the default browser
- */
- private String defaultPreferredBrowserPath()
- {
- String preferredBrowserPath = appConfig.getPreferredBrowser();
-
- if ( preferredBrowserPath.length() > 0 )
- {
- try
- {
- log.debug( "Preferred browser path read from config: " + preferredBrowserPath );
-
- boolean browserExists = new File( preferredBrowserPath ).exists();
- if ( !browserExists )
- {
- preferredBrowserPath = "";
- log.warn( "Preferred browser could not be found." );
- }
- } catch ( Exception e )
- {
- log.warn( "There was a problem loading the preferred browser from the config file." );
- }
-
- log.info( "Preferred browser path: " + preferredBrowserPath );
- }
-
- return preferredBrowserPath;
- }
-
+ return "http://localhost:" + appServer.getConnectorPort();
+ }
+
/**
* Launches the application in the default browser.
*/
private void launchBrowser()
{
- String preferredBrowserPath = defaultPreferredBrowserPath();
-
- if ( preferredBrowserPath.length() > 0 )
- {
- try
- { //if the preferred browser has not been defined and appears to be valid
- launchPreferredBrowser();
- } catch ( Exception ex )
- {
- log.warn( "Couldn't open preferred browser. Will attempt to use default browser. " + ex );
- }
- } else
- {
- try
- {
- launchDefaultBrowser();
- } catch ( Exception e )
- {
- log.error( "Could not open any browser" + e );
- }
- }
- }
-
- /**
- * Launches the application in the custom embedded browser.
- * The path of which is given in the config.xml in the
- * tag
- */
- private void launchPreferredBrowser()
- {
- String preferredBrowserPath = defaultPreferredBrowserPath();
-
- if ( preferredBrowserPath != null )
- {
- String thisurl = getUrl();
- log.debug( "About to open " + thisurl + " with " + preferredBrowserPath );
- String openPrefBrowser = ( preferredBrowserPath + " " + thisurl );
- //try and launch the prefered browser
- try
- {
- Runtime rt = Runtime.getRuntime();
- rt.exec( openPrefBrowser );
- } catch ( IOException e )
- {
- log.error( "There was a problem opening the preferred browser. " + e );
- }
- }
- else
- {
- launchDefaultBrowser();
- }
- }
-
- /**
- * Launches the default browser to open the URL
- */
- private void launchDefaultBrowser()
- {
try
{
Desktop.getDesktop().browse( URI.create( getUrl() ) );
- } catch ( IOException e )
+ }
+ catch ( Exception ex )
{
- log.error( "The default browser could not be launched" );
+ log.warn( "Couldn't open default desktop browser: " + ex );
}
}
-
+
/**
* Shuts down the web application server.
*/
@@ -570,7 +243,8 @@
try
{
appServer.stop();
- } catch ( Exception ex )
+ }
+ catch ( Exception ex )
{
log.warn( "Oops: " + ex.toString() );
}
@@ -588,13 +262,15 @@
private static Image createImage( String path, String description )
{
URL imageURL = TrayApp.class.getResource( path );
+
if ( imageURL == null )
{
log.warn( "Resource not found: " + path );
return null;
- } else
+ }
+ else
{
- return ( new ImageIcon( imageURL, description ) ).getImage();
+ return (new ImageIcon( imageURL, description )).getImage();
}
}
@@ -606,7 +282,7 @@
*
* @return a String
value representing the installation directory
*/
- public static String getInstallDir()
+ private static String getInstallDir()
{
// find a resource
String resourceString = TrayApp.class.getResource( "/icons/" ).toString();
@@ -624,113 +300,4 @@
result = result.replaceAll( "%20", " " );
return result;
}
-
- /**
- * Reads the config.xml and creates the Config Object
- * Uses JAXBElement to config back unmarshal the config.xml
- */
- private void readConfigFromStream( InputStream configStream )
- {
- try
- {
- JAXBContext jc = JAXBContext.newInstance( "org.hisp.dhis.config" );
- //Create unmarshaller
- Unmarshaller um = jc.createUnmarshaller();
- //Unmarshal XML contents of the file config.xml into your Java object instance.
- configElement = (JAXBElement) um.unmarshal( configStream );
- config = configElement.getValue();
- } catch ( JAXBException ex )
- {
- log.error( "Error parsing config file", ex );
- JOptionPane.showMessageDialog( null, "Error loading configuration xml", "Configuration Error", JOptionPane.ERROR_MESSAGE );
- System.exit( 1 );
- }
- }
-
- /**
- * Writes the config.xml based on the changed config by marshalling the config object
- * Uses JAXBElement to write the config back to xml
- */
- public void writeConfigToFile()
- {
- try
- {
- JAXBContext jc = JAXBContext.newInstance( "org.hisp.dhis.config" );
- //Create marshaller
- Marshaller m = jc.createMarshaller();
- m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
- //Marshal object into file.
- boolean confDirExists = createConfigDirectory();
- m.marshal( configElement, new FileOutputStream( installDir + CONFIG_FILE_NAME ) );
- log.info( "Config Saved at: " + installDir + CONFIG_FILE_NAME );
- } catch ( FileNotFoundException ex )
- {
- log.error( "Can't find configuration xml", ex );
- JOptionPane.showMessageDialog( null, "Can't find configuration xml", "Configuration Error", JOptionPane.ERROR_MESSAGE );
- System.exit( 1 );
- } catch ( JAXBException ex )
- {
- log.error( "Error serializing config to file", ex );
- JOptionPane.showMessageDialog( null, "Error serializing config to file", "Configuration Error", JOptionPane.ERROR_MESSAGE );
- System.exit( 1 );
- }
- }
-
- /**
- * Writes the hibernate.properties file to the /conf folder based on the selected
- * connection from the config.xml or the defaultConfig.xml
- *
- * @return Returns whether successful in writing hibernate.properties
- */
- private void writeHibernateProperties()
- {
- String url = ( (Connection) databaseConfig.getDatabaseConnections().getSelected() ).getURL();
- String userName = ( (Connection) databaseConfig.getDatabaseConnections().getSelected() ).getUserName();
- String password = ( (Connection) databaseConfig.getDatabaseConnections().getSelected() ).getPassword();
- String dialect = ( (ConnectionType) ( (Connection) databaseConfig.getDatabaseConnections().getSelected() ).getType() ).getDialect();
- String driver = ( (ConnectionType) ( (Connection) databaseConfig.getDatabaseConnections().getSelected() ).getType() ).getDriverClass();
- Properties props = new Properties();
- try
- {
- props.setProperty( "hibernate.dialect", dialect );
- props.setProperty( "hibernate.connection.driver_class", driver );
- props.setProperty( "hibernate.connection.url", url );
- props.setProperty( "hibernate.connection.username", userName );
- if ( password != null )
- {
- props.setProperty( "hibernate.connection.password", password );
- } else
- {
- props.setProperty( "hibernate.connection.password", "" );
- }
- props.setProperty( "hibernate.hbm2ddl.auto", "update" );
- boolean confDirExists = createConfigDirectory();
- props.store( new FileWriter( System.getProperty( "dhis2.home" ) + "/hibernate.properties" ), "DHIS2 Live Created" );
- log.info( "Hibernate properties written at: " + System.getProperty( "dhis2.home" ) + "/hibernate.properties" );
- } catch ( IOException ex )
- {
- log.error( "Error with Hibernate Properties: " + ex.getMessage() );
- JOptionPane.showMessageDialog( null, "Error with Hibernate Properties: \n" + ex.getMessage(), "Configuration error", JOptionPane.ERROR_MESSAGE );
- System.exit( 1 );
- }
- }
-
- private boolean createConfigDirectory()
- {
- File fileDirectory = new File(getInstallDir() + "/conf");
- boolean success = fileDirectory.exists();
- if ( !success )
- {
- try
- {
- success = fileDirectory.mkdir();
-
- }
- catch (Exception e)
- {
- log.error ("Could not create config directory");
- }
- }
- return success;
- }
}
=== modified file 'dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java'
--- dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2010-09-15 19:58:14 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2010-11-29 15:11:43 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2010, University of Oslo
+ * Copyright (c) 2004-2009, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,20 +24,26 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**
*
* @author Bob Jolliffe
* @version $$Id$$
*/
+
package org.hisp.dhis;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
-import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.mortbay.component.LifeCycle;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;
@@ -46,13 +52,8 @@
*/
public class WebAppServer
{
-
public static final String DHIS_DIR = "/webapps/dhis";
- public static final String BIRT_DIR = "/webapps/birt";
-
- public static final String BIRT_CONTEXT_PATH = "/birt";
-
public static final String JETTY_PORT_CONF = "/conf/jetty.port";
public static final int DEFAULT_JETTY_PORT = 8080;
@@ -69,46 +70,31 @@
connector = new SelectChannelConnector();
}
- public void init()
+ public void init( String installDir, LifeCycle.Listener serverListener )
throws Exception
{
- String installDir = TrayApp.installDir;
try
{
- int portFromConfig = this.getPortFromConfig();
+ int portFromConfig = this.getPortFromConfig( installDir + JETTY_PORT_CONF );
connector.setPort( portFromConfig );
log.info( "Loading DHIS 2 on port: " + portFromConfig );
- } catch ( Exception ex )
+ }
+ catch ( Exception ex )
{
log.info( "Couldn't load port number from " + installDir + JETTY_PORT_CONF );
connector.setPort( DEFAULT_JETTY_PORT );
log.info( "Loading DHIS 2 on port: " + DEFAULT_JETTY_PORT );
}
- server.setConnectors( new Connector[]
- {
- connector
- } );
-
- ContextHandlerCollection handlers = new ContextHandlerCollection();
+ server.setConnectors( new Connector[] { connector } );
WebAppContext dhisWebApp = new WebAppContext();
- dhisWebApp.setMaxFormContentSize( TrayApp.appConfig.getMaxFormContentSize() );
+ dhisWebApp.setMaxFormContentSize( 5000000 );
dhisWebApp.setWar( installDir + DHIS_DIR );
- handlers.addHandler( dhisWebApp );
log.info( "Setting DHIS 2 web app context to: " + installDir + DHIS_DIR );
- if ( new File( installDir, BIRT_DIR ).exists() )
- {
- WebAppContext birtWebApp = new WebAppContext();
- birtWebApp.setContextPath( BIRT_CONTEXT_PATH );
- birtWebApp.setWar( installDir + BIRT_DIR );
- handlers.addHandler( birtWebApp );
- log.info( "Setting BIRT web app context to: " + installDir + BIRT_DIR );
- }
-
- server.setHandler( handlers );
- server.addLifeCycleListener( TrayApp.getInstance() );
+ server.setHandler( dhisWebApp );
+ server.addLifeCycleListener( serverListener );
}
public void start()
@@ -129,8 +115,14 @@
return connector.getPort();
}
- private int getPortFromConfig()
+ private int getPortFromConfig( String conf )
+ throws FileNotFoundException, IOException
{
- return TrayApp.appConfig.getPort();
+ Reader r = new BufferedReader( new FileReader( conf ) );
+ char[] cbuf = new char[10];
+ r.read( cbuf );
+ String numstr = String.copyValueOf( cbuf );
+ Integer port = Integer.valueOf( numstr.trim() );
+ return port.intValue();
}
}
=== removed file 'dhis-live/src/main/resources/Config.xsd'
--- dhis-live/src/main/resources/Config.xsd 2010-09-15 19:58:14 +0000
+++ dhis-live/src/main/resources/Config.xsd 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
=== removed file 'dhis-live/src/main/resources/defaultConfig.xml'
--- dhis-live/src/main/resources/defaultConfig.xml 2010-09-19 02:08:43 +0000
+++ dhis-live/src/main/resources/defaultConfig.xml 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
-
-
-
-
-
-
- en
- GB
- 8080
- localhost
-
- 200000
-
-
-
-
- org.hisp.dhis.dialect.H2Dialect
- org.h2.Driver
-
-
- org.hibernate.dialect.MySQLDialect
- com.mysql.jdbc.Driver
-
-
- org.hibernate.dialect.PostgreSQLDialect
- org.postgresql.Driver
-
-
-
-
- DHIS2 Demo
- jdbc:h2:./database/demo;AUTO_SERVER=TRUE
- sa
-
-
-
-
=== modified file 'dhis-live/src/main/resources/icons/running.png'
Binary files dhis-live/src/main/resources/icons/running.png 2010-09-06 17:50:24 +0000 and dhis-live/src/main/resources/icons/running.png 2010-11-29 15:11:43 +0000 differ
=== removed file 'dhis-live/src/main/resources/icons/starting.gif'
Binary files dhis-live/src/main/resources/icons/starting.gif 2010-09-06 17:50:24 +0000 and dhis-live/src/main/resources/icons/starting.gif 1970-01-01 00:00:00 +0000 differ
=== modified file 'dhis-live/src/main/resources/icons/starting.png'
Binary files dhis-live/src/main/resources/icons/starting.png 2010-09-06 17:50:24 +0000 and dhis-live/src/main/resources/icons/starting.png 2010-11-29 15:11:43 +0000 differ
=== removed directory 'dhis-live/src/main/resources/messages'
=== removed file 'dhis-live/src/main/resources/messages/messages_de.properties'
--- dhis-live/src/main/resources/messages/messages_de.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_de.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=Open dhis 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Ausgang
-menuitem.settings=Einstellungen
-menuitem.database=Datenbanken
-dialogbox.unsupportedPlatform=System Tray nicht unterst\u00c3\u00bctzt auf dieser Plattform
-dialogbox.initFailure=DHIS2-live nicht \ nWenden Protokoll f\u00c3\u00bcr Details zu initialisieren
-dialogbox.webserverFailure=Web-Server nicht gestartet werden - siehe Protokolle f\u00c3\u00bcr Details
-notification.started=Started
-notification.startedDetails=Dhis 2 l\u00c3\u00a4uft. Ihr Browser wird \ n hingewiesen werden
-notification.starting=Beginnend
-notification.startingDetails=Dhis 2 ist ab. \ NBitte geduldig zu sein.
-notification.stopped=Gestoppt
-notification.stoppedDetails=Dhis 2 hat aufgeh\u00c3\u00b6rt.
-tooltip.running=Dhis 2 Server laufen
=== removed file 'dhis-live/src/main/resources/messages/messages_en_GB.properties'
--- dhis-live/src/main/resources/messages/messages_en_GB.properties 2010-09-19 02:08:43 +0000
+++ dhis-live/src/main/resources/messages/messages_en_GB.properties 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-menuitem.open=Open DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Exit
-menuitem.settings=Settings
-menuitem.database=Databases
-menuitem.dbname= Name of the blank database
-
-dialogbox.unsupportedPlatform = System Tray not supported on this platform
-dialogbox.initFailure = DHIS2-live failed to initialize\nSee log for details
-dialogbox.webserverFailure = Web server failed to start - see logs for details
-
-notification.started = Started
-notification.startedDetails = DHIS 2 is running. Your browser will\n be pointed to
-notification.starting = Starting
-notification.startingDetails = DHIS 2 is starting.\nPlease be patient.
-notification.stopped = Stopped
-notification.stoppedDetails = DHIS 2 has stopped.
-
-tooltip.running = DHIS 2 Server running
-#org.hisp.dhis.SettingsWindow
-settings.windowtitle=DHIS 2 Live - Settings
-settings.appconfig=Application Configuration'
-settings.port=Port:
-settings.host=Host:
-settings.browserpath="Preferred Browser Path:
-settings.browse=Browse
-settings.language=Language:
-settings.country=Country:
-settings.maxformsize=Max Form Content Size:
-settings.restartinfo=(* requires restart of DHIS 2 Live - default: 200000)
-settings.bytes=(bytes)
-settings.dbconfig= Database Configuration
-settings.conntypes=Connection Types (Disabled)
-settings.remove=Remove
-settings.connections=Connections:
-settings.add=Add
-settings.saveclose=Save and close
-
-ID=ID
-REMOVE=Remove
=== removed file 'dhis-live/src/main/resources/messages/messages_es.properties'
--- dhis-live/src/main/resources/messages/messages_es.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_es.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=Abrir DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Salida
-menuitem.settings=Configuraci\u00c3\u00b3n
-menuitem.database=Bases de datos
-dialogbox.unsupportedPlatform=La bandeja del sistema no se admite en esta plataforma
-dialogbox.initFailure=DHIS2-live no se pudo inicializar \ log nConsulte para obtener m\u00c3\u00a1s detalles
-dialogbox.webserverFailure=servidor Web no se pudo iniciar - ver los registros de datos
-notification.started=Introducci\u00c3\u00b3n
-notification.startedDetails=DHIS 2 est\u00c3\u00a1 en ejecuci\u00c3\u00b3n. Su navegador \ n se refiri\u00c3\u00b3 a
-notification.starting=A partir
-notification.startingDetails=DHIS 2 se est\u00c3\u00a1 iniciando. \ NPor favor, sea paciente.
-notification.stopped=Detenido
-notification.stoppedDetails=DHIS 2 se ha detenido.
-tooltip.running=DHIS 2 Server que se ejecuta
=== removed file 'dhis-live/src/main/resources/messages/messages_fr.properties'
--- dhis-live/src/main/resources/messages/messages_fr.properties 2010-09-19 02:08:43 +0000
+++ dhis-live/src/main/resources/messages/messages_fr.properties 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-menuitem.open= Open H2 database
-menuitem.blank=Blank H2 database
-menuitem.exit=Sortie
-menuitem.settings=Param\u00e8tres
-menuitem.database=Bases de donn\u00e9es
-dialogbox.unsupportedPlatform=System Tray pas support\u00e9 sur cette plate-forme
-dialogbox.initFailure=DHIS2-live n'a pas pu initialiser\nVoir log pour plus de d\u00e9tails
-dialogbox.webserverFailure=serveur Web n'a pas pu d\u00e9marrer - voir les logs pour plus de d\u00e9tails
-notification.started=En route
-notification.startedDetails=DHIS2 est en cours d'ex\u00e9cution. Votre navigateur \n lieu de relever \u00e0
-notification.starting=\u00c0 partir
-notification.startingDetails=DHIS2 est de d\u00e9part. \nVeuillez \u00eatre patient.
-notification.startingDetails = DHIS22 est de d\u00e9part. \nVeuillez \u00eatre patient.
-notification.stopped = Arr\u00eat\u00e9
-notification.stoppedDetails = DHIS 2 a cess\u00e9.
-
-
-
-settings.windowtitle = DHIS 2 Live - Param\u00e8tres
-settings.appconfig = Application Configuration '
-settings.port = Port:
-settings.host = Host:
-settings.browserpath = Pr\u00e9f\u00e9r\u00e9s navigateur Path:
-settings.browse = Parcourir
-settings.language = Langue:
-settings.country = Pays:
-settings.maxformsize = Taille maximum de contenu d'un formulaire:
-settings.restartinfo = (* n\u00e9cessite un red\u00e9marrage de DHIS 2 Live - par d\u00e9faut: 200000)
-settings.bytes = (octets)
-settings.dbconfig = Base de donn\u00e9es de configuration
-settings.conntypes = Les types de connexion (Disabled)
-
-settings.connections = Connexions =:
-settings.add = Ajouter
-settings.saveclose = Enregistrer et fermer
\ No newline at end of file
=== removed file 'dhis-live/src/main/resources/messages/messages_pt.properties'
--- dhis-live/src/main/resources/messages/messages_pt.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_pt.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=Open DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Sa\u00c3\u00adda
-menuitem.settings=Configura\u00c3\u00a7\u00c3\u00b5es
-menuitem.database=Bases de dados
-dialogbox.unsupportedPlatform=Bandeja do sistema n\u00c3\u00a3o \u00c3\u00a9 suportado nesta plataforma
-dialogbox.initFailure=DHIS2 vivo falhou ao inicializar \ log nConsulte para detalhes
-dialogbox.webserverFailure=servidor Web falhou ao iniciar - ver logs para obter detalhes
-notification.started=Come\u00c3\u00a7ado
-notification.startedDetails=DHIS 2 est\u00c3\u00a1 funcionando. Seu navegador \ n ser apontado
-notification.starting=Come\u00c3\u00a7ando
-notification.startingDetails=DHIS 2 est\u00c3\u00a1 de partida. \ NPor favor, seja paciente.
-notification.stopped=Parado
-notification.stoppedDetails=DHIS 2 parou.
-tooltip.running=DHIS 2 Server executando
=== removed file 'dhis-live/src/main/resources/messages/messages_ru.properties'
--- dhis-live/src/main/resources/messages/messages_ru.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_ru.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=\u041e\u0442\u043a\u0440\u044b\u0442\u044c DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=\u0412\u044b\u0445\u043e\u0434
-menuitem.settings=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438
-menuitem.database=\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445
-dialogbox.unsupportedPlatform=\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043b\u043e\u0442\u043e\u043a \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435
-dialogbox.initFailure=DHIS2-\u0436\u0438\u0442\u044c \u043d\u0435 \u0441\u043c\u043e\u0433 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \ nSee \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435
-dialogbox.webserverFailure=\u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c - \u0441\u043c. \u0436\u0443\u0440\u043d\u0430\u043b\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435
-notification.started=\u0420\u0430\u0431\u043e\u0442\u044b
-notification.startedDetails=DHIS 2 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \ \u043f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c
-notification.starting=\u041e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439
-notification.startingDetails=DHIS 2 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f. \u0425\u043f\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0431\u0443\u0434\u044c\u0442\u0435 \u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u044b.
-notification.stopped=\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f
-notification.stoppedDetails=DHIS 2 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f.
-tooltip.running=DHIS 2 Server \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442
=== removed file 'dhis-live/src/main/resources/messages/messages_sw.properties'
--- dhis-live/src/main/resources/messages/messages_sw.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_sw.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=Open DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Exit
-menuitem.settings=Vipimo
-menuitem.database=Databaser
-dialogbox.unsupportedPlatform=Mfumo tray si mkono kwenye jukwaa hili
-dialogbox.initFailure=DHIS2-kuishi alishindwa initialize \ nSee logi kwa maelezo
-dialogbox.webserverFailure=Web server alishindwa kuanza - angalia magogo kwa maelezo
-notification.started=Started
-notification.startedDetails=DHIS 2 anakimbia. browser yako \ n kuelekezwa kwa
-notification.starting=Kuanzia
-notification.startingDetails=DHIS 2 ni kuanzia \ nPlease kuwa na subira..
-notification.stopped=Kusimamishwa
-notification.stoppedDetails=DHIS 2 kimesimama.
-tooltip.running=DHIS 2 Server mbio
=== removed file 'dhis-live/src/main/resources/messages/messages_vi.properties'
--- dhis-live/src/main/resources/messages/messages_vi.properties 2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_vi.properties 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-menuitem.open=M\u1edf DHIS 2 Live
-menuitem.blank=Blank H2 database
-menuitem.exit=Ra
-menuitem.settings=C\u00e0i \u0111\u1eb7t
-menuitem.database=C\u01a1 s\u1edf d\u1eef li\u1ec7u
-dialogbox.unsupportedPlatform=Khay h\u1ec7 th\u1ed1ng kh\u00f4ng h\u1ed7 tr\u1ee3 tr\u00ean n\u1ec1n t\u1ea3ng n\u00e0y
-dialogbox.initFailure=DHIS2-s\u1ed1ng kh\u00f4ng th\u1ec3 kh\u1edfi t\u1ea1o \ log nSee \u0111\u1ec3 bi\u1ebft chi ti\u1ebft
-dialogbox.webserverFailure=Web server kh\u00f4ng th\u00e0nh c\u00f4ng \u0111\u1ec3 b\u1eaft \u0111\u1ea7u - xem nh\u1eadt k\u00fd \u0111\u1ec3 bi\u1ebft chi ti\u1ebft
-notification.started=B\u1eaft \u0111\u1ea7u
-notification.startedDetails=DHIS 2 \u0111ang ch\u1ea1y. Tr\u00ecnh duy\u1ec7t c\u1ee7a b\u1ea1n s\u1ebd \ n \u0111\u01b0\u1ee3c ch\u1ec9 ra
-notification.starting=B\u1eaft \u0111\u1ea7u
-notification.startingDetails=DHIS 2 l\u00e0 b\u1eaft \u0111\u1ea7u. \ NH\u00e3y \u0111\u01b0\u1ee3c b\u1ec7nh nh\u00e2n.
-notification.stopped=Ng\u01b0ng
-notification.stoppedDetails=DHIS 2 \u0111\u00e3 ng\u1eebng.
-tooltip.running=2 DHIS m\u00e1y ch\u1ee7 \u0111ang ch\u1ea1y