cvs diff -w Bundle.properties WebContextObject.java (in directory P:\release35\nb_all\web\core\src\org\netbeans\modules\web\context\) Index: Bundle.properties =================================================================== RCS file: /cvs/web/core/src/org/netbeans/modules/web/context/Bundle.properties,v retrieving revision 1.9.26.3 diff -u -w -r1.9.26.3 Bundle.properties --- Bundle.properties 28 Mar 2003 13:00:09 -0000 1.9.26.3 +++ Bundle.properties 4 Apr 2003 16:41:41 -0000 @@ -80,3 +80,13 @@ CTL_NewWebModuleMountWizardPanel.newFolderBrowseB.mnemonic=R ERR_cannotDeleteWebInf=WEB-INF object cannot be deleted. + +#ClearCase hack +MSG_PutIntoClearCase=Creating a web module will create new directories in your local filesystem. Do you also want these directories added to ClearCase now? \n\n\ + Note: If you are using a ClearCase dynamic view, you cannot add the directories to ClearCase later if you choose to create locally only. +MSG_PutIntoClearCaseYes=Add to ClearCase +MSG_PutIntoClearCaseNo=Create locally only +MSG_PutIntoClearCaseYes_MNEM=C +MSG_PutIntoClearCaseNo_MNEM=L +MSG_PutIntoClearCaseYes_Tooltip=Add to ClearCase +MSG_PutIntoClearCaseNo_Tooltip=Create locally only Index: WebContextObject.java =================================================================== RCS file: /cvs/web/core/src/org/netbeans/modules/web/context/WebContextObject.java,v retrieving revision 1.27.2.4 diff -u -w -r1.27.2.4 WebContextObject.java --- WebContextObject.java 28 Mar 2003 13:00:11 -0000 1.27.2.4 +++ WebContextObject.java 4 Apr 2003 16:41:42 -0000 @@ -38,6 +38,7 @@ import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.text.MessageFormat; +import javax.swing.JButton; import javax.swing.SwingUtilities; import org.openide.loaders.*; @@ -470,39 +471,61 @@ // Vector warnings = new Vector(); + boolean shouldPutIn = false; + boolean alreadyAsked = false; + // create WEB-INF FileObject webInf = fs.find(FOLDER_WEB_INF, null, null); if (webInf == null) { + if (!alreadyAsked) { + alreadyAsked = true; + shouldPutIn = shouldPutIntoClearCase(fs); + } // this should not happen, as if WEB-INF does not exist, then we shouldn't be called // but anyway try { - webInf = FileUtil.createFolder(fs.getRoot(), FOLDER_WEB_INF); + webInf = createFolderClearCaseHack(fs.getRoot(), FOLDER_WEB_INF, shouldPutIn); } catch (IOException fx1) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINF")); // NOI18N } } // create WEB-INF/classes FileObject classesDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_CLASSES, null, null);//NOI18N if (classesDir == null) { + if (!alreadyAsked) { + alreadyAsked = true; + shouldPutIn = shouldPutIntoClearCase(fs); + } try { - classesDir = FileUtil.createFolder(webInf, FOLDER_CLASSES); + if (webInf != null) { + classesDir = createFolderClearCaseHack(webInf, FOLDER_CLASSES, shouldPutIn); + } } catch (IOException fx1) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFclasses")); // NOI18N } } // create WEB-INF/lib FileObject libDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_LIB, null, null);//NOI18N if (libDir == null) { + if (!alreadyAsked) { + alreadyAsked = true; + shouldPutIn = shouldPutIntoClearCase(fs); + } try { - libDir = FileUtil.createFolder(webInf, FOLDER_LIB); + if (webInf != null) { + libDir = createFolderClearCaseHack(webInf, FOLDER_LIB, shouldPutIn); + } } catch (IOException fx1) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFlib")); // NOI18N } } // create web.xml // PENDING : should be easier to define in layer and copy related FileObject (doesn't require systemClassLoader) FileObject webXML = fs.find(FOLDER_WEB_INF, "web", "xml");//NOI18N - if (webXML == null) { + if ((webXML == null) && (webInf != null)) { String webXMLContent = readResource("org/netbeans/modules/web/core/resources/web.xml", //NOI18N (ClassLoader)Lookup.getDefault().lookup (ClassLoader.class)); webXML = FileUtil.createData(webInf, "web.xml");//NOI18N @@ -533,6 +556,70 @@ NotifyDescriptor.INFORMATION_MESSAGE)); } + } + + /** + * Creates a folder on given filesystem. The name of the new folder can be + * specified as a multi-component pathname whose components are separated + * by File.separatorChar or "/" (forward slash). + * Has the following ClearCase-related behavior: if the folder is on clearcase FS, + * and the putToVCS argument is set to true, then puts the file into VCS + * + * @param folder where the new folder will be placed in + * @param name name of the new folder + * @return the new folder + * @exception IOException if the creation fails + */ + public static FileObject createFolderClearCaseHack(FileObject folder, String name, boolean putToVCS) throws IOException { + FileObject result = null; + if (putToVCS) { + String folderName = folder.getPath(); + if ((folderName.length() > 0) && !folderName.endsWith("/")) { + folderName = folderName + "/"; + } + folderName = folderName + name; + folder.getFileSystem().getRoot().setAttribute("VCS_MKDIR_ACTION", folderName); + folder.refresh(); + result = folder.getFileObject(name); + } + if (result == null) { + result = FileUtil.createFolder(folder, name); + } + return result; + } + + /** Hack - we may be putting some directories into clearcase. + */ + public static boolean shouldPutIntoClearCase(FileSystem fs) { + FileObject root = fs.getRoot(); + if ("ClearCase".equals(root.getAttribute("FS_DISPLAY_NAME"))) { + // ask the user + NotifyDescriptor nd = new NotifyDescriptor.Confirmation( + NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCase"), NotifyDescriptor.YES_NO_OPTION); + //button1 + JButton button1 = new JButton(); + button1.setText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes")); + button1.setToolTipText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_Tooltip")); + button1.setMnemonic(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_MNEM").charAt(0)); + button1.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_Tooltip")); + button1.setDefaultCapable(false); + //button2 + JButton button2 = new JButton(); + button2.setText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo")); + button2.setToolTipText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_Tooltip")); + button2.setMnemonic(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_MNEM").charAt(0)); + button2.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_Tooltip")); + button2.setDefaultCapable(false); + // display it + nd.setOptions(new JButton[] {button1, button2}); + DialogDisplayer.getDefault().notify(nd); + + if (nd.getValue() != button1) return false; + return true; + } + else { + return false; + } } // Necessary because of bug - filesystems are added incorrectly if one is *****CVS exited normally with code 1*****