Beispiel #1
0
 public static void openProject(Project p, Object caller, boolean setMain) {
   if (p == null) {
     return;
   }
   Project[] projects = new Project[] {p};
   OpenProjects.getDefault().open(projects, false);
   if (setMain) {
     OpenProjects.getDefault().setMainProject(p); // set as main project and expand
   }
   selectAndExpandProject(p);
 }
 private static File getDirectoryContainingMainProject() {
   Project project = OpenProjects.getDefault().getMainProject();
   if (project != null) {
     return new File(project.getProjectDirectory().getParent().getPath());
   } else {
     return null;
   }
 }
 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;
 }
Beispiel #4
0
 @Override
 public boolean closing() {
   boolean cleanupRequested = false;
   final ArrayList<Node> libNodes = new ArrayList<Node>(2);
   for (final Project p : OpenProjects.getDefault().getOpenProjects()) {
     final LibrarySupportProjectNode lspn = p.getLookup().lookup(LibrarySupportProjectNode.class);
     if (lspn != null) {
       final String path = FileUtil.toFile(p.getProjectDirectory()).getAbsolutePath();
       if (ModificationStore.getInstance()
           .anyModifiedInContext(path, ModificationStore.MOD_CHANGED)) {
         if (!cleanupRequested) {
           final int answer =
               JOptionPane.showConfirmDialog(
                   WindowManager.getDefault().getMainWindow(),
                   NbBundle.getMessage(
                       this.getClass(),
                       "Installer.closing().JOptionPane.confirmDialog.message"), // NOI18N
                   NbBundle.getMessage(
                       this.getClass(),
                       "Installer.closing().JOptionPane.confirmDialog.title"), // NOI18N
                   JOptionPane.YES_NO_CANCEL_OPTION,
                   JOptionPane.QUESTION_MESSAGE);
           if (answer == JOptionPane.CANCEL_OPTION) {
             return false;
           } else if (answer == JOptionPane.NO_OPTION) {
             return true;
           } else if (answer == JOptionPane.YES_OPTION) {
             cleanupRequested = true;
           }
         }
         libNodes.add(lspn);
       }
     }
   }
   // node list will have at least one entry
   return performDeploy(libNodes);
 }
Beispiel #5
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO implement action body

    Project op = OpenProjects.getDefault().getMainProject();
    if (op != null) {

      File var = new File(op.getProjectDirectory().getPath() + File.separator + "var");

      if (var.exists()) {
        File cache = new File(var.getPath() + File.separator + "cache");
        if (cache.exists()) {
          deleteChildren(cache);
        }
        File[] children = var.listFiles();
        for (int x = 0; x < children.length; x++) {
          File f = new File(children[x].getPath() + File.separator + "cache");
          if (f.exists()) {
            deleteChildren(f);
          }
        }
      }
    }
  }
  public void computeTypeNames(TypeProvider.Context context, TypeProvider.Result res) {
    isCanceled = false;
    String text = context.getText();
    SearchType searchType = context.getSearchType();

    //        boolean hasBinaryOpen = Lookup.getDefault().lookup(BinaryElementOpen.class) != null;
    final ClassIndex.NameKind nameKind;
    switch (searchType) {
      case EXACT_NAME:
        nameKind = ClassIndex.NameKind.SIMPLE_NAME;
        break;
      case CASE_INSENSITIVE_EXACT_NAME:
        nameKind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP;
        break;
      case PREFIX:
        nameKind = ClassIndex.NameKind.PREFIX;
        break;
      case CASE_INSENSITIVE_PREFIX:
        nameKind = ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX;
        break;
      case REGEXP:
        nameKind = ClassIndex.NameKind.REGEXP;
        break;
      case CASE_INSENSITIVE_REGEXP:
        nameKind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP;
        break;
      case CAMEL_CASE:
        nameKind = ClassIndex.NameKind.CAMEL_CASE;
        break;
      default:
        throw new RuntimeException("Unexpected search type: " + searchType); // NOI18N
    }

    long time = 0;

    long cp, gss, gsb, sfb, gtn, add, sort;
    cp = gss = gsb = sfb = gtn = add = sort = 0;

    Future<Project[]> openProjectsTask = OpenProjects.getDefault().openProjects();
    Project[] projs = new Project[0];
    try {
      projs = openProjectsTask.get();
    } catch (InterruptedException ex) {
      LOGGER.fine(ex.getMessage());
    } catch (ExecutionException ex) {
      LOGGER.fine(ex.getMessage());
    }

    if (cache == null) {
      Set<CacheItem> sources = new HashSet<CacheItem>();
      Set<FileObject> roots = new HashSet<FileObject>();
      for (Project project : projs) {
        if (!(project instanceof VisageProject)) continue;
        VisageProject jfxp = (VisageProject) project;
        ClassPath pcp = jfxp.getClassPathProvider().getProjectSourcesClassPath(ClassPath.SOURCE);

        for (FileObject root : pcp.getRoots()) {
          if (roots.add(root)) {
            ClassPath src =
                org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(root);
            ClasspathInfo ci = ClasspathInfo.create(EMPTY_CLASSPATH, EMPTY_CLASSPATH, src);
            if (isCanceled) return;

            sources.add(new CacheItem(root, ci, false));
          }
        }
      }

      if (isCanceled) return;
      cache = sources;
    }

    ArrayList<VisageTypeDescription> types = new ArrayList<VisageTypeDescription>();

    res.setMessage(null); // no startup scanning yet.

    final String textForQuery;
    switch (nameKind) {
      case REGEXP:
      case CASE_INSENSITIVE_REGEXP:
        //                text = removeNonJavaChars(text);
        String pattern =
            searchType == SearchType.CASE_INSENSITIVE_EXACT_NAME ? text : text + "*"; // NOI18N
        pattern = pattern.replace("*", ".*").replace('?', '.');
        textForQuery = pattern;
        break;
      default:
        textForQuery = text;
    }
    LOGGER.fine("Text For Query '" + textForQuery + "'.");

    for (final CacheItem ci : cache) {
      @SuppressWarnings("unchecked")
      final Set<ElementHandle<TypeElement>> names =
          ci.classpathInfo
              .getClassIndex()
              .getDeclaredTypes(
                  textForQuery,
                  nameKind,
                  EnumSet.of(
                      ci.isBinary
                          ? ClassIndex.SearchScope.DEPENDENCIES
                          : ClassIndex.SearchScope.SOURCE));
      for (ElementHandle<TypeElement> name : names) {
        VisageTypeDescription td = new VisageTypeDescription(ci, name);
        types.add(td);
        if (isCanceled) {
          return;
        }
      }
    }

    if (isCanceled) return;

    res.addResult(types);
  }
 public ProjectMediator() {
   this.openProjects = OpenProjects.getDefault();
   this.projectManager = ProjectManager.getDefault();
 }