Examples of HitContainer


Examples of org.opensolaris.opengrok.egrok.model.HitContainer

  public Map<String, HitContainer> getHits() {
    return contentProvider.getHits();
  }

  private IEditorPart open(Hit hit) {
    HitContainer container = hit.getContainer();
    IFile correspondingFile = container.getCorrespondingFile();

    if (correspondingFile != null) {
      IEditorPart editor = openInEditor(correspondingFile,
          findEditor(hit.getContainer()));
View Full Code Here

Examples of org.opensolaris.opengrok.egrok.model.HitContainer

        result.append(before, courierNewGrey);
        result.append(term, courierNew);
        result.append(after, courierNewGrey);
        return result;
      } else if (element instanceof HitContainer) {
        HitContainer container = (HitContainer) element;
        StyledString result = new StyledString();

        IFile file = container.getCorrespondingFile();
        if (file != null) {
          String project = file.getProject().getName();

          result.append(project + "/");
          result.append(file.getProjectRelativePath().toString());

        } else {

          String name = container.getName();
          String fileName = name.substring(name.lastIndexOf('/') + 1);
          result.append(name.substring(0, name.lastIndexOf('/') + 1),
              StyledString.COUNTER_STYLER);
          result.append(fileName);
        }
        result.append(" (" + container.getNumberOfHits() + ")",
            StyledString.DECORATIONS_STYLER);
        return result;

      }
View Full Code Here

Examples of org.opensolaris.opengrok.egrok.model.HitContainer

    }

    @Override
    public Image getImage(Object element) {
      if (element instanceof HitContainer) {
        HitContainer container = (HitContainer) element;
        return findEditor(container).getImageDescriptor().createImage();
      }
      return super.getImage(element);
    }
View Full Code Here

Examples of org.opensolaris.opengrok.egrok.model.HitContainer

    final Map<String, HitContainer> roots = new HashMap<String, HitContainer>();

    for (Hit hit : results) {
      String key = hit.getDirectory() + "/" + hit.getFilename();

      HitContainer container = roots.get(key);
      if (container == null) {
        container = new HitContainer(key);
        roots.put(key, container);
      }
      container.add(hit);
    }

    viewer.setHits(roots);

    if (resultsView != null) {
      resultsView.setHits(roots);
    }

    Display.getDefault().asyncExec(new Runnable() {
      @Override
      public void run() {
        if (!viewer.getControl().isDisposed()) {
          viewer.refresh();
        }
      }
    });

    if (Activator.getDefault().getPreferenceStore()
        .getBoolean(EGrokPreferencePage.WORKSPACE_MATCHES)) {

      Runnable workspaceLocator = new Runnable() {
        @Override
        public void run() {
          IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
              .getRoot();
          final Map<HitContainer, HashMap<IProject, Integer>> potentialProjects = new HashMap<HitContainer, HashMap<IProject, Integer>>();

          final Map<IProject, ArrayList<String>> locationSegments = new HashMap<IProject, ArrayList<String>>();

          try {
            workspaceRoot.accept(new IResourceVisitor() {
              @Override
              public boolean visit(IResource resource) throws CoreException {
                if (resource instanceof IWorkspaceRoot) {
                  return true;
                }
                if (resource instanceof IProject) {
                  IProject project = (IProject) resource;

                  IPath location = project.getLocation();

                  for (String segment : location.segments()) {
                    ArrayList<String> segments = locationSegments.get(project);
                    if (segments == null) {
                      segments = new ArrayList<String>();
                      locationSegments.put(project, segments);
                    }
                    segments.add(segment);
                  }
                }
                return false;
              }

            });
          } catch (CoreException e) {
            e.printStackTrace();
          }

          Map<HitContainer, ArrayList<String>> hitcontainerSegments = new HashMap<HitContainer, ArrayList<String>>();

          for (HitContainer hitcontainer : roots.values()) {
            ArrayList<String> segments = new ArrayList<String>();

            for (String segment : hitcontainer.getName().split("/")) {
              segments.add(segment);
            }

            hitcontainerSegments.put(hitcontainer, segments);
          }

          for (IProject project : locationSegments.keySet()) {
            ArrayList<String> segments = locationSegments.get(project);
            int idx = 0;
            for (String segment : segments) {
              for (HitContainer container : hitcontainerSegments.keySet()) {

                for (String containerPathSegment : hitcontainerSegments
                    .get(container)) {
                  if (segment.equals(containerPathSegment)) {
                    HashMap<IProject, Integer> matches = potentialProjects
                        .get(container);

                    if (matches == null) {
                      matches = new HashMap<IProject, Integer>();
                      potentialProjects.put(container, matches);
                    }

                    matches.put(project, idx);
                  }
                }
              }
              idx++;
            }
          }

          for (HitContainer container : potentialProjects.keySet()) {
            String fullLocation = container.getName();
            HashMap<IProject, Integer> matches = potentialProjects
                .get(container);

            System.out.println(container.getName());
            for (Entry<IProject, Integer> match : matches.entrySet()) {
              IProject project = match.getKey();
              Integer matchingLocation = match.getValue();
              String matchingString = project.getLocation().segment(
                  matchingLocation);
              System.out.println("match: " + matchingString);

              String local = fullLocation.substring(fullLocation
                  .indexOf(matchingString) + matchingString.length());

              System.out.println("local: " + local);

              IResource member = project.findMember(local);
              System.out.println("member: " + member);

              if (member instanceof IFile) {
                IFile file = (IFile) member;

                container.setCorrespondingFile(file);
              }
            }
          }

          Display.getDefault().asyncExec(new Runnable() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.