Changeset 100
- Timestamp:
- 07/12/13 23:41:06 (11 years ago)
- Location:
- java/main
- Files:
-
- 16 added
- 4 deleted
- 113 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/pom.xml
r99 r100 36 36 </dependency> 37 37 <dependency> 38 <groupId>log4j</groupId> 39 <artifactId>log4j</artifactId> 40 <version>1.2.16</version> 41 <scope>compile</scope> 38 <groupId>org.apache.logging.log4j</groupId> 39 <artifactId>log4j-api</artifactId> 40 <version>2.0-beta7</version> 42 41 </dependency> 42 <dependency> 43 <groupId>org.apache.logging.log4j</groupId> 44 <artifactId>log4j-core</artifactId> 45 <version>2.0-beta7</version> 46 </dependency> 47 <!-- <dependency> --> 48 <!-- <groupId>org.apache.logging.log4j</groupId> --> 49 <!-- <artifactId>log4j-1.2-api</artifactId> --> 50 <!-- <version>2.0-beta7</version> --> 51 <!-- </dependency> --> 43 52 <dependency> 44 53 <groupId>commons-collections</groupId> … … 101 110 <version>2.9</version> 102 111 <configuration> 103 <forkedProcessTimeoutInSeconds> 60</forkedProcessTimeoutInSeconds>112 <forkedProcessTimeoutInSeconds>120</forkedProcessTimeoutInSeconds> 104 113 <useFile>false</useFile> 105 114 </configuration> … … 134 143 <argument>-ea</argument> 135 144 <argument>-Xdebug</argument> 136 < argument>-Xrunjdwp:transport=dt_socket,address=4711,server=y,suspend=n</argument>145 <!-- <argument>-Xrunjdwp:transport=dt_socket,address=4711,server=y,suspend=n</argument> --> 137 146 <argument>-classpath</argument> 138 147 <classpath /> -
java/main/src/main/java/com/framsticks/communication/ClientSideManagedConnection.java
r99 r100 17 17 import com.framsticks.util.dispatching.FutureHandler; 18 18 import com.framsticks.util.dispatching.JoinableState; 19 import com.framsticks.util.lang.Casting; 19 20 import com.framsticks.util.lang.Pair; 20 21 import com.framsticks.util.lang.Strings; 21 22 import com.framsticks.params.EventListener; 22 23 23 import org.apache.log4j.Logger; 24 import org.apache.logging.log4j.Logger; 25 import org.apache.logging.log4j.LogManager; 24 26 25 27 import java.util.*; 26 28 import java.util.regex.Matcher; 29 30 import javax.annotation.Nonnull; 31 import javax.annotation.Nullable; 32 27 33 import com.framsticks.util.dispatching.RunAt; 28 34 … … 32 38 public class ClientSideManagedConnection extends ManagedConnection { 33 39 34 private final static Logger log = Log ger.getLogger(ClientSideManagedConnection.class);40 private final static Logger log = LogManager.getLogger(ClientSideManagedConnection.class); 35 41 36 42 private final List<Runnable> applicationRequestsBuffer = new LinkedList<>(); … … 60 66 61 67 62 private static abstract class InboundMessage {63 protected String currentFilePath;64 protected List<String> currentFileContent;65 protected final List<File> files = new ArrayList<File>();66 67 public abstract void eof();68 69 protected void initCurrentFile(String path) {70 currentFileContent = new LinkedList<String>();71 currentFilePath = path;72 }73 74 protected void finishCurrentFile() {75 if (currentFileContent == null) {76 return;77 }78 files.add(new File(currentFilePath, new ListSource(currentFileContent)));79 currentFilePath = null;80 currentFileContent = null;81 }82 83 public abstract void startFile(String path);84 85 public final void addLine(String line) {86 assert line != null;87 assert currentFileContent != null;88 currentFileContent.add(line);89 }90 91 public List<File> getFiles() {92 return files;93 }94 }95 68 96 69 protected List<String> readFileContent() { 97 70 List<String> content = new LinkedList<String>(); 98 71 String line; 99 while (!(line = getLine()).startsWith("eof")) { 72 boolean longValue = false; 73 while (true) { 74 line = getLine(); 75 if (longValue) { 76 if (line.endsWith("~") && !line.endsWith("\\~")) { 77 longValue = false; 78 } 79 } else { 80 if (line.equals("eof")) { 81 break; 82 } 83 if (line.endsWith(":~")) { 84 longValue = true; 85 } 86 } 100 87 content.add(line); 101 88 } … … 103 90 } 104 91 105 private static class SentQuery<C> extends InboundMessage { 92 private static class SentQuery<C> { 93 106 94 Request request; 107 95 ClientSideResponseFuture callback; 108 96 Dispatcher<C> dispatcher; 109 110 public void startFile(String path) { 111 finishCurrentFile(); 112 if (!Strings.notEmpty(path)) { 113 assert request instanceof ApplicationRequest; 114 path = ((ApplicationRequest) request).getPath(); 115 } 116 Strings.assureNotEmpty(path); 117 initCurrentFile(path); 118 } 119 120 public void eof() { 121 assert Strings.notEmpty(currentFilePath); 122 finishCurrentFile(); 123 //no-operation 97 protected final List<File> files = new ArrayList<File>(); 98 99 public List<File> getFiles() { 100 return files; 124 101 } 125 102 … … 169 146 170 147 if (getState().ordinal() > JoinableState.RUNNING.ordinal()) { 171 log.fatal("not connected"); 172 return; 148 throw new FramsticksException().msg("connection is not connected").arg("connection", this); 173 149 } 174 150 … … 211 187 putLine(out); 212 188 flushOut(); 213 log.debug("sending query: " +out);189 log.debug("sending query: {}", out); 214 190 215 191 } … … 217 193 /* 218 194 synchronized (this) { 219 log.debug("queueing query: " +query);195 log.debug("queueing query: {}", query); 220 196 queryQueue.offer(sentQuery); 221 197 notifyAll(); … … 253 229 } 254 230 255 private synchronized SentQuery<?> fetchQuery(Integer id, boolean remove) { 256 if (id == null) { 257 if (requestIdEnabled) { 258 return null; 259 } 260 SentQuery<?> result = currentlySentQuery; 261 if (remove) { 262 currentlySentQuery = null; 263 notifyAll(); 264 } 265 return result; 266 } 267 if (queryMap.containsKey(id)) { 231 private synchronized @Nonnull SentQuery<?> fetchQuery(@Nullable Integer id, boolean remove) { 232 try { 233 if (id == null) { 234 if (requestIdEnabled) { 235 throw new FramsticksException().msg("request_id is enabled and id is missing"); 236 } 237 SentQuery<?> result = currentlySentQuery; 238 if (remove) { 239 currentlySentQuery = null; 240 notifyAll(); 241 } 242 return result; 243 } 244 245 if (!queryMap.containsKey(id)) { 246 throw new FramsticksException().msg("id is unknown").arg("id", id); 247 } 248 268 249 SentQuery<?> result = queryMap.get(id); 269 250 if (remove) { … … 271 252 } 272 253 return result; 273 } 274 return null; 254 255 } catch (FramsticksException e) { 256 throw new FramsticksException().msg("failed to match response to sent query").cause(e); 257 } 275 258 } 276 259 277 260 private int nextQueryId = 0; 278 279 protected void processMessage(InboundMessage inboundMessage) {280 if (inboundMessage == null) {281 log.error("failed to use any inbound message");282 return;283 }284 285 String line;286 while (!(line = getLine()).startsWith("eof")) {287 // log.debug("line: " + line);288 inboundMessage.addLine(line);289 }290 inboundMessage.eof();291 }292 261 293 262 protected void processEvent(String rest) { … … 303 272 String eventCalleePath = Request.takeGroup(rest, matcher, 2).toString(); 304 273 final File file = new File("", new ListSource(readFileContent())); 305 log.debug("firing event " +eventObjectPath);274 log.debug("firing event {}", eventObjectPath); 306 275 EventListener<File> listener; 307 276 synchronized (registeredListeners) { … … 314 283 } 315 284 316 protected void processMessageStartingWith(String line) { 285 protected void processFile(Pair<Integer, CharSequence> rest) { 286 final SentQuery<?> sentQuery = fetchQuery(rest.first, false); 287 288 String currentFilePath = rest.second.toString(); 289 if (!Strings.notEmpty(currentFilePath)) { 290 currentFilePath = Casting.throwCast(ApplicationRequest.class, sentQuery.request).getPath(); 291 } 292 293 sentQuery.files.add(new File(currentFilePath, new ListSource(readFileContent()))); 294 295 } 296 297 protected void processMessageStartingWith(final String header) { 317 298 try { 318 Pair<CharSequence, CharSequence> command = Request.takeIdentifier(line); 319 if (command.first.equals("event")) { 299 final Pair<CharSequence, CharSequence> command = Request.takeIdentifier(header); 300 if (command == null) { 301 throw new FramsticksException().msg("failed to parse command"); 302 } 303 final CharSequence keyword = command.first; 304 if (keyword.equals("event")) { 320 305 processEvent(command.second.toString()); 321 306 return; 322 307 } 323 Pair<Integer, CharSequence> rest = takeRequestId(command.second); 324 325 if (command.first.equals("file")) { 326 SentQuery<?> sentQuery = fetchQuery(rest.first, false); 327 sentQuery.startFile(rest.second.toString()); 328 processMessage(sentQuery); 308 309 final Pair<Integer, CharSequence> rest = takeRequestId(command.second); 310 if (rest == null) { 311 throw new FramsticksException().msg("failed to parse optional id and remainder"); 312 } 313 314 if (keyword.equals("file")) { 315 processFile(rest); 329 316 return; 330 317 } 331 332 SentQuery<?> sentQuery = fetchQuery(rest.first, true); 333 if (sentQuery == null) { 318 if (keyword.equals("ok") || keyword.equals("error")) { 319 320 final SentQuery<?> sentQuery = fetchQuery(rest.first, true); 321 322 log.debug("parsing response for request {}", sentQuery); 323 324 sentQuery.dispatchResponseProcess(new Response(command.first.equals("ok"), rest.second.toString(), sentQuery.getFiles())); 334 325 return; 335 326 } 336 log.debug("parsing response for request " + sentQuery); 337 338 sentQuery.dispatchResponseProcess(new Response(command.first.equals("ok"), rest.second.toString(), sentQuery.getFiles())); 327 328 throw new FramsticksException().msg("unknown command keyword").arg("keyword", keyword); 339 329 } catch (FramsticksException e) { 340 throw new FramsticksException().msg("failed to process message").arg("starting with line", line).cause(e);330 throw new FramsticksException().msg("failed to process message").arg("starting with line", header).cause(e); 341 331 } 342 332 } -
java/main/src/main/java/com/framsticks/communication/Connection.java
r97 r100 8 8 import com.framsticks.util.lang.Strings; 9 9 10 import org.apache.log4j.Level; 11 import org.apache.log4j.Logger; 10 import org.apache.logging.log4j.Level; 11 import org.apache.logging.log4j.Logger; 12 import org.apache.logging.log4j.LogManager; 12 13 import java.io.BufferedReader; 13 14 import java.io.IOException; … … 22 23 23 24 import com.framsticks.util.dispatching.AbstractJoinable; 25 import com.framsticks.util.dispatching.Dispatcher; 24 26 import com.framsticks.util.dispatching.Dispatching; 27 import com.framsticks.util.dispatching.ExceptionResultHandler; 25 28 import com.framsticks.util.dispatching.Joinable; 26 29 import com.framsticks.util.dispatching.JoinableCollection; … … 32 35 33 36 @FramsClassAnnotation 34 public abstract class Connection extends AbstractJoinable implements JoinableParent {35 36 protected final static Logger log = Log ger.getLogger(Connection.class);37 public abstract class Connection extends AbstractJoinable implements JoinableParent, ExceptionResultHandler { 38 39 protected final static Logger log = LogManager.getLogger(Connection.class); 37 40 38 41 private PrintWriter output = null; … … 48 51 protected final JoinableCollection<Thread<Connection>> threads = new JoinableCollection<>(); 49 52 protected final Set<ConnectionListener> listeners = new HashSet<>(); 53 54 protected ExceptionResultHandler exceptionHandler = ThrowExceptionHandler.getInstance(); 50 55 51 56 /** … … 161 166 try { 162 167 processNextInputBatch(); 168 } catch (FramsticksException e) { 169 handle(e); 163 170 } catch (Exception e) { 164 171 log.log(isRunning() ? Level.ERROR : Level.DEBUG, "caught exception: ", e); … … 183 190 } 184 191 185 186 187 192 @Override 188 193 protected void joinableFinish() { … … 197 202 input = null; 198 203 } 199 200 204 201 205 if (socket != null) { … … 250 254 } 251 255 252 253 256 @Override 254 257 protected void joinableJoin() throws InterruptedException { … … 258 261 protected static void startClientConnection(Connection connection) { 259 262 while (connection.isRunning() && !connection.isConnected()) { 260 log.debug("connecting to " +connection.address);263 log.debug("connecting to {}", connection.address); 261 264 try { 262 265 connection.socket = new Socket(connection.getAddressObject().getHostName(), connection.getAddressObject().getPort()); 263 266 } catch (IOException e) { 264 log.info( connection + " failed to connect (retrying): " +e);267 log.info("{} failed to connect (retrying): ", connection, e); 265 268 Dispatching.sleep(0.5); 266 269 } 267 270 } 268 271 269 log.debug( connection + " connected");272 log.debug("{} connected", connection); 270 273 try { 271 274 connection.socket.setSoTimeout(500); … … 288 291 } 289 292 290 291 293 /** 292 294 * @return the listeners … … 294 296 public Collection<ConnectionListener> getListeners() { 295 297 return listeners; 298 } 299 300 /** 301 * @return the handler 302 */ 303 public ExceptionResultHandler getExceptionHandler() { 304 return exceptionHandler; 305 } 306 307 /** 308 * @param handler the handler to set 309 */ 310 public void setExceptionHandler(ExceptionResultHandler handler) { 311 this.exceptionHandler = handler; 296 312 } 297 313 … … 301 317 } 302 318 319 @Override 320 public void handle(FramsticksException exception) { 321 exceptionHandler.handle(exception); 322 } 323 324 public Dispatcher<Connection> getReceiverDispatcher() { 325 return receiverThread; 326 } 327 328 public Dispatcher<Connection> getSenderDispatcher() { 329 return senderThread; 330 } 331 332 303 333 } -
java/main/src/main/java/com/framsticks/communication/ServerSideManagedConnection.java
r99 r100 8 8 import com.framsticks.util.lang.Strings; 9 9 10 import org.apache.log4j.Logger; 10 import org.apache.logging.log4j.Logger; 11 import org.apache.logging.log4j.LogManager; 11 12 12 13 import java.net.Socket; … … 18 19 public class ServerSideManagedConnection extends ManagedConnection { 19 20 20 private final static Logger log = Log ger.getLogger(ServerSideManagedConnection.class);21 private final static Logger log = LogManager.getLogger(ServerSideManagedConnection.class); 21 22 22 23 protected final RequestHandler requestHandler; … … 64 65 65 66 } 66 log.error("unhandled request: " +request);67 log.error("unhandled request: {}", request); 67 68 responseCallback.pass(new Response(false, "unhandled", null)); 68 69 } … … 123 124 124 125 if (log.isTraceEnabled()) { 125 log.trace("read request: " +request);126 log.trace("read request: {}", request); 126 127 } 127 128 -
java/main/src/main/java/com/framsticks/communication/util/LoggingStateCallback.java
r97 r100 4 4 import com.framsticks.communication.Response; 5 5 6 import org.apache.log 4j.Logger;6 import org.apache.logging.log4j.Logger; 7 7 8 8 /** -
java/main/src/main/java/com/framsticks/core/AbstractTree.java
r99 r100 1 1 package com.framsticks.core; 2 2 3 import java.util.Map; 4 3 5 import javax.annotation.Nonnull; 4 6 5 import org.apache.log4j.Logger; 6 7 import com.framsticks.params.AccessInterface; 7 import org.apache.commons.collections.map.ReferenceIdentityMap; 8 import org.apache.logging.log4j.Logger; 9 import org.apache.logging.log4j.LogManager; 10 11 import com.framsticks.params.Access; 8 12 import com.framsticks.params.CompositeParam; 9 13 import com.framsticks.params.FramsClass; … … 14 18 import com.framsticks.params.annotations.ParamAnnotation; 15 19 import com.framsticks.util.FramsticksException; 20 import com.framsticks.util.Misc; 16 21 import com.framsticks.util.dispatching.AbstractJoinable; 17 22 import com.framsticks.util.dispatching.Dispatcher; … … 25 30 import com.framsticks.util.dispatching.Thread; 26 31 import com.framsticks.util.dispatching.ThrowExceptionHandler; 32 import com.framsticks.util.lang.Casting; 27 33 28 34 /** … … 32 38 public abstract class AbstractTree extends AbstractJoinable implements Dispatcher<Tree>, Tree, JoinableParent { 33 39 34 private static final Logger log = Log ger.getLogger(AbstractTree.class);40 private static final Logger log = LogManager.getLogger(AbstractTree.class); 35 41 36 42 private Node root = null; … … 45 51 } 46 52 root = new Node(this, param, null); 47 log.debug("assigned root type: " +root);53 log.debug("assigned root type: {}", root); 48 54 } 49 55 … … 57 63 } 58 64 root = new Node(this, root.getParam(), object); 59 log.debug("assigned root object: " +root);65 log.debug("assigned root object: {}", root); 60 66 } 61 67 … … 93 99 94 100 @Override 95 public @Nonnull Access InterfaceprepareAccess(CompositeParam param) {101 public @Nonnull Access prepareAccess(CompositeParam param) { 96 102 return registry.prepareAccess(param); 97 103 } … … 104 110 @AutoAppendAnnotation 105 111 public void usePackage(ParamsPackage paramsPackage) { 106 log.debug("using package " + paramsPackage + " in tree " +this);112 log.debug("using package {} in tree {}", paramsPackage, this); 107 113 paramsPackage.register(registry); 108 114 } … … 110 116 @AutoAppendAnnotation 111 117 public void takeFromRegistry(Registry registry) { 112 log.debug("taking from registry " + registry + " in tree " +this);118 log.debug("taking from registry {} in tree {}", registry, this); 113 119 this.registry.takeAllFrom(registry); 114 120 } … … 231 237 } 232 238 239 240 @SuppressWarnings("unchecked") 241 protected final Map<Object, Object> sideNotes = (Map<Object, Object>) new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD); 242 243 @Override 244 public void putSideNote(Object object, Object key, Object value) { 245 assert isActive(); 246 Misc.throwIfNull(object); 247 Misc.throwIfNull(key); 248 Misc.throwIfNull(value); 249 Object sideNote = sideNotes.get(object); 250 if (sideNote == null) { 251 sideNote = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD); 252 sideNotes.put(object, sideNote); 253 } 254 @SuppressWarnings("unchecked") 255 Map<Object, Object> sideNotesMap = (Map<Object, Object>) sideNote; 256 sideNotesMap.put(key, value); 257 } 258 259 @Override 260 public <T> T getSideNote(Object object, Object key, Class<T> valueType) { 261 assert isActive(); 262 Misc.throwIfNull(object); 263 Misc.throwIfNull(key); 264 Object sideNote = sideNotes.get(object); 265 if (sideNote == null) { 266 return null; 267 } 268 return Casting.nullOrThrowCast(valueType, ((Map<?, ?>) sideNote).get(key)); 269 } 270 271 @Override 272 public boolean removeSideNote(Object object, Object key) { 273 Object sideNote = sideNotes.get(object); 274 if (sideNote == null) { 275 return false; 276 } 277 @SuppressWarnings("unchecked") 278 Map<Object, Object> sideNotesMap = (Map<Object, Object>) sideNote; 279 boolean result = (sideNotesMap.remove(key) != null); 280 if (sideNotesMap.isEmpty()) { 281 sideNotes.remove(object); 282 } 283 return result; 284 } 285 233 286 } 234 287 -
java/main/src/main/java/com/framsticks/core/Framsticks.java
r99 r100 7 7 import com.framsticks.util.dispatching.Monitor; 8 8 9 import org.apache.log 4j.Logger;10 import org.apache.log 4j.PropertyConfigurator;9 import org.apache.logging.log4j.Logger; 10 import org.apache.logging.log4j.LogManager; 11 11 12 12 import java.io.InputStream; … … 17 17 @FramsClassAnnotation 18 18 public class Framsticks extends JoinableCollection<Joinable> { 19 private static final Logger log = Log ger.getLogger(Framsticks.class);19 private static final Logger log = LogManager.getLogger(Framsticks.class); 20 20 21 21 public Framsticks() { 22 PropertyConfigurator.configure(getClass().getResource("/configs/log4j.properties"));23 22 24 // log.info("config is: " + System.getProperties().getProperty("framsticks.config", "/configs/framsticks.xml"));25 23 } 26 24 -
java/main/src/main/java/com/framsticks/core/ListChange.java
r87 r100 3 3 import com.framsticks.params.annotations.FramsClassAnnotation; 4 4 import com.framsticks.params.annotations.ParamAnnotation; 5 import com.framsticks.util.Misc; 5 6 import com.framsticks.util.lang.Strings; 6 7 … … 8 9 * @author Piotr Sniegowski 9 10 */ 10 @FramsClassAnnotation 11 @FramsClassAnnotation(order = {"type", "pos", "id"}) 11 12 public class ListChange { 13 14 15 /** 16 * @param action 17 */ 18 public ListChange(Action action, Integer position, String identifier) { 19 this.action = action; 20 this.position = position; 21 this.identifier = identifier; 22 } 23 24 /** 25 * 26 */ 27 public ListChange() { 28 } 12 29 13 30 public Action getAction() { … … 37 54 // */ 38 55 // Action(int value) { 39 // 56 // this.value = value; 40 57 // } 41 58 … … 43 60 44 61 public Action action = Action.Add; 45 @ParamAnnotation(id = "pos" )62 @ParamAnnotation(id = "pos", def = "-1") 46 63 public Integer position; 47 64 @ParamAnnotation(id = "id") … … 64 81 return action + " " + identifier + " " + position; 65 82 } 83 84 @Override 85 public boolean equals(Object object) { 86 if (object instanceof ListChange) { 87 ListChange r = (ListChange) object; 88 return Misc.equals(action, r.action) && Misc.equals(position, r.position) && Misc.equals(identifier, r.identifier); 89 } 90 return false; 91 } 92 66 93 } -
java/main/src/main/java/com/framsticks/core/LocalTree.java
r99 r100 1 1 package com.framsticks.core; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 import com.framsticks.params.Access Interface;6 import com.framsticks.params.Access; 6 7 import com.framsticks.params.CompositeParam; 7 8 import com.framsticks.params.EventListener; … … 9 10 import com.framsticks.params.ParamBuilder; 10 11 import com.framsticks.params.PrimitiveParam; 11 import com.framsticks.params.ValueParam;12 12 import com.framsticks.params.annotations.AutoAppendAnnotation; 13 13 import com.framsticks.params.annotations.FramsClassAnnotation; … … 21 21 @FramsClassAnnotation 22 22 public final class LocalTree extends AbstractTree { 23 private static final Logger log = Log ger.getLogger(LocalTree.class);23 private static final Logger log = LogManager.getLogger(LocalTree.class); 24 24 25 25 protected Object rootObject; … … 38 38 registry.registerAndBuild(javaClass); 39 39 40 Access Interfaceaccess = registry.createAccess(javaClass);40 Access access = registry.createAccess(javaClass); 41 41 42 42 assignRootParam(access.buildParam(new ParamBuilder()).id(getName()).finish(CompositeParam.class)); … … 62 62 public void get(Path path, Future<Path> future) { 63 63 assert isActive(); 64 log.debug("requesting: " +path);64 log.debug("requesting: {}", path); 65 65 path = resolveTopSync(path); 66 66 future.pass(path); 67 67 } 68 68 69 @Override70 public void get(Path path, ValueParam param, Future<Object> future) {71 assert isActive();72 path = resolveTopSync(path);73 future.pass(bindAccess(path).get(param, Object.class));74 }69 // @Override 70 // public void get(Path path, ValueParam param, Future<Object> future) { 71 // assert isActive(); 72 // path = resolveTopSync(path); 73 // future.pass(bindAccess(path).get(param, Object.class)); 74 // } 75 75 76 76 @Override … … 103 103 return path; 104 104 } 105 Access Interfaceaccess = bindAccess(path.getUnder());105 Access access = bindAccess(path.getUnder()); 106 106 Object object = access.get(path.getTop().getParam(), Object.class); 107 107 if (object == null) { -
java/main/src/main/java/com/framsticks/core/Path.java
r99 r100 1 1 package com.framsticks.core; 2 2 3 import com.framsticks.params.Access Interface;3 import com.framsticks.params.Access; 4 4 import com.framsticks.params.CompositeParam; 5 5 import com.framsticks.params.Param; … … 25 25 @Immutable 26 26 public final class Path { 27 // private final static Logger log = Log ger.getLogger(Path.class.getName());27 // private final static Logger log = LogManager.getLogger(Path.class.getName()); 28 28 29 29 final Tree tree; … … 31 31 final LinkedList<Node> nodes; 32 32 33 protected static Object getKnownChild(Tree tree, Access Interfaceaccess, CompositeParam param, ExceptionResultHandler handler) {33 protected static Object getKnownChild(Tree tree, Access access, CompositeParam param, ExceptionResultHandler handler) { 34 34 Object child = access.get(param, Object.class); 35 35 if (child == null) { … … 38 38 try { 39 39 tree.prepareAccess(param); 40 tree.putSideNote(child, CompositeParam.class, param); 40 41 return child; 41 42 } catch (FramsticksException e) { … … 151 152 Iterator<String> i = splitPath(textual); 152 153 while (i.hasNext() && current.getObject() != null) { 153 Access Interfaceaccess = TreeOperations.bindAccess(current);// tree.prepareAccess(current.getParam());154 Access access = TreeOperations.bindAccess(current);// tree.prepareAccess(current.getParam()); 154 155 String e = i.next(); 155 156 Param p = access.getParam(e); … … 163 164 b.append("/").append(e); 164 165 access.select(current.getObject()); 166 tree.putSideNote(current.getObject(), CompositeParam.class, current.getParam()); 165 167 current = new Node(current.getTree(), c, getKnownChild(tree, access, c, handler)); 166 168 nodes.add(current); -
java/main/src/main/java/com/framsticks/core/Tree.java
r99 r100 3 3 import javax.annotation.Nonnull; 4 4 5 import com.framsticks.params.Access Interface;5 import com.framsticks.params.Access; 6 6 import com.framsticks.params.CompositeParam; 7 7 import com.framsticks.params.EventListener; … … 9 9 import com.framsticks.params.PrimitiveParam; 10 10 import com.framsticks.params.Registry; 11 import com.framsticks.params.ValueParam;12 11 import com.framsticks.params.types.EventParam; 13 12 import com.framsticks.params.types.ProcedureParam; … … 24 23 public void assignRootObject(Object object); 25 24 26 public @Nonnull Access InterfaceprepareAccess(CompositeParam param);25 public @Nonnull Access prepareAccess(CompositeParam param); 27 26 public void takeAllFrom(Registry source); 28 27 … … 31 30 public void putInfoIntoCache(FramsClass framclass); 32 31 33 / **34 *35 * Functions accepts ValueParam, because it is also possible to get number of List elements.36 *37 */38 public void get(Path path, ValueParam param, Future<Object> future);32 // /** 33 // * 34 // * Functions accepts ValueParam, because it is also possible to get number of List elements. 35 // * 36 // */ 37 // public void get(Path path, ValueParam param, Future<Object> future); 39 38 40 39 public void get(Path path, Future<Path> future); … … 65 64 public Registry getRegistry(); 66 65 66 public void putSideNote(Object object, Object key, Object value); 67 68 public boolean removeSideNote(Object object, Object key); 69 70 public <T> T getSideNote(Object object, Object key, Class<T> valueType); 71 67 72 } -
java/main/src/main/java/com/framsticks/core/TreeOperations.java
r99 r100 8 8 import javax.annotation.Nonnull; 9 9 10 import org.apache.log4j.Logger; 10 import org.apache.logging.log4j.Logger; 11 import org.apache.logging.log4j.LogManager; 11 12 12 13 import com.framsticks.communication.File; 13 import com.framsticks.params.AccessInterface; 14 import com.framsticks.params.Access; 15 import com.framsticks.params.CompositeParam; 14 16 import com.framsticks.params.EventListener; 15 17 import com.framsticks.params.FramsClass; 16 18 import com.framsticks.params.ListAccess; 17 19 import com.framsticks.params.Param; 20 import com.framsticks.params.ParamBuilder; 18 21 import com.framsticks.params.PrimitiveParam; 22 import com.framsticks.params.PropertiesAccess; 19 23 import com.framsticks.params.UniqueListAccess; 20 24 import com.framsticks.params.Util; … … 25 29 import com.framsticks.parsers.MultiParamLoader; 26 30 import com.framsticks.util.FramsticksException; 31 import com.framsticks.util.dispatching.Dispatching; 27 32 import com.framsticks.util.dispatching.Future; 28 33 import com.framsticks.util.dispatching.FutureHandler; … … 33 38 public final class TreeOperations { 34 39 35 private static final Logger log = Log ger.getLogger(TreeOperations.class);40 private static final Logger log = LogManager.getLogger(TreeOperations.class); 36 41 37 42 private TreeOperations() { 38 43 } 39 44 45 public static final Object FETCHED_MARK = new Object(); 46 40 47 public static @Nonnull FramsClass processFetchedInfo(Tree tree, File file) { 41 48 assert tree.isActive(); 42 49 FramsClass framsClass = Loaders.loadFramsClass(file.getContent()); 43 log.debug("process fetched info for " + tree + ": " +framsClass);50 log.debug("process fetched info for {}: {}", tree, framsClass); 44 51 tree.putInfoIntoCache(framsClass); 45 52 return framsClass; 46 53 } 47 54 48 public static void processFetchedValues(Path path, List<File> files) { 49 Tree tree = path.getTree(); 50 assert tree.isActive(); 55 public static Path create(Path path) { 56 assert !path.isResolved(); 57 58 Access access = path.getTree().prepareAccess(path.getTop().getParam()); 59 Object child = createAccessee(path.getTree(), access); 60 assert child != null; 61 if (path.size() == 1) { 62 path.getTree().assignRootObject(child); 63 } else { 64 Access parentAccess = bindAccess(path.getUnder()); 65 66 /** this special case is not very good - maybe hide it in createAccessee? */ 67 if (parentAccess instanceof UniqueListAccess) { 68 access.select(child); 69 access.set(((UniqueListAccess) parentAccess).getUidName(), path.getTop().getParam().getId()); 70 } 71 72 parentAccess.set(path.getTop().getParam(), child); 73 } 74 path = path.appendResolution(child); 75 return path; 76 } 77 78 public static void processFetchedValues(final Path path, final List<File> files, final Access access, final Future<Path> future) { 51 79 assert files.size() == 1; 52 80 assert path.isTheSame(files.get(0).getPath()); 53 81 54 if (!path.isResolved()) {55 AccessInterface access = tree.prepareAccess(path.getTop().getParam());56 Object child = access.createAccessee();57 assert child != null;58 if (path.size() == 1) {59 tree.assignRootObject(child);60 } else {61 bindAccess(path.getUnder()).set(path.getTop().getParam(), child);62 }63 path = path.appendResolution(child);64 }65 66 log.debug("process fetched values: " + path);67 Node node = path.getTop();68 MultiParamLoader loader = new MultiParamLoader();69 loader.setNewSource(files.get(0).getContent());70 loader.addBreakCondition(MultiParamLoader.Status.AfterObject);71 82 72 83 try { 73 if (node.getParam() instanceof ObjectParam) { 74 loader.addAccessInterface(bindAccess(node)); 75 loader.go(); 76 return; 77 } 78 79 ListAccess listAccess = (ListAccess) bindAccess(node); 80 81 Set<String> oldValuesIds = new HashSet<>(); 82 for (Param p : listAccess.getParams()) { 83 oldValuesIds.add(p.getId()); 84 } 85 86 // listAccess.clearValues(); 87 88 AccessInterface elementAccess = listAccess.getElementAccess(); 89 AccessInterface clonerInterface = elementAccess.cloneAccess(); 90 91 loader.addAccessInterface(elementAccess); 92 MultiParamLoader.Status status; 93 int number = 0; 94 while ((status = loader.go()) != MultiParamLoader.Status.Finished) { 95 if (status == MultiParamLoader.Status.AfterObject) { 96 AccessInterface accessInterface = loader.getLastAccessInterface(); 97 98 String id; 99 if (listAccess instanceof UniqueListAccess) { 100 id = ((UniqueListAccess) listAccess).computeIdentifierFor(accessInterface.getSelected()); 101 } else { 102 id = Integer.toString(number); 103 } 104 ++number; 105 106 Object childTo = listAccess.get(id, Object.class); 107 boolean newOne; 108 if (childTo == null) { 109 childTo = clonerInterface.createAccessee(); 110 newOne = true; 111 } else { 112 assert oldValuesIds.contains(id); 113 newOne = false; 114 } 115 oldValuesIds.remove(id); 116 clonerInterface.select(childTo); 117 Util.takeAllNonNullValues(clonerInterface, accessInterface); 118 if (newOne) { 119 listAccess.set(id, childTo); 120 } 121 122 // listAccess.set(id, accessInterface.getSelected()); 123 accessInterface.select(null); 124 84 log.debug("process fetched values: {}", path); 85 final Access parsingAccess = new PropertiesAccess(access.getFramsClass()); 86 final List<Object> results = MultiParamLoader.loadAll(files.get(0).getContent(), parsingAccess); 87 88 Dispatching.dispatchIfNotActive(path.getTree(), new RunAt<Tree>(future) { 89 @Override 90 protected void runAt() { 91 92 Path result = path.tryResolveIfNeeded(); 93 94 if (!result.isResolved()) { 95 result = create(result); 96 } 97 98 if (path.getTop().getParam() instanceof ObjectParam) { 99 assert results.size() == 1; 100 Util.takeAllNonNullValues(bindAccess(result), parsingAccess.select(results.get(0))); 101 mark(result.getTree(), result.getTopObject(), FETCHED_MARK, true); 102 future.pass(result); 103 return; 104 } 105 106 107 final ListAccess listAccess = (ListAccess) access; 108 109 listAccess.select(result.getTopObject()); 110 Set<String> oldValuesIds = new HashSet<>(); 111 for (Param p : listAccess.getParams()) { 112 oldValuesIds.add(p.getId()); 113 } 114 115 Access targetAccess = listAccess.getElementAccess();//.cloneAccess(); 116 117 int number = 0; 118 for (Object r : results) { 119 120 parsingAccess.select(r); 121 String id; 122 if (listAccess instanceof UniqueListAccess) { 123 id = parsingAccess.get(((UniqueListAccess) listAccess).getUidName(), String.class); 124 } else { 125 id = Integer.toString(number); 126 } 127 ++number; 128 129 Object childTo = listAccess.get(id, Object.class); 130 boolean newOne; 131 if (childTo == null) { 132 childTo = createAccessee(result.getTree(), targetAccess); 133 newOne = true; 134 } else { 135 assert oldValuesIds.contains(id); 136 newOne = false; 137 } 138 oldValuesIds.remove(id); 139 140 targetAccess.select(childTo); 141 Util.takeAllNonNullValues(targetAccess, parsingAccess); 142 if (newOne) { 143 listAccess.set(id, childTo); 144 } 145 mark(result.getTree(), childTo, FETCHED_MARK, true); 146 147 } 148 mark(result.getTree(), result.getTopObject(), FETCHED_MARK, true); 149 150 /** It looks tricky for ArrayListAccess but should also work. 151 * 152 * They should be sorted. 153 */ 154 for (String id : oldValuesIds) { 155 listAccess.set(id, null); 156 } 157 future.pass(result); 125 158 } 126 } 127 /** It looks tricky for ArrayListAccess but should also work. 128 * 129 * They should be sorted. 130 */ 131 for (String id : oldValuesIds) { 132 listAccess.set(id, null); 133 } 159 }); 134 160 135 161 } catch (FramsticksException e) { … … 141 167 Tree tree = path.getTree(); 142 168 assert tree.isActive(); 143 log.debug("get info for: " +path);169 log.debug("get info for: {}", path); 144 170 final String name = path.getTop().getParam().getContainedTypeName(); 145 171 return tree.getInfoFromCache(name); … … 147 173 148 174 public static void findInfo(final Path path, final Future<FramsClass> future) { 149 log.debug("find info for: " +path);175 log.debug("find info for: {}", path); 150 176 try { 151 177 Tree tree = path.getTree(); … … 163 189 164 190 165 166 public static @Nonnull AccessInterface bindAccess(Tree tree, String path) { 167 log.debug("bind access for textual: " + path + " in " + tree); 191 public static @Nonnull Access bindAccessFromSideNote(Tree tree, Object object) { 192 CompositeParam param = tree.getSideNote(object, CompositeParam.class, CompositeParam.class); 193 if (param == null) { 194 throw new FramsticksException().msg("failed to bind access from side node").arg("tree", tree).arg("object", object).arg("type", object.getClass()); 195 } 196 return tree.prepareAccess(param).select(object); 197 } 198 199 public static @Nonnull Access bindAccess(Tree tree, String path) { 200 log.debug("bind access for textual: {} in {}", path, tree); 168 201 return bindAccess(Path.to(tree, path)); 169 202 } 170 203 171 public static @Nonnull Access InterfacebindAccess(Node node) {204 public static @Nonnull Access bindAccess(Node node) { 172 205 Tree tree = node.getTree(); 173 206 assert tree.isActive(); … … 175 208 176 209 try { 177 return tree.prepareAccess(node.getParam()).select(node.getObject()); 210 Access access = tree.prepareAccess(node.getParam()); 211 tree.putSideNote(node.getObject(), CompositeParam.class, node.getParam()); 212 213 return access.select(node.getObject()); 178 214 } catch (FramsticksException e) { 179 215 throw new FramsticksException().msg("failed to prepare access for param").arg("param", node.getParam()).cause(e); 180 // log.error("failed to bind access for " + node.getParam() + ": " +e);181 } 182 } 183 184 public static @Nonnull Access InterfacebindAccess(Path path) {216 // log.error("failed to bind access for {}: ", node.getParam(), e); 217 } 218 } 219 220 public static @Nonnull Access bindAccess(Path path) { 185 221 assert path.getTree().isActive(); 186 222 path.assureResolved(); 187 log.debug("bind access for: " +path);223 log.debug("bind access for: {}", path); 188 224 return bindAccess(path.getTop()); 189 225 } … … 196 232 protected void runAt() { 197 233 tree.set(path, param, value, future); 234 } 235 }); 236 } 237 238 public static void call(final Path path, final String procedureName, final Object[] arguments, final Future<Object> future) { 239 final Tree tree = path.getTree(); 240 241 dispatchIfNotActive(tree, new RunAt<Tree>(future) { 242 @Override 243 protected void runAt() { 244 path.assureResolved(); 245 tree.call(path, tree.getRegistry().getFramsClass(path.getTop().getParam()).getParamEntry(procedureName, ProcedureParam.class), arguments, future); 198 246 } 199 247 }); … … 241 289 * */ 242 290 public static void tryGet(final Tree tree, final String targetPath, final Future<Path> future) { 243 log.debug("resolve textual: " + targetPath + " for " +tree);291 log.debug("resolve textual: {} for {}", targetPath, tree); 244 292 dispatchIfNotActive(tree, new RunAt<Tree>(future) { 245 293 … … 247 295 protected void runAt() { 248 296 final Path path = Path.tryTo(tree, targetPath).tryResolveIfNeeded(); 249 log.debug("found: " +path);297 log.debug("found: {}", path); 250 298 if (path.isResolved()) { 251 299 future.pass(path); … … 257 305 protected void result(Path result) { 258 306 // if (result.isResolved(targetPath)) { 259 // 260 // 307 // future.pass(result); 308 // return; 261 309 // } 262 log.debug("retrying resolve textual: " + targetPath + " for " + tree + " with " +result);310 log.debug("retrying resolve textual: {} for {} with {}", targetPath, tree, result); 263 311 tryGet(tree, targetPath, future); 264 312 } … … 273 321 } 274 322 323 public static Object createAccessee(Tree tree, CompositeParam param) { 324 Object object = tree.prepareAccess(param).createAccessee(); 325 tree.putSideNote(object, CompositeParam.class, param); 326 return object; 327 } 328 329 public static Object createAccessee(Tree tree, Access access) { 330 Object object = access.createAccessee(); 331 tree.putSideNote(object, CompositeParam.class, access.buildParam(new ParamBuilder()).finish(CompositeParam.class)); 332 return object; 333 } 334 335 public static boolean isMarked(Tree tree, Object object, Object mark, boolean defValue) { 336 assert tree.isActive(); 337 Boolean v = tree.getSideNote(object, mark, Boolean.class); 338 return (v != null ? v : defValue); 339 } 340 341 public static void mark(Tree tree, Object object, Object mark, boolean value) { 342 assert tree.isActive(); 343 tree.putSideNote(object, mark, value); 344 } 345 346 public static FramsClass getFramsClass(Path path) { 347 return path.getTree().getRegistry().getFramsClass(path.getTop().getParam()); 348 } 349 275 350 } -
java/main/src/main/java/com/framsticks/diagnostics/Diagnostics.java
r98 r100 40 40 // @Override 41 41 // public void handle(FramsticksException exception) { 42 // log.error("caught error during diagnostics fetching (repeating): " +exception);42 // log.error("caught error during diagnostics fetching (repeating): {}", exception); 43 43 // again(); 44 44 // } -
java/main/src/main/java/com/framsticks/dumping/LoadStream.java
r98 r100 10 10 import com.framsticks.util.lang.Pair; 11 11 import com.framsticks.util.lang.Strings; 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import java.io.BufferedReader; … … 22 23 public class LoadStream extends Stream { 23 24 24 private final static Logger log = Log ger.getLogger(LoadStream.class.getName());25 private final static Logger log = LogManager.getLogger(LoadStream.class.getName()); 25 26 26 27 protected final Tree tree; … … 49 50 query = Strings.splitIntoPair(line, ' ', ""); 50 51 files = new LinkedList<File>(); 51 log.trace("loading " +line);52 log.trace("loading {}", line); 52 53 continue; 53 54 } … … 84 85 } 85 86 } catch (IOException e) { 86 log.error("failed to load: " +e);87 log.error("failed to load: {}", e); 87 88 future.handle(new FramsticksException().msg("failed to load stream").cause(e)); 88 89 return; 89 90 } 90 log.info("loaded in: " +stopwatch);91 log.info("loaded in: {}", stopwatch); 91 92 future.pass(Path.to(tree, mountPath.getTextual())); 92 93 } -
java/main/src/main/java/com/framsticks/dumping/SaveStream.java
r98 r100 4 4 import com.framsticks.core.Node; 5 5 import com.framsticks.core.Path; 6 import com.framsticks.params.Access Interface;6 import com.framsticks.params.Access; 7 7 import com.framsticks.params.CompositeParam; 8 8 import com.framsticks.params.FramsClass; … … 15 15 import com.framsticks.util.dispatching.Future; 16 16 17 import org.apache.log4j.Logger; 17 import org.apache.logging.log4j.Logger; 18 import org.apache.logging.log4j.LogManager; 18 19 import com.framsticks.util.dispatching.RunAt; 19 20 … … 27 28 public class SaveStream extends Stream { 28 29 29 private final static Logger log = Log ger.getLogger(SaveStream.class.getName());30 private final static Logger log = LogManager.getLogger(SaveStream.class.getName()); 30 31 31 32 protected final SinkInterface sink; … … 57 58 protected void finished() { 58 59 assert tree.isActive(); 59 log.info("stored in " +stopwatch);60 log.info("stored in {}", stopwatch); 60 61 future.pass(null); 61 62 } … … 64 65 assert tree.isActive(); 65 66 if (!path.isResolved()) { 66 log.debug("path " + path + " is not resolved - skipping");67 log.debug("path {} is not resolved - skipping", path); 67 68 } else { 68 Access Interfaceaccess = bindAccess(path);69 Access access = bindAccess(path); 69 70 assert access != null; 70 71 FramsClass framsClass = access.getFramsClass(); -
java/main/src/main/java/com/framsticks/gui/Browser.java
r99 r100 23 23 import javax.swing.*; 24 24 25 import org.apache.log4j.Logger; 25 import org.apache.logging.log4j.Logger; 26 import org.apache.logging.log4j.LogManager; 26 27 27 28 import java.awt.Dimension; … … 40 41 public class Browser extends AbstractJoinable implements Dispatcher<Browser>, JoinableParent, ExceptionResultHandler { 41 42 42 private static final Logger log = Log ger.getLogger(Browser.class);43 private static final Logger log = LogManager.getLogger(Browser.class); 43 44 44 45 protected final JoinableCollection<Frame> frames = new JoinableCollection<Frame>().setObservableName("frames"); … … 117 118 @AutoAppendAnnotation 118 119 public void addPanelProvider(PanelProvider panelProvider) { 119 log.debug("added panel provider of type: " +panelProvider.getClass().getCanonicalName());120 log.debug("added panel provider of type: {}", panelProvider.getClass().getCanonicalName()); 120 121 panelProviders.add(panelProvider); 121 122 } … … 133 134 @AutoAppendAnnotation 134 135 public void addTree(Tree tree) { 135 log.debug("adding tree: " +tree);136 log.debug("adding tree: {}", tree); 136 137 tree.setDispatcher(new SwingDispatcher<Tree>()); 138 tree.setExceptionHandler(this); 137 139 trees.add(tree); 138 140 } -
java/main/src/main/java/com/framsticks/gui/EmptyPanel.java
r84 r100 1 1 package com.framsticks.gui; 2 2 3 import com.framsticks. params.AccessInterface;3 import com.framsticks.gui.tree.AbstractNode; 4 4 5 5 /** … … 7 7 */ 8 8 @SuppressWarnings("serial") 9 public class EmptyPanel extends Panel {9 public class EmptyPanel extends AbstractPanel { 10 10 11 public EmptyPanel(Parameters parameters) { 12 super(parameters); 13 } 14 15 @Override 16 public void pullValuesFromLocalToUser(AccessInterface access) { 11 public EmptyPanel(Frame frame) { 12 super(frame); 17 13 } 18 14 … … 21 17 return "Empty"; 22 18 } 19 20 @Override 21 public void fillPanelWith(AbstractNode node) { 22 23 } 23 24 } -
java/main/src/main/java/com/framsticks/gui/Frame.java
r99 r100 36 36 import javax.swing.tree.TreeSelectionModel; 37 37 38 import org.apache.log4j.Logger; 38 import org.apache.logging.log4j.Logger; 39 import org.apache.logging.log4j.LogManager; 39 40 40 41 import com.framsticks.core.Path; 41 42 import com.framsticks.core.Tree; 43 import com.framsticks.gui.tree.AbstractNode; 42 44 import com.framsticks.gui.tree.MetaNode; 43 45 import com.framsticks.gui.tree.TreeCellRenderer; … … 50 52 import com.framsticks.util.dispatching.JoinableParent; 51 53 import com.framsticks.util.dispatching.JoinableState; 54 import com.framsticks.util.lang.Casting; 52 55 import com.framsticks.util.swing.KeyboardModifier; 53 56 import com.framsticks.util.swing.MenuConstructor; … … 59 62 public class Frame extends FrameJoinable implements JoinableParent { 60 63 61 private static final Logger log = Log ger.getLogger(Frame.class.getName());64 private static final Logger log = LogManager.getLogger(Frame.class.getName()); 62 65 63 66 protected final Browser browser; … … 89 92 protected JMenu windowMenu; 90 93 protected JMenu helpMenu; 94 protected EmptyPanel emptyPanel; 91 95 92 96 protected final Map<Tree, TreeAtFrame> treeAtFrames = new IdentityHashMap<>(); … … 103 107 * nor it can be removed in normal way through JSlider methods */ 104 108 UIManager.put("Slider.paintValue", false); 105 log.debug("creating " + this); 109 log.debug("creating {}", this); 110 111 cardPanel = new JPanel(); 112 cardPanel.setName("card"); 113 114 cardPanelLayout = new CardLayout(); 115 cardPanel.setLayout(cardPanelLayout); 116 117 emptyPanel = new EmptyPanel(this); 106 118 107 119 Container contentPane = getSwing().getContentPane(); … … 112 124 treePanel.setLayout(new BorderLayout()); 113 125 114 rootNode = new MetaNode( );126 rootNode = new MetaNode(this); 115 127 rootNode.setName("root"); 116 128 treeModel = new TreeModel(this); … … 139 151 @Override 140 152 public void treeExpanded(TreeExpansionEvent e) { 141 // loadChildren(treeModel.convertToPath(e.getPath()), false);153 treeModel.expandTreeNode(e.getPath()); 142 154 } 143 155 }); … … 169 181 .join(KeyStroke.getKeyStroke('l'), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)); 170 182 171 jtree.setCellRenderer(new TreeCellRenderer( ));183 jtree.setCellRenderer(new TreeCellRenderer(treeModel)); 172 184 173 185 treeScrollPane = new JScrollPane(jtree); … … 209 221 leftPanel.setForeground(Color.WHITE); 210 222 211 cardPanel = new JPanel();212 cardPanel.setName("card");213 223 JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, cardPanel); 214 224 split.setPreferredSize(browser.defaultFrameDimension); … … 224 234 mainPanelLayout.show(mainPanel, "browser"); 225 235 226 cardPanelLayout = new CardLayout();227 cardPanel.setLayout(cardPanelLayout);228 236 229 237 getSwing().pack(); 230 238 jtree.requestFocusInWindow(); 231 239 232 log.debug("frame configured: " +this);240 log.debug("frame configured: {}", this); 233 241 234 242 new MenuConstructor(fileMenu).add(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK), new AbstractAction("Close") { … … 258 266 Tree tree = path.getTree(); 259 267 260 log.debug("trying mount: " +path);268 log.debug("trying mount: {}", path); 261 269 if (!tree.getAssignedRoot().isResolved()) { 262 270 tree.get(path, new FutureHandler<Path>(this) { … … 274 282 TreeAtFrame e = new TreeAtFrame(tree, this); 275 283 treeAtFrames.put(tree, e); 276 277 rootNode.getChildren().add(new TreeNode(e, Path.to(tree, "/"))); 284 Path rootPath = Path.to(tree, "/"); 285 286 rootNode.getChildren().add(new TreeNode(e, rootPath)); 278 287 e.rootNode = tree.getAssignedRoot(); 279 treeModel. nodeStructureChanged(new TreePath(rootNode));288 treeModel.treeStructureChanged(new TreePath(rootNode)); 280 289 // jtree.expandPath(new TreePath(rootNode)); 281 290 } 282 291 283 292 284 public void showPanel( Panel panel) {293 public void showPanel(AbstractPanel panel) { 285 294 assert isActive(); 286 295 assert panel != null; 296 log.debug("showing panel: {}", panel); 287 297 cardPanelLayout.show(cardPanel, panel.getUniqueName()); 298 299 // cardPanel.revalidate(); 288 300 } 289 301 … … 297 309 298 310 Path path = treeModel.convertToPath(treePath); 311 if (path == null) { 312 return; 313 } 299 314 treePopupMenu.removeAll(); 300 315 … … 311 326 } 312 327 313 public void updatePanelIfIsLeadSelection( TreePath treePath,Path path) {328 public void updatePanelIfIsLeadSelection(Path path) { 314 329 assert isActive(); 330 TreePath treePath = treeModel.convertToTreePath(path, true); 331 if (treePath == null) { 332 return; 333 } 315 334 if (treePath.equals(jtree.getSelectionPath())) { 316 treeAtFrames.get(path.getTree()).useOrCreatePanel(treePath); 317 } 335 log.debug("updating: {} -> {}", treePath, path); 336 showPanelForTreePath(treePath); 337 } 338 } 339 340 public void showPanelForTreePath(TreePath treePath) { 341 assert isActive(); 342 AbstractNode node = Casting.assertCast(AbstractNode.class, treePath.getLastPathComponent()); 343 344 AbstractPanel panel = node.getPanel(); 345 if (panel == null) { 346 log.error("no panel for {} found", treePath); 347 return; 348 } 349 panel.fillPanelWith(node); 350 showPanel(panel); 351 // cardPanel.revalidate(); 318 352 } 319 353 … … 323 357 // assert isActive(); 324 358 // final TreePath treePath = treeModel.convertToTreePath(path); 325 // log.info("go to path: " + path + "(" + treePath + ")");326 359 327 360 // this.dispatch(new RunAt<Frame>(this) { … … 394 427 395 428 /** 429 * @return the emptyPanel 430 */ 431 public EmptyPanel getEmptyPanel() { 432 return emptyPanel; 433 } 434 435 /** 396 436 * @return the treeAtFrames 397 437 */ -
java/main/src/main/java/com/framsticks/gui/FrameJoinable.java
r97 r100 10 10 import javax.swing.UIManager; 11 11 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import com.framsticks.util.FramsticksException; … … 19 20 public abstract class FrameJoinable extends SwingJoinable<JFrame> implements ExceptionResultHandler { 20 21 private static final Logger log = 21 Log ger.getLogger(FrameJoinable.class);22 LogManager.getLogger(FrameJoinable.class); 22 23 23 24 protected String title; … … 65 66 boolean found = false; 66 67 // for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { 67 // log.info("look and feel available: " +info.getName());68 // log.info("look and feel available: {}", info.getName()); 68 69 // if ("Nimbus".equals(info.getName())) { 69 70 // UIManager.setLookAndFeel(info.getClassName()); … … 109 110 protected void joinableFinish() { 110 111 super.joinableFinish(); 111 log.debug("disposing frame " +this);112 log.debug("disposing frame {}", this); 112 113 getSwing().dispose(); 113 114 } -
java/main/src/main/java/com/framsticks/gui/Gui.java
r99 r100 10 10 import javax.swing.JPanel; 11 11 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import com.framsticks.gui.controls.CheckBoxControl; … … 39 40 public final class Gui { 40 41 41 private static final Logger log = Log ger.getLogger(Gui.class.getName());42 private static final Logger log = LogManager.getLogger(Gui.class.getName()); 42 43 43 44 private Gui() { … … 117 118 control.setOwner(owner); 118 119 119 log.debug("add component for " +param);120 log.debug("add component for {}", param); 120 121 JPanel line = new JPanel(); 121 122 line.setLayout(new BoxLayout(line, BoxLayout.LINE_AXIS)); -
java/main/src/main/java/com/framsticks/gui/ImageProvider.java
r98 r100 4 4 package com.framsticks.gui; 5 5 6 import org.apache.log4j.Logger; 6 import org.apache.logging.log4j.Logger; 7 import org.apache.logging.log4j.LogManager; 7 8 8 9 import javax.swing.*; … … 16 17 public class ImageProvider { 17 18 18 private final static Logger log = Log ger.getLogger(ImageProvider.class.getName());19 private final static Logger log = LogManager.getLogger(ImageProvider.class.getName()); 19 20 20 21 … … 87 88 return icon; 88 89 } catch (Exception ignored) { 89 log.error("failed to read icon: " +resourceName);90 log.error("failed to read icon: {}", resourceName); 90 91 } 91 92 return null; -
java/main/src/main/java/com/framsticks/gui/MainFrame.java
r97 r100 11 11 import javax.swing.WindowConstants; 12 12 13 import org.apache.log4j.Logger; 13 import org.apache.logging.log4j.Logger; 14 import org.apache.logging.log4j.LogManager; 14 15 15 16 import com.framsticks.util.swing.MenuConstructor; … … 21 22 public class MainFrame extends Frame { 22 23 23 private final static Logger log = Log ger.getLogger(MainFrame.class.getName());24 private final static Logger log = LogManager.getLogger(MainFrame.class.getName()); 24 25 25 26 JButton start, stop, step; … … 127 128 // // public void call(Exception e) { 128 129 // // if (e != null) { 129 // // log.error("failed to resolve: " +s);130 // // log.error("failed to resolve: {}", s); 130 131 // // return; 131 132 // // } 132 // // log.info("succeeded to resolve: " +s);133 // // log.info("succeeded to resolve: {}", s); 133 134 // // } 134 135 // // }); -
java/main/src/main/java/com/framsticks/gui/ModifiablePanel.java
r99 r100 1 1 package com.framsticks.gui; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 … … 13 14 */ 14 15 @SuppressWarnings("serial") 15 public abstract class ModifiablePanel extends Panel {16 public abstract class ModifiablePanel extends TreePanel { 16 17 17 private static final Logger log = Log ger.getLogger(ModifiablePanel.class.getName());18 private static final Logger log = LogManager.getLogger(ModifiablePanel.class.getName()); 18 19 19 20 /** … … 27 28 protected Component contentComponent; 28 29 29 public ModifiablePanel( Panel.Parameters parameters) {30 public ModifiablePanel(TreePanel.Parameters parameters) { 30 31 super(parameters); 31 log.debug("create panel for type: " +className);32 log.debug("create panel for type: {}", className); 32 33 33 34 -
java/main/src/main/java/com/framsticks/gui/MultiPanel.java
r98 r100 1 1 package com.framsticks.gui; 2 2 3 import com.framsticks.params.AccessInterface; 3 import com.framsticks.core.Path; 4 import com.framsticks.params.Access; 4 5 5 6 import javax.swing.*; 6 import javax.swing.tree.TreePath;7 7 8 8 import java.awt.*; … … 13 13 */ 14 14 @SuppressWarnings("serial") 15 public class MultiPanel extends Panel {15 public class MultiPanel extends TreePanel { 16 16 17 protected final List< Panel> panels;17 protected final List<TreePanel> panels; 18 18 protected final JTabbedPane tabbedPane; 19 19 20 20 21 public MultiPanel( Panel.Parameters parameters, List<Panel> panels) {21 public MultiPanel(TreePanel.Parameters parameters, List<TreePanel> panels) { 22 22 super(parameters); 23 23 this.panels = panels; 24 24 tabbedPane = new JTabbedPane(); 25 25 26 for ( Panel p : panels) {26 for (TreePanel p : panels) { 27 27 assert p.getClassName().equals(getClassName()); 28 28 assert p.getTreeAtFrame() == getTreeAtFrame(); … … 36 36 37 37 @Override 38 public void pullValuesFromLocalToUser(Access Interfaceaccess) {39 for ( Panel p : panels) {38 public void pullValuesFromLocalToUser(Access access) { 39 for (TreePanel p : panels) { 40 40 p.pullValuesFromLocalToUser(access); 41 41 } … … 48 48 49 49 @Override 50 public void setCurrent TreePath(TreePath currentTreePath) {51 super.setCurrent TreePath(currentTreePath);52 for ( Panel p : panels) {53 p.setCurrent TreePath(currentTreePath);50 public void setCurrentPath(Path currentPath) { 51 super.setCurrentPath(currentPath); 52 for (TreePanel p : panels) { 53 p.setCurrentPath(currentPath); 54 54 } 55 55 } -
java/main/src/main/java/com/framsticks/gui/NodeAtFrame.java
r98 r100 8 8 public class NodeAtFrame { 9 9 10 protected Panel panel;11 12 10 protected final Map<ValueControl, Object> localChanges = new IdentityHashMap<>(); 13 11 12 /** 13 * 14 */ 15 public NodeAtFrame() { 16 } 17 14 18 } -
java/main/src/main/java/com/framsticks/gui/ObjectPanel.java
r99 r100 1 1 package com.framsticks.gui; 2 2 3 import com.framsticks.core.Path; 3 4 import com.framsticks.gui.controls.Control; 4 5 import com.framsticks.gui.controls.ControlOwner; 5 6 import com.framsticks.gui.controls.ValueControl; 6 7 import com.framsticks.gui.controls.ValueControlListener; 7 import com.framsticks.params.Access Interface;8 import com.framsticks.params.Access; 8 9 import com.framsticks.params.Param; 9 10 import com.framsticks.params.ValueParam; 10 11 11 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 12 14 13 15 import javax.swing.*; 14 import javax.swing.tree.TreePath;15 16 16 17 import java.util.Collection; … … 24 25 public class ObjectPanel extends ModifiablePanel implements ControlOwner { 25 26 26 private static final Logger log = Log ger.getLogger(ObjectPanel.class);27 private static final Logger log = LogManager.getLogger(ObjectPanel.class); 27 28 28 29 final protected Map<Param, Control> components = new IdentityHashMap<Param, Control>(); … … 32 33 protected final JScrollPane scrollPane; 33 34 34 public ObjectPanel( Panel.Parameters parameters, Collection<Param> params) {35 public ObjectPanel(TreePanel.Parameters parameters, Collection<Param> params) { 35 36 super(parameters); 36 37 … … 49 50 @Override 50 51 public boolean onChange(Object newValue) { 51 if (current TreePath == null) {52 if (currentPath == null) { 52 53 return true; 53 54 } 54 boolean result = treeAtFrame.changeValue(current TreePath, c, newValue);55 boolean result = treeAtFrame.changeValue(currentPath.assureResolved().getTopObject(), c, newValue); 55 56 refreshControlButtons(); 56 57 return result; … … 66 67 protected void applyChanges() { 67 68 assert frame.isActive(); 68 assert current TreePath != null;69 treeAtFrame.pushLocalChanges(current TreePath);69 assert currentPath != null; 70 treeAtFrame.pushLocalChanges(currentPath); 70 71 } 71 72 72 73 protected void refreshControlButtons() { 73 74 assert frame.isActive(); 74 applyButton.setEnabled(treeAtFrame.hasLocalChanges(currentTreePath)); 75 } 76 77 protected static void fillControlsWithValues(Map<ValueControl, Object> map) { 75 applyButton.setEnabled(treeAtFrame.hasLocalChanges(currentPath.getTopObject())); 78 76 } 79 77 80 78 @Override 81 public void pullValuesFromLocalToUser(Access Interfaceaccess) {82 assert current TreePath != null;79 public void pullValuesFromLocalToUser(Access access) { 80 assert currentPath != null; 83 81 log.debug("refreshing components"); 84 82 … … 89 87 90 88 91 NodeAtFrame nodeAtFrame = treeAtFrame.getLocalInfo(current TreePath);89 NodeAtFrame nodeAtFrame = treeAtFrame.getLocalInfo(currentPath.getTopObject()); 92 90 if (nodeAtFrame != null) { 93 91 for (Map.Entry<ValueControl, Object> e : nodeAtFrame.localChanges.entrySet()) { … … 120 118 121 119 @Override 122 public TreePath getCurrentTreePath() {123 return super.getCurrent TreePath();120 public Path getCurrentPath() { 121 return super.getCurrentPath(); 124 122 } 125 123 126 127 124 } -
java/main/src/main/java/com/framsticks/gui/PanelProvider.java
r84 r100 6 6 */ 7 7 public interface PanelProvider { 8 public Panel providePanel(Panel.Parameters parameters);8 public TreePanel providePanel(TreePanel.Parameters parameters); 9 9 } -
java/main/src/main/java/com/framsticks/gui/StandardPanelProvider.java
r88 r100 17 17 @SuppressWarnings("unchecked") 18 18 @Override 19 public Panel providePanel(Panel.Parameters parameters) {19 public TreePanel providePanel(TreePanel.Parameters parameters) { 20 20 if (parameters.param instanceof ObjectParam) { 21 21 return new ObjectPanel(parameters, CollectionUtils.select(parameters.framsClass.getParamEntries(), new NotPredicate(new InstanceofPredicate(CompositeParam.class)))); -
java/main/src/main/java/com/framsticks/gui/StatusBar.java
r98 r100 9 9 import javax.swing.JTextField; 10 10 11 import org.apache.log4j.Logger; 11 import org.apache.logging.log4j.Logger; 12 import org.apache.logging.log4j.LogManager; 12 13 13 14 import com.framsticks.gui.controls.Control; … … 18 19 19 20 public class StatusBar implements ExceptionResultHandler, Dispatcher<StatusBar> { 20 private static final Logger log = Log ger.getLogger(StatusBar.class);21 private static final Logger log = LogManager.getLogger(StatusBar.class); 21 22 22 23 protected JTextField statusBar; … … 36 37 @Override 37 38 protected void runAt() { 38 log.error("error: ", exception);39 log.error("error: {}", exception.getMessage()); 39 40 statusBar.setText(exception.getShortMessage(new StringBuilder()).toString()); 40 41 if (exceptionHandler != null) { -
java/main/src/main/java/com/framsticks/gui/TreeAtFrame.java
r99 r100 1 1 package com.framsticks.gui; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.core.Tree; … … 8 9 import com.framsticks.core.TreeOperations; 9 10 import com.framsticks.gui.controls.ValueControl; 10 import com.framsticks.gui.tree.TreeNode;11 11 import com.framsticks.params.CompositeParam; 12 12 import com.framsticks.params.FramsClass; … … 14 14 import java.util.*; 15 15 16 import javax.swing.tree.TreePath;17 16 18 17 19 18 import com.framsticks.util.dispatching.FutureHandler; 20 import com.framsticks.util.lang.Casting;21 19 22 20 /** … … 25 23 public class TreeAtFrame { 26 24 27 private static final Logger log = Log ger.getLogger(TreeAtFrame.class);25 private static final Logger log = LogManager.getLogger(TreeAtFrame.class); 28 26 29 27 protected final Frame frame; 30 28 protected final Tree tree; 31 protected final Map<String, Panel> knownPanels = new HashMap<String, Panel>();29 protected final Map<String, TreePanel> knownPanels = new HashMap<>(); 32 30 protected Node rootNode; 33 34 protected Map<TreeNode, NodeAtFrame> nodesStorage = new WeakHashMap<>();35 31 36 32 public TreeAtFrame(Tree tree, Frame frame) { … … 50 46 } 51 47 52 public void registerPanel(Panel panel) {53 }54 55 public Panel findPanel(String accessId) {56 assert frame.isActive();57 return (knownPanels.containsKey(accessId) ? knownPanels.get(accessId) : null);58 }59 60 48 public final String getName() { 61 49 return tree.getName(); 62 50 } 63 51 64 public Panel preparePanel(CompositeParam param, FramsClass framsClass) {52 public TreePanel preparePanel(final CompositeParam param) { 65 53 assert frame.isActive(); 66 Panel panel = preparePanelImpl(param, framsClass);67 assert panel != null;68 String accessId = param.computeAccessId();69 panel.uniqueName = accessId + "@" + tree.getName();70 knownPanels.put(accessId, panel);71 frame.cardPanel.add(panel, panel.uniqueName);72 log.debug("prepared panel for " + panel);73 return panel;74 }75 54 76 protected Panel preparePanelImpl(CompositeParam param, FramsClass framsClass) { 77 assert frame.isActive(); 78 List<Panel> panels = new ArrayList<Panel>(); 55 TreePanel panel = knownPanels.get(param.getFramsTypeName()); 56 if (panel != null) { 57 return panel; 58 } 79 59 80 Panel.Parameters parameters = new Panel.Parameters(this, param, framsClass); 60 final FramsClass framsClass = tree.getInfoFromCache(param.getContainedTypeName()); 61 final List<TreePanel> panels = new ArrayList<TreePanel>(); 62 63 final TreePanel.Parameters parameters = new TreePanel.Parameters(this, param, framsClass); 81 64 for (PanelProvider pp : frame.browser.panelProviders) { 82 Panel p = pp.providePanel(parameters);65 TreePanel p = pp.providePanel(parameters); 83 66 if (p != null) { 84 67 panels.add(p); … … 87 70 88 71 if (panels.isEmpty()) { 89 return new EmptyPanel(parameters); 72 panel = new EmptyTreePanel(parameters); 73 } else if (panels.size() == 1) { 74 panel = panels.get(0); 75 } else { 76 panel = new MultiPanel(parameters, panels); 90 77 } 91 if (panels.size() == 1) {92 return panels.get(0);93 }94 return new MultiPanel(parameters, panels);95 78 79 knownPanels.put(param.getFramsTypeName(), panel); 80 81 log.debug("prepared panel for {}", panel); 82 return panel; 96 83 } 97 84 98 public boolean hasLocalChanges(TreePath treePath) { 99 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent()); 85 86 public boolean hasLocalChanges(Object object) { 87 NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class); 100 88 if (nodeAtFrame == null) { 101 89 return false; … … 104 92 } 105 93 106 public NodeAtFrame assureLocalInfo( TreePath treePath) {94 public NodeAtFrame assureLocalInfo(Object object) { 107 95 assert frame.isActive(); 108 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent());96 NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class); 109 97 110 98 if (nodeAtFrame == null) { 111 99 nodeAtFrame = new NodeAtFrame(); 112 nodesStorage.put(Casting.throwCast(TreeNode.class, treePath.getLastPathComponent()), nodeAtFrame); 100 // log.debug(); 101 tree.putSideNote(object, this, nodeAtFrame); 113 102 } 114 103 return nodeAtFrame; 115 104 } 116 105 117 public NodeAtFrame getLocalInfo( TreePath treePath) {118 return nodesStorage.get(treePath.getLastPathComponent());106 public NodeAtFrame getLocalInfo(Object object) { 107 return tree.getSideNote(object, this, NodeAtFrame.class); 119 108 } 120 109 121 public boolean changeValue( TreePath treePath, ValueControl component, Object newValue) {122 log.debug("changing value of " + component + " to '" + newValue + "'");110 public boolean changeValue(Object object, ValueControl component, Object newValue) { 111 log.debug("changing value of {} to '{}'", component, newValue); 123 112 124 assureLocalInfo( treePath).localChanges.put(component, newValue);113 assureLocalInfo(object).localChanges.put(component, newValue); 125 114 126 115 return true; 127 116 } 128 117 129 public void pushLocalChanges( TreePath treePath) {118 public void pushLocalChanges(Path path) { 130 119 assert frame.isActive(); 120 path.assureResolved(); 131 121 132 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent());122 NodeAtFrame nodeAtFrame = getLocalInfo(path.getTopObject()); 133 123 if (nodeAtFrame == null) { 134 124 return; 135 125 } 136 Path path = frame.treeModel.convertToPath(treePath);137 138 126 for (Map.Entry<ValueControl, Object> e : nodeAtFrame.localChanges.entrySet()) { 139 127 TreeOperations.set(path, e.getKey().getParam(), e.getValue(), new FutureHandler<Integer>(frame) { … … 145 133 } 146 134 147 public void fillPanelWithValues(TreePath treePath) {148 NodeAtFrame nodeAtFrame = assureLocalInfo(treePath);149 if (nodeAtFrame == null) {150 return;151 }152 153 if (nodeAtFrame.panel == null) {154 return;155 }156 Node node = TreeNode.tryGetNode(treePath);157 if (node == null) {158 return;159 }160 nodeAtFrame.panel.setCurrentTreePath(treePath);161 nodeAtFrame.panel.pullValuesFromLocalToUser(TreeOperations.bindAccess(node));162 163 frame.showPanel(nodeAtFrame.panel);164 165 }166 167 public void useOrCreatePanel(TreePath treePath) {168 // node.assureResolved();169 Node node = TreeNode.tryGetNode(treePath);170 171 NodeAtFrame nodeAtFrame = assureLocalInfo(treePath);172 173 if (nodeAtFrame.panel == null) {174 CompositeParam param = node.getParam();175 nodeAtFrame.panel = findPanel(param.computeAccessId());176 if (nodeAtFrame.panel == null) {177 FramsClass framsClass = node.getTree().getInfoFromCache(param.getContainedTypeName());178 nodeAtFrame.panel = preparePanel(param, framsClass);179 }180 }181 fillPanelWithValues(treePath);182 }183 135 } -
java/main/src/main/java/com/framsticks/gui/console/Console.java
r97 r100 9 9 import javax.swing.JTextPane; 10 10 11 import org.apache.log4j.Logger; 11 import org.apache.logging.log4j.Logger; 12 import org.apache.logging.log4j.LogManager; 12 13 13 14 import com.framsticks.communication.Connection; … … 24 25 @FramsClassAnnotation 25 26 public abstract class Console extends FrameJoinable implements JoinableParent { 26 private static final Logger log = Log ger.getLogger(Console.class);27 private static final Logger log = LogManager.getLogger(Console.class); 27 28 28 29 /** -
java/main/src/main/java/com/framsticks/gui/console/ConsolePainter.java
r97 r100 3 3 import com.framsticks.communication.File; 4 4 import com.framsticks.util.FramsticksException; 5 // import org.apache.log 4j.Logger;5 // import org.apache.logging.log4j.Logger; 6 6 7 7 // import java.awt.Color; … … 16 16 */ 17 17 public class ConsolePainter { 18 // private static final Logger log = Log ger.getLogger(ConsolePainter.class.getName());18 // private static final Logger log = LogManager.getLogger(ConsolePainter.class.getName()); 19 19 20 20 private final Document doc; -
java/main/src/main/java/com/framsticks/gui/controls/CheckBoxControl.java
r98 r100 7 7 import javax.swing.JCheckBox; 8 8 9 import org.apache.log4j.Logger; 9 import org.apache.logging.log4j.Logger; 10 import org.apache.logging.log4j.LogManager; 10 11 11 12 import com.framsticks.params.types.BooleanParam; … … 14 15 public class CheckBoxControl extends ValueControl { 15 16 16 private static final Logger log = Log ger.getLogger(CheckBoxControl.class.getName());17 private static final Logger log = LogManager.getLogger(CheckBoxControl.class.getName()); 17 18 18 19 protected final JCheckBox checkBox; … … 25 26 @Override 26 27 public void actionPerformed(ActionEvent actionEvent) { 27 log.debug("change to: " +checkBox.isSelected());28 log.debug("change to: {}", checkBox.isSelected()); 28 29 notifyOfChange(); 29 30 } -
java/main/src/main/java/com/framsticks/gui/controls/Control.java
r99 r100 19 19 public static final int LINE_HEIGHT = 36; 20 20 21 // private static final Logger log = Log ger.getLogger(Control.class.getName());21 // private static final Logger log = LogManager.getLogger(Control.class.getName()); 22 22 23 23 protected final Param param; -
java/main/src/main/java/com/framsticks/gui/controls/ControlOwner.java
r99 r100 2 2 3 3 import javax.swing.JPanel; 4 import javax.swing.tree.TreePath;5 4 5 import com.framsticks.core.Path; 6 6 import com.framsticks.gui.Frame; 7 7 import com.framsticks.util.dispatching.ExceptionResultHandler; … … 10 10 11 11 public JPanel getPanelForControls(); 12 public TreePath getCurrentTreePath();12 public Path getCurrentPath(); 13 13 public Frame getFrame(); 14 14 -
java/main/src/main/java/com/framsticks/gui/controls/EnumControl.java
r98 r100 3 3 import com.framsticks.params.types.EnumParam; 4 4 import com.framsticks.util.lang.Numbers; 5 import org.apache.log4j.Logger; 5 import org.apache.logging.log4j.Logger; 6 import org.apache.logging.log4j.LogManager; 6 7 7 8 import javax.swing.*; … … 16 17 protected final JComboBox<String> list; 17 18 18 private static final Logger log = Log ger.getLogger(EnumControl.class.getName());19 private static final Logger log = LogManager.getLogger(EnumControl.class.getName()); 19 20 20 21 public EnumControl(EnumParam enumParam) { -
java/main/src/main/java/com/framsticks/gui/controls/EventControl.java
r98 r100 14 14 @SuppressWarnings("serial") 15 15 public class EventControl extends Control { 16 // private static final Logger log = Log ger.getLogger(EventControl.class.getName());16 // private static final Logger log = LogManager.getLogger(EventControl.class.getName()); 17 17 18 18 protected final JButton button; -
java/main/src/main/java/com/framsticks/gui/controls/ProcedureControl.java
r99 r100 1 1 package com.framsticks.gui.controls; 2 2 3 import com.framsticks.core.Tree;4 3 import com.framsticks.core.Path; 5 4 import com.framsticks.gui.Frame; … … 10 9 import com.framsticks.util.dispatching.ExceptionResultHandler; 11 10 import com.framsticks.util.dispatching.FutureHandler; 12 import com.framsticks.util.dispatching.RunAt;13 11 import com.framsticks.util.dispatching.ThrowExceptionHandler; 12 import com.framsticks.util.swing.TooltipConstructor; 14 13 15 14 import javax.swing.*; 16 15 import javax.swing.border.BevelBorder; 17 import javax.swing.tree.TreePath;18 16 19 import org.apache.log4j.Logger; 17 import org.apache.logging.log4j.Logger; 18 import org.apache.logging.log4j.LogManager; 20 19 21 20 import java.awt.event.ActionEvent; … … 29 28 public class ProcedureControl extends Control implements ControlOwner { 30 29 31 private static final Logger log = Log ger.getLogger(ProcedureControl.class);30 private static final Logger log = LogManager.getLogger(ProcedureControl.class); 32 31 33 32 protected final JButton procedureButton; … … 37 36 public ProcedureControl(ProcedureParam procedureParam) { 38 37 super(procedureParam); 38 39 this.setToolTipText(new TooltipConstructor() 40 .append("name", procedureParam.getName()) 41 .append("id", procedureParam.getId()) 42 .append("help", procedureParam.getHelp()) 43 .build()); 39 44 40 45 procedureButton = new JButton("Call"); … … 56 61 public void actionPerformed(ActionEvent e) { 57 62 58 final Path path = get Frame().getTreeModel().convertToPath(getCurrentTreePath());63 final Path path = getCurrentPath(); 59 64 60 65 final List<Object> arguments = new LinkedList<Object>(); … … 62 67 Object value = components.get(arg).getCurrentValue(); 63 68 arguments.add(value); 64 log.debug("argument " + arg + ": " +value);69 log.debug("argument {}: {}", arg, value); 65 70 } 66 71 //TODO FEH: make it show dialog 67 final ExceptionResultHandler handler = ThrowExceptionHandler.getInstance();72 callProcedure(path, getParam(), arguments.toArray()); 68 73 69 path.getTree().dispatch(new RunAt<Tree>(handler) {70 @Override71 protected void runAt() {72 path.getTree().call(path, getParam(), arguments.toArray(), new FutureHandler<Object>(handler) {73 74 @Override75 public void result(Object result) {76 77 }78 });79 }80 });81 74 } 82 75 }); 83 76 this.add(procedureButton); 84 77 78 } 79 80 public static void callProcedure(final Path path, final ProcedureParam param, Object[] arguments) { 81 final ExceptionResultHandler handler = ThrowExceptionHandler.getInstance(); 82 83 assert path.getTree().isActive(); 84 85 path.getTree().call(path, param, arguments, new FutureHandler<Object>(handler) { 86 87 @Override 88 public void result(Object result) { 89 90 } 91 }); 85 92 } 86 93 … … 109 116 110 117 @Override 111 public TreePath getCurrentTreePath() {112 return owner.getCurrent TreePath();118 public Path getCurrentPath() { 119 return owner.getCurrentPath(); 113 120 } 114 121 -
java/main/src/main/java/com/framsticks/gui/controls/SliderControl.java
r98 r100 15 15 import javax.swing.event.ChangeListener; 16 16 17 import org.apache.log4j.Logger; 17 import org.apache.logging.log4j.Logger; 18 import org.apache.logging.log4j.LogManager; 18 19 19 20 import com.framsticks.params.types.DecimalParam; … … 26 27 public class SliderControl extends TextControl { 27 28 28 private static final Logger log = Log ger.getLogger(SliderControl.class.getName());29 private static final Logger log = LogManager.getLogger(SliderControl.class.getName()); 29 30 30 31 protected final JSlider slider; … … 115 116 return; 116 117 } 117 log.trace("changing " + getParam() + " with slider: " +slider.getValue());118 log.trace("changing {} with slider: {}", getParam(), slider.getValue()); 118 119 changing = slider; 119 120 text.setText(convertFromSliderDomain(slider.getValue()).toString()); … … 128 129 return; 129 130 } 130 log.trace("changing " + getParam() + " with text: " +text.getText());131 log.trace("changing {} with text: {}", getParam(), text.getText()); 131 132 changing = text; 132 133 Integer i = convertToSliderDomain(convertTextToNumber()); -
java/main/src/main/java/com/framsticks/gui/controls/TextAreaControl.java
r98 r100 23 23 this.setLayout(new BorderLayout()); 24 24 this.add(textScrollPane, BorderLayout.CENTER); 25 this.setMaximumSize(new Dimension(Integer.MAX_VALUE, LINE_HEIGHT * 3)); 26 textArea.setMaximumSize(new Dimension(Integer.MAX_VALUE, LINE_HEIGHT * 3)); 25 int maxSize = LINE_HEIGHT * 10; 26 this.setMaximumSize(new Dimension(Integer.MAX_VALUE, maxSize)); 27 textArea.setMaximumSize(new Dimension(Integer.MAX_VALUE, maxSize)); 27 28 28 29 this.revalidate(); -
java/main/src/main/java/com/framsticks/gui/controls/ValueControl.java
r99 r100 1 1 package com.framsticks.gui.controls; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.params.CastFailure; … … 18 19 public abstract class ValueControl extends Control { 19 20 private static final Logger log = 20 Log ger.getLogger(ValueControl.class);21 LogManager.getLogger(ValueControl.class); 21 22 22 23 /** … … 72 73 ReassignResult<?> res = getParam().reassign(candidate, oldValue); 73 74 if (res.getFlags() != 0) { 74 log.warn("filter of param " + param + " failed: " +FlagsUtil.write(SetStateFlags.class, res.getFlags(), "0"));75 log.warn("filter of param {} failed: {}", param, FlagsUtil.write(SetStateFlags.class, res.getFlags(), "0")); 75 76 } 76 77 return res.getValue(); -
java/main/src/main/java/com/framsticks/gui/table/ListPanel.java
r99 r100 3 3 4 4 import com.framsticks.gui.ModifiablePanel; 5 import com.framsticks.params.Access Interface;5 import com.framsticks.params.Access; 6 6 import com.framsticks.params.ListAccess; 7 import com.framsticks.params.PrimitiveParam; 7 import com.framsticks.params.Param; 8 import com.framsticks.util.FramsticksException; 8 9 import com.framsticks.util.lang.Casting; 9 import com.framsticks.util.lang.Containers;10 10 11 import org.apache.log4j.Logger; 11 import org.apache.logging.log4j.Logger; 12 import org.apache.logging.log4j.LogManager; 12 13 13 14 import javax.swing.*; … … 19 20 public class ListPanel extends ModifiablePanel { 20 21 21 private static final Logger log = Log ger.getLogger(ListPanel.class.getName());22 private static final Logger log = LogManager.getLogger(ListPanel.class.getName()); 22 23 23 24 protected final TableModel tableModel; … … 29 30 30 31 final ColumnsConfig config = provider.getColumnsConfigs().get(framsClass.getName()); 31 log.debug("creating ListPanel for " + parameters.framsClass + " using config " +config);32 log.debug("creating ListPanel for {} using config {}", parameters.framsClass, config); 32 33 33 tableModel = new TableModel( );34 tableModel = new TableModel(this); 34 35 if (config != null) { 35 36 for (String id : config.getColumnsNames()) { 36 tableModel.addColumn(framsClass.getParamEntry(id, PrimitiveParam.class)); 37 Param param = framsClass.getParam(id); 38 if (param == null) { 39 throw new FramsticksException().msg("requested param not found in frams class").arg("param", id).arg("frams class", framsClass); 40 } 41 if (!tableModel.addColumnIfSupported(param)) { 42 throw new FramsticksException().msg("param is not supported in table view").arg("param", param).arg("frams class", framsClass); 43 } 37 44 } 38 45 } else { 39 for (P rimitiveParam<?> param : Containers.filterInstanceof(framsClass.getParamEntries(), PrimitiveParam.class)) {46 for (Param param : framsClass.getParamEntries()) { 40 47 if (provider.getMaximumColumnNumber() != null && tableModel.getColumnCount() >= provider.getMaximumColumnNumber()) { 41 48 break; 42 49 } 43 tableModel.addColumn (param);50 tableModel.addColumnIfSupported(param); 44 51 } 45 52 } 46 53 47 54 table = new JTable(tableModel); 55 tableModel.setupTable(); 56 48 57 scrollPane = new JScrollPane(table); 49 58 setupContentComponent(scrollPane); … … 63 72 64 73 @Override 65 public void pullValuesFromLocalToUser(Access Interfaceaccess) {74 public void pullValuesFromLocalToUser(Access access) { 66 75 tableModel.attachSource(Casting.throwCast(ListAccess.class, access)); 67 76 } … … 71 80 return "List"; 72 81 } 82 83 /** 84 * @return the table 85 */ 86 public JTable getTable() { 87 return table; 88 } 73 89 } -
java/main/src/main/java/com/framsticks/gui/table/ListPanelProvider.java
r99 r100 5 5 import java.util.Map; 6 6 7 import com.framsticks.gui.Panel;8 7 import com.framsticks.gui.PanelProvider; 8 import com.framsticks.gui.TreePanel; 9 9 import com.framsticks.params.annotations.AutoAppendAnnotation; 10 10 import com.framsticks.params.annotations.FramsClassAnnotation; … … 22 22 23 23 @Override 24 public Panel providePanel(Panel.Parameters parameters) {24 public TreePanel providePanel(TreePanel.Parameters parameters) { 25 25 if (parameters.param instanceof ListParam) { 26 26 return new ListPanel(parameters, this); -
java/main/src/main/java/com/framsticks/gui/table/TableModel.java
r99 r100 6 6 import java.util.List; 7 7 8 import javax.swing.JCheckBox; 9 import javax.swing.JComponent; 10 import javax.swing.JTable; 11 import javax.swing.UIManager; 8 12 import javax.swing.event.TableModelEvent; 9 13 import javax.swing.event.TableModelListener; 10 14 11 import org.apache.log4j.Logger; 15 import org.apache.logging.log4j.Logger; 16 import org.apache.logging.log4j.LogManager; 12 17 13 import com.framsticks.params.Access Interface;18 import com.framsticks.params.Access; 14 19 import com.framsticks.params.ListAccess; 20 import com.framsticks.params.Param; 15 21 import com.framsticks.params.PrimitiveParam; 16 import com.framsticks. util.UnsupportedOperationException;22 import com.framsticks.params.types.ProcedureParam; 17 23 import com.framsticks.util.lang.Casting; 18 24 19 25 public class TableModel implements javax.swing.table.TableModel { 20 private static final Logger log =21 Logger.getLogger(TableModel.class);22 26 27 private static final Logger log = LogManager.getLogger(TableModel.class); 23 28 24 29 protected List<TableModelListener> listeners = new LinkedList<>(); 25 30 protected ListAccess access; 26 protected AccessInterface elementAccess; 27 protected final List<PrimitiveParam<?>> columnParams = new ArrayList<>(); 31 protected Access elementAccess; 32 protected final List<Column> columns = new ArrayList<>(); 33 protected final ListPanel listPanel; 34 protected JTable table; 35 36 /** 37 * @param listPanel 38 */ 39 public TableModel(ListPanel listPanel) { 40 this.listPanel = listPanel; 41 } 42 43 /** 44 * @return the listPanel 45 */ 46 public ListPanel getListPanel() { 47 return listPanel; 48 } 49 50 public JTable getTable() { 51 return listPanel.getTable(); 52 } 28 53 29 54 protected void refreshAll() { … … 31 56 l.tableChanged(new TableModelEvent(this)); 32 57 } 58 } 33 59 60 /** 61 * @param table the table to set 62 */ 63 public void setupTable() { 64 getTable().setDefaultRenderer(ProcedureParam.class, new ProcedureRenderer()); 65 getTable().setDefaultEditor(ProcedureParam.class, new ProcedureEditor(new JCheckBox())); 34 66 } 35 67 … … 38 70 39 71 this.elementAccess = this.access.getElementAccess().cloneAccess(); 40 log.debug("attached " +access);72 log.debug("attached {}", access); 41 73 refreshAll(); 42 74 } … … 49 81 @Override 50 82 public Class<?> getColumnClass(int columnIndex) { 51 // log.debug("returning column type " +columnParams.get(columnIndex).getStorageType());52 return column Params.get(columnIndex).getStorageType();83 // log.debug("returning column type {}", columnParams.get(columnIndex).getStorageType()); 84 return columns.get(columnIndex).getColumnClass(); 53 85 } 54 86 55 87 @Override 56 88 public int getColumnCount() { 57 // log.debug("returning column count " +columnParams.size());58 return column Params.size();89 // log.debug("returning column count {}", columnParams.size()); 90 return columns.size(); 59 91 } 60 92 61 93 @Override 62 94 public String getColumnName(int columnIndex) { 63 return column Params.get(columnIndex).getName();95 return columns.get(columnIndex).getParam().getName(); 64 96 } 65 97 66 98 @Override 67 99 public int getRowCount() { 68 // log.debug("returning row count " +access.getParamCount());69 return access .getParamCount();100 // log.debug("returning row count {}", access.getParamCount()); 101 return access == null ? 0 : access.getParamCount(); 70 102 } 71 103 72 104 @Override 73 105 public Object getValueAt(int rowIndex, int columnIndex) { 74 assert (rowIndex < access.getParamCount() && columnIndex < column Params.size());106 assert (rowIndex < access.getParamCount() && columnIndex < columns.size()); 75 107 76 return elementAccess.select(access.get(rowIndex, Object.class)).get(columnParams.get(columnIndex), Object.class);108 return columns.get(columnIndex).getValueAt(rowIndex); 77 109 } 78 110 79 111 @Override 80 112 public boolean isCellEditable(int rowIndex, int columnIndex) { 81 return false;113 return columns.get(columnIndex).isEditable(); 82 114 } 83 115 … … 87 119 } 88 120 121 89 122 @Override 90 123 public void setValueAt(Object value, int rowIndex, int columnIndex) { 91 throw new UnsupportedOperationException().msg("setting value in table"); 92 124 assert (rowIndex < access.getParamCount() && columnIndex < columns.size()); 125 // Object object = getObjectAt(rowIndex, columnIndex); 126 // if (object == null) { 127 // return; 128 // } 129 columns.get(columnIndex).setValueAt(rowIndex, value); 93 130 } 94 131 95 public void addColumn(PrimitiveParam<?> columnParam) { 96 log.debug("added " + columnParam); 97 columnParams.add(columnParam); 132 public void addColumn(Column column) { 133 log.debug("added {}", column); 134 columns.add(column); 135 } 136 137 /** 138 * @return the access 139 */ 140 public ListAccess getAccess() { 141 return access; 142 } 143 144 /** 145 * @return the elementAccess 146 */ 147 public Access getElementAccess() { 148 return elementAccess; 98 149 } 99 150 … … 101 152 * @return the columnParams 102 153 */ 103 public List<PrimitiveParam<?>> getColumnParams() { 104 return Collections.unmodifiableList(columnParams); 154 public List<Column> getColumns() { 155 return Collections.unmodifiableList(columns); 156 } 157 158 159 public boolean addColumnIfSupported(Param param) { 160 if (param instanceof PrimitiveParam) { 161 addColumn(new PrimitiveColumn((PrimitiveParam<?>) param, this)); 162 return true; 163 } 164 if (param instanceof ProcedureParam) { 165 if (((ProcedureParam) param).getArgumentsType().size() == 0) { 166 addColumn(new ProcedureColumn((ProcedureParam) param, this)); 167 return true; 168 } 169 return false; 170 } 171 return false; 172 } 173 174 public static void transferCellAppeariance(JTable table, JComponent component, boolean isSelected) { 175 if (isSelected) { 176 component.setForeground(table.getSelectionForeground()); 177 component.setBackground(table.getSelectionBackground()); 178 } else { 179 component.setForeground(table.getForeground()); 180 component.setBackground(UIManager.getColor("Button.background")); 181 } 182 105 183 } 106 184 -
java/main/src/main/java/com/framsticks/gui/tree/AbstractNode.java
r99 r100 1 1 package com.framsticks.gui.tree; 2 3 import com.framsticks.gui.AbstractPanel; 2 4 3 5 … … 9 11 10 12 public abstract int getChildCount(); 11 public abstract AbstractNodegetChild(int number);12 public abstract int getIndexOfChild( AbstractNodechild);13 public abstract Object getChild(int number); 14 public abstract int getIndexOfChild(Object child); 13 15 14 16 public abstract boolean isLeaf(); 15 17 public abstract void render(TreeCellRenderer renderer); 16 18 19 public abstract AbstractPanel getPanel(); 20 17 21 } -
java/main/src/main/java/com/framsticks/gui/tree/EmptyNode.java
r99 r100 2 2 3 3 4 import com.framsticks.gui.AbstractPanel; 5 import com.framsticks.gui.Frame; 4 6 import com.framsticks.gui.ImageProvider; 5 7 import com.framsticks.params.CompositeParam; … … 8 10 9 11 protected final CompositeParam param; 12 protected final Frame frame; 10 13 11 14 /** 12 15 * @param param 13 16 */ 14 public EmptyNode( CompositeParam param) {17 public EmptyNode(Frame frame, CompositeParam param) { 15 18 this.param = param; 19 this.frame = frame; 16 20 } 17 21 … … 22 26 23 27 @Override 24 public AbstractNodegetChild(int number) {28 public Object getChild(int number) { 25 29 return null; 26 30 } 27 31 28 32 @Override 29 public int getIndexOfChild( AbstractNodechild) {33 public int getIndexOfChild(Object child) { 30 34 return -1; 31 35 } … … 33 37 @Override 34 38 public boolean isLeaf() { 35 return true;39 return false; 36 40 } 37 41 38 42 @Override 39 43 public void render(TreeCellRenderer renderer) { 40 renderer.setIcon(ImageProvider.loadImage(TreeCellRenderer.findIconName(param))); 44 // TODO Auto-generated method stub 45 46 renderer.setToolTipText("?"); 41 47 renderer.setText(param.getId()); 42 renderer.setToolTipText("?"); 48 renderer.setIcon(ImageProvider.loadImage(ImageProvider.FOLDER_CLOSED)); 49 } 50 51 /** 52 * @return the param 53 */ 54 public CompositeParam getParam() { 55 return param; 43 56 } 44 57 45 58 @Override 46 public String toString() {47 return param.toString();59 public AbstractPanel getPanel() { 60 return frame.getEmptyPanel(); 48 61 } 49 62 -
java/main/src/main/java/com/framsticks/gui/tree/MetaNode.java
r99 r100 5 5 6 6 7 import com.framsticks.gui.AbstractPanel; 8 import com.framsticks.gui.Frame; 7 9 import com.framsticks.gui.ImageProvider; 8 10 9 11 public class MetaNode extends AbstractNode { 10 12 11 protected List<AbstractNode> children = new LinkedList<>(); 13 protected final Frame frame; 14 protected final List<Object> children = new LinkedList<>(); 12 15 protected String name = "meta node"; 16 17 /** 18 * @param frame 19 */ 20 public MetaNode(Frame frame) { 21 this.frame = frame; 22 } 13 23 14 24 /** 15 25 * @return the children 16 26 */ 17 public List< AbstractNode> getChildren() {27 public List<Object> getChildren() { 18 28 return children; 19 29 } … … 39 49 40 50 @Override 41 public AbstractNodegetChild(int number) {51 public Object getChild(int number) { 42 52 return children.get(number); 43 53 } 44 54 45 55 @Override 46 public int getIndexOfChild( AbstractNodechild) {56 public int getIndexOfChild(Object child) { 47 57 return children.indexOf(child); 48 58 } … … 65 75 } 66 76 77 @Override 78 public AbstractPanel getPanel() { 79 return frame.getEmptyPanel(); 80 } 81 67 82 } -
java/main/src/main/java/com/framsticks/gui/tree/TreeCellRenderer.java
r99 r100 15 15 public class TreeCellRenderer extends DefaultTreeCellRenderer { 16 16 17 p ublic TreeCellRenderer() {17 protected final TreeModel treeModel; 18 18 19 // setOpenIcon(ImageProvider.loadImage(ImageProvider.FOLDER_OPEN)); 20 // setClosedIcon(ImageProvider.loadImage(ImageProvider.FOLDER_CLOSED)); 21 // setLeafIcon(ImageProvider.loadImage(ImageProvider.NODE)); 19 20 /** 21 * @param treeModel 22 */ 23 public TreeCellRenderer(TreeModel treeModel) { 24 this.treeModel = treeModel; 22 25 } 23 26 … … 35 38 36 39 if (!(value instanceof AbstractNode)) { 37 set Icon(ImageProvider.loadImage(ImageProvider.SERVER));38 setText("framsticks");40 setText("?"); 41 // treeModel.renderTreeObject(Casting.throwCast(TreeNode.class, value), this); 39 42 return this; 40 43 } … … 92 95 93 96 94 95 97 } -
java/main/src/main/java/com/framsticks/gui/tree/TreeModel.java
r99 r100 1 1 package com.framsticks.gui.tree; 2 2 3 //import java.util.Enumeration;3 import java.util.Enumeration; 4 4 import java.util.Iterator; 5 5 import java.util.LinkedList; 6 6 import java.util.List; 7 7 8 import javax.annotation.Nullable; 8 9 import javax.swing.event.TreeModelEvent; 9 10 import javax.swing.event.TreeModelListener; 10 11 import javax.swing.tree.TreePath; 11 12 12 import org.apache.log4j.Logger; 13 14 13 import org.apache.logging.log4j.Logger; 14 import org.apache.logging.log4j.LogManager; 15 16 import com.framsticks.core.ListChange; 15 17 import com.framsticks.core.Node; 16 18 import com.framsticks.core.Path; 17 import com.framsticks.core.Tree;18 19 import com.framsticks.core.TreeOperations; 19 20 import com.framsticks.gui.Frame; 20 import com.framsticks.params.AccessInterface; 21 import com.framsticks.params.Access; 22 import com.framsticks.params.CompositeParam; 23 import com.framsticks.params.EventListener; 24 import com.framsticks.params.ListAccess; 25 import com.framsticks.params.PrimitiveParam; 26 import com.framsticks.params.Util; 27 import com.framsticks.params.ValueParam; 28 import com.framsticks.params.types.EventParam; 21 29 import com.framsticks.util.FramsticksException; 30 import com.framsticks.util.Misc; 22 31 import com.framsticks.util.UnsupportedOperationException; 23 32 import com.framsticks.util.dispatching.FutureHandler; 24 33 import com.framsticks.util.lang.Casting; 25 34 35 import static com.framsticks.core.TreeOperations.*; 36 26 37 public class TreeModel implements javax.swing.tree.TreeModel { 27 private static final Logger log = Log ger.getLogger(TreeModel.class);38 private static final Logger log = LogManager.getLogger(TreeModel.class); 28 39 29 40 30 41 protected List<TreeModelListener> listeners = new LinkedList<>(); 42 31 43 32 44 protected final Frame frame; … … 45 57 46 58 @Override 47 public AbstractNodegetChild(Object parent, int number) {48 return Casting. assertCast(AbstractNode.class, parent).getChild(number);59 public Object getChild(Object parent, int number) { 60 return Casting.throwCast(AbstractNode.class, parent).getChild(number); 49 61 } 50 62 51 63 @Override 52 64 public int getChildCount(Object parent) { 53 return Casting. assertCast(AbstractNode.class, parent).getChildCount();65 return Casting.throwCast(AbstractNode.class, parent).getChildCount(); 54 66 } 55 67 … … 59 71 return -1; 60 72 } 61 return Casting. assertCast(AbstractNode.class, parent).getIndexOfChild(Casting.assertCast(AbstractNode.class, child));73 return Casting.throwCast(AbstractNode.class, parent).getIndexOfChild(child); 62 74 } 63 75 … … 69 81 @Override 70 82 public boolean isLeaf(Object node) { 71 return Casting. assertCast(AbstractNode.class, node).isLeaf();83 return Casting.throwCast(AbstractNode.class, node).isLeaf(); 72 84 } 73 85 … … 85 97 protected boolean changing = false; 86 98 87 public void nodeStructureChanged(TreePath treePath) { 99 public void treeNodesInserted(TreeModelEvent event) { 100 assert frame.isActive(); 101 try { 102 for (TreeModelListener listener : listeners) { 103 listener.treeNodesInserted(event); 104 } 105 } catch (ArrayIndexOutOfBoundsException e) { 106 } 107 } 108 109 public void treeNodesRemoved(TreeModelEvent event) { 110 assert frame.isActive(); 111 try { 112 for (TreeModelListener listener : listeners) { 113 listener.treeNodesRemoved(event); 114 } 115 } catch (ArrayIndexOutOfBoundsException e) { 116 } 117 } 118 119 public void treeNodesChanged(TreeModelEvent event) { 120 try { 121 for (TreeModelListener listener : listeners) { 122 listener.treeNodesChanged(event); 123 } 124 } catch (ArrayIndexOutOfBoundsException e) { 125 } 126 } 127 128 public TreeModelEvent prepareModelEvent(TreePath treePath, int number, TreeNode node) { 129 return new TreeModelEvent(this, treePath, new int[] {number}, new Object[] { node }); 130 } 131 132 133 public TreeModelEvent prepareModelEventRegarding(Access access, String id, TreePath treeListPath) { 134 135 int number = Util.getNumberOfCompositeParamChild(access, access.get(id, Object.class)); 136 if (number == -1) { 137 log.debug("encountered minor tree inconsistency in {}", treeListPath); 138 return null; 139 } 140 TreeNode node = Casting.throwCast(TreeNode.class, Casting.throwCast(TreeNode.class, treeListPath.getLastPathComponent()).getChild(number)); 141 return prepareModelEvent(treeListPath, number, node); 142 } 143 144 public void treeStructureChanged(TreePath treePath) { 145 88 146 if (treePath == null) { 89 147 return; … … 92 150 93 151 changing = true; 94 log.debug("changing : " +treePath);95 // Enumeration<TreePath> expanded = frame.jtree.getExpandedDescendants(treePath);152 log.debug("changing structure: {}", treePath); 153 Enumeration<TreePath> expanded = frame.getJtree().getExpandedDescendants(treePath); 96 154 TreePath selection = frame.getJtree().getSelectionPath(); 97 155 98 for (TreeModelListener listener : listeners) { 99 listener.treeStructureChanged(new TreeModelEvent(this, treePath)); 100 } 101 // if (expanded != null) { 102 // while (expanded.hasMoreElements()) { 103 // TreePath expansion = expanded.nextElement(); 104 // // log.info("reexpanding: " + expansion); 105 // frame.jtree.expandPath(expansion); 106 // } 107 // } 156 try { 157 for (TreeModelListener listener : listeners) { 158 listener.treeStructureChanged(new TreeModelEvent(this, treePath)); 159 } 160 } catch (ArrayIndexOutOfBoundsException e) { 161 } 162 163 164 if (expanded != null) { 165 while (expanded.hasMoreElements()) { 166 TreePath expansion = expanded.nextElement(); 167 // log.info("reexpanding: {}", expansion); 168 frame.getJtree().expandPath(expansion); 169 } 170 } 171 108 172 if (selection != null) { 109 173 frame.getJtree().setSelectionPath(selection); … … 112 176 } 113 177 114 public Path convertToPath(TreePath treePath) { 178 /** 179 * 180 * This method may return null on conversion failure, which may happen in highload situations. 181 */ 182 public @Nullable Path convertToPath(TreePath treePath) { 115 183 final Object[] components = treePath.getPath(); 116 184 assert components[0] == frame.getRootNode(); … … 128 196 Node node = treeNode.tryCreateNode(); 129 197 if (node == null) { 130 throw new FramsticksException().msg("failed to recreate path").arg("treePath", treePath); 198 return null; 199 // throw new FramsticksException().msg("failed to recreate path").arg("treePath", treePath); 131 200 } 132 201 nodes.add(node); … … 137 206 } 138 207 139 public TreePath convertToTreePath(Path path ) {208 public TreePath convertToTreePath(Path path, boolean forceComplete) { 140 209 assert frame.isActive(); 141 210 … … 143 212 accumulator.add(getRoot()); 144 213 145 for ( AbstractNoder : getRoot().getChildren()) {214 for (Object r : getRoot().getChildren()) { 146 215 if (r instanceof TreeNode) { 147 216 TreeNode root = (TreeNode) r; 148 217 if (root.getTree() == path.getTree()) { 218 Iterator<Node> n = path.getNodes().iterator(); 219 TreeNode treeNode = root; 149 220 accumulator.add(root); 150 151 Iterator<Node> i = path.getNodes().iterator(); 152 i.next(); 153 TreeNode treeNode = root; 154 155 while (i.hasNext()) { 156 Node node = i.next(); 157 treeNode = treeNode.getTreeNodeForChild(node.getObject()); 221 n.next(); 222 while (n.hasNext()) { 223 Node node = n.next(); 224 treeNode = treeNode.prepareTreeNodeForChild(Path.build().tree(path.getTree()).buildUpTo(path.getNodes(), node).finish()); 158 225 if (treeNode == null) { 159 226 break; … … 161 228 accumulator.add(treeNode); 162 229 } 163 164 230 break; 165 231 } … … 167 233 } 168 234 return new TreePath(accumulator.toArray()); 235 } 236 237 /** 238 * @return the listeners 239 */ 240 public List<TreeModelListener> getListeners() { 241 return listeners; 169 242 } 170 243 … … 180 253 return; 181 254 } 182 Access Interfaceaccess = TreeOperations.bindAccess(path);255 Access access = TreeOperations.bindAccess(path); 183 256 184 257 int count = access.getCompositeParamCount(); … … 193 266 return; 194 267 } 195 if ( path.isResolved() && !reload) {268 if (!reload && path.isResolved() && isMarked(path.getTree(), path.getTopObject(), FETCHED_MARK, false)) { 196 269 return; 197 270 } … … 199 272 @Override 200 273 protected void result(Path result) { 201 final TreePath treePath = convertToTreePath(result); 202 203 nodeStructureChanged(treePath); 204 frame.updatePanelIfIsLeadSelection(treePath, result); 274 final TreePath treePath = convertToTreePath(result, true); 275 276 277 if (treePath != null) { 278 treeStructureChanged(treePath); 279 frame.updatePanelIfIsLeadSelection(result); 280 } 205 281 } 206 282 }); 207 283 } 208 284 209 public void chooseTreeNode(finalTreePath treePath) {285 public void expandTreeNode(TreePath treePath) { 210 286 assert frame.isActive(); 211 287 if (treePath == null) { … … 215 291 return; 216 292 } 217 218 293 Path path = convertToPath(treePath); 219 294 if (path == null) { 220 295 return; 221 296 } 297 loadChildren(path.assureResolved(), false); 298 } 299 300 public void chooseTreeNode(final TreePath treePath) { 301 assert frame.isActive(); 302 if (treePath == null) { 303 return; 304 } 305 if (isChanging()) { 306 return; 307 } 308 309 Path path = convertToPath(treePath); 310 if (path == null) { 311 return; 312 } 222 313 path = path.assureResolved(); 223 final Tree tree = path.getTree(); 224 225 frame.getTreeAtFrames().get(tree).useOrCreatePanel(treePath); 226 loadChildren(path, false); 227 228 } 314 315 log.debug("choosing {}", path); 316 frame.showPanelForTreePath(treePath); 317 loadPath(path, false); 318 319 } 320 321 322 protected void registerForEventParam(final TreeNode treeNode, Path path, final EventParam eventParam, ValueParam valueParam) { 323 /** TODO make this listener not bind hold the reference to this TreeNode, maybe hold WeakReference internally */ 324 if (valueParam instanceof PrimitiveParam) { 325 326 treeNode.tryAddListener(path, eventParam, Object.class, new EventListener<Object>() { 327 @Override 328 public void action(Object argument) { 329 loadPath(treeNode.assurePath(), true); 330 } 331 }); 332 333 } else if (valueParam instanceof CompositeParam) { 334 335 final CompositeParam compositeParam = (CompositeParam) valueParam; 336 337 treeNode.tryAddListener(path, eventParam, ListChange.class, new EventListener<ListChange>() { 338 @Override 339 public void action(ListChange listChange) { 340 assert treeNode.getTree().isActive(); 341 342 Path parentPath = treeNode.assurePath(); 343 final Path listPath = parentPath.appendParam(compositeParam).tryFindResolution(); 344 if (!listPath.isResolved()) { 345 /** that situation is quietly ignored - it may happen if first event comes before the container was resolved */ 346 return; 347 } 348 349 log.debug("reacting to change {} in {}", listChange, listPath); 350 final TreePath treeListPath = convertToTreePath(listPath, true); 351 if (treeListPath == null) { 352 throw new FramsticksException().msg("path was not fully converted").arg("path", listPath); 353 } 354 355 if ((listChange.getAction().equals(ListChange.Action.Modify)) && (listChange.getPosition() == -1)) { 356 // get(listPath, future); 357 // treeModel.nodeStructureChanged(treePath); 358 // frame.updatePanelIfIsLeadSelection(treePath, result); 359 return; 360 } 361 final String id = listChange.getBestIdentifier(); 362 363 final ListAccess access = (ListAccess) bindAccess(listPath); 364 switch (listChange.getAction()) { 365 case Add: { 366 Path childPath = listPath.appendParam(access.prepareParamFor(id)).tryFindResolution(); 367 if (!childPath.isResolved()) { 368 childPath = create(childPath); 369 370 TreeModelEvent event = prepareModelEventRegarding(access, id, treeListPath); 371 if (event != null) { 372 treeNodesInserted(event); 373 } else { 374 treeStructureChanged(treeListPath); 375 } 376 frame.updatePanelIfIsLeadSelection(listPath); 377 } 378 379 listPath.getTree().get(childPath, new FutureHandler<Path>(frame) { 380 @Override 381 protected void result(Path result) { 382 if (!result.isResolved()) { 383 log.warn("inconsistency after addition list change: {}", result); 384 } 385 assert frame.isActive(); 386 final TreePath treePath = Misc.throwIfNull(frame.getTreeModel().convertToTreePath(result, true)); 387 388 // treeModel.nodeStructureChanged(treePath); 389 frame.updatePanelIfIsLeadSelection(result); 390 391 log.debug("added {}({}) updated {}", id, result, treePath); 392 } 393 }); 394 break; 395 } 396 case Remove: { 397 398 TreeModelEvent event = prepareModelEventRegarding(access, id, treeListPath); 399 access.set(id, null); 400 if (event != null) { 401 treeNodesRemoved(event); 402 } else { 403 treeStructureChanged(treeListPath); 404 } 405 406 frame.updatePanelIfIsLeadSelection(listPath); 407 408 break; 409 } 410 case Modify: { 411 Path childPath = listPath.appendParam(access.prepareParamFor(id)).tryResolveIfNeeded(); 412 listPath.getTree().get(childPath, new FutureHandler<Path>(frame) { 413 @Override 414 protected void result(Path result) { 415 assert frame.isActive(); 416 // final TreePath treePath = frame.getTreeModel().convertToTreePath(result, true); 417 418 TreeModelEvent event = prepareModelEventRegarding(access, id, treeListPath); 419 if (event != null) { 420 treeNodesChanged(event); 421 } else { 422 treeStructureChanged(treeListPath); 423 } 424 425 frame.updatePanelIfIsLeadSelection(listPath); 426 frame.updatePanelIfIsLeadSelection(result); 427 } 428 }); 429 break; 430 } 431 } 432 } 433 }); 434 } 435 436 } 437 438 439 440 protected final Object createdTag = new Object(); 441 442 443 229 444 } -
java/main/src/main/java/com/framsticks/gui/tree/TreeNode.java
r99 r100 5 5 import java.util.LinkedList; 6 6 import java.util.List; 7 import java.util.concurrent.atomic.AtomicInteger; 8 9 import javax.swing.ImageIcon; 10 import javax.swing.tree.TreePath; 11 12 import org.apache.log4j.Logger; 13 14 import com.framsticks.core.ListChange; 7 8 import org.apache.logging.log4j.LogManager; 9 import org.apache.logging.log4j.Logger; 10 15 11 import com.framsticks.core.Node; 16 12 import com.framsticks.core.Path; … … 19 15 import com.framsticks.gui.ImageProvider; 20 16 import com.framsticks.gui.TreeAtFrame; 21 import com.framsticks.params.AccessInterface; 17 import com.framsticks.gui.TreePanel; 18 import com.framsticks.params.Access; 22 19 import com.framsticks.params.CompositeParam; 23 20 import com.framsticks.params.EventListener; 24 21 import com.framsticks.params.FramsClass; 25 import com.framsticks.params.PrimitiveParam;26 22 import com.framsticks.params.ValueParam; 27 23 import com.framsticks.params.types.EventParam; … … 32 28 import com.framsticks.util.lang.Casting; 33 29 import com.framsticks.util.lang.Containers; 34 import com.framsticks.util.lang.Pair;35 30 import com.framsticks.util.swing.TooltipConstructor; 31 36 32 import static com.framsticks.core.TreeOperations.*; 37 33 38 34 public class TreeNode extends AbstractNode { 39 private static final Logger log = Logger.getLogger(TreeNode.class); 40 41 42 protected static final AtomicInteger counter = new AtomicInteger(); 35 36 private static final Logger log = LogManager.getLogger(TreeNode.class); 43 37 44 38 protected final WeakReference<Object> reference; 39 protected final int hashCode; 40 protected final TreeAtFrame treeAtFrame; 41 protected final String textual; 45 42 protected final CompositeParam param; 46 protected final TreeAtFrame treeAtFrame;47 protected final List<Pair<WeakReference<Object>, WeakReference<TreeNode>>> children = new LinkedList<>(); 48 p rotected final int number;49 protected final String textualPath;50 protected final ImageIcon imageIcon;51 protected final TreeModel treeModel; 52 53 protected final List<EventListener<?>> listeners = new LinkedList<>();54 43 protected TreePanel panel; 44 45 public TreeModel getTreeModel() { 46 return treeAtFrame.getFrame().getTreeModel(); 47 } 48 49 /** 50 * @param reference 51 */ 55 52 public TreeNode(TreeAtFrame treeAtFrame, Path path) { 56 53 path.assureResolved(); 57 this.textualPath = path.getTextual(); 54 55 this.reference = new WeakReference<Object>(path.getTopObject()); 56 this.textual = path.getTextual(); 57 this.treeAtFrame = treeAtFrame; 58 58 this.param = path.getTop().getParam(); 59 this.treeAtFrame = treeAtFrame; 60 this.treeModel = treeAtFrame.getFrame().getTreeModel(); 61 this.imageIcon = ImageProvider.loadImage(TreeCellRenderer.findIconName(param)); 62 63 reference = new WeakReference<Object>(path.getTop().getObject()); 64 number = counter.getAndIncrement(); 59 hashCode = System.identityHashCode(path.getTopObject()); 60 61 if (getTree().getSideNote(path.getTopObject(), getTreeModel().createdTag, Object.class) == getTreeModel().createdTag) { 62 return; 63 } 64 65 // path.getTree().putSideNote(path.getTopObject(), Textual.class, path.getTextual()); 66 path.getTree().putSideNote(path.getTopObject(), getTreeModel().createdTag, getTreeModel().createdTag); 65 67 66 68 /** Iterate over all EventParams and for matching ValueParams register listeners. */ 67 if (pa raminstanceof ObjectParam) {68 Access Interfaceaccess = bindAccess(path);69 if (path.getTop().getParam() instanceof ObjectParam) { 70 Access access = bindAccess(path); 69 71 FramsClass framsClass = access.getFramsClass(); 70 72 for (EventParam eventParam : Containers.filterInstanceof(framsClass.getParamEntries(), EventParam.class)) { … … 77 79 continue; 78 80 } 79 registerForEventParam(path, eventParam, valueParam); 80 } 81 } 82 } 83 84 protected <A> void tryAddListener(final Path path, final EventParam eventParam, Class<A> argumentType, final EventListener<A> listener) { 85 treeAtFrame.getTree().addListener(path, eventParam, listener, argumentType, new FutureHandler<Void>(treeAtFrame.getFrame()) { 86 @Override 87 protected void result(Void result) { 88 assert treeAtFrame.getFrame().isActive(); 89 log.debug("registered gui listener for " + eventParam + " at " + path); 90 listeners.add(listener); 91 } 92 }); 93 } 94 95 protected void registerForEventParam(Path path, EventParam eventParam, ValueParam valueParam) { 96 /** TODO make this listener not bind hold the reference to this TreeNode, maybe hold WeakReference internally */ 97 if (valueParam instanceof PrimitiveParam) { 98 99 tryAddListener(path, eventParam, Object.class, new EventListener<Object>() { 100 @Override 101 public void action(Object argument) { 102 treeModel.loadPath(assurePath(), true); 103 } 104 }); 105 106 } else if (valueParam instanceof CompositeParam) { 107 108 final CompositeParam compositeParam = (CompositeParam) valueParam; 109 110 tryAddListener(path, eventParam, ListChange.class, new EventListener<ListChange>() { 111 @Override 112 public void action(ListChange listChange) { 113 assert treeAtFrame.getTree().isActive(); 114 115 final Path listPath = assurePath().appendParam(compositeParam).tryFindResolution().assureResolved(); 116 log.debug("reacting to change " + listChange + " in " + listPath); 117 118 if ((listChange.getAction().equals(ListChange.Action.Modify)) && (listChange.getPosition() == -1)) { 119 // get(listPath, future); 120 return; 121 } 122 final String id = listChange.getBestIdentifier(); 123 124 AccessInterface access = bindAccess(listPath); 125 switch (listChange.getAction()) { 126 case Add: { 127 tryGet(listPath.getTree(), Path.appendString(listPath.getTextual(), id), new FutureHandler<Path>(treeAtFrame.getFrame()) { 128 @Override 129 protected void result(Path result) { 130 final Frame frame = treeAtFrame.getFrame(); 131 assert frame.isActive(); 132 final TreePath treePath = frame.getTreeModel().convertToTreePath(listPath); 133 treeModel.nodeStructureChanged(treePath); 134 frame.updatePanelIfIsLeadSelection(treePath, listPath); 135 log.debug("added " + id + "(" + result + ") updated " + treePath); 136 } 137 }); 138 break; 139 } 140 case Remove: { 141 access.set(id, null); 142 Frame frame = treeAtFrame.getFrame(); 143 treeModel.nodeStructureChanged(frame.getTreeModel().convertToTreePath(listPath)); 144 break; 145 } 146 case Modify: { 147 tryGet(listPath.getTree(), Path.appendString(listPath.getTextual(), id), new FutureHandler<Path>(treeAtFrame.getFrame()) { 148 @Override 149 protected void result(Path result) { 150 final Frame frame = treeAtFrame.getFrame(); 151 assert frame.isActive(); 152 final TreePath treePath = frame.getTreeModel().convertToTreePath(result); 153 treeModel.nodeStructureChanged(treePath); 154 frame.updatePanelIfIsLeadSelection(treePath, listPath); 155 } 156 }); 157 break; 158 } 159 } 160 } 161 }); 162 } 163 164 } 165 166 protected Path assurePath() { 167 return Path.to(treeAtFrame.getTree(), textualPath).assureResolved(); 168 } 169 170 public Node tryCreateNode() { 171 Object child = lock(); 172 if (child == null) { 173 return null; 174 } 175 return Path.to(treeAtFrame.getTree(), textualPath).assureResolved().getTop(); 176 } 177 178 @Override 179 public int getChildCount() { 180 Object referent = lock(); 181 if (referent == null) { 182 return 0; 183 } 184 AccessInterface access = bindAccessFor(referent); 185 final int count = access.getCompositeParamCount(); 186 return count; 187 } 188 189 public TreeNode getTreeNodeForChild(Object child) { 190 Iterator<Pair<WeakReference<Object>, WeakReference<TreeNode>>> i = children.iterator(); 191 while (i.hasNext()) { 192 Pair<WeakReference<Object>, WeakReference<TreeNode>> p = i.next(); 193 Object object = p.first.get(); 194 if (object == null) { 195 i.remove(); 196 continue; 197 } 198 TreeNode treeNode = p.second.get(); 199 if (treeNode == null) { 200 i.remove(); 201 continue; 202 } 203 if (object == child) { 204 return treeNode; 205 } 206 } 207 return null; 208 209 // WeakReference<GuiTreeNode> resultReference = children.get(child); 210 // if (resultReference == null) { 211 // return null; 212 // } 213 // return resultReference.get(); 81 getTreeModel().registerForEventParam(this, path, eventParam, valueParam); 82 } 83 } 84 } 85 86 @Override 87 public int hashCode() { 88 return hashCode; 89 } 90 91 @Override 92 public boolean equals(Object obj) { 93 if (obj instanceof TreeNode) { 94 return lock() == ((TreeNode) obj).lock(); 95 } 96 return false; 214 97 } 215 98 … … 220 103 throw new FramsticksException().msg("invalid state - missing referent"); 221 104 } 222 AccessInterface access = bindAccessFor(referent); 105 Tree tree = getTree(); 106 Access access = bindAccessForTreeObject(referent); 223 107 224 108 final int count = access.getCompositeParamCount(); … … 227 111 } 228 112 113 /** textual path may be not valid anymore*/ 229 114 CompositeParam childParam = access.getCompositeParam(number); 230 Object child = access.get(childParam, Object.class); 231 if (child == null) { 232 log.debug("returning dummy node for " + childParam + " in " + referent); 233 return new EmptyNode(childParam); 234 } 235 236 TreeNode result = getTreeNodeForChild(child); 237 if (result != null) { 238 return result; 239 } 240 Path path = Path.to(treeAtFrame.getTree(), Path.appendString(textualPath, childParam.getId())).assureResolved(); 241 result = new TreeNode(treeAtFrame, path); 242 243 children.add(Pair.make(new WeakReference<Object>(child), new WeakReference<TreeNode>(result))); 244 245 return result; 246 115 116 try { 117 Path path = Path.to(tree, getTextual()).appendParam(childParam).tryFindResolution(); 118 if (!path.isResolved()) { 119 path = create(path); 120 } 121 return prepareTreeNodeForChild(path); 122 } catch (FramsticksException e) { 123 } 124 return new EmptyNode(getFrame(), childParam); 125 126 } 127 128 public TreeNode prepareTreeNodeForChild(Path path) { 129 assert path.getTree() == getTree(); 130 Object parent = lock(); 131 Iterator<Node> n = path.getNodes().iterator(); 132 while (n.hasNext()) { 133 if (n.next().getObject() == parent) { 134 break; 135 } 136 } 137 if (!n.hasNext()) { 138 return null; 139 // throw new FramsticksException().msg("tree node is not on path (or is last)").arg("path", path).arg("node", this); 140 } 141 return new TreeNode(treeAtFrame, path); 247 142 } 248 143 … … 252 147 253 148 @Override 254 public int getIndexOfChild( AbstractNodechild) {149 public int getIndexOfChild(Object child) { 255 150 final TreeNode treeChild = Casting.tryCast(TreeNode.class, child); 256 151 if (treeChild == null) { … … 262 157 return -1; 263 158 } 264 final Access Interface access = bindAccessFor(parentObject);159 final Access access = bindAccessForTreeObject(parentObject); 265 160 266 161 final int count = access.getCompositeParamCount(); … … 271 166 } 272 167 } 273 log.debug( child + " not found in " +this);168 log.debug("{} not found in {}", child, this); 274 169 return -1; 275 170 } 276 171 277 /** 278 * @return the param 279 */ 280 public CompositeParam getParam() { 281 return param; 282 } 283 284 /** 285 * @return the tree 286 */ 172 public Frame getFrame() { 173 return getTreeAtFrame().getFrame(); 174 } 175 176 public TreeAtFrame getTreeAtFrame() { 177 return treeAtFrame; 178 } 179 287 180 public Tree getTree() { 288 return treeAtFrame.getTree(); 289 } 290 181 return getTreeAtFrame().getTree(); 182 } 183 184 protected Path assurePath() { 185 return Path.to(getTree(), getTextual()).assureResolved(); 186 } 291 187 292 188 @Override 293 189 public String toString() { 294 return param.toString(); 295 } 296 297 public static Node tryGetNode(TreePath treePath) { 298 return Casting.throwCast(TreeNode.class, treePath.getLastPathComponent()).tryCreateNode(); 190 return getTextual(); 191 } 192 193 public Node tryCreateNode() { 194 Object child = lock(); 195 if (child == null) { 196 return null; 197 } 198 String textual = getTextual(); 199 Path path = Path.tryTo(getTree(), textual); 200 if (path.isResolved(textual)) { 201 return path.getTop(); 202 } 203 return null; 204 } 205 206 @Override 207 public int getChildCount() { 208 Object referent = lock(); 209 if (referent == null) { 210 return 0; 211 } 212 Access access = bindAccessForTreeObject(referent); 213 final int count = access.getCompositeParamCount(); 214 return count; 299 215 } 300 216 … … 305 221 return true; 306 222 } 307 return bindAccessFor (referent).getCompositeParamCount() == 0;308 } 309 310 protected Access Interface bindAccessFor(Object child) {311 return treeAtFrame.getTree().prepareAccess(param).select(child);223 return bindAccessForTreeObject(referent).getCompositeParamCount() == 0; 224 } 225 226 protected Access bindAccessForTreeObject(Object child) { 227 return bindAccessFromSideNote(getTree(), child); 312 228 } 313 229 314 230 @Override 315 231 public void render(TreeCellRenderer renderer) { 232 233 Object child = lock(); 234 if (child == null) { 235 renderer.setToolTipText("?"); 236 renderer.setText("?"); 237 renderer.setIcon(ImageProvider.loadImage(ImageProvider.FOLDER_CLOSED)); 238 return; 239 } 240 Access access = bindAccessForTreeObject(child); 241 CompositeParam param = getTree().getSideNote(child, CompositeParam.class, CompositeParam.class); 316 242 String name = param.getId(); 317 243 318 Object child = lock(); 319 if (child != null) { 320 AccessInterface access = bindAccessFor(child); 321 322 StringParam nameParam = Casting.tryCast(StringParam.class, access.getParam("name")); 323 324 if (nameParam != null) { 325 name = access.get(nameParam, String.class); 326 } 327 328 renderer.setToolTipText(new TooltipConstructor() 244 StringParam nameParam = Casting.tryCast(StringParam.class, access.getParam("name")); 245 246 if (nameParam != null) { 247 name = access.get(nameParam, String.class); 248 } 249 250 renderer.setToolTipText(new TooltipConstructor() 329 251 .append("frams", access.getId()) 330 252 .append("java", child.getClass().getCanonicalName()) … … 333 255 .append("id", param.getId()) 334 256 .append("object", Integer.toHexString(System.identityHashCode(child))) 335 .append("number", number) 336 .append("textual path", textualPath) 257 .append("size", access.getCompositeParamCount()) 337 258 .build()); 338 } else { 339 renderer.setToolTipText(new TooltipConstructor() 340 .append("param", param) 341 .append("textual path", textualPath) 342 .build()); 343 } 259 260 renderer.setIcon(ImageProvider.loadImage(TreeCellRenderer.findIconName(param))); 344 261 renderer.setText(name); 345 renderer.setIcon(imageIcon); 346 262 } 263 264 // public static class Textual { 265 // } 266 267 public String getTextual() { 268 return textual; 269 // return getTree().getSideNote(lock(), Textual.class, String.class); 270 } 271 272 protected final Object listenersTag = new Object(); 273 274 public List<EventListener<?>> getListeners() { 275 @SuppressWarnings("unchecked") 276 List<EventListener<?>> result = getTree().getSideNote(lock(), listenersTag, List.class); 277 if (result == null) { 278 result = new LinkedList<>(); 279 getTree().putSideNote(lock(), listenersTag, result); 280 } 281 282 return result; 283 } 284 285 protected <A> void tryAddListener(final Path path, final EventParam eventParam, Class<A> argumentType, final EventListener<A> listener) { 286 getTree().addListener(path, eventParam, listener, argumentType, new FutureHandler<Void>(getFrame()) { 287 @Override 288 protected void result(Void result) { 289 assert getFrame().isActive(); 290 log.debug("registered gui listener for {} at {}", eventParam, path); 291 getListeners().add(listener); 292 } 293 }); 294 } 295 296 @Override 297 public TreePanel getPanel() { 298 if (panel != null) { 299 return panel; 300 } 301 panel = getTreeAtFrame().preparePanel(param); 302 return panel; 347 303 } 348 304 -
java/main/src/main/java/com/framsticks/gui/windows/ServerLogFrame.java
r85 r100 2 2 3 3 import com.framsticks.gui.ImageProvider; 4 import org.apache.log 4j.Logger;4 import org.apache.logging.log4j.LogManager; 5 5 6 6 import javax.swing.*; … … 85 85 if (popUp && !this.isVisible()) 86 86 this.setVisible(true); 87 Log ger.getLogger(ServerLogFrame.class).error(87 LogManager.getLogger(ServerLogFrame.class).error( 88 88 "level " + level + " class " + clazz + " function " 89 89 + function + " msg " + message); -
java/main/src/main/java/com/framsticks/hosting/Cli.java
r99 r100 4 4 import java.util.TreeMap; 5 5 6 import org.apache.log4j.Logger; 6 import org.apache.logging.log4j.Logger; 7 import org.apache.logging.log4j.LogManager; 7 8 8 9 import com.framsticks.communication.Response; … … 20 21 public class Cli { 21 22 private static final Logger log = 22 Log ger.getLogger(Cli.class);23 LogManager.getLogger(Cli.class); 23 24 24 25 … … 39 40 40 41 public void addListener(Path path, EventParam param, String pathPrefix, ServerSideResponseFuture responseFuture) { 41 log.debug("adding listener for " + path + ": " +param);42 log.debug("adding listener for {}: {}", path, param); 42 43 43 44 final CliEvent event = new CliEvent(); … … 53 54 @Override 54 55 public void action(Object argument) { 55 log.debug("registered event " + event + " happened with " +argument);56 log.debug("registered event {} happened with {}", event, argument); 56 57 57 58 client.connection.sendFile( -
java/main/src/main/java/com/framsticks/hosting/CliEvent.java
r99 r100 56 56 57 57 @ParamAnnotation 58 public String getUid() { 59 return id; 60 } 61 62 @ParamAnnotation 58 63 public String getName() { 59 64 return id; -
java/main/src/main/java/com/framsticks/hosting/ClientAtServer.java
r99 r100 81 81 rootTree.getRegistry().registerAndBuild(CliEvent.class); 82 82 83 Access Interfaceaccess = new PropertiesAccess(rootFramsClass);84 85 root = access.createAccessee();83 Access access = new PropertiesAccess(rootFramsClass); 84 85 root = createAccessee(rootTree, access); 86 86 access.select(root); 87 87 access.set(id, treeRootObject); … … 112 112 } 113 113 114 public static File printToFile(String path, Access Interfaceaccess) {114 public static File printToFile(String path, Access access) { 115 115 ListSink sink = new ListSink(); 116 116 access.save(sink); … … 128 128 } 129 129 130 // final Access Interfaceaccess = tree.prepareAccess(path);131 final Access Interfaceaccess = bindAccess(path);130 // final Access access = tree.prepareAccess(path); 131 final Access access = bindAccess(path); 132 132 133 133 if (request instanceof GetRequest) { -
java/main/src/main/java/com/framsticks/hosting/Server.java
r98 r100 1 1 package com.framsticks.hosting; 2 2 3 import org.apache.log4j.Level; 4 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Level; 4 import org.apache.logging.log4j.Logger; 5 import org.apache.logging.log4j.LogManager; 5 6 6 7 import com.framsticks.core.Tree; … … 28 29 public class Server extends AbstractJoinable implements JoinableParent { 29 30 30 private final static Logger log = Log ger.getLogger(Server.class);31 private final static Logger log = LogManager.getLogger(Server.class); 31 32 32 33 protected int port; … … 131 132 final Socket socket = acceptSocket.accept(); 132 133 assert socket != null; 133 log.debug("accepted socket: " +socket.getInetAddress().getHostAddress());134 log.debug("accepted socket: {}", socket.getInetAddress().getHostAddress()); 134 135 hosted.dispatch(new RunAt<Tree>(this) { 135 136 @Override … … 137 138 ClientAtServer client = new ClientAtServer(Server.this, socket); 138 139 clients.add(client); 139 log.info("client connected: " +client);140 log.info("client connected: {}", client); 140 141 } 141 142 }); 142 143 } catch (IOException e) { 143 log.log((isRunning() ? Level.ERROR : Level.DEBUG), "failed to accept socket: " +e);144 log.log((isRunning() ? Level.ERROR : Level.DEBUG), "failed to accept socket: {}", e); 144 145 } 145 146 acceptNext(); … … 154 155 try { 155 156 acceptSocket.bind(new InetSocketAddress(port)); 156 log.debug("started accepting on port " +port);157 log.debug("started accepting on port {}", port); 157 158 acceptNext(); 158 159 return; 159 160 } catch (IOException e) { 160 log.warn("failed to accept on port " + port + " (repeating): " +e);161 log.warn("failed to accept on port {} (repeating): ", port, e); 161 162 } 162 163 tryBind(1000); … … 201 202 // } catch (ClassNotFoundException ignored) { 202 203 // } catch (ConstructionException e) { 203 // log.error("failed to use info from cache: " +e);204 // log.error("failed to use info from cache: {}", e); 204 205 // } 205 206 … … 213 214 // FramsClass framsClass = getInfoFromCache(path.getTop().getObject().getClass().getCanonicalName()); 214 215 // if (framsClass == null) { 215 // log.error("failed to create frams class for: " +path.getTop().getObject().getClass());216 // log.error("failed to create frams class for: {}", path.getTop().getObject().getClass()); 216 217 // future.result(null, new Exception()); 217 218 // return; -
java/main/src/main/java/com/framsticks/model/Genotype.java
r86 r100 5 5 6 6 7 // import org.apache.log 4j.Logger;7 // import org.apache.logging.log4j.Logger; 8 8 9 9 @FramsClassAnnotation 10 10 public class Genotype extends Model { 11 // private final static Logger log = Log ger.getLogger(Genotype.class);11 // private final static Logger log = LogManager.getLogger(Genotype.class); 12 12 13 13 @ParamAnnotation … … 87 87 public double getStrsiz() { return getNumparts(); } 88 88 @ParamAnnotation 89 public void setStrsiz(double strsiz) { setNumparts(strsiz);}89 public void setStrsiz(double strsiz) {} 90 90 91 91 … … 93 93 public double getStrjoints() { return getNumjoints(); } 94 94 @ParamAnnotation 95 public void setStrjoints(double strjoints) { setNumjoints(strjoints);}95 public void setStrjoints(double strjoints) {} 96 96 97 97 … … 99 99 public double getNnsiz() { return getNumneurons(); } 100 100 @ParamAnnotation 101 public void setNnsiz(double nnsiz) { setNumneurons(nnsiz);}101 public void setNnsiz(double nnsiz) {} 102 102 103 103 -
java/main/src/main/java/com/framsticks/model/Model.java
r99 r100 3 3 import com.framsticks.params.annotations.FramsClassAnnotation; 4 4 import com.framsticks.params.annotations.ParamAnnotation; 5 import com.framsticks.util.lang.Containers;6 5 7 6 import java.util.ArrayList; … … 48 47 //this is impossible to use, because numparts field is marked as readonly 49 48 @ParamAnnotation 50 public void setNumparts(double numparts) { Containers.resizeList(parts, (int) (double) numparts);}49 public void setNumparts(double numparts) {} 51 50 @ParamAnnotation 52 public void setNumjoints(double numjoints) { Containers.resizeList(joints, (int)(double)numjoints);}51 public void setNumjoints(double numjoints) {} 53 52 @ParamAnnotation 54 public void setNumneurons(double numneurons) { Containers.resizeList(neuroDefinitions, (int)(double)numneurons);}53 public void setNumneurons(double numneurons) {} 55 54 56 55 public List<Part> getParts() { return parts; } -
java/main/src/main/java/com/framsticks/model/ModelBuilder.java
r90 r100 35 35 } 36 36 F0Parser parser = new F0Parser(schema, stream); 37 components.addAll(Util.stripAccess Interface(parser.parse(), ModelComponent.class));37 components.addAll(Util.stripAccess(parser.parse(), ModelComponent.class)); 38 38 } 39 39 return build(); -
java/main/src/main/java/com/framsticks/params/ArrayListAccess.java
r99 r100 9 9 import java.util.List; 10 10 import java.util.ListIterator; 11 import static com.framsticks.params.SetStateFlags.*; 11 12 12 13 /** … … 18 19 19 20 20 public ArrayListAccess(Access InterfaceelementAccess) {21 public ArrayListAccess(Access elementAccess) { 21 22 super(elementAccess); 22 23 } … … 76 77 @Override 77 78 public <T> int set(int i, T value) { 78 while (i >= list.size()) { 79 list.add(null); 79 if (value != null) { 80 while (i >= list.size()) { 81 list.add(null); 82 } 83 list.set(i, value); 84 return 0; 80 85 } 81 list.set(i, value); 86 if (i >= list.size()) { 87 return PSET_HITMAX; 88 } 89 list.remove(i); 90 // for (int j = i + 1; j < list.size(); ++j) { 91 // if (list.get(j) != null) { 92 // list.set(i, null); 93 // return 0; 94 // } 95 // } 96 // while (list.size() > i) { 97 // list.remove(i); 98 // } 82 99 return 0; 83 100 } … … 107 124 @Override 108 125 public ArrayListAccess select(Object object) { 109 list = (List<Object>) object;126 list = Util.selectObjectForAccess(this, object, List.class); 110 127 return this; 111 128 } -
java/main/src/main/java/com/framsticks/params/CompositeParam.java
r98 r100 28 28 } 29 29 30 public abstract Access Interface prepareAccessInterface(AccessInterfaceaccess);30 public abstract Access prepareAccess(Access access); 31 31 32 32 public abstract String computeAccessId(); -
java/main/src/main/java/com/framsticks/params/FramsClass.java
r99 r100 13 13 import javax.annotation.concurrent.Immutable; 14 14 15 import org.apache.log4j.Logger; 15 import org.apache.logging.log4j.Logger; 16 import org.apache.logging.log4j.LogManager; 16 17 17 18 /** … … 31 32 public class FramsClass { 32 33 33 private final static Logger log = Log ger.getLogger(FramsClass.class);34 private final static Logger log = LogManager.getLogger(FramsClass.class); 34 35 35 36 protected final String id; … … 73 74 } 74 75 75 log.trace("created framsclass " +this);76 log.trace("created framsclass {}", this); 76 77 77 78 } -
java/main/src/main/java/com/framsticks/params/FramsClassBuilder.java
r99 r100 14 14 import java.util.Map; 15 15 16 import org.apache.log4j.Logger; 16 import org.apache.logging.log4j.Logger; 17 import org.apache.logging.log4j.LogManager; 17 18 18 19 import com.framsticks.params.annotations.AutoAppendAnnotation; … … 29 30 public class FramsClassBuilder implements Builder<FramsClass> { 30 31 private static final Logger log = 31 Log ger.getLogger(FramsClassBuilder.class);32 LogManager.getLogger(FramsClassBuilder.class); 32 33 33 34 public static String getName(FramsClassAnnotation fca, Class<?> javaClass) { … … 75 76 //TODO parametrize this 76 77 if (map) { 77 b.append(" name");78 b.append(" uid"); 78 79 } 79 80 … … 224 225 } 225 226 226 log.debug("building for class " +javaClass);227 log.debug("building for class {}", javaClass); 227 228 228 229 FramsClassAnnotation fca = javaClass.getAnnotation(FramsClassAnnotation.class); -
java/main/src/main/java/com/framsticks/params/ListAccess.java
r99 r100 7 7 import com.framsticks.params.types.EventParam; 8 8 import com.framsticks.params.types.ProcedureParam; 9 import com.framsticks.util.UnimplementedException; 9 10 10 11 /** 11 12 * @author Piotr Sniegowski 12 13 */ 13 public abstract class ListAccess implements Access Interface{14 public abstract class ListAccess implements Access { 14 15 15 final Access InterfaceelementAccess;16 final Access elementAccess; 16 17 final String containedTypeName; 17 18 18 19 protected final ParamBuilder paramBuilder; 19 20 20 public ListAccess(Access InterfaceelementAccess) {21 public ListAccess(Access elementAccess) { 21 22 this.elementAccess = elementAccess; 22 23 this.containedTypeName = elementAccess.getId(); … … 66 67 @Override 67 68 public void load(SourceInterface stream) { 69 throw new UnimplementedException().msg("load in list access"); 68 70 } 69 71 70 public Access InterfacegetElementAccess() {72 public Access getElementAccess() { 71 73 return elementAccess; 72 74 } … … 120 122 return b.toString(); 121 123 } 124 125 public CompositeParam prepareParamFor(String id) { 126 return paramBuilder.id(id).finish(CompositeParam.class); 127 } 122 128 }; -
java/main/src/main/java/com/framsticks/params/ParamBuilder.java
r99 r100 10 10 import com.framsticks.util.lang.Strings; 11 11 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import java.lang.reflect.InvocationTargetException; … … 32 33 @FramsClassAnnotation(name = "prop", id = "prop") 33 34 public class ParamBuilder implements Builder<Param> { 34 private final static Logger log = Log ger.getLogger(ParamBuilder.class.getName());35 private final static Logger log = LogManager.getLogger(ParamBuilder.class.getName()); 35 36 36 37 private static final String ID_FIELD = "id"; … … 265 266 assert type != null; 266 267 267 log.trace("parsing type: " +type);268 log.trace("parsing type: {}", type); 268 269 269 270 String[] typeSplitted = type.split(" "); … … 301 302 } 302 303 default: { 303 log.error("unknown type: " +first);304 log.error("unknown type: {}", first); 304 305 return this; 305 306 } … … 349 350 } 350 351 default: { 351 log.error("unknown type: " +first);352 log.error("unknown type: {}", first); 352 353 return this; 353 354 } … … 445 446 446 447 if (paramEntryValues.length == 0) { 447 log.warn("field empty or wrong format (" + line 448 + ") - omitting"); 448 log.warn("field empty or wrong format ({}) - omitting", line); 449 449 return null; 450 450 } … … 464 464 /** everything is ok, parameters have just finished*/ 465 465 } catch (NumberFormatException ex) { 466 log.warn("wrong format of entry: " + line 467 + ", omitting"); 466 log.warn("wrong format of entry: {}, omitting", line); 468 467 return null; 469 468 } … … 492 491 break; 493 492 default: 494 log.error("unknown field for Param: " +key);493 log.error("unknown field for Param: {}", key); 495 494 break; 496 495 } -
java/main/src/main/java/com/framsticks/params/ParamCandidate.java
r99 r100 213 213 return false; 214 214 } 215 if (Collection.class.isAssignableFrom(getRawType())) {216 return false;217 }218 if (setter.has()) {219 return false;220 }221 215 if (field.has()) { 222 216 return Modifier.isFinal(field.get().getModifiers()); 217 } 218 if (setter.has()) { 219 return false; 220 } 221 if (Collection.class.isAssignableFrom(getRawType())) { 222 return false; 223 223 } 224 224 return true; -
java/main/src/main/java/com/framsticks/params/PropertiesAccess.java
r99 r100 76 76 @Override 77 77 public PropertiesAccess select(Object object) { 78 this.properties = (Map<String, Object>)object;78 properties = Util.selectObjectForAccess(this, object, Map.class); 79 79 return this; 80 80 } … … 116 116 } 117 117 118 @Override 119 public String toString() { 120 StringBuilder b = new StringBuilder(); 121 b.append(framsClass); 122 if (getSelected() != null) { 123 b.append("(").append(getSelected().size()).append(")"); 124 } 125 return b.toString(); 126 } 118 127 } -
java/main/src/main/java/com/framsticks/params/ReflectionAccess.java
r99 r100 14 14 import javax.annotation.concurrent.Immutable; 15 15 16 import org.apache.log4j.Logger; 16 import org.apache.logging.log4j.Logger; 17 import org.apache.logging.log4j.LogManager; 17 18 18 19 import com.framsticks.params.annotations.AutoAppendAnnotation; … … 33 34 */ 34 35 public class ReflectionAccess extends SimpleAbstractAccess { 35 private final static Logger log = Log ger.getLogger(ReflectionAccess.class.getName());36 private final static Logger log = LogManager.getLogger(ReflectionAccess.class.getName()); 36 37 37 38 protected final Class<?> javaClass; … … 88 89 } 89 90 90 log.debug("constructing backend for " +id);91 log.debug("constructing backend for {}", id); 91 92 backend = new Backend(); 92 93 … … 96 97 for (final ProcedureParam pp : filterInstanceof(framsClass.getParamEntries(), ProcedureParam.class)) { 97 98 if (!candidates.containsKey(pp.getId())) { 98 log.trace("java class does implement method " +pp);99 log.trace("java class does implement method {}", pp); 99 100 continue; 100 101 } … … 114 115 for (final EventParam ep : filterInstanceof(framsClass.getParamEntries(), EventParam.class)) { 115 116 if (!candidates.containsKey(ep.getId())) { 116 log.trace("java class does not implement the event param " +ep);117 log.trace("java class does not implement the event param {}", ep); 117 118 continue; 118 119 } … … 312 313 if (s == null) { 313 314 throw new FramsticksException().msg("trying to set unsettable"); 315 // return; 316 // if (value != backend.getters.get(param).get(object, Object.class)) { 317 // } 314 318 } 315 319 s.set(object, value); … … 412 416 @Override 413 417 public ReflectionAccess select(Object object) { 414 assert object == null || javaClass.isInstance(object); 415 this.object = object; 418 this.object = Util.selectObjectForAccess(this, object, javaClass); 416 419 return this; 417 420 } … … 447 450 e.printStackTrace(); 448 451 } 449 log.fatal("failed to create reflected object of class " + javaClass.getCanonicalName() + " for frams type " +framsClass.getId());452 log.fatal("failed to create reflected object of class {} for frams type {}", javaClass.getCanonicalName(), framsClass.getId()); 450 453 return null; 451 454 } … … 459 462 if (m.getParameterTypes()[0].isAssignableFrom(value.getClass())) { 460 463 try { 461 log.trace("auto appending with value " + value + " with method " +m);464 log.trace("auto appending with value {} with method {}", value, m); 462 465 m.invoke(object, value); 463 466 return; … … 474 477 } 475 478 479 @Override 480 public String toString() { 481 StringBuilder b = new StringBuilder(); 482 b.append(framsClass); 483 if (getSelected() != null) { 484 b.append("(").append(getSelected()).append(")"); 485 } 486 return b.toString(); 487 } 476 488 } 477 489 -
java/main/src/main/java/com/framsticks/params/Registry.java
r99 r100 1 1 package com.framsticks.params; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.params.annotations.FramsClassAnnotation; … … 20 21 @FramsClassAnnotation 21 22 public class Registry { 22 private static final Logger log = Log ger.getLogger(Registry.class.getName());23 private static final Logger log = LogManager.getLogger(Registry.class.getName()); 23 24 24 25 protected final DoubleMap<String, Class<?>> javaClasses = new DoubleMap<>(); … … 84 85 } 85 86 86 public @Nonnull Access InterfacecreateAccess(String name, FramsClass framsClass) throws ConstructionException {87 public @Nonnull Access createAccess(String name, FramsClass framsClass) throws ConstructionException { 87 88 // assert framsClasses.containsValue(framsClass); 88 89 if (javaClasses.containsKey(name)) { … … 93 94 94 95 public FramsClass putFramsClass(FramsClass framsClass) { 95 log.debug("caching info for " +framsClass);96 log.debug("caching info for {}", framsClass); 96 97 framsClasses.put(framsClass.getId(), framsClass.getName(), framsClass); 97 98 return framsClass; 99 } 100 101 public FramsClass getFramsClass(@Nonnull CompositeParam param) { 102 return framsClasses.get(param.getContainedTypeName()); 98 103 } 99 104 … … 102 107 } 103 108 104 public static @Nonnull Access Interface wrapAccessWithListIfNeeded(@Nonnull CompositeParam param, @Nonnull AccessInterfaceaccess) {105 return param.prepareAccess Interface(access);109 public static @Nonnull Access wrapAccessWithListIfNeeded(@Nonnull CompositeParam param, @Nonnull Access access) { 110 return param.prepareAccess(access); 106 111 } 107 112 108 public @Nonnull Access InterfaceprepareAccess(CompositeParam param) throws ConstructionException {113 public @Nonnull Access prepareAccess(CompositeParam param) throws ConstructionException { 109 114 return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName())); 110 115 } 111 116 112 public @Nonnull Access InterfacecreateAccess(@Nonnull String name) throws ConstructionException {117 public @Nonnull Access createAccess(@Nonnull String name) throws ConstructionException { 113 118 try { 114 119 Strings.assureNotEmpty(name); -
java/main/src/main/java/com/framsticks/params/SimpleAbstractAccess.java
r99 r100 4 4 import static com.framsticks.util.lang.Containers.filterInstanceof; 5 5 6 import org.apache.log4j.Logger; 6 import org.apache.logging.log4j.Logger; 7 import org.apache.logging.log4j.LogManager; 7 8 8 9 import com.framsticks.params.types.ObjectParam; … … 11 12 12 13 /** 13 * The Class SimpleAbstractAccess implements all the methods of Access Interface14 * which actions can be implemented with usage of {@link Access Interface} methods14 * The Class SimpleAbstractAccess implements all the methods of Access 15 * which actions can be implemented with usage of {@link Access} methods 15 16 * or concern schema, which is stored in {@link #framsClass} 16 17 * … … 22 23 * @author Piotr Sniegowski 23 24 */ 24 public abstract class SimpleAbstractAccess implements Access Interface{25 26 private final static Logger log = Log ger.getLogger(SimpleAbstractAccess.class.getName());25 public abstract class SimpleAbstractAccess implements Access { 26 27 private final static Logger log = LogManager.getLogger(SimpleAbstractAccess.class.getName()); 27 28 28 29 protected final FramsClass framsClass; … … 190 191 } 191 192 192 private Entry readEntry(SourceInterface source) {193 private static Entry readEntry(SourceInterface source) { 193 194 194 195 String line; 195 196 String key = null; 196 197 StringBuilder value = null; 197 while ((line = source.readLine()) != null) 198 { 198 while ((line = source.readLine()) != null) { 199 199 if (key == null) { 200 200 int colonIndex = line.indexOf(':'); … … 216 216 value.append(System.getProperty("line.separator")); 217 217 } 218 if (line. contains("~")) {219 value.append(line.substring(0, line. indexOf("~")));220 return new Entry(key, value.toString() );218 if (line.endsWith("~") && !line.endsWith("\\~")) { 219 value.append(line.substring(0, line.length() - 1)); 220 return new Entry(key, value.toString().replaceAll("\\\\~", "~")); 221 221 } 222 222 value.append(line); 223 /*224 if (line.contains("~")) {225 String lastLine = line.substring(0, line.indexOf("~"));226 if (lastLine.length() > 0) {227 appendToValue(value, lastLine);228 }229 return new Entry(key, value.toString());230 }231 appendToValue(value, line);232 */233 223 } 234 224 return null; … … 244 234 Param param = getParam(entry.key); 245 235 if (param == null) { 246 continue;236 throw new FramsticksException().msg("param not found in access").arg("name", entry.key).arg("access", this); 247 237 } 248 238 if (!(param instanceof ValueParam)) { 249 log.warn("param " + param + " is not a ValueParam"); 250 continue; 251 } 252 if ((param.getFlags() & ParamFlags.DONTLOAD) != 0) { 253 log.debug("DontLoad flag was set - not loading..."); 254 } else { 239 throw new FramsticksException().msg("param is not a value param").arg("param", param).arg("access", this); 240 } 241 if ((param.getFlags() & ParamFlags.DONTLOAD) == 0) { 255 242 int retFlags = this.set((ValueParam) param, entry.value); 256 243 if ((retFlags & (PSET_HITMIN | PSET_HITMAX)) != 0) { 257 244 String which = ((retFlags & PSET_HITMIN) != 0) ? "small" : "big"; 258 log.warn("value of key ' " + entry.key + "' was too " + which + ", adjusted");245 log.warn("value of key '{}' was too {}, adjusted", entry.key, which); 259 246 } 260 247 } … … 297 284 }*/ 298 285 299 @Override300 public String toString() {301 StringBuilder b = new StringBuilder();302 b.append(framsClass);303 if (getSelected() != null) {304 b.append("(").append(getSelected()).append(")");305 }306 return b.toString();307 }308 286 309 287 @Override -
java/main/src/main/java/com/framsticks/params/UniqueListAccess.java
r99 r100 7 7 import com.framsticks.util.lang.Casting; 8 8 import com.framsticks.util.lang.Numbers; 9 import org.apache.log4j.Logger; 9 import org.apache.logging.log4j.Logger; 10 import org.apache.logging.log4j.LogManager; 10 11 11 12 import java.util.*; … … 16 17 public class UniqueListAccess extends ListAccess { 17 18 18 private static final Logger log = Log ger.getLogger(UniqueListAccess.class);19 private static final Logger log = LogManager.getLogger(UniqueListAccess.class); 19 20 20 21 Map<String, Object> map; 21 22 22 final String uidName; 23 24 public UniqueListAccess(AccessInterface elementAccess, String uidName) { 23 protected final String uidName; 24 protected final Access uidAccess; 25 26 public UniqueListAccess(Access elementAccess, String uidName) { 25 27 super(elementAccess); 26 28 this.uidName = uidName; 29 uidAccess = elementAccess.cloneAccess(); 27 30 } 28 31 … … 35 38 } 36 39 40 /** 41 * @return the uidName 42 */ 43 public String getUidName() { 44 return uidName; 45 } 46 37 47 public static class UidComparator implements Comparator<String> { 38 48 39 protected String name; 49 protected Object description; 50 40 51 41 52 /** 42 * @param name53 * @param description 43 54 */ 44 public UidComparator( String name) {45 this. name = name;55 public UidComparator(Object description) { 56 this.description = description; 46 57 } 47 58 … … 65 76 @Override 66 77 public String toString() { 67 return "comparator " + name; 68 } 69 70 78 return "comparator " + description; 79 } 80 81 82 } 83 84 public static <T> Map<String, T> createMap(Class<T> type, Object description) { 85 return new TreeMap<String, T>(new UidComparator(description)); 86 } 87 88 public static <M, T extends M> int getNumberInMap(Map<String, M> map, T object) { 89 Iterator<Map.Entry<String, M>> iterator = map.entrySet().iterator(); 90 int number = 0; 91 while (iterator.hasNext()) { 92 if (iterator.next().getValue() == object) { 93 return number; 94 } 95 ++number; 96 } 97 return -1; 71 98 } 72 99 73 100 @Override 74 101 public Map<String, Object> createAccessee() { 75 return new TreeMap<String, Object>(new UidComparator(elementAccess.toString()));102 return createMap(Object.class, elementAccess); 76 103 } 77 104 … … 92 119 return null; 93 120 } 94 return paramBuilder.id( getUidOf(iterator.next().getValue())).finish(CompositeParam.class);121 return paramBuilder.id(iterator.next().getKey()).finish(CompositeParam.class); 95 122 } 96 123 … … 110 137 return paramBuilder.id(id).finish(CompositeParam.class); 111 138 } 139 112 140 113 141 @Override … … 156 184 157 185 public String getUidOf(Object value) { 158 Object tmp = elementAccess.getSelected(); 159 elementAccess.select(value); 160 String uid = elementAccess.get(uidName, String.class); 161 elementAccess.select(tmp); 162 return uid; 186 return uidAccess.select(value).get(uidName, String.class); 163 187 } 164 188 … … 227 251 @Override 228 252 public UniqueListAccess select(Object object) { 229 assert (object instanceof Map); 230 map = (Map<String, Object>) object; 253 map = Util.selectObjectForAccess(this, object, Map.class); 231 254 return this; 232 255 } … … 242 265 } 243 266 244 public String computeIdentifierFor(Object selected) {245 String uid = getUidOf(selected);246 if (uid == null) {247 log.error("missing uid field");248 return null;249 }250 return uid;251 }267 // public String computeIdentifierFor(Object selected) { 268 // String uid = getUidOf(selected); 269 // if (uid == null) { 270 // log.error("missing uid field"); 271 // return null; 272 // } 273 // return uid; 274 // } 252 275 253 276 @Override -
java/main/src/main/java/com/framsticks/params/Util.java
r99 r100 24 24 } 25 25 26 public static <T> List<T> stripAccess Interface(List<AccessInterface> accesses, Class<T> type) {26 public static <T> List<T> stripAccess(List<Access> accesses, Class<T> type) { 27 27 List<T> result = new ArrayList<T>(); 28 for (Access Interfacea : accesses) {28 for (Access a : accesses) { 29 29 Object object = a.getSelected(); 30 30 if (!type.isInstance(object)) { … … 36 36 } 37 37 38 public static int takeAllNonNullValues(Access Interface to, AccessInterfacefrom) {38 public static int takeAllNonNullValues(Access to, Access from) { 39 39 int copied = 0; 40 40 for (ValueParam f : filterInstanceof(from.getParams(), ValueParam.class)) { … … 43 43 continue; 44 44 } 45 // if (to.get(f, Object.class) != null) { 46 // continue; 47 // } 45 48 to.set(f, v); 46 49 ++copied; … … 49 52 } 50 53 51 public static int copyExistingParamsTypeSafe(Access Interface to, AccessInterfacefrom) {54 public static int copyExistingParamsTypeSafe(Access to, Access from) { 52 55 int copied = 0; 53 56 for (ValueParam f : filterInstanceof(from.getParams(), ValueParam.class)) { … … 65 68 } 66 69 70 public static <T> T selectObjectForAccess(Access access, Object object, Class<T> type) { 71 if (object == null) { 72 return null; 73 } 74 if (!type.isInstance(object)) { 75 throw new FramsticksException().msg("trying to select object of wrong type").arg("object", object).arg("type", object.getClass()).arg("in", access); 76 } 77 return type.cast(object); 78 } 79 80 public static int getNumberOfCompositeParamChild(Access access, Object child) { 81 int count = access.getCompositeParamCount(); 82 for (int i = 0; i < count; ++i) { 83 if (access.get(i, Object.class) == child) { 84 return i; 85 } 86 } 87 return -1; 88 } 89 67 90 } -
java/main/src/main/java/com/framsticks/params/types/ArrayListParam.java
r87 r100 1 1 package com.framsticks.params.types; 2 2 3 import com.framsticks.params.Access Interface;3 import com.framsticks.params.Access; 4 4 import com.framsticks.params.ArrayListAccess; 5 5 import com.framsticks.params.CastFailure; … … 7 7 import com.framsticks.params.ReassignResult; 8 8 import com.framsticks.util.lang.Casting; 9 import com.framsticks.util.lang.Containers;10 9 import com.framsticks.util.lang.Numbers; 11 10 12 import java.util.ArrayList;13 11 import java.util.List; 14 12 … … 32 30 33 31 @Override 34 public Access Interface prepareAccessInterface(AccessInterfaceaccess) {32 public Access prepareAccess(Access access) { 35 33 return new ArrayListAccess(access); 36 34 } … … 49 47 if (size != null) { 50 48 //return oldValue; 51 List<?> list; 52 if (oldValue == null) { 53 list = new ArrayList<Object>(); 54 } else { 55 list = Casting.tryCast(List.class, oldValue); 56 if (list == null) { 57 throw new CastFailure(); 58 } 59 } 60 Containers.resizeList(list, size); 61 return new ReassignResult<List<?>>(list); 49 // List<?> list; 50 // if (oldValue == null) { 51 // list = new ArrayList<Object>(); 52 // } else { 53 // list = Casting.tryCast(List.class, oldValue); 54 // if (list == null) { 55 // throw new CastFailure(); 56 // } 57 // } 58 // Containers.resizeList(list, size); 59 return new ReassignResult<List<?>>(Casting.tryCast(List.class, oldValue)); 60 // return new ReassignResult<List<?>>(list); 62 61 } 63 if (oldValue != null) {64 return new ReassignResult<List<?>>(Casting.throwCast(List.class, oldValue));65 }62 // if (oldValue != null) { 63 // return new ReassignResult<List<?>>(Casting.throwCast(List.class, oldValue)); 64 // } 66 65 return new ReassignResult<List<?>>(Casting.throwCast(List.class, newValue)); 67 66 } -
java/main/src/main/java/com/framsticks/params/types/ObjectParam.java
r98 r100 1 1 package com.framsticks.params.types; 2 2 3 import com.framsticks.params.Access Interface;3 import com.framsticks.params.Access; 4 4 import com.framsticks.params.CastFailure; 5 5 import com.framsticks.params.CompositeParam; … … 41 41 42 42 @Override 43 public Access Interface prepareAccessInterface(AccessInterfaceaccess) {43 public Access prepareAccess(Access access) { 44 44 return access; 45 45 } -
java/main/src/main/java/com/framsticks/params/types/UniqueListParam.java
r98 r100 1 1 package com.framsticks.params.types; 2 2 3 import com.framsticks.params.Access Interface;3 import com.framsticks.params.Access; 4 4 import com.framsticks.params.CastFailure; 5 5 import com.framsticks.params.ParamBuilder; … … 38 38 39 39 @Override 40 public Access Interface prepareAccessInterface(AccessInterfaceaccess) {40 public Access prepareAccess(Access access) { 41 41 return new UniqueListAccess(access, uidName); 42 42 } -
java/main/src/main/java/com/framsticks/parsers/F0Parser.java
r99 r100 21 21 import com.framsticks.util.lang.Pair; 22 22 import com.framsticks.util.lang.Strings; 23 import org.apache.log4j.Logger; 23 import org.apache.logging.log4j.Logger; 24 import org.apache.logging.log4j.LogManager; 24 25 25 26 import com.framsticks.params.FramsClass; 26 import com.framsticks.params.Access Interface;27 import com.framsticks.params.Access; 27 28 import static com.framsticks.params.ParamFlags.*; 28 29 import static com.framsticks.params.SetStateFlags.*; … … 33 34 public class F0Parser { 34 35 35 private final static Logger log = Log ger.getLogger(F0Parser.class);36 private final static Logger log = LogManager.getLogger(F0Parser.class); 36 37 37 38 /** The schema proper for f0 representation. */ 38 39 protected final Schema schema; 39 40 protected final InputStream is; 40 protected final List<Access Interface> result = new ArrayList<AccessInterface>();41 protected final List<Access> result = new ArrayList<Access>(); 41 42 int lineNumber = 0; 42 43 … … 48 49 } 49 50 50 protected Access InterfaceprocessLine(String line) {51 protected Access processLine(String line) { 51 52 try { 52 53 … … 57 58 throw new Exception("unknown class id: " + classId); 58 59 } 59 Access Interfaceaccess = schema.getRegistry().createAccess(classId, framsClass);60 Access access = schema.getRegistry().createAccess(classId, framsClass); 60 61 access.select(access.createAccessee()); 61 62 for (Exception e : loadFromLine(access, p.second)) { … … 84 85 * the parse exception 85 86 */ 86 public List<Access Interface> parse() {87 public List<Access> parse() { 87 88 88 89 try (InputStreamReader reader = new InputStreamReader(is, Encoding.getDefaultCharset())) { … … 105 106 continue; 106 107 } 107 Access Interfaceaccess = processLine(line);108 Access access = processLine(line); 108 109 if (access != null) { 109 110 result.add(access); … … 123 124 124 125 private static void warn(int lineNumber, String message, Exception e) { 125 log.warn("in line " + lineNumber + " the following error occurred (" + message + "): " +e);126 log.warn("in line {} the following error occurred ({}): {}", lineNumber, message, e); 126 127 } 127 128 … … 170 171 } 171 172 172 public List<Exception> loadFromLine(Access Interfaceaccess, String parameters) throws Exception {173 public List<Exception> loadFromLine(Access access, String parameters) throws Exception { 173 174 174 175 List<Entry> entries = breakIntoEntries(parameters); … … 250 251 } 251 252 252 private static Exception createBoundaryHitException(Access Interfaceaccess, PrimitiveParam<?> param, String value, int flag) {253 private static Exception createBoundaryHitException(Access access, PrimitiveParam<?> param, String value, int flag) { 253 254 boolean minimum = (flag & PSET_HITMIN) != 0; 254 255 String boundary = (minimum ? param.getMin(Object.class) : param.getMax(Object.class)).toString(); -
java/main/src/main/java/com/framsticks/parsers/F0Writer.java
r99 r100 30 30 } 31 31 32 protected void write(Access Interfaceaccess) {32 protected void write(Access access) { 33 33 if (access instanceof ListAccess) { 34 34 // TODO … … 45 45 for (ValueParam param : filterInstanceof(access.getParams(), ValueParam.class)) { 46 46 if (param instanceof CompositeParam) { 47 Access Interfacea = schema.getRegistry().prepareAccess((CompositeParam) param);47 Access a = schema.getRegistry().prepareAccess((CompositeParam) param); 48 48 a.select(access.get((ValueParam) param, Object.class)); 49 49 write(a); … … 81 81 82 82 public void write() { 83 Access Interfaceaccess = schema.getRegistry().createAccess("m");83 Access access = schema.getRegistry().createAccess("m"); 84 84 access.select(model); 85 85 write(access); -
java/main/src/main/java/com/framsticks/parsers/GenotypeLoader.java
r99 r100 5 5 import com.framsticks.params.types.*; 6 6 7 import org.apache.log4j.Logger; 7 import org.apache.logging.log4j.Logger; 8 import org.apache.logging.log4j.LogManager; 8 9 import static com.framsticks.params.ParamFlags.*; 9 10 10 11 public class GenotypeLoader extends MultiParamLoader { 11 12 private Genotype genotypeReturnObject = new Genotype(); 12 private static Logger logger = Log ger.getLogger(GenotypeLoader.class);13 private static Logger logger = LogManager.getLogger(GenotypeLoader.class); 13 14 14 15 public GenotypeLoader() throws Exception { … … 54 55 .finish(); 55 56 56 Access InterfacereflectionParam = new PropertiesAccess(entries);57 addAccess Interface(reflectionParam);57 Access reflectionParam = new PropertiesAccess(entries); 58 addAccess(reflectionParam); 58 59 addBreakCondition(Status.AfterObject); 59 60 } -
java/main/src/main/java/com/framsticks/parsers/Loaders.java
r96 r100 4 4 5 5 import com.framsticks.params.*; 6 // import org.apache.log 4j.Logger;6 // import org.apache.logging.log4j.Logger; 7 7 8 8 /** … … 11 11 public class Loaders { 12 12 13 // private static final Logger log = Log ger.getLogger(Loaders.class.getName());13 // private static final Logger log = LogManager.getLogger(Loaders.class.getName()); 14 14 15 15 public static @Nonnull FramsClass loadFramsClass(SourceInterface source) throws ConstructionException { … … 19 19 final FramsClassBuilder builder = FramsClass.build(); 20 20 21 final Access InterfaceframsClassAccess = new ReflectionAccess(FramsClassBuilder.class, FramsClass.build().forClass(FramsClassBuilder.class));22 Access InterfaceparamBuilderAccess = new ReflectionAccess(ParamBuilder.class, FramsClass.build().forClass(ParamBuilder.class));21 final Access framsClassAccess = new ReflectionAccess(FramsClassBuilder.class, FramsClass.build().forClass(FramsClassBuilder.class)); 22 Access paramBuilderAccess = new ReflectionAccess(ParamBuilder.class, FramsClass.build().forClass(ParamBuilder.class)); 23 23 framsClassAccess.select(builder); 24 loader.addAccess Interface(framsClassAccess);25 loader.addAccess Interface(paramBuilderAccess);24 loader.addAccess(framsClassAccess); 25 loader.addAccess(paramBuilderAccess); 26 26 27 27 loader.addListener(MultiParamLoader.Status.AfterObject, new MultiParamLoader.StatusListener() { -
java/main/src/main/java/com/framsticks/parsers/MultiParamLoader.java
r97 r100 2 2 3 3 import com.framsticks.params.*; 4 import org.apache.log4j.Logger; 4 import org.apache.logging.log4j.Logger; 5 import org.apache.logging.log4j.LogManager; 5 6 6 7 import java.util.*; … … 12 13 } 13 14 14 private final static Logger log = Log ger.getLogger(MultiParamLoader.class);15 private final static Logger log = LogManager.getLogger(MultiParamLoader.class); 15 16 16 17 /** … … 18 19 * should be passed. 19 20 */ 20 public Access Interface getLastAccessInterface() {21 return lastAccess Interface;21 public Access getLastAccess() { 22 return lastAccess; 22 23 } 23 24 … … 39 40 } 40 41 41 protected Access Interface lastAccessInterface;42 protected Access lastAccess; 42 43 43 44 protected static final FramsClass emptyFramsClass = FramsClass.build().idAndName("<empty>").finish(); … … 46 47 * objects in the file. 47 48 */ 48 protected Access InterfaceemptyParam = new PropertiesAccess(emptyFramsClass);49 protected Access emptyParam = new PropertiesAccess(emptyFramsClass); 49 50 50 51 /** … … 87 88 * List of known classes. 88 89 */ 89 private Map<String, Access Interface> knownParamInterfaces = new HashMap<String, AccessInterface>();90 private Map<String, Access> knownParamInterfaces = new HashMap<String, Access>(); 90 91 91 92 /** … … 132 133 } 133 134 } 134 log.trace("read line: " +currentLine);135 log.trace("read line: {}", currentLine); 135 136 136 137 // empty line … … 158 159 } 159 160 160 // log.warn("unknown line: " +currentLine);161 // log.warn("unknown line: {}", currentLine); 161 162 changeStatus(Status.OnError); 162 163 if (action == LoopAction.Break) { … … 177 178 */ 178 179 private LoopAction tryReadObject() { 179 if (status == Status.BeforeObject 180 || (status == Status.BeforeUnknown && lastAccessInterface != null)) { 180 if (status == Status.BeforeObject || (status == Status.BeforeUnknown && lastAccess != null)) { 181 181 // found object - let it load data 182 if (lastAccess Interface.getSelected() == null) {183 lastAccess Interface.select(lastAccessInterface.createAccessee());184 } 185 log.trace("loading into " + lastAccessInterface);186 lastAccess Interface.load(currentSource);182 if (lastAccess.getSelected() == null) { 183 lastAccess.select(lastAccess.createAccessee()); 184 } 185 log.trace("loading into {}", lastAccess); 186 lastAccess.load(currentSource); 187 187 188 188 if (changeStatus(Status.AfterObject)) { … … 191 191 return LoopAction.Continue; 192 192 } else if (status == Status.BeforeUnknown) { 193 log.warn("omitting unknown object: " +lastUnknownObjectName);193 log.warn("omitting unknown object: {}", lastUnknownObjectName); 194 194 195 195 // found unknown object … … 262 262 if (line.charAt(line.length() - 1) == ':') { 263 263 String typeName = line.substring(0, line.length() - 1); 264 lastAccess Interface= knownParamInterfaces.get(typeName);265 266 if (lastAccess Interface!= null) {264 lastAccess = knownParamInterfaces.get(typeName); 265 266 if (lastAccess != null) { 267 267 if (changeStatus(Status.BeforeObject)) { 268 268 return LoopAction.Break; … … 299 299 * Adds another class. 300 300 */ 301 public void addAccess Interface(AccessInterface accessInterface) {301 public void addAccess(Access access) { 302 302 /**TODO: by id or by name? rather by id, because from file is always lowercase*/ 303 knownParamInterfaces.put(access Interface.getId(), accessInterface);303 knownParamInterfaces.put(access.getId(), access); 304 304 } 305 305 … … 325 325 326 326 public boolean setNewSource(SourceInterface source) { 327 log.debug("switching current source to " + source.getFilename() + "...");327 log.debug("switching current source to {}...", source.getFilename()); 328 328 329 329 currentSource = source; … … 345 345 // check if it is already included and break if it is 346 346 if (isAlreadyIncluded(includeFilename)) { 347 log.debug("circular reference ignored (" + includeFilename 348 + ")"); 347 log.debug("circular reference ignored ({})", includeFilename); 349 348 return; 350 349 } 351 350 352 log.info("including file " + includeFilename + "...");351 log.info("including file {}...", includeFilename); 353 352 354 353 SourceInterface newSource = currentSource.openInclude(includeFilename); … … 369 368 for (String file : fileStack) { 370 369 if (filename.equals(file)) { 371 log.warn("file " + filename + " was already included");370 log.warn("file {} was already included", filename); 372 371 return true; 373 372 } … … 400 399 */ 401 400 private boolean changeStatus(Status status) { 402 log.trace("changing status: " + this.status.toString() + " -> " +status.toString());401 log.trace("changing status: {} -> {}", this.status.toString(), status.toString()); 403 402 this.status = status; 404 403 if (listeners.containsKey(status)) { … … 411 410 412 411 public Object returnObject() { 413 assert lastAccess Interface!= null;414 Object result = lastAccess Interface.getSelected();412 assert lastAccess != null; 413 Object result = lastAccess.getSelected(); 415 414 if (result == null) { 416 415 return null; 417 416 } 418 lastAccess Interface.select(null);417 lastAccess.select(null); 419 418 return result; 420 419 } … … 426 425 listeners.get(status).add(listener); 427 426 } 427 428 public static List<Object> loadAll(SourceInterface source, Access access) { 429 final List<Object> result = new LinkedList<>(); 430 431 final MultiParamLoader loader = new MultiParamLoader(); 432 loader.setNewSource(source); 433 loader.addAccess(access); 434 loader.addListener(MultiParamLoader.Status.AfterObject, new StatusListener() { 435 @Override 436 public void onStatusChange() { 437 result.add(loader.returnObject()); 438 } 439 }); 440 loader.go(); 441 return result; 442 } 428 443 } -
java/main/src/main/java/com/framsticks/parsers/Savers.java
r96 r100 10 10 public static <S extends SinkInterface> S saveFramsClass(S sink, FramsClass framsClass) { 11 11 12 Access InterfaceframsClassAccess = new ReflectionAccess(FramsClass.class);13 Access InterfaceparamAccess = new ReflectionAccess(Param.class);12 Access framsClassAccess = new ReflectionAccess(FramsClass.class); 13 Access paramAccess = new ReflectionAccess(Param.class); 14 14 framsClassAccess.select(framsClass); 15 15 framsClassAccess.save(sink); -
java/main/src/main/java/com/framsticks/parsers/XmlLoader.java
r99 r100 1 1 package com.framsticks.parsers; 2 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileNotFoundException; 3 6 import java.io.InputStream; 4 7 import java.util.LinkedList; … … 8 11 import javax.xml.parsers.DocumentBuilderFactory; 9 12 10 import org.apache.log4j.Logger; 13 import org.apache.logging.log4j.Logger; 14 import org.apache.logging.log4j.LogManager; 11 15 import org.w3c.dom.Document; 12 16 import org.w3c.dom.Element; … … 15 19 import org.w3c.dom.NodeList; 16 20 17 import com.framsticks.params.Access Interface;21 import com.framsticks.params.Access; 18 22 import com.framsticks.params.Registry; 19 23 import com.framsticks.util.AutoBuilder; … … 22 26 23 27 public class XmlLoader { 24 private static final Logger log = Log ger.getLogger(XmlLoader.class);28 private static final Logger log = LogManager.getLogger(XmlLoader.class); 25 29 26 30 protected Registry registry = new Registry(); … … 30 34 */ 31 35 public XmlLoader() { 36 registry.registerAndBuild(AutoInjector.class); 32 37 } 33 38 … … 56 61 } 57 62 58 public Object processElement(Element element ) {63 public Object processElement(Element element, Class<?> enclosingClass) { 59 64 final String name = mangleName(element.getNodeName()); 60 65 if (name.equals("import")) { … … 67 72 } 68 73 } 74 if (name.equals("include")) { 75 String fileName = element.getAttribute("file"); 76 if (Strings.notEmpty(fileName)) { 77 try { 78 return load(new FileInputStream(new File(fileName)), enclosingClass); 79 } catch (FileNotFoundException e) { 80 throw new FramsticksException().msg("failed to include file").arg("file", fileName).cause(e); 81 } 82 } 83 String resourceName = element.getAttribute("resource"); 84 if (Strings.notEmpty(resourceName)) { 85 Class<?> javaClass = enclosingClass; 86 String className = element.getAttribute("class"); 87 if (Strings.notEmpty(className)) { 88 try { 89 javaClass = Class.forName(className); 90 } catch (ClassNotFoundException e) { 91 throw new FramsticksException().msg("failed to find class for resource loading").arg("class name", className).cause(e); 92 } 93 } 69 94 70 AccessInterface access = registry.createAccess(name); 95 return load(javaClass.getResourceAsStream(resourceName), enclosingClass); 96 } 97 throw new FramsticksException().msg("invalid <include/> node"); 98 } 99 100 Access access = registry.createAccess(name); 71 101 72 102 Object object = access.createAccessee(); … … 81 111 82 112 NodeList children = element.getChildNodes(); 83 log.debug("found " + children.getLength() + " children in " +object);113 log.debug("found {} children in {}", children.getLength(), object); 84 114 for (int i = 0; i < children.getLength(); ++i) { 85 115 Node childNode = children.item(i); … … 87 117 continue; 88 118 } 89 Object childObject = processElement((Element) childNode );119 Object childObject = processElement((Element) childNode, object.getClass()); 90 120 if (childObject == null) { 91 121 continue; … … 104 134 } 105 135 } 106 log.debug("loaded " +object);136 log.debug("loaded {}", object); 107 137 108 138 return object; 109 139 } 110 140 111 p ublic Object load(InputStream stream) {141 protected Object load(InputStream stream, Class<?> enclosingClass) { 112 142 try { 113 143 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); … … 119 149 assert element != null; 120 150 121 return processElement(element );151 return processElement(element, enclosingClass); 122 152 123 153 } catch (Exception e) { … … 129 159 registry.registerAndBuild(type); 130 160 131 Object object = load(stream );161 Object object = load(stream, type); 132 162 if (type.isAssignableFrom(object.getClass())) { 133 163 return type.cast(object); -
java/main/src/main/java/com/framsticks/portals/Portal.java
r98 r100 28 28 // public void run() { 29 29 // ++counter; 30 // log.debug("counter is now: " +counter);30 // log.debug("counter is now: {}", counter); 31 31 // again(); 32 32 // } -
java/main/src/main/java/com/framsticks/remote/RecursiveFetcher.java
r99 r100 5 5 import com.framsticks.core.Node; 6 6 import com.framsticks.core.Path; 7 import com.framsticks.params.Access Interface;7 import com.framsticks.params.Access; 8 8 import com.framsticks.params.CompositeParam; 9 9 import com.framsticks.params.FramsClass; … … 15 15 import com.framsticks.util.Logging; 16 16 import com.framsticks.util.Stopwatch; 17 import org.apache.log4j.Logger; 17 import org.apache.logging.log4j.Logger; 18 import org.apache.logging.log4j.LogManager; 18 19 import static com.framsticks.util.lang.Containers.filterInstanceof; 19 20 import com.framsticks.util.dispatching.RunAt; … … 24 25 public class RecursiveFetcher { 25 26 26 private final static Logger log = Log ger.getLogger(RecursiveFetcher.class.getName());27 private final static Logger log = LogManager.getLogger(RecursiveFetcher.class.getName()); 27 28 28 29 protected final Tree tree; … … 40 41 protected void finished() { 41 42 assert tree.isActive(); 42 log.info("recursively fetched in " +stopwatch);43 log.info("recursively fetched in {}", stopwatch); 43 44 future.pass(null); 44 45 } … … 47 48 assert tree.isActive(); 48 49 if (path == null || !path.isResolved()) { 49 log.warn("path " + path + " is not resolved - skipping");50 log.warn("path {} is not resolved - skipping", path); 50 51 } else { 51 Access Interfaceaccess = bindAccess(path);52 Access access = bindAccess(path); 52 53 FramsClass framsClass = access.getFramsClass(); 53 54 assert framsClass != null; … … 86 87 @Override 87 88 public void handle(FramsticksException e) { 88 log.error("failed to fetch values for " + path + ": " +e);89 log.error("failed to fetch values for {}: ", path, e); 89 90 process(null); 90 91 } -
java/main/src/main/java/com/framsticks/remote/RemoteTree.java
r99 r100 15 15 import com.framsticks.params.types.EventParam; 16 16 import com.framsticks.params.types.ProcedureParam; 17 import com.framsticks.parsers.Loaders; 17 18 import com.framsticks.parsers.MultiParamLoader; 18 19 import com.framsticks.core.Tree; 19 20 import com.framsticks.util.*; 21 import com.framsticks.util.dispatching.AtOnceDispatcher; 20 22 import com.framsticks.util.dispatching.Dispatching; 21 23 import com.framsticks.util.dispatching.Dispatching.DispatcherWaiter; 24 import com.framsticks.util.dispatching.DispatchingFuture; 25 import com.framsticks.util.dispatching.ExceptionResultHandler; 22 26 import com.framsticks.util.dispatching.Future; 23 27 import com.framsticks.util.dispatching.FutureHandler; … … 34 38 import javax.annotation.Nonnull; 35 39 36 import org.apache.log4j.Logger; 40 import org.apache.logging.log4j.Logger; 41 import org.apache.logging.log4j.LogManager; 37 42 38 43 /** … … 42 47 public final class RemoteTree extends AbstractTree implements JoinableParent { 43 48 44 private final static Logger log = Log ger.getLogger(RemoteTree.class);49 private final static Logger log = LogManager.getLogger(RemoteTree.class); 45 50 46 51 protected ClientSideManagedConnection connection; … … 62 67 public void setConnection(final ClientSideManagedConnection connection) { 63 68 this.connection = connection; 69 this.connection.setExceptionHandler(this); 64 70 } 65 71 … … 74 80 } 75 81 76 @Override 77 public void get(final Path path, final ValueParam param, final Future<Object> future) { 78 assert isActive(); 79 assert param != null; 80 // assert path.isResolved(); 81 //TODO only do that if needed 82 connection.send(new GetRequest().field(param.getId()).path(path.getTextual()), this, new ClientSideResponseFuture(future) { 83 @Override 84 protected void processOk(Response response) { 85 assert isActive(); 86 processFetchedValues(path, response.getFiles()); 87 future.pass(bindAccess(path.tryResolveIfNeeded()).get(param, Object.class)); 88 } 89 }); 90 } 82 protected ExceptionResultHandler pathRemoveHandler(final Path path, final ExceptionResultHandler handler) { 83 return new ExceptionResultHandler() { 84 85 @Override 86 public void handle(final FramsticksException exception) { 87 Dispatching.dispatchIfNotActive(RemoteTree.this, new RunAt<RemoteTree>(RemoteTree.this) { 88 89 @Override 90 protected void runAt() { 91 assert path.getTree().isActive(); 92 log.info("path is invalid (removing): {}", path); 93 bindAccess(path.getUnder()).set(path.getTop().getParam(), null); 94 handler.handle(exception); 95 } 96 }); 97 } 98 }; 99 } 100 101 // @Override 102 // public void get(final Path path, final ValueParam param, final Future<Object> future) { 103 // assert isActive(); 104 // assert param != null; 105 // // assert path.isResolved(); 106 // //TODO only do that if needed 107 // connection.send(new GetRequest().field(param.getId()).path(path.getTextual()), this, new ClientSideResponseFuture(pathRemoveHandler(path, future)) { 108 // @Override 109 // protected void processOk(Response response) { 110 // assert isActive(); 111 // processFetchedValues(path, response.getFiles()); 112 // future.pass(bindAccess(path.tryResolveIfNeeded()).get(param, Object.class)); 113 // } 114 // }); 115 // } 91 116 92 117 protected final Map<String, Set<Future<FramsClass>>> infoRequests = new HashMap<String, Set<Future<FramsClass>>>(); … … 103 128 } 104 129 105 log.debug("issuing info request for " +name);130 log.debug("issuing info request for {}", name); 106 131 final Set<Future<FramsClass>> futures = new HashSet<Future<FramsClass>>(); 107 132 futures.add(future); 108 133 infoRequests.put(name, futures); 109 134 110 final Future<FramsClass> compositeFuture = new Future<FramsClass>() {135 final Future<FramsClass> compositeFuture = DispatchingFuture.create(this, new Future<FramsClass>() { 111 136 112 137 @Override … … 122 147 protected void result(FramsClass framsClass) { 123 148 assert isActive(); 149 putInfoIntoCache(framsClass); 124 150 infoRequests.remove(name); 125 151 for (Future<FramsClass> f : futures) { … … 127 153 } 128 154 } 129 } ;155 }); 130 156 131 157 //TODO: if the info is in the cache, then don't communicate 132 connection.send(new InfoRequest().path(path.getTextual()), this, new ClientSideResponseFuture(compositeFuture) {158 connection.send(new InfoRequest().path(path.getTextual()), AtOnceDispatcher.getInstance(), new ClientSideResponseFuture(compositeFuture) { 133 159 @Override 134 160 protected void processOk(Response response) { 135 assert isActive();161 assert connection.getReceiverDispatcher().isActive(); 136 162 137 163 if (response.getFiles().size() != 1) { … … 141 167 throw new FramsticksException().msg("path mismatch").arg("returned path", response.getFiles().get(0).getPath()); 142 168 } 143 FramsClass framsClass = processFetchedInfo(RemoteTree.this, response.getFiles().get(0));169 FramsClass framsClass = Loaders.loadFramsClass(response.getFiles().get(0).getContent()); 144 170 145 171 CompositeParam thisParam = path.getTop().getParam(); … … 155 181 public void get(final Path path, final Future<Path> future) { 156 182 assert isActive(); 157 158 log.trace("fetching values for " + path); 159 findInfo(path, new FutureHandler<FramsClass>(future) { 183 final ExceptionResultHandler remover = pathRemoveHandler(path, future); 184 185 log.trace("fetching values for {}", path); 186 findInfo(path, new FutureHandler<FramsClass>(remover) { 160 187 @Override 161 188 protected void result(FramsClass result) { 162 189 163 connection.send(new GetRequest().path(path.getTextual()), RemoteTree.this, new ClientSideResponseFuture(future) { 190 final Access access = registry.prepareAccess(path.getTop().getParam()); 191 connection.send(new GetRequest().path(path.getTextual()), AtOnceDispatcher.getInstance(), new ClientSideResponseFuture(remover) { 164 192 @Override 165 193 protected void processOk(Response response) { 166 assert isActive(); 167 Path p = path.tryResolveIfNeeded(); 168 processFetchedValues(p, response.getFiles()); 169 future.pass(p.tryResolveIfNeeded().assureResolved()); 194 processFetchedValues(path, response.getFiles(), access, future); 170 195 } 171 196 }); … … 179 204 final Integer flag = bindAccess(path).set(param, value); 180 205 181 log.trace("storing value " + param + " for " +path);206 log.trace("storing value {} for {}", param, path); 182 207 //TODO break in passing exception handler is here 183 208 connection.send(new SetRequest().value(value.toString()).field(param.getId()).path(path.getTextual()), this, new ClientSideResponseFuture(future) { … … 274 299 return; 275 300 } 276 Access Interfaceaccess = registry.createAccess(argumentType);301 Access access = registry.createAccess(argumentType); 277 302 Object argument = access.createAccessee(); 278 303 access.select(argument); … … 282 307 A typedArgument = argumentType.cast(argument); 283 308 284 // log.info("executing event with argument " +argumentType);309 // log.info("executing event with argument {}", argumentType); 285 310 MultiParamLoader loader = new MultiParamLoader(); 286 311 loader.setNewSource(file.getContent()); 287 312 loader.addBreakCondition(MultiParamLoader.Status.AfterObject); 288 loader.addAccess Interface(access);313 loader.addAccess(access); 289 314 loader.go(); 290 315 -
java/main/src/main/java/com/framsticks/running/ExternalProcess.java
r97 r100 12 12 13 13 14 import org.apache.log4j.Logger; 14 import org.apache.logging.log4j.Logger; 15 import org.apache.logging.log4j.LogManager; 15 16 16 17 import com.framsticks.params.annotations.AutoAppendAnnotation; … … 31 32 @FramsClassAnnotation 32 33 public class ExternalProcess extends AbstractJoinable implements JoinableParent { 33 private static final Logger log = Log ger.getLogger(ExternalProcess.class);34 private static final Logger log = LogManager.getLogger(ExternalProcess.class); 34 35 35 36 protected List<String> arguments = new ArrayList<>(); … … 83 84 try { 84 85 while ((line = output.readLine()) != null) { 85 log.trace("read line: " +line);86 log.trace("read line: {}", line); 86 87 synchronized (listeners) { 87 88 for (OutputListener l : listeners) { … … 98 99 throw new FramsticksException().msg("failed to wait for process").cause(e); 99 100 } 100 log.debug("process ended " +this);101 log.debug("process ended {}", this); 101 102 // process = null; 102 103 } catch (FramsticksException e) { 103 log.error("exception caught in process " +this, e);104 log.error("exception caught in process {}", this, e); 104 105 } 105 106 interrupt(); … … 119 120 @Override 120 121 protected void joinableStart() { 121 log.debug("running process with arguments: " +arguments);122 log.debug("running process with arguments: {}", arguments); 122 123 builder.command(arguments); 123 124 try { -
java/main/src/main/java/com/framsticks/running/LoggingOutputListener.java
r90 r100 1 1 package com.framsticks.running; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.params.annotations.FramsClassAnnotation; … … 8 9 public class LoggingOutputListener implements OutputListener { 9 10 private static final Logger log = 10 Log ger.getLogger(LoggingOutputListener.class);11 LogManager.getLogger(LoggingOutputListener.class); 11 12 12 13 -
java/main/src/main/java/com/framsticks/test/TestClass.java
r99 r100 1 1 package com.framsticks.test; 2 2 3 import java.util.Collections; 3 4 import java.util.LinkedList; 4 5 import java.util.List; 6 import java.util.Map; 5 7 6 import org.apache.log4j.Logger; 8 import org.apache.logging.log4j.Logger; 9 import org.apache.logging.log4j.LogManager; 7 10 11 import com.framsticks.core.ListChange; 8 12 import com.framsticks.params.EventListener; 13 import com.framsticks.params.UniqueListAccess; 9 14 import com.framsticks.params.annotations.FramsClassAnnotation; 10 15 import com.framsticks.params.annotations.ParamAnnotation; 11 16 import com.framsticks.params.types.ProcedureParam; 12 17 13 @FramsClassAnnotation(order = {"name", "history", "history_changed", "appendHistory", "resetHistory"}, register = {ChangeEvent.class}) 18 @FramsClassAnnotation( 19 order = { 20 "name", 21 "history", 22 "history_changed", 23 "appendHistory", 24 "resetHistory", 25 "children", 26 "createChild", 27 "children_changed" 28 }, 29 register = { 30 ChangeEvent.class, 31 TestChild.class, 32 ListChange.class 33 } 34 ) 14 35 public class TestClass { 15 36 private static final Logger log = 16 Log ger.getLogger(TestClass.class);37 LogManager.getLogger(TestClass.class); 17 38 18 39 … … 20 41 protected String history = "initial|"; 21 42 protected final List<EventListener<ChangeEvent>> historyListeners = new LinkedList<>(); 43 protected final List<EventListener<ListChange>> childrenListeners = new LinkedList<>(); 44 45 protected final Map<String, TestChild> children = UniqueListAccess.createMap(TestChild.class, this); 46 protected int counter = 0; 47 48 /** 49 * 50 */ 51 public TestClass() { 52 } 22 53 23 54 /** … … 53 84 } 54 85 86 /** 87 * @return the children 88 */ 89 @ParamAnnotation 90 public Map<String, TestChild> getChildren() { 91 return Collections.unmodifiableMap(children); 92 } 93 55 94 @ParamAnnotation(paramType = ProcedureParam.class) 56 95 public int appendHistory(String line) { 57 log.debug("appending ' " + line + "'");96 log.debug("appending '{}'", line); 58 97 history = history + line + "|"; 59 98 fireHistoryChange(); … … 68 107 } 69 108 109 @ParamAnnotation(paramType = ProcedureParam.class) 110 public void createChild(String name) { 111 TestChild child = new TestChild(this); 112 child.name = name; 113 children.put(child.getUid(), child); 114 fireChildrenChange(child, ListChange.Action.Add); 115 } 116 70 117 protected void fireHistoryChange() { 71 118 for (EventListener<ChangeEvent> l : historyListeners) { … … 73 120 event.history = history; 74 121 l.action(event); 122 } 123 } 124 125 protected void fireChildrenChange(TestChild child, ListChange.Action action) { 126 ListChange change = new ListChange(action, UniqueListAccess.getNumberInMap(children, child), child.getUid()); 127 for (EventListener<ListChange> l : childrenListeners) { 128 l.action(change); 75 129 } 76 130 } … … 86 140 } 87 141 142 @ParamAnnotation(id = "children_changed") 143 public void addChildrenListener(EventListener<ListChange> listener) { 144 childrenListeners.add(listener); 145 } 146 147 @ParamAnnotation(id = "children_changed") 148 public void removeChildrenListener(EventListener<ListChange> listener) { 149 childrenListeners.remove(listener); 150 } 151 88 152 @Override 89 153 public String toString() { -
java/main/src/main/java/com/framsticks/util/Logging.java
r96 r100 1 1 package com.framsticks.util; 2 2 3 import org.apache.log 4j.Logger;3 import org.apache.logging.log4j.Logger; 4 4 5 5 import com.framsticks.util.dispatching.ExceptionResultHandler; … … 28 28 }; 29 29 } 30 31 public static <T> T passThru(Logger log, String header, T value) { 32 log.info("{}: {}", header, value); 33 return value; 34 } 30 35 } -
java/main/src/main/java/com/framsticks/util/Misc.java
r88 r100 1 1 package com.framsticks.util; 2 2 3 // import org.apache.log 4j.Logger;3 // import org.apache.logging.log4j.Logger; 4 4 5 5 /** … … 8 8 public class Misc { 9 9 // private static final Logger log = 10 // Log ger.getLogger(Misc.class);10 // LogManager.getLogger(Misc.class); 11 11 12 12 public static class WithType { … … 34 34 35 35 public static boolean equals(Object a, Object b) { 36 // log.info("equality of " + withType(a) + " ? " +withType(b));36 // log.info("equality of {} ? {}", withType(a), withType(b)); 37 37 if (a != null) { 38 38 return (b != null && a.equals(b)); -
java/main/src/main/java/com/framsticks/util/dispatching/AbstractJoinable.java
r97 r100 10 10 11 11 import org.apache.commons.collections.CollectionUtils; 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import com.framsticks.util.FramsticksException; … … 16 17 public abstract class AbstractJoinable implements Joinable { 17 18 18 private static final Logger log = Log ger.getLogger(AbstractJoinable.class);19 private static final Logger log = LogManager.getLogger(AbstractJoinable.class); 19 20 20 21 protected final Set<JoinableParent> owners = new HashSet<JoinableParent>(); … … 41 42 } 42 43 } 43 log.debug("state: " +b);44 log.debug("state: {}", b); 44 45 } 45 46 … … 53 54 this.state = state; 54 55 55 log.debug( this + " is notifying " + joinableListeners.size() + " parents");56 log.debug("{} is notifying {} parents", this, joinableListeners.size()); 56 57 57 58 List<JoinableParent> parents = new LinkedList<>(); … … 141 142 } 142 143 start = owners.isEmpty(); 143 log.debug( owner + " is using " +this);144 log.debug("{} is using {}", owner, this); 144 145 owners.add(owner); 145 146 joinableListeners.add(owner); … … 161 162 } 162 163 // assert owners.containsKey(owner); 163 log.debug( owner + " is droping " +this);164 log.debug("{} is droping {}", owner, this); 164 165 owners.remove(owner); 165 166 stop = owners.isEmpty(); -
java/main/src/main/java/com/framsticks/util/dispatching/Dispatching.java
r99 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.util.FramsticksException; … … 9 10 */ 10 11 public abstract class Dispatching { 11 private static final Logger log = Log ger.getLogger(Dispatching.class);12 private static final Logger log = LogManager.getLogger(Dispatching.class); 12 13 13 14 public static boolean isThreadSafe() { … … 57 58 58 59 public static void use(final Joinable joinable, final JoinableParent owner) { 59 log.debug("using " + joinable + " by " +owner);60 log.debug("using {} by {}", joinable, owner); 60 61 if (joinable.use(owner)) { 61 log.debug("started " +joinable);62 log.debug("started {}", joinable); 62 63 } else { 63 log.debug("start of " + joinable + " already happened");64 log.debug("start of {} already happened", joinable); 64 65 } 65 66 } 66 67 67 68 public static void drop(final Joinable joinable, final JoinableParent owner) { 68 log.debug("droping " + joinable + " by " +owner);69 log.debug("droping {} by {}", joinable, owner); 69 70 if (joinable.drop(owner)) { 70 log.debug("stoped " +joinable);71 log.debug("stoped {}", joinable); 71 72 } else { 72 log.debug("stop of " + joinable + " deferred");73 log.debug("stop of {} deferred", joinable); 73 74 } 74 75 } 75 76 76 77 public static void join(Joinable joinable) throws InterruptedException { 77 log.debug("joining " +joinable);78 log.debug("joining {}", joinable); 78 79 try { 79 80 joinable.join(); 80 81 } catch (InterruptedException e) { 81 log.debug("failed to join " +joinable);82 log.debug("failed to join {}", joinable); 82 83 throw e; 83 84 } 84 log.debug("joined " +joinable);85 log.debug("joined {}", joinable); 85 86 } 86 87 … … 92 93 @Override 93 94 protected void runAt() { 94 log.debug("joinable " + joinable + " is notifying parent " + parent + " about change to " +state);95 log.debug("joinable {} is notifying parent {} about change to {}", joinable, parent, state); 95 96 parent.childChangedState(joinable, state); 96 97 } … … 108 109 109 110 public static void joinAbsolutely(Joinable joinable) { 110 log.debug("joining absolutely " +joinable);111 log.debug("joining absolutely {}", joinable); 111 112 while (true) { 112 113 try { … … 116 117 // throw new FramsticksException().msg("failed to join").arg("dispatcher", dispatcher).cause(e); 117 118 } 118 log.debug("waiting for " +joinable);119 log.debug("waiting for {}", joinable); 119 120 wait(joinable, 500); 120 121 } -
java/main/src/main/java/com/framsticks/util/dispatching/Monitor.java
r96 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 import com.framsticks.util.dispatching.Dispatching; 5 6 import java.lang.Thread; … … 7 8 public class Monitor implements JoinableParent { 8 9 private static final Logger log = 9 Log ger.getLogger(Monitor.class);10 LogManager.getLogger(Monitor.class); 10 11 11 12 protected final Joinable joinable; … … 30 31 Runtime.getRuntime().addShutdownHook(shutdownHook); 31 32 32 log.debug( this + " is using");33 log.debug("{} is using", this); 33 34 Dispatching.use(joinable, this); 34 35 return this; … … 41 42 42 43 public Monitor waitFor() { 43 log.debug( this + " is waiting");44 log.debug("{} is waiting", this); 44 45 synchronized (this) { 45 46 while (joinable.getState().ordinal() < JoinableState.FINISHING.ordinal()) { … … 47 48 } 48 49 } 49 log.debug( this + " ended waiting");50 log.debug("{} ended waiting", this); 50 51 return this; 51 52 } … … 53 54 54 55 public Monitor drop() { 55 log.debug( this + " is droping");56 log.debug("{} is droping", this); 56 57 Dispatching.drop(joinable, this); 57 58 return this; … … 59 60 60 61 public Monitor join() { 61 log.debug( this + " is joining");62 log.debug("{} is joining", this); 62 63 Dispatching.joinAbsolutely(joinable); 63 log.debug( this + " is joined");64 log.debug("{} is joined", this); 64 65 65 66 try { … … 78 79 this.notify(); 79 80 } 80 log.debug( this + " received notification about transition to " +state);81 log.debug("{} received notification about transition to {}", this, state); 81 82 } 82 83 -
java/main/src/main/java/com/framsticks/util/dispatching/Thread.java
r99 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import java.util.LinkedList; … … 15 16 public class Thread<C> extends AbstractJoinable implements JoinableDispatcher<C> { 16 17 17 private static final Logger log = Log ger.getLogger(Thread.class);18 private static final Logger log = LogManager.getLogger(Thread.class); 18 19 19 20 protected final java.lang.Thread thread; … … 46 47 47 48 protected void routine() { 48 log.debug("starting thread " +this);49 log.debug("starting thread {}", this); 49 50 assert getMonitor() != null; 50 51 ExceptionHandler exceptionHandler = getMonitor().getTaskExceptionHandler(); … … 83 84 } 84 85 } 85 log.debug("finishing thread " +this);86 log.debug("finishing thread {}", this); 86 87 finish(); 87 88 } … … 138 139 protected void joinableJoin() throws InterruptedException { 139 140 thread.join(500); 140 log.debug("joined " +this);141 log.debug("joined {}", this); 141 142 } 142 143 -
java/main/src/main/java/com/framsticks/util/lang/Casting.java
r99 r100 29 29 return class_.cast(object); 30 30 } 31 32 public static <T> T nullOrThrowCast(Class<T> class_, Object object) { 33 if (object == null) { 34 return null; 35 } 36 return class_.cast(object); 37 } 31 38 } -
java/main/src/main/java/com/framsticks/util/lang/FlagsUtil.java
r99 r100 2 2 3 3 import java.lang.reflect.Field; 4 import org.apache.log4j.Logger; 4 import org.apache.logging.log4j.Logger; 5 import org.apache.logging.log4j.LogManager; 5 6 6 7 import com.framsticks.util.lang.Delimeted; … … 8 9 public final class FlagsUtil { 9 10 10 private final static Logger log = Log ger.getLogger(FlagsUtil.class);11 private final static Logger log = LogManager.getLogger(FlagsUtil.class); 11 12 12 13 private FlagsUtil() { … … 41 42 allFlags |= Integer.parseInt(field.get(null).toString()); 42 43 } catch (SecurityException e) { 43 log.warn("security exception was thrown while trying to read flag ( " + flag + ")");44 log.warn("security exception was thrown while trying to read flag ({})", flag); 44 45 } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { 45 log.warn("selected flag is not known ( " + flag + ")");46 log.warn("selected flag is not known ({})", flag); 46 47 } 47 48 } -
java/main/src/main/java/com/framsticks/visualization/SingleViewPanel.java
r84 r100 1 1 package com.framsticks.visualization; 2 2 3 import com.framsticks.gui. Panel;3 import com.framsticks.gui.TreePanel; 4 4 import com.framsticks.model.Model; 5 import com.framsticks.params.Access Interface;5 import com.framsticks.params.Access; 6 6 7 7 import javax.swing.*; … … 12 12 */ 13 13 @SuppressWarnings("serial") 14 public class SingleViewPanel extends Panel {14 public class SingleViewPanel extends TreePanel { 15 15 16 16 Viewer viewer; 17 17 18 public SingleViewPanel( Panel.Parameters parameters) {18 public SingleViewPanel(TreePanel.Parameters parameters) { 19 19 super(parameters); 20 20 //viewer = new Viewer(); … … 26 26 27 27 @Override 28 public void pullValuesFromLocalToUser(Access Interfaceaccess) {28 public void pullValuesFromLocalToUser(Access access) { 29 29 Object object = access.getSelected(); 30 30 if (!(object instanceof Model)) { -
java/main/src/main/java/com/framsticks/visualization/SingleViewPanelProvider.java
r84 r100 1 1 package com.framsticks.visualization; 2 2 3 import com.framsticks.gui.Panel;4 3 import com.framsticks.gui.PanelProvider; 4 import com.framsticks.gui.TreePanel; 5 5 6 6 /** … … 9 9 public class SingleViewPanelProvider implements PanelProvider { 10 10 @Override 11 public Panel providePanel(Panel.Parameters parameters) {11 public TreePanel providePanel(TreePanel.Parameters parameters) { 12 12 if (parameters.param.getContainedTypeName().equals("Model")) { 13 13 return new SingleViewPanel(parameters); -
java/main/src/main/java/com/framsticks/visualization/Viewer.java
r85 r100 19 19 import java.io.*; 20 20 21 import org.apache.log4j.Logger; 21 import org.apache.logging.log4j.Logger; 22 import org.apache.logging.log4j.LogManager; 22 23 23 24 public class Viewer { 24 25 25 private static Logger log = Log ger.getLogger(Viewer.class);26 private static Logger log = LogManager.getLogger(Viewer.class); 26 27 27 28 Canvas3D canvas3d; -
java/main/src/main/java/com/framsticks/visualization/ViewerTest.java
r84 r100 3 3 import com.sun.j3d.utils.universe.*; 4 4 import com.sun.j3d.utils.geometry.ColorCube; 5 import org.apache.log4j.Logger; 5 import org.apache.logging.log4j.Logger; 6 import org.apache.logging.log4j.LogManager; 6 7 7 8 import javax.media.j3d.*; … … 17 18 @SuppressWarnings("serial") 18 19 public class ViewerTest extends JPanel { 19 private static final Logger log = Log ger.getLogger(ViewerTest.class.getName());20 private static final Logger log = LogManager.getLogger(ViewerTest.class.getName()); 20 21 21 22 private SimpleUniverse univ = null; -
java/main/src/main/resources/configs/framsticks.xml
r99 r100 21 21 <!-- </LocalTree> --> 22 22 <RemoteTree name="remote" address="localhost:9007" /> 23 <ColumnsConfig className="Genotype" columnsNames="uid name" /> 23 <include resource="/configs/common-columns.xml" /> 24 <!-- <ColumnsConfig className="Genotype" columnsNames="uid name" /> --> 24 25 </Browser> 25 26 <Server name="server" port="9007"> -
java/main/src/test/java/com/framsticks/core/ListChangeTest.java
r87 r100 1 1 package com.framsticks.core; 2 3 import java.util.Arrays; 2 4 3 5 import org.testng.annotations.BeforeMethod; … … 6 8 import com.framsticks.core.ListChange.Action; 7 9 import com.framsticks.params.FramsClass; 10 import com.framsticks.params.ListSink; 8 11 import com.framsticks.params.ListSource; 9 12 import com.framsticks.params.ReflectionAccess; … … 57 60 @Test(dependsOnMethods = "createReflectionAccess") 58 61 public void load() throws Exception { 59 access.select(listChange).load(ListSource.createFrom("type:2", "pos: 5", "id:test"));62 access.select(listChange).load(ListSource.createFrom("type:2", "pos:0", "id:test")); 60 63 61 64 assertThat(listChange.action).isEqualTo(Action.Modify); 62 assertThat(listChange.position).isEqualTo( 5);65 assertThat(listChange.position).isEqualTo(0); 63 66 assertThat(listChange.identifier).isEqualTo("test"); 67 68 ListSink sink = new ListSink(); 69 access.select(listChange).save(sink); 70 assertThat(sink.getOut()).isEqualTo(Arrays.asList("ListChange:", "type:2", "pos:0", "id:test", "")); 64 71 } 65 72 -
java/main/src/test/java/com/framsticks/core/LocalTreeTest.java
r99 r100 16 16 import com.framsticks.util.dispatching.Monitor; 17 17 import com.framsticks.util.dispatching.RunAt; 18 import com.framsticks.params.Access Interface;18 import com.framsticks.params.Access; 19 19 import com.framsticks.params.ReflectionAccess; 20 20 import com.framsticks.params.types.FloatParam; … … 72 72 Path path = Path.to(tree, "/"); 73 73 assertThat(path.isResolved()); 74 Access Interfaceaccess = TreeOperations.bindAccess(path);74 Access access = TreeOperations.bindAccess(path); 75 75 assertThat(access.get("se", Double.class)).isEqualTo(1.0); 76 76 -
java/main/src/test/java/com/framsticks/dumping/StreamTest.java
r97 r100 16 16 // public void result(Path result, Exception e) { 17 17 // if (e != null) { 18 // log.error("failed to load file: " +e);18 // log.error("failed to load file: {}", e); 19 19 // fireRun(e); 20 20 // return; … … 26 26 // stream.load(); 27 27 // } catch (IOException e) { 28 // log.error("io failure: " +e);28 // log.error("io failure: {}", e); 29 29 // fireRun(e); 30 30 // } -
java/main/src/test/java/com/framsticks/gui/BrowserBaseTest.java
r99 r100 3 3 import javax.swing.JFrame; 4 4 5 import org.apache.log4j.Logger; 5 import org.apache.logging.log4j.Logger; 6 import org.apache.logging.log4j.LogManager; 6 7 import org.fest.swing.edt.GuiQuery; 7 8 import org.fest.swing.fixture.FrameFixture; … … 18 19 public abstract class BrowserBaseTest extends GuiTest { 19 20 20 private static final Logger log = Log ger.getLogger(BrowserTest.class);21 private static final Logger log = LogManager.getLogger(BrowserTest.class); 21 22 22 23 protected Browser browser; … … 52 53 Dispatching.sleep(2.0); 53 54 tree.expandPath(path); 55 Dispatching.sleep(2.0); 54 56 robot.waitForIdle(); 55 57 } -
java/main/src/test/java/com/framsticks/gui/BrowserTest.java
r99 r100 7 7 8 8 9 import org.apache.log4j.Logger; 9 import org.apache.logging.log4j.Logger; 10 import org.apache.logging.log4j.LogManager; 10 11 import org.fest.swing.edt.GuiTask; 11 12 import org.testng.annotations.Test; … … 17 18 public class BrowserTest extends BrowserBaseTest { 18 19 19 private static final Logger log = Log ger.getLogger(BrowserTest.class);20 private static final Logger log = LogManager.getLogger(BrowserTest.class); 20 21 21 22 RemoteTree localhost; … … 34 35 } 35 36 36 @Test(timeOut = 30000)37 @Test(timeOut = 60000) 37 38 public void testShow() { 38 39 Dispatching.synchronize(localhost, 1.0); -
java/main/src/test/java/com/framsticks/gui/LocalTreeBrowserTest.java
r99 r100 29 29 } 30 30 31 @Test(timeOut = 10000)31 @Test(timeOut = 30000) 32 32 public void testShow() { 33 33 tree.dispatch(new RunAt<Tree>(failOnException) { -
java/main/src/test/java/com/framsticks/gui/ProcedureBrowserTest.java
r99 r100 10 10 import com.framsticks.core.Tree; 11 11 import com.framsticks.core.LocalTree; 12 import com.framsticks.params.Access Interface;12 import com.framsticks.params.Access; 13 13 import com.framsticks.params.EventListener; 14 14 import com.framsticks.params.FramsClass; … … 62 62 @Override 63 63 protected void runAt() { 64 Access Interfaceaccess = bindAccess(tree, "/");64 Access access = bindAccess(tree, "/"); 65 65 assertThat(access).isInstanceOf(ReflectionAccess.class); 66 66 FramsClass framsClass = access.getFramsClass(); 67 assertThat(framsClass.getParamCount()).isEqualTo(5);68 67 assertThat(framsClass.getParam(0).getId()).isEqualTo("name"); 69 68 assertThat(framsClass.getParam(1).getId()).isEqualTo("history"); … … 94 93 @Override 95 94 protected void runAt() { 96 Access Interfaceaccess = bindAccess(tree, "/");95 Access access = bindAccess(tree, "/"); 97 96 assertThat(access.get("history", String.class)).isEqualTo("initial|Żółw|"); 98 97 … … 107 106 @Override 108 107 protected void runAt() { 109 Access Interfaceaccess = bindAccess(tree, "/");108 Access access = bindAccess(tree, "/"); 110 109 assertThat(access.get("history", String.class)).isEqualTo(""); 111 110 -
java/main/src/test/java/com/framsticks/hosting/ServerTest.java
r99 r100 8 8 import org.testng.annotations.Test; 9 9 10 import com.framsticks.core.ListChange; 10 11 import com.framsticks.core.LocalTree; 11 12 import com.framsticks.core.Path; … … 18 19 import com.framsticks.core.Tree; 19 20 import com.framsticks.params.FramsClass; 20 import com.framsticks.params.Access Interface;21 import com.framsticks.params.Access; 21 22 import com.framsticks.params.EventListener; 22 23 import com.framsticks.params.PrimitiveParam; 23 24 import com.framsticks.params.PropertiesAccess; 24 25 import com.framsticks.params.types.EventParam; 26 import com.framsticks.params.types.StringParam; 25 27 // import com.framsticks.params.types.EventParam; 26 28 import com.framsticks.params.types.ProcedureParam; … … 44 46 protected TestClass hostedObject; 45 47 protected EventListener<ChangeEvent> listener; 48 protected EventListener<ListChange> childListener; 49 46 50 protected List<String> listenerArguments = new LinkedList<>(); 51 protected List<ListChange> childrenChanges = new LinkedList<>(); 52 47 53 48 54 @Override … … 90 96 assertThat(path.isResolved()).isTrue(); 91 97 remotePath = path; 92 Access Interfaceaccess = bindAccess(path);98 Access access = bindAccess(path); 93 99 assertThat(access).isInstanceOf(PropertiesAccess.class); 94 100 assertThat(access.get("name", String.class)).isEqualTo("a test name"); … … 167 173 } 168 174 169 @Test(dependsOnMethods = "callMethod") 175 176 @Test(dependsOnMethods = "deregisterListener") 177 public void registerChildListener() { 178 179 childListener = new EventListener<ListChange>() { 180 @Override 181 public void action(ListChange listChange) { 182 childrenChanges.add(listChange); 183 } 184 }; 185 186 addListener(remotePath, remoteTestFramsClass.getParamEntry("children_changed", EventParam.class), childListener, ListChange.class, produceWaiter(1.0).passInFuture(Void.class)); 187 } 188 189 @Test(dependsOnMethods = "registerChildListener") 190 public void createChild() { 191 final Waiter waiter = produceWaiter(2.0); 192 call(remotePath, "createChild", new Object[] { "a child" }, produceWaiter(2.0).passInFuture(Object.class)); 193 call(remotePath, "createChild", new Object[] { "another child" }, produceWaiter(2.0).passInFuture(Object.class)); 194 195 tryGet(remote, "/testClass/children/c0", new FutureHandler<Path>(failOnException) { 196 197 @Override 198 protected void result(Path result) { 199 set(result, getFramsClass(result).getParamEntry("name", StringParam.class), "new_name", new FutureHandler<Integer>(failOnException) { 200 201 @Override 202 protected void result(Integer result) { 203 waiter.pass(); 204 } 205 }); 206 } 207 }); 208 } 209 210 @Test(dependsOnMethods = "createChild") 211 public void deregisterChildListener() { 212 removeListener(remotePath, remoteTestFramsClass.getParamEntry("children_changed", EventParam.class), childListener, produceWaiter(1.0).passInFuture(Void.class)); 213 } 214 215 @Test(dependsOnMethods = "deregisterChildListener") 216 public void checkListChanges() { 217 assertThat(childrenChanges).isEqualTo(Arrays.asList( 218 new ListChange(ListChange.Action.Add, 0, "c0"), 219 new ListChange(ListChange.Action.Add, 1, "c1"), 220 new ListChange(ListChange.Action.Modify, 0, "c0") 221 )); 222 } 223 224 @Test(dependsOnMethods = "checkListChanges") 170 225 public void endWait() { 171 226 monitor.useFor(1.0); -
java/main/src/test/java/com/framsticks/model/ModelPackageTest.java
r90 r100 21 21 @Test(dataProvider = "classesList") 22 22 public void testFramsClass(Class<?> javaClass, String name, int paramCount, Object[][] paramsTests) throws InstantiationException, IllegalAccessException { 23 // log.info("testing " + name + " " + javaClass + " " + Package.class.getResource(filename));24 23 String filename = "/info/" + name + ".info"; 25 24 InputStream stream = ModelPackage.class.getResourceAsStream(filename); -
java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java
r99 r100 34 34 @Test 35 35 public void checkProcedureParams() { 36 assertThat(framsClass.getParamCount()).isEqualTo( 5);36 assertThat(framsClass.getParamCount()).isEqualTo(8); 37 37 38 38 assertThat(framsClass.getParam("name")).isInstanceOf(StringParam.class); … … 80 80 "name:ResetHistory", 81 81 "type:p()", 82 "", 83 "prop:", 84 "id:children", 85 "name:Children", 86 "type:l TestChild uid", 87 "flags:1", 88 "", 89 "prop:", 90 "id:createChild", 91 "name:CreateChild", 92 "type:p(s arg0)", 93 "", 94 "prop:", 95 "id:children_changed", 96 "name:ChildrenListener", 97 "type:e ListChange", 82 98 "" 83 99 ) -
java/main/src/test/java/com/framsticks/params/ParamBuilderTest.java
r96 r100 14 14 ParamBuilder builder; 15 15 FramsClass builderFramsClass; 16 Access Interfaceaccess;16 Access access; 17 17 18 18 @Test … … 34 34 MultiParamLoader loader = new MultiParamLoader(); 35 35 loader.setNewSource(source); 36 loader.addAccess Interface(access);36 loader.addAccess(access); 37 37 loader.addBreakCondition(MultiParamLoader.Status.AfterObject); 38 38 -
java/main/src/test/java/com/framsticks/parsers/F0ParserTest.java
r90 r100 24 24 25 25 private Schema schema; 26 private List<Access Interface> accesses;26 private List<Access> accesses; 27 27 private List<ModelComponent> components; 28 28 private Model model; … … 72 72 73 73 @Test(dependsOnMethods = {"readF0"}) 74 public void stripAccess Interface() {75 components = Util.stripAccess Interface(accesses, ModelComponent.class);74 public void stripAccess() { 75 components = Util.stripAccess(accesses, ModelComponent.class); 76 76 77 77 assertThat(components.get(1)).isInstanceOf(Part.class); … … 81 81 } 82 82 83 @Test(dependsOnMethods = {"stripAccess Interface"})83 @Test(dependsOnMethods = {"stripAccess"}) 84 84 public void buildModel() { 85 85 model = new ModelBuilder().addComponents(components).finish(); -
java/main/src/test/java/com/framsticks/test/TestConfiguration.java
r99 r100 6 6 import java.util.Set; 7 7 8 import org.apache.log 4j.Logger;9 import org.apache.log 4j.PropertyConfigurator;8 import org.apache.logging.log4j.Logger; 9 import org.apache.logging.log4j.LogManager; 10 10 import org.testng.annotations.*; 11 11 … … 21 21 public class TestConfiguration { 22 22 23 private static final Logger log = Log ger.getLogger(TestConfiguration.class);23 private static final Logger log = LogManager.getLogger(TestConfiguration.class); 24 24 25 25 @BeforeClass 26 26 public void setUpConfiguration() { 27 PropertyConfigurator.configure(TestConfiguration.class.getResource("/log4j.properties")); 28 log.info("testing " + this.getClass()); 27 log.info("testing {}", this.getClass()); 29 28 } 30 29 … … 86 85 @BeforeMethod 87 86 public void clearWaiters() { 88 waiters.clear(); 87 synchronized (waiters) { 88 waiters.clear(); 89 } 89 90 } 90 91 91 92 protected Dispatching.Waiter produceWaiter(double timeOut) { 92 93 Waiter waiter = new Waiter(timeOut, failOnException); 93 waiters.add(waiter); 94 synchronized (waiters) { 95 waiters.add(waiter); 96 } 94 97 return waiter; 95 98 } … … 98 101 @Override 99 102 public void handle(FramsticksException e) { 100 log.error("passing exception as assertion in " +TestConfiguration.this.getClass(), e);103 log.error("passing exception as assertion in {}", TestConfiguration.this.getClass(), e); 101 104 addAsyncAssertion(e); 102 105 }
Note: See TracChangeset
for help on using the changeset viewer.