private void runJavaProcessInProject(
      TmcProjectInfo projectInfo,
      ClassPath classPath,
      String taskName,
      List<String> args,
      InputOutput inOut,
      BgTaskListener<ProcessResult> listener) {
    FileObject projectDir = projectInfo.getProjectDir();

    JavaPlatform platform =
        JavaPlatform.getDefault(); // Should probably use project's configured platform instead

    FileObject javaExe = platform.findTool("java");
    if (javaExe == null) {
      throw new IllegalArgumentException();
    }

    // TMC server packages this with every exercise for our convenience.
    // True even for Maven exercises, at least until NB's Maven API is published.
    ClassPath testRunnerClassPath = getTestRunnerClassPath(projectInfo);

    if (testRunnerClassPath != null) {
      classPath = ClassPathSupport.createProxyClassPath(classPath, testRunnerClassPath);
    }

    String[] command = new String[3 + args.size()];
    command[0] = FileUtil.toFile(javaExe).getAbsolutePath();
    command[1] = "-cp";
    command[2] = classPath.toString(ClassPath.PathConversionMode.WARN);
    System.arraycopy(args.toArray(new String[args.size()]), 0, command, 3, args.size());

    log.info(StringUtils.join(command, ' '));
    ProcessRunner runner = new ProcessRunner(command, FileUtil.toFile(projectDir), inOut);
    BgTask.start(taskName, runner, listener);
  }
Esempio n. 2
0
 private void setRoots(Project[] projects) {
   Set<File> newRoots = new HashSet<File>();
   for (Project project : projects) {
     Sources sources = ProjectUtils.getSources(project);
     SourceGroup[] groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
     for (SourceGroup group : groups) {
       FileObject fo = group.getRootFolder();
       File root = FileUtil.toFile(fo);
       if (root == null) {
         LOG.log(
             Level.WARNING, "source group{0} returned null root folder", group.getDisplayName());
       } else {
         addRootFile(newRoots, root);
       }
     }
     File root = FileUtil.toFile(project.getProjectDirectory());
     if (root == null) {
       LOG.log(
           Level.WARNING, "project {0} returned null root folder", project.getProjectDirectory());
     } else {
       addRootFile(newRoots, root);
     }
   }
   synchronized (roots) {
     roots.clear();
     roots.addAll(newRoots);
   }
   fireFileEvent(EVENT_PROJECTS_CHANGED, null);
 }
  /**
   * Simulates deadlock issue 133616 - create MultiFileSystem - create lookup to set our
   * MultiFileSystem and system filesystem - create handler to manage threads - put test FileObject
   * to 'potentialLock' set - call hasLocks - it call LocalFileSystemEx.getInvalid which ends in our
   * DeadlockHandler - it starts lockingThread which calls FileObject.lock which locks our
   * FileObject - when we in LocalFileSystemEx.lock, we notify main thread which continues in
   * getInvalid and tries to accuire lock on FileObject and it dead locks
   */
  public void testLocalFileSystemEx133616() throws Exception {
    System.setProperty("workdir", getWorkDirPath());
    clearWorkDir();

    FileSystem lfs =
        TestUtilHid.createLocalFileSystem("mfs1" + getName(), new String[] {"/fold/file1"});
    LocalFileSystemEx exfs = new LocalFileSystemEx();
    exfs.setRootDirectory(FileUtil.toFile(lfs.getRoot()));
    FileSystem xfs = TestUtilHid.createXMLFileSystem(getName(), new String[] {});
    FileSystem mfs = new MultiFileSystem(exfs, xfs);
    testedFS = mfs;
    System.setProperty(
        "org.openide.util.Lookup", LocalFileSystemEx133616Test.class.getName() + "$Lkp");
    Lookup l = Lookup.getDefault();
    if (!(l instanceof Lkp)) {
      fail("Wrong lookup: " + l);
    }

    final FileObject file1FO = mfs.findResource("/fold/file1");
    File file1File = FileUtil.toFile(file1FO);

    Logger.getLogger(LocalFileSystemEx.class.getName()).setLevel(Level.FINEST);
    Logger.getLogger(LocalFileSystemEx.class.getName()).addHandler(new DeadlockHandler(file1FO));
    LocalFileSystemEx.potentialLock(file1FO.getPath());
    LocalFileSystemEx.hasLocks();
  }
Esempio n. 4
0
 /**
  * DOCUMENT ME!
  *
  * @param libNodes DOCUMENT ME!
  * @return DOCUMENT ME!
  */
 private boolean performDeploy(final List<Node> libNodes) {
   final List<DeployInformation> infos = new LinkedList<DeployInformation>();
   final ModificationStore modStore = ModificationStore.getInstance();
   for (final Node libNode : libNodes) {
     for (final Node node : libNode.getChildren().getNodes(true)) {
       for (final Action a : node.getActions(false)) {
         // if this action is registered it node should be of type
         // LocalManagement or StarterManagement
         if (a instanceof DeployChangedJarsAction) {
           for (final Node ch : node.getChildren().getNodes()) {
             final DeployInformation info = DeployInformation.getDeployInformation(ch);
             final String path = FileUtil.toFile(info.getSourceDir()).getAbsolutePath();
             if (modStore.anyModifiedInContext(path, ModificationStore.MOD_CHANGED)) {
               infos.add(info);
             }
           }
           // continue with outer loop since only one action of
           // this type should be registered
           break;
         }
       }
     }
   }
   try {
     JarHandler.deployAllJars(infos, JarHandler.ANT_TARGET_DEPLOY_CHANGED_JARS);
     for (final DeployInformation info : infos) {
       final String path = FileUtil.toFile(info.getSourceDir()).getAbsolutePath();
       modStore.removeAllModificationsInContext(path, ModificationStore.MOD_CHANGED);
     }
     return true;
   } catch (final IOException ex) {
     LOG.warn("could not deploy changed jars", ex); // NOI18N
     return false;
   }
 }
  private List<String> getCommandArguments() {
    List<String> args = new ArrayList<>();

    if (outputDirectory != null) {
      args.add("-o");
      args.add(FileUtil.toFile(outputDirectory).getAbsolutePath());
    }

    // Where do we want ANTLR to look for .tokens and import grammars?
    if (libDirectory != null && libDirectory.isFolder()) {
      args.add("-lib");
      args.add(FileUtil.toFile(libDirectory).getAbsolutePath());
    }

    if (atn) {
      args.add("-atn");
    }

    if (encoding != null && !encoding.isEmpty()) {
      args.add("-encoding");
      args.add(encoding);
    }

    if (listener) {
      args.add("-listener");
    } else {
      args.add("-no-listener");
    }

    if (visitor) {
      args.add("-visitor");
    } else {
      args.add("-no-visitor");
    }

    if (treatWarningsAsErrors) {
      args.add("-Werror");
    }

    if (forceATN) {
      args.add("-Xforce-atn");
    }

    if (targetArgument != null) {
      args.add("-Dlanguage=" + targetArgument);
    }

    if (options != null) {
      for (Map.Entry<String, String> option : options.entrySet()) {
        args.add(String.format("-D%s=%s", option.getKey(), option.getValue()));
      }
    }

    if (arguments != null) {
      args.addAll(arguments);
    }

    return args;
  }
 public FuelPhpIgnoredFilesExtender(PhpModule pm) {
   assert pm != null;
   docs = new File(FileUtil.toFile(pm.getProjectDirectory()), "docs"); // NOI18N
   // add settings whether MVC direcotries is ignored
   if (FuelPhpPreferences.ignoreMVCNode(pm)) {
     controller = FileUtil.toFile(FuelUtils.getControllerDirectory(pm));
     model = FileUtil.toFile(FuelUtils.getModelDirectory(pm));
     views = FileUtil.toFile(FuelUtils.getViewsDirectory(pm));
     modules = FileUtil.toFile(FuelUtils.getModulesDirectory(pm));
   }
 }
Esempio n. 7
0
 void load() {
   FileObject checkstyleConfigurationFile =
       GlobalCheckstyleSettings.INSTANCE.getCheckstyleConfigurationFile();
   String cleanAbsoluteFile = FileUtil.toFile(checkstyleConfigurationFile).getAbsolutePath();
   checkstyleConfiguration.setConfigFilePath(cleanAbsoluteFile);
   FileObject checkstylePropertiesFile = GlobalCheckstyleSettings.INSTANCE.getPropertiesFile();
   if (null != checkstylePropertiesFile) {
     String propertiesFilePath = FileUtil.toFile(checkstylePropertiesFile).getAbsolutePath();
     checkstyleConfiguration.setPropertiesFilePath(propertiesFilePath);
   } else {
     checkstyleConfiguration.setPropertiesFilePath("");
   }
   checkstyleConfiguration.setProperties(
       GlobalCheckstyleSettings.INSTANCE.getPropertiesAsString());
 }
 private List<TestMethod> findProjectTests(TmcProjectInfo projectInfo, FileObject testDir) {
   TestScanner scanner = new TestScanner();
   scanner.setClassPath(
       getTestClassPath(projectInfo, testDir).toString(ClassPath.PathConversionMode.WARN));
   scanner.addSource(FileUtil.toFile(testDir));
   return scanner.findTests();
 }
Esempio n. 9
0
  /**
   * Gets the name of the CASA file in the given project.
   *
   * @param project a JBI project
   * @return CASA file name
   */
  public static String getCasaFileName(Project project) {
    ProjectInformation projInfo = project.getLookup().lookup(ProjectInformation.class);
    String projName = projInfo.getName();

    File pf = FileUtil.toFile(project.getProjectDirectory());
    return pf.getPath() + CASA_DIR_NAME + projName + CASA_EXT;
  }
  private NbGradleProject(FileObject projectDir, ProjectState state) throws IOException {
    this.projectDir = projectDir;
    this.projectDirAsFile = FileUtil.toFile(projectDir);
    if (projectDirAsFile == null) {
      throw new IOException("Project directory does not exist.");
    }

    this.mergedCommandQueryRef = new AtomicReference<BuiltInGradleCommandQuery>(null);
    this.delayedInitTasks =
        new AtomicReference<Queue<Runnable>>(new LinkedBlockingQueue<Runnable>());
    this.state = state;
    this.defaultLookupRef = new AtomicReference<Lookup>(null);
    this.properties = new ProjectPropertiesProxy(this);
    this.projectInfoManager = new ProjectInfoManager();

    this.hasModelBeenLoaded = new AtomicBoolean(false);
    this.loadErrorRef = new AtomicReference<ProjectInfoRef>(null);
    this.modelChanges = new ChangeSupport(this);
    this.currentModelRef =
        new AtomicReference<NbGradleModelRef>(
            new NbGradleModelRef(GradleModelLoader.createEmptyModel(projectDirAsFile)));

    this.loadedAtLeastOnceSignal = new WaitableSignal();
    this.name = projectDir.getNameExt();
    this.exceptionDisplayer = new ExceptionDisplayer(NbStrings.getProjectErrorTitle(name));
    this.extensionRefs = Collections.emptyList();
    this.extensionsOnLookup = Lookup.EMPTY;
    this.lookupRef = new AtomicReference<DynamicLookup>(null);
    this.protectedLookupRef = new AtomicReference<Lookup>(null);
  }
Esempio n. 11
0
  protected void performAction(Node[] activatedNodes) {
    BoraDataObject c = activatedNodes[0].getCookie(BoraDataObject.class);

    String reference = FileUtil.toFile(c.getPrimaryFile().getParent()).getPath();
    String oemmDir = Utilities.absoluteFileName(activatedNodes[0].getName() + ".oemm", reference);
    view(c, oemmDir, activatedNodes[0].getName() + " OEMM");
  }
  public void savePreset(String name, Layout layout) {
    Preset preset = addPreset(new Preset(name, layout));

    try {
      // Create file if dont exist
      FileObject folder = FileUtil.getConfigFile("layoutpresets");
      if (folder == null) {
        folder = FileUtil.getConfigRoot().createFolder("layoutpresets");
      }
      FileObject presetFile = folder.getFileObject(name, "xml");
      if (presetFile == null) {
        presetFile = folder.createData(name, "xml");
      }

      // Create doc
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder documentBuilder = factory.newDocumentBuilder();
      final Document document = documentBuilder.newDocument();
      document.setXmlVersion("1.0");
      document.setXmlStandalone(true);

      // Write doc
      preset.writeXML(document);

      // Write XML file
      Source source = new DOMSource(document);
      Result result = new StreamResult(FileUtil.toFile(presetFile));
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
      transformer.transform(source, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /** Actually performs the detection and stores relevant information in this Iterator */
 public void run() {
   try {
     FileObject java = findTool("java"); // NOI18N
     if (java == null) return;
     File javaFile = FileUtil.toFile(java);
     if (javaFile == null) return;
     String javapath = javaFile.getAbsolutePath();
     String filePath =
         File.createTempFile("nb-platformdetect", "properties").getAbsolutePath(); // NOI18N
     final String probePath = getSDKProperties(javapath, filePath);
     File f = new File(filePath);
     Properties p = new Properties();
     InputStream is = new FileInputStream(f);
     p.load(is);
     Map<String, String> m = new HashMap<String, String>(p.size());
     for (Enumeration en = p.keys(); en.hasMoreElements(); ) {
       String k = (String) en.nextElement();
       String v = p.getProperty(k);
       if (VisagePlatformImpl.SYSPROP_JAVA_CLASS_PATH.equals(k)) {
         v = filterProbe(v, probePath);
       } else if (VisagePlatformImpl.SYSPROP_USER_DIR.equals(k)) {
         v = ""; // NOI18N
       }
       v = fixSymLinks(k, v);
       m.put(k, v);
     }
     this.setSystemProperties(m);
     this.valid = true;
     is.close();
     f.delete();
   } catch (IOException ex) {
     this.valid = false;
   }
 }
Esempio n. 14
0
  private File getFileToRender() throws IOException {
    FileObject render = toRender;
    if (render == null) {
      PovrayProject proj = renderService.getProject();
      MainFileProvider provider =
          (MainFileProvider) proj.getLookup().lookup(MainFileProvider.class);
      if (provider == null) {
        throw new IllegalStateException("Main file provider missing");
      }
      render = provider.getMainFile();
      if (render == null) {
        ProjectInformation info =
            (ProjectInformation) proj.getLookup().lookup(ProjectInformation.class);

        // XXX let the user choose
        throw new IOException(
            NbBundle.getMessage(Povray.class, "MSG_NoMainFile", info.getDisplayName()));
      }
    }
    assert render != null;
    File result = FileUtil.toFile(render);
    if (result == null) {
      throw new IOException(NbBundle.getMessage(Povray.class, "MSG_VirtualFile", render.getName()));
    }
    assert result.exists();
    assert result.isFile();
    return result;
  }
Esempio n. 15
0
 private File getImagesDir() {
   PovrayProject proj = renderService.getProject();
   FileObject fob = proj.getImagesFolder(true);
   File result = FileUtil.toFile(fob);
   assert result != null && result.exists();
   return result;
 }
Esempio n. 16
0
  private void writeResultsXml(GtaResult resultsObject) throws IOException {

    String newAnResFileName =
        FileUtil.findFreeFileName(
            resultsfolder,
            resultsfolder.getName() + "_" + modelReference.getFilename() + "_results",
            "xml");
    FileObject newAnResFile = resultsfolder.createData(newAnResFileName, "xml");
    resultsObject.setSummary(new Summary());
    resultsObject.getSummary().setFitModelCall(fitModelCall);
    // TODO resolve problem with multiple modelcalls
    resultsObject.getSummary().setInitModelCall(modelCalls.get(0));

    for (int i = 0; i < relationsList.size(); i++) {
      resultsObject.getDatasetRelations().add(new DatasetRelation());
      resultsObject
          .getDatasetRelations()
          .get(i)
          .setTo(String.valueOf((int) floor(relationsList.get(i)[0])));
      resultsObject
          .getDatasetRelations()
          .get(i)
          .setFrom(String.valueOf((int) floor(relationsList.get(i)[1])));
      // TODO do this in a different way
      // resultsObject.getDatasetRelations().get(i).getValues().add(relationsList.get(i)[2]);
      String cmd =
          timpcontroller.NAME_OF_RESULT_OBJECT
              + "$currTheta[["
              + (int) floor(relationsList.get(i)[0])
              + "]]@drel";
      resultsObject.getDatasetRelations().get(i).getValues().add(timpcontroller.getDouble(cmd));
    }

    createAnalysisResultsFile(resultsObject, FileUtil.toFile(newAnResFile));
  }
Esempio n. 17
0
  public Tgm getTgm() { // perhaps IOExeption?
    // If the Object "tgm" doesn't exist yet, read in from file

    if (tgm == null) {
      tgm = new Tgm();
      try {
        javax.xml.bind.JAXBContext jaxbCtx =
            javax.xml.bind.JAXBContext.newInstance(tgm.getClass().getPackage().getName());
        javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
        tgm =
            (Tgm)
                unmarshaller.unmarshal(
                    FileUtil.toFile(
                        this.getPrimaryFile())); // NOI18N //replaced: new java.io.File("File path")
        // //Fix this: java.lang.IllegalArgumentException:
        // file parameter must not be null
      } catch (javax.xml.bind.JAXBException ex) {
        // XXXTODO Handle exception
        java.util.logging.Logger.getLogger("global")
            .log(java.util.logging.Level.SEVERE, null, ex); // NOI18N
      }
    }
    // Else simply return the object
    return tgm;
  }
 public void testChangeReentrant() throws Exception {
   assertEquals(false, getEntityGeneralPanel().getReentrantCheckBox().isSelected());
   getEntityGeneralPanel().getReentrantCheckBox().doClick(); // change it
   assertEquals(true, bean.isReentrant());
   Thread.sleep(1000);
   Utils utils = new Utils(this);
   utils.checkInXML(ddObj, "<reentrant>true</reentrant>");
   utils.save(ddObj);
   if (ContentComparator.equalsXML(
           FileUtil.toFile(ddFo), getGoldenFile("testChangeReentrant_ejb-jar.xml"))
       == false) {
     assertFile(
         FileUtil.toFile(ddFo),
         getGoldenFile("testChangeReentrant_ejb-jar.xml"),
         new File(getWorkDir(), "testChangeReentrant.diff")); // check file on disc
   }
 }
Esempio n. 19
0
 /**
  * Determines all files and folders that belong to a given project and adds them to the supplied
  * Collection.
  *
  * @param filteredFiles destination collection of Files
  * @param project project to examine
  */
 public static void addProjectFiles(
     Collection filteredFiles,
     Collection rootFiles,
     Collection rootFilesExclusions,
     Project project) {
   FileStatusCache cache = CvsVersioningSystem.getInstance().getStatusCache();
   Sources sources = ProjectUtils.getSources(project);
   SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
   for (int j = 0; j < sourceGroups.length; j++) {
     SourceGroup sourceGroup = sourceGroups[j];
     FileObject srcRootFo = sourceGroup.getRootFolder();
     File rootFile = FileUtil.toFile(srcRootFo);
     try {
       getCVSRootFor(rootFile);
     } catch (IOException e) {
       // the folder is not under a versioned root
       continue;
     }
     rootFiles.add(rootFile);
     boolean containsSubprojects = false;
     FileObject[] rootChildren = srcRootFo.getChildren();
     Set projectFiles = new HashSet(rootChildren.length);
     for (int i = 0; i < rootChildren.length; i++) {
       FileObject rootChildFo = rootChildren[i];
       if (CvsVersioningSystem.FILENAME_CVS.equals(rootChildFo.getNameExt())) continue;
       File child = FileUtil.toFile(rootChildFo);
       // #67900 Added special treatment for .cvsignore files
       if (sourceGroup.contains(rootChildFo)
           || CvsVersioningSystem.FILENAME_CVSIGNORE.equals(rootChildFo.getNameExt())) {
         // TODO: #60516 deep scan is required here but not performed due to performace reasons
         projectFiles.add(child);
       } else {
         int status = cache.getStatus(child).getStatus();
         if (status != FileInformation.STATUS_NOTVERSIONED_EXCLUDED) {
           rootFilesExclusions.add(child);
           containsSubprojects = true;
         }
       }
     }
     if (containsSubprojects) {
       filteredFiles.addAll(projectFiles);
     } else {
       filteredFiles.add(rootFile);
     }
   }
 }
Esempio n. 20
0
 public static File[] toFileArray(Collection fileObjects) {
   Set files = new HashSet(fileObjects.size() * 4 / 3 + 1);
   for (Iterator i = fileObjects.iterator(); i.hasNext(); ) {
     files.add(FileUtil.toFile((FileObject) i.next()));
   }
   files.remove(null);
   return (File[]) files.toArray(new File[files.size()]);
 }
 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. 22
0
 /** Returns the exercise associated with the given project, or null if none. */
 public Exercise tryGetExerciseForProject(TmcProjectInfo project, CourseDb courseDb) {
   File projectDir = FileUtil.toFile(project.getProjectDir());
   for (Exercise ex : courseDb.getCurrentCourseExercises()) {
     if (getProjectDirForExercise(ex).equals(projectDir)) {
       return ex;
     }
   }
   return null;
 }
 private File endorsedLibsPath(final TmcProjectInfo projectInfo) {
   String path =
       FileUtil.toFile(projectInfo.getProjectDir()).getAbsolutePath()
           + File.separatorChar
           + "lib"
           + File.separatorChar
           + "endorsed";
   return new File(path);
 }
Esempio n. 24
0
  public JComponent createComponent(Category category, Lookup context) {
    Project p = context.lookup(Project.class);
    CheckstyleSettingsProvider checkstyleSettingsProvider =
        p.getLookup().lookup(CheckstyleSettingsProvider.class);
    if (checkstyleSettingsProvider == null) {
      return new JLabel("<not available>");
    }
    final CheckstyleSettings checkstyleSettings =
        checkstyleSettingsProvider.getCheckstyleSettings();

    final CheckstyleConfiguration checkstyleConfiguration = new CheckstyleConfiguration();
    FileObject checkstyleConfigurationFile = checkstyleSettings.getCheckstyleConfigurationFile();
    if (checkstyleConfigurationFile != null) {
      String cleanAbsoluteFile = FileUtil.toFile(checkstyleConfigurationFile).getAbsolutePath();
      checkstyleConfiguration.setConfigFilePath(cleanAbsoluteFile);
    } else {
      checkstyleConfiguration.setConfigFilePath("");
    }
    FileObject checkstylePropertiesFile = checkstyleSettings.getPropertiesFile();
    if (null != checkstylePropertiesFile) {
      String propertiesFilePath = FileUtil.toFile(checkstylePropertiesFile).getAbsolutePath();
      checkstyleConfiguration.setPropertiesFilePath(propertiesFilePath);
    } else {
      checkstyleConfiguration.setPropertiesFilePath("");
    }
    checkstyleConfiguration.setProperties(checkstyleSettings.getPropertiesAsString());

    category.setOkButtonListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (checkstyleSettings instanceof CheckstyleSettingsProviderImpl.Settings) {
              CheckstyleSettingsProviderImpl.Settings checkstyleSettingsImpl =
                  (CheckstyleSettingsProviderImpl.Settings) checkstyleSettings;
              checkstyleSettingsImpl.setCheckstyleConfigurationPath(
                  checkstyleConfiguration.getConfigFilePath());
              checkstyleSettingsImpl.setPropertiesPath(
                  checkstyleConfiguration.getPropertiesFilePath());
              checkstyleSettingsImpl.setProperties(checkstyleConfiguration.getProperties());
            }
          }
        });

    return checkstyleConfiguration;
  }
Esempio n. 25
0
 /**
  * Gets a the file related to the document
  *
  * @return the file related to the document, <code>null</code> if none exists.
  */
 File getCurrentFile() {
   File result = referencedFile;
   if (result == null) {
     DataObject dobj = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
     if (dobj != null) {
       FileObject fo = dobj.getPrimaryFile();
       result = FileUtil.toFile(fo);
     }
   }
   return result;
 }
 private static void setModules(final FileObject dir, final WizardDescriptor wiz) {
   final Properties properties =
       (Properties) wiz.getProperty(ModuleSelectionWizardPanel1.MODULE_SELECTION_PROPS);
   if (properties != null) {
     final FileObject jinferProjectDir = dir.getFileObject("jinferproject");
     try {
       final FileObject projectProperties = jinferProjectDir.createData("project", "properties");
       properties.store(new FileOutputStream(FileUtil.toFile(projectProperties)), null);
     } catch (IOException ex) {
       Exceptions.printStackTrace(ex);
     }
   }
 }
 private void browseTargetFolderButtonActionPerformed(
     ActionEvent evt) { // GEN-FIRST:event_browseTargetFolderButtonActionPerformed
   File target =
       new FileChooserBuilder(ApiGenProvider.lastDirFor(phpModule))
           .setTitle(info)
           .setDirectoriesOnly(true)
           .setFileHiding(true)
           .setDefaultWorkingDirectory(FileUtil.toFile(phpModule.getSourceDirectory()))
           .showOpenDialog();
   if (target != null) {
     target = FileUtil.normalizeFile(target);
     targetFolderTextField.setText(target.getAbsolutePath());
   }
 } // GEN-LAST:event_browseTargetFolderButtonActionPerformed
 public CakePhpIgnoredFilesExtender(PhpModule phpModule) {
   assert phpModule != null;
   if (CakePreferences.ignoreTmpDirectory(phpModule)) {
     CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule);
     if (cakeModule == null) {
       appTmp = null;
     } else {
       FileObject tmpDirectory = cakeModule.getDirectory(DIR_TYPE.APP, FILE_TYPE.TMP, null);
       appTmp = tmpDirectory == null ? null : FileUtil.toFile(tmpDirectory);
     }
   } else {
     appTmp = null;
   }
 }
  private static CacheKey tryCreateKey(NbGradleModel model) {
    ExceptionHelper.checkNotNullArgument(model, "model");

    File projectDir = model.getGenericInfo().getProjectDir();

    FileObject settingsFileObj = model.getGenericInfo().tryGetSettingsFileObj();
    File settingsFile = settingsFileObj != null ? FileUtil.toFile(settingsFileObj) : null;

    if (projectDir == null || (settingsFile == null && settingsFileObj != null)) {
      return null;
    }

    return new CacheKey(projectDir, settingsFile);
  }
Esempio n. 30
0
  private static File getCompAppWSDLLockFile(Project project) {
    ProjectInformation projInfo = project.getLookup().lookup(ProjectInformation.class);
    String projName = projInfo.getName();
    FileObject srcDirFO = ((JbiProject) project).getSourceDirectory();
    if (srcDirFO != null) {
      // FileObject doesn't work:
      // srcDirFO.getFileObject(
      //     LOCK_FILE_PREFIX + projName + WSDL_EXT + LOCK_FILE_SUFFIX);
      File lockFile =
          new File(
              FileUtil.toFile(srcDirFO), LOCK_FILE_PREFIX + projName + WSDL_EXT + LOCK_FILE_SUFFIX);
      return lockFile;
    }

    return null;
  }