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/core/Instance.java

    r88 r90  
    88
    99import javax.annotation.Nonnull;
    10 import javax.annotation.OverridingMethodsMustInvokeSuper;
    1110
    1211import org.apache.log4j.Logger;
     
    1413import com.framsticks.communication.File;
    1514import com.framsticks.params.AccessInterface;
     15import com.framsticks.params.CompositeParam;
    1616import com.framsticks.params.ConstructionException;
    1717import com.framsticks.params.FramsClass;
    1818import com.framsticks.params.ListAccess;
    1919import com.framsticks.params.Param;
     20import com.framsticks.params.ParamsPackage;
    2021import com.framsticks.params.Registry;
    2122import com.framsticks.params.ValueParam;
     23import com.framsticks.params.annotations.AutoAppendAnnotation;
    2224import com.framsticks.params.annotations.FramsClassAnnotation;
    2325import com.framsticks.params.types.ObjectParam;
     26import com.framsticks.params.types.ProcedureParam;
    2427import com.framsticks.parsers.Loaders;
    2528import com.framsticks.parsers.MultiParamLoader;
     29import com.framsticks.util.FramsticksException;
    2630import com.framsticks.util.StateFunctor;
    2731import com.framsticks.util.UnsupportedOperationException;
     
    4044        private static final Logger log = Logger.getLogger(Instance.class.getName());
    4145
    42         protected Node root;
     46        private Node root;
     47
     48        protected @Nonnull Node setRoot(CompositeParam param, Object object) {
     49                // if (isRootAssigned()) {
     50                //      throw new FramsticksException().msg("root is already assigned");
     51                // }
     52                // assert isActive();
     53                root = new Node(param, object);
     54                return root;
     55        }
     56
     57        protected @Nonnull Node getRoot() {
     58                // assert isActive();
     59                assert root != null;
     60                return root;
     61        }
     62
     63        public boolean isRootAssigned() {
     64                // assert isActive();
     65                return root != null;
     66        }
    4367
    4468        protected Set<InstanceListener> listeners = new HashSet<InstanceListener>();
     
    6892        }
    6993
    70         public void fetchValue(Path path, Param param, StateFunctor stateFunctor) {
    71                 stateFunctor.call(null);
    72         }
    73 
    74         public void fetchValues(Path path, StateFunctor stateFunctor) {
    75                 stateFunctor.call(null);
    76         }
     94        /** This is part of the Instance interface.
     95         *
     96         */
     97        public abstract void fetchValue(Path path, Param param, StateFunctor stateFunctor);
     98
     99        /** This is part of the Instance interface.
     100         *
     101         */
     102        public abstract void fetchValues(Path path, StateFunctor stateFunctor);
     103
     104        /** This is part of the Instance interface.
     105         *
     106         */
     107        public abstract void call(Path path, ProcedureParam param, Object[] arguments, StateFunctor stateFunctor);
    77108
    78109        protected void tryRegisterOnChangeEvents(Path path) {
     
    82113        public void storeValue(Path path, Param param, Object value, final StateFunctor stateFunctor) {
    83114                assert isActive();
    84                 invokeLater(new RunAt<Instance>() {
     115                dispatch(new RunAt<Instance>() {
    85116                        @Override
    86117                        public void run() {
     
    104135        public void addListener(final InstanceListener listener) {
    105136                assert Dispatching.isThreadSafe();
    106                 Dispatching.invokeLaterOrNow(this, new RunAt<Instance>() {
     137                Dispatching.dispatchIfNotActive(this, new RunAt<Instance>() {
    107138                        @Override
    108139                        public void run() {
     
    114145        public void removeListener(final InstanceListener listener) {
    115146                assert Dispatching.isThreadSafe();
    116                 Dispatching.invokeLaterOrNow(this, new RunAt<Instance>() {
     147                Dispatching.dispatchIfNotActive(this, new RunAt<Instance>() {
    117148                        @Override
    118149                        public void run() {
     
    142173        public FramsClass getInfoFromCache(String id) {
    143174                assert isActive();
    144                 return registry.getInfoFromCache(id);
     175                return registry.getFramsClass(id);
    145176        }
    146177
     
    169200        }
    170201
     202        public final AccessInterface bindAccess(String path) {
     203                return bindAccess(getPath(path));
     204        }
     205
    171206        public final AccessInterface bindAccess(Node node) {
     207                assert isActive();
    172208                assert node.getObject() != null;
    173209
    174210                try {
    175                         return registry.prepareAccess(node.getParam()).select(node.getObject());
     211                        AccessInterface access = registry.prepareAccess(node.getParam());
     212                        if (access == null) {
     213                                throw new FramsticksException().msg("failed to prepare access for param").arg("param", node.getParam());
     214                        }
     215                        return access.select(node.getObject());
    176216                } catch (ConstructionException e) {
    177217                        log.error("failed to bind access for " + node.getParam() + ": " + e);
     
    185225
    186226        public final AccessInterface bindAccess(Path path) {
    187                 assert path.isResolved();
     227                path.assureResolved();
    188228                return bindAccess(path.getTop());
    189229        }
     
    260300                        assert child != null;
    261301                        if (path.size() == 1) {
    262                                 root = new Node(root.getParam(), child);
     302                                setRoot(getRoot().getParam(), child);
    263303                        } else {
    264304                                bindAccess(path.getUnder()).set(path.getTop().getParam(), child);
     
    277317                FramsClass framsClass = Loaders.loadFramsClass(file.getContent());
    278318                if ("/".equals(file.getPath())) {
    279                         if (root.getParam().getContainedTypeName() == null) {
    280                                 root = new Node(Param.build().name("Instance").id(getName()).type("o " + framsClass.getId()), root.getObject());
    281                         }
    282                 }
    283                 registry.putInfoIntoCache(framsClass);
     319                        if (getRoot().getParam().getContainedTypeName() == null) {
     320                                setRoot(Param.build().name("Instance").id(getName()).type("o " + framsClass.getId()).finish(CompositeParam.class), getRoot().getObject());
     321                        }
     322                }
     323                registry.putFramsClass(framsClass);
    284324                return framsClass;
    285325        }
     
    299339                                loader.go();
    300340                                fireFetch(path);
    301         //            for (NodeListener l : listeners) {
    302         //                l.onChange(this);
    303         //            }
    304341                                return;
    305342                        }
     
    318355                                        String id = listAccess.computeIdentifierFor(accessInterface.getSelected());
    319356                                        //TODO listAccessParam
    320                                         Param param = Param.build().type("o " + accessInterface.getId()).id(id).finish();
     357                                        Param param = Param.build().forAccess(accessInterface).id(id).finish();
    321358                                        Object child = accessInterface.getSelected();
    322359                                        accessInterface.select(null);
     
    327364
    328365                        fireFetch(path);
    329         //        for (NodeListener l : listeners) {
    330         //            l.onChange(this);
    331         //        }
    332366                } catch (Exception e) {
    333367                        log.error("exception occurred while loading: " + e);
     
    358392        }
    359393
     394        @AutoAppendAnnotation
     395        public void usePackage(ParamsPackage paramsPackage) {
     396                log.debug("using package " + paramsPackage + " in instance " + this);
     397                paramsPackage.register(registry);
     398        }
     399
     400        @AutoAppendAnnotation
     401        public void takeFromRegistry(Registry registry) {
     402                log.debug("taking from registry " + registry + " in instance " + this);
     403                this.registry.takeAllFrom(registry);
     404        }
     405
    360406        @Override
    361         @OverridingMethodsMustInvokeSuper
    362         protected void firstTask() {
    363                 root = new Node(Param.build().name("Instance").id(getName()).type("o"), null);
    364                 com.framsticks.model.Package.register(registry);
     407        protected void joinableStart() {
     408                dispatch(new RunAt<Instance>() {
     409                        @Override
     410                        public void run() {
     411                                if (!isRootAssigned()) {
     412                                        setRoot(Param.build().name("Instance").id(getName()).type("o").finish(CompositeParam.class), null);
     413                                }
     414                        }
     415                });
     416                super.joinableStart();
    365417        }
    366418
Note: See TracChangeset for help on using the changeset viewer.