1 19 20 package org.netbeans.modules.web.project; 21 22 import java.io.IOException ; 23 import java.io.File ; 24 import javax.swing.Action ; 25 import org.netbeans.api.project.ProjectManager; 26 import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties; 27 import org.netbeans.spi.project.support.ant.EditableProperties; 28 import org.netbeans.spi.project.support.ant.PropertyUtils; 29 import org.openide.ErrorManager; 30 import org.openide.modules.InstalledFileLocator; 31 import org.openide.modules.ModuleInstall; 32 import org.netbeans.spi.project.ActionProvider; 33 import org.netbeans.spi.project.ui.support.FileSensitiveActions; 34 import org.openide.NotifyDescriptor; 35 import org.openide.DialogDisplayer; 36 import org.openide.util.NbBundle; 37 38 46 public class WebProjectModule extends ModuleInstall { 47 public static final String JSPC_CLASSPATH = "jspc.classpath"; public static final String COPYFILES_CLASSPATH = "copyfiles.classpath"; 50 public void restored() { 51 52 ProjectManager.mutex().postWriteRequest( 53 new Runnable () { 54 public void run () { 55 try { 56 EditableProperties ep = PropertyUtils.getGlobalProperties(); 57 boolean changed = false; 58 StringBuffer sb = new StringBuffer (450); 60 sb.append(InstalledFileLocator.getDefault().locate("ant/lib/ant.jar", null, false)) .append(':') .append(InstalledFileLocator.getDefault().locate("modules/ext/servlet2.5-jsp2.1-api.jar", null, false)) .append(":${" + WebProjectProperties.J2EE_PLATFORM_CLASSPATH + "}:") .append(InstalledFileLocator.getDefault().locate("modules/ext/glassfish-jspparser.jar", null, false)) .append(':') .append(InstalledFileLocator.getDefault().locate("modules/ext/glassfish-logging.jar", null, false)) .append(':') .append(InstalledFileLocator.getDefault().locate("modules/ext/commons-logging-1.0.4.jar", null, false)); 74 String jspc_cp_old = ep.getProperty(JSPC_CLASSPATH); 75 String jspc_cp = sb.toString(); 76 if (jspc_cp_old == null || !jspc_cp_old.equals (jspc_cp)) { 77 ep.setProperty(JSPC_CLASSPATH, jspc_cp); 78 changed = true; 79 } 80 File copy_files = InstalledFileLocator.getDefault().locate("ant/extra/copyfiles.jar", null, false); if (copy_files == null) { 82 String msg = NbBundle.getMessage(WebProjectModule.class,"MSG_CopyFileMissing"); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE)); 84 } else { 85 String copy_files_old = ep.getProperty(COPYFILES_CLASSPATH); 86 if (copy_files_old == null || !copy_files_old.equals(copy_files.toString())) { 87 ep.setProperty(COPYFILES_CLASSPATH, copy_files.toString()); 88 changed = true; 89 } 90 } 91 if (changed) { 92 PropertyUtils.putGlobalProperties (ep); 93 } 94 } catch (IOException ioe) { 95 ErrorManager.getDefault().notify (ioe); 96 } 97 } 98 } 99 ); 100 } 101 102 public static Action compile() { 103 return FileSensitiveActions.fileCommandAction( 104 ActionProvider.COMMAND_COMPILE_SINGLE, 105 NbBundle.getMessage(WebProjectModule.class, "LBL_CompileFile_Action"), null ); 107 } 108 109 public static Action run() { 110 return FileSensitiveActions.fileCommandAction( 111 ActionProvider.COMMAND_RUN_SINGLE, 112 NbBundle.getMessage(WebProjectModule.class, "LBL_RunFile_Action"), null ); 114 } 115 116 public static Action debug() { 117 return FileSensitiveActions.fileCommandAction( 118 ActionProvider.COMMAND_DEBUG_SINGLE, 119 NbBundle.getMessage(WebProjectModule.class, "LBL_DebugFile_Action"), null ); 121 } 122 123 public static Action htmlRun() { 124 return FileSensitiveActions.fileCommandAction( 125 ActionProvider.COMMAND_RUN_SINGLE, 126 NbBundle.getMessage(WebProjectModule.class, "LBL_RunFile_Action"), null ); 128 } 129 130 public static Action htmlDebug() { 131 return FileSensitiveActions.fileCommandAction( 132 ActionProvider.COMMAND_DEBUG_SINGLE, 133 NbBundle.getMessage(WebProjectModule.class, "LBL_DebugFile_Action"), null ); 135 } 136 137 } 138 | Popular Tags |