private static void unZipFile(InputStream source, FileObject projectRoot, WizardDescriptor wiz)
     throws IOException {
   try {
     ZipInputStream str = new ZipInputStream(source);
     ZipEntry entry;
     while ((entry = str.getNextEntry()) != null) {
       if (entry.isDirectory()) {
         FileUtil.createFolder(projectRoot, entry.getName());
       } else {
         FileObject fo = FileUtil.createData(projectRoot, entry.getName());
         if ("nbproject/project.xml".equals(entry.getName())) {
           // Special handling for setting name of Ant-based projects; customize as needed:
           filterProjectXML(fo, str, projectRoot.getName());
         }
         // if build.xml has been found replace its content with provided values
         else if ("build.xml".equals(entry.getName())) {
           processBuildXML(fo, str, wiz);
         } else if ("nbproject/project.properties".equals(entry.getName())) {
           processProjectProperties(fo, str, wiz, projectRoot.getName());
         } else {
           writeFile(str, fo);
         }
       }
     }
   } finally {
     source.close();
   }
 }
  private FileObject getArchivedFile(FileObject fileObject) {
    // ZIP and JAR archives
    if (FileUtil.isArchiveFile(fileObject)) {
      try {
        fileObject = FileUtil.getArchiveRoot(fileObject).getChildren()[0];
      } catch (Exception e) {
        throw new RuntimeException(
            "The archive can't be opened, be sure it has no password and contains a single file, without folders");
      }
    } else { // GZ or BZIP2 archives
      boolean isGz = fileObject.getExt().equalsIgnoreCase("gz");
      boolean isBzip = fileObject.getExt().equalsIgnoreCase("bz2");
      if (isGz || isBzip) {
        try {
          String[] splittedFileName = fileObject.getName().split("\\.");
          if (splittedFileName.length < 2) {
            return fileObject;
          }

          String fileExt1 = splittedFileName[splittedFileName.length - 1];
          String fileExt2 = splittedFileName[splittedFileName.length - 2];

          File tempFile = null;
          if (fileExt1.equalsIgnoreCase("tar")) {
            String fname = fileObject.getName().replaceAll("\\.tar$", "");
            fname = fname.replace(fileExt2, "");
            tempFile = File.createTempFile(fname, "." + fileExt2);
            // Untar & unzip
            if (isGz) {
              tempFile = getGzFile(fileObject, tempFile, true);
            } else {
              tempFile = getBzipFile(fileObject, tempFile, true);
            }
          } else {
            String fname = fileObject.getName();
            fname = fname.replace(fileExt1, "");
            tempFile = File.createTempFile(fname, "." + fileExt1);
            // Unzip
            if (isGz) {
              tempFile = getGzFile(fileObject, tempFile, false);
            } else {
              tempFile = getBzipFile(fileObject, tempFile, false);
            }
          }
          tempFile.deleteOnExit();
          tempFile = FileUtil.normalizeFile(tempFile);
          fileObject = FileUtil.toFileObject(tempFile);
        } catch (IOException ex) {
          Exceptions.printStackTrace(ex);
        }
      }
    }
    return fileObject;
  }
  @Override
  public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
      Component c = panels[i].getComponent();
      if (steps[i] == null) {
        // Default step name to component name of panel.
        // Mainly useful for getting the name of the target
        // chooser to appear in the list of steps.
        steps[i] = c.getName();
      }
      if (c instanceof JComponent) { // assume Swing components
        JComponent jc = (JComponent) c;
        // Step #.
        jc.putClientProperty(WizardProperties.SELECTED_INDEX, new Integer(i));
        // Step name (actually the whole list for reference).
        jc.putClientProperty(WizardProperties.CONTENT_DATA, steps);
      }
    }

    FileObject template = Templates.getTemplate(wiz);

    wiz.putProperty(WizardProperties.NAME, template.getName());
  }
    private void analyzePatternsImpl(CompilationInfo javac) {
      checkState(1);
      String clsname = javaFile.getName();
      TypeElement clselm = null;
      for (TypeElement top : javac.getTopLevelElements()) {
        if (clsname.contentEquals(top.getSimpleName())) {
          clselm = top;
        }
      }

      if (clselm == null) {
        isCancelled = true;
        error =
            new NotifyDescriptor.Message(
                NbBundle.getMessage(
                    GenerateBeanInfoAction.class,
                    "MSG_FileWitoutTopLevelClass",
                    clsname,
                    FileUtil.getFileDisplayName(javaFile)),
                NotifyDescriptor.ERROR_MESSAGE);
        return;
      }

      PatternAnalyser pa = new PatternAnalyser(javaFile, null, true);
      pa.analyzeAll(javac, clselm);
      // XXX analyze also superclasses here
      try {
        bia = new BiAnalyser(pa, javac);
      } catch (Exception ex) {
        isCancelled = true;
        Exceptions.printStackTrace(ex);
      }
    }
Exemple #5
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));
  }
Exemple #6
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;
  }
 /**
  * Get file name. If ASSET_TYPE is IMAGE, get name with extention, otherwise only name.
  *
  * @param fo target FileObject
  * @return file name if type is image, with extention.
  */
 private String getFileName(FileObject fo) {
   String name;
   if (type == ASSET_TYPE.IMAGE) {
     name = fo.getNameExt();
   } else {
     name = fo.getName();
   }
   return name;
 }
 protected boolean enable(Node[] activatedNodes) {
   if (activatedNodes.length != 1) {
     return false;
   } else {
     FileObject fo = findFileObject(activatedNodes[0]);
     return fo != null
         && JavaSource.forFileObject(fo) != null
         && !fo.getName().endsWith("BeanInfo"); // NOI18N
   }
 }
  private static Object createImpl(FileObject f) {
    if ("org-netbeans-modules-java-debug-TreeNavigatorProviderImpl".equals(f.getName())) {
      return new TreeNavigatorProviderImpl();
    }

    if ("org-netbeans-modules-java-debug-ElementNavigatorProviderImpl".equals(f.getName())) {
      return new ElementNavigatorProviderImpl();
    }

    if ("org-netbeans-modules-java-debug-ErrorNavigatorProviderImpl".equals(f.getName())) {
      return new ErrorNavigatorProviderImpl();
    }

    if ("org-netbeans-modules-java-debug-ClasspathNavigatorProviderImpl".equals(f.getName())) {
      return new ClasspathNavigatorProviderImpl();
    }

    // unknown:
    return new Object();
  }
  public void testDeleteCreateFile() throws IOException {

    // non atomic delete and create
    File file1 = new File(dataRootDir, "file1");
    file1 = FileUtil.normalizeFile(file1);
    file1.createNewFile();

    final FileObject fo1 = FileUtil.toFileObject(file1);
    fo1.delete();
    fo1.getParent().createData(fo1.getName());

    // get intercepted events
    String[] nonAtomic =
        DeleteCreateTestAnnotationProvider.instance.events.toArray(
            new String[DeleteCreateTestAnnotationProvider.instance.events.size()]);
    DeleteCreateTestAnnotationProvider.instance.events.clear();

    // atomic delete and create
    File file2 = new File(dataRootDir, "file2");
    file2 = FileUtil.normalizeFile(file2);
    file2.createNewFile();

    final FileObject fo2 = FileUtil.toFileObject(file2);
    AtomicAction a =
        new AtomicAction() {
          public void run() throws IOException {
            fo2.delete();
            fo2.getParent().createData(fo2.getName());
          }
        };
    fo2.getFileSystem().runAtomicAction(a);
    // get intercepted events
    String[] atomic =
        DeleteCreateTestAnnotationProvider.instance.events.toArray(
            new String[DeleteCreateTestAnnotationProvider.instance.events.size()]);

    Logger l = Logger.getLogger(DeleteCreateTest.class.getName());
    l.info("- atomic events ----------------------------------");
    for (String s : atomic) l.info(s);
    l.info("- non atomic events ------------------------------");
    for (String s : nonAtomic) l.info(s);
    l.info("-------------------------------");

    // test
    assertEquals(atomic.length, nonAtomic.length);
    for (int i = 0; i < atomic.length; i++) {
      assertEquals(atomic[i], nonAtomic[i]);
    }
  }
 /**
  * Get plugin names of baserCMS.
  *
  * @param baserModule {@link CakePhpModule}
  * @return plugin names
  */
 private List<String> getBaserPluginNames(CakePhpModule baserModule) {
   FileObject baserPluginDirectory = baserModule.getDirectory(DIR_TYPE.BASER_PLUGIN);
   if (baserPluginDirectory == null) {
     return Collections.emptyList();
   }
   FileObject[] children = baserPluginDirectory.getChildren();
   ArrayList<String> pluginNames = new ArrayList<String>(children.length);
   for (FileObject child : children) {
     if (!child.isFolder()) {
       continue;
     }
     pluginNames.add(child.getName());
   }
   return pluginNames;
 }
 private void replaceXmlFiles() {
   List<FileObject> newFiles = new ArrayList<FileObject>();
   for (Iterator<FileObject> it = assetList.iterator(); it.hasNext(); ) {
     FileObject fileObject = it.next();
     if (fileObject.hasExt("xml")) {
       FileObject binaryFile = fileObject.getParent().getFileObject(fileObject.getName());
       if (binaryFile != null) {
         newFiles.add(binaryFile);
         it.remove();
       }
     }
   }
   for (Iterator<FileObject> it = newFiles.iterator(); it.hasNext(); ) {
     FileObject fileObject = it.next();
     assetList.add(fileObject);
   }
 }
      public ZipNode(FileObject key) throws DataObjectNotFoundException {
        super(
            DataFolder.find(key).getNodeDelegate(),
            new FilterNode.Children(DataFolder.find(key).getNodeDelegate()),
            new AbstractLookup(instanceContent = new InstanceContent()));
        setDisplayName(key.getName() + ".zip");
        key.addRecursiveListener(
            new FileChangeListener() {
              @Override
              public void fileFolderCreated(FileEvent fe) {
                modify(fe.getFile());
              }

              @Override
              public void fileDataCreated(FileEvent fe) {
                modify(fe.getFile());
              }

              @Override
              public void fileChanged(FileEvent fe) {
                modify(fe.getFile());
              }

              @Override
              public void fileDeleted(FileEvent fe) {
                modify(fe.getFile());
              }

              @Override
              public void fileRenamed(FileRenameEvent fre) {
                modify(fre.getFile());
              }

              @Override
              public void fileAttributeChanged(FileAttributeEvent fae) {
                modify(fae.getFile());
              }

              private void modify(FileObject file) {
                if (getLookup().lookup(ZIPSavable.class) == null) {
                  instanceContent.add(new ZIPSavable(file));
                }
              }
            });
      }
  public void cssMinify() {
    MinifyProperty minifyProperty = MinifyProperty.getInstance();
    MinifyUtil util = new MinifyUtil();
    try {
      FileObject file = context.getPrimaryFile();

      String inputFilePath = file.getPath();
      String outputFilePath;

      if (minifyProperty.isNewCSSFile()
          && minifyProperty.getPreExtensionCSS() != null
          && !minifyProperty.getPreExtensionCSS().trim().isEmpty()) {
        outputFilePath =
            file.getParent().getPath()
                + File.separator
                + file.getName()
                + minifyProperty.getSeparatorCSS()
                + minifyProperty.getPreExtensionCSS()
                + "."
                + file.getExt();
      } else {
        outputFilePath = inputFilePath;
      }

      MinifyFileResult minifyFileResult =
          util.compressCss(inputFilePath, outputFilePath, minifyProperty);
      if (minifyProperty.isEnableOutputLogAlert()) {
        JOptionPane.showMessageDialog(
            null,
            "CSS Minified Completed Successfully\n"
                + "Input CSS Files Size : "
                + minifyFileResult.getInputFileSize()
                + "Bytes \n"
                + "After Minifying CSS Files Size : "
                + minifyFileResult.getOutputFileSize()
                + "Bytes \n"
                + "CSS Space Saved "
                + minifyFileResult.getSavedPercentage()
                + "%");
      }
    } catch (Exception ex) {
      Exceptions.printStackTrace(ex);
    }
  }
 /**
  * Add elements to field for {@link PhpClass}.
  *
  * @param phpClass
  * @param helperDirectory
  */
 private void addElements(
     @NonNull PhpClass phpClass, FileObject targetDirectory, FILE_TYPE fileType) {
   if (targetDirectory == null) {
     return;
   }
   for (FileObject child : targetDirectory.getChildren()) {
     if (!FileUtils.isPhpFile(child)) {
       continue;
     }
     String fullName = child.getName();
     if (fileType == FILE_TYPE.HELPER && "AppHelper".equals(fullName)) { // NOI18N
       continue;
     }
     String name = fullName.replace(fileType.toString(), ""); // NOI18N
     if (fileType == FILE_TYPE.MODEL) {
       phpClass.addField(name, new PhpClass(name, name), child, 0);
     } else {
       phpClass.addField(name, new PhpClass(name, name + fileType.toString()), child, 0);
     }
   }
 }
 private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
   try {
     ZipInputStream str = new ZipInputStream(source);
     ZipEntry entry;
     while ((entry = str.getNextEntry()) != null) {
       if (entry.isDirectory()) {
         FileUtil.createFolder(projectRoot, entry.getName());
       } else {
         FileObject fo = FileUtil.createData(projectRoot, entry.getName());
         if ("nbproject/project.xml".equals(entry.getName())) {
           // Special handling for setting name of Ant-based projects; customize as needed:
           filterProjectXML(fo, str, projectRoot.getName());
         } else {
           writeFile(str, fo);
         }
       }
     }
   } finally {
     source.close();
   }
 }
  public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    FileObject template = Templates.getTemplate(wiz);
    preferredName = template.getName();
    this.wiz.putProperty("name", preferredName);
    platform = (String) template.getAttribute("platform");

    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
      Component c = panels[i].getComponent();
      if (steps[i] == null) {
        // Default step name to component name of panel.
        // Mainly useful for getting the name of the target
        // chooser to appear in the list of steps.
        steps[i] = c.getName();
      }
      if (c instanceof JComponent) { // assume Swing components
        JComponent jc = (JComponent) c;
        // Step #.
        jc.putClientProperty(
            WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i)); // NOI18N
        // Step name (actually the whole list for reference).
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
        /*
         * Fix for #147260 - Wrong title in Ricoh samples wizard
         */
        jc.putClientProperty(
            "NewProjectWizard_Title",
            NbBundle.getMessage(NewProjectIterator.class, "TXT_SampleProject")); // NOI18N
      }
    }
    this.wiz.putProperty("additionalProperties", new Properties());
  }
 /**
  * Get extends class name. (e.g. component : Component, helper : AppHelper)
  *
  * @param fo
  * @param fileType
  * @return
  */
 @CheckForNull
 private PhpClass getPhpClass(FileObject fo) {
   if (CakePhpUtils.isComponent(fo)) {
     return getComponentPhpClass();
   } else if (CakePhpUtils.isController(fo)) {
     // get AppController fields info.
     String name = fo.getName();
     name = CakePhpUtils.toUnderscoreCase(name);
     if ("app_controller".equals(name)) { // NOI18N
       FileObject currentFileObject = CakePhpUtils.getCurrentFileObject();
       if (currentFileObject != null && CakePhpUtils.isView(currentFileObject)) {
         return getViewPhpClass();
       }
     }
     return getControllerPhpClass();
   } else if (CakePhpUtils.isView(fo)) {
     if (CakePhpUtils.isCtpFile(fo) || FileUtils.isPhpFile(fo)) {
       return getViewPhpClass();
     }
   } else if (CakePhpUtils.isHelper(fo)) {
     return getHelperPhpClass();
   }
   return null;
 }
  private void loadFromDefaultFileSystem() {
    FileObject f = FileUtil.getConfigFile("SaaSServices"); // NOI18N

    if (f != null && f.isFolder()) {
      Enumeration<? extends FileObject> en = f.getFolders(false);
      while (en.hasMoreElements()) {
        FileObject groupFolder = en.nextElement();
        for (FileObject fo : groupFolder.getChildren()) {
          if (fo.isFolder()) {
            continue;
          }
          if (PROFILE_PROPERTIES_FILE.equals(fo.getNameExt())) {
            continue;
          }
          loadSaasServiceFile(fo, false);
        }
        SaasGroup g = rootGroup.getChildGroup(groupFolder.getName());
        if (g != null) {
          g.setIcon16Path((String) groupFolder.getAttribute("icon16"));
          g.setIcon32Path((String) groupFolder.getAttribute("icon32"));
        }
      }
    }
  }
Exemple #20
0
 public int compare(FileObject fo1, FileObject fo2) {
   return fo1.getName().compareTo(fo2.getName());
 }
Exemple #21
0
  private void writeResults(
      TimpResultDataset[] results, GtaModelReference modelReference, String[] nlsprogressResult) {
    Tgm model = getModel(modelReference);
    GtaResult newResultsObject = new GtaResult();
    String freeResultsFilename =
        FileUtil.findFreeFileName(resultsfolder, resultsfolder.getName(), "summary");
    try {
      writeSummary(resultsfolder, freeResultsFilename);
    } catch (IOException ex) {
      Exceptions.printStackTrace(ex);
    }

    if (nlsprogressResult != null) {
      for (int i = 0; i < nlsprogressResult.length; i++) {
        NlsProgress progress = new NlsProgress();
        progress.setRss(nlsprogressResult[i]);
        newResultsObject.getNlsprogress().add(progress);
      }
    }

    for (int i = 0; i < results.length; i++) {
      TimpResultDataset timpResultDataset = results[i];
      timpResultDataset.setType(datasets[i].getType());

      newResultsObject.getDatasets().add(new Dataset());
      newResultsObject.getDatasets().get(i).setDatasetFile(new OutputFile());
      newResultsObject
          .getDatasets()
          .get(i)
          .getDatasetFile()
          .setFilename(datasetContainer.getDatasets().get(i).getFilename());
      newResultsObject
          .getDatasets()
          .get(i)
          .getDatasetFile()
          .setPath(datasetContainer.getDatasets().get(i).getPath());
      newResultsObject.getDatasets().get(i).getDatasetFile().setFiletype(datasets[i].getType());
      newResultsObject.getDatasets().get(i).setId(String.valueOf(i + 1));

      if (model.getDat().getIrfparPanel().getLamda() != null) {
        timpResultDataset.setLamdac(model.getDat().getIrfparPanel().getLamda());
      }

      if (datasets[i].getType().equalsIgnoreCase("flim")) {
        timpResultDataset.setOrheigh(datasets[i].getOriginalHeight());
        timpResultDataset.setOrwidth(datasets[i].getOriginalWidth());
        timpResultDataset.setIntenceIm(datasets[i].getIntenceIm().clone());
        timpResultDataset.setMaxInt(datasets[i].getMaxInt());
        timpResultDataset.setMinInt(datasets[i].getMinInt());
        timpResultDataset.setX(datasets[i].getX().clone());
        timpResultDataset.setX2(datasets[i].getX2().clone());
      }

      try {
        String freeFilename =
            FileUtil.findFreeFileName(
                resultsfolder,
                resultsfolder.getName() + "_d" + (i + 1) + "_" + timpResultDataset.getDatasetName(),
                "timpres");
        timpResultDataset.setDatasetName(freeFilename);
        writeTo = resultsfolder.createData(freeFilename, "timpres");
        ObjectOutputStream stream = new ObjectOutputStream(writeTo.getOutputStream());
        stream.writeObject(timpResultDataset);
        stream.close();

        newResultsObject.getDatasets().get(i).setResultFile(new OutputFile());
        newResultsObject.getDatasets().get(i).getResultFile().setFilename(freeFilename);
        newResultsObject
            .getDatasets()
            .get(i)
            .getResultFile()
            .setPath(FileUtil.getRelativePath(project.getProjectDirectory(), resultsfolder));

      } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
      }
    }
    try {
      writeResultsXml(newResultsObject);
    } catch (IOException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
  /** Initialization method. Creates appropriate labels in the panel. */
  public void initialize() {
    // This is needed since the checkBox is gets disabled on a
    // repeated invocation of SafeDelete follwing removal of references
    // to the element
    searchInComments.setEnabled(true);

    if (initialized) {
      return;
    }

    final String labelText;

    Lookup lkp = refactoring.getRefactoringSource();
    NonRecursiveFolder folder = lkp.lookup(NonRecursiveFolder.class);
    Collection<? extends FileObject> files = lkp.lookupAll(FileObject.class);
    final Collection<? extends ElementDef> defs = lkp.lookupAll(ElementDef.class);
    if (folder != null) {
      String pkgName = folder.getFolder().getNameExt().replace('/', '.');
      labelText = NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDelPkg", pkgName);
    } else if (files.size() > 1 && files.size() == defs.size()) {
      // delete multiple files
      if (regulardelete) {
        labelText =
            NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDel_RegularDelete", defs.size());
      } else {
        labelText = NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDel_Classes", defs.size());
      }
    } else if (defs.size() > 1) {
      labelText = NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDel_Classes", defs.size());
    } else if (defs.size() == 1) {
      ElementDef edef = defs.iterator().next();
      if (regulardelete) {
        labelText =
            NbBundle.getMessage(
                SafeDeletePanel.class, "LBL_SafeDel_RegularDeleteElement", edef.getName());
      } else {
        labelText =
            NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDel_Element", edef.getName());
      }
    } else {
      FileObject fileObject = files.iterator().next();
      boolean isSingleFolderSelected =
          (files != null && files.size() == 1 && fileObject.isFolder());
      if (isSingleFolderSelected && !regulardelete) {
        String folderName = fileObject.getName();
        labelText = NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDelFolder", folderName);
      } else {
        labelText = ""; // NOI18N
      }
    }

    SwingUtilities.invokeLater(
        new Runnable() {

          public void run() {
            if (regulardelete) {
              safeDelete = new JCheckBox();
              Mnemonics.setLocalizedText(
                  safeDelete, NbBundle.getMessage(SafeDeletePanel.class, "LBL_SafeDelCheckBox"));
              safeDelete
                  .getAccessibleContext()
                  .setAccessibleDescription(
                      NbBundle.getMessage(
                          SafeDeletePanel.class,
                          "SafeDeletePanel.safeDelete.AccessibleContext.accessibleDescription")); // NOI18N
              safeDelete.setMargin(new java.awt.Insets(2, 14, 2, 2));
              searchInComments.setEnabled(false);
              safeDelete.addItemListener(
                  new ItemListener() {

                    public void itemStateChanged(ItemEvent evt) {
                      searchInComments.setEnabled(safeDelete.isSelected());
                      parent.stateChanged(null);
                    }
                  });

              checkBoxes.add(safeDelete, BorderLayout.CENTER);
            }
            label.setText(labelText);
            validate();
          }
        });
    initialized = true;
  }
Exemple #23
0
  private void doAnalysis() {
    if (project != null) {
      if (output.getIterations() != null) {
        if (!output.getIterations().isEmpty()) {
          numIterations = Integer.parseInt(output.getIterations());
        }
      } else {
        numIterations = NO_OF_ITERATIONS;
      }
      if (output.getOutputPath() != null) {
        String[] nlsprogressResult = null;
        String outputPath =
            project.getResultsFolder(true) + File.separator + output.getOutputPath();
        File outputFolder = new File(outputPath);
        if (outputFolder.exists()) {
          resultsfolder = FileUtil.toFileObject(outputFolder);
          if (resultsfolder.getChildren().length > 0) {
            try {
              resultsfolder =
                  FileUtil.createFolder(
                      resultsfolder.getParent(),
                      FileUtil.findFreeFolderName(
                          resultsfolder.getParent(), resultsfolder.getName()));
            } catch (IOException ex) {
              Exceptions.printStackTrace(ex);
            }
          }
        } else {
          try {
            FileUtil.createFolder(outputFolder);
            resultsfolder = outputFolder.exists() ? FileUtil.toFileObject(outputFolder) : null;
          } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
          }
        }

        datasets = getDatasets(datasetContainer);
        modelCalls.add(getModelCall(modelReference, 0));

        fitModelCall =
            getFitModelCall(datasets, modelCalls, modelDifferences, output, numIterations);

        if (isValidAnalysis(datasets, modelReference)) {
          timpcontroller = Lookup.getDefault().lookup(TimpControllerInterface.class);
          if (timpcontroller != null) {
            results = timpcontroller.runAnalysis(datasets, modelCalls, fitModelCall);
            nlsprogressResult =
                timpcontroller.getStringArray(
                    TimpControllerInterface.NAME_OF_RESULT_OBJECT + "$nlsprogress");
          }
        } else {
          // TODO: CoreErrorMessages warning
          return;
        }

        if (results != null) {
          writeResults(results, modelReference, nlsprogressResult);

        } else {
          try {
            writeSummary(
                resultsfolder,
                FileUtil.findFreeFileName(
                    resultsfolder, resultsfolder.getName() + "_errorlog", "summary"));
          } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
          }
        }
        timpcontroller.cleanup();
      }
    }
  }
 static String getFileName(JTextComponent targetComponent) {
   FileObject fo = NbEditorUtilities.getFileObject(targetComponent.getDocument());
   return fo.getName();
 }
  public void initValues(
      final Project project, final FileObject template, final FileObject preselectedFolder) {
    this.project = project;
    this.helper = project.getLookup().lookup(AntProjectHelper.class);
    final Object obj = template.getAttribute(IS_MIDLET_TEMPLATE_ATTRIBUTE);
    isMIDlet = false;
    if (obj instanceof Boolean) isMIDlet = ((Boolean) obj).booleanValue();

    projectTextField.setText(ProjectUtils.getInformation(project).getDisplayName());

    final Sources sources = ProjectUtils.getSources(project);
    final SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    final SourceGroup preselectedGroup = getPreselectedGroup(groups, preselectedFolder);
    if (preselectedGroup != null) {
      final ModelItem groupItem = new ModelItem(preselectedGroup);
      final ModelItem[] nodes = groupItem.getChildren();
      packageComboBox.setModel(new DefaultComboBoxModel(nodes));
      final Object folderItem = getPreselectedPackage(groupItem, preselectedFolder);
      if (folderItem != null) packageComboBox.setSelectedItem(folderItem);
    } else {
      packageComboBox.setModel(new DefaultComboBoxModel());
    }

    // Determine the extension
    final String ext = template == null ? "" : template.getExt(); // NOI18N
    expectedExtension = ext.length() == 0 ? "" : "." + ext; // NOI18N

    lName.setVisible(isMIDlet);
    tName.setVisible(isMIDlet);
    lIcon.setVisible(isMIDlet);
    cIcon.setVisible(isMIDlet);
    lNote.setVisible(isMIDlet);
    org.openide.awt.Mnemonics.setLocalizedText(
        lClassName,
        NbBundle.getMessage(
            MIDPTargetChooserPanelGUI.class,
            isMIDlet ? "LBL_File_MIDletClassName" : "LBL_File_MIDPClassName")); // NOI18N

    // Show name of the project
    if (isMIDlet) {
      tName.getDocument().removeDocumentListener(this);
      tName.setText(template.getName());
      updateClassNameAndIcon();
      if (testIfFileNameExists(preselectedGroup) && updateClassName) {
        String name = tName.getText();
        int i = 1;
        for (; ; ) {
          tName.setText(name + "_" + i); // NOI18N
          updateClassNameAndIcon();
          if (!testIfFileNameExists(preselectedGroup) || !updateClassName) break;
          i++;
        }
      }
      tName.getDocument().addDocumentListener(this);
    } else {
      tClassName.setText(template.getName());
      if (testIfFileNameExists(preselectedGroup)) {
        String name = tClassName.getText();
        int i = 1;
        for (; ; ) {
          tClassName.setText(name + "_" + i); // NOI18N
          if (!testIfFileNameExists(preselectedGroup)) break;
          i++;
        }
      }
      tClassName.getDocument().addDocumentListener(this);
    }
    updateText();

    // Find all icons
    if (loadIcons) {
      loadIcons = false;
      final DefaultComboBoxModel icons = new DefaultComboBoxModel();
      cIcon.setModel(icons);
      cIcon.setSelectedItem(""); // NOI18N
      RequestProcessor.getDefault()
          .post(
              new Runnable() {
                public void run() {
                  final ArrayList<FileObject> roots = new ArrayList<FileObject>();
                  roots.add(
                      helper.resolveFileObject(
                          helper.getStandardPropertyEvaluator().getProperty("src.dir"))); // NOI18N
                  final String libs =
                      J2MEProjectUtils.evaluateProperty(
                          helper, DefaultPropertiesDescriptor.LIBS_CLASSPATH);
                  if (libs != null) {
                    final String elements[] = PropertyUtils.tokenizePath(helper.resolvePath(libs));
                    for (int i = 0; i < elements.length; i++)
                      try {
                        final FileObject root =
                            FileUtil.toFileObject(FileUtil.normalizeFile(new File(elements[i])));
                        if (root != null)
                          roots.add(
                              FileUtil.isArchiveFile(root) ? FileUtil.getArchiveRoot(root) : root);
                      } catch (Exception e) {
                      }
                  }
                  for (FileObject root : roots) {
                    if (root != null) {
                      final int rootLength = root.getPath().length();
                      final Enumeration en = root.getChildren(true);
                      while (en.hasMoreElements()) {
                        final FileObject fo = (FileObject) en.nextElement();
                        if (fo.isData()) {
                          final String ext = fo.getExt().toLowerCase();
                          if ("png".equals(ext)) { // NOI18N
                            String name = fo.getPath().substring(rootLength);
                            if (!name.startsWith("/")) name = "/" + name; // NOI18N
                            if (icons.getIndexOf(name) < 0) icons.addElement(name);
                          }
                        }
                      }
                    }
                  }
                }
              });
    }
  }