private void btnDefinitionActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDefinitionActionPerformed
   File f = FileUtil.toFile(helper.getProjectDirectory()); // NOI18N
   String curr = SharableLibrariesUtils.browseForLibraryLocation(getLibraryLocation(), this, f);
   if (curr != null) {
     setLibraryLocation(curr);
   }
 } // GEN-LAST:event_btnDefinitionActionPerformed
Esempio n. 2
0
 public LogicalViewChildren(
     AntProjectHelper helper, PropertyEvaluator evaluator, Project project) {
   assert helper != null;
   this.helper = helper;
   projectDir = helper.getProjectDirectory();
   this.evaluator = evaluator;
   this.project = project;
 }
Esempio n. 3
0
 private DataFolder getFolder(String propName) {
   FileObject fo = helper.resolveFileObject(evaluator.getProperty(propName));
   if (fo != null) {
     DataFolder df = DataFolder.findFolder(fo);
     return df;
   }
   return null;
 }
 private void prepareProject(String platformName) throws IOException {
   scratch = makeScratchDir(this);
   projdir = scratch.createFolder("proj");
   AntProjectHelper helper =
       ProjectGenerator.createProject(projdir, "org.netbeans.modules.web.project");
   pm = ProjectManager.getDefault();
   pp = pm.findProject(projdir);
   EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
   props.setProperty("javac.source", "${def}");
   props.setProperty("platform.active", platformName);
   props.setProperty("def", "1.2");
   helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
   props = PropertyUtils.getGlobalProperties();
   props.put("default.javac.source", "4.3");
   PropertyUtils.putGlobalProperties(props);
   sources = projdir.createFolder("src");
 }
Esempio n. 5
0
 public boolean interestedInScript(File script, AntSession session) {
   FileObject projfile = FileUtil.toFileObject(FileUtil.normalizeFile(script));
   if (projfile == null) return false;
   Project proj = FileOwnerQuery.getOwner(projfile);
   if (proj == null) return false;
   AntProjectHelper helper = proj.getLookup().lookup(AntProjectHelper.class);
   if (helper == null) return false;
   String sourceRoot = helper.getStandardPropertyEvaluator().getProperty("src.dir"); // NOI18N
   if (sourceRoot == null) return false;
   File srcRoot = helper.resolveFile(sourceRoot);
   if (srcRoot == null) return false;
   HashMap<File, String> roots = (HashMap) session.getCustomData(this);
   if (roots == null) {
     roots = new HashMap();
     session.putCustomData(this, roots);
   }
   roots.put(
       script, srcRoot.getAbsolutePath().replaceAll(CHARSTOESCAPE, ESCAPESEQUENCE) + separator);
   return true;
 }
Esempio n. 6
0
    protected Node[] createNodes(Object key) {
      Node n = null;
      if (key == KEY_SOURCE_DIR) {
        FileObject srcRoot =
            helper.resolveFileObject(evaluator.getProperty(IcanproProjectProperties.SRC_DIR));
        Project p = FileOwnerQuery.getOwner(srcRoot);
        Sources s = ProjectUtils.getSources(p);
        SourceGroup sgs[] =
            ProjectUtils.getSources(p).getSourceGroups(IcanproProject.SOURCES_TYPE_ICANPRO);
        for (int i = 0; i < sgs.length; i++) {
          if (sgs[i].contains(srcRoot)) {
            n = PackageView.createPackageView(sgs[i]);
            break;
          }
        }
        /*
                  } else if (key == KEY_DOC_BASE) {
                      n = new DocBaseNode (getFolder(IcanproProjectProperties.META_INF).getNodeDelegate());
                  } else if (key == KEY_EJBS) {
                      FileObject srcRoot = helper.resolveFileObject(evaluator.getProperty (IcanproProjectProperties.SRC_DIR));
                      Project project = FileOwnerQuery.getOwner (srcRoot);
                      DDProvider provider = DDProvider.getDefault();
                      EjbJarImplementation jp = (EjbJarImplementation) project.getLookup().lookup(EjbJarImplementation.class);
                      org.netbeans.modules.j2ee.dd.api.ejb.EjbJar ejbJar = null;
                      try {
                          ejbJar = provider.getDDRoot(jp.getDeploymentDescriptor());
                      } catch (IOException ioe) {
                          ErrorManager.getDefault().notify(ioe);
                      }
                      ClassPathProvider cpp = (ClassPathProvider)
                          project.getLookup().lookup(ClassPathProvider.class);
                      assert cpp != null;
                      ClassPath classPath = cpp.findClassPath(srcRoot, ClassPath.SOURCE);
                      n = new EjbContainerNode(ejbJar, classPath);
                      //Node nws =  new WebServicesNode(ejbJar, classPath);
                      return n == null ? new Node[0] : new Node[] {n};
                  } else if (key == WEBSERVICES_DIR){
        FileObject 	srcRoot = helper.resolveFileObject(evaluator.getProperty (IcanproProjectProperties.SRC_DIR));
                      WebServicesView webServicesView = WebServicesView.getWebServicesView(srcRoot);
                      if(webServicesView != null)
        {
        n = webServicesView.createWebServicesView(srcRoot);
                      }
           } else if (key == KEY_SETUP_DIR) {
                      try {
                          DataObject sdo = DataObject.find(getSetupFolder());
                          n = new ServerResourceNode(project); // sdo.getNodeDelegate());
                      } catch (org.openide.loaders.DataObjectNotFoundException dnfe) {}
                      */
      }

      return n == null ? new Node[0] : new Node[] {n};
    }
  @Messages({
    "WARN_MakeSharable.absolutePath=<html>Please make sure that the absolute path in the Libraries Folder field is valid for all users.<html>",
    "WARN_makeSharable.relativePath=<html>Please make sure that the relative path in the Libraries Folder field is valid for all users.<html>"
  })
  boolean isValidPanel() {
    String location = getLibraryLocation();
    boolean wrong = false;
    if (new File(location).isAbsolute()) {
      settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_MakeSharable_absolutePath());
      wrong = true;
    } else {
      File projectLoc = FileUtil.toFile(helper.getProjectDirectory());
      File libLoc = PropertyUtils.resolveFile(projectLoc, location);
      if (!CollocationQuery.areCollocated(projectLoc, libLoc)) {
        settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_makeSharable_relativePath());
        wrong = true;
      }
    }
    if (!wrong) {
      settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
    }

    return true;
  }
 public FileObject getRootFolder() {
   return helper.resolveFileObject(
       helper.getStandardPropertyEvaluator().getProperty("src.dir")); // NOI18N
 }
  public Set /*<FileObject>*/ instantiate() throws IOException {

    Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
    File dirPr = (File) wiz.getProperty("projdir"); // NOI18N
    if (dirPr != null) {
      dirPr = FileUtil.normalizeFile(dirPr);
    }

    String name = (String) wiz.getProperty("name"); // NOI18N

    final String activePlatform = (String) wiz.getProperty("activePlatform"); // NOI18N
    final String activeDevice = (String) wiz.getProperty("activeDevice"); // NOI18N
    final String activeProfile = (String) wiz.getProperty("activeProfile"); // NOI18N
    Properties props = (Properties) wiz.getProperty("additionalProperties"); // NOI18N
    final FileObject template = Templates.getTemplate(wiz);
    PlatformSelectionPanel.PlatformDescription pd =
        (PlatformSelectionPanel.PlatformDescription)
            wiz.getProperty(PlatformSelectionPanel.PLATFORM_DESCRIPTION);
    AntProjectHelper h =
        J2MEProjectGenerator.createProject(
            dirPr,
            name,
            pd,
            new J2MEProjectGenerator.ProjectGeneratorCallback() {
              public void doPostGeneration(
                  Project p,
                  final AntProjectHelper h,
                  FileObject dir,
                  File projectLocationFile,
                  ArrayList<String> configurations)
                  throws IOException {

                createManifest(dir, MANIFEST_FILE);
                unZipFile(template.getInputStream(), dir);

                final FileObject lib = dir.getFileObject("lib");
                if (lib != null) {
                  final ReferenceHelper refHelper =
                      (ReferenceHelper) p.getLookup().lookup(ReferenceHelper.class);
                  try {
                    ProjectManager.mutex()
                        .writeAccess(
                            new Mutex.ExceptionAction() {
                              public Object run() throws Exception {
                                final List<String> entries = new ArrayList<String>();
                                final FileObject[] libs = lib.getChildren();
                                for (int i = 0; i < libs.length; i++) {
                                  String ref =
                                      refHelper.createForeignFileReference(
                                          FileUtil.normalizeFile(FileUtil.toFile(libs[i])), null);
                                  entries.add(ref + ((i < libs.length - 1) ? ";" : ""));
                                }

                                EditableProperties editableProps =
                                    h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                                editableProps.setProperty(
                                    "extra.classpath", entries.toArray(new String[entries.size()]));
                                editableProps.setProperty(
                                    "libs.classpath", entries.toArray(new String[entries.size()]));
                                h.putProperties(
                                    AntProjectHelper.PROJECT_PROPERTIES_PATH,
                                    editableProps); // #47609
                                return null;
                              }
                            });
                  } catch (MutexException me) {
                    ErrorManager.getDefault().notify(me);
                  }
                }

                final FileObject res = dir.getFileObject("resources");
                if (res != null) {
                  final ReferenceHelper refHelper =
                      (ReferenceHelper) p.getLookup().lookup(ReferenceHelper.class);
                  try {
                    ProjectManager.mutex()
                        .writeAccess(
                            new Mutex.ExceptionAction() {
                              public Object run() throws Exception {
                                String ref =
                                    ";"
                                        + refHelper.createForeignFileReference(
                                            FileUtil.normalizeFile(FileUtil.toFile(res)), null);

                                EditableProperties editableProps =
                                    h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                                editableProps.setProperty(
                                    "libs.classpath",
                                    editableProps.getProperty("libs.classpath") + ref);
                                h.putProperties(
                                    AntProjectHelper.PROJECT_PROPERTIES_PATH,
                                    editableProps); // #47609
                                return null;
                              }
                            });
                  } catch (MutexException me) {
                    ErrorManager.getDefault().notify(me);
                  }
                }

                Properties parsed = parseRicohAdditionalResources(dir);
                if (parsed != null) {
                  Iterator entries = parsed.entrySet().iterator();
                  while (entries.hasNext()) {
                    final Map.Entry elem = (Map.Entry) entries.next();
                    final Object value = elem.getValue();
                    if (value instanceof File) {
                      final ReferenceHelper refHelper =
                          (ReferenceHelper) p.getLookup().lookup(ReferenceHelper.class);
                      if (value != null && ((File) value).exists()) {
                        try {
                          ProjectManager.mutex()
                              .writeAccess(
                                  new Mutex.ExceptionAction() {
                                    public Object run() throws Exception {
                                      String ref =
                                          refHelper.createForeignFileReference(
                                              FileUtil.normalizeFile((File) value), null);
                                      EditableProperties props =
                                          h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                                      props.put((String) elem.getKey(), ref);
                                      h.putProperties(
                                          AntProjectHelper.PROJECT_PROPERTIES_PATH,
                                          props); // #47609
                                      return null;
                                    }
                                  });
                        } catch (MutexException me) {
                          ErrorManager.getDefault().notify(me);
                        }
                      }
                    } else {
                      EditableProperties editableProps =
                          h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                      editableProps.setProperty(
                          (String) elem.getKey(), String.valueOf(elem.getValue()));
                      h.putProperties(
                          AntProjectHelper.PROJECT_PROPERTIES_PATH, editableProps); // #47609
                    }
                  }
                }

                JavaPlatform[] platforms =
                    JavaPlatformManager.getDefault()
                        .getPlatforms(
                            activePlatform,
                            new Specification(CDCPlatform.PLATFORM_CDC, null)); // NOI18N
                if (platforms.length != 0) {
                  CDCPlatform cdcplatform = (CDCPlatform) platforms[0];
                  final EditableProperties ep =
                      h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                  ep.setProperty(
                      CDCPropertiesDescriptor.APPLICATION_NAME,
                      p.getProjectDirectory().getNameExt());
                  ep.setProperty(
                      DefaultPropertiesDescriptor.PLATFORM_ACTIVE,
                      cdcplatform.getAntName()); // NOI18N
                  ep.setProperty(
                      DefaultPropertiesDescriptor.PLATFORM_ACTIVE_DESCRIPTION,
                      cdcplatform.getDisplayName()); // NOI18N
                  ep.setProperty(DefaultPropertiesDescriptor.PLATFORM_TRIGGER, "CDC"); // NOI18N
                  ep.setProperty(
                      DefaultPropertiesDescriptor.PLATFORM_TYPE, cdcplatform.getType()); // NOI18N
                  String classVersion = cdcplatform.getClassVersion();
                  ep.setProperty(
                      DefaultPropertiesDescriptor.PLATFORM_DEVICE, activeDevice); // NOI18N
                  ep.setProperty(
                      DefaultPropertiesDescriptor.PLATFORM_PROFILE, activeProfile); // NOI18N
                  // add bootclasspath
                  NewCDCProjectWizardIterator.generatePlatformProperties(
                      cdcplatform, activeDevice, activeProfile, ep); // NOI18N
                  ep.setProperty(
                      DefaultPropertiesDescriptor.JAVAC_SOURCE,
                      classVersion != null ? classVersion : "1.2"); // NOI18N
                  ep.setProperty(
                      DefaultPropertiesDescriptor.JAVAC_TARGET,
                      classVersion != null ? classVersion : "1.2"); // NOI18N
                  h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
                } else {
                  throw new IllegalArgumentException("No CDC platform installed"); // NOI18N
                }
              }
            });

    resultSet.add(h.getProjectDirectory());
    dirPr = (dirPr != null) ? dirPr.getParentFile() : null;
    if (dirPr != null && dirPr.exists()) {
      ProjectChooser.setProjectsFolder(dirPr);
    }
    return resultSet;
  }