Changeset 4872


Ignore:
Timestamp:
Apr 2, 2009, 9:22:17 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #1271: Add extension points to all toolbars

Added GuiContext? information to extension points.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ExtensionsControl.java

    r4870 r4872  
    4141import net.sf.basedb.core.PermissionDeniedException;
    4242import net.sf.basedb.core.SessionControl;
     43import net.sf.basedb.core.plugin.GuiContext;
    4344import net.sf.basedb.util.extensions.Extension;
    4445import net.sf.basedb.util.extensions.ExtensionPoint;
     
    273274  public static JspContext createContext(SessionControl sc, PageContext pageContext)
    274275  {
    275     return new JspContext(extensionsDir, sc, null, pageContext);
     276    return new JspContext(extensionsDir, sc, null, pageContext, null, null);
    276277  }
    277278 
     
    283284  public static JspContext createContext(DbControl dc, PageContext pageContext)
    284285  {
    285     return new JspContext(extensionsDir, dc.getSessionControl(), dc, pageContext);
     286    return new JspContext(extensionsDir, dc.getSessionControl(), dc, pageContext,
     287      null, null);
     288  }
     289 
     290  /**
     291    Create a new {@link JspContext} object with an active DbControl
     292    and a current {@link GuiContext} and item.
     293    @param dc An open DbControl
     294    @param pageContext Page context for the executing JSP page
     295    @since 2.12
     296  */
     297  public static JspContext createContext(DbControl dc, PageContext pageContext,
     298    GuiContext guiContext, Object currentItem)
     299  {
     300    return new JspContext(extensionsDir, dc.getSessionControl(), dc,
     301      pageContext, guiContext, currentItem);
    286302  }
    287303
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/JspContext.java

    r4512 r4872  
    3131import net.sf.basedb.core.DbControl;
    3232import net.sf.basedb.core.SessionControl;
     33import net.sf.basedb.core.plugin.GuiContext;
    3334import net.sf.basedb.util.extensions.ActionFactory;
    3435import net.sf.basedb.util.extensions.ClientContext;
     
    7374  private final ExtensionsDirectory directory;
    7475  private final PageContext pageContext;
     76  private final GuiContext guiContext;
    7577 
    7678  private Set<String> scripts;
     
    7880 
    7981  JspContext(ExtensionsDirectory directory, SessionControl sc, DbControl dc,
    80     PageContext pageContext)
    81   {
    82     super(sc, dc, null);
     82    PageContext pageContext, GuiContext guiContext, Object item)
     83  {
     84    super(sc, dc, item);
    8385    this.directory = directory;
    8486    this.pageContext = pageContext;
     87    this.guiContext = guiContext;
    8588  }
    8689
     
    112115 
    113116  /**
     117    Get the current {@link GuiContext}.
     118    @return A GuiContext object or null if it is not applicable
     119      to the extension point
     120    @since 2.12
     121  */
     122  public GuiContext getGuiContext()
     123  {
     124    return guiContext;
     125  }
     126 
     127  /**
    114128    Get the URL to the web application root as a string. The URL
    115129    only includes the path information, not the server name or protocol.
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/PermissionButtonFactory.java

    r4512 r4872  
    337337    boolean hasPermission = false;
    338338    Object currentItem = cc.getCurrentItem();
    339     System.out.println("currentItem: " + currentItem);
    340339    if (currentItem instanceof AccessControlled)
    341340    {
     
    346345      }
    347346    }
    348     else if (itemToCheck != null)
     347    else if (accepted != null)
    349348    {
    350349      hasPermission = cc.getSessionControl().hasPermission(permission, itemToCheck);
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/ToolbarUtil.java

    r4871 r4872  
    107107   
    108108    @param jspContext The current jsp context
    109     @param guiContext The current gui context
    110109    @return An invoker instance
    111110  */
    112   public static ExtensionsInvoker useExtensions(JspContext jspContext, GuiContext guiContext)
     111  public static ExtensionsInvoker useExtensions(JspContext jspContext)
    113112  {
    114113    String[] ep = new String[5]; // 5 is the maximum number of extension points
    115114    int index = 0;
     115    GuiContext guiContext = jspContext.getGuiContext();
    116116    int type = guiContext.getType() == GuiContext.Type.LIST ? LIST : ITEM;
    117117    Item itemType = guiContext.getItem();
  • trunk/www/views/experiments/bioassays/list_bioassays.jsp

    r4871 r4872  
    132132  }
    133133  int numListed = 0;
    134   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    135   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     134  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext,
     135      guiContext, bioAssaySet);
     136  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    136137  %>
    137138  <base:page title="<%=title%>" type="<%=mode.getPageType()%>">
  • trunk/www/views/experiments/bioassays/view_bioassay.jsp

    r4871 r4872  
    9090  final boolean writePermission = bioAssay.hasPermission(Permission.WRITE);
    9191  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    92   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    93   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     92  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioAssay);
     93  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    9494  %>
    9595  <base:page title="<%=title%>">
  • trunk/www/views/experiments/bioassaysets/analysis_tree.jsp

    r4871 r4872  
    280280  int numListed = 0;
    281281 
    282   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
     282  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext,
     283    guiContext, root == null ? experiment : root);
    283284  ExtensionsInvoker toolsInvoker = ExtensionsControl.useExtensions(jspContext,
    284285      "net.sf.basedb.clients.web.bioassayset.list.tools");
    285   ExtensionsInvoker toolbarInvoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     286  ExtensionsInvoker toolbarInvoker = ToolbarUtil.useExtensions(jspContext);
    286287  %>
    287288  <base:page type="include">
  • trunk/www/views/experiments/bioassaysets/view_bioassayset.jsp

    r4871 r4872  
    142142  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    143143  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    144   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    145   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     144  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioAssaySet);
     145  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    146146  %>
    147147  <base:page title="<%=title%>">
  • trunk/www/views/experiments/extravalues/view_extravalue.jsp

    r4871 r4872  
    147147  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    148148  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    149   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    150   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     149  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, extraValue);
     150  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    151151  %>
    152152  <base:page title="<%=title%>">
  • trunk/www/views/experiments/list_experiments.jsp

    r4870 r4872  
    9999  int numListed = 0;
    100100  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    101   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    102   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     101  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
     102  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    103103  %>
    104104  <base:page title="<%=title==null ? "Experiments" : title%>" type="<%=mode.getPageType()%>">
  • trunk/www/views/experiments/spotdata/list_spotdata.jsp

    r4871 r4872  
    124124
    125125  int numListed = 0;
    126   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    127   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     126  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext,
     127    guiContext, bioAssay == null ? bioAssaySet : bioAssay);
     128  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    128129  %>
    129130  <base:page title="<%=title%>">
  • trunk/www/views/experiments/transformations/view_transformation.jsp

    r4871 r4872  
    138138  final boolean writePermission = transformation.hasPermission(Permission.WRITE);
    139139  final boolean deletePermission = transformation.hasPermission(Permission.DELETE);
    140   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    141   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     140  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, transformation);
     141  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    142142  %>
    143143  <base:page title="<%=title%>">
  • trunk/www/views/experiments/view_experiment.jsp

    r4871 r4872  
    111111    new HashMap<AnnotationType, Set<Object>>();
    112112  Map<AnnotationType, Integer> factorValuesCount = new HashMap<AnnotationType, Integer>();
    113   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    114   ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext, guiContext);
     113  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, experiment);
     114  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    115115  %>
    116116  <base:page title="<%=title%>">
Note: See TracChangeset for help on using the changeset viewer.