Changeset 2949


Ignore:
Timestamp:
Nov 24, 2006, 4:53:37 PM (16 years ago)
Author:
Martin Svensson
Message:

Fixes #334 Project default items

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Select.java

    r2597 r2949  
    6565      recent=...
    6666      selectrecent=true|false
     67      defaultitem=...
     68      selectdefault=true|false
    6769      onselect=...
    6870      onchange=...
     
    154156  </tr>
    155157  <tr>
     158    <td>defaultitem</td>
     159    <td></td>
     160    <td>no</td>
     161    <td>
     162      Default value set e.g. for a project.
     163    </td>
     164  </tr>
     165  <tr>
     166    <td>selectdefault</td>
     167    <td>true</td>
     168    <td>no</td>
     169    <td>
     170      If no current or recent has been specified and it is a new item then, if this
     171      parameter is TRUE the default value is selected. If this
     172      parameter is FALSE, no item is selected.
     173    </td>
     174  </tr>
     175  <tr>
    156176    <td>onchange</td>
    157177    <td></td>
     
    245265 
    246266  /**
     267      The project default value
     268  */
     269  private BasicItem defaultitem;
     270 
     271  /**
     272    If the default item should be selected for new items with
     273    no current or recently used items.
     274  */
     275  private boolean selectdefault = true;
     276 
     277  /**
    247278    JavaScript statement.
    248279  */
     
    336367  }
    337368
     369  public void setDefaultitem(BasicItem defaultitem)
     370  {
     371    this.defaultitem = defaultitem;
     372  }
     373  public BasicItem getDefaultitem()
     374  {
     375    return defaultitem;
     376  }
     377 
     378  public void setSelectdefault(boolean selectdefault)
     379  {
     380    this.selectdefault = selectdefault;
     381  }
     382  public boolean getSelectdefault()
     383  {
     384    return selectdefault;
     385  }
    338386 
    339387  public void setOnchange(String onChange)
     
    423471      if (recent != null && recent.size() > 0)
    424472      {
    425         sb.append("<option value=\"0\" class=\"recentheader\">- recently used -\n");
     473        sb.append("<option value=\"0\" disabled=\"true\" class=\"recentheader\">- recently used -\n");
    426474        int i = 1;
    427475        for (BasicItem item : recent)
     
    444492        }
    445493      }
     494      if (defaultitem != null)
     495      {
     496        sb.append("<option value=\"0\" disabled=\"true\" class=\"defaultheader\">- default -\n");
     497        String name = getName(defaultitem);
     498        String clazz = "default";
     499       
     500        sb.append("<option value=\"").append(defaultitem.getId()).append("\"");
     501        sb.append(" class=\"").append(clazz).append("\"");       
     502        if ( current == null &&
     503            (recent != null && recent.isEmpty()) &&
     504            isNewitem() &&
     505            getSelectdefault() )
     506        {         
     507          sb.append(" selected");
     508        }
     509        sb.append(">").append(name).append("\n");
     510      }
    446511    }
    447512    sb.append("</select>&nbsp;\n");
  • trunk/www/WEB-INF/base.tld

    r2597 r2949  
    403403    </attribute>
    404404    <attribute>
     405      <name>defaultitem</name>
     406      <required>false</required>
     407      <rtexprvalue>true</rtexprvalue>
     408    </attribute>
     409    <attribute>
     410      <name>selectdefault</name>
     411      <required>false</required>
     412      <rtexprvalue>true</rtexprvalue>
     413    </attribute>
     414    <attribute>
    405415      <name>onchange</name>
    406416      <required>false</required>
  • trunk/www/biomaterials/extracts/edit_extract.jsp

    r2942 r2949  
    3838  import="net.sf.basedb.core.Protocol"
    3939  import="net.sf.basedb.core.ProtocolType"
     40  import="net.sf.basedb.core.Project"
    4041  import="net.sf.basedb.core.PermissionDeniedException"
    4142  import="net.sf.basedb.core.BaseException"
     
    7677  boolean readCurrentProtocol = true;
    7778  Protocol currentProtocol = null;
     79  Protocol defaultProtocol = null;
    7880  boolean readCurrentSample = true;
    7981  Sample currentSample = null;
     
    8587  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL);
    8688  List<Sample> recentSamples = (List<Sample>)cc.getRecent(dc, Item.SAMPLE);
    87  
     89
     90  int activeProjectId = sc.getActiveProjectId();
     91  if (activeProjectId > 0)
     92  {
     93    Project activeProject = Project.getById(dc, activeProjectId);
     94    try
     95    {
     96      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.EXTRACTING_PROTOCOL);
     97    }
     98    catch(PermissionDeniedException pdex)
     99    {
     100      defaultProtocol = null;
     101    }
     102  }
    88103  if (itemId == 0)
    89104  {
     
    111126      name = Values.getString(cc.getPropertyValue("name"), "New extract");
    112127    }
    113     eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate");
     128    eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate");   
    114129  }
    115130  else
     
    502517            denied="<%=!readCurrentProtocol%>"
    503518            recent="<%=recentProtocols%>"
     519            defaultitem="<%=defaultProtocol%>"
    504520            newitem="<%=extract == null%>"
    505521            onselect="selectProtocolOnClick()"
  • trunk/www/biomaterials/labeledextracts/edit_labeledextract.jsp

    r2942 r2949  
    3939  import="net.sf.basedb.core.Protocol"
    4040  import="net.sf.basedb.core.ProtocolType"
     41  import="net.sf.basedb.core.Project"
    4142  import="net.sf.basedb.core.PermissionDeniedException"
    4243  import="net.sf.basedb.core.BaseException"
     
    7778  boolean readCurrentProtocol = true;
    7879  Protocol currentProtocol = null;
     80  Protocol defaultProtocol = null;
    7981  boolean readCurrentLabel = true;
    8082  Label currentLabel = null;
     
    8991  List<Extract> recentExtracts = (List<Extract>)cc.getRecent(dc, Item.EXTRACT);
    9092  List<Label> recentLabels = (List<Label>)cc.getRecent(dc, Item.LABEL);
     93
     94  int activeProjectId = sc.getActiveProjectId();
     95  if (activeProjectId > 0)
     96  {
     97    Project activeProject = Project.getById(dc, activeProjectId);
     98    try
     99    {
     100      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.LABELING_PROTOCOL);
     101    }
     102    catch(PermissionDeniedException pdex)
     103    {
     104      defaultProtocol = null;
     105    }
     106  }
    91107 
    92108  if (itemId == 0)
     
    558574            denied="<%=!readCurrentProtocol%>"
    559575            recent="<%=recentProtocols%>"
     576            defaultitem="<%=defaultProtocol%>"
    560577            newitem="<%=extract == null%>"
    561578            onselect="selectProtocolOnClick()"
  • trunk/www/biomaterials/samples/edit_sample.jsp

    r2942 r2949  
    3838  import="net.sf.basedb.core.Protocol"
    3939  import="net.sf.basedb.core.ProtocolType"
     40  import="net.sf.basedb.core.Project"
    4041  import="net.sf.basedb.core.PermissionDeniedException"
    4142  import="net.sf.basedb.core.BaseException"
     
    7778  boolean readCurrentProtocol = true;
    7879  Protocol currentProtocol = null;
     80  Protocol defaultProtocol = null;
    7981  boolean readCurrentBioSource = true;
    8082  BioSource currentBioSource = null;
     
    8486  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL);
    8587  List<BioSource> recentBioSources = (List<BioSource>)cc.getRecent(dc, Item.BIOSOURCE);
     88 
     89  int activeProjectId = sc.getActiveProjectId();
     90  if (activeProjectId > 0)
     91  {
     92    Project activeProject = Project.getById(dc, activeProjectId);
     93    try
     94    {
     95      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.SAMPLING_PROTOCOL);
     96    }
     97    catch(PermissionDeniedException pdex)
     98    {
     99      defaultProtocol = null;
     100    }
     101  }
     102   
    86103
    87104  if (itemId == 0)
     
    486503            denied="<%=!readCurrentProtocol%>"
    487504            recent="<%=recentProtocols%>"
     505            defaultitem="<%=defaultProtocol%>"
    488506            newitem="<%=sample == null%>"
    489507            onselect="selectProtocolOnClick()"
  • trunk/www/include/styles/main.css

    r2733 r2949  
    201201}
    202202
     203.selectoptionheader, .defaultheader {
     204    font-weight: bold;
     205}
     206
     207.selectionlist .default {
     208}
     209
    203210.selectionlist .removed {
    204211  font-style: italic;
  • trunk/www/lims/arraybatches/edit_batch.jsp

    r2875 r2949  
    3838  import="net.sf.basedb.core.Protocol"
    3939  import="net.sf.basedb.core.ProtocolType"
     40  import="net.sf.basedb.core.Project"
    4041  import="net.sf.basedb.core.Hardware"
    4142  import="net.sf.basedb.core.HardwareType"
     
    7172  boolean readCurrentArrayDesign = true;
    7273  ArrayDesign currentArrayDesign = null;
     74  ArrayDesign defaultArrayDesign = null;
    7375  boolean readCurrentProtocol = true;
    7476  Protocol currentProtocol = null;
     77  Protocol defaultProtocol = null;
    7578  boolean readCurrentPrintRobot = true;
    7679  Hardware currentPrintRobot = null;
     80  Hardware defaultPrintRobot = null;
    7781
    7882  // Load recently used items
     
    8185  List<Hardware> recentPrintRobots = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE);
    8286 
     87  int activeProjectId = sc.getActiveProjectId();
     88  if (activeProjectId > 0)
     89  {
     90    Project activeProject = Project.getById(dc, activeProjectId);
     91    try
     92    {
     93      defaultArrayDesign = (ArrayDesign)activeProject.getDefaultItem(dc, Project.Default.ARRAYDESIGN);
     94    }
     95    catch (PermissionDeniedException pdex)
     96    {
     97      defaultArrayDesign = null;
     98    }
     99    try
     100    {
     101      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.PRINTING_PROTOCOL);
     102    }
     103    catch (PermissionDeniedException pdex)
     104    {
     105      defaultProtocol = null;
     106    }
     107    try
     108    {
     109      defaultPrintRobot = (Hardware)activeProject.getDefaultItem(dc, Project.Default.PRINTROBOT_HARDWARE);
     110    }
     111    catch (PermissionDeniedException pdex)
     112    {
     113      defaultPrintRobot = null;
     114    }
     115  }
    83116  if (itemId == 0)
    84117  {
     
    118151    try
    119152    {
    120       currentPrintRobot = batch.getPrintRobot();
     153      currentPrintRobot = batch.getPrintRobot();     
    121154    }
    122155    catch (PermissionDeniedException ex)
     
    126159    try
    127160    {
    128       currentProtocol = batch.getProtocol();
     161      currentProtocol = batch.getProtocol();     
    129162    }
    130163    catch (PermissionDeniedException ex)
     
    363396              denied="<%=!readCurrentArrayDesign%>"
    364397              recent="<%=recentArrayDesigns%>"
     398              defaultitem="<%=defaultArrayDesign%>"
    365399              newitem="true"
    366400              onselect="selectArrayDesignOnClick()"
     
    382416            denied="<%=!readCurrentPrintRobot%>"
    383417            recent="<%=recentPrintRobots%>"
     418            defaultitem="<%=defaultPrintRobot%>"
    384419            newitem="<%=batch == null%>"
    385420            onselect="selectPrintRobotOnClick()"
     
    397432            denied="<%=!readCurrentProtocol%>"
    398433            recent="<%=recentProtocols%>"
     434            defaultitem="<%=defaultProtocol%>"
    399435            newitem="<%=batch == null%>"
    400436            onselect="selectProtocolOnClick()"
  • trunk/www/views/experiments/edit_experiment.jsp

    r2942 r2949  
    4848  import="net.sf.basedb.core.PermissionDeniedException"
    4949  import="net.sf.basedb.core.BaseException"
     50  import="net.sf.basedb.core.Project"
    5051  import="net.sf.basedb.clients.web.Base"
    5152  import="net.sf.basedb.clients.web.WebException"
     
    7475  Experiment experiment = null;
    7576  RawDataType currentRawDataType = null;
     77  RawDataType defaultRawDataType = null;
    7678  ItemQuery<RawBioAssay> rbaQuery = null;
    7779  ItemQuery<AnnotationType> efQuery = null;
     
    8284  List<Directory> recentDirectories = (List<Directory>)cc.getRecent(dc, Item.DIRECTORY);
    8385
     86  int activeProjectId = sc.getActiveProjectId();
     87  if (activeProjectId > 0)
     88  {
     89    Project activeProject = Project.getById(dc, activeProjectId);   
     90    defaultRawDataType = activeProject.getDefaultRawDataType();
     91  }
    8492  if (itemId == 0)
    8593  {
     
    101109      rbaQuery.restrict(Restrictions.in(Hql.property("id"), Expressions.parameter("selected")));
    102110      rbaQuery.setParameter("selected", Arrays.asList(Values.getInt(selected)), Type.INT);
    103     }
     111    }   
    104112  }
    105113  else
     
    328336            <select name="rawdatatype" class="required">
    329337            <%
     338            currentRawDataType = currentRawDataType != null ? currentRawDataType : defaultRawDataType;
    330339            for (RawDataType rdt : RawDataTypes.getRawDataTypes())
    331340            {
  • trunk/www/views/formulas/edit_formula.jsp

    r2733 r2949  
    3737  import="net.sf.basedb.core.RawDataTypes"
    3838  import="net.sf.basedb.core.RawDataProperty"
     39  import="net.sf.basedb.core.Project"
    3940  import="net.sf.basedb.core.PermissionDeniedException"
    4041  import="net.sf.basedb.util.Values"
     
    6061  Formula.Parser currentParser = null;
    6162  RawDataType currentRawDataType = null;
     63  RawDataType defaultRawDataType = null;
    6264  List<String> expressions = null;
    6365  Coloring coloring = null;
    6466
     67  int activeProjectId = sc.getActiveProjectId();
     68  if (activeProjectId > 0)
     69  {
     70    Project activeProject = Project.getById(dc, activeProjectId);
     71    defaultRawDataType = activeProject.getDefaultRawDataType();
     72  }
    6573  if (itemId == 0)
    6674  {
     
    8593    coloring.setMidValue(Values.getFloat(cc.getPropertyValue("coloring.midValue"), null));
    8694    coloring.setMaxValue(Values.getFloat(cc.getPropertyValue("coloring.maxValue"), null));
     95   
     96    currentRawDataType = currentRawDataType != null ? currentRawDataType : defaultRawDataType;
    8797  }
    8898  else
  • trunk/www/views/hybridizations/edit_hybridization.jsp

    r2942 r2949  
    4141  import="net.sf.basedb.core.Protocol"
    4242  import="net.sf.basedb.core.ProtocolType"
     43  import="net.sf.basedb.core.Project"
    4344  import="net.sf.basedb.core.LabeledExtract"
    4445  import="net.sf.basedb.core.ItemQuery"
     
    8384  boolean readCurrentProtocol = true;
    8485  Protocol currentProtocol = null;
     86  Protocol defaultProtocol = null;
    8587 
    8688  boolean readCurrentHybStation = true;
    8789  Hardware currentHybStation = null;
     90  Hardware defaultHybStation = null;
    8891
    8992  // Load recently used items
     
    9194  List<Hardware> recentStations = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE);
    9295 
     96  int activeProjectId = sc.getActiveProjectId();
     97  if (activeProjectId > 0)
     98  {
     99    Project activeProject = Project.getById(dc, activeProjectId);
     100    try
     101    {
     102      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.HYBRIDIZATION_PROTOCOL);
     103    }
     104    catch (PermissionDeniedException pdex)
     105    {
     106      defaultProtocol = null;
     107    }
     108    try
     109    {
     110      defaultHybStation = (Hardware)activeProject.getDefaultItem(dc, Project.Default.HYBRIDIZATION_HARDWARE);
     111    }
     112    catch (PermissionDeniedException pdex)
     113    {
     114      defaultHybStation = null;
     115    }
     116  }
    93117  if (itemId == 0)
    94118  {
     
    477501            denied="<%=!readCurrentProtocol%>"
    478502            recent="<%=recentProtocols%>"
     503            defaultitem="<%=defaultProtocol%>"
    479504            newitem="<%=hyb == null%>"
    480505            onselect="selectProtocolOnClick()"
     
    493518            denied="<%=!readCurrentHybStation%>"
    494519            recent="<%=recentStations%>"
     520            defaultitem="<%=defaultHybStation%>"
    495521            newitem="<%=hyb == null%>"
    496522            onselect="selectHybStationOnClick()"
  • trunk/www/views/rawbioassays/edit_rawbioassay.jsp

    r2875 r2949  
    3838  import="net.sf.basedb.core.Protocol"
    3939  import="net.sf.basedb.core.ProtocolType"
     40  import="net.sf.basedb.core.Project"
    4041  import="net.sf.basedb.core.Software"
    4142  import="net.sf.basedb.core.SoftwareType"
     
    7778  boolean readCurrentProtocol = true;
    7879  Protocol currentProtocol = null;
     80  Protocol defaultProtocol = null;
    7981  boolean readCurrentSoftware = true;
    8082  Software currentSoftware = null;
     83  Software defaultSoftware = null;
    8184  boolean readCurrentArrayDesign = true;
    8285  ArrayDesign currentArrayDesign = null;
     86  ArrayDesign defaultArrayDesign = null;
    8387  RawDataType currentRawDataType = null;
     88  RawDataType defaultRawDataType = null;
    8489
    8590  // Load recently used items
     
    9095  List<File> recentFiles = (List<File>)cc.getRecent(dc, Item.FILE);
    9196 
     97  int activeProjectId = sc.getActiveProjectId();
     98  if (activeProjectId > 0)
     99  {
     100    Project activeProject = Project.getById(dc, activeProjectId);
     101    try
     102    {
     103      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.FEATURE_EXTRACTION_PROTOCOL);     
     104    }
     105    catch (PermissionDeniedException pdex)
     106    {
     107      defaultProtocol = null;
     108    }
     109    try
     110    {
     111      defaultSoftware = (Software)activeProject.getDefaultItem(dc, Project.Default.SOFTWARE);     
     112    }
     113    catch (PermissionDeniedException pdex)
     114    {
     115      defaultSoftware = null;
     116    }
     117    try
     118    {
     119      defaultArrayDesign = (ArrayDesign)activeProject.getDefaultItem(dc, Project.Default.ARRAYDESIGN);     
     120    }
     121    catch (PermissionDeniedException pdex)
     122    {
     123      defaultArrayDesign = null;
     124    }
     125    defaultRawDataType = activeProject.getDefaultRawDataType();
     126  }
    92127  if (itemId == 0)
    93128  {
     
    139174    {
    140175      currentArrayDesign = Base.getFirstMatching(dc, ArrayDesign.getQuery(), "name", cc.getPropertyFilter("arrayDesign.name"));
    141     }
     176    }
     177    currentRawDataType = currentRawDataType != null ? currentRawDataType : defaultRawDataType;
    142178  }
    143179  else
     
    550586              denied="<%=!readCurrentArrayDesign%>"
    551587              recent="<%=recentArrayDesigns%>"
     588              defaultitem="<%=defaultArrayDesign%>"
    552589              newitem="<%=rawBioAssay == null%>"
    553590              onselect="selectArrayDesignOnClick()"
     
    600637            denied="<%=!readCurrentProtocol%>"
    601638            recent="<%=recentProtocols%>"
     639            defaultitem="<%=defaultProtocol%>"
    602640            newitem="<%=rawBioAssay == null%>"
    603641            onselect="selectProtocolOnClick()"
     
    631669            denied="<%=!readCurrentSoftware%>"
    632670            recent="<%=recentSoftware%>"
     671            defaultitem="<%=defaultSoftware%>"
    633672            newitem="<%=rawBioAssay == null%>"
    634673            onselect="selectSoftwareOnClick()"
  • trunk/www/views/scans/edit_scan.jsp

    r2875 r2949  
    3737  import="net.sf.basedb.core.Protocol"
    3838  import="net.sf.basedb.core.ProtocolType"
     39  import="net.sf.basedb.core.Project"
    3940  import="net.sf.basedb.core.Hardware"
    4041  import="net.sf.basedb.core.HardwareType"
     
    6970  Hybridization currentHybridization = null;
    7071  boolean readCurrentProtocol = true;
    71   Protocol currentProtocol = null;
     72  Protocol currentProtocol = null; 
     73  Protocol defaultProtocol = null;
    7274  boolean readCurrentScanner = true;
    7375  Hardware currentScanner = null;
     76  Hardware defaultScanner = null;
    7477
    7578  // Load recently used items
     
    7881  List<Hybridization> recentHybridizations = (List<Hybridization>)cc.getRecent(dc, Item.HYBRIDIZATION);
    7982
     83  int activeProjectId = sc.getActiveProjectId();
     84  if (activeProjectId > 0)
     85  {
     86    Project activeProject = Project.getById(dc, activeProjectId);
     87    try
     88    {
     89      defaultProtocol = (Protocol)activeProject.getDefaultItem(dc, Project.Default.SCANNING_PROTOCOL);     
     90    }
     91    catch (PermissionDeniedException pdex)
     92    {
     93      defaultProtocol = null;
     94    }
     95    try
     96    {
     97      defaultScanner = (Hardware)activeProject.getDefaultItem(dc, Project.Default.SCANNER_HARDWARE);     
     98    }
     99    catch (PermissionDeniedException pdex)
     100    {
     101      defaultScanner = null;
     102    }
     103  }
    80104  if (itemId == 0)
    81105  {
     
    373397            denied="<%=!readCurrentScanner%>"
    374398            recent="<%=recentScanners%>"
     399            defaultitem="<%=defaultScanner%>"
    375400            newitem="<%=scan == null%>"
    376401            onselect="selectScannerOnClick()"
     
    388413            denied="<%=!readCurrentProtocol%>"
    389414            recent="<%=recentProtocols%>"
     415            defaultitem="<%=defaultProtocol%>"
    390416            newitem="<%=scan == null%>"
    391417            onselect="selectProtocolOnClick()"
Note: See TracChangeset for help on using the changeset viewer.