Search in sources :

Example 1 with EmptyRunnable

use of com.intellij.openapi.util.EmptyRunnable in project intellij-community by JetBrains.

the class SvnPropertiesDiffViewer method performRediff.

@NotNull
@Override
protected Runnable performRediff(@NotNull ProgressIndicator indicator) {
    if (!myFirstRediff)
        return new EmptyRunnable();
    myFirstRediff = false;
    for (DiffChange change : myDiffChanges) {
        PropertyRecord record = change.getRecord();
        String before = record.getBefore();
        String after = record.getAfter();
        assert before != null || after != null;
        if (before == null) {
            change.setFragments(createEverythingChanged(0, after.length(), 0, StringUtil.countNewLines(after) + 1));
            continue;
        }
        if (after == null) {
            change.setFragments(createEverythingChanged(before.length(), 0, StringUtil.countNewLines(before) + 1, 0));
            continue;
        }
        try {
            ComparisonManager manager = ComparisonManager.getInstance();
            change.setFragments(manager.squash(manager.compareLinesInner(before, after, ComparisonPolicy.DEFAULT, indicator)));
        } catch (DiffTooBigException e) {
            change.setFragments(createEverythingChanged(before.length(), after.length(), StringUtil.countNewLines(before) + 1, StringUtil.countNewLines(after) + 1));
        }
    }
    return () -> {
        for (DiffChange change : myDiffChanges) {
            setupHighlighting(change, Side.LEFT);
            setupHighlighting(change, Side.RIGHT);
        }
    };
}
Also used : ComparisonManager(com.intellij.diff.comparison.ComparisonManager) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) DiffTooBigException(com.intellij.diff.comparison.DiffTooBigException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with EmptyRunnable

use of com.intellij.openapi.util.EmptyRunnable in project intellij-community by JetBrains.

the class PutSourceItemIntoParentAndLinkViaManifestAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final List<PackagingSourceItem> items = mySourceItemsTree.getSelectedItems();
    ParentElementsInfo parentsInfo = findParentAndGrandParent(myArtifactEditor.getArtifact());
    if (parentsInfo == null) {
        return;
    }
    final Artifact artifact = parentsInfo.getGrandparentArtifact();
    final ArtifactEditorContext context = myArtifactEditor.getContext();
    //todo[nik] improve
    final Runnable emptyRunnable = EmptyRunnable.getInstance();
    context.editLayout(artifact, emptyRunnable);
    context.editLayout(parentsInfo.getParentArtifact(), emptyRunnable);
    //find elements under modifiable root
    parentsInfo = findParentAndGrandParent(myArtifactEditor.getArtifact());
    if (parentsInfo == null) {
        return;
    }
    final CompositePackagingElement<?> grandParent = parentsInfo.getGrandparentElement();
    final List<String> classpath = new ArrayList<>();
    context.editLayout(artifact, () -> {
        for (PackagingSourceItem item : items) {
            final List<? extends PackagingElement<?>> elements = item.createElements(context);
            grandParent.addOrFindChildren(elements);
            classpath.addAll(ManifestFileUtil.getClasspathForElements(elements, context, artifact.getArtifactType()));
        }
    });
    final ArtifactEditor parentArtifactEditor = context.getOrCreateEditor(parentsInfo.getParentArtifact());
    parentArtifactEditor.addToClasspath(parentsInfo.getParentElement(), classpath);
    ((ArtifactEditorImpl) context.getOrCreateEditor(parentsInfo.getGrandparentArtifact())).rebuildTries();
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) ArtifactEditor(com.intellij.packaging.ui.ArtifactEditor) ArrayList(java.util.ArrayList) Artifact(com.intellij.packaging.artifacts.Artifact) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) ArtifactEditorImpl(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorImpl) ArtifactEditorContext(com.intellij.packaging.ui.ArtifactEditorContext)

Aggregations

EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)2 ComparisonManager (com.intellij.diff.comparison.ComparisonManager)1 DiffTooBigException (com.intellij.diff.comparison.DiffTooBigException)1 ArtifactEditorImpl (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorImpl)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ArtifactEditor (com.intellij.packaging.ui.ArtifactEditor)1 ArtifactEditorContext (com.intellij.packaging.ui.ArtifactEditorContext)1 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1