1 9 10 package org.enhydra.jawe.actions; 11 12 import org.enhydra.jawe.*; 13 import org.enhydra.jawe.graph.*; 14 import org.enhydra.jawe.xml.elements.PackageHeader; 15 16 import java.awt.event.ActionEvent ; 17 import java.io.*; 18 import javax.swing.*; 19 20 public class ReferredDocument extends ActionBase { 21 22 public ReferredDocument(AbstractEditor editor) { 23 super(editor); 24 } 25 26 public void actionPerformed(ActionEvent e) { 27 if (editor instanceof ProcessEditor) { 28 Activity selected = (Activity)editor.getGraph().getSelectionCell(); 30 String doc = selected.get("Documentation").toString(); 31 showExternalDocument(doc); 33 } else { 34 String doc=((PackageHeader)((PackageEditor)editor).getXMLPackage(). 35 get("PackageHeader")).get("Documentation").toString(); 36 showExternalDocument(doc); 37 } 38 } 39 40 47 private void showExternalDocument(String document) { 48 if (!(new File(document).canRead())) { 49 JOptionPane.showMessageDialog(editor.getWindow(), 50 document+": "+ 51 ResourceManager.getLanguageDependentString("InformationFileNotReadable"), 52 JaWE.getAppTitle(), JOptionPane.INFORMATION_MESSAGE); 53 return; 54 } 55 String startCommand = System.getProperty("path.to.start"); 56 if (null != startCommand) { 57 if(!new File(startCommand).canRead()) { 58 JOptionPane.showMessageDialog(editor.getWindow(), startCommand + ": " 59 +ResourceManager.getLanguageDependentString("InformationFileNotReadable"), 60 JaWE.getAppTitle(), JOptionPane.INFORMATION_MESSAGE); 61 return; 62 } 63 if (System.getProperty("path.separator").equals(";")) { 64 document = "\"" + document + "\""; 65 } 66 } else { 67 if (System.getProperty("path.separator").equals(":")) { 68 startCommand = "kfmclient exec"; 69 } else { 70 startCommand = "cmd /c start"; 71 document = "\"" + document + "\"" + " \"" + document + "\""; 72 } 73 } 74 try { 75 Runtime.getRuntime().exec(startCommand + " " + document); 76 } catch (Throwable t) { 77 t.printStackTrace(); 78 } 79 } 80 81 82 } 83 | Popular Tags |