Ignore:
Timestamp:
07/02/13 16:20:07 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

CHANGELOG:
Make ProcedureParam? hold only ValueParams?.

Use id instead of names when naming gui components internally.

Basic procedure calling in GUI.

The actual procedure call is currently only backed
by the ObjectInstance?.

Add UnimplementedException?.

Improve naming of various gui elements.

Allow easy navigating in FEST Swing testing.

Add optional explicit order attribute to FramsClassAnnotation?.

That's because java reflection does return declared members
in any specific order. That ordering is needed only for
classes that have no representation in framsticks and need
a deterministic ordering of params.

Add ControlOwner? interface.

Add test for procedure calling in Browser.

First version of ParamAnnotation? for procedures.

Development of ProcedureParam?.

Add draft version of ProcedureParam? implementation in ReflectionAccess?.

Allow viewing FramsClasses? in gui Browser.

Extract ResourceBuilder? from ModelBuilder?.

Remove internalId from Param.

It was currently completely not utilised. Whether it is still needed
after introduction of ParamAnnotation? is arguable.

Add remaining param attributes to ParamAnnotation?.

Change AutoBuilder? semantics.

AutoBuilder? returns list of objects that are to be appended
with methods @AutoAppendAnnotation?.

This allows to omit explicit addition of ModelPackage? to instance
if the instance uses ModelBuilder? (registration of ModelPackage? comes
from schema).

Fix params ordering problem in auto created FramsClasses?.

Improve ObjectInstance?.

Several fixes to ModelBuilder?.

Improve test for ObjectInstance? in Browser.

Make initialization of robot static.

With robot recreated for second browser test, the test hanged
deep in AWT.

Add base convenience base test for Browser tests.

More tests to ObjectInstance?.

Rename Dispatcher.invokeLater() to dispatch().

Add assertDispatch.

It allows assertions in other threads, than TestNGInvoker.
Assertions are gathered after each method invocation and rethrown.

Use timeOut annotation attribute for tests involving some waiting.

Remove firstTask method (merge with joinableStart).

Clean up leftovers.

Remove unused FavouritesXMLFactory (the reading part is already
completely done with generic XmlLoader?, and writing part will be done
based on the same approach if needed).
Move UserFavourite? to the com.framsticks.gui.configuration package.

Remove GenotypeBrowser? as to specific.

This functionality will be available in ObjectInstance?.

Add interface ParamsPackage?.

Package containing registration of Java classes meant to use with
ReflectionAccess? may be in Instance using configuration.

Minor changes.

Make Group immutable.

Add AutoBuilder? interface extending Builder - only those would
be used to automatically build from XML.

Fix groups in FramsClass?.

Minor naming cleanup in Registry.

Add ModelComponent? interface.

All class creating the Model are implementing that interface.

Extract Model.build into ModelBuilder?.

ModelBuilder? will be compatible with other builders
and allow using it from configuration.

Fix NeuroConnection?.

Add synchronous get operation for dispatchers.

Rename JoinableMonitor? to Monitor.

Add ObjectInstance?.

This class is mainly for demonstration
and testing purposes.

Improve FramsServer? runner.

  • improve ExternalProcess? runner,
  • runner can kill the server but also react properly, when the server exists on it's own,
  • set default path to search for framsticks server installation,
  • add LoggingOutputListener?.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/FramsClassBuilder.java

    r88 r90  
    2222import com.framsticks.parsers.Loaders;
    2323import com.framsticks.util.Builder;
    24 import com.framsticks.util.FramsticksException;
     24import com.framsticks.util.lang.Containers;
    2525import com.framsticks.util.lang.Strings;
    2626
     
    3838        }
    3939
    40         public static String getParamTypeForNativeType(Type type) {
     40        public static ParamBuilder induceParamType(ParamBuilder builder, Type type) {
     41
    4142                if (type instanceof ParameterizedType) {
    4243                        ParameterizedType p = (ParameterizedType) type;
     
    5253                        }
    5354                        if (!(containedType instanceof Class)) {
    54                                 return null;
     55                                return builder;
    5556                        }
    5657                        Class<?> containedClass = (Class<?>) containedType;
     
    6061                        if (fca == null) {
    6162                                log.error("the class is not annotated: " + containedClass);
    62                                 return null;
     63                                return builder;
    6364                        }
    6465                        b.append(getName(fca, containedClass));
     
    6768                        }
    6869
    69                         return b.toString();
     70                        builder.type(b.toString());
     71                        return builder;
    7072                }
    7173
     
    8789                        // }
    8890                        if (cl.equals(Integer.class) || cl.equals(int.class)) {
    89                                 return "d";
     91                                builder.type("d");
     92                                return builder;
    9093                        }
    9194                        if (cl.equals(String.class)) {
    92                                 return "s";
     95                                builder.type("s");
     96                                return builder;
    9397                        }
    9498                        if (cl.equals(Double.class) || cl.equals(double.class)) {
    95                                 return "f";
     99                                builder.type("f");
     100                                return builder;
    96101                        }
    97102                        if (cl.equals(Boolean.class) || cl.equals(boolean.class)) {
    98                                 return "d 0 1";
     103                                builder.type( "d 0 1");
     104                                return builder;
    99105                        }
    100106                        if (cl.equals(Object.class)) {
    101                                 return "x";
    102                         }
    103 
    104                         return "o " + ((Class<?>) type).getCanonicalName();
     107                                builder.type("x");
     108                                return builder;
     109                        }
     110
     111                        // builder.type("o " + (cl).getCanonicalName());
     112                        builder.type("o " + cl.getSimpleName());
     113                        builder.fillStorageType(cl);
     114                        return builder;
    105115                }
    106116
    107117                throw new ConstructionException().msg("failed to find framsticks for native type").arg("type", type);
     118        }
     119
     120
     121        public static ParamBuilder induceParamType(ParamBuilder builder, ParamCandidate candidate) {
     122                Method method = candidate.getCaller();
     123                if (method == null) {
     124                        return induceParamType(builder, candidate.getType());
     125                }
     126
     127                builder.resultType(induceParamType(Param.build(), method.getGenericReturnType()).finish(ValueParam.class));
     128
     129                List<ValueParam> arguments = new ArrayList<>();
     130                int number = 0;
     131                for (Type arg : method.getGenericParameterTypes()) {
     132                        arguments.add(induceParamType(Param.build(), arg).idAndName("arg" + (number++)).finish(ValueParam.class));
     133                }
     134                builder.argumentsType(arguments);
     135
     136                return builder;
    108137        }
    109138
     
    183212                name(getName(fca, javaClass));
    184213
    185                 Map<String, ParamCandidate> candidates = ParamCandidate.getAllCandidates(javaClass);
    186 
    187                 for (ParamCandidate pc : candidates.values()) {
    188                         String type = getParamTypeForNativeType(pc.getType());
    189                         if (type == null) {
    190                                 throw new FramsticksException().msg("failed to find type for param candidate").arg("candidate", pc);
    191                         }
    192                         param(Param.build().id(pc.getId()).name(pc.getName()).type(type).flags(pc.getFlags()));
     214                for (ParamCandidate pc : ParamCandidate.getAllCandidates(javaClass).getOrder()) {
     215                        ParamBuilder builder = Param.build().id(pc.getId()).name(pc.getName()).flags(pc.getFlags());
     216
     217                        induceParamType(builder, pc);
     218
     219                        for (ParamAnnotation pa : pc.getAnnotations()) {
     220                                if (!"".equals(pa.def())) {
     221                                        builder.def(pa.def());
     222                                }
     223                                if (!"".equals(pa.help())) {
     224                                        builder.help(pa.help());
     225                                }
     226                                if (!"".equals(pa.min())) {
     227                                        builder.min(pa.min());
     228                                }
     229                                if (!"".equals(pa.max())) {
     230                                        builder.max(pa.max());
     231                                }
     232                                builder.extra(pa.extra());
     233                                if (!"".equals(pa.stringType())) {
     234                                        builder.type(pa.stringType());
     235                                }
     236                                if (!pa.paramType().equals(Param.class)) {
     237                                        builder.type(pa.paramType());
     238                                }
     239                        }
     240                        param(builder);
    193241                }
    194242
     
    209257        protected final List<Param> params = new LinkedList<>();
    210258
    211         protected List<Group> groups = new ArrayList<Group>();
     259        protected List<GroupBuilder> groupBuilders = new ArrayList<GroupBuilder>();
    212260
    213261        @ParamAnnotation
     
    242290        }
    243291
    244         public FramsClassBuilder append(Param param) {
    245                 params.add(param);
    246                 return this;
    247         }
    248 
    249292        @AutoAppendAnnotation
    250293        public FramsClassBuilder param(ParamBuilder builder) {
    251                 return append(builder.finish());
     294                Param param = builder.finish();
     295
     296                Integer group = param.getGroup();
     297                if (group != null) {
     298                        Containers.getFromList(groupBuilders, group, "group", this).addParam(param);
     299                }
     300
     301                params.add(param);
     302                return this;
    252303        }
    253304
    254305        @AutoAppendAnnotation
    255306        public FramsClassBuilder group(GroupBuilder builder) {
    256                 return group(builder.finish());
    257         }
    258 
    259         @AutoAppendAnnotation
    260         public FramsClassBuilder group(Group group) {
    261                 groups.add(group);
     307                groupBuilders.add(builder);
    262308                return this;
    263309        }
     
    288334
    289335        public FramsClassBuilder group(String group) {
    290                 return group(new Group(group));
    291         }
    292 
    293         public ParamBuilder param(String id) {
    294                 return new ParamBuilder(this).id(id);
    295         }
     336                return group(new GroupBuilder().name(group));
     337        }
     338
    296339
    297340}
Note: See TracChangeset for help on using the changeset viewer.