Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using final on Java code #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions framework/play/src/main/java/play/mvc/Controller.java
Expand Up @@ -3,25 +3,27 @@
import play.mvc.Http.*;
import play.mvc.Result.*;

import static java.lang.String.format;

public abstract class Controller {

public static Request request() {
return Http.Context.current().request();
}

public static Result Text(Object any, String... args) {
String text;
final String text;
if(any == null) {
text = "";
} else {
text = any.toString();
}
String formatted = String.format(text, (Object)args);
final String formatted = format(text, (Object)args);
return new Text(formatted);
}

public static Result Html(Object any) {
String html;
final String html;
if(any == null) {
html = "";
} else {
Expand Down
4 changes: 2 additions & 2 deletions framework/play/src/main/scala/api/mvc/Http.scala
Expand Up @@ -5,10 +5,10 @@ package play.api.mvc {

import scala.annotation._

@implicitNotFound("Cannot find any HTTP context here")
@implicitNotFound("Não foi possível achar um contexto HTTP aqui")
case class Context(application:Application, request:Request)

@implicitNotFound("Cannot find any HTTP Request here")
@implicitNotFound("Não foi possível achar um contexto HTTP aqui")
trait Request {

def uri:String
Expand Down
36 changes: 17 additions & 19 deletions framework/play/src/main/scala/console/Console.scala
Expand Up @@ -28,12 +28,12 @@ object Console {
val defaultName = path.getName

println()
println("The new application will be created in %s".format(path.getAbsolutePath))
println("Uma nova aplicação vai ser criada em %s".format(path.getAbsolutePath))

if(path.listFiles.size > 0) {
new ANSIBuffer().red("The directory is not empty, cannot create a new application here.")
new ANSIBuffer().red("O diretório não está vazio, não é possível criar uma nova aplicação aqui.")
} else {
consoleReader.printString(new ANSIBuffer().cyan("What is the application name? ").toString)
consoleReader.printString(new ANSIBuffer().cyan("Qual é o nome da aplicação? ").toString)
consoleReader.putString(defaultName)
val name = Option(consoleReader.readLine()).map(_.trim).filter(_.size > 0).getOrElse(defaultName)
println()
Expand All @@ -44,14 +44,14 @@ object Console {

def helpCommand = {
"""
|Welcome to Play 2.0!
|Bem-vindo ao Play 2.0!
|
|These commands are available:
|Estes comandos estão disponíveis:
|-----------------------------
|(default) Enter the development console.
|new Create a new Play application in the current directory.
|(default) Entrar no console de desenvolvimento.
|new Criar uma nova aplicação do Play no diretório atual.
|
|You can also browse the complete documentation at """.stripMargin +
|Você também pode ver a documentação completa em """.stripMargin +
new ANSIBuffer().underscore("http://www.playframework.org").append(".")
}

Expand All @@ -64,12 +64,12 @@ object Console {
}.map { command =>
command()
}.getOrElse {
new ANSIBuffer().red("\nThis is not a play application!\n").append(
new ANSIBuffer().red("\nEsta não é uma aplicação do Play!\n").append(
"""|
|Use `play new` to create a new Play application in the current directory,
|or go to an existing application and launch the development console using `play`.
|Use `play new` para criar uma nova aplicação do play no diretório atual,
|ou vá para uma aplicação existente e inicie o ambiente de desenvolvimento usando `play`.
|
|You can also browse the complete documentation at """.stripMargin +
|Você também pode ver a documentação completa em """.stripMargin +
new ANSIBuffer().underscore("http://www.playframework.org").append(".")
).toString
}
Expand All @@ -92,7 +92,7 @@ case class NewApplication(path:File, name:String) {
|public class Application extends Controller {
|
| public static Result index() {
| return Html(index.apply("World"));
| return Html(index.apply("Mundo"));
| }
|
|}
Expand All @@ -108,7 +108,7 @@ case class NewApplication(path:File, name:String) {
| <link rel="stylesheet" type="text/css" media="screen" href="/public/stylesheets/main.css">
| </head>
| <body>
| <h1>Hello @name!</h1>
| <h1>Olá @name!</h1>
| </body>
|</html>
""".stripMargin
Expand Down Expand Up @@ -169,11 +169,9 @@ case class NewApplication(path:File, name:String) {
""".stripMargin
)

"""|OK, application %s is created.
|Type `play` to enter the development console.
|Have fun!
"""|OK, a aplicação %s foi criada.
|Digite `play` para entrar no ambiente de desenvolvimento.
|Divirta-se!
""".stripMargin.format(name).trim
}


}
56 changes: 28 additions & 28 deletions framework/play/src/main/scala/sbt/SbtPlugin.scala
Expand Up @@ -33,9 +33,9 @@ object PlayProject extends Plugin {
// ----- Exceptions

case class CompilationException(problem:xsbti.Problem) extends PlayException(
"Compilation error",
"The file %s could not be compiled. Error raised is: %s".format(
problem.position.sourcePath.getOrElse("(no source file defined?)"),
"Erro de compilação",
"O arquivo %s não pode ser compilado. O erro é: %s".format(
problem.position.sourcePath.getOrElse("(arquivo fonte não definido?)"),
problem.message
)
) with ExceptionSource {
Expand All @@ -45,8 +45,8 @@ object PlayProject extends Plugin {
}

case class TemplateCompilationException(source:File, message:String, atLine:Int, column:Int) extends PlayException(
"Compilation error",
"The file %s could not be compiled. Error raised is: %s".format(
"Erro de compilação",
"O arquivo %s não pode ser compilado. O erro é: %s".format(
source.getAbsolutePath,
message
)
Expand All @@ -57,8 +57,8 @@ object PlayProject extends Plugin {
}

case class RoutesCompilationException(source:File, message:String, atLine:Option[Int], column:Option[Int]) extends PlayException(
"Compilation error",
"The file %s could not be compiled. Error raised is: %s".format(
"Erro de compilação",
"O arquivo %s não pode ser compilado. O erro é: %s".format(
source.getAbsolutePath,
message
)
Expand Down Expand Up @@ -93,7 +93,7 @@ object PlayProject extends Plugin {
val playCopyResourcesTask = (baseDirectory, playResourceDirectories, classDirectory in Compile, cacheDirectory, streams) map { (b,r,t,c,s) =>
val cacheFile = c / "copy-resources"
val mappings = r.map( _ *** ).reduceLeft(_ +++ _) x rebase(b, t)
s.log.debug("Copy play resource mappings: " + mappings.mkString("\n\t","\n\t",""))
s.log.debug("Copie os mapeamentos dos recursos do play: " + mappings.mkString("\n\t","\n\t",""))
Sync(cacheFile)(mappings)
mappings
}
Expand All @@ -103,7 +103,7 @@ object PlayProject extends Plugin {
analysises.reduceLeft(_ ++ _)
}

val dist = TaskKey[File]("dist", "Build the standalone application package")
val dist = TaskKey[File]("dist", "Construir o pacote de aplicação standalone")
val distTask = (baseDirectory, playPackageEverything, dependencyClasspath in Runtime, target, normalizedName, version) map { (root, packaged, dependencies, target, id, version) =>

import sbt.NameFilter._
Expand Down Expand Up @@ -134,7 +134,7 @@ object PlayProject extends Plugin {
IO.delete(run)

println()
println("Your application is ready in " + zip.getCanonicalPath)
println("Sua aplicação está pronta em " + zip.getCanonicalPath)
println()

zip
Expand Down Expand Up @@ -373,7 +373,7 @@ object PlayProject extends Plugin {
val server = new play.core.server.NettyServer(reloader)

println()
println(new ANSIBuffer().green("(Server started, use Ctrl+D to stop and go back to the console...)").toString)
println(new ANSIBuffer().green("(Servidor iniciado, use Ctrl+D para parar e voltar para o console...)").toString)
println()

waitForKey()
Expand All @@ -392,7 +392,7 @@ object PlayProject extends Plugin {
Project.evaluateTask(compile in Compile, state).get.toEither match {
case Left(_) => {
println()
println("Cannot start with errors.")
println("Não é possível começar com erros.")
println()
state.fail
}
Expand Down Expand Up @@ -427,7 +427,7 @@ object PlayProject extends Plugin {

}.right.getOrElse {
println()
println("Oops, cannot start the server?")
println("Oops, não consegue iniciar o servidor?")
println()
state.fail
}
Expand All @@ -441,22 +441,22 @@ object PlayProject extends Plugin {

println(
"""
|Welcome to Play 2.0!
|Bem-vindo ao Play 2.0!
|
|These commands are available:
|Estes comandos estão disponíveis:
|-----------------------------
|clean Clean all generated files.
|compile Compile the current application.
|dist Construct standalone application package.
|package Package your application as a JAR.
|publish Publish your application in a remote repository.
|publish-local Publish your application in the local repository.
|reload Reload the current application build file.
|run Run the current application in DEV mode.
|start Start the current application in another JVM in PROD mode.
|update Update application dependencies.
|clean Limpa todos os arquivos gerados.
|compile Compila a aplicação atual.
|dist Construir um pacote de aplicação standalone.
|package Enpacotar sua aplicação como um JAR.
|publish Publicar sua aplicação em um repositório remoto.
|publish-local Publicar sua aplicação em um repositório local.
|reload Recarregar o arquivo de build da aplicação atual.
|run Execute a aplicação corrente no modo DEV (Desenvolvimento).
|start Inicie a aplicação atual em outra JVM no modo PROD.
|update Atualizar as dependências da aplicação.
|
|You can also browse the complete documentation at """.stripMargin +
|Você também pode ver a documentação completa em """.stripMargin +
new ANSIBuffer().underscore("http://www.playframework.org").append(".\n")
)

Expand All @@ -471,8 +471,8 @@ object PlayProject extends Plugin {
// Display logo
println(play.console.Console.logo)
println("""
|> Type "help" or "license" for more information.
|> Type "exit" or use Ctrl+D to leave this console.
|> Digite "help" ou "license" para mais informações.
|> Digite "exit" ou use Ctrl+D para deixar este ambiente.
|""".stripMargin
)

Expand Down