Changeset 1738


Ignore:
Timestamp:
Jan 9, 2006, 12:12:47 PM (18 years ago)
Author:
Nicklas Nordborg
Message:

View / Reporters should now be more or less functional

Location:
trunk/www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/include/scripts/table.js

    r1716 r1738  
    153153  {
    154154    Main.openPopup(getRoot()+'common/filter/configure.jsp?ID='+ID+'&table_id='+tableId+'&item_type='+itemType, 'ConfigureFilter', 500, 400);
     155  }
     156 
     157  this.submitToPopup = function(tableId, cmd, width, height)
     158  {
     159    var target = tableId+cmd;
     160    Main.openPopup('', target, width, height);
     161    var frm = document.forms[tableId];
     162    var oldCmd = frm.cmd.value;
     163    frm.cmd.value = cmd;
     164    frm.target = target;
     165    frm.submit();
     166    frm.target = window.name;
     167    frm.cmd.value = oldCmd;
    155168  }
    156169 
  • trunk/www/include/styles/main.css

    r1727 r1738  
    7373
    7474a {
     75  color: #0000CC;
    7576  text-decoration: none;
    7677}
    7778
    7879a:hover {
     80  text-decoration: underline;
     81}
     82
     83.link {
     84  color: #0000CC;
     85  cursor: pointer;
     86}
     87
     88.link:hover {
    7989  text-decoration: underline;
    8090}
  • trunk/www/views/reporters/edit_reporter.jsp

    r1727 r1738  
    212212        <td class="prompt">Type</td>
    213213        <td>
    214           <select name="reportertype_id" <%=!readCurrentReporterType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>
     214          <select name="reportertype_id" <%=!readCurrentReporterType ? "disabled readonly class=\"disabled\"" : ""%>>
    215215          <%
    216216          if (!readCurrentReporterType)
     
    254254          <a href="javascript:Main.zoom('Description', 'reporter', 'description')" title="Edit in larger window"><base:icon image="zoom.gif" /></a>
    255255        </td>
    256       </tr>
    257       <tr>
    258         <td class="prompt">Last update</td>
    259         <td><%=Values.formatDate(reporter == null ? new Date() : reporter.getLastUpdate())%></td>
    260256      </tr>
    261257      </table>
  • trunk/www/views/reporters/index.jsp

    r1730 r1738  
    7474  if (cmd == null || "List".equals(cmd))
    7575  {
     76    // Display the list page without updatinging the current context
    7677    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
    7778    redirect = listPage;
     
    7980  else if ("UpdateContext".equals(cmd))
    8081  {
     82    // Display the list page after updating the current context from the request parameters
    8183    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    8284    redirect = listPage;
     
    8486  else if ("LoadContext".equals(cmd))
    8587  {
     88    // Display the list page after loading a saved context
    8689    int contextId = Values.getInt(request.getParameter("context"));
    8790    sc.loadContext(contextId);
    8891    redirect = listPage;
    8992  }
    90   else if ("DeleteItems".equals(cmd))
    91   {
    92     dc = sc.newDbControl();
    93     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    94     ReporterBatcher batcher = ReporterBatcher.getNew(dc);
    95     for (int reporterId : cc.getSelected())
    96     {
    97       batcher.delete(reporterId);
    98     }
    99     batcher.close();
    100     dc.commit();
    101     redirect = listPage;
    102   }
    103   else if ("DeleteItem".equals(cmd))
    104   {
    105     dc = sc.newDbControl();
    106     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    107     ReporterBatcher batcher = ReporterBatcher.getNew(dc);
    108     batcher.delete(cc.getId());
    109     batcher.close();
    110     dc.commit();
    111     redirect = listPage;
    112   }
     93 
    11394  else if ("ViewItem".equals(cmd))
    11495  {
     96    // Display the view page for a single item
    11597    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    11698    redirect = viewPage;
     
    118100  else if ("EditItem".equals(cmd))
    119101  {
     102    // Display the edit page for a single item (should be opened in a popup)
    120103    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    121104    redirect = editPage;
     
    123106  else if ("NewItem".equals(cmd))
    124107  {
     108    // Display the edit page for a new item (should be opened in a popup)
    125109    if (!sc.hasPermission(Permission.CREATE, itemType))
    126110    {
     
    133117  else if ("UpdateItem".equals(cmd))
    134118  {
     119    // Update the properties on an item (will close the popup)
    135120    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
    136121    dc = sc.newDbControl();
     
    158143      reporter.setExtended(name, value);
    159144    }
    160 
    161145    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
    162146    if (reporter.getId() != 0)
     
    174158    cc.removeObject("item");
    175159  }
    176   else if ("Export".equals(cmd))
    177   {
     160  else if ("DeleteItem".equals(cmd))
     161  {
     162    // Delete a single item and then return to the list page
     163    dc = sc.newDbControl();
     164    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     165    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
     166    batcher.delete(cc.getId());
     167    batcher.close();
     168    dc.commit();
     169    redirect = listPage;
     170  }
     171  else if ("DeleteItems".equals(cmd))
     172  {
     173    // Delete all selected items on the list page
     174    dc = sc.newDbControl();
     175    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     176    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
     177    for (int reporterId : cc.getSelected())
     178    {
     179      batcher.delete(reporterId);
     180    }
     181    batcher.close();
     182    dc.commit();
     183    redirect = listPage;
     184  }
     185  else if ("ExportItems".equals(cmd))
     186  {
     187    // Run an export plugin in a list context
    178188    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    179189    final DataQuery<ReporterData> query = Reporter.getQuery();
    180190    cc.configureQuery(query, true);
    181191    cc.setQuery(query);
    182     forward = "../../common/export/configure.jsp";
    183   }
    184   else if ("Import".equals(cmd))
    185   {
     192    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+reporters";
     193  }
     194  else if ("ExportItem".equals(cmd))
     195  {
     196    // Run an export plugin in single-item context
     197    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     198    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+reporter";
     199  }
     200  else if ("ImportItems".equals(cmd))
     201  {
     202    // Run an import plugin in a list context
    186203    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    187204    final DataQuery<ReporterData> query = Reporter.getQuery();
     
    190207    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+reporters";
    191208  }
    192   else if ("RunPlugin".equals(cmd))
    193   {
     209  else if ("ImportItem".equals(cmd))
     210  {
     211    // Run an import plugin in single-item context
     212    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     213    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+reporter";
     214  }
     215  else if ("RunListPlugin".equals(cmd))
     216  {
     217    // Run another plugin in a list context
    194218    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    195219    final DataQuery<ReporterData> query = Reporter.getQuery();
    196220    cc.configureQuery(query, true);
    197221    cc.setQuery(query);
    198     redirect = "TODO";
     222    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Run+plugin";
     223  }
     224  else if ("RunPlugin".equals(cmd))
     225  {
     226    // Run another plugin in single-item context
     227    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     228    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Run+plugin";
    199229  }
    200230  else
  • trunk/www/views/reporters/list_reporters.jsp

    r1730 r1738  
    8383  cc.configureQuery(query, true);
    8484
    85   Map<Plugin.MainType, Integer> plugins = PluginDefinition.countPlugins(dc, guiContext);
     85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    8686  final ItemQuery<ReporterType> typeQuery = ReporterType.getQuery();
    8787  typeQuery.order(Orders.asc(Hql.property("name")));
     
    108108      location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id='+itemId;
    109109    }
     110    function itemOnClick(evt, itemId)
     111    {
     112      if (evt && (evt.altKey || evt.ctrlKey || evt.shiftKey))
     113      {
     114        editItem(itemId);
     115      }
     116      else
     117      {
     118        viewItem(itemId);
     119      }
     120    }
    110121    function deleteItems()
    111122    {
     
    145156      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
    146157    }
    147     function configureFilter()
    148     {
    149       Table.configureFilter('<%=ID%>', formId, '<%=itemType.name()%>');
    150     }
    151     function configureExport()
    152     {
    153       Table.configureExport(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
    154     }
    155     function configureImport()
    156     {
    157       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=Import', 'Import'+formId, 540, 460);
     158    function runPlugin(cmd)
     159    {
     160      Table.submitToPopup(formId, cmd, 540, 460);
    158161    }
    159162    function returnSelected()
     
    310313        <tbl:button
    311314          image="import.gif"
    312           onclick="configureImport()"
     315          onclick="runPlugin('ImportItems')"
    313316          title="Import&hellip;"
    314317          tooltip="Import data"
    315           visible="<%=plugins.containsKey(Plugin.MainType.IMPORT)%>"
     318          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
    316319        />
    317320        <tbl:button
    318321          image="export.gif"
    319           onclick="configureExport()"
     322          onclick="runPlugin('ExportItems')"
    320323          title="Export&hellip;"
    321           tooltip="Export to XML or a tab-separated file"
    322           visible="<%=plugins.containsKey(Plugin.MainType.EXPORT)%>"
     324          tooltip="Export data"
     325          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
    323326        />
    324327        <tbl:button
    325328          image="runplugin.gif"
    326           onclick="runPlugin()"
     329          onclick="runPlugin('RunListPlugin')"
    327330          title="Run plugin&hellip;"
    328331          tooltip="Run a plugin"
    329           visible="<%=plugins.containsKey(Plugin.MainType.OTHER)%>"
     332          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
    330333        />
    331334      </tbl:toolbar>
     
    406409                visible="<%=mode.hasIcons()%>"
    407410                >&nbsp;</tbl:header>
    408               <tbl:cell column="name"><a href="javascript:viewItem(<%=itemId%>)" title="Edit this reporter type"><%=name%></a></tbl:cell>
     411              <tbl:cell column="name"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" title="View this reporter (use CTRL, ALT or SHIFT to edit)"><%=name%></div></tbl:cell>
    409412              <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
    410413              <tbl:cell column="symbol"><%=HTML.encodeTags(item.getSymbol())%></tbl:cell>
  • trunk/www/views/reporters/view_reporter.jsp

    r1727 r1738  
    4242  import="net.sf.basedb.core.ItemResultIterator"
    4343  import="net.sf.basedb.core.PermissionDeniedException"
     44  import="net.sf.basedb.core.PluginDefinition"
     45  import="net.sf.basedb.core.plugin.GuiContext"
     46  import="net.sf.basedb.core.plugin.Plugin"
    4447  import="net.sf.basedb.core.query.Orders"
    4548  import="net.sf.basedb.core.query.Hql"
     
    4851  import="net.sf.basedb.clients.web.util.Values"
    4952  import="java.util.Date"
     53  import="java.util.Map"
    5054%>
    5155<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    5256<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
    5357<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
     58<%!
     59  private static final Item itemType = Item.REPORTER;
     60  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
     61%>
    5462<%
    55 final Item itemType = Item.REPORTER;
    5663final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
     64final String ID = sc.getId();
    5765final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    5866final int itemId = cc.getId();
    59 final String ID = sc.getId();
    6067final float scale = Base.getScale(sc);
    6168final DbControl dc = sc.newDbControl();
    6269try
    6370{
     71  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     72
    6473  String title = null;
    6574  ReporterData reporter = Reporter.getById(dc, itemId);
     
    94103      }
    95104    }
     105    function runPlugin(cmd)
     106    {
     107      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 540, 460);
     108    }
    96109    </script>
    97110  </base:head>
     
    118131        title="Delete&hellip;"
    119132        tooltip="<%=deletePermission ? "Delete this reporter" : "You do not have permission to delete this reporter"%>"
     133      />
     134      <tbl:button
     135        image="import.gif"
     136        onclick="runPlugin('ImportItem')"
     137        title="Import&hellip;"
     138        tooltip="Import data"
     139        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
     140      />
     141      <tbl:button
     142        image="export.gif"
     143        onclick="runPlugin('ExportItem')"
     144        title="Export&hellip;"
     145        tooltip="Export data"
     146        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
     147      />
     148      <tbl:button
     149        image="runplugin.gif"
     150        onclick="runPlugin('RunPlugin')"
     151        title="Run plugin&hellip;"
     152        tooltip="Run a plugin"
     153        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
    120154      />
    121155      </tbl:toolbar>
Note: See TracChangeset for help on using the changeset viewer.