Changeset 4433


Ignore:
Timestamp:
Mar 7, 2013, 3:35:37 PM (10 years ago)
Author:
Fredrik Levander
Message:

Refs #800. Added client class for removing biomaterials from file.

Location:
trunk/client/servlet/src/org/proteios/action/file
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/file/ViewActiveFile.java

    r4160 r4433  
    2525    Foundation, Inc., 59 Temple Place - Suite 330,
    2626    Boston, MA  02111-1307, USA.
    27 */
     27 */
    2828package org.proteios.action.file;
    2929
     
    4545import org.proteios.core.ItemFactory;
    4646import org.proteios.core.ItemQuery;
     47import org.proteios.core.QueryFactory;
     48import org.proteios.core.query.Hql;
     49import org.proteios.core.query.Restrictions;
    4750import org.proteios.gui.ColumnContainer;
    4851import org.proteios.gui.Image;
     
    5457import org.proteios.gui.Toolbar;
    5558import org.proteios.gui.form.AnnotationsForm;
     59import org.proteios.gui.form.Checkbox;
    5660import org.proteios.gui.form.Form;
    5761import org.proteios.gui.form.FormFactory;
     
    7579
    7680/**
    77     * Displays File properties and forms aswell as file annotations.
    78     *
    79     * @author gregory
    80 */
     81 * Displays File properties and forms aswell as file annotations.
     82 *
     83 * @author gregory
     84 */
    8185public class ViewActiveFile
    82 extends ProteiosAction<ViewActiveFile>
     86    extends ProteiosAction<ViewActiveFile>
    8387{
    84     /**
    85         * Session id for active file
    86     */
    87     public static final VInteger VFILEID = new VInteger("active.file.id", 1,
    88     true);
    89   private final long MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM = 2*1024*1024;
    90   private final long MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING = 10*1024*1024;
    91    
    92     @SuppressWarnings("unchecked")
    93     @Override
    94     public void runMe()
    95     throws ActionException, InvalidParameterValue
    96     {
    97         Integer fileId;
    98         DbControl dc;
    99         ItemFactory factory;
    100         File file;
    101         Form form, annotationForm;
    102         Toolbar tb;
    103         Annotator anna;
    104         ActionLink show, download, listPlugins, moveFile, deleteFile, saveFile, viewSample;
    105         PopupLink confirm = null;
    106         boolean fileTooLargeToShow = false;
    107         ItemQuery<Annotation> annotations;
    108         Iterator<BioMaterial> bioit;
    109         Table annotationTable, bioTable;
    110         String mimeType;
    111         BioMaterial bm;
    112         Row row;
    113         Image img;
    114         RowLayout layout;
    115         Title title;
    116         ColumnContainer cc;
    117         RowContainer rc, rc1;
    118         TabSet tabs;
    119         Tab propertiesTab, annotationsTab;
    120        
    121         verifySessionAttributes(VFILEID);
    122        
    123         fileId = getSessionAttribute(VFILEID);
    124         dc = newDbControl();
    125         factory = getItemFactory(dc);
    126         file = factory.getById(File.class, fileId);
    127         form = getFormFactory().getForm(File.class, file);
    128         tb = new Toolbar();
    129         anna = new Annotator(factory);
    130         rc = new RowContainer();
    131         rc1 = new RowContainer();
    132         cc = new ColumnContainer();
    133         title = new Title("File");
    134         tabs = new TabSet();
    135         propertiesTab = new Tab("Properties", "propertiesTab");
    136         annotationsTab = new Tab("Annotations", "annotationsTab");
    137         title.setSubtitle(file.getName());
    138        
    139         annotationTable = null;
    140         annotationForm = null;
    141        
    142         if (file != null)
    143         {
    144             annotationForm = createAnnotationForm(factory, file);
    145             annotations = anna.getAnnotationSet(file).getAnnotations();
    146             annotationTable = createAnnotationsTable(getTableFactory(),
    147             annotations);
    148            
    149             show = getActionFactory().getActionLink(ShowFile.class, "View");
    150             //tb.add(show);
    151             show.addParameter(FormFactory.VID, file.getId());
    152             show.addParameter(ShowFile.VDOWNLOAD, false);
    153             // If file is not viewable, show button should be disabled
    154             mimeType = file.getMimeType();
    155             if (mimeType == null)
    156             {
    157                 show.disable();
    158             }
    159             else if (!mimeType.startsWith("text")
    160                 && !mimeType.equals("application/xml")
    161                 && !mimeType.equals("application/xml-dtd"))
    162             {
    163                 show.disable();
    164             }
    165             else if (file.getSizeInBytes() > MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM)
    166             {
    167               if (file.getSize() <= MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING)
    168               {
    169                 // Display confirmation dialog before showing file in browser
    170                 confirm = new PopupLink();
    171                 confirm.setLabel("View");
    172                 TitledWindow window = createPermissionForm(false, file.getId(), file.getSizeInBytes());
    173                 confirm.setContent(window);
    174               }
    175               else
    176               {
    177                 // File too large to show in browser window
    178                 fileTooLargeToShow = true;
    179                 show.disable();
    180               }
    181             }
    182             // Add either confirmation PopupLink or show actionLink to "View" button
    183             if (confirm != null)
    184             {
    185               tb.add(confirm);
    186             }
    187             else
    188             {
    189               tb.add(show);
    190             }
    191             //
    192             download = getActionFactory().getActionLink(ShowFile.class,
    193             "Download");
    194             tb.add(download);
    195             download.addParameter(FormFactory.VID, file.getId());
    196             download.addParameter(ShowFile.VDOWNLOAD, true);
    197             //
    198             listPlugins = getActionFactory().getActionLink(
    199             ListFilePlugins.class, "RunImportPlugin");
    200             tb.add(listPlugins);
    201             //
    202             moveFile = getActionFactory()
    203             .getActionLink(MoveFile1.class, "Move");
    204             tb.add(moveFile);
    205             //
    206             deleteFile = getActionFactory().getActionLink(
    207             DeleteActiveItem.class, "Delete");
    208             tb.add(deleteFile);
    209             deleteFile.addParameter(FormFactory.VID, file.getId());
    210             deleteFile.addParameter(TableFactory.VCLASSNAME, File.class
    211             .getName());
    212             deleteFile.addParameter(ForwardField.VPARAM,
    213             ViewActiveDirectory.class.getName());
    214             //
    215             saveFile = getActionFactory().getActionLink(
    216             SaveFileProperties.class, "Save");
    217             tb.add(saveFile);
    218         }
    219         else
    220         {
    221             tb.add(getActionFactory().getActionLink(SaveFile.class, "Save"));
    222         }
    223         form.setToolbar(tb);
    224         // Add FileType extensions button
    225         form = addFileTypeExtensionsButton(form, file);
    226         /***********************************************************************
    227             * BioMaterials table - shown if file has link to BioMaterials
    228         */
    229         bioTable = null;
    230         bioit = file.getBioMaterials().iterator();
    231         if (bioit.hasNext())
    232         {
    233             bioTable = new Table("biomaterials");
    234             bioTable.setTitle("AnnotatedBiomaterials");
    235             bioTable.add(new Column<String>("Name"));
    236             bioTable.add(new Column<String>("ExternalId"));
    237             while (bioit.hasNext())
    238             {
    239                 bm = bioit.next();
    240                 row = new Row(bm.getId());
    241                 viewSample = getActionFactory().getActionLink(
    242                 ViewBioMaterial.class, "View");
    243                 viewSample.addParameter(FormFactory.VID, bm.getId());
    244                 Cell name = new Cell<String>(bm.getName());
    245                 name.setActionLink(viewSample);
    246                 row.addCell(name);
    247                 row.addCell(new Cell<String>(bm.getExternalId()));
    248                 bioTable.addRow(row);
    249             }
    250         }
    251         /***********************************************************************
    252             * If the file is an image show it
    253         */
    254         // TODO gregory decide how to handle large images, scale and cache
    255         // perhaps
    256         img = null;
    257         if (file.getMimeType() != null && file.getMimeType()
    258         .startsWith("image"))
    259         {
    260             img = new Image();
    261             show = getActionFactory().getActionLink(ShowFile.class, "Show");
    262             show.addParameter(FormFactory.VID, fileId);
    263             img.setViewAction(show);
    264         }
    265        
    266         layout = getLayoutFactory().getRowLayout();
    267         layout.add(title);
    268         layout.add(tabs);
    269         tabs.add(propertiesTab);
    270         tabs.add(annotationsTab);
    271         propertiesTab.setGuiElement(rc);
    272         if (fileTooLargeToShow)
    273         {
    274           // Add comment box explaining that the file is too large to show in browser
    275         double maxFileSizeInMegaBytesForShowing = MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING/(1024.0*1024.0);
    276         double fileSizeInMegaBytes = file.getSizeInBytes()/(1024.0*1024.0);
    277         int numberOfDecimals = 1;
    278         NumberFormat fixedNumberOfDecimals = new DecimalFormat("#########.###");
    279         fixedNumberOfDecimals.setMinimumFractionDigits(numberOfDecimals);
    280         fixedNumberOfDecimals.setMaximumFractionDigits(numberOfDecimals);
    281         // Comment area
    282         TitledWindow commentArea = new TitledWindow();
    283         String comment = "The file is larger than " + fixedNumberOfDecimals.format(maxFileSizeInMegaBytesForShowing) + " Mb (" + fixedNumberOfDecimals.format(fileSizeInMegaBytes) + " Mb),";
    284         comment += " and therefore considered too large to open in browser.";
    285         commentArea.setContent(comment);
    286         commentArea.setTitle("Note");
    287         rc.add(commentArea);
    288         }
    289         rc.add(form);
    290         annotationsTab.setGuiElement(cc);
    291         cc.add(rc1);
    292         rc1.add(annotationForm);
    293         if (bioTable != null)
    294         {
    295             rc1.add(bioTable);
    296         }
    297         cc.add(annotationTable);
    298         if (img != null)
    299         {
    300             layout.add(img);
    301         }
    302         setLayout(layout);
    303     }
    304    
    305     private Form createAnnotationForm(ItemFactory factory, File file)
    306     {
    307         // Define
    308         Form form;
    309         Toolbar toolbar;
    310         ActionLink saveBtn;
    311        
    312         // Create
    313         toolbar = new Toolbar();
    314         form = new AnnotationsForm(factory.getDc(), new Annotator(factory), file,
    315         getActionFactory().getId(ViewActiveFile.class));
    316         saveBtn = getActionFactory().getActionLink(AddAnnotation.class, "Save");
    317        
    318         // Use
    319         toolbar.add(saveBtn);
    320         form.setToolbar(toolbar);
    321         return form;
    322     }
    323    
    324     private Table createAnnotationsTable(TableFactory tableFactory,
    325     ItemQuery<Annotation> annotationQuery)
    326     {
    327         // Define
    328         Table table;
    329        
    330         // Use
    331         tableFactory.reset();
    332         tableFactory.setItemClass(Annotation.class);
    333         tableFactory.setQuery(annotationQuery);
    334         ActionLink actionLink = getActionFactory().getActionLink(ViewAnnotation.class, "ViewAnnotation");
    335         actionLink.addParameter(ForwardField.VPARAM, this.getClass().getName());
    336         tableFactory.setColumnAction("Value", actionLink);
    337         table = tableFactory.build();
    338         Toolbar toolbar = new Toolbar();
    339         toolbar.add(getActionFactory().getActionLink(
    340             DeleteAnnotations.class, "Delete"));
    341         table.setToolbar(toolbar);
    342         return table;
    343     }
     88  /**
     89   * Session id for active file
     90   */
     91  public static final VInteger VFILEID = new VInteger("active.file.id", 1,
     92    true);
     93  private final long MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM = 2 * 1024 * 1024;
     94  private final long MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING = 10 * 1024 * 1024;
     95
     96
     97  @SuppressWarnings("unchecked")
     98  @Override
     99  public void runMe()
     100      throws ActionException, InvalidParameterValue
     101  {
     102    Integer fileId;
     103    DbControl dc;
     104    ItemFactory factory;
     105    File file;
     106    Form form, annotationForm;
     107    Toolbar tb;
     108    Annotator anna;
     109    ActionLink show, download, listPlugins, moveFile, deleteFile, saveFile;
     110    PopupLink confirm = null;
     111    boolean fileTooLargeToShow = false;
     112    ItemQuery<Annotation> annotations;
     113    Table annotationTable, bioTable;
     114    String mimeType;
     115    Row row;
     116    Image img;
     117    RowLayout layout;
     118    Title title;
     119    ColumnContainer cc;
     120    RowContainer rc, rc1;
     121    TabSet tabs;
     122    Tab propertiesTab, annotationsTab;
     123
     124    verifySessionAttributes(VFILEID);
     125
     126    fileId = getSessionAttribute(VFILEID);
     127    dc = newDbControl();
     128    factory = getItemFactory(dc);
     129    file = factory.getById(File.class, fileId);
     130    form = getFormFactory().getForm(File.class, file);
     131    tb = new Toolbar();
     132    anna = new Annotator(factory);
     133    rc = new RowContainer();
     134    rc1 = new RowContainer();
     135    cc = new ColumnContainer();
     136    title = new Title("File");
     137    tabs = new TabSet();
     138    propertiesTab = new Tab("Properties", "propertiesTab");
     139    annotationsTab = new Tab("Annotations", "annotationsTab");
     140    title.setSubtitle(file.getName());
     141
     142    annotationTable = null;
     143    annotationForm = null;
     144
     145    if (file != null)
     146    {
     147      annotationForm = createAnnotationForm(factory, file);
     148      annotations = anna.getAnnotationSet(file).getAnnotations();
     149      annotationTable = createAnnotationsTable(getTableFactory(),
     150        annotations);
     151
     152      show = getActionFactory().getActionLink(ShowFile.class, "View");
     153      // tb.add(show);
     154      show.addParameter(FormFactory.VID, file.getId());
     155      show.addParameter(ShowFile.VDOWNLOAD, false);
     156      // If file is not viewable, show button should be disabled
     157      mimeType = file.getMimeType();
     158      if (mimeType == null)
     159      {
     160        show.disable();
     161      }
     162      else if (!mimeType.startsWith("text") && !mimeType
     163        .equals("application/xml") && !mimeType
     164        .equals("application/xml-dtd"))
     165      {
     166        show.disable();
     167      }
     168      else if (file.getSizeInBytes() > MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM)
     169      {
     170        if (file.getSize() <= MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING)
     171        {
     172          // Display confirmation dialog before showing file in
     173          // browser
     174          confirm = new PopupLink();
     175          confirm.setLabel("View");
     176          TitledWindow window = createPermissionForm(false,
     177            file.getId(), file.getSizeInBytes());
     178          confirm.setContent(window);
     179        }
     180        else
     181        {
     182          // File too large to show in browser window
     183          fileTooLargeToShow = true;
     184          show.disable();
     185        }
     186      }
     187      // Add either confirmation PopupLink or show actionLink to "View"
     188      // button
     189      if (confirm != null)
     190      {
     191        tb.add(confirm);
     192      }
     193      else
     194      {
     195        tb.add(show);
     196      }
     197      //
     198      download = getActionFactory().getActionLink(ShowFile.class,
     199        "Download");
     200      tb.add(download);
     201      download.addParameter(FormFactory.VID, file.getId());
     202      download.addParameter(ShowFile.VDOWNLOAD, true);
     203      //
     204      listPlugins = getActionFactory().getActionLink(
     205        ListFilePlugins.class, "RunImportPlugin");
     206      tb.add(listPlugins);
     207      //
     208      moveFile = getActionFactory()
     209        .getActionLink(MoveFile1.class, "Move");
     210      tb.add(moveFile);
     211      //
     212      deleteFile = getActionFactory().getActionLink(
     213        DeleteActiveItem.class, "Delete");
     214      tb.add(deleteFile);
     215      deleteFile.addParameter(FormFactory.VID, file.getId());
     216      deleteFile.addParameter(TableFactory.VCLASSNAME,
     217        File.class.getName());
     218      deleteFile.addParameter(ForwardField.VPARAM,
     219        ViewActiveDirectory.class.getName());
     220      //
     221      saveFile = getActionFactory().getActionLink(
     222        SaveFileProperties.class, "Save");
     223      tb.add(saveFile);
     224    }
     225    else
     226    {
     227      tb.add(getActionFactory().getActionLink(SaveFile.class, "Save"));
     228    }
     229    form.setToolbar(tb);
     230    // Add FileType extensions button
     231    form = addFileTypeExtensionsButton(form, file);
     232    /***********************************************************************
     233     * BioMaterials table - shown if file has link to BioMaterials
     234     */
     235    bioTable = createBioMaterialsTable(file);
     236    /***********************************************************************
     237     * If the file is an image show it
     238     */
     239    // TODO gregory decide how to handle large images, scale and cache
     240    // perhaps
     241    img = null;
     242    if (file.getMimeType() != null && file.getMimeType()
     243      .startsWith("image"))
     244    {
     245      img = new Image();
     246      show = getActionFactory().getActionLink(ShowFile.class, "Show");
     247      show.addParameter(FormFactory.VID, fileId);
     248      img.setViewAction(show);
     249    }
     250
     251    layout = getLayoutFactory().getRowLayout();
     252    layout.add(title);
     253    layout.add(tabs);
     254    tabs.add(propertiesTab);
     255    tabs.add(annotationsTab);
     256    propertiesTab.setGuiElement(rc);
     257    if (fileTooLargeToShow)
     258    {
     259      // Add comment box explaining that the file is too large to show in
     260      // browser
     261      double maxFileSizeInMegaBytesForShowing = MAX_FILE_SIZE_IN_BYTES_FOR_SHOWING / (1024.0 * 1024.0);
     262      double fileSizeInMegaBytes = file.getSizeInBytes() / (1024.0 * 1024.0);
     263      int numberOfDecimals = 1;
     264      NumberFormat fixedNumberOfDecimals = new DecimalFormat(
     265        "#########.###");
     266      fixedNumberOfDecimals.setMinimumFractionDigits(numberOfDecimals);
     267      fixedNumberOfDecimals.setMaximumFractionDigits(numberOfDecimals);
     268      // Comment area
     269      TitledWindow commentArea = new TitledWindow();
     270      String comment = "The file is larger than " + fixedNumberOfDecimals
     271        .format(maxFileSizeInMegaBytesForShowing) + " Mb (" + fixedNumberOfDecimals
     272        .format(fileSizeInMegaBytes) + " Mb),";
     273      comment += " and therefore considered too large to open in browser.";
     274      commentArea.setContent(comment);
     275      commentArea.setTitle("Note");
     276      rc.add(commentArea);
     277    }
     278    rc.add(form);
     279    annotationsTab.setGuiElement(cc);
     280    cc.add(rc1);
     281    rc1.add(annotationForm);
     282    if (bioTable != null)
     283    {
     284      rc1.add(bioTable);
     285    }
     286    cc.add(annotationTable);
     287    if (img != null)
     288    {
     289      layout.add(img);
     290    }
     291    setLayout(layout);
     292  }
     293
     294
     295  private Form createAnnotationForm(ItemFactory factory, File file)
     296  {
     297    // Define
     298    Form form;
     299    Toolbar toolbar;
     300    ActionLink saveBtn;
     301
     302    // Create
     303    toolbar = new Toolbar();
     304    form = new AnnotationsForm(factory.getDc(), new Annotator(factory),
     305      file, getActionFactory().getId(ViewActiveFile.class));
     306    saveBtn = getActionFactory().getActionLink(AddAnnotation.class, "Save");
     307
     308    // Use
     309    toolbar.add(saveBtn);
     310    form.setToolbar(toolbar);
     311    return form;
     312  }
     313
     314
     315  private Table createBioMaterialsTable(File file)
     316  {
     317    Table bioTable = null;
     318    Iterator<BioMaterial> bioit = file.getBioMaterials().iterator();
     319    if (bioit.hasNext())
     320    {
     321      bioTable = new Table("biomaterials");
     322      bioTable.setTitle("AnnotatedBiomaterials");
     323      bioTable.setUseCheckBox(true);
     324      bioTable.add(new Column<Checkbox<VInteger>>(""));
     325      bioTable.add(new Column<String>("Name"));
     326      bioTable.add(new Column<String>("ExternalId"));
     327      while (bioit.hasNext())
     328      {
     329        BioMaterial<?> bm = bioit.next();
     330        Row row = new Row(bm.getId());
     331        ActionLink viewSample = getActionFactory().getActionLink(
     332          ViewBioMaterial.class, "View");
     333        viewSample.addParameter(FormFactory.VID, bm.getId());
     334        Checkbox<VInteger> cb = new Checkbox<VInteger>(RemoveBioMaterialsFromFile.VBIOMATERIALID);
     335        cb.setValue(bm.getId());
     336        Cell<Checkbox<VInteger>> chk = new Cell<Checkbox<VInteger>>(cb);
     337        row.addCell(chk);
     338        Cell<String> name = new Cell<String>(bm.getName());
     339        name.setActionLink(viewSample);
     340        row.addCell(name);
     341        row.addCell(new Cell<String>(bm.getExternalId()));
     342        bioTable.addRow(row);
     343      }
     344      Toolbar toolbar = new Toolbar();
     345      ActionLink al = getActionFactory().getActionLink(
     346        RemoveBioMaterialsFromFile.class, "Remove");
     347      al.addParameter(RemoveBioMaterialsFromFile.VFILEID, file.getId());
     348      toolbar.add(al);
     349      bioTable.setToolbar(toolbar);
     350
     351    }
     352    return bioTable;
     353  }
     354
     355
     356  private Table createAnnotationsTable(TableFactory tableFactory,
     357      ItemQuery<Annotation> annotationQuery)
     358  {
     359    // Define
     360    Table table;
     361
     362    // Use
     363    tableFactory.reset();
     364    tableFactory.setItemClass(Annotation.class);
     365    tableFactory.setQuery(annotationQuery);
     366    ActionLink actionLink = getActionFactory().getActionLink(
     367      ViewAnnotation.class, "ViewAnnotation");
     368    actionLink.addParameter(ForwardField.VPARAM, this.getClass().getName());
     369    tableFactory.setColumnAction("Value", actionLink);
     370    table = tableFactory.build();
     371    Toolbar toolbar = new Toolbar();
     372    toolbar.add(getActionFactory().getActionLink(DeleteAnnotations.class,
     373      "Delete"));
     374    table.setToolbar(toolbar);
     375    return table;
     376  }
    344377
    345378
    346379  private Form addFileTypeExtensionsButton(Form form, File file)
    347380  {
    348         String fileTypeStr = null;
    349         if (file.getFileType() != null)
    350         {
    351             fileTypeStr = file.getFileType().getSystemId();
    352         }
    353         log.debug("fileTypeStr = " + fileTypeStr);
     381    String fileTypeStr = null;
     382    if (file.getFileType() != null)
     383    {
     384      fileTypeStr = file.getFileType().getSystemId();
     385    }
     386    log.debug("fileTypeStr = " + fileTypeStr);
    354387    Table fileTypeExtTable = new Table("fileTypeExtensionsTable");
    355388    List<Column> fileTypeExtHeader = new ArrayList<Column>(2);
     
    359392    fileTypeExtTable.setHeader(fileTypeExtHeader);
    360393    // Get actions with appropriate FileType context
    361     List<FileTypeContext> tmpContexts = getRegistry()
    362       .getContexts(FileTypeContext.class);
     394    List<FileTypeContext> tmpContexts = getRegistry().getContexts(
     395      FileTypeContext.class);
    363396    List<FileTypeContext> contexts = new ArrayList<FileTypeContext>();
    364397    if (!tmpContexts.isEmpty() && fileTypeStr != null)
     
    366399      for (FileTypeContext context : tmpContexts)
    367400      {
    368         if (context.getFileTypeString() != null && context.getFileTypeString().equals(fileTypeStr))
     401        if (context.getFileTypeString() != null && context
     402          .getFileTypeString().equals(fileTypeStr))
    369403        {
    370404          contexts.add(context);
     
    420454        //
    421455        /*
    422         AbstractLink link = context.getActionLink(getActionFactory());
    423         // Link the extensions so that when one is selected the
    424         // file table/form is posted to the given action.
    425         CrossLink postTableLink = new CrossLink(form, link);
    426         nameCell.setActionLink(postTableLink);
    427         */
    428         ActionLink actionLink = context.getActionLink(getActionFactory());
     456         * AbstractLink link =
     457         * context.getActionLink(getActionFactory()); // Link the
     458         * extensions so that when one is selected the // file
     459         * table/form is posted to the given action. CrossLink
     460         * postTableLink = new CrossLink(form, link);
     461         * nameCell.setActionLink(postTableLink);
     462         */
     463        ActionLink actionLink = context
     464          .getActionLink(getActionFactory());
    429465        actionLink.addParameter(FormFactory.VID, file.getId());
    430466        nameCell.setActionLink(actionLink);
     
    436472    // Create pop-up link for FileType extensions
    437473    PopupLink fileTypeExtensions = new PopupLink();
    438     TitledWindow popup = new TitledWindow(
    439       "ExtensionsForFileTypes");
     474    TitledWindow popup = new TitledWindow("ExtensionsForFileTypes");
    440475    popup.setStatic(false);
    441476    popup.setContent(fileTypeExtTable);
     
    443478    fileTypeExtensions.setContent(popup);
    444479    // Disable pop-up link if no extensions found
    445     if (fileTypeExtTable.getRows() == null || fileTypeExtTable.getRows().size() == 0)
     480    if (fileTypeExtTable.getRows() == null || fileTypeExtTable.getRows()
     481      .size() == 0)
    446482    {
    447483      fileTypeExtensions.disable();
     
    456492
    457493
    458   public TitledWindow createPermissionForm(Boolean recursive, int fileId, long fileSizeInBytes)
     494  public TitledWindow createPermissionForm(Boolean recursive, int fileId,
     495      long fileSizeInBytes)
    459496  {
    460497    // Define
     
    468505    yes = new ActionLink("Yes", ShowFile.class.getName());
    469506    yes.addParameter(FormFactory.VID, fileId);
    470     yes.addParameter(ShowFile.VDOWNLOAD, false);     
    471     double maxFileSizeInMegaBytesWithoutConfirm = MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM/(1024.0*1024.0);
    472     double fileSizeInMegaBytes = fileSizeInBytes/(1024.0*1024.0);
     507    yes.addParameter(ShowFile.VDOWNLOAD, false);
     508    double maxFileSizeInMegaBytesWithoutConfirm = MAX_FILE_SIZE_IN_BYTES_WITHOUT_CONFIRM / (1024.0 * 1024.0);
     509    double fileSizeInMegaBytes = fileSizeInBytes / (1024.0 * 1024.0);
    473510    int numberOfDecimals = 1;
    474511    NumberFormat fixedNumberOfDecimals = new DecimalFormat("#########.###");
     
    478515    // Use
    479516    window
    480       .setContent("The file is larger than " + fixedNumberOfDecimals.format(maxFileSizeInMegaBytesWithoutConfirm) + " Mb (" + fixedNumberOfDecimals.format(fileSizeInMegaBytes) + " Mb). Opening it in the browser may take some time. Do you still want to open the file?");
     517      .setContent("The file is larger than " + fixedNumberOfDecimals
     518        .format(maxFileSizeInMegaBytesWithoutConfirm) + " Mb (" + fixedNumberOfDecimals
     519        .format(fileSizeInMegaBytes) + " Mb). Opening it in the browser may take some time. Do you still want to open the file?");
    481520    window.setStatic(false);
    482521    window.setToolbar(toolbar);
Note: See TracChangeset for help on using the changeset viewer.