Example #1
0
 private void dispatch(final Screen<?> screen, final ScreenPath path, final String parentPath) {
   if (screen == null) {
     return;
   }
   if (path.child != null) {
     dispatch(
         screen.child(path.key), path.child, (parentPath == null ? "" : parentPath) + "/" + path);
   } else {
     screen.setupPathFactory(parentPath);
     switch (path.action) {
       case NEW:
         screen.showNew();
         break;
       case SHOW:
         screen.showRead(path.key);
         break;
       case EDIT:
         screen.showEdit(path.key);
         break;
       case INDEX:
         final Map<String, String> query = new HashMap<String, String>();
         if (path.query != null) {
           for (final String param : path.query.split("&")) {
             final int index = param.indexOf('=');
             if (index > 0) {
               query.put(param.substring(0, index), param.substring(index + 1));
             }
           }
         }
         screen.showAll(query);
     }
   }
 }