Giter Club home page Giter Club logo

arena's People

Contributors

faloi avatar fdodino avatar flbulgarelli avatar gdecuzzi avatar javierfernandes avatar npasserini avatar tesonep avatar vmariano avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

liliana01 osquic

arena's Issues

Add the concept of Bootstrap/Seed/Fixture end environments

Arena sample applications we deliver tend to have test data initialization code as part of the repositories or even views. This is a bad practice, since it couples the data set - which is envirment dependent e.g. production and development - to the views or repositories, making them impossible to use in diferent environment wihout modification to code.

It would be nice that Arena had some kind of bootstrap interface - essentially, a runnable - that could be passed to an Arena Application init code, ensuring it is executed before the app starts, similar to Rails seeds or Grails Bootstraps. That way we would discourage the previously mentioned bad practice.

Unify Adapters & Transformers Controllers

Original problem:

The biggest problem here is in table columns.
Theres a bindContentsToProperty "or" bindContentsToTransformer

Using the latter will not create any binding. Arena looses information on which property are you using from the object, therefore, it won't refresh the cell when the model changes.

'What steps will reproduce the problem?'

  1. Create a Table, bound to a list of Objects
  2. Change a property of an object in the list, without changing the list iself.

Table cell should actualize its contents, but it does not (unless the whole list changes).

The best approach for this is to have something really similar to transformers in bindings for other controls.

Column<Account> column = ...

Binding binding = column.bindContentProperty("amountOfMoney")
binding.setTransformer[ Double d |  "$" + d ]

In this way there's still a binding there, so it will be updated automatically upon a change on that property.
But it still allows the user to change the way it's been seen.

Also note that in this case the transformer works on the value of the property.
While the current transformer works on the object that's one of the item on the list

[ Account a |  "$" + a.getAmountOfMoney() ]

Note: Arena 3.5.1 has a setTransformer method, but Transformer needs to conform a <String, String> conversion. See example below:

bindContentsToProperty("recibeResumenCuenta").transformer = [ recibe | if (recibe) "SI" else "NO"]
does not work,

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
    at ar.edu.celulares.ui.BuscarCelularesWindow$10$1.transform(BuscarCelularesWindow.java:1)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceLabelProviderBuilder$1.transform(JFaceLabelProviderBuilder.java:85)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceLabelProviderBuilder$1.transform(JFaceLabelProviderBuilder.java:82)

you should ask

bindContentsToProperty("recibeResumenCuenta").transformer = [ recibe | if (recibe == "true") "SI" else "NO"]

Same situation rises if you define a Transformer class:

BooleanToSiNoTransformer implements Transformer<String, String>

is ok while

BooleanToSiNoTransformer implements Transformer<Boolean, String>

does not compile.

Allow to define minimum sizes for an ErrorPanel

Something like

new ErrorPanel(parent).setMinHeight(2)

We should discuss if measures should be given in lines or pixels. I would prefer lines, but I don't know what to do with the width.

Enhance Warning message when a view uses a binding against a non-observable object

Now if an Arena window uses a non-observable domain object, Application doesn't start.
But if a window model object has a reference to a non observable property, like a combo selector of elements T which are not observable, you get

org.eclipse.core.databinding - 0 - Could not attach listener to Eleccion Nacional
java.lang.NoSuchMethodException: ar.edu.votacion.Zona.addPropertyChangeListener(java.beans.PropertyChangeListener)
	at java.lang.Class.getMethod(Class.java:1786)
	at org.eclipse.core.internal.databinding.beans.ListenerSupport.processListener(ListenerSupport.java:177)
	at org.eclipse.core.internal.databinding.beans.ListenerSupport.hookListener(ListenerSupport.java:72)

Maybe we can enhance message description or do a deeper validation...

Please see page 25 of https://docs.google.com/document/d/17EvP3IGEbdzhC-da-V2iV3OB6yU4qYXbMNbycu3maPo/edit#

How to bind a CheckBox to a non-attribute value?

Several students had a runtime error when clicking on a checkbox that has a binding like this:

new CheckBox(panel) => [
    value <=> "checked"
]

and, in model:

def getChecked() {
true
}
def void setChecked(Boolean b) {
}

In particular, I tried to breakpoint the setter and couldn't... tried with multiple combinations of method signature but it was the same.

NumericField: decimals should take into account locale

If you try to run an application with locale ES:

-Djava.system.class.loader=org.uqbar.apo.APOClassLoader -Duser.language=es -Duser.region=AR

NumericField doesn't work with decimals, it ignores it treating them as the integer part.

numericField

Strange error in firePropertyChange when defining a variable as "protected"

See link to this branch. UI project is this

image

Exception in thread "main" javassist.CannotCompileException: [source error] firePropertyChange(java.lang.String,edu.unsam.tpeventos2018.grupo3.Usuario,edu.unsam.tpeventos2018.grupo3.Usuario) not found in edu.unsam.tpeventos2018.grupo3.Evento
at javassist.expr.FieldAccess.replace(FieldAccess.java:216)
at org.uqbar.apo.Advice.edit(Advice.scala:47)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtClassType.instrument(CtClassType.java:1398)
at org.uqbar.apo.Advice.apply(Advice.scala:83)
at org.uqbar.poo.aop.ObservableConfiguration$$anon$2.apply(ObservableConfiguration.scala:28)
at org.uqbar.apo.AdviceWeaver.applyAdviceToCtClass(AdviceWeaver.scala:42)
at org.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:35)
at org.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:33)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.uqbar.apo.AdviceWeaver.applyAdvice(AdviceWeaver.scala:33)
at org.uqbar.apo.APOClassLoader.applyAPO(APOClassLoader.scala:106)
at org.uqbar.apo.APOClassLoader.findClass(APOClassLoader.scala:83)
at org.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:58)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:69)
at jose.RealmenteNoSeQuePasa.main(RealmenteNoSeQuePasa.java:20)
Caused by: compile error: firePropertyChange(java.lang.String,edu.unsam.tpeventos2018.grupo3.Usuario,edu.unsam.tpeventos2018.grupo3.Usuario) not found in edu.unsam.tpeventos2018.grupo3.Evento
at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:723)
at javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:688)
at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:330)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
at javassist.compiler.Javac.compileStmnt(Javac.java:569)
at javassist.expr.FieldAccess.replace(FieldAccess.java:210)
... 17 more

Cosas que probé:

  • Utilizar como modelo una clase creada en el mismo proyecto de Arena y funciona
  • Utilizar como modelo otra clase del dominio del año pasado exactamente igual que utilizo esta y funciona (utilizo Locacion y funciona!!!)
  • No es un problema del settings.xml
  • No es un problema del @observable
  • No es un problema de dependencias porque como mencioné con otras clases si anda... y ahí va un Screen que lo prueba

image

Hay novedades.
Si extiendo la clase Usuario y uso esa clase como dominio, anda..

package edu.unsam.tpeventos2018.grupo3

import edu.unsam.tpeventos2018.grupo3.Usuario
import org.uqbar.commons.model.annotations.Observable

@Observable
class UsuarioExtendido extends Usuario {
}

Enhancements to TextBox with numeric inputs

If you have a TextBox bound to an int property for example.
Then while using the dialog, you write a number and delete all the content of the textbox, you'll see that the binding sets an error to the control, and you'll see it in the feedback panel.
"Missing character for value. ...".

But the control's interface has methods to declare when it's mandatory. So one would think that controls are not mandatory by default, which is not the case here.

Perhaps Arena can offer a NumericTextBox, which

  • works with a numeric/string transformer
  • with a numeric filter
  • and also showing nothing but digits or decimal comma (now you see a "12.224.424" in large numbers)

@Dependencies does not fire property change if you don't subscribe Java Bean contract

En https://github.com/uqbar-project/eg-votacion-arena-xtend
si intentás definir una propiedad para inhabilitar el botón y en Encuesta, si en lugar de hacer

@Dependencies("candidato")
getPuedeVotarse() {
    candidato.puedeVotarse()  // es candidato.partido === "PRO"
}

escribís sin el get

@Dependencies("candidato")
puedeVotarse() {
    candidato.puedeVotarse()  // es candidato.partido === "PRO"
}

Arena no se queja en ningún momento, pero al cambiar el candidato no se inhabilita el botón. Deberíamos chequear que el método original de xtend comience con get (en Java sin embargo lo genera con get, por eso no salta la validación de Arena).

Optimize dependency tree

Currently this project depends on the following jar:

  • scala-library
  • apache collections
  • generic version of apache collections

And in addition it will be mostly used in project that:

  • target compiled to java 8
  • are written in XTend
  • or depend on Guava

That means that we have no more than 4 collection frameworks, which makes more complex to determine which to use

Different "bindEnabled**" methods override each other (also with disabledOnError)

In the "apuestas" example:

  • start it
  • write the following string "1/1/" in the date field
  • it's invalid, therefore the "Jugar" button gets disabled.
  • then append a "1" to the date, then it's valid

The problem is that the button gets now enabled, while in the code we have set two different conditions

botonJugar.bindEnabled(new NotNullObservable("valorApostado"))
botonJugar.disableOnError

Somehow, it seems like in only takes into account the last call. It's like the disableOnError overrides the previous "enabled/disable" condition/binding.

I believe this should be treated as an "AND" operation.

Duplicated abstraction: Home

There are two Home abstractions, both in uqbar-domain project.

1° ==> package org.uqbar.commons.utils public class Home
2° ==> package org.uqbar.commons.model public interface Home

2° defines a contract for homes
1° is used by ApplicationContext

What do we expect?

  • Should be unified in one abstraction (perhaps class Home as DefaultRepo?)
  • Should be renamed to "Repo" suffix

Unify method adapter and transformer

Students get confused over where they should use transformer and where adapter.
You can use
-bindValueToProperty("fecha").transformer = new DateAdapter
or
-bindContentsToProperty("modeloCelular").transformer

But
-bindContentsToProperty("modeloCelular").adapter does not exists

And on the selector we can do:
-bindItems(new ObservableProperty(homeModelos, "modelos")).adapter = new PropertyAdapter(typeof(Modelo), "descripcionEntera")

I don't know if this is on purpose but it is so confusing...
Can't we do anything about it?

Advanced Binding with Type Checking (Arena-xtend)

Now in Arena's xtend versions you can add check typing like this:

new TextBox(mainPanel) => [
            value <=> "valor"
            enabled <=> [ CalculadoraBigDecimal calc | calc.habilitado ]

But you can't transform that property inside the closure:

new TextBox(mainPanel) => [
            value <=> "valor"
            enabled <=> [ CalculadoraBigDecimal calc | calc.valor != 2 ]

Because you get an exception:

java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Boolean
    at org.eclipse.jface.internal.databinding.swt.TextEditableObservableValue.doSetValue(TextEditableObservableValue.java:67)
    at org.eclipse.core.databinding.observable.value.AbstractObservableValue.setValue(AbstractObservableValue.java:55)
    at org.uqbar.ui.jface.base.BaseUpdateValueStrategy.doSet(BaseUpdateValueStrategy.java:37)
    at org.eclipse.core.databinding.ValueBinding$4.run(ValueBinding.java:184)

That's because operator_spaceship defines the following operation:

def static <M,R> operator_spaceship(ViewObservable obs, Function1<M,R> propertyBinder) {
       obs <=> calculateObservable(obs.view.containerModelObject, propertyBinder)
}

calculateObservable searches for a property,

    def static <M,R> calculateObservable(Object model, Function1<M, R> propertyBinder) {
        val Class<M> concreteModelType = model.class as Class<M>
        val handler = createInvocationHandler()
        val M mock = createMockFor(concreteModelType, handler) 

        // call closure
        propertyBinder.apply(mock)

        //TODO: inspect mock for getter calls, register binding.
        handler.getPropertyName
    }

For the above example calculateObservable returns at runtime:
property: valor
value: a boolean value, which is not compatible (thus resulting in a class cast exception).

It should be nice to transform the value in the closure.

Application does not use isPending() method of Bootstrap class

Forgot to ask if isPending() message returns true/false:

    @Override
    public void run() {
        ObjectTransactionManager.getTransaction();
        this.bootstrap.run();
        this.createMainWindow().open();
    }

Should be:

    @Override
    public void run() {
        ObjectTransactionManager.getTransaction();
        if (this.bootstrap.isPending()) this.bootstrap.run();
        this.createMainWindow().open();
    }

Already deployed 3.6.1 version, sorry. :(

Rename Home to Repo

All homes interfaces and classes should be renamed to Repo.
CollectionBasedHome ==> CollectionBasedRepo
Home ==> Repo

New Widget: create a PasswordField to hide data

Enhancement: create a specialized text field for password entry. For security reasons, a password field does not show the characters that the user types. Instead, the field displays a character different from the one typed, such as an asterisk '*

ColumnLayout and Horizontal layout do not make the items larger to fit to its size

Columnlayout, no autoajusta el ancho de los controles que tiene dentro. Ej label.

En swt existe un parámetro para indicarle que haga todas las columnas del mismo tamañao, y eso "estira" los controles internos. Se llama "makesamewidth", o algo así.

The problem here is that if I create a screen with a "label-control" structure, and for example I have a Label whose initial value is just one digit, like "A", but the model changes because of some interaction and this gets a longer value like "ABCDEFG", then the label will just show "A", because it was sized for the initial content, and not resized after.

The only layout that we have that stretches controls is the Vertical Layout.

Remove MessageSend

Now we are using arena only from languages that have static typing and lambdas/blocks, but MessageSend is largerly a patch for the lack of lambdas, in a dynamic typed way.

Perhaps it is time to remove that class, since it only adds confussion to framework users.

Ugly exception when the class of the Table items is not @Observable

If you have a window with a model object that is @observable, and create a table bound to a list property which holds objects of type "B", let say.
If that class B doesn't have the @observable annotation, then when you run the application it will log the following ugly exception, because it tries to register a listener into an instance of B class, which was not weaved, and therefore doesn't have the observable methods.

org.eclipse.core.databinding - 0 - Could not attach listener to uqbar.examples.burros.model.Caballo@1682598
java.lang.NoSuchMethodException: uqbar.examples.burros.model.Caballo.addPropertyChangeListener(java.beans.PropertyChangeListener)
    at java.lang.Class.getMethod(Class.java:1605)
    at org.eclipse.core.internal.databinding.beans.ListenerSupport.processListener(ListenerSupport.java:177)
    at org.eclipse.core.internal.databinding.beans.ListenerSupport.hookListener(ListenerSupport.java:72)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.hookListener(JavaBeanObservableMap.java:86)
    at org.eclipse.core.databinding.observable.map.ComputedObservableMap.init(ComputedObservableMap.java:114)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.<init>(JavaBeanObservableMap.java:81)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.<init>(JavaBeanObservableMap.java:63)
    at org.eclipse.core.databinding.beans.BeansObservables.observeMap(BeansObservables.java:109)
    at org.eclipse.core.databinding.beans.BeansObservables.observeMaps(BeansObservables.java:171)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceLabelProviderBuilder.createLabelProvider(JFaceLabelProviderBuilder.java:41)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceTableItemsBindingBuilder.build(JFaceTableItemsBindingBuilder.java:33)
    at org.uqbar.lacar.ui.model.bindings.Binding.execute(Binding.java:79)
    at org.uqbar.arena.widgets.Control.showOn(Control.java:137)
    at org.uqbar.arena.widgets.Panel.showOn(Panel.java:121)
    at org.uqbar.arena.windows.Window.showOn(Window.java:189)
    at org.uqbar.arena.windows.Window.showOn(Window.java:1)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder.createWindowContents(JFaceWindowBuilder.java:104)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder$2.createContents(JFaceWindowBuilder.java:215)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder.open(JFaceWindowBuilder.java:71)
    at org.uqbar.arena.windows.Window.open(Window.java:137)
    at org.uqbar.arena.Application.run(Application.java:70)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
    at org.uqbar.lacar.ui.impl.jface.JFaceApplicationBuilder.run(JFaceApplicationBuilder.java:25)
    at org.uqbar.arena.Application.start(Application.java:51)
    at uqbar.examples.burros.ui.arena.BurrosApplication.main(BurrosApplication.java:30)
org.eclipse.core.databinding - 0 - Could not attach listener to uqbar.examples.burros.model.Caballo@7c3885
java.lang.NoSuchMethodException: uqbar.examples.burros.model.Caballo.addPropertyChangeListener(java.beans.PropertyChangeListener)
    at java.lang.Class.getMethod(Class.java:1605)
    at org.eclipse.core.internal.databinding.beans.ListenerSupport.processListener(ListenerSupport.java:177)
    at org.eclipse.core.internal.databinding.beans.ListenerSupport.hookListener(ListenerSupport.java:72)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.hookListener(JavaBeanObservableMap.java:86)
    at org.eclipse.core.databinding.observable.map.ComputedObservableMap.init(ComputedObservableMap.java:114)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.<init>(JavaBeanObservableMap.java:81)
    at org.eclipse.core.internal.databinding.beans.JavaBeanObservableMap.<init>(JavaBeanObservableMap.java:63)
    at org.eclipse.core.databinding.beans.BeansObservables.observeMap(BeansObservables.java:109)
    at org.eclipse.core.databinding.beans.BeansObservables.observeMaps(BeansObservables.java:171)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceLabelProviderBuilder.createLabelProvider(JFaceLabelProviderBuilder.java:41)
    at org.uqbar.lacar.ui.impl.jface.tables.JFaceTableItemsBindingBuilder.build(JFaceTableItemsBindingBuilder.java:33)
    at org.uqbar.lacar.ui.model.bindings.Binding.execute(Binding.java:79)
    at org.uqbar.arena.widgets.Control.showOn(Control.java:137)
    at org.uqbar.arena.widgets.Panel.showOn(Panel.java:121)
    at org.uqbar.arena.windows.Window.showOn(Window.java:189)
    at org.uqbar.arena.windows.Window.showOn(Window.java:1)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder.createWindowContents(JFaceWindowBuilder.java:104)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder$2.createContents(JFaceWindowBuilder.java:215)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.uqbar.lacar.ui.impl.jface.windows.JFaceWindowBuilder.open(JFaceWindowBuilder.java:71)
    at org.uqbar.arena.windows.Window.open(Window.java:137)
    at org.uqbar.arena.Application.run(Application.java:70)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
    at org.uqbar.lacar.ui.impl.jface.JFaceApplicationBuilder.run(JFaceApplicationBuilder.java:25)
    at org.uqbar.arena.Application.start(Application.java:51)
    at uqbar.examples.burros.ui.arena.BurrosApplication.main(BurrosApplication.java:30)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.