Changeset 130


Ignore:
Timestamp:
08/18/11 12:39:22 (13 years ago)
Author:
vmipsl
Message:

[Visualization] interface quite finish

Location:
ether_megapoli/trunk
Files:
3 added
1 deleted
20 edited
1 moved

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/common/implementation/com/ether/EtherException.java

    r129 r130  
    55 * @date 02 feb 2011 
    66 */ 
    7 public class WebException 
     7public class EtherException 
    88        extends FormattedException 
    99{ 
    10     public WebException( final Enum<? extends Code> code ) 
     10    public EtherException( final Enum<? extends Code> code ) 
    1111    { 
    1212        super( code ); 
    1313    } 
    1414 
    15     public WebException( final Enum<? extends Code> code, final Throwable cause, final Object... parameters ) 
     15    public EtherException( final Enum<? extends Code> code, final Throwable cause, final Object... parameters ) 
    1616    { 
    1717        this( code, cause.getMessage(), cause, parameters ); 
    1818    } 
    1919 
    20     protected WebException( final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters ) 
     20    protected EtherException( final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters ) 
    2121    { 
    2222        super( prefix( code, message ), cause, parameters ); 
    2323    } 
    2424 
    25     public WebException( final Throwable cause ) 
     25    public EtherException( final Throwable cause ) 
    2626    { 
    2727        super( cause ); 
    2828    } 
    2929 
    30     public WebException( final Enum<? extends Code> code, final String string ) 
     30    public EtherException( final Enum<? extends Code> code, final String string ) 
    3131    { 
    3232        super( code, string ); 
    3333    } 
    3434 
    35     public static enum WebCode 
     35    public static enum EtherCode 
    3636            implements Code 
    3737    { 
    38         UNKNOWN, 
    39         PERSISTENCE, 
    40         SERVICE_PROBLEM, 
    41         PLATEFORME_ID_NOT_FOUND, 
    4238        IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, 
    43         ERROR_UNSUPPORTED_UTF8_ENCODING, 
    44         ERROR_NO_REQUEST_HANDLING_METHOD, 
    45         ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
    46         FILE_NOT_FOUND; 
    4739    } 
    4840} 
  • ether_megapoli/trunk/common/implementation/com/ether/WebHelper.java

    r89 r130  
    44import java.io.PrintWriter; 
    55import java.security.InvalidParameterException; 
     6import java.util.Locale; 
     7import java.util.ResourceBundle; 
    68 
    79import javax.servlet.ServletOutputStream; 
     
    1416import org.jetbrains.annotations.Nullable; 
    1517 
    16 import com.ether.WebException.WebCode; 
     18import com.ether.EtherException.EtherCode; 
    1719 
    1820public final class WebHelper 
     
    2325 
    2426    @NotNull 
    25     public static String getRequestParameter(@NotNull final HttpServletRequest httpServletRequest, @Nullable final String parameterName, @Nullable final String defaultParameterValue, final boolean canBeNull ) 
    26         throws InvalidParameterException 
     27    public static String getRequestParameter( @NotNull final HttpServletRequest httpServletRequest, @Nullable final String parameterName, @Nullable final String defaultParameterValue, final boolean canBeNull ) 
     28            throws InvalidParameterException 
    2729    { 
    28         String parameterValue; 
    29         if(null == parameterName) 
    30                 parameterValue = defaultParameterValue; 
    31          
     30        String parameterValue; 
     31        if( null == parameterName ) 
     32            parameterValue = defaultParameterValue; 
     33 
    3234        parameterValue = httpServletRequest.getParameter( parameterName ); 
    3335 
     
    5456    } 
    5557 
    56     public static void displayAjaxError(@NotNull final HttpServletResponse response, @Nullable final String methodName)  
    57         throws WebException 
    58     {            
    59         try { 
    60                 response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); 
    61                 response.setCharacterEncoding(UTF8Charset.getEncoding()); 
    62                 response.setContentType("text/plain;charset="+ UTF8Charset.getEncoding()); 
    63                 final ServletOutputStream outputStream = response.getOutputStream(); 
    64                 outputStream.print("error.method_not_implemented : " + methodName+ " is not implemented."); 
    65                 outputStream.flush(); 
    66                 outputStream.close(); 
    67         } catch (IOException e) { 
    68                 throw new WebException(WebCode.IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, e); 
    69         } 
     58    public static void displayAjaxError( @NotNull final HttpServletResponse response, @Nullable final String methodName ) 
     59            throws EtherException 
     60    { 
     61        try 
     62        { 
     63            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED ); 
     64            response.setCharacterEncoding( UTF8Charset.getEncoding() ); 
     65            response.setContentType( "text/plain;charset=" + UTF8Charset.getEncoding() ); 
     66            final ServletOutputStream outputStream = response.getOutputStream(); 
     67            outputStream.print( "error.method_not_implemented : " + methodName + " is not implemented." ); 
     68            outputStream.flush(); 
     69            outputStream.close(); 
     70        } 
     71        catch( IOException e ) 
     72        { 
     73            throw new EtherException( EtherCode.IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, e ); 
     74        } 
     75    } 
     76 
     77    @NotNull 
     78    public static ResourceBundle getBundle( @Nullable final Locale locale ) 
     79    { 
     80        if( null != locale ) 
     81            return ResourceBundle.getBundle( "ApplicationResources", locale ); 
     82        else 
     83            return ResourceBundle.getBundle( "ApplicationResources" ); 
    7084    } 
    7185 
    7286    private static final Log LOGGER = LogFactory.getLog( WebHelper.class ); 
    73      
     87 
    7488    private static final String CONTENT_TYPE_TEXT_JSON = "text/javascript;charset=" + UTF8Charset.getEncoding(); 
    75     private static final char JSON_TAG_BEGIN = ' ' ;  // '('; 
     89    private static final char JSON_TAG_BEGIN = ' ';  // '('; 
    7690    private static final char JSON_TAG_END = ' ';     // ')'; 
    7791} 
  • ether_megapoli/trunk/persistence/implementation/hibernate-domain.cfg.xml

    r129 r130  
    66<hibernate-configuration> 
    77        <session-factory> 
     8 
    89        <!--<mapping resource="com/medias/objects/Adresse.hbm.xml"/>--> 
    910        <!--<mapping resource="com/medias/objects/Bilan.hbm.xml"/>--> 
     
    3233        <!--<mapping resource="com/medias/objects/Valeur.hbm.xml"/>--> 
    3334        <!--<mapping resource="com/medias/objects/Zone.hbm.xml"/>--> 
     35 
    3436        </session-factory> 
    3537</hibernate-configuration> 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r129 r130  
    88import org.jetbrains.annotations.NotNull; 
    99import org.jetbrains.annotations.Nullable; 
     10import org.medias.megapoli.utils.MegapoliInitialisation; 
    1011 
    1112import javax.swing.*; 
     
    2930     * @param locale 
    3031     * @return 
    31      * @throws WebException 
    32      */ 
    33     @NotNull 
    34     public BufferedImage createJPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
    35     { 
    36         JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, MAIN_HEIGHT ) ); 
     32     */ 
     33    @NotNull 
     34    public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
     35    { 
     36//        JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, MAIN_HEIGHT ) ); 
     37        JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, 700 ) ); 
    3738        if( null != megapoliPlot.getWidth() && null != megapoliPlot.getHeight() ) 
    3839            jPane = new JPane( "Main jPane", new Dimension( megapoliPlot.getWidth(), megapoliPlot.getHeight() ) ); 
     
    4344        jPane.setOpaque( true ); 
    4445 
    45         final JPane jPaneTop = createTopPane( megapoliPlot ); 
    46         jPane.add( jPaneTop, BorderLayout.NORTH ); 
    47 //        final JPane jPaneCenter = createCenterPane( megapoliPlot.getData() ); 
    48         final JPane jPaneCenter = createTopPane( megapoliPlot ); 
     46        // Top Pane 
     47//        final JPane jPaneTop = createTopPane( megapoliPlot ); 
     48//        jPane.add( jPaneTop, BorderLayout.NORTH ); 
     49 
     50        // Center Pane 
     51        final Integer valuesNumber = megapoliPlot.getData().getYArray().length; 
     52        final JPane jPaneCenter; 
     53        if( valuesNumber > 0 ) 
     54            jPaneCenter = createCenterPane( megapoliPlot.getData() ); 
     55        else 
     56            jPaneCenter = createEmptyCenterPane( locale ); 
    4957        jPane.add( jPaneCenter, BorderLayout.CENTER ); 
    50         final JPane jPaneBottom = createBottomPane( megapoliPlot.getData().getYArray().length, locale ); 
    51         jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
     58 
     59        // Bottom Pane 
     60//        final JPane jPaneBottom = createBottomPane( valuesNumber, locale ); 
     61//        jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
    5262 
    5363        final JPanelToImageManager jPanelToImageManager = new JPanelToImageManager( jPane ); 
    54  
    5564        return jPanelToImageManager.saveAsImage(); 
    5665    } 
     
    5968     * Create the top JPane with the logos and title 
    6069     * 
    61      * @param megapoliPlot@return 
     70     * @param megapoliPlot 
     71     * @return 
    6272     */ 
    6373    @NotNull 
     
    8393 
    8494        // Title 
    85         final JLabel jLabelTitle = new JLabel( megapoliPlot.getTitle(), JLabel.CENTER ); 
    86         final Font police = new Font( "Arial", Font.BOLD, FONT_SIZE ); 
     95        final String formatedTitle = formatTitle( megapoliPlot.getTitle() ); 
     96        final JLabel jLabelTitle = new JLabel( formatedTitle, JLabel.CENTER ); 
     97        final Font police = new Font( "Arial", Font.BOLD, TITLE_FONT_SIZE ); 
    8798        jLabelTitle.setFont( police ); 
    8899        jPaneTop.add( jLabelTitle, BorderLayout.CENTER ); 
     
    100111    public JPane createCenterPane( @NotNull final SGTData data ) 
    101112    { 
    102         final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( 0, 1000 ) ); 
    103         jPaneCenter.setLayout( new BorderLayout() ); 
     113//        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( 0, 1000 ) ); 
    104114 
    105115        // Graph 
    106116        final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
    107         jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     117        jPlotLayout.setTitles( "", "", "" ); 
    108118        jPlotLayout.addData( data, data.getTitle() ); 
    109 //        jPlotLayout.setSize( 800, 800 ); 
     119//        jPlotLayout.setSize( 800, 1 ); 
    110120        jPlotLayout.setVisible( true ); 
    111121 
     
    114124 
    115125        // TODO : remove this change to bufferedImage to insert directly the jPlotLayout !!!! 
     126//        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
    116127        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
    117128        final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     
    119130 
    120131        final ImageIcon imageIcon = new ImageIcon( bufferedImage ); 
    121         final JLabel jLabel = new JLabel( imageIcon ); 
     132        final JLabel jLabel = new JLabel( imageIcon, JLabel.CENTER ); 
    122133        jLabel.setBorder( BorderFactory.createLineBorder( Color.blue, 2 ) ); 
     134 
     135//        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( jPlotLayout.getWidth(), jPlotLayout.getHeight() ) ); 
     136        final JPane jPaneCenter = new JPane(); 
     137        jPaneCenter.setLayout( new BorderLayout() ); 
    123138        jPaneCenter.add( jLabel, BorderLayout.CENTER ); 
    124139 
    125 //        final JLabel jj = new JLabel("pif"); 
    126 //        jj.setBorder( BorderFactory.createLineBorder( Color.red, 2 ) ); 
    127 //        jPaneCenter.add( jj, BorderLayout.CENTER ); 
    128  
    129140        return jPaneCenter; 
    130141    } 
    131142 
    132143    /** 
     144     * Create the center JPane with no graph (if no value) 
     145     * 
     146     * @param locale 
     147     * @return 
     148     */ 
     149    public JPane createEmptyCenterPane( @Nullable final Locale locale ) 
     150    { 
     151        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     152        final String messageData = bundle.getString( "plot.noData" ); 
     153 
     154        final JPane jPaneCenter = new JPane(); 
     155        jPaneCenter.setLayout( new BorderLayout() ); 
     156 
     157        final JLabel jLabelData = new JLabel( messageData, JLabel.CENTER ); 
     158        final Font police = new Font( "Arial", Font.BOLD, FONT_SIZE ); 
     159        jLabelData.setFont( police ); 
     160 
     161        jPaneCenter.add( jLabelData, BorderLayout.CENTER ); 
     162        return jPaneCenter; 
     163    } 
     164 
     165    /** 
    133166     * Create the bottom JPane with the text "published .. (date)" 
    134167     * 
     
    140173    public JPane createBottomPane( @Nullable final Integer dataNumber, @Nullable final Locale locale ) 
    141174    { 
    142         final ResourceBundle bundle = getBundle( locale ); 
     175        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
    143176 
    144177        final JPane jPaneBottom = new JPane(); 
     
    148181        final Calendar calendar = Calendar.getInstance(); 
    149182        final String messagePublished = bundle.getString( "plot.published" ); 
    150         final JLabel jLabel = new JLabel( messagePublished + " " + DateHelper.formatDate( calendar.getTime(), DateHelper.ENGLISH_DATE_PATTERN ) + " " ); 
     183        final JLabel jLabel = new JLabel( messagePublished + ' ' + DateHelper.formatDate( calendar.getTime(), DateHelper.ENGLISH_DATE_PATTERN ) + " " ); 
     184        final Font police = new Font( "Arial", Font.BOLD, FONT_SIZE ); 
     185        jLabel.setFont( police ); 
    151186        jPaneBottom.add( jLabel, BorderLayout.EAST ); 
    152187 
     
    154189        { 
    155190            final String messageDataNumber = bundle.getString( "plot.dataNumber" ); 
    156             final JLabel jLabelDataNumber = new JLabel( messageDataNumber + " " + dataNumber ); 
     191            final JLabel jLabelDataNumber = new JLabel( messageDataNumber + ' ' + dataNumber ); 
     192            jLabelDataNumber.setFont( police ); 
    157193            jPaneBottom.add( jLabelDataNumber, BorderLayout.WEST ); 
    158194        } 
     
    161197    } 
    162198 
    163     // TODO : move this function in a more generally class 
    164     private ResourceBundle getBundle( @Nullable final Locale locale ) 
    165     { 
    166         if( null != locale ) 
    167             return ResourceBundle.getBundle( "ApplicationResources", locale ); 
     199    /** 
     200     * Create an error JPane when plot can be created 
     201     * 
     202     * @param mainError 
     203     * @param errorText 
     204     * @param locale 
     205     * @return 
     206     */ 
     207    @NotNull 
     208    public BufferedImage createErrorPane( @NotNull final String mainError, @NotNull final String errorText, @Nullable final Locale locale ) 
     209    { 
     210        // Image 
     211        final ImageIcon errorImage = new ImageIcon( MegapoliInitialisation.pathImages + "/erreur.gif" ); 
     212        final JLabel jLabelErrorImage = new JLabel( errorImage ); 
     213 
     214        // Text 
     215        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     216        final String mainMessage = bundle.getString( "plot.errorMessage" ); 
     217        final JLabel jLabelError = new JLabel( "<html>" + mainMessage + "<br><br>" + mainError + "<br>" + errorText + "</html>", JLabel.CENTER ); 
     218        final Font police = new Font( "Arial", Font.BOLD, ERROR_FONT_SIZE ); 
     219        jLabelError.setFont( police ); 
     220 
     221        // jPane 
     222        final JPane jPane = new JPane( "jPane", new Dimension( MAIN_WIDTH, errorImage.getIconHeight() ) ); 
     223        jPane.setLayout( new BorderLayout() ); 
     224        jPane.setBackground( Color.white ); 
     225        jPane.setOpaque( true ); 
     226        jPane.add( jLabelErrorImage, BorderLayout.WEST ); 
     227        jPane.add( jLabelError, BorderLayout.CENTER ); 
     228 
     229        final JPanelToImageManager jPanelToImageManager = new JPanelToImageManager( jPane ); 
     230        return jPanelToImageManager.saveAsImage(); 
     231    } 
     232 
     233    @NotNull 
     234    private String formatTitle( @Nullable final String title ) 
     235    { 
     236        if( null == title ) 
     237            return ""; 
    168238        else 
    169             return ResourceBundle.getBundle( "ApplicationResources" ); 
     239        { 
     240            final String formatTitle = title.replaceAll( "\\n", "<br>" ); 
     241            return "<html>" + formatTitle + "</html>"; 
     242        } 
    170243    } 
    171244 
     
    180253    private static final int MAIN_HEIGHT = 800; 
    181254 
    182     private static final int FONT_SIZE = 20; 
     255    private static final int TITLE_FONT_SIZE = 20; 
     256    private static final int FONT_SIZE = 12; 
     257    private static final int ERROR_FONT_SIZE = 10; 
    183258} 
  • ether_megapoli/trunk/service/implementation/com/ether/JPanelToImageManager.java

    r129 r130  
    1010 
    1111/** 
     12 * @Author : E.Mo.. 
    1213 * This class convert a JPanel into a BufferedImage 
    1314 */ 
     
    3334    private BufferedImage paintComponent( @NotNull final Component component ) 
    3435    { 
     36        if( 0 >= component.getWidth() || 0 >= component.getHeight() ) 
     37            return null; 
     38 
    3539        // Set it to it's preferred size. (optional) 
    3640        component.setSize( component.getPreferredSize() ); 
  • ether_megapoli/trunk/service/implementation/com/ether/MegapoliPlot.java

    r129 r130  
    4141    } 
    4242 
    43     @Nullable 
     43    @NotNull 
    4444    public String getLogoMegapoli() 
    4545    { 
     
    4747    } 
    4848 
    49     public void setLogoMegapoli( @Nullable final String logoMegapoli ) 
     49    public void setLogoMegapoli( @NotNull final String logoMegapoli ) 
    5050    { 
    5151        _logoMegapoli = logoMegapoli; 
    5252    } 
    5353 
    54     @Nullable 
     54    @NotNull 
    5555    public String getLogoEther() 
    5656    { 
     
    5858    } 
    5959 
    60     public void setLogoEther( @Nullable final String logoEther ) 
     60    public void setLogoEther( @NotNull final String logoEther ) 
    6161    { 
    6262        _logoEther = logoEther; 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r129 r130  
    1717{ 
    1818    @NotNull 
    19     public BufferedImage createJPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ); 
     19    public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ); 
    2020 
    2121    @NotNull 
     
    2828    public JPane createBottomPane( @Nullable final Integer dataNumber, @Nullable final Locale locale ); 
    2929 
     30    @NotNull 
     31    public BufferedImage createErrorPane( @NotNull final String mainError, @NotNull final String errorText, @Nullable final Locale locale ); 
    3032} 
  • ether_megapoli/trunk/service/test/com/ether/SGTTest.java

    r129 r130  
    2323import javax.imageio.ImageIO; 
    2424import javax.servlet.ServletException; 
    25 import javax.servlet.http.HttpServletRequest; 
    2625import javax.servlet.http.HttpServletResponse; 
    2726import javax.swing.*; 
    2827import java.awt.*; 
    2928import java.awt.image.BufferedImage; 
    30 import java.awt.image.RenderedImage; 
    3129import java.io.File; 
    3230import java.io.FileInputStream; 
     
    482480    } 
    483481 
    484  
    485  
    486482    @ControllerMethod(jsonResult = true) 
    487483    public JSONObject searchDatasByPlateformByParameterByPeriod( 
     
    490486            @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    491487            @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd ) 
    492             throws ServiceException, WebException, ParseException 
     488            throws ServiceException, EtherException, ParseException 
    493489    { 
    494490//        final String pofBegin = "2009-07-13 13:00"; 
     
    612608//              @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    613609//              @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
    614 //      throws ServiceException, WebException, ParseException 
     610//      throws ServiceException, EtherException, ParseException 
    615611//    { 
    616612//      final long time1 = Calendar.getInstance().getTimeInMillis(); 
  • ether_megapoli/trunk/web/resources/css/button.css

    r89 r130  
    55/* BUTTONS */ 
    66 
    7 .buttons a, .buttons button { 
     7button { 
    88    display:block; 
    99    float:left; 
     
    2121    color:#565656; 
    2222    cursor:pointer; 
    23     padding:5px 10px 6px 7px; /* Links */ 
    24 } 
    25 .buttons button{ 
     23 
    2624    width:auto; 
    2725    overflow:visible; 
    2826    padding:4px 6px 3px 6px; /* IE6 */ 
    2927} 
    30 .buttons button[type]{ 
     28 
     29button[type]{ 
    3130    padding:5px 10px 5px 7px; /* Firefox */ 
    3231    line-height:17px; /* Safari */ 
    3332} 
     33 
    3434*:first-child+html button[type]{ 
    3535    padding:4px 10px 3px 7px; /* IE7 */ 
    3636} 
    37 .buttons button img, .buttons a img{ 
     37 
     38.small{ 
     39    font-size:80%; 
     40} 
     41 
     42button img{ 
    3843    margin:0 3px -3px 0 !important; 
    3944    padding:0; 
     
    4550 
    4651/* STANDARD */ 
    47  
    48 button:hover, .buttons a:hover{ 
     52button:hover{ 
    4953    background-color:#dff4ff; 
    5054    border:1px solid #c2e1ef; 
    5155    color:#336699; 
    5256} 
    53 .buttons a:active{ 
    54     background-color:#6299c5; 
    55     border:1px solid #6299c5; 
    56     color:#fff; 
    57 } 
    5857 
    5958/* POSITIVE */ 
    60  
    61 button.positive, .buttons a.positive{ 
     59button.positive{ 
    6260    color:#529214; 
    6361} 
    64 .buttons a.positive:hover, button.positive:hover{ 
     62button.positive:hover{ 
    6563    background-color:#E6EFC2; 
    6664    border:1px solid #C6D880; 
    6765    color:#529214; 
    6866} 
    69 .buttons a.positive:active{ 
    70     background-color:#529214; 
    71     border:1px solid #529214; 
    72     color:#fff; 
    73 } 
    7467 
    7568/* NEGATIVE */ 
    76  
    77 .buttons a.negative, button.negative{ 
     69button.negative{ 
    7870    color:#d12f19; 
    7971} 
    80 .buttons a.negative:hover, button.negative:hover{ 
     72button.negative:hover{ 
    8173    background:#fbe3e4; 
    8274    border:1px solid #fbc2c4; 
    8375    color:#d12f19; 
    8476} 
    85 .buttons a.negative:active{ 
    86     background-color:#d12f19; 
    87     border:1px solid #d12f19; 
    88     color:#fff; 
    89 } 
    9077 
    9178/* DISABLE */ 
    92  
    93 .buttons a.disable, .buttons a.disable:hover, .buttons button.disable, .buttons button.disable:hover 
    94 { 
     79button.disable, button.disable:hover{ 
    9580    background-color:#CCCCCC; 
    9681    border:1px solid #dedede; 
    9782    color:#565656; 
    9883} 
    99  
  • ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css

    r129 r130  
    11/* ****************** CONTAINERS ************************* */ 
    2 #containerPlateforms, #containerParameters, #containerCalendar 
    3 { 
    4         margin-top: 10px; 
     2#containerPlateforms, #containerParameters, #containerCalendar { 
     3    margin-top: 10px; 
    54} 
    65 
    7 .containerPlateform, .containerParameter 
    8 { 
    9         color: #6178BC; 
     6.containerPlateform, .containerParameter { 
     7    color: #6178BC; 
    108} 
    119 
    12 .containerPlateform:hover, .containerParameter:hover 
    13 { 
    14         text-decoration: underline; 
    15         background: #70739C; 
    16         color: #FFFFFF; 
     10.containerPlateform:hover, .containerParameter:hover { 
     11    text-decoration: none; 
     12    background: #70739C; 
     13    color: #FFFFFF; 
     14} 
     15 
     16#containerOptionTitle { 
     17    margin-top: 25px; 
     18    margin-bottom: 25px; 
     19} 
     20 
     21#containerButtons { 
     22    margin-top: 25px; 
    1723} 
    1824 
    1925/* ****************** LOADINGS ************************* */ 
    20 #loadingForPlateforms, #loadingForParameters 
    21 { 
     26#loadingForPlateforms, #loadingForParameters { 
    2227    position: relative; 
    2328    top: 102px; 
     
    2530} 
    2631 
     32.loadingPlot { 
     33    margin: auto; 
     34    height: 15px; 
     35    width: 128px; 
     36    margin-top: 50px; 
     37} 
     38 
    2739/* ****************** OTHERS ************************* */ 
    28 #NoPlateform, #NoParameter 
    29 { 
     40#NoPlateform, #NoParameter { 
    3041    position: relative; 
    3142    top: 100px; 
    3243    left: 65px; 
    33         color: #04155D; 
     44    color: #04155D; 
    3445} 
    3546 
    3647.plateform_selected, .plateform_selected:hover, 
    37 .parameter_selected, .parameter_selected:hover 
    38 { 
    39         background: #70739C; 
    40         color: #E1DEF1; 
    41         text-decoration: none; 
     48.parameter_selected, .parameter_selected:hover { 
     49    background: #70739C; 
     50    color: #E1DEF1; 
     51    text-decoration: none; 
    4252} 
    4353 
    44 .errorAndButtons{ 
    45 #       margin: 0px 22px; 
    46         margin-left: auto; 
     54.errorAndButtons { 
     55    /*margin: 0px 22px;*/ 
     56    margin-left: auto; 
    4757    margin-right: auto; 
    4858    max-width: 240px; 
     
    5060 
    5161#copyright { 
    52         margin-left:-80em; 
     62    margin-left: -80em; 
    5363} 
     64 
     65.messagesHeight { 
     66    margin-bottom: 5px; 
     67} 
     68 
    5469/** ************************************ **/ 
    5570/** ************ CALENDAR ************** **/ 
    5671/** ************************************ **/ 
    57 .embeddedCalendar 
    58 { 
    59         margin-top: 10px; 
    60         margin-bottom: 10px; 
    61         max-width: 240px; 
     72/*.embeddedCalendar*/ 
     73/*{*/ 
     74/*margin-top: 10px;*/ 
     75/*margin-bottom: 10px;*/ 
     76/*max-width: 240px;*/ 
     77/*}*/ 
     78 
     79#beginDate, #endDate { 
     80    background-image: url("../../resources/icons/calendrier-icone-16x16.png"); 
     81    background-position: right center; 
     82    background-repeat: no-repeat; 
    6283} 
    6384 
    64 div.leftField{ 
    65         float: left; 
    66         margin-left: 53px; 
     85div.leftField { 
     86    float: left; 
    6787} 
    6888 
    69 div.rightField{ 
    70         float: right; 
    71         margin-right: 53px; 
     89div.rightField { 
     90    float: right; 
     91    margin-right: 53px; 
    7292} 
    7393 
  • ether_megapoli/trunk/web/resources/js/etherClasses.js

    r89 r130  
    22/* ****************** LIST ************************* */ 
    33/* ************************************************* */ 
    4 var ListItem = Class.create({ 
     4var ListItem = Class.create( { 
    55 
    66    initialize: function( plateforms, objectParameter ) 
    77    { 
    88        this.array = $A(); 
    9         $A(plateforms).each(function( jsonObject ) 
     9        $A( plateforms ).each( function( jsonObject ) 
    1010        { 
    11             this.addItem(jsonObject, objectParameter); 
    12         }.bind(this)); 
     11            this.addItem( jsonObject, objectParameter ); 
     12        }.bind( this ) ); 
    1313    }, 
    1414 
     
    1919        var objectItemNew = new Object(); 
    2020        objectItemNew.jsonElement = jsonElement; 
    21         objectItemNew.divItem = this.createItemDiv(objectItemNew.jsonElement, objectParameter); 
     21        objectItemNew.divItem = this.createItemDiv( objectItemNew.jsonElement, objectParameter ); 
    2222 
    23         this.array.push(objectItemNew); 
     23        this.array.push( objectItemNew ); 
    2424    }, 
    2525 
    2626    createItemDiv: function( itemHash, objectParameter ) 
    2727    { 
    28         return new Plateform(itemHash, objectParameter); 
     28        return new Plateform( itemHash, objectParameter ); 
    2929    }, 
    3030 
    3131    addOpenListener : function( func ) 
    3232    { 
    33         this.array.each(function( objectItem ) 
     33        this.array.each( function( objectItem ) 
    3434        { 
    35             objectItem.divItem.addOpenListener(func); 
    36         }); 
     35            objectItem.divItem.addOpenListener( func ); 
     36        } ); 
    3737    }, 
    3838 
     
    4141        if( 0 >= this.array.size() ) 
    4242        { 
    43             var divNoItem = $(document.createElement("div")); 
     43            var divNoItem = $( document.createElement( "div" ) ); 
    4444            divNoItem.id = idIfNoItem; 
    4545            divNoItem.textContent = textIfNoItem; 
    46             parentNode.appendChild(divNoItem); 
     46            parentNode.appendChild( divNoItem ); 
    4747        } 
    4848        else 
    49             this.array.each(function( item ) 
     49            this.array.each( function( item ) 
    5050            { 
    51                 item.divItem.display(parentNode); 
    52             }); 
     51                item.divItem.display( parentNode ); 
     52            } ); 
    5353    }, 
    5454 
    5555    displayWithPairImpair : function( parentNode, idIfNoItem, textIfNoItem ) 
    5656    { 
    57         Dom.clearContainer(parentNode); 
     57        Dom.clearContainer( parentNode ); 
    5858        if( 0 >= this.array.size() ) 
    5959        { 
    60             var divNoItem = $(document.createElement("div")); 
     60            var divNoItem = $( document.createElement( "div" ) ); 
    6161            divNoItem.id = idIfNoItem; 
    6262            divNoItem.textContent = textIfNoItem; 
    63             parentNode.appendChild(divNoItem); 
     63            parentNode.appendChild( divNoItem ); 
    6464        } 
    6565        else 
    6666        { 
    67                 var rowNumber = 0; 
    68             this.array.each(function( item ) 
     67            var rowNumber = 0; 
     68            this.array.each( function( item ) 
    6969            { 
    70                 if(rowNumber % 2 == 0) 
    71                     item.divItem.display(parentNode,"pair"); 
    72                 else 
    73                     item.divItem.display(parentNode,"impair"); 
    74                 rowNumber++; 
    75             }); 
     70                if( rowNumber % 2 == 0 ) 
     71                    item.divItem.display( parentNode, "pair" ); 
     72                else 
     73                    item.divItem.display( parentNode, "impair" ); 
     74                rowNumber++; 
     75            } ); 
    7676        } 
    7777    }, 
     
    8080    { 
    8181        var returnObj = false; 
    82         this.array.each(function( objItem ) 
     82        this.array.each( function( objItem ) 
    8383        { 
    8484            if( objItem.jsonElement.id == itemId ) 
    8585                returnObj = objItem; 
    86         }.bind(this)); 
     86        }.bind( this ) ); 
    8787 
    8888        return returnObj; 
    8989    } 
    9090 
    91 }); 
     91} ); 
    9292 
    9393/* ************************************************* */ 
    9494/* ****************** ITEM ************************* */ 
    9595/* ************************************************* */ 
    96 var Item = Class.create({ 
     96var Item = Class.create( { 
    9797 
    9898    initialize: function( jsonElement, objectParameter ) 
    9999    { 
    100         this.jsonElement = Object.clone(jsonElement); // Warning: This is only a shallow copy 
     100        this.jsonElement = Object.clone( jsonElement ); // Warning: This is only a shallow copy 
    101101        this.listeners = $A(); 
    102102 
     
    124124    createContainer: function ( containerName, classNameValue ) 
    125125    { 
    126         this.divContainer = $(document.createElement("div")); 
     126        this.divContainer = $( document.createElement( "div" ) ); 
    127127        this.divContainer.item = this; 
    128         if(classNameValue) 
    129         this.divContainer.className = classNameValue; 
     128        if( classNameValue ) 
     129            this.divContainer.className = classNameValue; 
    130130        this.divContainer.id = containerName + "_" + this.jsonElement.id; 
    131131    }, 
     
    134134    { 
    135135        this.parentNode = parentNode; 
    136         parentNode.appendChild(this.divContainer); 
     136        parentNode.appendChild( this.divContainer ); 
    137137    }, 
    138138 
     
    146146    { 
    147147        if( classNameValue ) 
    148             this.divContainer.addClassName(classNameValue); 
     148            this.divContainer.addClassName( classNameValue ); 
    149149    }, 
    150150 
     
    152152    { 
    153153        if( classNameValue ) 
    154             this.divContainer.removeClassName(classNameValue); 
     154            this.divContainer.removeClassName( classNameValue ); 
    155155    }, 
    156156 
    157157    executeListenersFunction: function() 
    158158    { 
    159         this.listeners.each(function ( func ) 
     159        this.listeners.each( function ( func ) 
    160160        { 
    161             func(this); 
    162         }.bind(this)); 
     161            func( this ); 
     162        }.bind( this ) ); 
    163163    }, 
    164164 
     
    166166    { 
    167167        if( this.divContainer ) 
    168             Event.observe(this.divContainer, 'click', this.onClickContainer.bindAsEventListener(this)); 
     168            Event.observe( this.divContainer, 'click', this.onClickContainer.bindAsEventListener( this ) ); 
    169169    }, 
    170170 
    171171    addOpenListener: function( func ) 
    172172    { 
    173         this.listeners.push(func); 
     173        this.listeners.push( func ); 
    174174    }, 
    175175 
     
    179179            return; 
    180180 
    181         this.divName = $(document.createElement("div")); 
     181        this.divName = $( document.createElement( "div" ) ); 
    182182        this.divName.className = classNameValue; 
    183183        this.divName.innerHTML = this.jsonElement.name; 
    184184 
    185         this.divContainer.appendChild(this.divName); 
     185        this.divContainer.appendChild( this.divName ); 
     186    }, 
     187 
     188    getName: function () 
     189    { 
     190        return this.jsonElement.name; 
    186191    } 
    187 }); 
     192 
     193} ); 
  • ether_megapoli/trunk/web/resources/jsp/etherHead.jsp

    r89 r130  
    11<%@ taglib prefix="ether" tagdir="/WEB-INF/tags" %> 
    22 
    3 <ether:htmlJs jsFile="library/prototype/prototype"/> 
     3<ether:htmlJs jsFile="library/prototype"/> 
    44<ether:htmlJs jsFile="Request"/> 
    55<ether:htmlJs jsFile="DomHelper"/> 
  • ether_megapoli/trunk/web/resources/templates/template.jsp

    r89 r130  
    1818        <link rel="shortcut icon" href="<html:rewrite page='/resources/images/megapoli/favicon.ico'/>"> 
    1919        <script src="<html:rewrite page='/resources/js/maj.js'/>"></script> 
    20         <script src="<html:rewrite page='/resources/js/ajax.js'/>"></script> 
     20        <script src="<html:rewrite page='/resources/js/medias/ajax.js'/>"></script> 
    2121        <script type="text/javascript"> 
    2222        <!-- 
  • ether_megapoli/trunk/web/src/ApplicationResources.properties

    r129 r130  
    408408data.visualization.noParameter=Pas de param\u00E8tre 
    409409data.visualization.selectParameter=Param\u00E8tres 
    410 data.visualization.selectTime=P\u00E9riode 
     410data.visualization.selectPeriod=P\u00E9riode 
    411411data.visualization.selectDate=Choisissez une date 
     412data.visualization.selectYear=Ann\u00E9e 
     413data.visualization.selectMonth=Mois 
     414data.visualization.selectDay=Jour 
     415data.visualization.selectTime=Choisissez un temps 
     416data.visualization.selectHour=Heure 
     417data.visualization.selectMinute=Minute 
    412418data.visualization.BeginDate=Date de d\u00E9but : 
    413419data.visualization.EndDate=Date de fin : 
    414420data.visualization.Unvalid_Period=P\u00E9riode non valide ! 
     421data.visualization.titleChoice=Title 
     422data.visualization.axe=Axes 
     423data.visualization.button.clear=Effacer 
    415424data.visualization.button.visualize=Visualisation 
    416425data.visualization.button.download=T\u00E9l\u00E9chargement 
     
    419428data.visualization.quicklook=Quicklook 
    420429 
     430data.visualization.axeType.Time=S\u00E9rie temporelle 
     431data.visualization.axeType.Latitude=Latitude / Longitude 
     432 
    421433simulation.visualization=Visualisation des simulations 
    422434 
     
    424436plot.published=Publi\u00E9 le 
    425437plot.dataNumber=Nombre de donn\u00E9es extraites : 
     438plot.errorMessage=Erreur de cr\u00E9ation du quicklook. <BR>Veuillez essayer de corriger les erreurs suivantes ou contacter l'administrateur en indiquant les erreurs rencontr\u00E9es. 
     439plot.noData=Aucune donn\u00E9e extraite 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r129 r130  
    395395data.visualization.noParameter=No parameter 
    396396data.visualization.selectParameter=Parameters 
    397 data.visualization.selectTime=Period 
     397data.visualization.selectPeriod=Period 
    398398data.visualization.selectDate=Select a date 
    399 data.visualization.BeginDate=Start date :  
     399data.visualization.selectYear=Year 
     400data.visualization.selectMonth=Month 
     401data.visualization.selectDay=Day 
     402data.visualization.selectTime=Select a time 
     403data.visualization.selectHour=Hour 
     404data.visualization.selectMinute=Minute 
     405data.visualization.BeginDate=Start date : 
    400406data.visualization.EndDate=End date : 
    401 data.visualization.Unvalid_Period=Unvalid periode !  
     407data.visualization.Unvalid_Period=Unvalid periode ! 
     408data.visualization.titleChoice=Titre 
     409data.visualization.axe=Axes 
     410data.visualization.button.clear=Clear 
    402411data.visualization.button.visualize=Visualization 
    403412data.visualization.button.download=Download 
     
    406415data.visualization.quicklook=Quicklook 
    407416 
     417data.visualization.axeType.Time=Time serie 
     418data.visualization.axeType.Latitude=Latitude / Longitude 
     419 
    408420simulation.visualization=Simulations visualization 
    409421 
     
    411423plot.published=Published 
    412424plot.dataNumber=Number of extracted datas : 
     425plot.errorMessage=Error creating the quicklook. <BR>Please try to correct the following errors or contact the administrator with the detected errors. 
     426plot.noData=No extracted data 
  • ether_megapoli/trunk/web/src/com/ether/Controller.java

    r129 r130  
    1515import javax.servlet.http.HttpServletRequest; 
    1616import javax.servlet.http.HttpServletResponse; 
     17import java.util.ArrayList; 
    1718import java.util.HashMap; 
    1819import java.util.List; 
     
    2829    /** *********************************************************** **/ 
    2930    /** *********************** VIEWS ***************************** **/ 
    30     /** *********************************************************** **/ 
     31    /** 
     32     * ********************************************************** * 
     33     */ 
    3134    // Default view if methodName is unknown 
    3235    public ModelAndView home( final HttpServletRequest request, final HttpServletResponse response ) 
    33             throws WebException 
     36            throws EtherException 
    3437    { 
    3538        return new ModelAndView( "index" ); 
     
    4851    { 
    4952        final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 
     53//        final List<Plateforme> plateforms = new ArrayList<Plateforme>(); 
     54//        final Plateforme pf = new Plateforme(); 
     55//        pf.setPlateformeId( 1 ); 
     56//        pf.setPlateformeNom( "LHVP" ); 
     57//        plateforms.add( pf ); 
     58//        final Plateforme pf2 = new Plateforme(); 
     59//        pf2.setPlateformeId( 2 ); 
     60//        pf2.setPlateformeNom( "SIRTA" ); 
     61//        plateforms.add( pf2 ); 
    5062 
    5163        final Map<String, Object> model = new HashMap<String, Object>(); 
    5264        model.put( "plateforms", getJsonHelper().toJSON( plateforms ) ); 
     65        model.put( "axeTypes", getJSONAxeTypes() ); 
    5366        return model; 
    5467    } 
     
    5669    /** *********************************************************** **/ 
    5770    /** *********************** CALLS ***************************** **/ 
    58     /** ********************************************************** **/ 
     71    /** 
     72     * ********************************************************* * 
     73     */ 
    5974    @ControllerMethod(jsonResult = true) 
    6075    public JSONObject searchParametersByPlateform( @Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId ) 
    61             throws ServiceException, WebException 
     76            throws ServiceException, EtherException 
    6277    { 
    6378        final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 
     79//        final List<Parametre> parametersByPlateform = new ArrayList<Parametre>( 2 ); 
     80//        final Parametre p1 = new Parametre(); 
     81//        p1.setParametreId( 1 ); 
     82//        p1.setParametreNom( "JNO2" ); 
     83//        parametersByPlateform.add( p1 ); 
     84//        final Parametre p2 = new Parametre(); 
     85//        p2.setParametreId( 2 ); 
     86//        p2.setParametreNom( "CO2" ); 
     87//        parametersByPlateform.add( p2 ); 
    6488 
    6589        final JSONObject result = new JSONObject(); 
    6690        result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform ) ); 
    6791        return result; 
     92    } 
     93 
     94    @ControllerMethod(jsonResult = true) 
     95    private List<JSONObject> getJSONAxeTypes() 
     96    { 
     97        final AxeType[] axeTypes = AxeType.values(); 
     98 
     99        final List<JSONObject> jsonAxeTypes = new ArrayList<JSONObject>( axeTypes.length ); 
     100 
     101        for( final AxeType axeType : axeTypes ) 
     102        { 
     103            final JSONObject jsonAxeType = new JSONObject(); 
     104            jsonAxeType.put( "text", axeType.name() ); 
     105            jsonAxeType.put( "value", axeType.name() ); 
     106            jsonAxeTypes.add( jsonAxeType ); 
     107        } 
     108        return jsonAxeTypes; 
    68109    } 
    69110 
  • ether_megapoli/trunk/web/src/com/ether/ControllerEther.java

    r89 r130  
    11package com.ether; 
    22 
     3import com.ether.annotation.ControllerMethod; 
     4import com.ether.annotation.Mandatory; 
     5import com.ether.annotation.ParamName; 
     6import com.ether.annotation.UseJSON; 
     7import net.sf.json.JSON; 
     8import net.sf.json.JSONArray; 
     9import net.sf.json.JSONNull; 
     10import net.sf.json.JSONObject; 
     11import net.sf.json.util.JSONUtils; 
     12import org.apache.commons.logging.Log; 
     13import org.apache.commons.logging.LogFactory; 
     14import org.jetbrains.annotations.NotNull; 
     15import org.jetbrains.annotations.Nullable; 
     16import org.springframework.beans.factory.annotation.Required; 
     17import org.springframework.web.servlet.ModelAndView; 
     18import org.springframework.web.servlet.mvc.AbstractController; 
     19import org.springframework.web.servlet.mvc.multiaction.MethodNameResolver; 
     20import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; 
     21 
     22import javax.servlet.http.HttpServletRequest; 
     23import javax.servlet.http.HttpServletResponse; 
    324import java.io.UnsupportedEncodingException; 
    425import java.lang.annotation.Annotation; 
     
    1233import java.util.Map; 
    1334 
    14 import javax.servlet.http.HttpServletRequest; 
    15 import javax.servlet.http.HttpServletResponse; 
    16  
    17 import net.sf.json.JSON; 
    18 import net.sf.json.JSONArray; 
    19 import net.sf.json.JSONNull; 
    20 import net.sf.json.JSONObject; 
    21 import net.sf.json.util.JSONUtils; 
    22  
    23 import org.apache.commons.logging.Log; 
    24 import org.apache.commons.logging.LogFactory; 
    25 import org.jetbrains.annotations.NotNull; 
    26 import org.jetbrains.annotations.Nullable; 
    27 import org.springframework.beans.factory.annotation.Required; 
    28 import org.springframework.web.servlet.ModelAndView; 
    29 import org.springframework.web.servlet.mvc.AbstractController; 
    30 import org.springframework.web.servlet.mvc.multiaction.MethodNameResolver; 
    31 import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; 
    32  
    33 import com.ether.annotation.ControllerMethod; 
    34 import com.ether.annotation.Mandatory; 
    35 import com.ether.annotation.ParamName; 
    36 import com.ether.annotation.UseJSON; 
    37  
    38 public class ControllerEther extends AbstractController 
     35public class ControllerEther 
     36        extends AbstractController 
    3937{ 
    40         @Override 
    41         @Nullable 
    42         protected ModelAndView handleRequestInternal(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response) 
    43                 throws WebException 
    44         { 
    45                 try { 
    46                         if (!_initialized) 
    47                                 initialize(); 
    48  
    49                         request.setCharacterEncoding(UTF8Charset.getEncoding()); 
    50                          
    51                         // Get method to call 
    52                         final String methodName = _methodNameResolver.getHandlerMethodName(request); 
    53  
    54                         final MethodDescription methodDescription = _methods.get(methodName); 
    55                         if (null == methodDescription) { 
    56                                 WebHelper.displayAjaxError(response, methodName); 
    57                                 if (LOGGER.isWarnEnabled()) 
    58                                         LOGGER.warn(String.format("Controller=%1$s Method=%2$s METHOD NOT FOUND", getClass().getSimpleName(), methodName)); 
    59                                 return null; 
    60                         } 
    61  
    62                         return invokeMethod(methodDescription, request, response); 
    63  
    64                 } catch (UnsupportedEncodingException e) { 
    65                         throw new WebException(WebException.WebCode.ERROR_UNSUPPORTED_UTF8_ENCODING, e); 
    66                 } catch (NoSuchRequestHandlingMethodException e) { 
    67                         throw new WebException(WebException.WebCode.ERROR_NO_REQUEST_HANDLING_METHOD, e); 
    68                 } 
    69         } 
    70  
    71         @Nullable 
    72         private ModelAndView invokeMethod( @NotNull final MethodDescription methodDescription, @NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response) 
    73                 throws WebException  
    74         { 
    75                 try { 
    76                         // Parse parameters 
    77                         final Object[] params = buildParams(methodDescription, request); 
    78  
    79                         // Invoke method (go to controller) 
    80                         final Object result = methodDescription.getMethod().invoke(this, params); 
    81                          
    82                         // Return result 
    83                         if (!methodDescription.getView().isEmpty()) { 
    84                                 response.setStatus(HttpServletResponse.SC_OK); 
    85                                 if (result instanceof Map) 
    86                                         return new ModelAndView(methodDescription.getView(), (Map) result); 
    87                                 else 
    88                                         return new ModelAndView(methodDescription.getView(), "result", result); 
    89                                  
    90                         } else if (methodDescription.isJsonResult()) { 
    91                                 response.setStatus(HttpServletResponse.SC_OK); 
    92                                 final String jsonResult = convertToJson(result); 
    93                                 WebHelper.writeJsonToResponse(response, jsonResult);                             
    94                                 return null; 
    95                         } else { 
    96                                 response.setStatus(HttpServletResponse.SC_NO_CONTENT); 
    97                                 return null; 
    98                         } 
    99                          
    100                 } catch (Throwable e) { 
    101                         throw new WebException(e); 
    102                 } 
    103         }        
    104          
    105         @NotNull 
    106         private String convertToJson( @Nullable final Object object ) 
    107     { 
    108         if( null == object) 
     38    @Override 
     39    @Nullable 
     40    protected ModelAndView handleRequestInternal( @NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response ) 
     41            throws WebException, EtherException 
     42    { 
     43        try 
     44        { 
     45            if( !_initialized ) 
     46                initialize(); 
     47 
     48            request.setCharacterEncoding( UTF8Charset.getEncoding() ); 
     49 
     50            // Get method to call 
     51            final String methodName = _methodNameResolver.getHandlerMethodName( request ); 
     52 
     53            final MethodDescription methodDescription = _methods.get( methodName ); 
     54            if( null == methodDescription ) 
     55            { 
     56                WebHelper.displayAjaxError( response, methodName ); 
     57                if( LOGGER.isWarnEnabled() ) 
     58                    LOGGER.warn( String.format( "Controller=%1$s Method=%2$s METHOD NOT FOUND", getClass().getSimpleName(), methodName ) ); 
     59                return null; 
     60            } 
     61 
     62            return invokeMethod( methodDescription, request, response ); 
     63 
     64        } 
     65        catch( UnsupportedEncodingException e ) 
     66        { 
     67            throw new WebException( WebException.WebCode.ERROR_UNSUPPORTED_UTF8_ENCODING, e ); 
     68        } 
     69        catch( NoSuchRequestHandlingMethodException e ) 
     70        { 
     71            throw new WebException( WebException.WebCode.ERROR_NO_REQUEST_HANDLING_METHOD, e ); 
     72        } 
     73    } 
     74 
     75    @Nullable 
     76    private ModelAndView invokeMethod( @NotNull final MethodDescription methodDescription, @NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response ) 
     77            throws WebException 
     78    { 
     79        try 
     80        { 
     81            // Parse parameters 
     82            final Object[] params = buildParams( methodDescription, request ); 
     83 
     84            // Invoke method (go to controller) 
     85            final Object result = methodDescription.getMethod().invoke( this, params ); 
     86 
     87            // Return result 
     88            if( !methodDescription.getView().isEmpty() ) 
     89            { 
     90                response.setStatus( HttpServletResponse.SC_OK ); 
     91                if( result instanceof Map ) 
     92                    return new ModelAndView( methodDescription.getView(), (Map) result ); 
     93                else 
     94                    return new ModelAndView( methodDescription.getView(), "result", result ); 
     95 
     96            } 
     97            else if( methodDescription.isJsonResult() ) 
     98            { 
     99                response.setStatus( HttpServletResponse.SC_OK ); 
     100                final String jsonResult = convertToJson( result ); 
     101                WebHelper.writeJsonToResponse( response, jsonResult ); 
     102                return null; 
     103            } 
     104            else 
     105            { 
     106                response.setStatus( HttpServletResponse.SC_NO_CONTENT ); 
     107                return null; 
     108            } 
     109 
     110        } 
     111        catch( Throwable e ) 
     112        { 
     113            throw new WebException( e ); 
     114        } 
     115    } 
     116 
     117    @NotNull 
     118    private String convertToJson( @Nullable final Object object ) 
     119    { 
     120        if( null == object ) 
    109121            return JSONNull.getInstance().toString(); 
    110122        if( object instanceof JSON ) 
     
    119131    } 
    120132 
    121         @NotNull 
    122         private Object[] buildParams(@NotNull final MethodDescription methodDescription, @NotNull final HttpServletRequest request)  
    123                 throws InvalidParameterException  
    124         { 
    125                 final List<Object> params = new ArrayList<Object>(); 
    126                 for (final ParamDescription paramDescription : methodDescription.getParams()) { 
    127                         if (null == paramDescription) { 
    128                                 params.add(null); 
    129                                 continue; 
    130                         } 
    131                         final boolean canBeNull = !paramDescription.isPrimitive() && !paramDescription.isMandatory(); 
    132                         final String paramValue = WebHelper.getRequestParameter(request, paramDescription.getName(), null, canBeNull); 
    133                         final boolean useJSON = paramDescription.isUsingJSON(); 
    134                         params.add(convertParameter(paramDescription.getType(), paramValue, useJSON)); 
    135                 } 
    136                 return params.toArray(new Object[params.size()]); 
    137         } 
    138          
    139         @Nullable 
    140         private Object convertParameter( @NotNull final Class paramType, @Nullable final String paramValue, final boolean useJSON ) 
     133    @NotNull 
     134    private Object[] buildParams( @NotNull final MethodDescription methodDescription, @NotNull final HttpServletRequest request ) 
     135            throws InvalidParameterException 
     136    { 
     137        final List<Object> params = new ArrayList<Object>(); 
     138        for( final ParamDescription paramDescription : methodDescription.getParams() ) 
     139        { 
     140            if( null == paramDescription ) 
     141            { 
     142                params.add( null ); 
     143                continue; 
     144            } 
     145            final boolean canBeNull = !paramDescription.isPrimitive() && !paramDescription.isMandatory(); 
     146            final String paramValue = WebHelper.getRequestParameter( request, paramDescription.getName(), null, canBeNull ); 
     147            final boolean useJSON = paramDescription.isUsingJSON(); 
     148            params.add( convertParameter( paramDescription.getType(), paramValue, useJSON ) ); 
     149        } 
     150        return params.toArray( new Object[params.size()] ); 
     151    } 
     152 
     153    @Nullable 
     154    private Object convertParameter( @NotNull final Class paramType, @Nullable final String paramValue, final boolean useJSON ) 
    141155    { 
    142156        if( null == paramValue ) 
     
    148162        if( JSONArray.class.equals( paramType ) ) 
    149163            return _jsonHelper.toJSON( paramValue ); 
    150         if( String.class .equals( paramType ) ) 
     164        if( String.class.equals( paramType ) ) 
    151165            return paramValue; 
    152166        if( Boolean.TYPE.equals( paramType ) || Boolean.class.equals( paramType ) ) 
     
    170184    } 
    171185 
    172     private void initialize()  
    173         throws WebException 
     186    private void initialize() 
     187            throws WebException 
    174188    { 
    175189        for( final Method method : getClass().getMethods() ) 
     
    178192            if( null != annotation ) 
    179193            { 
    180                 final MethodDescription methodDescription = new MethodDescription( method, annotation ); 
    181                 fillMethodDescription( method, methodDescription ); 
    182                 _methods.put( method.getName(), methodDescription ); 
     194                final MethodDescription methodDescription = new MethodDescription( method, annotation ); 
     195                fillMethodDescription( method, methodDescription ); 
     196                _methods.put( method.getName(), methodDescription ); 
    183197            } 
    184198        } 
     
    187201    } 
    188202 
    189     private void fillMethodDescription( @NotNull final Method method, @NotNull final MethodDescription methodDescription )  
    190         throws WebException 
     203    private void fillMethodDescription( @NotNull final Method method, @NotNull final MethodDescription methodDescription ) 
     204            throws WebException 
    191205    { 
    192206        final Class<?>[] paramTypes = method.getParameterTypes(); 
    193207        final Annotation[][] paramAnnotations = method.getParameterAnnotations(); 
    194208 
    195         if(paramTypes.length != paramAnnotations.length) 
    196                 throw new WebException(WebException.WebCode.ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, paramTypes.length+" "+paramAnnotations.length); 
    197           
     209        if( paramTypes.length != paramAnnotations.length ) 
     210            throw new WebException( WebException.WebCode.ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, paramTypes.length + " " + paramAnnotations.length ); 
     211 
    198212        for( int i = 0; i < paramTypes.length; ++i ) 
    199213        { 
     
    219233            } 
    220234        } 
    221     }     
    222  
    223      
     235    } 
     236 
     237 
    224238    @Required 
    225239    public void setMethodNameResolver( final MethodNameResolver methodNameResolver ) 
     
    236250    public void setJsonHelper( final JSONHelper jsonHelper ) 
    237251    { 
    238         _jsonHelper = jsonHelper; 
     252        _jsonHelper = jsonHelper; 
    239253    } 
    240254 
     
    245259 
    246260    private static final Log LOGGER = LogFactory.getLog( ControllerEther.class ); 
    247     
     261 
    248262    private JSONHelper _jsonHelper; 
    249263    private MethodNameResolver _methodNameResolver; 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r129 r130  
    88import org.apache.commons.logging.LogFactory; 
    99import org.jetbrains.annotations.NotNull; 
     10import org.jetbrains.annotations.Nullable; 
    1011import org.springframework.context.ApplicationContext; 
    1112import org.springframework.web.context.support.WebApplicationContextUtils; 
     
    1920import java.awt.image.BufferedImage; 
    2021import java.io.IOException; 
    21 import java.text.ParseException; 
     22import java.util.ArrayList; 
     23import java.util.Calendar; 
    2224import java.util.Date; 
    2325import java.util.List; 
     
    5759            throws ServletException 
    5860    { 
     61        boolean flagException = false; 
     62 
    5963        try 
    6064        { 
     65            //Parameters 
    6166            final Integer plateformId = Integer.valueOf( request.getParameter( "plateformId" ) ); 
    6267            final Integer parameterId = Integer.valueOf( request.getParameter( "parameterId" ) ); 
     68            final String title = request.getParameter( "title" ); 
     69            final String axeType = request.getParameter( "axeType" ); 
     70 
    6371            final String dateBegin = request.getParameter( "dateBegin" ); 
    6472            final String dateEnd = request.getParameter( "dateEnd" ); 
    65             final String pofBegin = "2009-07-13 13:00"; 
    66             final String pofEnd = "2009-07-14 14:00"; 
    67             final Date formatedDateBegin = DateHelper.parseDate( pofBegin, DateHelper.ENGLISH_DATE_PATTERN ); 
    68             final Date formatedDateEnd = DateHelper.parseDate( pofEnd, DateHelper.ENGLISH_DATE_PATTERN ); 
     73            final Calendar calendar = Calendar.getInstance(); 
     74            final Date formatedDateBegin; 
     75            final Date formatedDateEnd; 
     76            try 
     77            { 
     78                calendar.setTimeInMillis( Long.valueOf( dateBegin ) ); 
     79                formatedDateBegin = calendar.getTime(); 
     80                calendar.setTimeInMillis( Long.valueOf( dateEnd ) ); 
     81                formatedDateEnd = calendar.getTime(); 
     82            } 
     83            catch( Exception e ) 
     84            { 
     85                createErrorPane( response, request, WebException.WebCode.INVALID_DATE.toString(), e ); 
     86                flagException = true; 
     87                throw new ServletException( WebException.WebCode.INVALID_DATE.toString(), e ); 
     88            } 
    6989 
     90            // Create plot 
    7091            //** ******************************************************************** **// 
    7192            // TODO : replace List<Data> by List<value> and List<double> 
    7293            //** ******************************************************************** **// 
    73             final List<Pair<Double, Date>> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     94//            final List<Pair<Double, Date>> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     95            final List<Pair<Double, Date>> values = new ArrayList<Pair<Double, Date>>(); 
     96            final Pair<Double, Date> p1 = new Pair<Double, Date>( Double.valueOf( 23 ), new Date() ); 
     97            final Pair<Double, Date> p2 = new Pair<Double, Date>( Double.valueOf( 24 ), new Date() ); 
     98            final Pair<Double, Date> p3 = new Pair<Double, Date>( Double.valueOf( 25 ), new Date() ); 
     99            final Pair<Double, Date> p4 = new Pair<Double, Date>( Double.valueOf( 26 ), new Date() ); 
     100            values.add( p1 ); 
     101            values.add( p2 ); 
     102            values.add( p3 ); 
     103            values.add( p4 ); 
    74104            final double[] dataArray = extractDoubles( values ); 
    75105            final Date[] dateValues = extractDates( values ); 
     
    88118 
    89119            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
    90             megapoliPlot.setTitle( "Mobilis LIDAR" ); 
     120            megapoliPlot.setTitle( title ); 
    91121            megapoliPlot.setData( data ); 
    92122 
    93             final BufferedImage bufferedImage = _etherPlotService.createJPane( megapoliPlot, Context.getLocale( request ) ); 
    94  
     123            final BufferedImage bufferedImage = _etherPlotService.createMainPane( megapoliPlot, Context.getLocale( request ) ); 
    95124            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
    96125        } 
    97         catch( IOException e ) 
     126        catch( Exception e1 ) 
    98127        { 
    99             throw new ServletException( "Error : no possibity to write image in response", e ); 
     128            try 
     129            { 
     130                if( !flagException ) 
     131                    createErrorPane( response, request, "", e1 ); 
     132            } 
     133            catch( Exception e2 ) 
     134            { 
     135                throw new ServletException( "Error : no possibity to write image in response", e2 ); 
     136            } 
    100137        } 
    101         catch( ServiceException e ) 
    102         { 
    103             throw new ServletException( "Error : no possibility to extract data from base", e ); 
    104         } 
    105         catch( ParseException e ) 
    106         { 
    107             throw new ServletException( "Error : invalid dates, no parsing available", e ); 
    108         } 
     138    } 
     139 
     140    private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @NotNull final Exception e ) 
     141            throws IOException 
     142    { 
     143        final BufferedImage errorImage = _etherPlotService.createErrorPane( mainError, e.toString(), Context.getLocale( request ) ); 
     144        ImageIO.write( errorImage, "png", response.getOutputStream() ); 
    109145    } 
    110146 
     
    137173    private static final Log LOGGER = LogFactory.getLog( ControllerPlot.class ); 
    138174 
    139     // Dimensions of the jPanes 
    140     private static final int MAIN_WIDTH = 1000; 
    141     private static final int MAIN_HEIGHT = 1000; 
    142  
    143175    private EtherService _etherService; 
    144176    private EtherPlotService _etherPlotService; 
  • ether_megapoli/trunk/web/src/com/ether/WebException.java

    r89 r130  
    3030        public static enum WebCode implements Code  
    3131    { 
    32                 UNKNOWN,  
    33                 PERSISTENCE,  
    34                 SERVICE_PROBLEM, 
    35                 PLATEFORME_ID_NOT_FOUND, 
    36                 IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, 
    3732                ERROR_UNSUPPORTED_UTF8_ENCODING, 
    3833                ERROR_NO_REQUEST_HANDLING_METHOD, 
    3934                ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
     35        INVALID_DATE, 
    4036    } 
    4137} 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r129 r130  
    22var InterfaceVisualization = Class.create( { 
    33 
    4     initialize: function( jsonPlateforms ) 
     4    initialize: function( jsonPlateforms, axeTypes ) 
    55    { 
    66        // Values 
     
    99        this.generalContainerPlateforms = $( "generalContainerPlateforms" ); 
    1010        this.generalContainerParameters = $( "generalContainerParameters" ); 
    11         this.generalContainerCalendar = $( "generalContainerCalendar" ); 
     11        this.generalContainerOptions = $( "generalContainerOptions" ); 
    1212        this.jsonPlateforms = jsonPlateforms || null; 
     13        this.jsonAxeTypes = axeTypes || null; 
    1314        this.selectedPlateform = false; 
    1415        this.selectedParameter = false; 
    1516        this.beginDate = false; 
    1617        this.endDate = false; 
    17         this.notice = Dom.getContainer( "notice" ); 
    1818 
    1919        /** *********** CONTAINERS *********** **/ 
    20         // Create container for plateforms 
    21         this.containerPlateforms = Dom.getContainer( "containerPlateforms" ); 
    22         this.containerParameters = Dom.getContainer( "containerParameters" ); 
    23         this.containerButtons = Dom.getContainer( "containerButtons" ); 
     20        this.containerPlateforms = $( "containerPlateforms" ); 
     21        this.containerParameters = $( "containerParameters" ); 
     22        this.containerButtons = $( "containerButtons" ); 
     23        this.containerOptionCalendar = $( "containerOptionCalendar" ); 
     24        this.containerOptionAxe = $( "containerOptionAxe" ); 
    2425 
    2526        /** *********** LOADING *********** **/ 
     
    3839        this.loadingParameters.display(); 
    3940 
    40         /** *********** BUTTONS *********** **/ 
    41         this.visualizeButton = new Button( {value:interfaceTexts["data.visualization.button.visualize"], parent:this.containerButtons, id:"button_visualize", onClick:this.onClickVisualize.bind( this )} ); 
    42         this.visualizeButton.enable(); 
    43         this.downloadButton = new Button( {value:interfaceTexts["data.visualization.button.download"], parent:this.containerButtons, id:"button_download", onClick:this.onClickDownload.bind( this )} ); 
    44         this.downloadButton.disable(); 
    45  
    46  
    4741        /** *********** WINDOW FOR THE PLOT *********** **/ 
    4842        this.plotWindow = new Window( {className: "dialog", zIndex: 100, 
     
    5145        this.plotWindow.setTitle( interfaceTexts["app.title"] + "-" + interfaceTexts["data.visualization.quicklook"] ); 
    5246 
    53  
    54         this.createCalendar(); 
     47        this.createOptions(); 
    5548        this.displayPlateforms(); 
     49    }, 
     50 
     51    // CREATES ******************************************************** 
     52    createOptions: function() 
     53    { 
     54        // Calendar 
     55        this.calendarFormat = "%Y-%m-%d %H:%i"; 
     56        this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } ); 
     57 
     58        AnyTime.picker( "beginDate", { format: this.calendarFormat, firstDOW: 1, 
     59            labelTitle: interfaceTexts["data.visualization.selectDate"], labelYear: interfaceTexts["data.visualization.selectYear"], labelMonth: interfaceTexts["data.visualization.selectMonth"], labelDayOfMonth: interfaceTexts["data.visualization.selectDay"], 
     60            labelHour: interfaceTexts["data.visualization.selectHour"], labelMinute: interfaceTexts["data.visualization.selectMinute"], 
     61            methodToCall: this.onClickBeginDate.bindAsEventListener( this ) 
     62        } ); 
     63 
     64        AnyTime.picker( "endDate", { format: this.calendarFormat, firstDOW: 1, 
     65            labelTitle: interfaceTexts["data.visualization.selectDate"], labelYear: interfaceTexts["data.visualization.selectYear"], labelMonth: interfaceTexts["data.visualization.selectMonth"], labelDayOfMonth: interfaceTexts["data.visualization.selectDay"], 
     66            labelHour: interfaceTexts["data.visualization.selectHour"], labelMinute: interfaceTexts["data.visualization.selectMinute"], 
     67            idToUpdateEarliest: "beginDate" 
     68        } ); 
     69 
     70        this.clearButton = new Button( {value:interfaceTexts["data.visualization.button.clear"], parent:this.containerOptionCalendar, id:"button_clear", className:"small", onClick:this.onClickClear.bind( this )} ); 
     71 
     72        // Buttons and axe's types 
     73        this.createButtons(); 
     74        this.createListAxes(); 
     75    }, 
     76 
     77    createButtons: function() 
     78    { 
     79        this.visualizeButton = new Button( {value:interfaceTexts["data.visualization.button.visualize"], parent:this.containerButtons, id:"button_visualize", onClick:this.onClickVisualize.bind( this )} ); 
     80//        this.visualizeButton.disable(); 
     81        this.downloadButton = new Button( {value:interfaceTexts["data.visualization.button.download"], parent:this.containerButtons, id:"button_download", onClick:this.onClickDownload.bind( this )} ); 
     82        this.downloadButton.disable(); 
     83    }, 
     84 
     85    createListAxes: function() 
     86    { 
     87        var paramSelect = new Object(); 
     88        paramSelect.id = "select_axes"; 
     89        paramSelect.parent = $( "containerOptionAxe" ); 
     90        this.selectAxes = new Select( paramSelect ); 
     91 
     92        this.jsonAxeTypes.each( function ( axeType ) 
     93        { 
     94            this.selectAxes.add( axeType.value, interfaceTexts[axeType.text] ); 
     95        }.bind( this ) ); 
     96 
     97        this.selectAxes.selectFirst( false ); 
    5698    }, 
    5799 
     
    73115    }, 
    74116 
    75     handleValuesByPlateformByParameterByPeriod: function( result ) 
    76     { 
    77 //              this.notice.style.visibility = "hidden";         
    78  
    79         this.jsonEncodedImage = result.responseText.evalJSON().encodedImage; 
    80  
    81  
    82     }, 
    83  
    84117    // DISPLAYS ******************************************************** 
    85     createCalendar: function() 
    86     { 
    87         // Embedded Calendar 
    88         this.calendar = Calendar.setup( 
    89         { 
    90             dateField: 'embeddedDateField', 
    91             endDateField: 'embeddedEndDateField', 
    92             parentElement: 'embeddedCalendar', 
    93             clickToDateField: true, 
    94             selectHandler: this.onClickCalendar.bind( this ) 
    95         } ) 
    96     }, 
    97  
    98118    displayPlateforms: function() 
    99119    { 
     
    141161            this.selectedParameter = false; 
    142162 
     163        $( "textareaTitle" ).value = this.selectedPlateform.getName(); 
    143164        this.requestParametersByPlateform(); 
    144165        this.testAllFields(); 
     
    156177        this.selectedParameter = objParameter; 
    157178        this.selectedParameter.select(); 
     179 
     180        $( "textareaTitle" ).value = this.selectedPlateform.getName() + " - " + this.selectedParameter.getName(); 
    158181        this.testAllFields(); 
    159182    }, 
    160183 
    161     onClickCalendar: function( calendar ) 
    162     { 
    163         if( !calendar.dateField ) return false 
    164  
    165         if( calendar.clickToDateField ) 
    166         { 
    167             Element.update( calendar.dateField, calendar.date.print( calendar.dateFormat ) ) 
    168             this.beginDate = calendar.date.print( calendar.dateFormat ); 
    169         } 
    170         else 
    171         { 
    172             Element.update( calendar.endDateField, calendar.date.print( calendar.dateFormat ) ) 
    173             this.endDate = calendar.date.print( calendar.dateFormat ); 
    174         } 
    175         calendar.setClickToDateField( !calendar.clickToDateField ); 
    176         this.testCalendarPeriod( calendar.dateField.innerHTML, calendar.endDateField.innerHTML ); 
    177  
    178         // Call the close handler, if necessary 
    179         if( calendar.shouldClose ) calendar.callCloseHandler() 
     184    onClickBeginDate: function() 
     185    { 
     186        var oneHour = 60 * 60 * 1000; 
     187        var beginDateTime = this.calendarConverter.parse( $( "beginDate" ).value ).getTime(); 
     188        var endDateTime = null; 
     189        if( "" != $( "endDate" ).value ) 
     190            endDateTime = this.calendarConverter.parse( $( "endDate" ).value ).getTime(); 
     191        this.beginDateWithAnHourLater = new Date( beginDateTime + oneHour ); 
     192 
     193        if( null == endDateTime || endDateTime < beginDateTime ) 
     194            $( "endDate" ).value = this.calendarConverter.format( this.beginDateWithAnHourLater ); 
     195 
     196        this.beginDate = this.calendarConverter.parse( $( "beginDate" ).value ).getTime(); 
     197        this.endDate = this.calendarConverter.parse( $( "endDate" ).value ).getTime(); 
     198 
     199        this.testAllFields(); 
     200    }, 
     201 
     202    onClickClear: function() 
     203    { 
     204        $( "beginDate" ).value = ""; 
     205        this.beginDate = false; 
     206        $( "endDate" ).value = ""; 
     207        this.endDate = false; 
    180208    }, 
    181209 
    182210    onClickVisualize: function() 
    183211    { 
     212//        this.plotWindow.getContent().innerHTML = '<div class="loadingPlot"><img src="/Megapoli/resources/icons/loading_datas.gif"/></div>'; 
     213 
    184214//        var url = "visualization/plotEther?plateformId=" + this.selectedPlateform.getId() 
    185215//                + "&parameterId=" + this.selectedParameter.getId() 
    186216//                + "&dateBegin=" + this.beginDate 
    187 //                + "&dateEnd=" + this.endDate; 
     217//                + "&dateEnd=" + this.endDate 
     218//                + "&title=" + encodeURIComponent( $( "textareaTitle" ).value ) 
     219//                + "&axeType=" + this.selectAxes.getValue(); 
     220 
    188221        var url = "visualization/plotEther?plateformId=33" 
    189222                + "&parameterId=10" 
    190223                + "&dateBegin=" + this.beginDate 
    191                 + "&dateEnd=" + this.endDate; 
    192  
    193         this.plotWindow.getContent().innerHTML = '<img src=' + url + '/>'; 
    194         this.plotWindow.height = this.plotWindow.getContent().firstChild.height; 
    195         this.plotWindow.width = this.plotWindow.getContent().firstChild.width; 
     224                + "&dateEnd=" + this.endDate 
     225                + "&title=" + encodeURIComponent( $( "textareaTitle" ).value ) 
     226                + "&axeType=" + this.selectAxes.getValue(); 
     227 
     228        this.plotWindow.getContent().innerHTML = '<img src=' + url + ' />'; 
     229//        this.plotWindow.setSize( this.plotWindow.getContent().firstChild.width, this.plotWindow.getContent().firstChild.height, true ); 
     230        this.plotWindow.setSize( 800, 700 ); 
    196231        this.plotWindow.show(); 
     232//        this.plotWindow.height = this.plotWindow.getContent().firstChild.height; 
     233//        this.plotWindow.width = this.plotWindow.getContent().firstChild.width; 
    197234    }, 
    198235 
     
    206243 
    207244    // OTHERS ******************************************************** 
     245    // TODO : resize !!! 
    208246    resizeContainers: function() 
    209247    { 
     
    215253        var containerPlateforms = this.containerPlateforms.offsetHeight; 
    216254        var containerParameters = this.containerParameters.offsetHeight; 
    217         var containerCalendarHeight = this.generalContainerCalendar.offsetHeight; 
    218  
    219         var maxHeight = Math.max( containerPlateforms, containerParameters, containerCalendarHeight ); 
    220  
     255        var containerOptionsHeight = this.generalContainerOptions.offsetHeight; 
     256 
     257        var maxHeight = Math.max( containerPlateforms, containerParameters, containerOptionsHeight ); 
    221258 
    222259        if( maxHeight > parentHeight ) 
     
    225262            this.generalContainerPlateforms.style.height = maxHeight + 10 + "px"; 
    226263            this.generalContainerParameters.style.height = maxHeight + 10 + "px"; 
    227         } else if( maxHeight == containerCalendarHeight ) 
    228         { 
    229             this.superParent.style.height = containerCalendarHeight + titleSize + 25 + "px"; 
    230             this.generalContainerPlateforms.style.height = containerCalendarHeight + "px"; 
    231             this.generalContainerParameters.style.height = containerCalendarHeight + "px"; 
     264        } else if( maxHeight == containerOptionsHeight ) 
     265        { 
     266//            this.superParent.style.height = containerOptionsHeight + titleSize + 25 + "px"; 
     267            this.generalContainerPlateforms.style.height = containerOptionsHeight + "px"; 
     268            this.generalContainerParameters.style.height = containerOptionsHeight + "px"; 
    232269        } 
    233270    }, 
    234271 
    235     testCalendarPeriod: function( beginDate, endDate ) 
    236     { 
    237         if( !beginDate || !endDate ) 
    238             return false; 
    239  
    240         var matchFormat = /^(\d{4})-(\d{2})-(\d{2})$/i; 
    241         var testBeginDate = beginDate.match( matchFormat ); 
    242         var testEndDate = endDate.match( matchFormat ); 
    243         if( !testEndDate || !testEndDate ) 
     272    testAllFields: function() 
     273    { 
     274        if( !this.selectedPlateform || !this.selectedParameter || !this.beginDate || !this.endDate ) 
     275        { 
     276//            this.visualizeButton.disable(); 
     277            this.downloadButton.disable(); 
    244278            return; 
    245  
    246         this.resizeContainers(); 
    247  
    248         var datesOk = beginDate <= endDate; 
    249         if( !datesOk ) 
    250             this.displayNotice(); 
    251         else 
    252             this.hideNotice(); 
    253  
    254         if( !datesOk || !this.selectedPlateform || !this.selectedParameter ) 
    255         { 
    256             this.visualizeButton.disable(); 
    257             this.downloadButton.disable(); 
    258             return false; 
    259279        } 
    260         else 
    261         { 
    262             this.visualizeButton.enable(); 
    263             this.downloadButton.enable(); 
    264             return true; 
    265         } 
    266     }, 
    267  
    268     testAllFields: function() 
    269     { 
    270         return true; 
    271  
    272         if( !this.selectedPlateform || !this.selectedParameter || !this.beginDate || !this.endDate ) 
    273         { 
    274             this.visualizeButton.disable(); 
    275             this.downloadButton.disable(); 
    276         } 
    277  
    278         return this.testCalendarPeriod( this.beginDate, this.endDate ); 
    279     }, 
    280  
    281     displayNotice: function() 
    282     { 
    283         this.notice.innerHTML = "&nbsp"; 
    284         this.notice.removeClassName( "loading" ); 
    285         this.notice.addClassName( "error" ); 
    286         this.notice.innerHTML = interfaceTexts["data.visualization.Unvalid_Period"]; 
    287         this.notice.style.visibility = "visible"; 
    288     }, 
    289  
    290     hideNotice: function() 
    291     { 
    292         this.notice.innerHTML = "&nbsp"; 
    293         this.notice.style.visibility = "hidden"; 
    294     }, 
    295  
    296     displayLoading: function() 
    297     { 
    298         this.notice.innerHTML = "&nbsp"; 
    299         this.notice.removeClassName( "error" ); 
    300         this.notice.style.visibility = "visible"; 
    301         this.notice.addClassName( "loading" ); 
    302         var image = new Element( 'img', {src: 'resources/icons/loading_datas.gif'} ); 
    303         this.notice.appendChild( image ); 
    304     }, 
    305  
    306     hideLoading: function() 
    307     { 
    308         this.notice.innerHTML = "&nbsp"; 
     280 
     281        this.visualizeButton.enable(); 
     282        this.downloadButton.enable(); 
    309283    } 
     284 
    310285} ); 
    311286 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp

    r129 r130  
    11<!-- /*** ****************** VISU ******************** **/ --> 
    22<%@ page import="com.medias.Context" %> 
     3<%@ page import="com.ether.AxeType" %> 
    34 
    45<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 
     
    1617 
    1718    <tiles:put name="insertCss" type="string"> 
    18         <ether:htmlCss cssFile="calendarview-1.2/calendarview"/> 
    1919        <ether:htmlCss cssFile="visu_parameter_by_pf"/> 
     20        <ether:htmlCss cssFile="select"/> 
     21 
     22        <%-- Calendar --%> 
     23        <ether:htmlCss cssFile="calendar/anytime"/> 
    2024        <ether:htmlCss cssFile="windows_js_1.3/themes/default"/> 
    2125        <ether:htmlCss cssFile="windows_js_1.3/themes/mac_os_x"/> 
     26 
     27        <%-- Select --%> 
     28        <%--ether:htmlCss cssFile="customedSelect/css/customSelect" /--%> 
    2229    </tiles:put> 
    2330 
     
    2734        <ether:htmlJsp jspFile="visu_parameter_by_pf-classes"/> 
    2835        <ether:htmlJs jsFile="Button"/> 
    29         <ether:htmlJs jsFile="calendarview-1.2/javascripts/calendarview"/> 
     36        <ether:htmlJs jsFile="Select"/> 
    3037 
    31         <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/debug"/> 
    32         <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/effects"/> 
    33         <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/window"/> 
    34         <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/window_ext"/> 
     38        <ether:htmlJs jsFile="library/jquery-1.4.2.min"/> 
     39        <ether:htmlJs jsFile="library/prototype"/> 
     40 
     41        <%-- Calendar --%> 
     42        <ether:htmlJs jsFile="calendar/anytime"/> 
     43        <ether:htmlJs jsFile="windows_js_1.3/javascripts/debug"/> 
     44        <ether:htmlJs jsFile="windows_js_1.3/javascripts/effects"/> 
     45        <ether:htmlJs jsFile="windows_js_1.3/javascripts/window"/> 
     46        <ether:htmlJs jsFile="windows_js_1.3/javascripts/window_ext"/> 
     47 
     48        <%-- Select --%> 
     49        <%--ether:htmlJs jsFile="customedSelect/js/customSelect"/--%> 
    3550    </tiles:put> 
    3651 
     
    5974            </div> 
    6075 
    61             <div id="generalContainerCalendar" class="span-9 last"> 
    62                 <div id="messages"><bean:message key="data.visualization.selectTime"/></div> 
    63                 <div id="embeddedCalendar" class="embeddedCalendar"></div> 
     76            <div id="generalContainerOptions" class="span-9 last"> 
     77                <div id="containerOptionCalendar" class="span-9"> 
     78                    <div id="messages" class="messagesHeight"><bean:message key="data.visualization.selectPeriod"/></div> 
     79                    <input type="text" id="beginDate" size="15"/> 
     80                    <input type="text" id="endDate" size="15"/> 
     81                </div> 
    6482 
    65                 <div class="dateField leftField"><bean:message key="data.visualization.BeginDate"/></div> 
    66                 <div id="embeddedDateField" class="dateField rightField"><bean:message 
    67                         key="data.visualization.selectDate"/></div> 
    68                 <div class="dateField leftField"><bean:message key="data.visualization.EndDate"/></div> 
    69                 <div id="embeddedEndDateField" class="dateField rightField"><bean:message 
    70                         key="data.visualization.selectDate"/></div> 
     83                <div id="containerOptionTitle" class="span-8"> 
     84                    <div id="messages" class="messagesHeight"><bean:message key="data.visualization.titleChoice"/></div> 
     85                    <textarea id="textareaTitle" cols="37" rows="2"></textarea> 
     86                </div> 
     87 
     88                <div id="containerOptionAxe" class="span-8"> 
     89                    <div id="messages" class="messagesHeight"><bean:message key="data.visualization.axe"/></div> 
     90                </div> 
    7191 
    7292                <div class="errorAndButtons"> 
    73                     <div id="notice" style="visibility:hidden" class="error span-6">&nbsp;</div> 
    74                     <div id="containerButtons" class="buttons span-7"></div> 
     93                    <div id="containerButtons" class="span-7"></div> 
    7594                </div> 
    7695            </div> 
     
    87106            interfaceTexts["data.visualization.Unvalid_Period"] = "<bean:message key="data.visualization.Unvalid_Period"/>"; 
    88107            interfaceTexts["data.visualization.quicklook"] = "<bean:message key="data.visualization.quicklook"/>"; 
     108            interfaceTexts["data.visualization.titleChoice"] = "<bean:message key="data.visualization.titleChoice"/>"; 
     109            interfaceTexts["data.visualization.axe"] = "<bean:message key="data.visualization.axe"/>"; 
     110            interfaceTexts["data.visualization.button.today"] = "<bean:message key="data.visualization.button.today"/>"; 
     111            interfaceTexts["data.visualization.button.clear"] = "<bean:message key="data.visualization.button.clear"/>"; 
    89112 
    90             var interfaceVisualization = new InterfaceVisualization( ${plateforms} ); 
     113            interfaceTexts["data.visualization.selectDate"] = "<bean:message key="data.visualization.selectDate"/>"; 
     114            interfaceTexts["data.visualization.selectYear"] = "<bean:message key="data.visualization.selectYear"/>"; 
     115            interfaceTexts["data.visualization.selectMonth"] = "<bean:message key="data.visualization.selectMonth"/>"; 
     116            interfaceTexts["data.visualization.selectDay"] = "<bean:message key="data.visualization.selectDay"/>"; 
     117            interfaceTexts["data.visualization.selectTime"] = "<bean:message key="data.visualization.selectTime"/>"; 
     118            interfaceTexts["data.visualization.selectHour"] = "<bean:message key="data.visualization.selectHour"/>"; 
     119            interfaceTexts["data.visualization.selectMinute"] = "<bean:message key="data.visualization.selectMinute"/>"; 
     120 
     121            interfaceTexts["<%=AxeType.TIME%>"] = "<bean:message key="data.visualization.axeType.Time"/>"; 
     122            interfaceTexts["<%=AxeType.LATITUDE%>"] = "<bean:message key="data.visualization.axeType.Latitude"/>"; 
     123 
     124            var interfaceVisualization = new InterfaceVisualization( ${plateforms}, ${axeTypes} ); 
    91125        </script> 
    92126 
Note: See TracChangeset for help on using the changeset viewer.