Lines 38-43
Link Here
|
38 |
import java.awt.event.ActionListener; |
38 |
import java.awt.event.ActionListener; |
39 |
import java.awt.event.ActionEvent; |
39 |
import java.awt.event.ActionEvent; |
40 |
import java.text.MessageFormat; |
40 |
import java.text.MessageFormat; |
|
|
41 |
import javax.swing.JButton; |
41 |
import javax.swing.SwingUtilities; |
42 |
import javax.swing.SwingUtilities; |
42 |
|
43 |
|
43 |
import org.openide.loaders.*; |
44 |
import org.openide.loaders.*; |
Lines 470-508
Link Here
|
470 |
// |
471 |
// |
471 |
Vector warnings = new Vector(); |
472 |
Vector warnings = new Vector(); |
472 |
|
473 |
|
|
|
474 |
boolean shouldPutIn = false; |
475 |
boolean alreadyAsked = false; |
476 |
|
473 |
// create WEB-INF |
477 |
// create WEB-INF |
474 |
FileObject webInf = fs.find(FOLDER_WEB_INF, null, null); |
478 |
FileObject webInf = fs.find(FOLDER_WEB_INF, null, null); |
475 |
if (webInf == null) { |
479 |
if (webInf == null) { |
|
|
480 |
if (!alreadyAsked) { |
481 |
alreadyAsked = true; |
482 |
shouldPutIn = shouldPutIntoClearCase(fs); |
483 |
} |
476 |
// this should not happen, as if WEB-INF does not exist, then we shouldn't be called |
484 |
// this should not happen, as if WEB-INF does not exist, then we shouldn't be called |
477 |
// but anyway |
485 |
// but anyway |
478 |
try { |
486 |
try { |
479 |
webInf = FileUtil.createFolder(fs.getRoot(), FOLDER_WEB_INF); |
487 |
webInf = createFolderClearCaseHack(fs.getRoot(), FOLDER_WEB_INF, shouldPutIn); |
480 |
} catch (IOException fx1) { |
488 |
} catch (IOException fx1) { |
|
|
489 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); |
481 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINF")); // NOI18N |
490 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINF")); // NOI18N |
482 |
} |
491 |
} |
483 |
} |
492 |
} |
484 |
// create WEB-INF/classes |
493 |
// create WEB-INF/classes |
485 |
FileObject classesDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_CLASSES, null, null);//NOI18N |
494 |
FileObject classesDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_CLASSES, null, null);//NOI18N |
486 |
if (classesDir == null) { |
495 |
if (classesDir == null) { |
|
|
496 |
if (!alreadyAsked) { |
497 |
alreadyAsked = true; |
498 |
shouldPutIn = shouldPutIntoClearCase(fs); |
499 |
} |
487 |
try { |
500 |
try { |
488 |
classesDir = FileUtil.createFolder(webInf, FOLDER_CLASSES); |
501 |
if (webInf != null) { |
|
|
502 |
classesDir = createFolderClearCaseHack(webInf, FOLDER_CLASSES, shouldPutIn); |
503 |
} |
489 |
} catch (IOException fx1) { |
504 |
} catch (IOException fx1) { |
|
|
505 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); |
490 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFclasses")); // NOI18N |
506 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFclasses")); // NOI18N |
491 |
} |
507 |
} |
492 |
} |
508 |
} |
493 |
// create WEB-INF/lib |
509 |
// create WEB-INF/lib |
494 |
FileObject libDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_LIB, null, null);//NOI18N |
510 |
FileObject libDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_LIB, null, null);//NOI18N |
495 |
if (libDir == null) { |
511 |
if (libDir == null) { |
|
|
512 |
if (!alreadyAsked) { |
513 |
alreadyAsked = true; |
514 |
shouldPutIn = shouldPutIntoClearCase(fs); |
515 |
} |
496 |
try { |
516 |
try { |
497 |
libDir = FileUtil.createFolder(webInf, FOLDER_LIB); |
517 |
if (webInf != null) { |
|
|
518 |
libDir = createFolderClearCaseHack(webInf, FOLDER_LIB, shouldPutIn); |
519 |
} |
498 |
} catch (IOException fx1) { |
520 |
} catch (IOException fx1) { |
|
|
521 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fx1); |
499 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFlib")); // NOI18N |
522 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFlib")); // NOI18N |
500 |
} |
523 |
} |
501 |
} |
524 |
} |
502 |
// create web.xml |
525 |
// create web.xml |
503 |
// PENDING : should be easier to define in layer and copy related FileObject (doesn't require systemClassLoader) |
526 |
// PENDING : should be easier to define in layer and copy related FileObject (doesn't require systemClassLoader) |
504 |
FileObject webXML = fs.find(FOLDER_WEB_INF, "web", "xml");//NOI18N |
527 |
FileObject webXML = fs.find(FOLDER_WEB_INF, "web", "xml");//NOI18N |
505 |
if (webXML == null) { |
528 |
if ((webXML == null) && (webInf != null)) { |
506 |
String webXMLContent = readResource("org/netbeans/modules/web/core/resources/web.xml", //NOI18N |
529 |
String webXMLContent = readResource("org/netbeans/modules/web/core/resources/web.xml", //NOI18N |
507 |
(ClassLoader)Lookup.getDefault().lookup (ClassLoader.class)); |
530 |
(ClassLoader)Lookup.getDefault().lookup (ClassLoader.class)); |
508 |
webXML = FileUtil.createData(webInf, "web.xml");//NOI18N |
531 |
webXML = FileUtil.createData(webInf, "web.xml");//NOI18N |
Lines 533-538
Link Here
|
533 |
NotifyDescriptor.INFORMATION_MESSAGE)); |
556 |
NotifyDescriptor.INFORMATION_MESSAGE)); |
534 |
|
557 |
|
535 |
} |
558 |
} |
|
|
559 |
} |
560 |
|
561 |
/** |
562 |
* Creates a folder on given filesystem. The name of the new folder can be |
563 |
* specified as a multi-component pathname whose components are separated |
564 |
* by File.separatorChar or "/" (forward slash). |
565 |
* Has the following ClearCase-related behavior: if the folder is on clearcase FS, |
566 |
* and the putToVCS argument is set to true, then puts the file into VCS |
567 |
* |
568 |
* @param folder where the new folder will be placed in |
569 |
* @param name name of the new folder |
570 |
* @return the new folder |
571 |
* @exception IOException if the creation fails |
572 |
*/ |
573 |
public static FileObject createFolderClearCaseHack(FileObject folder, String name, boolean putToVCS) throws IOException { |
574 |
FileObject result = null; |
575 |
if (putToVCS) { |
576 |
String folderName = folder.getPath(); |
577 |
if ((folderName.length() > 0) && !folderName.endsWith("/")) { |
578 |
folderName = folderName + "/"; |
579 |
} |
580 |
folderName = folderName + name; |
581 |
folder.getFileSystem().getRoot().setAttribute("VCS_MKDIR_ACTION", folderName); |
582 |
folder.refresh(); |
583 |
result = folder.getFileObject(name); |
584 |
} |
585 |
if (result == null) { |
586 |
result = FileUtil.createFolder(folder, name); |
587 |
} |
588 |
return result; |
589 |
} |
590 |
|
591 |
/** Hack - we may be putting some directories into clearcase. |
592 |
*/ |
593 |
public static boolean shouldPutIntoClearCase(FileSystem fs) { |
594 |
FileObject root = fs.getRoot(); |
595 |
if ("ClearCase".equals(root.getAttribute("FS_DISPLAY_NAME"))) { |
596 |
// ask the user |
597 |
NotifyDescriptor nd = new NotifyDescriptor.Confirmation( |
598 |
NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCase"), NotifyDescriptor.YES_NO_OPTION); |
599 |
//button1 |
600 |
JButton button1 = new JButton(); |
601 |
button1.setText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes")); |
602 |
button1.setToolTipText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_Tooltip")); |
603 |
button1.setMnemonic(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_MNEM").charAt(0)); |
604 |
button1.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseYes_Tooltip")); |
605 |
button1.setDefaultCapable(false); |
606 |
//button2 |
607 |
JButton button2 = new JButton(); |
608 |
button2.setText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo")); |
609 |
button2.setToolTipText(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_Tooltip")); |
610 |
button2.setMnemonic(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_MNEM").charAt(0)); |
611 |
button2.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCaseNo_Tooltip")); |
612 |
button2.setDefaultCapable(false); |
613 |
// display it |
614 |
nd.setOptions(new JButton[] {button1, button2}); |
615 |
DialogDisplayer.getDefault().notify(nd); |
616 |
|
617 |
if (nd.getValue() != button1) return false; |
618 |
return true; |
619 |
} |
620 |
else { |
621 |
return false; |
622 |
} |
536 |
} |
623 |
} |
537 |
|
624 |
|
538 |
// Necessary because of bug - filesystems are added incorrectly if one is |
625 |
// Necessary because of bug - filesystems are added incorrectly if one is |