| 1 8 package com.nightlabs.rcp.action; 9 10 import java.io.File ; 11 12 import org.eclipse.jface.action.Action; 13 import org.eclipse.ui.PartInitException; 14 15 import com.nightlabs.base.NLBasePlugin; 16 import com.nightlabs.rcp.io.IOUtil; 17 import com.nightlabs.rcp.util.RCPUtil; 18 19 public class ReOpenFileAction 20 extends Action 21 { 22 public static final String ID = ReOpenFileAction.class.getName(); 23 protected String fileName; 24 25 public ReOpenFileAction(String fileName) 26 { 27 if (fileName == null) 28 throw new IllegalArgumentException ("Param fileName must not be null!"); 29 30 this.fileName = fileName; 31 init(); 32 } 33 34 protected void init() 35 { 36 setId(ID + "-" + fileName + fileName.hashCode()); 37 setText(fileName); 38 setToolTipText(fileName); 39 } 40 41 public String getFileName() { 42 return fileName; 43 } 44 45 public void run() 46 { 47 try 48 { 49 File file = new File (fileName); 50 if (file.exists()) 51 IOUtil.openFile(file); 52 } 53 catch (PartInitException e) 54 { 55 RCPUtil.showErrorDialog( 56 NLBasePlugin.getResourceString("action.openfile.error.message1") 57 + " " + fileName + " " + 58 NLBasePlugin.getResourceString("action.openfile.error.message2") 59 ); 60 e.printStackTrace(); 61 } 62 } 63 64 } 65 | Popular Tags |