New research and technology page

* Added legacyworlds-server-beans-technologies Maven module, including
the player-level DAO and controller.

* Added session classes to carry technology information, modified web
client session façade accordingly

* Various changes to common UI elements (forms, lists, etc...) so the
start and end of some element can be drawn separately

* Added controller, templates and JavaScript for research page
This commit is contained in:
Emmanuel BENOîT 2012-04-07 13:06:03 +02:00
parent 154f215e24
commit 6dcd59d7bc
45 changed files with 2314 additions and 178 deletions

View file

@ -1,28 +0,0 @@
package com.deepclone.lw.cmd.player;
import com.deepclone.lw.session.Command;
public class ImplementTechCommand
extends Command
{
private static final long serialVersionUID = 1L;
private final int tech;
public ImplementTechCommand( int tech )
{
this.tech = tech;
}
public int getTech( )
{
return tech;
}
}

View file

@ -0,0 +1,373 @@
package com.deepclone.lw.cmd.player.gdata.empire;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* An entry from the research page
*
* <p>
* This class represents entries from the research page. It is capable of representing in-progress
* research (with or without details), as well as pending and implemented technologies.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class ResearchData
implements Serializable , Comparable< ResearchData >
{
/**
* The serialisation version identifier
*
* <ul>
* <li>Introduced in B6M2 with ID 1
* </ul>
*/
private static final long serialVersionUID = 1L;
/** The identifier of the technology */
private String identifier;
/** The category the technology belongs to */
private String category;
/**
* The translated name of the technology, or <code>null</code> if the technology is being
* researched and progress is insufficient to display details.
*/
private String name;
/**
* The description of the technology, or <code>null</code> if the technology is being researched
* and progress is insufficient to display details.
*/
private String description;
/**
* The implementation price of the technology, or <code>null</code> if the technology is being
* researched and progress is insufficient to display details.
*/
private Long price;
/**
* The completion percentage of the technology, or <code>null</code> if the technology has been
* fully researched.
*/
private Integer completion;
/**
* Priority of the research on this technology, or <code>null</code> if the technology is not
* being researched.
*/
private Integer priority;
/**
* Whether the technology is being researched (<code>null</code>), pending implementation (
* <code>false</code>) or implemented (<code>true</code>).
*/
private Boolean implemented;
/** List of identifiers of technologies the current technology depends on. */
private List< String > dependencies = new ArrayList< String >( );
/** List of identifiers of technologies that depend on the current technology. */
private List< String > revDependencies = new LinkedList< String >( );
/**
* Gets the identifier of the technology.
*
* @return the identifier of the technology
*/
public String getIdentifier( )
{
return this.identifier;
}
/**
* Sets the identifier of the technology.
*
* @param identifier
* the new identifier of the technology
*/
public void setIdentifier( String identifier )
{
this.identifier = identifier;
}
/**
* Gets the category the technology belongs to.
*
* @return the category the technology belongs to
*/
public String getCategory( )
{
return this.category;
}
/**
* Sets the category the technology belongs to.
*
* @param category
* the new category the technology belongs to
*/
public void setCategory( String category )
{
this.category = category;
}
/**
* Gets the translated name of the technology
*
* @return the translated name of the technology, or <code>null</code> if the technology is
* being researched and progress is insufficient to display details
*/
public String getName( )
{
return this.name;
}
/**
* Sets the translated name of the technology
*
* @param name
* the new translated name of the technology
*/
public void setName( String name )
{
this.name = name;
}
/**
* Gets the description of the technology
*
* @return the description of the technology, or <code>null</code> if the technology is being
* researched and progress is insufficient to display details
*/
public String getDescription( )
{
return this.description;
}
/**
* Sets the description of the technology
*
* @param description
* the new description of the technology
*/
public void setDescription( String description )
{
this.description = description;
}
/**
* Gets the implementation price of the technology
*
* @return the implementation price of the technology, or <code>null</code> if the technology is
* being researched and progress is insufficient to display details
*/
public Long getPrice( )
{
return this.price;
}
/**
* Sets the implementation price of the technology
*
* @param price
* the new implementation price of the technology
*/
public void setPrice( Long price )
{
this.price = price;
}
/**
* Gets the completion percentage of the technology.
*
* @return the completion percentage of the technology, or <code>null</code> if the technology
* has been fully researched
*/
public Integer getCompletion( )
{
return this.completion;
}
/**
* Sets the completion percentage of the technology.
*
* @param completion
* the new completion percentage of the technology
*/
public void setCompletion( Integer completion )
{
this.completion = completion;
}
/**
* Gets the priority of the research on this technology
*
* @return the priority of the research on this technology, or <code>null</code> if the
* technology is not being researched
*/
public Integer getPriority( )
{
return this.priority;
}
/**
* Sets the priority of the research on this technology.
*
* @param priority
* the new priority of the research on this technology
*/
public void setPriority( Integer priority )
{
this.priority = priority;
}
/**
* Gets whether the technology is being researched (<code>null</code>), pending implementation (
* <code>false</code>) or implemented (<code>true</code>).
*
* @return whether the technology is being researched (<code>null</code>), pending
* implementation ( <code>false</code>) or implemented (<code>true</code>)
*/
public Boolean getImplemented( )
{
return this.implemented;
}
/**
* Sets whether the technology is being researched (<code>null</code>), pending implementation (
* <code>false</code>) or implemented (<code>true</code>).
*
* @param implemented
* whether the technology is being researched (<code>null</code>), pending
* implementation ( <code>false</code>) or implemented (<code>true</code>)
*/
public void setImplemented( Boolean implemented )
{
this.implemented = implemented;
}
/**
* Get the list of dependencies
*
* @return the list of dependencies
*/
public List< String > getDependencies( )
{
return Collections.unmodifiableList( this.dependencies );
}
/**
* Update the list of dependencies
*
* @param dependencies
* the new list of dependencies
*/
public void setDependencies( String[] dependencies )
{
this.dependencies = Arrays.asList( dependencies );
}
/**
* Get the list of reverse dependencies
*
* @return the list of reverse dependencies
*/
public List< String > getReverseDependencies( )
{
return this.revDependencies;
}
/**
* Add a reverse dependency
*
* @param identifier
* the identifier of the reverse dependency
*/
public void addReverseDependency( String identifier )
{
this.revDependencies.add( identifier );
}
/**
* Research page entry comparison
*
* <p>
* This method compares research entries based on:
* <ul>
* <li>The entries' states (in progress, pending implementation, implemented),
* <li>For in-progress entries, their current completion ratio,
* <li>The entries' names
* </ul>
*
* @param other
* the entry to compare to
*
* @return 1 if the current entry is "bigger", -1 if it is "smaller", and 0 if both entries are
* equal
*/
@Override
public int compareTo( ResearchData other )
{
if ( other == null ) {
return 1;
}
if ( this.implemented == null && other.implemented != null ) {
return -1;
}
if ( other.implemented == null && this.implemented != null ) {
return 1;
}
if ( this.implemented != null ) {
if ( this.implemented && !other.implemented ) {
return 1;
}
if ( other.implemented && !this.implemented ) {
return -1;
}
return this.name.compareTo( other.name );
}
if ( this.completion != other.completion ) {
return other.completion - this.completion;
}
if ( this.name == null ) {
return other.name == null ? 0 : -1;
}
return this.name.compareTo( other.name );
}
}

View file

@ -0,0 +1,26 @@
package com.deepclone.lw.cmd.player.tech;
import com.deepclone.lw.session.Command;
/**
* Command that obtains the current research &amp; technology data
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class GetResearchCommand
extends Command
{
/**
* The serialisation version identifier
*
* <ul>
* <li>Introduced in B6M2 with ID 1
* </ul>
*/
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,66 @@
package com.deepclone.lw.cmd.player.tech;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import com.deepclone.lw.cmd.player.gdata.GamePageData;
import com.deepclone.lw.cmd.player.gdata.GameResponseBase;
import com.deepclone.lw.cmd.player.gdata.empire.ResearchData;
/**
* Response that lists all research entries (sent by the server in response to
* {@link GetResearchCommand})
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class GetResearchResponse
extends GameResponseBase
{
/**
* The serialisation version identifier
*
* <ul>
* <li>Introduced in B6M2 with ID 1
* </ul>
*/
private static final long serialVersionUID = 1L;
/** Sorted list of research entries */
private final List< ResearchData > researchData;
/**
* Initialise the response
*
* <p>
* Copy and sort the list of research entries
*
* @param page
* the common page information
* @param technologies
* the list of research entries
*/
public GetResearchResponse( GamePageData page , List< ResearchData > technologies )
{
super( page );
this.researchData = new LinkedList< ResearchData >( technologies );
Collections.sort( this.researchData );
}
/**
* Get the list of research entries
*
* @return the sorted list of research entries
*/
public List< ResearchData > getResearchData( )
{
return this.researchData;
}
}

View file

@ -0,0 +1,53 @@
package com.deepclone.lw.cmd.player.tech;
import com.deepclone.lw.session.Command;
/**
* Technology implementation command
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class ImplementTechCommand
extends Command
{
/**
* The serialisation version identifier
*
* <ul>
* <li>Introduced in B6M1 with ID 1
* <li>Modified in B6M2, ID set to 2
* </ul>
*/
private static final long serialVersionUID = 2L;
/** Identifier of the technology to implement */
private final String tech;
/**
* Initialise the command
*
* @param tech
* the identifier of the technology to implement
*/
public ImplementTechCommand( String tech )
{
this.tech = tech;
}
/**
* Get the identifier of the technology to implement
*
* @return the identifier of the technology to implement
*/
public String getTech( )
{
return this.tech;
}
}

View file

@ -0,0 +1,50 @@
package com.deepclone.lw.cmd.player.tech;
import java.util.Map;
import com.deepclone.lw.session.Command;
/**
* Command that updates research priorities
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public class UpdateResearchPrioritiesCommand
extends Command
{
/**
* Serialisation version identifier
*
* <ul>
* <li>Introduced in B6M2
* </ul>
*/
private static final long serialVersionUID = 1L;
/** The new research priorities */
private final Map< String , Integer > priorities;
/**
* Initialise the command using research priority values
*
* @param priorities
* a map that associates technology identifiers to priorities
*/
public UpdateResearchPrioritiesCommand( Map< String , Integer > priorities )
{
this.priorities = priorities;
}
/** @return the new research priorities */
public Map< String , Integer > getPriorities( )
{
return this.priorities;
}
}