Esempio n. 1
0
 public static DiffButtonsPainter addTo(
     RootDifferenceDialog dialog,
     DiffEditor diffEditor,
     ChangeGroupLayout changeGroupLayout,
     boolean inspector) {
   EditorComponent editorComponent = diffEditor.getEditorComponent(inspector);
   DiffButtonsPainter painter = new DiffButtonsPainter(dialog, editorComponent, changeGroupLayout);
   editorComponent.getLeftEditorHighlighter().addFoldingAreaPainter(painter);
   return painter;
 }
Esempio n. 2
0
 @Nullable
 private static AnnotationColumn findAnnotationColumn(@NotNull EditorComponent editorComponent) {
   for (AbstractLeftColumn column :
       ListSequence.fromList(editorComponent.getLeftEditorHighlighter().getLeftColumns())) {
     if (column instanceof AnnotationColumn) {
       return ((AnnotationColumn) column);
     }
   }
   return null;
 }
 private void clearAllEditors() {
   List<EditorComponent> allEditorComponents =
       EditorComponentUtil.getAllEditorComponents(myFileEditorManager, true);
   for (EditorComponent component : allEditorComponents) {
     component.getLeftEditorHighlighter().removeAllIconRenderers(BreakpointIconRenderrer.TYPE);
     List<AdditionalPainter> additionalPainters = component.getAdditionalPainters();
     for (AdditionalPainter painter : additionalPainters) {
       if (painter instanceof BreakpointPainter) {
         component.removeAdditionalPainter(painter);
       }
     }
   }
 }
Esempio n. 4
0
  private static boolean annotate(@NotNull final EditorComponent editorComponent, boolean dryRun) {
    final LeftEditorHighlighter leftEditorHighlighter = editorComponent.getLeftEditorHighlighter();
    if (findAnnotationColumn(editorComponent) != null) {
      if (!(dryRun)) {
        leftEditorHighlighter.removeLeftColumn(findAnnotationColumn(editorComponent));
      }
      return true;
    }
    final SNode root = editorComponent.getEditedNode();
    SModel model = check_19hp0u_a0d0b(root);
    SModelDescriptor modelDescriptor = check_19hp0u_a0e0b(model);
    if (!((modelDescriptor instanceof EditableSModelDescriptor))) {
      return false;
    }
    IFile modelFile = ((EditableSModelDescriptor) modelDescriptor).getModelFile();
    if (modelFile == null) {
      return false;
    }
    final VirtualFile file = VirtualFileUtils.getVirtualFile(modelFile);
    final Project project =
        ProjectHelper.toIdeaProject(editorComponent.getOperationContext().getProject());
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (vcs == null) {
      return false;
    }

    _FunctionTypes._return_P1_E0<? extends Boolean, ? super FileStatus> checkFileStatus =
        new _FunctionTypes._return_P1_E0<Boolean, FileStatus>() {
          public Boolean invoke(FileStatus fs) {
            return fs == FileStatus.UNKNOWN || fs == FileStatus.ADDED || fs == FileStatus.IGNORED;
          }
        };
    if (checkFileStatus.invoke(FileStatusManager.getInstance(project).getStatus(file))) {
      return false;
    }

    final AnnotationProvider annotationProvider = vcs.getAnnotationProvider();
    if (annotationProvider == null) {
      return false;
    }

    if (dryRun) {
      return true;
    }
    Task.Backgroundable annotateTask =
        new Task.Backgroundable(
            project, "Retrieving annotations", true, BackgroundFromStartOption.getInstance()) {
          private FileAnnotation myFileAnnotation;
          private VcsException myException;

          public void run(@NotNull ProgressIndicator indicator) {
            try {
              myFileAnnotation = annotationProvider.annotate(file);
            } catch (VcsException e) {
              myException = e;
            }
          }

          @Override
          public void onCancel() {
            onSuccess();
          }

          @Override
          public void onSuccess() {
            if (myException != null) {
              AbstractVcsHelper.getInstance(project)
                  .showErrors(Arrays.asList(myException), "Exception on retrieving annotation");
            }

            if (myFileAnnotation != null) {
              ModelAccess.instance()
                  .runReadAction(
                      new Runnable() {
                        public void run() {
                          AnnotationColumn annotationColumn =
                              new AnnotationColumn(
                                  leftEditorHighlighter, root, myFileAnnotation, vcs, file);
                          leftEditorHighlighter.addLeftColumn(annotationColumn);
                        }
                      });
            }
          }
        };
    ProgressManager.getInstance().run(annotateTask);
    return true;
  }