Ignore:
Timestamp:
2023-02-17T11:42:23+13:00 (14 months ago)
Author:
davidb
Message:

More carefully developed version of opening an file (via a constructed URL) in webswing version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r37191 r37329  
    3939import java.io.File;
    4040import javax.swing.*;
     41
     42import org.webswing.toolkit.api.WebswingUtil;
     43
     44import org.greenstone.gatherer.Configuration;
    4145import org.greenstone.gatherer.Dictionary;
    4246import org.greenstone.gatherer.Gatherer;
     
    365369            }
    366370        }
     371        }
     372        else if (Gatherer.isWebswing) {
     373        if (Gatherer.GS3) {
     374            String full_filename = file.getAbsolutePath();
     375            String collect_dirname = Gatherer.getCollectDirectoryPath();
     376           
     377            if (full_filename.startsWith(collect_dirname)) {
     378            // Strip off everything up to .../site/<site>/collect
     379            // => so local_filename start with the name of the actual collection
     380           
     381            String local_filename = full_filename.substring(collect_dirname.length());
     382            //String coll_name      = CollectionManager.getLoadedCollectionTailName();
     383            String opt_group_name = CollectionManager.getLoadedCollectionGroupName();
     384           
     385            //String this_collect_dirname = collect_dirname + coll_group_with_name;
     386            //if (full_filename.startsWith(this_collect_dirname)) {
     387            //String local_filename = full_filename.substring(this_collect_dirname.length());
     388
     389            String library_url = Configuration.library_url.toString();
     390            String site = Configuration.site_name;
     391           
     392           
     393            //String library_collect_url = library_url + "/sites/" + site + "/collect/" + coll_group_with_name;
     394            String library_site_url = library_url + "/sites/" + site;
     395           
     396            String library_collect_url = library_site_url + "/collect";
     397            if (opt_group_name != null && !opt_group_name.equals("")) {
     398                library_collect_url = library_collect_url + "/" + opt_group_name;
     399            }
     400           
     401            String library_collect_file_url = library_collect_url + "/" + local_filename;
     402           
     403            WebswingUtil.getWebswingApi().sendActionEvent("previewURL", library_collect_file_url, null);
     404            }
     405            else {
     406            System.err.println("Warning - OpenFileInExternalApplicationTask.run() unable to construct a URL to access the following file" );
     407            System.err.println("    " + full_filename);
     408            System.err.println("Did not fall within " + collect_dirname);
     409
     410            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Webswing_Unable_To_Open"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     411            }
     412        }
     413        else {
     414            System.err.println("Error - Greenstone2 version of GLI using WebSwing does not currently support opening files externally" );
     415            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Webswing_Unable_To_Open_GS2"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     416        }
     417           
     418        // finish here
     419        return;
    367420        }
    368421
Note: See TracChangeset for help on using the changeset viewer.