Changeset 3492


Ignore:
Timestamp:
Jun 14, 2007, 10:44:39 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #578

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/userdoc/webclient.xml

    r3490 r3492  
    237237          <listitem>
    238238            <para>
    239             Go to the most recently viewed item. By default, the list contains links to
    240             the most recently viewed experiment and bioassayset, but this
    241             is configurable. If you, for example, work a lot with protocols, you may
    242             add a link to the most recently viewed protocol.
     239            Shortcut to the most recently viewed items. The number of items are
     240            configurable and you can also make some item types
     241            <emphasis>sticky</emphasis>. This will for example keep the shortcut
     242            to the last experiment even if you have viewed lots of other items
     243            more recently.
    243244            See <xref linkend="webclient.configuration.preferences.mostrecent"/>
     245            for configuration information.
    244246            </para>
    245247          </listitem>
     
    593595            <varlistentry>
    594596              <term>
    595                 <guilabel>Recently used items</guilabel>
    596               </term>
    597               <listitem>
    598                 <para>
    599                 The number of items to remember in the list
    600                 of recently used items. The default is to remember
    601                 4 items.
    602                 </para>
    603               </listitem>
    604             </varlistentry>
    605             <varlistentry>
    606               <term>
    607597                <guilabel>Ratio color range</guilabel>
    608598              </term>
     
    732722       
    733723        <sect3 id="webclient.configuration.preferences.mostrecent">
    734           <title>The Most recent tab</title>
    735          
    736           <helptext external_id="userpreferences.mostrecent" title="Preferences - Most recent">
     724          <title>The Recent items tab</title>
     725         
     726          <helptext external_id="userpreferences.mostrecent"
     727            title="Preferences - Recent items">
    737728         
    738729          <para>
    739             This tab contains settings that affect the <guilabel>Most
    740             recent</guilabel> menu. You can select which items should
    741             appear in the menu by moving them to the left list. Use
    742             the up and down arrows to change the order in which they appear.
     730            This tab contains settings that affect the <guilabel>Recent
     731            items</guilabel> menu.
    743732          </para>
    744733         
    745           <para>
    746             If the <guilabel>Load the names of all recent items</guilabel> checkbox
    747             is checked the name of the items will be displayed in the menu (for example,
    748             Experiment: My experiment). Otherwise only the type of the item is
    749             displayed (for example, Experiment).
    750           </para>
     734          <variablelist>
     735          <varlistentry>
     736            <term>
     737              <guilabel>Recently viewed items</guilabel>
     738            </term>
     739            <listitem>
     740              <para>
     741              The number of recently <emphasis>viewed</emphasis> items to remember.
     742              The default is to remember 6 items. The remembered items
     743              will be displayed in the <guilabel>Recent items</guilabel>
     744              menu in the menu bar.
     745              </para>
     746            </listitem>
     747          </varlistentry>
     748          <varlistentry>
     749            <term>
     750              <guilabel>Recently used items</guilabel>
     751            </term>
     752            <listitem>
     753              <para>
     754              The number of recently <emphasis>used</emphasis> items to remember.
     755              The default is to remember 4 items. The remembered items will
     756              be displayed in edit dialogs where they have been used before.
     757              Each type of edit operation has it's own list of remembered items.
     758              For example, there is one list that remembers the most recently used
     759              protocols when creating a sample, and there is another list that
     760              remembers the most recently used scanners when creating a scan.
     761              </para>
     762            </listitem>
     763          </varlistentry>
     764         
     765          <varlistentry>
     766            <term>
     767              <guilabel>Load the names of all items</guilabel>
     768            </term>
     769            <listitem>
     770              <para>
     771              If checked, the names of the items will be loaded and
     772              displayed in the menu, otherwise only the ID and type of item
     773              is displayed.
     774              </para>
     775            </listitem>
     776          </varlistentry>
     777         
     778          <varlistentry>
     779            <term>
     780              <guilabel>Sticky items</guilabel>
     781            </term>
     782            <listitem>
     783              <para>
     784              Always remember the last viewed item of the selected types.
     785              For example, if you have selected <emphasis>Experiment</emphasis>
     786              as a sticky item, the last viewed experiment will be remembered
     787              even if you view hundreds of other items. Use the arrow buttons
     788              to move item types between the lists and sort the sticky items list.
     789              Sticky items will be displayed in the <guilabel>Recent items</guilabel>
     790              menu in the menu bar.             
     791              </para>
     792            </listitem>
     793          </varlistentry>
     794          </variablelist>
    751795          </helptext>
    752796         
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r3045 r3492  
    4040import net.sf.basedb.core.PropertyFilter;
    4141import net.sf.basedb.core.ItemQuery;
     42import net.sf.basedb.core.StringUtil;
    4243import net.sf.basedb.core.Type;
    4344import net.sf.basedb.core.Operator;
     
    6768
    6869import java.awt.Color;
     70import java.util.ArrayList;
    6971import java.util.Date;
     72import java.util.List;
    7073import java.util.Set;
    7174import java.util.Arrays;
     
    390393     
    391394      // Current item
    392       cc.setId(Values.getInt(request.getParameter("item_id"), cc.getId()));
     395      String itemId = request.getParameter("item_id");
     396      cc.setId(Values.getInt(itemId, cc.getId()));
    393397     
     398      // Record this in the list of recently view items
     399      if (itemId != null)
     400      {
     401        String recent = sc.getUserClientSetting("menu.mostRecent.viewed");
     402        List<String> recentItems = null;
     403        if (recent == null)
     404        {
     405          recentItems = new ArrayList<String>();
     406        }
     407        else
     408        {
     409          // Need a new list since Arrays.asList returns a read-only list
     410          recentItems = new ArrayList<String>(Arrays.asList(recent.split(":")));
     411        }
     412        String thisItem = itemType.name()+"="+itemId;
     413        recentItems.remove(thisItem);
     414        recentItems.add(0, thisItem);
     415        int maxRecent = Values.getInt(sc.getUserClientSetting("menu.mostRecent.maxViewed"), 6);
     416        if (recentItems.size() > maxRecent) recentItems = recentItems.subList(0, maxRecent);
     417        sc.setUserClientSetting("menu.mostRecent.viewed", StringUtil.join(recentItems, ":", true));
     418      }
    394419      // Visible columns
    395420      cc.setSetting("columns", Values.getString(request.getParameter("columns"), cc.getSetting("columns")));
     
    467492        if (extraValueContext != null) extraValueContext.getSelected().clear();
    468493
    469         String itemId = request.getParameter("item_id");
    470494        if (itemId != null && request.getParameter(itemId) == null)
    471495        {
  • trunk/www/include/menu.jsp

    r3021 r3492  
    5757  import="java.util.HashMap"
    5858  import="java.util.ArrayList"
     59  import="java.util.List"
     60  import="java.util.Arrays"
    5961%>
    6062<%@ taglib prefix="m" uri="/WEB-INF/menu.tld" %>
     
    7375{
    7476  // Recently used items menu
    75   String mostRecent = Values.getString(sc.getUserClientSetting("menu.mostRecent"),
     77  String stickyItems = Values.getString(sc.getUserClientSetting("menu.mostRecent"),
    7678    "EXPERIMENT:BIOASSAYSET:TRANSFORMATION");
    7779  boolean loadNames = Values.getBoolean(sc.getUserClientSetting("menu.mostRecent.loadNames"),
    7880    false);
     81  String recentItems = sc.getUserClientSetting("menu.mostRecent.viewed");
    7982  DbControl dc = loadNames ? sc.newDbControl() : null;
    8083  try
     
    8790      <%
    8891      int numItems = 0;
    89       for (String recentItem : mostRecent.split(":"))
     92      // Recently viewed items
     93      List<String> recentlyViewed = recentItems == null ?
     94        new ArrayList<String>() : Arrays.asList(recentItems.split(":"));
     95      if (recentlyViewed.size() > 0)
    9096      {
    91         Item itemType = Item.valueOf(recentItem);
    92         ItemContext cc = sc.getCurrentContext(itemType);
    93         if (cc.getId() != 0)
     97        %>
     98        <m:menuitem
     99          title="Recently viewed items"
     100          style="font-weight: bold; color: #000000; background: #e8e8e8;"
     101          enabled="false"
     102        />
     103        <m:menuseparator />
     104        <%
     105        for (String recent : recentlyViewed)
    94106        {
    95           String shortName = "";
    96           String fullName = "";
    97           if (loadNames)
     107          String[] tmp = recent.split("=");
     108          Item itemType = Item.valueOf(tmp[0]);
     109          int itemId = Values.getInt(tmp[1], 0);
     110          if (itemId != 0)
    98111          {
    99             try
     112            String shortName = "";
     113            String fullName = "";
     114            if (loadNames)
    100115            {
    101               BasicItem item = itemType.getById(dc, cc.getId());
    102               fullName = ((Nameable)item).getName();
    103               shortName = ": " + StringUtil.trimString(fullName, 20);
     116              try
     117              {
     118                BasicItem item = itemType.getById(dc, itemId);
     119                fullName = ((Nameable)item).getName();
     120                shortName = HTML.encodeTags(StringUtil.trimString(fullName, 20));
     121              }
     122              catch (Throwable t)
     123              {
     124                continue;
     125              }
    104126            }
    105             catch (Throwable t)
    106             {}
    107           }
    108           else
    109           {
    110             fullName = itemType.toString() + "; id=" + cc.getId();
    111           }
    112           numItems++;
    113           %>
    114           <m:menuitem
    115             title="<%=itemType.toString()+HTML.encodeTags(shortName)%>"
    116             onclick="<%="Main.viewOrEditItem('" + ID + "', '" + itemType.name() + "', " + cc.getId() + ")"%>"
    117             tooltip="<%="Go to " + HTML.encodeTags(fullName)%>"
    118           />
    119           <%
    120           if (itemType == Item.BIOASSAYSET)
    121           {
    122             // Add menu for Experiment explorer as well
     127            else
     128            {
     129              fullName = itemType.toString() + "; id=" + itemId;
     130              shortName = itemType + " (id=" + itemId + ")";
     131            }
     132            numItems++;
    123133            %>
    124134            <m:menuitem
    125               title="<%="Experiment explorer"+HTML.encodeTags(shortName)%>"
    126               onclick="<%="location.href = '"+root+"views/experiments/explorer/view/index.jsp?ID=" + ID + "&bioassayset_id="+cc.getId()+"'"%>"
    127               tooltip="Go to experiment explorer"
     135              title="<%=numItems + ". " + shortName%>"
     136              onclick="<%="Main.viewOrEditItem('" + ID + "', '" + itemType.name() + "', " + itemId + ")"%>"
     137              tooltip="<%="Go to " + HTML.encodeTags(fullName) + " (" + itemType + ")"%>"
    128138            />
    129139            <%
     
    131141        }
    132142      }
    133       if (numItems == 0)
     143      if (stickyItems != null && stickyItems.length() > 0)
    134144      {
     145        int numSticky = 0;
     146        if (numItems > 0)
     147        {
     148          %>
     149          <m:menuseparator />
     150          <%
     151        }
    135152        %>
    136153        <m:menuitem
    137           title="<i>- no recent items -</i>"
    138           enabled="false"
    139         />
     154          title="Sticky items"
     155          style="font-weight: bold; color: #000000; background: #e8e8e8;"
     156          enabled="false"
     157        />
     158        <m:menuseparator />
    140159        <%
     160        // Sticky items
     161        for (String recentItem : stickyItems.split(":"))
     162        {
     163          Item itemType = Item.valueOf(recentItem);
     164          ItemContext cc = sc.getCurrentContext(itemType);
     165          if (cc.getId() != 0)
     166          {
     167            String shortName = "";
     168            String fullName = "";
     169            if (loadNames)
     170            {
     171              try
     172              {
     173                BasicItem item = itemType.getById(dc, cc.getId());
     174                fullName = ((Nameable)item).getName();
     175                shortName = ": " + HTML.encodeTags(StringUtil.trimString(fullName, 20));
     176              }
     177              catch (Throwable t)
     178              {
     179                continue;
     180              }
     181            }
     182            else
     183            {
     184              fullName = itemType.toString() + "; id=" + cc.getId();
     185              shortName = " (id=" + cc.getId() + ")";
     186            }
     187            numItems++;
     188            numSticky++;
     189            %>
     190            <m:menuitem
     191              title="<%=itemType + shortName%>"
     192              onclick="<%="Main.viewOrEditItem('" + ID + "', '" + itemType.name() + "', " + cc.getId() + ")"%>"
     193              tooltip="<%="Go to " + HTML.encodeTags(fullName) + " (" + itemType + ")"%>"
     194            />
     195            <%
     196            if (itemType == Item.BIOASSAYSET)
     197            {
     198              // Add menu for Experiment explorer as well
     199              %>
     200              <m:menuitem
     201                title="<%="Experiment explorer"+HTML.encodeTags(shortName)%>"
     202                onclick="<%="location.href = '"+root+"views/experiments/explorer/view/index.jsp?ID=" + ID + "&bioassayset_id="+cc.getId()+"'"%>"
     203                tooltip="Go to experiment explorer"
     204              />
     205              <%
     206            }
     207          }
     208        }
     209        if (numSticky == 0)
     210        {
     211          %>
     212          <m:menuitem
     213            title="<i>- no sticky items -</i>"
     214            enabled="false"
     215          />
     216          <%
     217        }
    141218      }
    142219      %>
  • trunk/www/my_base/user/preferences.jsp

    r3480 r3492  
    9393        return false;
    9494      }
    95       var recent = parseInt(frm.recent.value);
    96       if (!Numbers.isInteger(frm.recent.value) || recent < 0 || recent > 10)
     95      return true;
     96    }
     97    function validatePlugins()
     98    {
     99      return true;
     100    }
     101    function validateMostRecent()
     102    {
     103      var frm = document.forms['preferences'];
     104      var maxViewed = parseInt(frm.maxViewed.value);
     105      if (!Numbers.isInteger(frm.maxViewed.value) || maxViewed < 0 || maxViewed > 10)
    97106      {
    98         frm.recent.focus();
    99         frm.recent.select();
     107        frm.maxViewed.focus();
     108        frm.maxViewed.select();
     109        alert("Please enter a value between 0 and 10.");
     110        return false;
     111      }
     112      var maxUsed = parseInt(frm.maxUsed.value);
     113      if (!Numbers.isInteger(frm.maxUsed.value) || maxUsed < 0 || maxUsed > 10)
     114      {
     115        frm.maxUsed.focus();
     116        frm.maxUsed.select();
    100117        alert("Please enter a value between 0 and 10.");
    101118        return false;
     
    103120      return true;
    104121    }
    105     function validatePlugins()
    106     {
    107       return true;
    108     }
    109     function validateMostRecent()
    110     {
    111       return true;
    112     }
    113122    // Changes the scale value
    114123    function setScale(newScale)
     
    123132      if (TabControl.validateActiveTab('settings'))
    124133      {
    125         var enabled = frm.enabled;
    126         for (var i = 0; i < enabled.length; i++) // >
     134        var sticky_items = frm.sticky_items;
     135        for (var i = 0; i < sticky_items.length; i++) // >
    127136        {
    128           enabled.options[i].selected = true;
     137          sticky_items.options[i].selected = true;
    129138        }
    130139        frm.submit();
     
    172181    {
    173182      var frm = document.forms['preferences'];
    174       var enabled = frm.enabled;
    175       var disabled = frm.disabled;
     183      var sticky_items = frm.sticky_items;
     184      var all_items = frm.all_items;
    176185      <%
    177186      String mostRecent = Values.getString(sc.getUserClientSetting("menu.mostRecent"),
     
    183192      for (Item item : items)
    184193      {
    185         String list = current.contains(item.name()) ? "enabled" : "disabled";
     194        String list = current.contains(item.name()) ? "sticky_items" : "all_items";
    186195        %>
    187196        var option = new Option('<%=item.toString()%>', '<%=item.name()%>');
     
    281290          ><a href="javascript:document.forms['preferences'].toolbar[2].click()">Text only</a>
    282291      </td>
    283     </tr>
    284     <tr>
    285       <td class="prompt">Recently used items</td>
    286       <td>
    287         <input class="text required" type="text" name="recent"
    288           value="<%=Values.getInt(sc.getUserClientSetting("appearance.recent"), 4)%>"
    289           size="4" maxlength="2"  onkeypress="return Numbers.integerOnly(event);">
    290         (0 - 10)
    291       </td>
    292     </tr>
    293    
     292    </tr>   
    294293    <tr>
    295294      <td class="prompt">Ratio color range</td>
     
    446445  <t:tab
    447446    id="mostRecent"
    448     title="Most recent"
     447    title="Recent items"
    449448    validate="validateMostRecent()"
    450449    helpid="userpreferences.mostrecent"
    451     tooltip="Specify which items should be shown in the 'Most recent' menu."
     450    tooltip="Specify how many items to remember in lists of 'most recent items'"
    452451    >
     452    <%
     453    boolean loadNames = Values.getBoolean(sc.getUserClientSetting("menu.mostRecent.loadNames"), false);
     454    %>
     455    <table border=0 cellspacing=0 cellpadding=2 class="form">
     456    <tr valign="baseline">
     457      <td class="prompt">Recently viewed items</td>
     458      <td>
     459        <input class="text required" type="text" name="maxViewed"
     460          value="<%=Values.getInt(sc.getUserClientSetting("menu.mostRecent.maxViewed"), 6)%>"
     461          size="4" maxlength="2"  onkeypress="return Numbers.integerOnly(event);">
     462        (0 - 10)
     463      </td>
     464    </tr>
     465    <tr>
     466      <td class="prompt">Recently used items</td>
     467      <td>
     468        <input class="text required" type="text" name="maxUsed"
     469          value="<%=Values.getInt(sc.getUserClientSetting("appearance.recent"), 4)%>"
     470          size="4" maxlength="2"  onkeypress="return Numbers.integerOnly(event);">
     471        (0 - 10)
     472      </td>
     473    </tr>
     474    <tr>
     475      <td class="prompt">Load the names of all items</td>
     476      <td>
     477        <input type="checkbox" name="loadNames" value="1" <%=loadNames ? "checked" : ""%>>
     478      </td>
     479    </tr>
     480    </table>
    453481    <table border=0 cellspacing=0 cellpadding=2>
     482   
    454483    <tr>
    455484      <td style="vertical-align: middle">
    456485        <br>
    457486        <base:button
    458           onclick="moveSelected(document.forms['preferences'].enabled, false)"
     487          onclick="moveSelected(document.forms['preferences'].sticky_items, false)"
    459488          title="<img src='../../images/move_up.gif' alt='' style='vertical-align: middle;'>"
    460489          tooltip="Move up"
    461490        /><p>
    462491        <base:button
    463           onclick="moveSelected(document.forms['preferences'].enabled, true)"
     492          onclick="moveSelected(document.forms['preferences'].sticky_items, true)"
    464493          title="<img src='../../images/move_down.gif' alt='' style='vertical-align: middle;'>"
    465494          tooltip="Move down"
     
    468497      </td>
    469498      <td>
    470         <b>Show in 'Most recent' menu</b><br>
    471         <select name="enabled" multiple size="14" style="width: 12em;"
    472           ondblclick="moveBetween(document.forms['preferences'].enabled, document.forms['preferences'].disabled)">
     499        <b>Sticky items</b><br>
     500        <select name="sticky_items" multiple size="10" style="width: 12em;"
     501          ondblclick="moveBetween(document.forms['preferences'].sticky_items, document.forms['preferences'].all_items)">
    473502        </select>
    474503      </td>
     
    477506         <br>
    478507        <base:button
    479           onclick="moveBetween(document.forms['preferences'].disabled, document.forms['preferences'].enabled)"
     508          onclick="moveBetween(document.forms['preferences'].all_items, document.forms['preferences'].sticky_items)"
    480509          title="<img src='../../images/move_left.gif' alt='' style='vertical-align: middle;'>"
    481510          tooltip="Show this item in the 'Most recent' menu"
    482511        /><p>
    483512        <base:button
    484           onclick="moveBetween(document.forms['preferences'].enabled, document.forms['preferences'].disabled)"
     513          onclick="moveBetween(document.forms['preferences'].sticky_items, document.forms['preferences'].all_items)"
    485514          title="<img src='../../images/move_right.gif' alt='' style='vertical-align: middle;'>"
    486515          tooltip="Don't show this item in the 'Most recent' menu"
     
    490519 
    491520      <td>
    492         <b>Don't show</b><br>
    493         <select name="disabled" multiple size="14" style="width: 12em;"
    494           ondblclick="moveBetween(document.forms['preferences'].disabled, document.forms['preferences'].enabled)">
     521        <b>All items</b><br>
     522        <select name="all_items" multiple size="10" style="width: 12em;"
     523          ondblclick="moveBetween(document.forms['preferences'].all_items, document.forms['preferences'].sticky_items)">
    495524        </select>
    496525      </td>
    497526    </tr>
    498527    </table>
    499     <%
    500     boolean loadNames = Values.getBoolean(sc.getUserClientSetting("menu.mostRecent.loadNames"), false);
    501     %>
    502     <input type="checkbox" name="loadNames" value="1" <%=loadNames ? "checked" : ""%>>
    503       <a href="javascript:document.forms['preferences'].loadNames.click()"
    504         >Load the names of all recent items</a>
    505528  </t:tab>
    506529  </t:tabcontrol>
  • trunk/www/my_base/user/submit_user.jsp

    r3480 r3492  
    9393    sc.setUserClientSetting("appearance.fontsize", Values.getString(request.getParameter("fontsize"), "size_m.css"));
    9494    sc.setSessionSetting("appearance.scale", new Float(newScale / 100.0));
    95     int newMaxRecent = Values.getInt(request.getParameter("recent"), 4);
    96     sc.setUserClientSetting("appearance.recent", Integer.toString(newMaxRecent));
    97     sc.setSessionSetting("appearance.recent", newMaxRecent);
    9895    ItemContext cc = sc.getCurrentContext(Item.USERCLIENTSETTING);
    9996    int maxRecent = Base.getMaxRecent(sc);
     
    130127    FormatterSettings.setNumDecimals(sc, numDecimals);
    131128   
     129    // Plugins tab
    132130    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
    133131    sc.setUserClientSetting("plugins.removejob", Values.getString(request.getParameter("removejob"), "0"));
    134     String[] mostRecent = request.getParameterValues("enabled");
     132   
     133    // Recent items tab
     134    int newMaxUsed = Values.getInt(request.getParameter("maxUsed"), 4);
     135    sc.setUserClientSetting("appearance.recent", Integer.toString(newMaxUsed));
     136    sc.setSessionSetting("appearance.recent", newMaxUsed);
     137    int newMaxViewed = Values.getInt(request.getParameter("maxViewed"), 6);
     138    sc.setUserClientSetting("menu.mostRecent.maxViewed", Integer.toString(newMaxViewed));
     139    sc.setUserClientSetting("menu.mostRecent.loadNames", Values.getString(request.getParameter("loadNames"), "0"));
     140
     141    String[] stickyItems = request.getParameterValues("sticky_items");
    135142    sc.setUserClientSetting("menu.mostRecent",
    136       mostRecent == null ? "" : Values.getString(Arrays.asList(mostRecent), ":", true));
    137     sc.setUserClientSetting("menu.mostRecent.loadNames", Values.getString(request.getParameter("loadNames"), "0"));
     143      stickyItems == null ? "" : Values.getString(Arrays.asList(stickyItems), ":", true));
    138144   
    139145    message = "Preferences saved";
Note: See TracChangeset for help on using the changeset viewer.