Changeset 1021


Ignore:
Timestamp:
Apr 6, 2009, 9:59:18 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #189: Add toolbar extension examples

Location:
extensions/net.sf.basedb.examples/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.examples/trunk/META-INF/extensions.xml

    r1019 r1021  
    231231    </action-factory>
    232232  </extension>
     233  <extension
     234    id="toolbar.clickme"
     235    extends="net.sf.basedb.clients.web.toolbar.list.all"
     236    >
     237    <index>2</index>
     238    <about>
     239      <name>Click me!</name>
     240      <description>
     241        Click the button!
     242      </description>
     243    </about>
     244    <action-factory>
     245      <factory-class>
     246        net.sf.basedb.clients.web.extensions.toolbar.FixedButtonFactory
     247      </factory-class>
     248      <parameters>
     249        <title>Click me!</title>
     250        <tooltip>Come on! Do it!</tooltip>
     251        <icon>/images/info.gif</icon>
     252        <onClick>alert('Ouch!')</onClick>
     253      </parameters>
     254    </action-factory>
     255  </extension>
    233256
    234257</extensions>
  • extensions/net.sf.basedb.examples/trunk/resources/item_info.jsp

    r1019 r1021  
    99  import="net.sf.basedb.core.Removable"
    1010  import="net.sf.basedb.core.Ownable"
     11  import="net.sf.basedb.core.Reporter"
     12  import="net.sf.basedb.core.data.ReporterData"
    1113  import="net.sf.basedb.util.Values"
    1214  import="net.sf.basedb.util.formatter.Formatter"
     
    2527try
    2628{
    27   BasicItem item = itemType.getById(dc, itemId);
    28   String name = item instanceof Nameable ?
    29     ((Nameable)item).getName() : item.toString();
    30   Date registered = item instanceof Registered ?
    31     ((Registered)item).getEntryDate() : null;
    32   boolean isShared = item instanceof Shareable ?
    33     ((Shareable)item).isShared() : false;
    34   boolean isRemoved = item instanceof Removable ?
    35     ((Removable)item).isRemoved() : false;
    36   boolean isOwnedByYou = item instanceof Ownable ?
    37     ((Ownable)item).isOwner() : false;
     29  String name = null;
     30  Date registered = null;
     31  boolean isShared = false;
     32  boolean isRemoved = false;
     33  boolean isOwnedByYou = false;
     34  if (itemType.getItemClass() != null)
     35  {
     36    BasicItem item = itemType.getById(dc, itemId);
     37    name = item instanceof Nameable ? ((Nameable)item).getName() : item.toString();
     38    if (item instanceof Registered) registered = ((Registered)item).getEntryDate();
     39    if (item instanceof Shareable) isShared = ((Shareable)item).isShared();
     40    if (item instanceof Removable) isRemoved = ((Removable)item).isRemoved();
     41    if (item instanceof Ownable) isOwnedByYou = ((Ownable)item).isOwner();
     42  }
     43  else if (itemType == Item.REPORTER)
     44  {
     45    ReporterData reporter = Reporter.getById(dc, itemId);
     46    name = reporter.getName();
     47    registered = reporter.getEntryDate();
     48  }
    3849
    3950  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     
    5667      <tr>
    5768        <td class="prompt">Name</td>
    58         <td><%=HTML.niceFormat(name)%></td>
     69        <td><%=name == null ? "<i>unknown</i>" : HTML.niceFormat(name)%></td>
    5970      </tr>
    6071      <tr>
  • extensions/net.sf.basedb.examples/trunk/src/net/sf/basedb/examples/extensions/toolbar/InfoButtonFactory.java

    r1019 r1021  
    77import net.sf.basedb.core.BasicItem;
    88import net.sf.basedb.core.Nameable;
     9import net.sf.basedb.core.data.BasicData;
     10import net.sf.basedb.core.data.NameableData;
     11import net.sf.basedb.core.plugin.GuiContext;
    912import net.sf.basedb.util.extensions.InvokationContext;
    1013
     
    3538    Object item = context.getClientContext().getCurrentItem();
    3639    JspContext jspContext = (JspContext)context.getClientContext();
     40    GuiContext guiContext = jspContext.getGuiContext();
    3741    String ID = null;
    38     String TYPE = jspContext.getGuiContext().getItem().name();
     42    String TYPE = guiContext == null ? null : guiContext.getItem().name();
    3943    String name = null;
    4044    if (item instanceof BasicItem)
     
    4650        ((Nameable)item).getName() : item.toString();
    4751       
     52    }
     53    else if (item instanceof BasicData)
     54    {
     55      BasicData bData = (BasicData)item;
     56      ID = Integer.toString(bData.getId());
     57      name = (item instanceof NameableData) ?
     58          ((NameableData)item).getName() : item.toString();
    4859    }
    4960    String onClick = getOnClick();
Note: See TracChangeset for help on using the changeset viewer.