Changeset 6738


Ignore:
Timestamp:
10/01/06 16:30:54 (5 years ago)
Author:
sys
Message:

Passage de reveal/launch local file dans la lib ut

Location:
trunk/Xul_Cms/content/scenaricms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Xul_Cms/content/scenaricms/ut.js

    r6148 r6738  
    150150 
    151151/** 
    152  * 
     152 * Lance l'application par défaut de l'OS pour l'URL passée en paramètre. 
    153153 */ 
    154154ut.loadExternalURL = function(pUrl){ 
     
    159159    vExtProtocolSvc.loadUrl(vUri); 
    160160  } 
     161} 
     162 
     163/** 
     164 * Ouvre ou révèle un fichier local. 
     165 * @param pReveal : true = révèle dans le système de fichier de l'OS, false lance l'appli associée par l'OS 
     166 */ 
     167ut.openExternalLocalFile = function wspOpenExternal(pFilePath, pReveal) { 
     168        var vFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); 
     169        vFile.initWithPath(pFilePath); 
     170        try { 
     171                if(pReveal) vFile.reveal(); else vFile.launch(); 
     172        } catch(e) { 
     173                // This is only called on unix systems due to the fact that nsILocalFile::Launch and nsILocalFile::Reveal have a bug under that OS. 
     174                // This code is copied from the firefox 1.5 chrome, original file: mozapps/downloads/downloads.js 
     175                if(pReveal && ! vFile.isDirectory()) vFile = vFile.parent; 
     176                var vUri = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newFileURI(vFile); 
     177                var vProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService); 
     178                vProtocolSvc.loadUrl(vUri); 
     179        } 
    161180} 
    162181// ####################### XML UTIL ####################### 
  • trunk/Xul_Cms/content/scenaricms/wspview/wspview.js

    r6675 r6738  
    13141314                var vFilePath = vCtx.fServer.getTextFromService("/u/vueObjet?cdaction=GetFilePath&param="+encodeURIComponent(vCtx.fUri)); 
    13151315        } 
    1316         if(vFilePath) wspOpenExternal(vFilePath, true); 
     1316        if(vFilePath) ut.openExternalLocalFile(vFilePath, true); 
    13171317} 
    13181318 
     
    13201320        var vCtx = ut.getContextActions(pEvent.target); 
    13211321        var vFilePath = vCtx.fServer.getTextFromService("/u/vueObjet?cdaction=GetFilePath&param="+window.encodeURIComponent(vCtx.fUri)); 
    1322         if(vFilePath) wspOpenExternal(vFilePath, false); 
    1323 } 
    1324  
    1325 function wspOpenExternal(pFilePath, pReveal) { 
    1326         var vFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); 
    1327         vFile.initWithPath(pFilePath); 
    1328         try { 
    1329                 if(pReveal) vFile.reveal(); else vFile.launch(); 
    1330         } catch(e) { 
    1331                 // This is only called on unix systems due to the fact that nsILocalFile::Launch and nsILocalFile::Reveal have a bug under that OS. 
    1332                 // This code is copied from the firefox 1.5 chrome, original file: mozapps/downloads/downloads.js 
    1333                 if(pReveal && ! vFile.isDirectory()) vFile = vFile.parent; 
    1334                 var vUri = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newFileURI(vFile); 
    1335                 var vProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService); 
    1336                 vProtocolSvc.loadUrl(vUri); 
    1337         } 
     1322        if(vFilePath) ut.openExternalLocalFile(vFilePath, false); 
    13381323} 
    13391324 
Note: See TracChangeset for help on using the changeset viewer.