Changeset 2674


Ignore:
Timestamp:
03/08/10 13:28:03 (2 years ago)
Author:
mswertz
Message:

Simplified Screen and Command framework.
Enabled adding or replacing commands in generated screens.
use <form name="x" entity="y" commands="command.CommandClass?1,command.CommandClass?2"/> in meta model.

Location:
molgenis/3.3/src/org/molgenis
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • molgenis/3.3/src/org/molgenis/framework/ui/FormController.java

    r2442 r2674  
    5555         * @param view 
    5656         */ 
    57         public FormController(FormModel<E> view) 
     57        public FormController(FormModel view) 
    5858        { 
    5959                super(view); 
     
    6262                try 
    6363                { 
    64                         this.pager = new LimitOffsetPager<E>(view.getEntityClass(), view.create().getFields() 
     64                        this.pager = new LimitOffsetPager(view.getEntityClass(), view.create().getFields() 
    6565                                        .firstElement()); 
    6666                        // this.pager = new PrimaryKeyPager<E>(view.getEntityClass(), 
     
    9393 
    9494                // clear the old messages 
    95                 view.setMessages(new Vector<ScreenMessage<E>>()); // clear messsages 
     95                view.setMessages(new Vector<ScreenMessage>()); // clear messsages 
    9696 
    9797                try 
     
    399399 
    400400                // load all records and select rows that can be visible 
    401                 // List<E> allRecords = view.getDatabase().find( view.getEntityClass(), 
     401                // List allRecords = view.getDatabase().find( view.getEntityClass(), 
    402402                // allRules ); 
    403403                List<E> allRecords = pager.getPage(db); 
     
    427427        public boolean doAdd(Database db, Tuple request) throws ParseException, DatabaseException, IOException 
    428428        { 
    429                 ScreenMessage<E> msg = null; 
    430                 E entity = view.create(); 
     429                ScreenMessage msg = null; 
     430                Entity entity = view.create(); 
    431431                boolean result = false; 
    432432 
     
    451451                        } 
    452452                        db.commitTx(); 
    453                         msg = new ScreenMessage<E>("ADD SUCCESS: affected " + updatedRows, null, true); 
     453                        msg = new ScreenMessage("ADD SUCCESS: affected " + updatedRows, null, true); 
    454454                        result = true; 
    455455                        // navigate to newly added record 
     
    460460                { 
    461461                        db.rollbackTx(); 
    462                         msg = new ScreenMessage<E>("ADD FAILED: " + e.getMessage(), null, false); 
     462                        msg = new ScreenMessage("ADD FAILED: " + e.getMessage(), null, false); 
    463463                        result = false; 
    464464                } 
     
    478478        protected void doUpdate(Database db, Tuple request) throws DatabaseException, IOException, ParseException 
    479479        { 
    480                 E entity = view.create(); 
    481                 ScreenMessage<E> msg = null; 
     480                Entity entity = view.create(); 
     481                ScreenMessage msg = null; 
    482482                try 
    483483                { 
    484484                        entity.set(request); 
    485485                        int updatedRows = db.update(entity); 
    486                         msg = new ScreenMessage<E>("UPDATE SUCCESS: affected " + updatedRows, null, true); 
     486                        msg = new ScreenMessage("UPDATE SUCCESS: affected " + updatedRows, null, true); 
    487487                } 
    488488                catch (Exception e) 
    489489                { 
    490490                        logger.error("doUpdate(): " + e); 
    491                         msg = new ScreenMessage<E>("UPDATE FAILED: " + e.getMessage(), null, false); 
     491                        msg = new ScreenMessage("UPDATE FAILED: " + e.getMessage(), null, false); 
    492492                } 
    493493                view.getMessages().add(msg); 
     
    502502        protected void doRemove(Database db, Tuple request) throws DatabaseException, ParseException, IOException 
    503503        { 
    504                 E entity = view.create(); 
    505                 ScreenMessage<E> msg = null; 
     504                Entity entity = view.create(); 
     505                ScreenMessage msg = null; 
    506506                try 
    507507                { 
    508508                        entity.set(request); 
    509509                        int updatedRows = db.remove(entity); 
    510                         if (updatedRows > 0) msg = new ScreenMessage<E>("REMOVE SUCCESS: affected " + updatedRows, null, true); 
     510                        if (updatedRows > 0) msg = new ScreenMessage("REMOVE SUCCESS: affected " + updatedRows, null, true); 
    511511                        else 
    512                                 msg = new ScreenMessage<E>("REMOVE FAILED: call system administrator", null, false); 
     512                                msg = new ScreenMessage("REMOVE FAILED: call system administrator", null, false); 
    513513                } 
    514514                catch (Exception e) 
    515515                { 
    516                         msg = new ScreenMessage<E>("REMOVE FAILED: " + e.getMessage(), null, false); 
     516                        msg = new ScreenMessage("REMOVE FAILED: " + e.getMessage(), null, false); 
    517517                } 
    518518                view.getMessages().add(msg); 
     
    572572        // { 
    573573        // Database db = view.getDatabase(); 
    574         // ScreenMessage<E> msg = null; 
     574        // ScreenMessage msg = null; 
    575575        // try 
    576576        // { 
     
    588588        // view.getDatabase().query(view.getEntityClass()).in(view.create() 
    589589        // .getIdField(), idList); 
    590         // List<E> selection = q.find(); 
     590        // List selection = q.find(); 
    591591        // 
    592592        // // delete selected entities 
    593593        // db.remove(selection); 
    594         // msg = new ScreenMessage<E>("REMOVED " + selection.size() + " records", 
     594        // msg = new ScreenMessage("REMOVED " + selection.size() + " records", 
    595595        // null, true); 
    596596        // } 
    597597        // catch (Exception e) 
    598598        // { 
    599         // msg = new ScreenMessage<E>("REMOVE SELECTION FAILED: " + e.getMessage(), 
     599        // msg = new ScreenMessage("REMOVE SELECTION FAILED: " + e.getMessage(), 
    600600        // null, false); 
    601601        // } 
     
    618618        // } 
    619619        // 
    620         // ScreenMessage<E> msg = null; 
     620        // ScreenMessage msg = null; 
    621621        // Database db = view.getDatabase(); 
    622622        // int row = 0; 
     
    625625        // Query q = db.query(view.getEntityClass()).in(view.create().getIdField(), 
    626626        // idList); 
    627         // List<E> entities = q.find(); 
     627        // List entities = q.find(); 
    628628        // 
    629629        // db.beginTx(); 
     
    635635        // } 
    636636        // db.commitTx(); 
    637         // msg = new ScreenMessage<E>("MASS UPDATE SUCCESS: updated " + 
     637        // msg = new ScreenMessage("MASS UPDATE SUCCESS: updated " + 
    638638        // entities.size() + " rows", null, true); 
    639639        // } 
     
    650650        // e1.printStackTrace(); 
    651651        // } 
    652         // msg = new ScreenMessage<E>("MASS UPDATE FAILED on item '" + row + "': " + 
     652        // msg = new ScreenMessage("MASS UPDATE FAILED on item '" + row + "': " + 
    653653        // e, null, false); 
    654654        // } 
     
    660660        // { 
    661661        // logger.debug("doCsvUpload: " + request); 
    662         // ScreenMessage<E> msg = null; 
     662        // ScreenMessage msg = null; 
    663663        // try 
    664664        // { 
    665         // CsvEntityReader<E> csvReader = this.view.getCsvReader(); 
     665        // CsvEntityReader csvReader = this.view.getCsvReader(); 
    666666        // 
    667667        // int updatedRows = csvReader.importCsv(view.getDatabase(), new 
     
    670670        // // logger.debug("parsed: " + entity); 
    671671        // //view.getDatabase().add(entities); 
    672         // msg = new ScreenMessage<E>("CSV UPLOAD SUCCESS: added " + updatedRows + 
     672        // msg = new ScreenMessage("CSV UPLOAD SUCCESS: added " + updatedRows + 
    673673        // " rows", null, true); 
    674674        // logger.debug("CSV UPLOAD SUCCESS: added " + updatedRows + " rows"); 
     
    679679        // { 
    680680        // e.printStackTrace(); 
    681         // msg = new ScreenMessage<E>("CSV UPLOAD FAILED: " + e.getMessage(), null, 
     681        // msg = new ScreenMessage("CSV UPLOAD FAILED: " + e.getMessage(), null, 
    682682        // false); 
    683683        // logger.error("CSV UPLOAD FAILED: " + e.getMessage()); 
  • molgenis/3.3/src/org/molgenis/framework/ui/FormModel.java

    r2594 r2674  
    1818import java.util.ArrayList; 
    1919import java.util.Arrays; 
     20import java.util.LinkedHashMap; 
    2021import java.util.List; 
    2122import java.util.Map; 
     
    4142import org.molgenis.framework.ui.commands.RemoveSelectedCommand; 
    4243import org.molgenis.framework.ui.commands.ScreenCommand; 
    43 import org.molgenis.framework.ui.commands.SimpleCommand; 
    4444import org.molgenis.framework.ui.commands.ViewEditViewCommand; 
    4545import org.molgenis.framework.ui.commands.ViewListViewCommand; 
     
    5353 *  
    5454 *  
    55  * @param <E> 
     55 * @param  
    5656 */ 
    5757public abstract class FormModel<E extends Entity> extends SimpleModel 
     
    6868                private String parentForm; 
    6969                private String parentId; 
    70                 private String parentLabel; 
     70                private List<String> parentLabels; 
    7171                private String xrefToParent; 
    7272 
    73                 public ParentFilter(String parentForm, String parentId, String parentLabel, String xrefToParent) 
     73                public ParentFilter(String parentForm, String parentId, List<String> parentLabel, String xrefToParent) 
    7474                { 
    7575                        this.parentForm = parentForm; 
    7676                        this.parentId = parentId; 
    77                         this.parentLabel = parentLabel; 
     77                        this.parentLabels = parentLabel; 
    7878                        this.xrefToParent = xrefToParent; 
    7979                } 
     
    109109                } 
    110110 
    111                 public String getParentLabel() 
    112                 { 
    113                         return parentLabel; 
    114                 } 
    115  
    116                 public void setParentLabel(String parentLabel) 
    117                 { 
    118                         this.parentLabel = parentLabel; 
     111                public List<String> getParentLabels() 
     112                { 
     113                        return parentLabels; 
     114                } 
     115 
     116                public void setParentLabels(List<String> parentLabel) 
     117                { 
     118                        this.parentLabels = parentLabel; 
    119119                } 
    120120        } 
     
    129129         * @throws ParseException 
    130130         */ 
    131         public abstract HtmlForm<E> getInputs(E entity, boolean newrecord); 
    132  
     131        public abstract HtmlForm getInputs(E entity, boolean newrecord); 
     132 
     133        public List<HtmlInput> getInputs() 
     134        { 
     135                return getInputs((E)create(),true).getInputs(); 
     136        } 
     137         
     138        public List<HtmlInput> getInputs(E entity) 
     139        { 
     140                return getInputs(entity,false).getInputs(); 
     141        } 
     142         
    133143        /** 
    134144         * Provides the class of the entitites managed by this form. Note: Java 
     
    185195 
    186196        /** List of actions of this screen */ 
    187         private List<ScreenCommand<E>> actions = new ArrayList<ScreenCommand<E>>(); 
     197        private Map<String,ScreenCommand> commands = new LinkedHashMap<String, ScreenCommand>(); 
    188198 
    189199        /** entity csv reader */ 
    190         private CsvToDatabase<E> csvReader; 
     200        private CsvToDatabase csvReader; 
    191201 
    192202        /** currently known offset */ 
     
    209219 
    210220        /** cache of currently viewable records */ 
    211         private List<E> records = new ArrayList<E>(); 
     221        private List records = new ArrayList(); 
    212222 
    213223        /** whether this form can be edited */ 
     
    221231 
    222232        /** messages to show to the user */ 
    223         private Vector<ScreenMessage<E>> messages; 
     233        private Vector<ScreenMessage> messages; 
    224234 
    225235        /** Active command (in case of a command with dialog) */ 
    226         private ScreenCommand<E> currentCommand = null; 
     236        private ScreenCommand currentCommand = null; 
    227237 
    228238        /** columns that are invisible to the user */ 
     
    231241 
    232242        /** Helper object that takes care of database paging */ 
    233         private DatabasePager<E> pager; 
     243        private DatabasePager pager; 
    234244 
    235245        /** Here the currently selected is are stored */ 
     
    269279 
    270280                setMode(Mode.LIST_VIEW); 
    271                 setMessages(new Vector<ScreenMessage<E>>()); 
     281                setMessages(new Vector<ScreenMessage>()); 
    272282                setReadonly(false); 
    273283                resetSystemHiddenColumns(); 
    274284                resetUserHiddenColumns(); 
    275285 
    276                 setController(new FormController<E>(this)); 
     286                setController(new FormController(this)); 
    277287 
    278288                // add all actions 
     
    280290 
    281291                // File:Download visible 
    282                 ScreenCommand<E> f1 = new DownloadVisibleCommand("download_visible", this); 
    283                 super.addCommand("File", f1); 
     292                super.addCommand(new DownloadVisibleCommand("download_visible", this)); 
    284293 
    285294                // File:Download Selected 
    286                 SimpleCommand<E> f2 = new DownloadSelectedCommand<E>("download_selected", this); 
    287                 super.addCommand("File", f2); 
     295                super.addCommand(new DownloadSelectedCommand("download_selected", this)); 
    288296 
    289297                // FILE:Download all 
    290                 SimpleCommand<E> f3 = new DownloadAllCommand<E>("download_all", this); 
    291                 super.addCommand("File", f3); 
     298                super.addCommand(new DownloadAllCommand("download_all", this)); 
    292299 
    293300                // File: Add batch 
    294                 SimpleCommand<E> f4 = new AddBatchCommand<E>("upload_csv", this); 
    295                 super.addCommand("File", f4); 
     301                super.addCommand(new AddBatchCommand("upload_csv", this)); 
    296302 
    297303                // EDIT MENU 
    298304                // EDIT: Add new record 
    299                 SimpleCommand<E> e1 = new AddCommand<E>("edit_new", this); 
    300                 e1.setToolbar(true); 
    301                 super.addCommand("Edit", e1); 
     305                super.addCommand(new AddCommand("edit_new", this)); 
    302306 
    303307                // EDIT: Update selected 
    304                 SimpleCommand<E> e2 = new EditSelectedCommand<E>("edit_update_selected", this); 
    305                 super.addCommand("Edit", e2); 
    306  
    307                 SimpleCommand<E> e3 = new RemoveSelectedCommand<E>("edit_remove_selected", this); 
    308                 super.addCommand("Edit", e3); 
     308                super.addCommand(new EditSelectedCommand("edit_update_selected", this)); 
     309 
     310                // EDIT: Remove selected 
     311                super.addCommand(new RemoveSelectedCommand("edit_remove_selected", this)); 
    309312 
    310313                // menu VIEW 
    311                 // SimpleCommand<E> v2 = new ViewRecordViewCommand<E>("recordview", 
     314                // ScreenCommand v2 = new ViewRecordViewCommand("recordview", 
    312315                // this); 
    313316                // v2.setToolbar(true); 
    314317                // super.addCommand("View", v2); 
    315318 
    316                 SimpleCommand<E> v3 = new ViewEditViewCommand<E>("editview", this); 
    317319                // v3.setToolbar(true); 
    318                 super.addCommand("View", v3); 
    319  
    320                 SimpleCommand<E> v4 = new ViewListViewCommand<E>("listview", this); 
    321                 v4.setToolbar(true); 
    322                 super.addCommand("View", v4); 
    323  
    324                 ChangeListLimitCommand<E> view_5 = new ChangeListLimitCommand<E>("view_5show5", this); 
     320                super.addCommand(new ViewEditViewCommand("editview", this)); 
     321                super.addCommand(new ViewListViewCommand("listview", this)); 
     322 
     323                ChangeListLimitCommand view_5 = new ChangeListLimitCommand("view_5show5", this); 
    325324                view_5.setLimit(5); 
    326                 super.addCommand("View", view_5); 
    327  
    328                 ChangeListLimitCommand<E> view_10 = new ChangeListLimitCommand<E>("view_6show10", this); 
     325                super.addCommand(view_5); 
     326 
     327                ChangeListLimitCommand view_10 = new ChangeListLimitCommand("view_6show10", this); 
    329328                view_5.setLimit(10); 
    330                 super.addCommand("View", view_10); 
    331  
    332                 ChangeListLimitCommand<E> view_20 = new ChangeListLimitCommand<E>("view_7show20", this); 
     329                super.addCommand(view_10); 
     330 
     331                ChangeListLimitCommand view_20 = new ChangeListLimitCommand("view_7show20", this); 
    333332                view_20.setLimit(20); 
    334                 super.addCommand("View", view_20); 
    335  
    336                 ChangeListLimitCommand<E> view_50 = new ChangeListLimitCommand<E>("view_8show50", this); 
     333                super.addCommand(view_20); 
     334 
     335                ChangeListLimitCommand view_50 = new ChangeListLimitCommand("view_8show50", this); 
    337336                view_50.setLimit(50); 
    338                 super.addCommand("View", view_50); 
    339  
    340                 ChangeListLimitCommand<E> view_100 = new ChangeListLimitCommand<E>("view_9show100", this); 
     337                super.addCommand(view_50); 
     338 
     339                ChangeListLimitCommand view_100 = new ChangeListLimitCommand("view_9show100", this); 
    341340                view_100.setLimit(100); 
    342                 super.addCommand("View", view_100); 
    343  
    344                 ChangeListLimitCommand<E> view_500 = new ChangeListLimitCommand<E>("view_10show500", this); 
     341                super.addCommand(view_100); 
     342 
     343                ChangeListLimitCommand view_500 = new ChangeListLimitCommand("view_10show500", this); 
    345344                view_500.setLimit(500); 
    346                 super.addCommand("View", view_500); 
     345                super.addCommand(view_500); 
    347346 
    348347                // add the plugged-in actions 
    349                 for (ScreenCommand<E> command : this.actions) 
    350                 { 
    351                         super.addCommand(command.getMenu(), command); 
     348                for (ScreenCommand command : this.commands.values()) 
     349                { 
     350                        super.addCommand(command); 
    352351                } 
    353352        } 
    354353 
    355354        @Override 
    356         public boolean isVisible() 
    357         { 
    358                 return this.getSecurity().canRead(this.create().getClass()); 
     355        public boolean isVisible()  
     356        { 
     357                try 
     358                { 
     359                        return this.getSecurity().canRead(this.create().getClass()); 
     360                } 
     361                catch (DatabaseException e) 
     362                { 
     363                        // TODO Auto-generated catch block 
     364                        e.printStackTrace(); 
     365                } 
     366                return false; 
    359367        } 
    360368 
     
    368376                Vector<ScreenCommand> toolbar = new Vector<ScreenCommand>(); 
    369377 
    370                 for (CommandMenu<E> menu : this.getMenus()) 
    371                 { 
    372                         for (ScreenCommand<E> c : menu.getCommands()) 
     378                for (CommandMenu menu : this.getMenus()) 
     379                { 
     380                        for (ScreenCommand c : menu.getCommands()) 
    373381                        { 
    374382                                if (c.isToolbar() && c.isVisible()) 
     
    442450                                        // xref only 
    443451                                        Object value = records.get(0).get(pf.getParentId()); 
    444                                         Object label = records.get(0).get(pf.getParentLabel()); 
    445452                                        if (!(value instanceof List) && value != null) 
    446453                                        { 
    447454                                                entity.set(pf.getXrefToParent(), value); 
    448                                                 entity.set(pf.getXrefToParent()+"_"+pf.getParentLabel(), label); 
     455                                        } 
     456                                         
     457                                        for(String labelName: pf.getParentLabels()) 
     458                                        { 
     459                                                Object label = records.get(0).get(labelName); 
     460                                                entity.set(pf.getXrefToParent()+"_"+labelName, label); 
    449461                                        } 
    450462                                } 
     
    482494         * @throws DatabaseException 
    483495         */ 
    484         public HtmlForm<E> getNewRecordForm() throws DatabaseException 
     496        public HtmlForm getNewRecordForm() throws DatabaseException 
    485497        { 
    486498                E entity = this.create(); 
     
    495507         *         row on screen. 
    496508         */ 
    497         public Vector<HtmlForm<E>> getRecordInputs() 
    498         { 
    499                 Vector<HtmlForm<E>> records = new Vector<HtmlForm<E>>(); 
     509        public Vector<HtmlForm> getRecordInputs() 
     510        { 
     511                Vector<HtmlForm> records = new Vector<HtmlForm>(); 
    500512 
    501513                try 
     
    503515                        for (E entity : getRecords()) 
    504516                        { 
    505                                 HtmlForm<E> record = getInputs(entity, false); 
     517                                HtmlForm record = getInputs(entity, false); 
    506518                                record.setReadonly(!getSecurity().canWrite(entity)); 
    507519                                records.add(record); 
     
    663675         * @param recordlist 
    664676         */ 
    665         public void setRecords(List<E> recordlist) 
     677        public void setRecords(List recordlist) 
    666678        { 
    667679                this.records = recordlist; 
     
    786798         * @param messages 
    787799         */ 
    788         public void setMessages(Vector<ScreenMessage<E>> messages) 
     800        public void setMessages(Vector<ScreenMessage> messages) 
    789801        { 
    790802                this.messages = messages; 
    791803        } 
    792804 
    793         public void setMessages(ScreenMessage<E>... messages) 
    794         { 
    795                 this.messages = new Vector<ScreenMessage<E>>(Arrays.asList(messages)); 
     805        public void setMessages(ScreenMessage... messages) 
     806        { 
     807                this.messages = new Vector<ScreenMessage>(Arrays.asList(messages)); 
    796808        } 
    797809 
     
    799811         * @return Messages to inform the user of state changes and succes. 
    800812         */ 
    801         public Vector<ScreenMessage<E>> getMessages() 
     813        public Vector<ScreenMessage> getMessages() 
    802814        { 
    803815                return this.messages; 
     
    873885        } 
    874886 
    875         public CsvToDatabase<E> getCsvReader() 
     887        public CsvToDatabase getCsvReader() 
    876888        { 
    877889                return csvReader; 
    878890        } 
    879891 
    880         public void setCsvReader(CsvToDatabase<E> csvReader) 
     892        public void setCsvReader(CsvToDatabase csvReader) 
    881893        { 
    882894                this.csvReader = csvReader; 
     
    888900        } 
    889901 
    890         public List<ScreenCommand<E>> getActions() 
    891         { 
    892                 return actions; 
    893         } 
    894  
    895         public void addAction(ScreenCommand<E> action) 
    896         { 
    897                 this.actions.add(action); 
    898         } 
    899  
    900         public ScreenCommand<E> getCurrentCommand() 
     902        public List<ScreenCommand> getCommands() 
     903        { 
     904                return new ArrayList<ScreenCommand>(commands.values()); 
     905        } 
     906 
     907        public ScreenCommand getCurrentCommand() 
    901908        { 
    902909                return currentCommand; 
    903910        } 
    904911 
    905         public void setCurrentCommand(ScreenCommand<E> currentCommand) 
     912        public void setCurrentCommand(ScreenCommand currentCommand) 
    906913        { 
    907914                this.currentCommand = currentCommand; 
  • molgenis/3.3/src/org/molgenis/framework/ui/MenuModel.java

    r2442 r2674  
    1717import java.util.List; 
    1818 
    19  
    20  
    2119/** 
    2220 * This class describes the functionality needed for a menu-screen. The 
     
    3129        public enum Position 
    3230        { 
    33                 /* put on top of subform, float to right*/ 
     31                /* put on top of subform, float to right */ 
    3432                TOP_RIGHT, 
    3533                /* put on top of subform, float to left */ 
     
    5957                super(name, parent); 
    6058                setController(new MenuController(this)); 
    61                 //macro has exact name as class, but then ending with 'view'. 
     59                // macro has exact name as class, but then ending with 'view'. 
    6260                setViewMacro(MenuModel.class.getSimpleName().replace("Model", "View")); 
    6361        } 
     
    7169        public void hide(String name) 
    7270        { 
    73                 if (this.get(name) != null) hiddenScreenNames.add(name); 
     71                if (this.get(name) != null) 
     72                        hiddenScreenNames.add(name); 
    7473 
    7574        } 
     
    110109        { 
    111110                List<ScreenModel> subscreens = getVisibleChildren(); 
    112                 if(subscreens.contains(super.getSelected())) 
     111                if (subscreens.contains(super.getSelected())) 
    113112                { 
    114113                        return super.getSelected(); 
    115114                } 
    116                 else if(subscreens.size() > 0) 
     115                else if (subscreens.size() > 0) 
    117116                { 
    118117                        return subscreens.get(0); 
     
    128127        { 
    129128                // the menu is visible if one its children is visible. 
    130                 if (this.getVisibleChildren().size() > 0) return true; 
     129                if (this.getVisibleChildren().size() > 0) 
     130                        return true; 
    131131                return false; 
    132132        } 
     
    141141                this.position = position; 
    142142        } 
     143 
     144        public String getCustomHtmlHeaders() 
     145        { 
     146                if (this.getSelected() != null) 
     147                { 
     148                        return this.getSelected().getCustomHtmlHeaders(); 
     149                } 
     150                return ""; 
     151        } 
    143152} 
  • molgenis/3.3/src/org/molgenis/framework/ui/ScreenMessage.java

    r2308 r2674  
    1010package org.molgenis.framework.ui; 
    1111 
     12import org.molgenis.util.Entity; 
     13 
    1214// imports 
    1315 
     
    2022 * @version 1.0.0 
    2123 */ 
    22 public class ScreenMessage<E> 
     24public class ScreenMessage 
    2325{ 
    2426        // constructor 
     
    3133         * @param success Indicates whether the transaction was succesfull. 
    3234         */ 
    33         public ScreenMessage(String message, E entity, boolean success) 
     35        public ScreenMessage(String message, Entity entity, boolean success) 
    3436        { 
    3537                this.entity = entity; 
     
    6567         * @return The entity. 
    6668         */ 
    67         public E getEntity() 
     69        public Entity getEntity() 
    6870        { 
    6971                return entity; 
     
    106108 
    107109        /** The entity that was used in the database and generated this message */ 
    108         private E entity; 
     110        private Entity entity; 
    109111 
    110112        /** Whether the operation on the database was succesfull */ 
  • molgenis/3.3/src/org/molgenis/framework/ui/ScreenModel.java

    r2442 r2674  
    5858                SHOW_MAIN("inline"),  
    5959                /** 
    60                  * Show the current screen or command as popup. This means the layout template is applied on this element. 
     60                 * Show the current screen or command as popup. This means the layout template is applied on this element only. 
    6161                 */ 
    6262                SHOW_DIALOG("popup"),  
    6363                /** 
    64                  * Pass current screen in handlerequest the outputstream so it can be 
     64                 * Don't layout the screen. Instead pass use the outputstream in handleRequest so it can be 
    6565                 * downloaded. This result in a download file. 
    6666                 */ 
  • molgenis/3.3/src/org/molgenis/framework/ui/SimpleModel.java

    r2629 r2674  
    190190 
    191191        /** COMMANDS for on the menu bar. Idea: move to screen? * */ 
    192         public void addCommand(String menu_name, ScreenCommand command) 
     192        public <E extends ScreenCommand>void addCommand(E command) 
    193193        { 
    194194                // link the command to the screen 
     
    199199                if (getCommand(command.getName()) != null) 
    200200                { 
    201                         throw new RuntimeException("addCommand failed: command with name '" + command.getName() 
    202                                         + "' already exists"); 
     201                        logger.warn("command with name '" + command.getName() 
     202                                        + "' already exists; replaced"); 
    203203                } 
    204204 
    205205                // create new menu if not exists 
    206                 if (menubar.containsKey(menu_name) == false) 
    207                 { 
    208                         menubar.put(menu_name, new CommandMenu(menu_name, (FormModel) this, menu_name, "", "")); 
     206                if (menubar.containsKey(command.getMenu()) == false) 
     207                { 
     208                        menubar.put(command.getMenu(), new CommandMenu(command.getMenu(), (FormModel) this, command.getMenu(), "", "")); 
    209209                } 
    210210 
    211211                // put the command in the menu 
    212                 menubar.get(menu_name).addCommand(command); 
     212                menubar.get(command.getMenu()).addCommand(command); 
    213213                this.logger.debug("added action " + command.getName()); 
    214214        } 
     
    237237        public String getCustomHtmlHeaders() 
    238238        { 
    239                 if (this.getSelected() != null) 
    240                 { 
    241                         return this.getSelected().getCustomHtmlHeaders(); 
    242                 } 
    243                 else 
    244                 { 
     239//              if (this.getSelected() != null) 
     240//              { 
     241//                      return this.getSelected().getCustomHtmlHeaders(); 
     242//              } 
     243//              else 
     244//              { 
    245245                        String result = ""; 
    246246                        for(ScreenModel m: this.getChildren()) 
     
    249249                        } 
    250250                        return result; 
    251                 } 
     251        //      } 
    252252 
    253253        } 
  • molgenis/3.3/src/org/molgenis/framework/ui/UserInterface.ftl

    r2442 r2674  
    3131<div id="container"> 
    3232         
    33 <#list screen.getVisibleChildren() as subscreen> 
     33<#list screen.children as subscreen> 
    3434        <@layout subscreen /> 
    3535</#list> 
  • molgenis/3.3/src/org/molgenis/framework/ui/UserInterface.java

    r2442 r2674  
    1919 * of authentication/authorization). 
    2020 */ 
    21 public class UserInterface extends MenuModel implements ScreenController 
     21public class UserInterface extends SimpleModel implements ScreenController 
    2222{ 
    2323        public static String MOLGENIS_TEMP_PATH = "molgenis_temp"; 
     
    181181        } 
    182182 
    183         /** 
    184          * This enables plugin developers to add their custom css or javascript (or 
    185          * whatever) headers. 
    186          *  
    187          * @return valid header html such as css or javascript references 
    188          */ 
    189         public String getCustomHtmlHeaders() { 
    190                 return this.getSelected().getCustomHtmlHeaders(); 
    191         } 
    192          
    193183        public String getVersion() 
    194184        { 
     
    210200                this.emailService = emailService; 
    211201        } 
     202 
     203        @Override 
     204        public boolean isVisible() 
     205        { 
     206                // TODO Auto-generated method stub 
     207                return true; 
     208        } 
    212209} 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/AddBatchCommand.java

    r2442 r2674  
    1414import org.molgenis.framework.ui.ScreenMessage; 
    1515import org.molgenis.framework.ui.ScreenModel; 
    16 import org.molgenis.framework.ui.ScreenModel.Show; 
    1716import org.molgenis.framework.ui.html.ActionInput; 
    1817import org.molgenis.framework.ui.html.HtmlInput; 
     
    2524 * The command to add in batch/upload csv 
    2625 */ 
    27 public class AddBatchCommand<E extends Entity> extends SimpleCommand<E> 
     26public class AddBatchCommand extends SimpleCommand 
    2827{ 
    2928 
    30         public AddBatchCommand(String name, FormModel<E> owner) 
     29        public AddBatchCommand(String name, FormModel owner) 
    3130        { 
    3231                super(name, owner); 
     
    3433                this.setIcon("generated-res/img/upload.png"); 
    3534                this.setDialog(true); 
     35                this.setMenu("File"); 
    3636        } 
    3737 
     
    8080                if (request.getString(FormModel.INPUT_SHOW) == null) 
    8181                { 
    82                         ScreenMessage<E> msg = null; 
     82                        ScreenMessage msg = null; 
    8383                        try 
    8484                        { 
    85                                 CsvToDatabase<E> csvReader = this.getFormScreen().getCsvReader(); 
     85                                CsvToDatabase csvReader = this.getFormScreen().getCsvReader(); 
    8686 
    8787                                int updatedRows = csvReader.importCsv(db, new CsvStringReader(request 
     
    9090                                // logger.debug("parsed: " + entity); 
    9191                                // view.getDatabase().add(entities); 
    92                                 msg = new ScreenMessage<E>("CSV UPLOAD SUCCESS: added " + updatedRows + " rows", null, true); 
     92                                msg = new ScreenMessage("CSV UPLOAD SUCCESS: added " + updatedRows + " rows", null, true); 
    9393                                logger.debug("CSV UPLOAD SUCCESS: added " + updatedRows + " rows"); 
    9494                                getFormScreen().getPager().resetFilters(); 
     
    9898                        { 
    9999                                e.printStackTrace(); 
    100                                 msg = new ScreenMessage<E>("CSV UPLOAD FAILED: " + e.getMessage(), null, false); 
     100                                msg = new ScreenMessage("CSV UPLOAD FAILED: " + e.getMessage(), null, false); 
    101101                                logger.error("CSV UPLOAD FAILED: " + e.getMessage()); 
    102102                        } 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/AddCommand.java

    r2442 r2674  
    2020 * The command to add a new record 
    2121 */ 
    22 public class AddCommand<E extends Entity> extends SimpleCommand<E> 
     22public class AddCommand extends SimpleCommand 
    2323{ 
    24         public AddCommand(String name, FormModel<E> parent) 
     24        public AddCommand(String name, FormModel parent) 
    2525        { 
    2626                super(name, parent); 
     
    2828                this.setIcon("generated-res/img/new.png"); 
    2929                this.setDialog(true); 
    30  
     30                this.setMenu("Edit"); 
     31                this.setToolbar(true); 
    3132        } 
    3233 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/AddCommand2.java

    r2442 r2674  
    2525 * screen again. 
    2626 */ 
    27 public class AddCommand2<E extends Entity> extends SimpleCommand<E> 
     27public class AddCommand2<E extends Entity> extends SimpleCommand 
    2828{ 
    2929        Tuple previousRequest = new SimpleTuple(); 
    30         Vector<ScreenMessage<E>> messages = new Vector<ScreenMessage<E>>(); 
     30        Vector<ScreenMessage> messages = new Vector<ScreenMessage>(); 
    3131        boolean success = false; 
    3232 
    33         public AddCommand2(String name, FormModel<E> parent) 
     33        public AddCommand2(String name, FormModel parent) 
    3434        { 
    3535                super(name, parent); 
     
    8181                { 
    8282                        // delegate to the form controller 
    83                         boolean success = ((FormController<E>) this.getScreen().getController()).doAdd(db, request); 
     83                        boolean success = ((FormController) this.getScreen().getController()).doAdd(db, request); 
    8484                        this.messages = this.getFormScreen().getMessages();  
    8585                } 
     
    8787        } 
    8888         
    89         public Vector<ScreenMessage<E>> getMessages() 
     89        public Vector<ScreenMessage> getMessages() 
    9090        { 
    9191                return messages; 
    9292        } 
    9393 
    94         public void setMessages(Vector<ScreenMessage<E>> messages) 
     94        public void setMessages(Vector<ScreenMessage> messages) 
    9595        { 
    9696                this.messages = messages; 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/ChangeListLimitCommand.java

    r2442 r2674  
    2121 * @param <E> 
    2222 */ 
    23 public class ChangeListLimitCommand<E extends Entity> extends SimpleCommand<E> 
     23public class ChangeListLimitCommand extends SimpleCommand 
    2424{ 
    2525        //the limit it should change too 
    2626        private int limit = 5; 
    2727 
    28         public ChangeListLimitCommand(String name, FormModel<E> parentScreen) 
     28        public ChangeListLimitCommand(String name, FormModel parentScreen) 
    2929        { 
    3030                super(name, parentScreen); 
    3131                this.setLabel("Show %s items"); 
    3232                this.setIcon("generated-res/img/limit.png"); 
     33                this.setMenu("View"); 
    3334        } 
    3435 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/CommandMenu.java

    r2442 r2674  
    66import java.util.Map; 
    77 
    8 import org.apache.log4j.Logger; 
    98import org.molgenis.framework.db.DatabaseException; 
    109import org.molgenis.framework.ui.FormModel; 
     
    1413 
    1514 
    16 public class CommandMenu<E extends Entity> extends SimpleCommand<E> 
     15public class CommandMenu extends SimpleCommand 
    1716{ 
    18         private static Logger logger = Logger.getLogger(CommandMenu.class); 
    19          
    2017        /** menu items with order as entered*/ 
    2118        private Map<String,ScreenCommand> menu_items = new LinkedHashMap<String,ScreenCommand>(); 
    2219 
    23         public CommandMenu(String id, FormModel<E> screen, String label, String icon, String action) 
     20        public <E extends Entity>CommandMenu(String id, FormModel screen, String label, String icon, String action) 
    2421        { 
    2522                super( id, screen ); 
     
    4441                if(menu_items.containsKey(command.getName())) 
    4542                { 
    46                         throw new IllegalArgumentException("addCommand: command with id '"+command.getName()+"' already exists"); 
     43                        logger.warn("addCommand: command with id '"+command.getName()+"' already exists; replaced"); 
    4744                } 
    4845                menu_items.put(command.getName(),command); 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadAllCommand.java

    r2442 r2674  
    2121 * @param <E> 
    2222 */ 
    23 public class DownloadAllCommand<E extends Entity> extends SimpleCommand<E> 
     23public class DownloadAllCommand extends SimpleCommand 
    2424{ 
    25         public DownloadAllCommand(String name, FormModel<E> parentScreen) 
     25        public DownloadAllCommand(String name, FormModel parentScreen) 
    2626        { 
    2727                super(name, parentScreen); 
     
    2929                this.setIcon("generated-res/img/download.png"); 
    3030                this.setDownload(true); 
     31                this.setMenu("File"); 
    3132        } 
    3233 
     
    3637                logger.debug(this.getName()); 
    3738 
    38                 FormModel<E> view = this.getFormScreen(); 
     39                FormModel view = this.getFormScreen(); 
    3940                db.find(view.getEntityClass(), new CsvWriter(csvDownload), view.getRulesExclLimitOffset()); 
    4041 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadSelectedCommand.java

    r2442 r2674  
    2020import org.molgenis.framework.ui.html.HtmlInput; 
    2121import org.molgenis.util.CsvWriter; 
    22 import org.molgenis.util.Entity; 
    2322import org.molgenis.util.Tuple; 
    2423 
     
    2827 * @param <E> 
    2928 */ 
    30 public class DownloadSelectedCommand<E extends Entity> extends SimpleCommand<E> 
     29public class DownloadSelectedCommand extends SimpleCommand 
    3130{ 
    32         public DownloadSelectedCommand(String name, FormModel<E> parentScreen) 
     31        public DownloadSelectedCommand(String name, FormModel parentScreen) 
    3332        { 
    3433                super(name, parentScreen); 
     
    3635                this.setIcon("generated-res/img/download.png"); 
    3736                this.setDownload(true); 
     37                this.setMenu("File"); 
    3838        } 
    3939 
     
    5151                logger.debug(this.getName()); 
    5252                 
    53                 FormModel<E> view = this.getFormScreen(); 
     53                FormModel view = this.getFormScreen(); 
    5454 
    5555                Object ids = request.getObject(FormModel.INPUT_SELECTED); 
     
    5858                if (ids != null) 
    5959                { 
    60                         if (ids.getClass().equals(Vector.class)) records = (Vector<String>) ids; 
     60                        if (ids.getClass().equals(Vector.class)) records = (Vector)ids; 
    6161                        else 
    6262                                records.add(ids.toString()); 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadVisibleCommand.java

    r2442 r2674  
    2424 * @param <E> 
    2525 */ 
    26 public class DownloadVisibleCommand<E extends Entity> extends SimpleCommand<E> 
     26public class DownloadVisibleCommand extends SimpleCommand 
    2727{ 
    28         public DownloadVisibleCommand(String name, FormModel<E> parentScreen) 
     28        public DownloadVisibleCommand(String name, FormModel parentScreen) 
    2929        { 
    3030                super(name, parentScreen); 
     
    3232                this.setLabel("Download visible"); 
    3333                this.setIcon("generated-res/img/download.png"); 
     34                this.setMenu("File"); 
    3435        } 
    3536 
     
    4041                logger.debug(this.getName()); 
    4142 
    42                 FormModel<E> view = this.getFormScreen(); 
    43                 List<E> records = view.getRecords(); 
     43                FormModel view = this.getFormScreen(); 
     44                List<Entity> records = view.getRecords(); 
    4445                CsvWriter writer = new CsvWriter(csvDownload, view.create().getFields()); 
    4546                writer.writeHeader(); 
    46                 for (E e : records) 
     47                for (Entity e : records) 
    4748                        writer.writeRow(e); 
    4849                 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/EditSelectedCommand.java

    r2442 r2674  
    1919 * template 
    2020 */ 
    21 public class EditSelectedCommand<E extends Entity> extends SimpleCommand<E> 
     21public class EditSelectedCommand extends SimpleCommand 
    2222{ 
    23         public EditSelectedCommand(String name, FormModel<E> parentScreen) 
     23        public EditSelectedCommand(String name, FormModel parentScreen) 
    2424        { 
    2525                super(name, parentScreen); 
     
    2727                this.setIcon("generated-res/img/update.gif"); 
    2828                this.setDialog(true); 
     29                this.setMenu("Edit"); 
    2930        } 
    3031 
     
    3839        public boolean isVisible() 
    3940        { 
    40                 FormModel<E> view = this.getFormScreen(); 
     41                FormModel view = this.getFormScreen(); 
    4142                return !view.isReadonly() && view.getMode().equals(Mode.LIST_VIEW); 
    4243        } 
     
    5051                if (request.getString(FormModel.INPUT_SHOW) == null) 
    5152                { 
    52                         FormModel<E> view = this.getFormScreen(); 
     53                        FormModel view = this.getFormScreen(); 
    5354                        List<Object> idList = request.getList(FormModel.INPUT_SELECTED); 
    5455                        for (Object id : idList) 
     
    5758                        } 
    5859 
    59                         ScreenMessage<E> msg = null; 
     60                        ScreenMessage msg = null; 
    6061 
    6162                        int row = 0; 
    6263                        try 
    6364                        { 
    64                                 Query q = db.query(view.getEntityClass()).in(view.create().getIdField(), idList); 
    65                                 List<E> entities = q.find(); 
     65                                Query<Entity> q = db.query(view.getEntityClass()).in(view.create().getIdField(), idList); 
     66                                List<Entity> entities = q.find(); 
    6667 
    6768                                db.beginTx(); 
    68                                 for (E e : entities) 
     69                                for (Entity e : entities) 
    6970                                { 
    7071                                        row++; 
     
    7374                                } 
    7475                                db.commitTx(); 
    75                                 msg = new ScreenMessage<E>("MASS UPDATE SUCCESS: updated " + entities.size() + " rows", null, true); 
     76                                msg = new ScreenMessage("MASS UPDATE SUCCESS: updated " + entities.size() + " rows", null, true); 
    7677                        } 
    7778 
     
    8788                                        e1.printStackTrace(); 
    8889                                } 
    89                                 msg = new ScreenMessage<E>("MASS UPDATE FAILED on item '" + row + "': " + e, null, false); 
     90                                msg = new ScreenMessage("MASS UPDATE FAILED on item '" + row + "': " + e, null, false); 
    9091                        } 
    9192 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/PluginCommand.java

    r2308 r2674  
    99import org.molgenis.util.Tuple; 
    1010 
    11 public abstract class PluginCommand<E extends Entity> extends SimpleCommand<E> 
     11public abstract class PluginCommand extends SimpleCommand 
    1212{ 
    1313        /** Constructor */ 
    14         public PluginCommand(String name, FormModel<E> parentScreen) 
     14        public PluginCommand(String name, FormModel parentScreen) 
    1515        { 
    1616                super(name, parentScreen); 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/RemoveSelectedCommand.java

    r2442 r2674  
    2020import org.molgenis.util.Tuple; 
    2121 
    22 public class RemoveSelectedCommand<E extends Entity> extends SimpleCommand<E> 
     22public class RemoveSelectedCommand extends SimpleCommand 
    2323{ 
    24         public RemoveSelectedCommand(String name, FormModel<E> parentScreen) 
     24        public RemoveSelectedCommand(String name, FormModel parentScreen) 
    2525        { 
    2626                super(name, parentScreen); 
    2727                this.setLabel("Remove selected"); 
    2828                this.setIcon("generated-res/img/delete.png"); 
     29                this.setMenu("Edit"); 
    2930        } 
    3031 
     
    4142                logger.debug(this.getName()); 
    4243                 
    43                 FormModel<E> view = getFormScreen(); 
     44                FormModel view = getFormScreen(); 
    4445 
    45                 ScreenMessage<E> msg = null; 
     46                ScreenMessage msg = null; 
    4647                try 
    4748                { 
     
    5556 
    5657                        // find selected entities 
    57                         Query q = db.query(view.getEntityClass()).in(view.create().getIdField(), idList); 
    58                         List<E> selection = q.find(); 
     58                        Query<Entity> q = db.query(view.getEntityClass()).in(view.create().getIdField(), idList); 
     59                        List<Entity> selection = q.find(); 
    5960 
    6061                        // delete selected entities 
    6162                        db.remove(selection); 
    62                         msg = new ScreenMessage<E>("REMOVED " + selection.size() + " records", null, true); 
     63                        msg = new ScreenMessage("REMOVED " + selection.size() + " records", null, true); 
    6364                } 
    6465                catch (Exception e) 
    6566                { 
    66                         msg = new ScreenMessage<E>("REMOVE SELECTION FAILED: " + e.getMessage(), null, false); 
     67                        msg = new ScreenMessage("REMOVE SELECTION FAILED: " + e.getMessage(), null, false); 
    6768                } 
    6869                view.getMessages().add(msg); 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/ScreenCommand.java

    r2442 r2674  
    1616 
    1717/** 
    18  * A command describes actions to change the state of a screen (each consequence 
    19  * of command is handled by a Screen.handleRequest function). 
     18 * A command defines a button on a screen, including the logic when the command 
     19 * is executed. In architecture it behaves the same as any screen, i.e. it is 
     20 * Templateable to allow for customized layouts. However, the default layout is 
     21 * usually sufficient listing inputs (from getInputs) and actions (from 
     22 * getActions). 
     23 * <ul> 
     24 * <li>handleRequest() defines how the action should be processed and how the 
     25 * result should be shown</li> 
     26 * <li>getInputs() lists the inputs to be shown</li> 
     27 * <li>getActions() lists the pushbuttons to be shown</li> 
     28 * </ul> 
    2029 */ 
    21 public interface ScreenCommand<E extends Entity> extends Templateable 
     30public interface ScreenCommand extends Templateable 
    2231{ 
    2332        /** 
    24          * Retrieve the name of the icon to be shown. No icon will be if null) 
     33         * Retrieve the name of the icon to be shown. No icon will be shown if null. 
    2534         *  
    2635         * @return path to the icon 
     
    2938 
    3039        /** 
    31          * Set the name of the icon to be shown. No icon will be if null) 
     40         * Set the name of the icon to be shown. No icon will be if null. 
    3241         *  
    3342         * @param icon 
     
    3746 
    3847        /** 
    39          * Hide this command 
    40          *  
    41          * @param hide 
    42          *            if true, the command will be hidden. 
    43          */ 
    44         public void setHidden(boolean hide); 
    45  
    46         /** 
    4748         * @return descriptive label of this command 
    4849         */ 
     
    5657 
    5758        /** 
    58          * Override the default javascript for this command by your own. 
     59         * Override the default javascript for this command by your own (usally not 
     60         * necessary, @see 'isDialog'). 
    5961         *  
    6062         * @param action 
     
    6466 
    6567        /** 
    66          * FIXME can this be hidden? 
     68         * Returns the javascript that is run when this action is clicked. 
    6769         *  
    6870         * @return the javascript that should be executed onClick. 
     
    7274        /** 
    7375         * @param name 
    74          *            unique action name of this command (unique within one screen) 
     76         *            unique action name of this command (unique within the parent 
     77         *            screen) 
    7578         */ 
    7679        public void setName(String name); 
     
    8184        public String getName(); 
    8285 
    83         /** @return Unique name of the target screen that should handle this command */ 
     86        /** 
     87         * @return Unique name of the target screen that should handle this command. 
     88         *         Default this equals getScreen(), i.e. the target is the same as 
     89         *         the screen this command is part of. 
     90         */ 
    8491        public String getTarget(); 
    8592 
    8693        /** 
    87          * @param target Unique 
    88          *            name of the target screen that should handle this command 
     94         * @param target 
     95         *            Unique name of the target screen that should handle this 
     96         *            command 
    8997         */ 
    9098        public void setTarget(String target); 
    9199 
    92100        /** 
    93          * @return The screen this command is a child of 
     101         * @return The screen this command is a part of 
    94102         */ 
    95103        public ScreenModel getScreen(); 
    96          
     104 
    97105        /** 
    98106         * Helper method to reduce casting 
     
    106114        public void setScreen(ScreenModel screen); 
    107115 
    108         /** @return true if this command should show a dialog */ 
     116        /** 
     117         * @return true if this command should be shown as a dialog. @see #setDialog 
     118         */ 
    109119        public boolean isDialog(); 
    110120 
    111121        /** 
    112          * @param dialog set 
    113          *            to true if MOLGENIS should show this command via a dialog 
     122         * @param dialog 
     123         *            set to true if MOLGENIS should show this command via a dialog. 
     124         *            This results in javascript that pop-ups a dialog when pushed. 
    114125         */ 
    115126        public void setDialog(boolean dialog); 
     
    117128        /** 
    118129         * @return the unique name of the menu this command is part of. Null 
    119          *         indicates it will now shown on the menu. 
     130         *         indicates it will not be shown on the menu. 
    120131         */ 
    121132        public String getMenu(); 
     
    123134        /** 
    124135         * @param menu 
    125          *            unique name of the screenmenu this command is part of (typically shown on top of each screen). Not to be confused with the parent ScreenMenu. 
     136         *            unique name of the screenmenu this command is part of 
     137         *            (typically shown on top of each screen). Not to be confused 
     138         *            with the parent ScreenMenu. 
    126139         */ 
    127140        public void setMenu(String menu); 
     
    142155 
    143156        /** 
    144          * Handle the request thrown by this command. Typically handled by subclassing. 
    145          *  
    146          * @param db provides access to the database 
     157         * Handle the request thrown by this command. 
     158         *  
     159         * @param db 
     160         *            provides access to the database 
    147161         * @param request 
     162         *            provides access to the filled in inputs and actions 
    148163         * @param downloadStream 
    149          *            this the request can use to write results as download 
    150          * @return if their should still be a popup, inline or download 
     164         *            this the request can use to write results as download (in 
     165         *            combination with Show.VIEW_DOWNLOAD 
     166         * @return a Show.XYZ that indicates if next action should be shown as 
     167         *         popup, back to main screen or as download. @see ScreenModel.Show 
    151168         * @throws IOException 
    152169         * @throws DatabaseException 
    153170         * @throws ParseException 
    154171         */ 
    155         public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, 
    156                         DatabaseException, IOException; 
     172        public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) 
     173                        throws ParseException, DatabaseException, IOException; 
    157174 
    158175        /** 
    159176         * @return boolean whether this action should be treated as a download 
    160          *         action. 
     177         *         button. 
    161178         */ 
    162179        public boolean isDownload(); 
    163180 
    164181        /** 
    165          * @param download true indicates that this action should be treated as a download 
    166          *        action. @see handleRequest() where the download target is passed as stream. 
     182         * @param download 
     183         *            true indicates that this action should be treated as a 
     184         *            download action. @see handleRequest() where the download 
     185         *            target is passed as stream and ScreenModel.Show can return 
     186         *            Show.VIEW_DOWNLOAD. 
    167187         */ 
    168188        public void setDownload(boolean download); 
    169189 
    170190        /** 
    171          * @return whether this command should be shown on the command menu 
     191         * @return whether this command should be shown on the command menu. 
    172192         */ 
    173193        public boolean isToolbar(); 
     
    176196         * @param showOnToolbar 
    177197         *            indicates whether this command should be shown on the command 
    178          *            menu 
     198         *            menu. 
    179199         */ 
    180200        public void setToolbar(boolean showOnToolbar); 
    181201 
    182202        /** 
    183          * @return the layout macro to be used if this command has a dialog 
    184          */ 
    185         String getViewName(); 
    186  
    187         /** 
    188          * @return the layout macro to be used if this command has a dialog 
    189          */ 
    190         String getViewTemplate(); 
     203         * @return the layout macro to be used if this command has a dialog. 
     204         *         Defaults to the default layout showing inputs and actions. 
     205         */ 
     206        public String getViewName(); 
     207 
     208        /** 
     209         * @return the layout macro to be used if this command has a dialog. 
     210         *         Defaults to the default layout template for commands, 
     211         *         ScreenCommand.ftl 
     212         */ 
     213        public String getViewTemplate(); 
    191214 
    192215        /** 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/SimpleCommand.java

    r2442 r2674  
    1212import org.molgenis.framework.ui.ScreenModel; 
    1313import org.molgenis.framework.ui.ScreenModel.Show; 
     14import org.molgenis.framework.ui.html.HtmlForm; 
    1415import org.molgenis.framework.ui.html.HtmlInput; 
    1516import org.molgenis.util.Entity; 
     
    1718 
    1819/** 
    19  * Base class to link a command to a formscreen. <br> 
    20  * TODO: this may be very useful for other screens also. 
     20 * Implementation of screen command. 
    2121 */ 
    22 public abstract class SimpleCommand<E extends Entity> implements ScreenCommand<E> 
     22public abstract class SimpleCommand implements ScreenCommand 
    2323{ 
    2424        /** Logger */ 
    2525        public Logger logger = Logger.getLogger(this.getClass().getSimpleName()); 
    2626 
    27         /** Internal name of this command (unique within the screen( */ 
     27        /** Internal name of this command (unique within the screen) */ 
    2828        private String name; 
    2929 
    30         /** The pretty label of this command (default: getName() */ 
     30        /** The pretty label of this command (default: getName()) */ 
    3131        private String label; 
    3232 
    33         /** Path to an icon image */ 
     33        /** Path to an icon image to show on this command */ 
    3434        private String icon; 
    3535 
    36         /** Piece of javascript (default: autogenerated) */ 
    37         private String action; 
    38  
    39         /** The name of the screen to be target (default: parent screen) */ 
    40         private String target; 
     36        /** Piece of javascript; if none is provide it is autogenerated depend on all settings */ 
     37        private String onClickJavascript; 
     38         
     39        /** The Screen this command is linked to */ 
     40        private ScreenModel screen;      
     41 
     42        /** The name of the screen to be target (default: this.screen) */ 
     43        private String targetScreen; 
    4144 
    4245        /** Indicates to the screen to show a dialog box for this action */ 
    43         private boolean dialog = false; 
     46        private boolean showDialog = false; 
    4447 
    4548        /** Indicates to the screen to start a download procedure for this action */ 
    4649        private boolean download = false; 
    4750 
    48         /** The Screen this command is linked to */ 
    49         private ScreenModel screen; 
    50  
    5151        /** The name of the menu this command should be shown on */ 
    5252        private String menu; 
    5353 
    5454        /** Indicates to the screen to show this command on the toolbar */ 
    55         private boolean toolbar; 
    56  
    57         /** 
    58          * Tells that this action should be hidden for now (for dynamic menu 
    59          * options) 
    60          */ 
    61         private boolean visible; 
    62  
    63         /** 
    64          * Default constructure. Note that this.setScreen needs to be called 
    65          * elsewhere. 
    66          */ 
    67         public SimpleCommand() 
    68         { 
    69                 this.setName(this.getClass().getSimpleName()); 
    70                 // note that this.setScreen needs to be called elsewhere. 
    71         } 
     55        private boolean showOnToolbar; 
    7256 
    7357        /** 
     
    7862         * @param parentScreen 
    7963         */ 
    80         public SimpleCommand(String name, FormModel<E> parentScreen) 
     64        public SimpleCommand(String name, FormModel parentScreen) 
    8165        { 
    8266                this.setName(name); 
     
    8973        public String getJavaScriptAction() 
    9074        { 
    91                 if (action == null) 
     75                if (onClickJavascript == null) 
    9276                { 
    9377                        if (this.getScreen() == null) throw new NullPointerException("setScreen() has not been set on command '" 
     
    156140                        return jScript.toString(); 
    157141                } 
    158                 return action; 
     142                return onClickJavascript; 
    159143        } 
    160144 
     
    193177 
    194178        @Override 
    195         public void setHidden(boolean hidden) 
    196         { 
    197                 this.visible = hidden; 
    198         } 
    199  
    200         @Override 
    201179        public void setJavaScriptAction(String action) 
    202180        { 
    203                 this.action = action; 
     181                this.onClickJavascript = action; 
    204182        } 
    205183 
     
    219197        public String getTarget() 
    220198        { 
    221                 return this.target; 
     199                return this.targetScreen; 
    222200        } 
    223201 
     
    225203        public void setTarget(String target) 
    226204        { 
    227                 this.target = target; 
     205                this.targetScreen = target; 
    228206        } 
    229207 
     
    235213 
    236214        @Override 
    237         public FormModel<E> getFormScreen() 
     215        public FormModel<Entity> getFormScreen() 
    238216        { 
    239217                return (FormModel) this.screen; 
     
    249227        public boolean isDialog() 
    250228        { 
    251                 return dialog; 
     229                return showDialog; 
    252230        } 
    253231 
     
    255233        public void setDialog(boolean dialog) 
    256234        { 
    257                 this.dialog = dialog; 
     235                this.showDialog = dialog; 
    258236        } 
    259237 
     
    297275        public boolean isToolbar() 
    298276        { 
    299                 return toolbar; 
     277                return showOnToolbar; 
    300278        } 
    301279 
     
    303281        public void setToolbar(boolean toolbar) 
    304282        { 
    305                 this.toolbar = toolbar; 
     283                this.showOnToolbar = toolbar; 
    306284        } 
    307285 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/ViewEditViewCommand.java

    r2442 r2674  
    1616import org.molgenis.util.Tuple; 
    1717 
    18 public class ViewEditViewCommand<E extends Entity> extends SimpleCommand<E> 
     18public class ViewEditViewCommand extends SimpleCommand 
    1919{ 
    20         public ViewEditViewCommand(String name, FormModel<E> parentScreen) 
     20        public ViewEditViewCommand(String name, FormModel parentScreen) 
    2121        { 
    2222                super(name, parentScreen); 
    2323                this.setLabel("Edit Record"); 
    2424                this.setIcon("generated-res/img/editview.gif"); 
     25                this.setMenu("View"); 
    2526        } 
    2627 
     
    4243                && !this.getFormScreen().isReadonly()  
    4344                && this.getFormScreen().getRecordInputs().size() != 0 
    44                 && !this.getFormScreen().getRecordInputs().get(0).isReadonly(); 
     45                && !this.getFormScreen().getRecords().get(0).isReadonly(); 
    4546        } 
    4647 
  • molgenis/3.3/src/org/molgenis/framework/ui/commands/ViewListViewCommand.java

    r2442 r2674  
    1515import org.molgenis.framework.ui.FormModel.Mode; 
    1616import org.molgenis.framework.ui.html.HtmlInput; 
    17 import org.molgenis.util.Entity; 
    1817import org.molgenis.util.Tuple; 
    1918 
    20 public class ViewListViewCommand<E extends Entity> extends SimpleCommand<E> 
     19public class ViewListViewCommand extends SimpleCommand 
    2120{ 
    22         public ViewListViewCommand(String name, FormModel<E> parentScreen) 
     21        public ViewListViewCommand(String name, FormModel parentScreen) 
    2322        { 
    2423                super(name, parentScreen); 
    2524                this.setLabel("List Records"); 
    2625                this.setIcon("generated-res/img/listview.png"); 
     26                this.setMenu("View"); 
    2727        } 
    2828 
  • molgenis/3.3/src/org/molgenis/framework/ui/html/HtmlForm.java

    r2442 r2674  
    44import java.util.ArrayList; 
    55import java.util.List; 
    6 import java.util.Vector; 
    76 
    87import org.molgenis.util.Entity; 
     
    109import org.molgenis.util.Tuple; 
    1110 
    12 public class HtmlForm<E extends Entity> 
     11public class HtmlForm 
    1312{ 
    1413        /** The entity to be shown in this form*/ 
    15         private E entity = null; 
     14        private Entity entity = null; 
    1615        /** Some columns can be hidden, using the name*/ 
    1716        private List<String> hiddenColumns = new ArrayList<String>(); 
     
    4948        } 
    5049 
    51         public HtmlForm(E entity) 
     50        public HtmlForm(Entity entity) 
    5251        { 
    5352                this.entity = entity; 
     
    6564        } 
    6665 
    67         public E getEntity() 
     66        public Entity getEntity() 
    6867        { 
    6968                return entity; 
    7069        } 
    7170 
    72         public void setEntity(E entity) 
     71        public void setEntity(Entity entity) 
    7372        { 
    7473                this.entity = entity; 
  • molgenis/3.3/src/org/molgenis/framework/ui/html/MrefInput.java

    r2381 r2674  
    1717import java.util.Arrays; 
    1818import java.util.List; 
     19import java.util.Map; 
    1920 
    2021import org.molgenis.framework.db.QueryRule; 
     
    2930        //private List<ValueLabel> options = new Vector<ValueLabel>(); 
    3031        //The label of the value to show in the box 
    31         private List<String> valueLabels; 
     32        //xrefLabel,values 
     33        private Map<String,List> valueLabels; 
    3234        //what is this? 
    3335        private String targetfield; 
     
    3638        private String xrefEntity; 
    3739        private String xrefField; 
    38         private String xrefLabel; 
     40        private List<String> xrefLabels = new ArrayList<String>(); 
    3941        private List<QueryRule> xrefFilters = new ArrayList<QueryRule>(); 
    4042         
     
    5759                input.setXrefEntity(this.getXrefEntity()); 
    5860                input.setXrefField(this.getXrefField()); 
    59                 input.setXrefLabel(this.getXrefLabel()); 
     61                input.setXrefLabels(this.getXrefLabels()); 
    6062                input.setReadonly(this.isReadonly()); 
    6163                input.setStyle("display: block;"); 
     
    6870                {        
    6971                        input.setValue(values.get(i)); 
    70                         input.setValueLabel(this.getValueLabels().get(i)); 
     72                         
     73                        String result = ""; 
     74 
     75                        for(String labelName: this.getXrefLabels()) 
     76                        { 
     77                                input.setValueLabel(labelName, this.getValueLabels(labelName).get(i)); 
     78                        } 
    7179                        input.setId(this.getName()+i); 
    7280                        html.append(input.toHtml()); 
     
    8088                }        
    8189                 
    82                 String buttons = String.format("<button style=\"\" type=\"button\" onclick=\"mref_addInput('%s','%s','%s','%s','%s',this.parentNode);\">+</button>", getName(), getXrefEntity(), getXrefField(), getXrefLabel(), getXrefFilterRESTString()); 
     90                String buttons = String.format("<button style=\"\" type=\"button\" onclick=\"mref_addInput('%s','%s','%s','%s','%s',this.parentNode);\">+</button>", getName(), getXrefEntity(), getXrefField(), getXrefLabels(), getXrefFilterRESTString()); 
    8391                buttons +="<button type=\"button\" onclick=\"mref_removeInput(this.parentNode);\">-</button>"; 
    8492                 
     
    92100        public String getValue() 
    93101        { 
    94  
    95                 if(this.getValueLabels() == null) 
    96                         return ""; 
     102                String result = ""; 
    97103                 
    98                 List<String> labels = this.getValueLabels(); 
    99                 String result = ""; 
    100                 for(int i = 0; i < labels.size(); i++) 
     104                int size = this.getValueLabels(this.getXrefLabels().get(0)).size(); 
     105                for(int i = 0; i < size ; i++) 
    101106                { 
    102                         if(i>0) result += ",\n"; 
    103                         result += labels.get(i); 
     107                        String valueLabel = ""; 
     108                        for(String labelName: this.getXrefLabels()) 
     109                        { 
     110                                 
     111                                if(valueLabel.equals("")) 
     112                                        valueLabel += this.getValueLabels(labelName).get(i); 
     113                                else 
     114                                        valueLabel += ":" + this.getValueLabels(labelName).get(i); 
     115                        } 
     116                        result += valueLabel; 
    104117                } 
    105                  
    106118                 
    107119                return result; 
     
    139151        } 
    140152 
    141         public String getXrefLabel() { 
    142                 return xrefLabel; 
     153        public List<String> getXrefLabels() { 
     154                return xrefLabels; 
     155        } 
     156         
     157        public void setXrefLabels(List<String> xrefLabels) { 
     158                this.xrefLabels = xrefLabels; 
    143159        } 
    144160 
    145161        public void setXrefLabel(String xrefLabel) { 
    146                 this.xrefLabel = xrefLabel; 
     162                this.xrefLabels.clear(); 
     163                this.xrefLabels.add(xrefLabel); 
    147164        } 
    148165 
    149         public List<String> getValueLabels() { 
    150                 return valueLabels; 
     166        public List<String> getValueLabels(String xrefLabelName) { 
     167                return valueLabels.get(xrefLabelName); 
    151168        } 
    152169 
    153         public void setValueLabels(List<String> valueLabels) { 
    154                 this.valueLabels = valueLabels; 
     170        public void setValueLabels(String xrefLabelName, List valueLabels) { 
     171                this.valueLabels.put(xrefLabelName, valueLabels); 
    155172        } 
    156173 
  • molgenis/3.3/src/org/molgenis/framework/ui/html/XrefInput.java

    r2308 r2674  
    1414 
    1515// jdk 
     16import java.util.LinkedHashMap; 
     17import java.util.List; 
     18import java.util.Map; 
     19 
    1620import org.molgenis.util.Entity; 
    1721 
    1822/** 
    1923 * Input for cross-reference (xref) data. Data will be shown as selection box. 
     24 * Optionally, multi-column xref_labels can be set. 
    2025 */ 
    2126public class XrefInput extends HtmlInput 
     
    2328        //private List<ValueLabel> options = new Vector<ValueLabel>(); 
    2429        //The label of the value to show in the box 
    25         private String valueLabel; 
     30        private Map<String,Object> valueLabel = new LinkedHashMap<String,Object>(); 
    2631        //what is this? 
    2732        private String targetfield; 
     
    3035        private String xrefEntity; 
    3136        private String xrefField; 
    32         private String xrefLabel; 
     37        private List<String> xrefLabels; 
    3338         
    3439        public XrefInput(String name, Object value) 
     
    4045        public String toHtml() 
    4146        { 
    42                 String readonly = (this.isReadonly()) ? " readonly class=\"readonly\" " : String.format(" onfocus=\"showXrefInput(this,'%s','%s','%s'); return false;\" ", xrefEntity, xrefField, xrefLabel); 
     47                String xrefLabelString = this.toCsv(xrefLabels); 
     48                String readonly = (this.isReadonly()) ? " readonly class=\"readonly\" " : String.format(" onfocus=\"showXrefInput(this,'%s','%s','%s'); return false;\" ", xrefEntity, xrefField, xrefLabelString); 
    4349 
    4450                if (this.isHidden()) 
     
    5460                if(super.getObject() != null) 
    5561                { 
    56                         optionsHtml.append("\t<option selected value=\""+super.getValue()+"\">"+this.getValueLabel()+"</option>\n"); 
     62                        optionsHtml.append("\t<option selected value=\""+super.getValue()+"\">"+this.getValue()+"</option>\n"); 
    5763                } 
    5864                if (!this.isReadonly()) 
     
    6470        } 
    6571 
     72        private String toCsv(List<String> xrefLabels) 
     73        { 
     74                String result = ""; 
     75                for(String label: xrefLabels) 
     76                { 
     77                        result+= ","+label; 
     78                } 
     79                 
     80                return result.replaceFirst(",", ""); 
     81        } 
     82 
    6683        @Override 
    6784        /** 
     
    7087        public String getValue() 
    7188        { 
    72  
    73                 if(this.getValueLabel() == null) 
    74                         return ""; 
    75                 return this.getValueLabel(); 
     89                String result = ""; 
     90                for(String label: this.xrefLabels) 
     91                { 
     92                        if(result.equals("")) 
     93                                result += this.valueLabel.get(label); 
     94                        else 
     95                                result += ":" + this.valueLabel.get(label); 
     96                } 
     97                 
     98                return result; 
    7699        } 
    77100 
     
    107130        } 
    108131 
    109         public String getXrefLabel() { 
    110                 return xrefLabel; 
     132        public List<String> getXrefLabel() { 
     133                return xrefLabels; 
    111134        } 
    112135 
    113136        public void setXrefLabel(String xrefLabel) { 
    114                 this.xrefLabel = xrefLabel; 
     137                this.xrefLabels.clear(); 
     138                this.xrefLabels.add(xrefLabel); 
     139        } 
     140         
     141        public void setXrefLabels(List<String> xrefLabels) { 
     142                this.xrefLabels = xrefLabels; 
    115143        } 
    116144 
    117         public String getValueLabel() { 
    118                 return valueLabel; 
     145        public Object getValueLabel(String xrefLabelName) { 
     146                return valueLabel.get(xrefLabelName); 
    119147        } 
    120148 
    121         public void setValueLabel(String valueLabel) { 
    122                 this.valueLabel = valueLabel; 
     149        public void setValueLabel(String xrefLabelName, Object valueLabel) { 
     150                this.valueLabel.put(xrefLabelName, valueLabel); 
    123151        } 
    124152 
  • molgenis/3.3/src/org/molgenis/generators/ui/FormScreenGen.java.ftl

    r2594 r2674  
    5555        private static final long serialVersionUID = 1L; 
    5656         
     57        public ${Name(form.className)}Form() 
     58        { 
     59                this(null); 
     60        } 
     61         
    5762        public ${Name(form.className)}Form(ScreenModel parent) 
    5863        { 
     
    7277        <#if field.getType() == "xref" || field.getType() == "mref"> 
    7378                <#list superclasses(parent_form.getRecord()) as parent_entity> 
    74                         <#if parent_entity.getName() == field.getXRefEntity()> 
    75                 //filter on <#if field.getType() == "mref">ANY </#if>subform_entity.${name(field)} == parentform_entity.${field.getXRefField()} 
    76                 this.getParentFilters().add(new ParentFilter("${parent_form.name}","${SqlName(field.getXRefField())}","${SqlName(field.getXRefLabelString())}","${SqlName(name(field))}")); 
     79                        <#if parent_entity.getName() == field.xrefEntityName> 
     80                //filter on <#if field.getType() == "mref">ANY </#if>subform_entity.${name(field)} == parentform_entity.${field.xrefField} 
     81                this.getParentFilters().add(new ParentFilter("${parent_form.name}","${SqlName(field.xrefField)}",Arrays.asList("${csv(field.xrefLabelNames)}".split(",")),"${SqlName(name(field))}")); 
    7782                        </#if> 
    7883                </#list> 
     
    8590        <#if field.getType() == "xref" || field.getType() == "mref"> 
    8691                <#list superclasses(form.getRecord()) as subform_entity> 
    87                         <#if subform_entity.getName() == field.getXRefEntity()> 
    88                 //filter on subform_entity.${field.getXRefField()} == <#if field.getType() == "mref">ANY </#if> parentform_entity.${name(field)} 
    89                 this.getParentFilters().add(new ParentFilter("${parent_form.name}","${SqlName(name(field))}","${SqlName(field.getXRefLabelString())}","${SqlName(field.getXRefField())}"));              
     92                        <#if subform_entity.getName() == field.xrefEntityName> 
     93                //filter on subform_entity.${field.xrefField} == <#if field.getType() == "mref">ANY </#if> parentform_entity.${name(field)} 
     94                this.getParentFilters().add(new ParentFilter("${parent_form.name}","${SqlName(name(field))}",Arrays.asList("${csv(field.xrefLabelNames)}".split(",")),"${SqlName(field.xrefField)}"));           
    9095                        </#if> 
    9196                </#list> 
     
    9398</#list> 
    9499</#if>   
    95 <#list form.actions as action> 
    96                 this.addAction(new ${action}<${entity}>(this)); 
     100<#list form.commands as command> 
     101                this.addCommand(new ${command}(this)); 
    97102</#list>                 
    98103<#if form.readOnly> 
     
    123128         
    124129        @Override 
    125         public HtmlForm<${entity}> getInputs(${entity} entity, boolean newrecord) 
    126         { 
    127                 HtmlForm<${Name(entity)}> form = new HtmlForm<${Name(entity)}>(); 
     130        public HtmlForm getInputs(${entity} entity, boolean newrecord) 
     131        { 
     132                HtmlForm form = new HtmlForm(); 
    128133                form.setNewRecord(newrecord); 
    129134                form.setReadonly(isReadonly()); 
     
    153158                        </#if>   
    154159                        <#if inputtype = "Xref" || inputtype = "Mref"> 
    155                         <#assign xref_entity = model.getEntity(field.XRefEntity)> 
    156                         input.setXrefEntity("${xref_entity.getNamespace()}.${JavaName(field.XRefEntity)}"); 
    157                         input.setXrefField("${name(field.XRefField)}"); 
    158                         input.setXrefLabel("${name(field.XRefLabelString)}"); 
    159                         //initialize the ${field.XRefEntity}.${field.XRefLabelString} of current record 
    160                         input.setValueLabel<#if inputtype = "Mref">s</#if>(entity.get${JavaName(field)}Label<#if inputtype = "Mref">s</#if>());  
     160                        <#assign xref_entity = field.xrefEntity> 
     161                        input.setXrefEntity("${xref_entity.getNamespace()}.${JavaName(field.xrefEntity)}"); 
     162                        input.setXrefField("${name(field.xrefField)}"); 
     163                        input.setXrefLabels(Arrays.asList("${csv(field.xrefLabelNames)}".split(","))); 
     164                        //initialize the ${field.xrefEntityName}.${csv(field.xrefLabelNames)} of current record 
     165                        <#if field.xrefLabelNames[0] != field.xrefFieldName><#list field.xrefLabelNames as label> 
     166                        input.setValueLabel<#if inputtype = "Mref">s</#if>("${label}", entity.get${JavaName(field)}_${label}());  
     167                        </#list><#else> 
     168                        input.setValueLabel<#if inputtype = "Mref">s</#if>("${field.xrefField}", entity.get${JavaName(field)}()); 
     169                        </#if> 
    161170                        </#if> 
    162171                        <#if field.hidden>               
     
    187196<#list form.getRecord().getAllFields() as field> 
    188197        <#if field.type="xref" || field.type="mref"> 
    189                 if(fieldName.equals("${name(field)}")) return "${name(field)}_${name(field.getXRefLabelString())}"; 
     198                <#list field.xrefLabelNames as label> 
     199                if(fieldName.equals("${name(field)}")) return "${name(field)}_${name(label)}"; 
     200                </#list> 
    190201        </#if> 
    191202</#list>         
  • molgenis/3.3/src/org/molgenis/generators/ui/PluginScreenGen.java.ftl

    r2308 r2674  
    3131                super("${plugin.getVelocityName()}", parent); 
    3232                this.setLabel("${plugin.label}"); 
     33                 
     34                <#list plugin.getChildren() as subscreen> 
     35                <#assign screentype = Name(subscreen.getType().toString()?lower_case) /> 
     36                new ${package}.${JavaName(subscreen)}${screentype}(this); 
     37                </#list>         
    3338        } 
    3439<#else> 
     
    3641        { 
    3742                super("${plugin.getVelocityName()}", parent); 
    38                 this.setLabel("${plugin.label}");                
     43                this.setLabel("${plugin.label}"); 
     44                 
     45                <#list plugin.getChildren() as subscreen> 
     46                <#assign screentype = Name(subscreen.getType().toString()?lower_case) /> 
     47                new ${package}.${JavaName(subscreen)}${screentype}(this); 
     48                </#list>                         
    3949        } 
    4050</#if> 
Note: See TracChangeset for help on using the changeset viewer.