Changeset 2442
- Timestamp:
- 11/30/09 22:51:56 (2 years ago)
- Location:
- molgenis/3.3/src/org/molgenis/framework/ui
- Files:
-
- 3 added
- 26 edited
-
FormController.java (modified) (1 diff)
-
FormModel.java (modified) (17 diffs)
-
FormView.ftl (modified) (1 diff)
-
FormViewYUI.ftl (added)
-
MainYUI.ftl (added)
-
MenuController.java (modified) (1 diff)
-
MenuModel.java (modified) (1 diff)
-
MenuViewYUI.ftl (added)
-
ScreenModel.java (modified) (2 diffs)
-
SimpleModel.java (modified) (1 diff)
-
UserInterface-EBI.ftl (modified) (1 diff)
-
UserInterface.ftl (modified) (1 diff)
-
UserInterface.java (modified) (1 diff)
-
commands/AddBatchCommand.java (modified) (6 diffs)
-
commands/AddCommand.java (modified) (4 diffs)
-
commands/AddCommand2.java (modified) (4 diffs)
-
commands/ChangeListLimitCommand.java (modified) (4 diffs)
-
commands/CommandMenu.java (modified) (2 diffs)
-
commands/DownloadAllCommand.java (modified) (2 diffs)
-
commands/DownloadSelectedCommand.java (modified) (4 diffs)
-
commands/DownloadVisibleCommand.java (modified) (3 diffs)
-
commands/EditSelectedCommand.java (modified) (4 diffs)
-
commands/RemoveSelectedCommand.java (modified) (3 diffs)
-
commands/ScreenCommand.java (modified) (4 diffs)
-
commands/SimpleCommand.java (modified) (13 diffs)
-
commands/ViewEditViewCommand.java (modified) (3 diffs)
-
commands/ViewListViewCommand.java (modified) (3 diffs)
-
html/Form.java (modified) (1 diff)
-
html/HtmlForm.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molgenis/3.3/src/org/molgenis/framework/ui/FormController.java
r2314 r2442 294 294 public void reload(Database db) 295 295 { 296 logger. debug("reloading...");296 logger.info("reloading..."); 297 297 298 298 // FIXME -
molgenis/3.3/src/org/molgenis/framework/ui/FormModel.java
r2369 r2442 15 15 // jdk 16 16 import java.io.File; 17 import java.text.ParseException; 17 18 import java.util.ArrayList; 18 19 import java.util.Arrays; … … 56 57 public abstract class FormModel<E extends Entity> extends SimpleModel 57 58 { 59 /** 60 * Parameters to enable links between parent forms and subforms using 61 * foreign key relationships (aka master-detail views) 62 * 63 * @author Morris Swertz 64 */ 65 public static class ParentFilter 66 { 67 /** for filtering based on parentform */ 68 private String parentForm; 69 private String parentId; 70 private String parentLabel; 71 private String xrefToParent; 72 73 public ParentFilter(String parentForm, String parentId, String parentLabel, String xrefToParent) 74 { 75 this.parentForm = parentForm; 76 this.parentId = parentId; 77 this.parentLabel = parentLabel; 78 this.xrefToParent = xrefToParent; 79 } 80 81 public String getParentForm() 82 { 83 return parentForm; 84 } 85 86 public String getParentId() 87 { 88 return parentId; 89 } 90 91 public String getXrefToParent() 92 { 93 return xrefToParent; 94 } 95 96 public void setParentForm(String parentForm) 97 { 98 this.parentForm = parentForm; 99 } 100 101 public void setParentId(String parentId) 102 { 103 this.parentId = parentId; 104 } 105 106 public void setXrefToParent(String xrefToParent) 107 { 108 this.xrefToParent = xrefToParent; 109 } 110 111 public String getParentLabel() 112 { 113 return parentLabel; 114 } 115 116 public void setParentLabel(String parentLabel) 117 { 118 this.parentLabel = parentLabel; 119 } 120 } 121 58 122 // ABSTRACT METHODS, varied per entity 59 123 /** … … 63 127 * @param entity 64 128 * @param newrecord 129 * @throws ParseException 65 130 */ 66 131 public abstract HtmlForm<E> getInputs(E entity, boolean newrecord); … … 87 152 { 88 153 LIST_VIEW("listview"), EDIT_VIEW("editview"); 89 // RECORD_VIEW("recordview")90 // , EMBEDDED_VIEW("embeddedview"),;154 // RECORD_VIEW("recordview") 155 // , EMBEDDED_VIEW("embeddedview"),; 91 156 92 157 private Mode(String tag) … … 104 169 105 170 // CONSTANTS 171 public static final String INPUT_SHOW = "__show"; 106 172 public static final String INPUT_OFFSET = "__offset"; 107 173 public static final String INPUT_DOWNLOADFILENAME = "__filename"; … … 161 227 /** Helper object that takes care of database paging */ 162 228 private DatabasePager<E> pager; 163 164 /** Here the currently selected is are stored */229 230 /** Here the currently selected is are stored */ 165 231 private List<Object> selectedIds; 232 /** Filter of parent form filtering */ 233 // TODO make this infer automatically 234 private List<ParentFilter> parentFilters = new ArrayList<ParentFilter>(); 166 235 167 236 /** */ … … 198 267 199 268 setController(new FormController<E>(this)); 200 201 // add all actions269 270 // add all actions 202 271 // menu FILE 203 272 … … 232 301 233 302 // menu VIEW 234 //SimpleCommand<E> v2 = new ViewRecordViewCommand<E>("recordview", this); 235 //v2.setToolbar(true); 236 //super.addCommand("View", v2); 303 // SimpleCommand<E> v2 = new ViewRecordViewCommand<E>("recordview", 304 // this); 305 // v2.setToolbar(true); 306 // super.addCommand("View", v2); 237 307 238 308 SimpleCommand<E> v3 = new ViewEditViewCommand<E>("editview", this); 239 // v3.setToolbar(true);309 // v3.setToolbar(true); 240 310 super.addCommand("View", v3); 241 311 242 312 SimpleCommand<E> v4 = new ViewListViewCommand<E>("listview", this); 243 v4.setToolbar(true); 313 v4.setToolbar(true); 244 314 super.addCommand("View", v4); 245 315 … … 274 344 } 275 345 } 276 346 277 347 @Override 278 348 public boolean isVisible() … … 289 359 { 290 360 Vector<ScreenCommand> toolbar = new Vector<ScreenCommand>(); 291 292 for (CommandMenu<E> menu: this.getMenus())293 { 294 for (ScreenCommand<E> c: menu.getCommands())361 362 for (CommandMenu<E> menu : this.getMenus()) 363 { 364 for (ScreenCommand<E> c : menu.getCommands()) 295 365 { 296 if (c.isToolbar() && c.isVisible())366 if (c.isToolbar() && c.isVisible()) 297 367 { 298 368 toolbar.add(c); … … 300 370 } 301 371 } 302 372 303 373 return toolbar; 304 374 } … … 315 385 316 386 /** 317 * A convenience method that merges system and user rules, excluding limit and offset318 * (i.e., if you want 'all').387 * A convenience method that merges system and user rules, excluding limit 388 * and offset (i.e., if you want 'all'). 319 389 * 320 390 * @return an array of all rules … … 353 423 try 354 424 { 355 return getEntityClass().newInstance(); 425 E entity = getEntityClass().newInstance(); 426 427 // set defaults for xrefs 428 for (ParentFilter pf : this.getParentFilters()) 429 { 430 FormModel parent = (FormModel) this.get(pf.getParentForm()); 431 List<Entity> records = parent.getRecords(); 432 if (records.size() > 0) 433 { 434 // xref only 435 Object value = records.get(0).get(pf.getParentId()); 436 Object label = records.get(0).get(pf.getParentLabel()); 437 if (!(value instanceof List) && value != null) 438 { 439 entity.set(pf.getXrefToParent(), value); 440 entity.set(pf.getXrefToParent()+"_"+pf.getParentLabel(), label); 441 } 442 } 443 } 444 445 return entity; 356 446 } 357 447 catch (Exception e) 358 448 { 359 // should never happen449 // should never happen 360 450 logger.error("failed to create class " + getEntityClass() + ": " + e); 361 451 e.printStackTrace(); … … 602 692 * field of a related record. 603 693 */ 604 public abstract List<QueryRule> getSystemRules(); 694 public List<QueryRule> getSystemRules() 695 { 696 List<QueryRule> rules = new ArrayList<QueryRule>(); 697 698 // parent filters 699 if (this.getParentFilters() != null && this.getParentFilters().size() > 0) 700 { 701 List<QueryRule> xref_filters = new ArrayList<QueryRule>(); 702 703 for (ParentFilter pf : this.getParentFilters()) 704 { 705 FormModel parent = (FormModel) this.get(pf.getParentForm()); 706 List<Entity> records = parent.getRecords(); 707 708 // add filters for xref or mref relationships (if any) 709 // if multiple xrefs apply then the filters are union (so xref1 710 // OR 711 // xref2 OR etc) 712 if (records.size() > 0) 713 { 714 715 Object parentValue = records.get(0).get(pf.getParentId()); 716 // mref? 717 if (parentValue instanceof List) 718 { 719 List values = (List) parentValue; 720 if (values.size() > 0) for (Object val : values) 721 { 722 QueryRule rule = new QueryRule(pf.getXrefToParent(), QueryRule.Operator.EQUALS, val); 723 rule.setOr(true); 724 xref_filters.add(rule); 725 } 726 // if no filters then prohibit to get ALL data by adding 727 // impossible condition 728 else 729 { 730 QueryRule rule = new QueryRule(pf.getXrefToParent(), QueryRule.Operator.EQUALS, 731 Integer.MIN_VALUE); 732 rule.setOr(true); 733 xref_filters.add(rule); 734 } 735 } 736 // xref 737 else if (parentValue != null) 738 { 739 QueryRule rule = new QueryRule(pf.getXrefToParent(), QueryRule.Operator.EQUALS, parentValue); 740 rule.setOr(true); 741 xref_filters.add(rule); 742 } 743 else 744 { 745 QueryRule rule = new QueryRule(pf.getXrefToParent(), QueryRule.Operator.EQUALS, 746 Integer.MIN_VALUE); 747 rule.setOr(true); 748 xref_filters.add(rule); 749 } 750 } 751 } 752 // put it all in one clause, e.g. (xref1 = 0 OR xref1 = 1 OR xref2=3 753 // ....) 754 rules.add(new QueryRule(xref_filters)); 755 } 756 757 // security filters 758 { 759 QueryRule rule = super.getRootScreen().getLogin().getRowlevelSecurityFilters(this.create()); 760 if (rule != null /* && !rule.equals(new QueryRule()) */) rules.add(rule); 761 } 762 return rules; 763 764 } 605 765 606 766 /** … … 623 783 } 624 784 625 public void setMessages(ScreenMessage<E> ... messages)785 public void setMessages(ScreenMessage<E>... messages) 626 786 { 627 787 this.messages = new Vector<ScreenMessage<E>>(Arrays.asList(messages)); 628 788 } 629 630 789 631 790 /** 632 791 * @return Messages to inform the user of state changes and succes. … … 745 904 return ((FormController) getController()).getPager(); 746 905 } 747 906 748 907 public List<Object> getSelectedIds() 749 908 { … … 755 914 this.selectedIds = selected; 756 915 } 916 917 public void setParentFilters(List<ParentFilter> parentFilters) 918 { 919 this.parentFilters = parentFilters; 920 } 921 922 public List<ParentFilter> getParentFilters() 923 { 924 return parentFilters; 925 } 926 757 927 } -
molgenis/3.3/src/org/molgenis/framework/ui/FormView.ftl
r2308 r2442 27 27 <#list menu.getCommands() as command> 28 28 <#if command.isVisible()> 29 <tr><td class="submenuitem" onclick="${command.getJavaScriptAction()}">< img src="${command.icon}" align="left" />${command.label}</td></tr>29 <tr><td class="submenuitem" onclick="${command.getJavaScriptAction()}"><#if command.icon?exists><img src="${command.icon}" align="left" /><#else> </#if>${command.label}</td></tr> 30 30 </#if> 31 31 </#list> -
molgenis/3.3/src/org/molgenis/framework/ui/MenuController.java
r2308 r2442 49 49 public void reload(Database db) 50 50 { 51 logger.debug("reloading Menu("+view.getName()+")"); 51 52 ScreenModel selected = view.getSelected(); 52 53 if (selected == null) -
molgenis/3.3/src/org/molgenis/framework/ui/MenuModel.java
r2308 r2442 59 59 super(name, parent); 60 60 setController(new MenuController(this)); 61 //macro has exact name as class, but then ending with 'view'. 61 62 setViewMacro(MenuModel.class.getSimpleName().replace("Model", "View")); 62 63 } -
molgenis/3.3/src/org/molgenis/framework/ui/ScreenModel.java
r2314 r2442 18 18 import org.molgenis.util.EmailService; 19 19 import org.molgenis.util.Tree; 20 import org.molgenis.util.SimpleEmailService.EmailException;21 20 22 21 // jdk … … 47 46 /** Bind parameter name for screen action (to be used by layout renderer) */ 48 47 public static final String INPUT_ACTION = "__action"; 48 49 49 /** 50 50 * Parameter to indicate how the results should be shown (as download, as 51 51 * popup, inline with the rest of the GUI (Default) 52 52 */ 53 public static final String INPUT_SHOW = "__show"; 54 55 /** The default of 'input_show' */ 56 public static final String SHOW_INLINE = "inline"; 57 58 /** Show current screen in a popup */ 59 public static final String SHOW_DIALOG = "popup"; 60 61 /** 62 * Pass current screen in handlerequest the outputstream so it can be 63 * downloaded 64 */ 65 public static final String SHOW_DOWNLOAD = "download"; 53 public enum Show 54 { 55 /** 56 * Show the current screen as part of its parent. This means the layout template is called on the root of the user interface. 57 */ 58 SHOW_MAIN("inline"), 59 /** 60 * Show the current screen or command as popup. This means the layout template is applied on this element. 61 */ 62 SHOW_DIALOG("popup"), 63 /** 64 * Pass current screen in handlerequest the outputstream so it can be 65 * downloaded. This result in a download file. 66 */ 67 SHOW_DOWNLOAD("download"); 68 69 private String TAG; 70 Show(String name) 71 { 72 this.TAG = name; 73 } 74 75 public String toString() 76 { 77 return this.TAG; 78 } 79 80 public boolean equals(String str) 81 { 82 if(str != null && str.equals(this.TAG)) return true; 83 return false; 84 } 85 } 66 86 67 87 /** -
molgenis/3.3/src/org/molgenis/framework/ui/SimpleModel.java
r2314 r2442 194 194 { 195 195 // link the command to the screen 196 command.setScreen(this); 196 197 command.setTarget(this.getName()); 197 198 -
molgenis/3.3/src/org/molgenis/framework/ui/UserInterface-EBI.ftl
r2308 r2442 6 6 <meta http-equiv="Window-target" content="_top" /> 7 7 <meta name="no-email-collection" content="http://www.unspam.com/noemailcollection/" /> 8 <script type="text/javascript"> 9 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 10 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 11 </script> 12 <script type="text/javascript"> 13 try { 14 var pageTracker = _gat._getTracker("UA-11526343-1"); 15 pageTracker._trackPageview(); 16 } catch(err) {} 17 </script> 8 18 <!--link rel="shortcut icon" href="generated-res/img/molgenis.ico"--> 9 19 <link rel="stylesheet" href="http://www.ebi.ac.uk/inc/css/contents.css" type="text/css" /> -
molgenis/3.3/src/org/molgenis/framework/ui/UserInterface.ftl
r2369 r2442 30 30 <@molgenis_header/> 31 31 <div id="container"> 32 <div id="header"> 33 <div><p><a href="http://www.molgenis.org"><img src="generated-res/img/logo_molgenis.gif" height="70px" align="right"/></a> ${application.getLabel()}</p></div> 34 <!--div align="right" style="color: maroon; font: 12px Arial;margin-right: 10px;">| <a href="about.html">About</a> | <a href="doc/objectmodel.html">Object model</a> | <a href="api/R">R-project API</a> | <a href="api/find">HTTP API</a> | <a href="api/soap?wsdl">Web Services API</a></div--> 35 </div> 32 36 33 <#list screen.getVisibleChildren() as subscreen> 37 34 <@layout subscreen /> 38 35 </#list> 36 39 37 <div id="push"> 40 38 </div> -
molgenis/3.3/src/org/molgenis/framework/ui/UserInterface.java
r2314 r2442 145 145 public void reload(Database db) 146 146 { 147 if(this.getController() != this)147 for(ScreenModel s: this.getChildren()) 148 148 { 149 this.getController().reload(db);149 s.getController().reload(db); 150 150 } 151 else 152 { 153 if(this.getSelected() != null) 154 this.getSelected().getController().reload(db); 155 } 151 152 // if(this.getController() != this) 153 // { 154 // this.getController().reload(db); 155 // } 156 // else 157 // { 158 // //refresh whole selected subtree 159 // if(this.getSelected() != null) 160 // this.getSelected().getController().reload(db); 161 // } 156 162 } 157 163 -
molgenis/3.3/src/org/molgenis/framework/ui/commands/AddBatchCommand.java
r2369 r2442 13 13 import org.molgenis.framework.ui.FormModel; 14 14 import org.molgenis.framework.ui.ScreenMessage; 15 import org.molgenis.framework.ui.ScreenModel; 16 import org.molgenis.framework.ui.ScreenModel.Show; 15 17 import org.molgenis.framework.ui.html.ActionInput; 16 18 import org.molgenis.framework.ui.html.HtmlInput; … … 53 55 public List<HtmlInput> getInputs() throws DatabaseException 54 56 { 55 // todo add help/subheadings56 57 57 // delegate to the formscreen 58 List<HtmlInput> inputs = this.get Screen().getNewRecordForm().getInputs();58 List<HtmlInput> inputs = this.getFormScreen().getNewRecordForm().getInputs(); 59 59 60 60 // remove not-null constraints … … 72 72 73 73 @Override 74 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, DatabaseException,74 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, DatabaseException, 75 75 IOException 76 76 { … … 83 83 try 84 84 { 85 CsvToDatabase<E> csvReader = this.get Screen().getCsvReader();85 CsvToDatabase<E> csvReader = this.getFormScreen().getCsvReader(); 86 86 87 87 int updatedRows = csvReader.importCsv(db, new CsvStringReader(request … … 92 92 msg = new ScreenMessage<E>("CSV UPLOAD SUCCESS: added " + updatedRows + " rows", null, true); 93 93 logger.debug("CSV UPLOAD SUCCESS: added " + updatedRows + " rows"); 94 get Screen().getPager().resetFilters();95 get Screen().getPager().last(db);94 getFormScreen().getPager().resetFilters(); 95 getFormScreen().getPager().last(db); 96 96 } 97 97 catch (Exception e) … … 101 101 logger.error("CSV UPLOAD FAILED: " + e.getMessage()); 102 102 } 103 get Screen().getMessages().add(msg);103 getFormScreen().getMessages().add(msg); 104 104 } 105 105 106 return true; 106 //show result in the main screen 107 return ScreenModel.Show.SHOW_MAIN; 107 108 } 108 109 -
molgenis/3.3/src/org/molgenis/framework/ui/commands/AddCommand.java
r2308 r2442 11 11 import org.molgenis.framework.ui.FormController; 12 12 import org.molgenis.framework.ui.FormModel; 13 import org.molgenis.framework.ui.ScreenModel; 13 14 import org.molgenis.framework.ui.html.ActionInput; 14 15 import org.molgenis.framework.ui.html.HtmlInput; … … 34 35 { 35 36 // delegate to the formscreen 36 return this.get Screen().getNewRecordForm().getInputs();37 return this.getFormScreen().getNewRecordForm().getInputs(); 37 38 } 38 39 … … 60 61 { 61 62 //hide add button if the screen is readonly 62 return !this.get Screen().isReadonly();63 return !this.getFormScreen().isReadonly(); 63 64 } 64 65 65 66 @Override 66 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException,67 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, 67 68 DatabaseException, IOException 68 69 { … … 72 73 ((FormController) this.getScreen().getController()).doAdd(db, request); 73 74 } 74 return true;75 return ScreenModel.Show.SHOW_MAIN; 75 76 } 76 77 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/AddCommand2.java
r2314 r2442 13 13 import org.molgenis.framework.ui.FormModel; 14 14 import org.molgenis.framework.ui.ScreenMessage; 15 import org.molgenis.framework.ui.ScreenModel; 15 16 import org.molgenis.framework.ui.html.ActionInput; 16 17 import org.molgenis.framework.ui.html.Form; … … 42 43 { 43 44 Form f = new Form(); 44 f.addAll(this.get Screen().getNewRecordForm().getInputs());45 f.addAll(this.getFormScreen().getNewRecordForm().getInputs()); 45 46 f.setAll(previousRequest); 46 47 return f.getInputs(); … … 70 71 { 71 72 // hide add button from the menu/toolbar if the screen is readonly 72 return !this.get Screen().isReadonly();73 return !this.getFormScreen().isReadonly(); 73 74 } 74 75 75 76 @Override 76 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, DatabaseException,77 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, DatabaseException, 77 78 IOException 78 79 { … … 81 82 // delegate to the form controller 82 83 boolean success = ((FormController<E>) this.getScreen().getController()).doAdd(db, request); 83 this.messages = this.get Screen().getMessages();84 this.messages = this.getFormScreen().getMessages(); 84 85 } 85 return true;86 return ScreenModel.Show.SHOW_MAIN; 86 87 } 87 88 -
molgenis/3.3/src/org/molgenis/framework/ui/commands/ChangeListLimitCommand.java
r2308 r2442 5 5 6 6 import java.io.PrintWriter; 7 import java.util.List; 7 8 8 9 import org.molgenis.framework.db.Database; 10 import org.molgenis.framework.db.DatabaseException; 9 11 import org.molgenis.framework.ui.FormModel; 12 import org.molgenis.framework.ui.ScreenModel; 10 13 import org.molgenis.framework.ui.FormModel.Mode; 14 import org.molgenis.framework.ui.html.HtmlInput; 11 15 import org.molgenis.util.Entity; 12 16 import org.molgenis.util.Tuple; … … 33 37 { 34 38 // only show in list view 35 return get Screen().getMode().equals(Mode.LIST_VIEW);39 return getFormScreen().getMode().equals(Mode.LIST_VIEW); 36 40 } 37 41 … … 43 47 44 48 @Override 45 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream)49 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) 46 50 { 47 51 48 get Screen().setLimit(getLimit());49 return true;52 getFormScreen().setLimit(getLimit()); 53 return ScreenModel.Show.SHOW_MAIN; 50 54 } 51 55 … … 59 63 this.limit = limit; 60 64 } 65 66 @Override 67 public List<HtmlInput> getActions() 68 { 69 // TODO Auto-generated method stub 70 return null; 71 } 72 73 @Override 74 public List<HtmlInput> getInputs() throws DatabaseException 75 { 76 // TODO Auto-generated method stub 77 return null; 78 } 61 79 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/CommandMenu.java
r2308 r2442 3 3 import java.util.Collection; 4 4 import java.util.LinkedHashMap; 5 import java.util.List; 5 6 import java.util.Map; 6 7 7 8 import org.apache.log4j.Logger; 9 import org.molgenis.framework.db.DatabaseException; 8 10 import org.molgenis.framework.ui.FormModel; 9 11 import org.molgenis.framework.ui.Templateable; 12 import org.molgenis.framework.ui.html.HtmlInput; 10 13 import org.molgenis.util.Entity; 11 14 … … 65 68 } 66 69 70 @Override 71 public List<HtmlInput> getActions() 72 { 73 // TODO Auto-generated method stub 74 return null; 75 } 76 77 @Override 78 public List<HtmlInput> getInputs() throws DatabaseException 79 { 80 // TODO Auto-generated method stub 81 return null; 82 } 83 67 84 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadAllCommand.java
r2314 r2442 5 5 6 6 import java.io.PrintWriter; 7 import java.util.List; 7 8 8 9 import org.molgenis.framework.db.Database; 9 10 import org.molgenis.framework.db.DatabaseException; 10 11 import org.molgenis.framework.ui.FormModel; 12 import org.molgenis.framework.ui.ScreenModel; 13 import org.molgenis.framework.ui.html.HtmlInput; 11 14 import org.molgenis.util.CsvWriter; 12 15 import org.molgenis.util.Entity; … … 29 32 30 33 @Override 31 public booleanhandleRequest(Database db, Tuple request, PrintWriter csvDownload) throws DatabaseException34 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter csvDownload) throws DatabaseException 32 35 { 33 36 logger.debug(this.getName()); 34 37 35 FormModel<E> view = this.get Screen();38 FormModel<E> view = this.getFormScreen(); 36 39 db.find(view.getEntityClass(), new CsvWriter(csvDownload), view.getRulesExclLimitOffset()); 37 40 38 return true; 41 return ScreenModel.Show.SHOW_MAIN; 42 } 43 44 @Override 45 public List<HtmlInput> getActions() 46 { 47 // TODO Auto-generated method stub 48 return null; 49 } 50 51 @Override 52 public List<HtmlInput> getInputs() throws DatabaseException 53 { 54 // TODO Auto-generated method stub 55 return null; 39 56 } 40 57 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadSelectedCommand.java
r2314 r2442 16 16 import org.molgenis.framework.db.QueryRule.Operator; 17 17 import org.molgenis.framework.ui.FormModel; 18 import org.molgenis.framework.ui.ScreenModel; 18 19 import org.molgenis.framework.ui.FormModel.Mode; 20 import org.molgenis.framework.ui.html.HtmlInput; 19 21 import org.molgenis.util.CsvWriter; 20 22 import org.molgenis.util.Entity; … … 40 42 { 41 43 // only show in listview 42 return this.get Screen().getMode().equals(Mode.LIST_VIEW);44 return this.getFormScreen().getMode().equals(Mode.LIST_VIEW); 43 45 } 44 46 45 47 @Override 46 public booleanhandleRequest(Database db, Tuple request, PrintWriter csvDownload) throws ParseException, DatabaseException,48 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter csvDownload) throws ParseException, DatabaseException, 47 49 IOException 48 50 { 49 51 logger.debug(this.getName()); 50 52 51 FormModel<E> view = this.get Screen();53 FormModel<E> view = this.getFormScreen(); 52 54 53 55 Object ids = request.getObject(FormModel.INPUT_SELECTED); … … 64 66 { 65 67 csvDownload.println("No records selected."); 66 return true;68 return ScreenModel.Show.SHOW_MAIN; 67 69 } 68 70 … … 70 72 db.find(view.getEntityClass(), new CsvWriter(csvDownload), 71 73 new QueryRule("id", Operator.IN, records)); 72 return true; 74 return ScreenModel.Show.SHOW_MAIN; 75 } 76 77 @Override 78 public List<HtmlInput> getActions() 79 { 80 // TODO Auto-generated method stub 81 return null; 82 } 83 84 @Override 85 public List<HtmlInput> getInputs() throws DatabaseException 86 { 87 // TODO Auto-generated method stub 88 return null; 73 89 } 74 90 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/DownloadVisibleCommand.java
r2330 r2442 12 12 import org.molgenis.framework.db.DatabaseException; 13 13 import org.molgenis.framework.ui.FormModel; 14 import org.molgenis.framework.ui.ScreenModel; 15 import org.molgenis.framework.ui.html.HtmlInput; 14 16 import org.molgenis.util.CsvWriter; 15 17 import org.molgenis.util.Entity; … … 33 35 34 36 @Override 35 public booleanhandleRequest(Database db, Tuple request, PrintWriter csvDownload) throws ParseException, DatabaseException,37 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter csvDownload) throws ParseException, DatabaseException, 36 38 IOException 37 39 { 38 40 logger.debug(this.getName()); 39 41 40 FormModel<E> view = this.get Screen();42 FormModel<E> view = this.getFormScreen(); 41 43 List<E> records = view.getRecords(); 42 44 CsvWriter writer = new CsvWriter(csvDownload, view.create().getFields()); … … 44 46 for (E e : records) 45 47 writer.writeRow(e); 46 return true; 48 49 return ScreenModel.Show.SHOW_MAIN; 50 } 51 52 @Override 53 public List<HtmlInput> getActions() 54 { 55 // TODO Auto-generated method stub 56 return null; 57 } 58 59 @Override 60 public List<HtmlInput> getInputs() throws DatabaseException 61 { 62 // TODO Auto-generated method stub 63 return null; 47 64 } 48 65 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/EditSelectedCommand.java
r2308 r2442 9 9 import org.molgenis.framework.ui.FormModel; 10 10 import org.molgenis.framework.ui.ScreenMessage; 11 import org.molgenis.framework.ui.ScreenModel; 11 12 import org.molgenis.framework.ui.FormModel.Mode; 13 import org.molgenis.framework.ui.html.HtmlInput; 12 14 import org.molgenis.util.Entity; 13 15 import org.molgenis.util.Tuple; … … 36 38 public boolean isVisible() 37 39 { 38 FormModel<E> view = this.get Screen();40 FormModel<E> view = this.getFormScreen(); 39 41 return !view.isReadonly() && view.getMode().equals(Mode.LIST_VIEW); 40 42 } 41 43 42 44 @Override 43 public booleanhandleRequest(Database db, Tuple request, PrintWriter out) throws DatabaseException45 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter out) throws DatabaseException 44 46 { 45 47 logger.debug(this.getName()); … … 48 50 if (request.getString(FormModel.INPUT_SHOW) == null) 49 51 { 50 FormModel<E> view = this.get Screen();52 FormModel<E> view = this.getFormScreen(); 51 53 List<Object> idList = request.getList(FormModel.INPUT_SELECTED); 52 54 for (Object id : idList) … … 90 92 view.getMessages().add(msg); 91 93 } 92 return true; 94 return ScreenModel.Show.SHOW_MAIN; 95 } 96 97 @Override 98 public List<HtmlInput> getActions() 99 { 100 // TODO Auto-generated method stub 101 return null; 102 } 103 104 @Override 105 public List<HtmlInput> getInputs() throws DatabaseException 106 { 107 // TODO Auto-generated method stub 108 return null; 93 109 } 94 110 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/RemoveSelectedCommand.java
r2308 r2442 14 14 import org.molgenis.framework.ui.FormModel; 15 15 import org.molgenis.framework.ui.ScreenMessage; 16 import org.molgenis.framework.ui.ScreenModel; 16 17 import org.molgenis.framework.ui.FormModel.Mode; 18 import org.molgenis.framework.ui.html.HtmlInput; 17 19 import org.molgenis.util.Entity; 18 20 import org.molgenis.util.Tuple; … … 31 33 { 32 34 //only in listview 33 return get Screen().getMode().equals(Mode.LIST_VIEW);35 return getFormScreen().getMode().equals(Mode.LIST_VIEW); 34 36 } 35 37 36 38 @Override 37 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws DatabaseException, ParseException, IOException39 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws DatabaseException, ParseException, IOException 38 40 { 39 41 logger.debug(this.getName()); 40 42 41 FormModel<E> view = get Screen();43 FormModel<E> view = getFormScreen(); 42 44 43 45 ScreenMessage<E> msg = null; … … 73 75 } 74 76 75 return true; 77 return ScreenModel.Show.SHOW_MAIN; 78 } 79 80 @Override 81 public List<HtmlInput> getActions() 82 { 83 // TODO Auto-generated method stub 84 return null; 85 } 86 87 @Override 88 public List<HtmlInput> getInputs() throws DatabaseException 89 { 90 // TODO Auto-generated method stub 91 return null; 76 92 } 77 93 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/ScreenCommand.java
r2308 r2442 9 9 import org.molgenis.framework.db.DatabaseException; 10 10 import org.molgenis.framework.ui.FormModel; 11 import org.molgenis.framework.ui.ScreenModel; 11 12 import org.molgenis.framework.ui.Templateable; 12 13 import org.molgenis.framework.ui.html.HtmlInput; … … 92 93 * @return The screen this command is a child of 93 94 */ 94 public FormModel<E> getScreen(); 95 public ScreenModel getScreen(); 96 97 /** 98 * Helper method to reduce casting 99 */ 100 public FormModel getFormScreen(); 95 101 96 102 /** … … 98 104 * The screen this command belongs to 99 105 */ 100 public void setScreen( FormModel<E>screen);106 public void setScreen(ScreenModel screen); 101 107 102 108 /** @return true if this command should show a dialog */ … … 142 148 * @param downloadStream 143 149 * this the request can use to write results as download 144 * @return true if the request was handled succesfully150 * @return if their should still be a popup, inline or download 145 151 * @throws IOException 146 152 * @throws DatabaseException 147 153 * @throws ParseException 148 154 */ 149 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException,155 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, 150 156 DatabaseException, IOException; 151 157 -
molgenis/3.3/src/org/molgenis/framework/ui/commands/SimpleCommand.java
r2308 r2442 11 11 import org.molgenis.framework.ui.FormModel; 12 12 import org.molgenis.framework.ui.ScreenModel; 13 import org.molgenis.framework.ui.ScreenModel.Show; 13 14 import org.molgenis.framework.ui.html.HtmlInput; 14 15 import org.molgenis.util.Entity; 15 import org.molgenis.util.SimpleTree;16 16 import org.molgenis.util.Tuple; 17 17 … … 20 20 * TODO: this may be very useful for other screens also. 21 21 */ 22 public class SimpleCommand<E extends Entity> implements ScreenCommand<E>22 public abstract class SimpleCommand<E extends Entity> implements ScreenCommand<E> 23 23 { 24 24 /** Logger */ 25 25 public Logger logger = Logger.getLogger(this.getClass().getSimpleName()); 26 26 27 27 /** Internal name of this command (unique within the screen( */ 28 28 private String name; … … 46 46 private boolean download = false; 47 47 48 /** The FormScreen this command is linked to */49 private FormModel<E>screen;48 /** The Screen this command is linked to */ 49 private ScreenModel screen; 50 50 51 51 /** The name of the menu this command should be shown on */ 52 52 private String menu; 53 53 54 54 /** Indicates to the screen to show this command on the toolbar */ 55 55 private boolean toolbar; … … 62 62 63 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 } 72 73 /** 64 74 * Constructor 65 * @param name unique name of the command (within the screen) 75 * 76 * @param name 77 * unique name of the command (within the screen) 66 78 * @param parentScreen 67 79 */ … … 73 85 74 86 /** 75 * Get the javascript needed. 76 * If not provided it will be auto-generated. 87 * Get the javascript needed. If not provided it will be auto-generated. 77 88 */ 78 89 public String getJavaScriptAction() … … 80 91 if (action == null) 81 92 { 93 if (this.getScreen() == null) throw new NullPointerException("setScreen() has not been set on command '" 94 + getName() + "'"); 95 82 96 StringBuffer jScript = new StringBuffer(); 83 97 84 //make sure the current window has a name (so popup can call back if necessary) 98 // make sure the current window has a name (so popup can call back 99 // if necessary) 85 100 jScript.append("if( window.name == '' ){ window.name = 'molgenis'+Math.random();}"); 86 101 87 102 // default target screen is 'self' 88 103 jScript.append("document.forms." + this.getScreen().getName() + "_form." + FormModel.INPUT_TARGET 89 104 + ".value='" + this.getScreen().getName() + "';"); 90 91 // default action handler is also 'self'105 106 // default action handler is also 'self' 92 107 jScript.append("document.forms." + this.getScreen().getName() + "_form." + FormModel.INPUT_ACTION 93 108 + ".value='" + getName() + "';"); 94 109 95 110 // in case of dialog make a popup 96 111 if (this.isDialog()) … … 98 113 // open a new screen named 'popup' 99 114 jScript 100 .append("molgenis_window = window.open('','"+"molgenis_"+this.getName()+"','height=800,width=600,location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes');"); 101 115 .append("molgenis_window = window.open('','" 116 + "molgenis_" 117 + this.getName() 118 + "','height=800,width=600,location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes');"); 119 102 120 // make this new screen the target of this form 103 jScript.append("document.forms." + this.getScreen().getName() + "_form.target='"+"molgenis_"+this.getName()+"';"); 121 jScript.append("document.forms." + this.getScreen().getName() + "_form.target='" + "molgenis_" 122 + this.getName() + "';"); 104 123 105 124 // set the 'show' parameter to 'popup' so the server knows to 106 125 // show only this dialog 107 126 jScript.append("document.forms." + this.getScreen().getName() + "_form." + FormModel.INPUT_SHOW 108 + ".value='" + ScreenModel.S HOW_DIALOG + "';");127 + ".value='" + ScreenModel.Show.SHOW_DIALOG + "';"); 109 128 } 110 129 … … 112 131 else if (this.isDownload()) 113 132 { 114 // tell molgenis to download133 // tell molgenis to download 115 134 jScript.append("document.forms." + this.getScreen().getName() + "_form." + FormModel.INPUT_SHOW 116 + ".value='" + ScreenModel.S HOW_DOWNLOAD + "';");135 + ".value='" + ScreenModel.Show.SHOW_DOWNLOAD + "';"); 117 136 } 118 119 // default show inline137 138 // default show inline 120 139 else 121 140 { 122 141 // make this this action target current window 123 142 jScript.append("document.forms." + this.getScreen().getName() + "_form.target=window.name;"); 124 143 125 144 jScript.append("document.forms." + this.getScreen().getName() + "_form." + FormModel.INPUT_SHOW 126 + ".value='" + ScreenModel.S HOW_INLINE+ "';");145 + ".value='" + ScreenModel.Show.SHOW_MAIN + "';"); 127 146 } 128 147 129 148 jScript.append("document.forms." + this.getScreen().getName() + "_form.submit();"); 130 131 149 132 150 // make popup on front … … 146 164 * @throws DatabaseException 147 165 */ 148 public List<HtmlInput> getInputs() throws DatabaseException 149 { 150 return null; 151 } 166 public abstract List<HtmlInput> getInputs() throws DatabaseException; 152 167 153 168 // GETTERS AND SETTERS BELOW … … 167 182 public String getLabel() 168 183 { 169 return label; 184 if (label != null) return label; 185 return this.getName(); 170 186 } 171 187 … … 213 229 214 230 @Override 215 public FormModel<E>getScreen()231 public ScreenModel getScreen() 216 232 { 217 233 return this.screen; … … 219 235 220 236 @Override 221 public void setScreen(FormModel<E> screen) 237 public FormModel<E> getFormScreen() 238 { 239 return (FormModel) this.screen; 240 } 241 242 @Override 243 public void setScreen(ScreenModel screen) 222 244 { 223 245 this.screen = screen; … … 250 272 251 273 @Override 252 public List<HtmlInput> getActions() 274 public abstract List<HtmlInput> getActions(); 275 276 @Override 277 public Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, 278 DatabaseException, IOException 253 279 { 254 280 // TODO Auto-generated method stub 281 return ScreenModel.Show.SHOW_MAIN; 282 } 283 284 @Override 285 public boolean isDownload() 286 { 287 return download; 288 } 289 290 @Override 291 public void setDownload(boolean download) 292 { 293 this.download = download; 294 } 295 296 @Override 297 public boolean isToolbar() 298 { 299 return toolbar; 300 } 301 302 @Override 303 public void setToolbar(boolean toolbar) 304 { 305 this.toolbar = toolbar; 306 } 307 308 /** 309 * Default view name = 'SimpleCommand' 310 */ 311 public String getViewName() 312 { 313 return ScreenCommand.class.getSimpleName(); 314 } 315 316 public String getViewTemplate() 317 { 255 318 return null; 256 319 } 257 320 258 321 @Override 259 public boolean handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws ParseException, DatabaseException, 260 IOException 261 { 262 // TODO Auto-generated method stub 263 return false; 264 } 265 266 @Override 267 public boolean isDownload() 268 { 269 return download; 270 } 271 272 @Override 273 public void setDownload(boolean download) 274 { 275 this.download = download; 276 } 277 278 @Override 279 public boolean isToolbar() 280 { 281 return toolbar; 282 } 283 284 @Override 285 public void setToolbar(boolean toolbar) 286 { 287 this.toolbar = toolbar; 288 } 289 290 /** 291 * Default view name = 'SimpleCommand' 292 */ 293 public String getViewName() 294 { 295 return ScreenCommand.class.getSimpleName(); 296 } 297 298 public String getViewTemplate() 299 { 300 return null; 301 } 302 303 @Override 304 public String getCustomHtmlHeaders() { 322 public String getCustomHtmlHeaders() 323 { 305 324 return ""; 306 325 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/ViewEditViewCommand.java
r2308 r2442 5 5 6 6 import java.io.PrintWriter; 7 import java.util.List; 7 8 8 9 import org.molgenis.framework.db.Database; 10 import org.molgenis.framework.db.DatabaseException; 9 11 import org.molgenis.framework.ui.FormModel; 12 import org.molgenis.framework.ui.ScreenModel; 10 13 import org.molgenis.framework.ui.FormModel.Mode; 14 import org.molgenis.framework.ui.html.HtmlInput; 11 15 import org.molgenis.util.Entity; 12 16 import org.molgenis.util.Tuple; … … 22 26 23 27 @Override 24 public booleanhandleRequest(Database db, Tuple request, PrintWriter out)28 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter out) 25 29 { 26 get Screen().setMode(Mode.EDIT_VIEW);30 getFormScreen().setMode(Mode.EDIT_VIEW); 27 31 Integer offset = request.getInt(FormModel.INPUT_OFFSET); 28 if (offset != null) get Screen().getPager().setOffset(offset - 1);29 return true;32 if (offset != null) getFormScreen().getPager().setOffset(offset - 1); 33 return ScreenModel.Show.SHOW_MAIN; 30 34 } 31 35 … … 35 39 //show add button when not in recordview 36 40 //show add button if the screen is not readonly 37 return !this.getScreen().getMode().equals(Mode.EDIT_VIEW) 38 && !this.getScreen().isReadonly() 39 && this.getScreen().getRecordInputs().size() != 0 40 && !this.getScreen().getRecordInputs().get(0).isReadonly(); 41 return !this.getFormScreen().getMode().equals(Mode.EDIT_VIEW) 42 && !this.getFormScreen().isReadonly() 43 && this.getFormScreen().getRecordInputs().size() != 0 44 && !this.getFormScreen().getRecordInputs().get(0).isReadonly(); 45 } 46 47 @Override 48 public List<HtmlInput> getActions() 49 { 50 // TODO Auto-generated method stub 51 return null; 52 } 53 54 @Override 55 public List<HtmlInput> getInputs() throws DatabaseException 56 { 57 // TODO Auto-generated method stub 58 return null; 41 59 } 42 60 } -
molgenis/3.3/src/org/molgenis/framework/ui/commands/ViewListViewCommand.java
r2308 r2442 7 7 import java.io.PrintWriter; 8 8 import java.text.ParseException; 9 import java.util.List; 9 10 10 11 import org.molgenis.framework.db.Database; 11 12 import org.molgenis.framework.db.DatabaseException; 12 13 import org.molgenis.framework.ui.FormModel; 14 import org.molgenis.framework.ui.ScreenModel; 13 15 import org.molgenis.framework.ui.FormModel.Mode; 16 import org.molgenis.framework.ui.html.HtmlInput; 14 17 import org.molgenis.util.Entity; 15 18 import org.molgenis.util.Tuple; … … 25 28 26 29 @Override 27 public booleanhandleRequest(Database db, Tuple request, PrintWriter downloadStream) throws DatabaseException, ParseException,30 public ScreenModel.Show handleRequest(Database db, Tuple request, PrintWriter downloadStream) throws DatabaseException, ParseException, 28 31 IOException 29 32 { 30 33 logger.debug(this.getName()); 31 34 32 get Screen().setMode(Mode.LIST_VIEW);35 getFormScreen().setMode(Mode.LIST_VIEW); 33 36 Integer offset = request.getInt(FormModel.INPUT_OFFSET); 34 37 if (offset != null) 35 38 { 36 get Screen().getPager().setOffset(offset - 1);39 getFormScreen().getPager().setOffset(offset - 1); 37 40 } 38 41 else 39 42 { 40 get Screen().getPager().setOffset(getScreen().getOffset());43 getFormScreen().getPager().setOffset(getFormScreen().getOffset()); 41 44 } 42 return true;45 return ScreenModel.Show.SHOW_MAIN; 43 46 } 44 47 … … 47 50 { 48 51 // hide when already in list view 49 return !getScreen().getMode().equals(Mode.LIST_VIEW); 52 return !getFormScreen().getMode().equals(Mode.LIST_VIEW); 53 } 54 55 @Override 56 public List<HtmlInput> getActions() 57 { 58 // TODO Auto-generated method stub 59 return null; 60 } 61 62 @Override 63 public List<HtmlInput> getInputs() throws DatabaseException 64 { 65 // TODO Auto-generated method stub 66 return null; 50 67 } 51 68 } -
molgenis/3.3/src/org/molgenis/framework/ui/html/Form.java
r2308 r2442 17 17 } 18 18 19 public void addAll(List< Input> inputs)19 public void addAll(List<HtmlInput> inputs) 20 20 { 21 21 for(Input i: inputs) this.add(i); -
molgenis/3.3/src/org/molgenis/framework/ui/html/HtmlForm.java
r2314 r2442 10 10 import org.molgenis.util.Tuple; 11 11 12 public abstractclass HtmlForm<E extends Entity>12 public class HtmlForm<E extends Entity> 13 13 { 14 14 /** The entity to be shown in this form*/ … … 20 20 /** A form may be used to add a new record. This may result in readonly fields, e.g. for autoid.*/ 21 21 private boolean newRecord = false; 22 /** Inputs */ 23 private List<HtmlInput> inputs = new ArrayList<HtmlInput>(); 24 25 public HtmlForm() 26 { 27 28 } 22 29 23 30 public boolean isNewRecord() … … 48 55 49 56 /**Create the inputs to be shown*/ 50 public abstract Vector<HtmlInput> getInputs(); 57 public List<HtmlInput> getInputs() 58 { 59 return this.inputs; 60 } 61 62 public void setInputs(List<HtmlInput> inputs) 63 { 64 this.inputs = inputs; 65 } 51 66 52 67 public E getEntity()
Note: See TracChangeset
for help on using the changeset viewer.