コード例 #1
0
ファイル: IcanproViews.java プロジェクト: bflavius/nb-soa
    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};
    }
コード例 #2
0
  public void showCustomizer(String preselectedCategory, String preselectedSubCategory) {

    Dialog dialog = project2Dialog.get(project);
    if (dialog != null) {
      dialog.setVisible(true);
      return;
    } else {
      SharedRubyProjectProperties uiProperties =
          createUiProperties(project, updateHelper, evaluator, refHelper, genFileHelper);
      Lookup context =
          Lookups.fixed(
              new Object[] {
                project,
                uiProperties,
                new SubCategoryProvider(preselectedCategory, preselectedSubCategory)
              });

      OptionListener listener = new OptionListener(project, uiProperties);
      dialog =
          ProjectCustomizer.createCustomizerDialog(
              getCustomizerFolderPath(), context, preselectedCategory, listener, null);
      dialog.addWindowListener(listener);
      dialog.setTitle(
          MessageFormat.format(
              NbBundle.getMessage(
                  BaseRubyCustomizerProvider.class, "LBL_Customizer_Title"), // NOI18N
              new Object[] {ProjectUtils.getInformation(project).getDisplayName()}));

      project2Dialog.put(project, dialog);
      dialog.setVisible(true);
    }
  }
コード例 #3
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);
 }
コード例 #4
0
ファイル: GitProjectUtils.java プロジェクト: jonas/nbgit
 public static String getProjectName(final Project p) {
   if (p == null) {
     return null;
   }
   ProjectInformation pi = ProjectUtils.getInformation(p);
   return pi == null ? null : pi.getDisplayName();
 }
コード例 #5
0
 private void initProjectInfo() {
   Project p = FileOwnerQuery.getOwner(fileObject);
   if (p != null) {
     ProjectInformation pi = ProjectUtils.getInformation(p);
     projectName = pi.getDisplayName();
     projectIcon = pi.getIcon();
   }
 }
コード例 #6
0
 private void initComboBox(String root) {
   Preferences preferences;
   if (SelectProviderPanel.USE_PROJECT_PROPERTIES) {
     preferences =
         ProjectUtils.getPreferences(wizardDescriptor.getProject(), ProviderControl.class, false);
   } else {
     preferences = NbPreferences.forModule(ProviderControl.class);
   }
   field.setStorage(propertyKey, preferences);
   field.read(root);
 }
コード例 #7
0
 private void storeHistory() {
   Preferences preferences;
   if (SelectProviderPanel.USE_PROJECT_PROPERTIES) {
     preferences =
         ProjectUtils.getPreferences(wizardDescriptor.getProject(), ProviderControl.class, false);
   } else {
     preferences = NbPreferences.forModule(ProviderControl.class);
     field.setStorage(propertyKey, NbPreferences.forModule(ProviderControl.class));
   }
   field.setStorage(propertyKey, preferences);
   field.store();
 }
コード例 #8
0
  @Override
  public void showCustomizer() {
    init();

    final Dialog dialog =
        ProjectCustomizer.createCustomizerDialog(
            categories, componentProvider, null, new PropertiesListener(this), null);

    dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName());

    dialog.setVisible(true);
  }
コード例 #9
0
 static SourceGroup getSourceGroup(FileObject file, Project prj) {
   Sources src = ProjectUtils.getSources(prj);
   SourceGroup[] srcGrps = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
   for (SourceGroup srcGrp : srcGrps) {
     FileObject rootFolder = srcGrp.getRootFolder();
     if (((file == rootFolder) || FileUtil.isParentOf(rootFolder, file))
         && srcGrp.contains(file)) {
       return srcGrp;
     }
   }
   return null;
 }
コード例 #10
0
  protected WizardDescriptor.Panel<WizardDescriptor>[] createPanels() {
    if (targetChooserDescriptorPanel == null) {
      TemplateWizard wiz = getWizard();
      DataObject dobj = wiz.getTemplate();
      FileObject fobj = dobj.getPrimaryFile();
      String mimeType = fobj.getMIMEType();
      MIMEExtensions extensions = MIMEExtensions.get(mimeType);
      if (extensions != null) {
        Project project = Templates.getProject(getWizard());
        Sources sources = ProjectUtils.getSources(project);
        SourceGroup[] groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
        if (MIMENames.HEADER_MIME_TYPE.equals(extensions.getMIMEType())) {
          // this is the only place where we want to differ c headers from cpp headers (creation of
          // new one)
          if (dobj.getPrimaryFile().getAttribute(C_HEADER_MIME_TYPE) != null) {
            MIMEExtensions cHeaderExtensions = MIMEExtensions.get(C_HEADER_MIME_TYPE);
            if ((cHeaderExtensions == null)
                || !C_HEADER_MIME_TYPE.equals(cHeaderExtensions.getMIMEType())) {
              System.err.println("not found extensions for C Headers"); // NOI18N
            } else {
              extensions = cHeaderExtensions;
            }
          }
        }
        String defaultExt = null; // let the chooser panel decide default extension
        if (mimeType.equals(MIMENames.SHELL_MIME_TYPE)) {
          // for shell scripts set default extension explicitly
          defaultExt = fobj.getExt();
        } else if (mimeType.equals(MIMENames.HEADER_MIME_TYPE) && fobj.getExt().length() == 0) {
          // for standard header without extension
          defaultExt = fobj.getExt();
        }

        targetChooserDescriptorPanel =
            new NewTestSimplePanel(
                project,
                groups,
                null,
                extensions,
                defaultExt,
                (String) wiz.getProperty(CND_UNITTEST_DEFAULT_NAME));
      } else {
        targetChooserDescriptorPanel = getWizard().targetChooser();
      }
    }
    @SuppressWarnings("unchecked")
    Panel<WizardDescriptor>[] panels = new WizardDescriptor.Panel[] {targetChooserDescriptorPanel};
    return panels;
  }
コード例 #11
0
ファイル: Utils.java プロジェクト: JSansalone/NetBeansIDE
 /**
  * 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);
     }
   }
 }
コード例 #12
0
 @Override
 public void showCustomizer() {
   Dialog dialog =
       ProjectCustomizer.createCustomizerDialog(
           // Path to layer folder:
           CUSTOMIZER_FOLDER_PATH,
           // Lookup, which must contain, at least, the Project:
           Lookups.fixed(project),
           // Preselected category:
           "",
           // OK button listener:
           new OKOptionListener(),
           // HelpCtx for Help button of dialog:
           null);
   dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName());
   dialog.setVisible(true);
 }
コード例 #13
0
 private static FileObject findProjectDir(
     Project project, SonarQubeProjectConfiguration projectConfiguration, String key)
     throws MvnModelInputException {
   if (projectConfiguration.getKey().toString().equals(key)) {
     return project.getProjectDirectory();
   }
   Set<Project> subprojects = ProjectUtils.getContainedProjects(project, true);
   if (subprojects != null) {
     for (Project subproject : subprojects) {
       SonarQubeProjectConfiguration subprojectInfo =
           SonarQubeProjectBuilder.getSubconfiguration(projectConfiguration, subproject);
       if (subprojectInfo.getKey().toString().equals(key)) {
         return subproject.getProjectDirectory();
       }
     }
   }
   return null;
 }
コード例 #14
0
 public File getFile(Project parentProject, SonarQubeProjectConfiguration projectConfiguration)
     throws MvnModelInputException {
   Project projectOwner = getProjectOwner(parentProject, projectConfiguration);
   if (projectOwner == null) {
     throw new ProjectNotFoundException(getShortProjectKey());
   }
   File file;
   String path = getPath();
   if (path.contains("/")) {
     /* It's a relative file path*/
     file = new File(projectOwner.getProjectDirectory().getPath(), path);
   } else {
     /* It's an element name. Assume is a java file */
     String filePath = path.replace(".", "/") + DEFAULT_EXTENSION;
     Sources sources = ProjectUtils.getSources(projectOwner);
     SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
     file = new File(sourceGroups[0].getRootFolder().getPath(), filePath);
   }
   return file;
 }
コード例 #15
0
ファイル: Utils.java プロジェクト: JSansalone/NetBeansIDE
 /**
  * @return <code>true</code> if
  *     <ul>
  *       <li>the project != null and
  *       <li>the project contains at least one CVS versioned source group
  *     </ul>
  *     otherwise <code>false</code>.
  * @param checkStatus if set to true, cache.getStatus is called and can take significant amount of
  *     time
  */
 public static boolean isVersionedProject(Project project, boolean checkStatus) {
   if (project != null) {
     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];
       File f = FileUtil.toFile(sourceGroup.getRootFolder());
       if (f != null) {
         if (checkStatus
             && (cache.getStatus(f).getStatus() & FileInformation.STATUS_MANAGED) != 0) {
           return true;
         } else if (!checkStatus && CvsVersioningSystem.isManaged(f)) {
           return true;
         }
       }
     }
   }
   return false;
 }
 public List getConfigFiles() {
   //        System.out.println("BuildConfigurationManager#getConfigFiles");
   ArrayList arraylist = new ArrayList();
   // arraylist.add("<all project files>");
   Repository repository = null;
   Project project = OpenProjects.getDefault().getMainProject();
   if (project == null) {
     Ajde.getDefault().getErrorHandler().handleWarning("Please set a project as main project");
     return arraylist;
   }
   SourceGroup[] sourceGroups =
       ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
   for (SourceGroup sourceGroup : sourceGroups) {
     arraylist.addAll(
         getLstFilesInDir(FileUtil.toFile(sourceGroup.getRootFolder()).getAbsolutePath()));
   }
   if (arraylist.size() == 0)
     Ajde.getDefault()
         .getErrorHandler()
         .handleWarning("Could not find any \".lst\" in the main project.");
   return arraylist;
 }
コード例 #17
0
  void read(WizardDescriptor settings) {
    //        jsfFolder.setText((String) settings.getProperty(WizardProperties.JSF_FOLDER));

    project = Templates.getProject(settings);
    FileObject targetFolder = Templates.getTargetFolder(settings);

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

    SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project);
    SourceGroupUISupport.connect(locationComboBox, sourceGroups);

    packageComboBox.setRenderer(PackageView.listRenderer());

    updateSourceGroupPackages();

    // set default source group and package cf. targetFolder
    //        if (targetFolder != null) {
    //            SourceGroup targetSourceGroup =
    // SourceGroupSupport.getFolderSourceGroup(sourceGroups, targetFolder);
    //            if (targetSourceGroup != null) {
    //                locationComboBox.setSelectedItem(targetSourceGroup);
    //                String targetPackage =
    // SourceGroupSupport.getPackageForFolder(targetSourceGroup, targetFolder);
    //                if (targetPackage != null) {
    //                    packageComboBoxEditor.setText(targetPackage);
    //                }
    //            }
    //            if (FileUtil.isParentOf(WebModule.getWebModule(
    //                    targetFolder).getDocumentBase(), targetFolder)) {
    //                Sources s = (Sources)
    // Templates.getProject(wizard).getLookup().lookup(Sources.class);
    //                SourceGroup[] groups = s.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
    //
    // jsfFolder.setText("/"+JSFConfigUtilities.getResourcePath(groups,targetFolder,'/',true));
    //            }
    //        }
  }
コード例 #18
0
  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);
                          }
                        }
                      }
                    }
                  }
                }
              });
    }
  }
コード例 #19
0
 public static ComboBoxModel getPackageComboModel(Project project) {
   return PackageView.createListView(
       (org.netbeans.api.project.ProjectUtils.getSources(project))
           .getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)[0]);
 }