mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: remove usage of deprecated API
This commit is contained in:
committed by
Aleksey Pivovarov
parent
5877b0c830
commit
4fd30ddb1b
+2
-2
@@ -51,6 +51,7 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings;
|
||||
@@ -108,8 +109,7 @@ class DiffPreviewPanel implements PreviewPanel {
|
||||
private final List<DiffContent> myContents;
|
||||
|
||||
public SampleRequest() {
|
||||
com.intellij.openapi.diff.DiffContent[] contents = DiffPreviewProvider.getContents();
|
||||
myContents = ContainerUtil.list(convert(contents[0]), convert(contents[1]), convert(contents[2]));
|
||||
myContents = Arrays.asList(DiffPreviewProvider.getContents());
|
||||
}
|
||||
|
||||
private static DiffContent convert(@NotNull com.intellij.openapi.diff.DiffContent content) {
|
||||
|
||||
+22
-6
@@ -16,12 +16,14 @@
|
||||
|
||||
package com.intellij.openapi.diff.impl.settings;
|
||||
|
||||
import com.intellij.openapi.diff.DiffContent;
|
||||
import com.intellij.openapi.diff.SimpleContent;
|
||||
import com.intellij.diff.DiffContentFactory;
|
||||
import com.intellij.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
@@ -30,19 +32,33 @@ import org.jetbrains.annotations.NonNls;
|
||||
public abstract class DiffPreviewProvider {
|
||||
public static final ExtensionPointName<DiffPreviewProvider> EP_NAME = ExtensionPointName.create("com.intellij.diffPreviewProvider");
|
||||
|
||||
@NotNull
|
||||
public abstract DiffContent[] createContents();
|
||||
|
||||
@NotNull
|
||||
public static DiffContent[] getContents() {
|
||||
// Assuming that standalone IDE should provide one provider
|
||||
final DiffPreviewProvider[] providers = Extensions.getExtensions(EP_NAME);
|
||||
if (providers.length != 0){
|
||||
if (providers.length != 0) {
|
||||
return providers[0].createContents();
|
||||
}
|
||||
return new DiffContent[]{createContent(LEFT_TEXT), createContent(CENTER_TEXT), createContent(RIGHT_TEXT)};
|
||||
return createContent(LEFT_TEXT, CENTER_TEXT, RIGHT_TEXT, StdFileTypes.JAVA);
|
||||
}
|
||||
|
||||
private static SimpleContent createContent(String text) {
|
||||
return new SimpleContent(text, StdFileTypes.JAVA);
|
||||
@NotNull
|
||||
public static DiffContent[] createContent(@NotNull String left,
|
||||
@NotNull String center,
|
||||
@NotNull String right,
|
||||
@NotNull FileType fileType) {
|
||||
return new DiffContent[]{
|
||||
createContent(left, StdFileTypes.JAVA),
|
||||
createContent(center, StdFileTypes.JAVA),
|
||||
createContent(right, StdFileTypes.JAVA)};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DiffContent createContent(@NotNull String text, @NotNull FileType fileType) {
|
||||
return DiffContentFactory.getInstance().create(text, fileType);
|
||||
}
|
||||
|
||||
@NonNls private static final String LEFT_TEXT = "class MyClass {\n" +
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="diff-api" />
|
||||
</component>
|
||||
</module>
|
||||
+4
-7
@@ -15,23 +15,20 @@
|
||||
*/
|
||||
package com.jetbrains.python.configuration;
|
||||
|
||||
import com.intellij.openapi.diff.DiffContent;
|
||||
import com.intellij.openapi.diff.SimpleContent;
|
||||
import com.intellij.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.diff.impl.settings.DiffPreviewProvider;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
*/
|
||||
public class PyDiffPreviewProvider extends DiffPreviewProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public DiffContent[] createContents() {
|
||||
return new DiffContent[]{createContent(LEFT_TEXT), createContent(CENTER_TEXT), createContent(RIGHT_TEXT)};
|
||||
}
|
||||
|
||||
private static SimpleContent createContent(final String text) {
|
||||
return new SimpleContent(text, PythonFileType.INSTANCE);
|
||||
return createContent(LEFT_TEXT, CENTER_TEXT, RIGHT_TEXT, PythonFileType.INSTANCE);
|
||||
}
|
||||
|
||||
@NonNls private static final String LEFT_TEXT = "class MyClass\n" +
|
||||
|
||||
Reference in New Issue
Block a user