Skip to content

Commit 789390d

Browse files
committed
Fix deprecated API issues
1 parent b66a5b7 commit 789390d

File tree

9 files changed

+26
-197
lines changed

9 files changed

+26
-197
lines changed

src/com/intellij/ide/scratch/NewZenUmlBufferAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.intellij.ide.scratch;
22

33
import com.intellij.lang.Language;
4-
import com.intellij.lang.StdLanguages;
54
import com.intellij.openapi.actionSystem.AnActionEvent;
5+
import com.intellij.openapi.fileTypes.PlainTextLanguage;
66
import com.intellij.openapi.project.DumbAwareAction;
77
import com.intellij.openapi.project.Project;
88
import com.intellij.openapi.util.registry.Registry;
@@ -70,6 +70,6 @@ public void actionPerformed(@NotNull AnActionEvent e) {
7070

7171
private Language getLanguage() {
7272
Language zenUML = Language.findLanguageByID("ZenUML");
73-
return zenUML != null ? zenUML : StdLanguages.TEXT;
73+
return zenUML != null ? zenUML : PlainTextLanguage.INSTANCE;
7474
}
7575
}

src/org/intellij/plugins/markdown/injection/LanguageGuesser.java

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/org/intellij/plugins/markdown/settings/ZenUmlApplicationSettings.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.intellij.plugins.markdown.settings;
22

3-
import com.intellij.ide.ui.LafManager;
3+
import com.intellij.ide.ui.LafManagerListener;
4+
import com.intellij.openapi.Disposable;
45
import com.intellij.openapi.application.ApplicationManager;
56
import com.intellij.openapi.components.PersistentStateComponent;
67
import com.intellij.openapi.components.ServiceManager;
@@ -23,13 +24,15 @@
2324
)
2425
public class ZenUmlApplicationSettings implements PersistentStateComponent<ZenUmlApplicationSettings.State>,
2526
MarkdownCssSettings.Holder,
26-
MarkdownPreviewSettings.Holder {
27+
MarkdownPreviewSettings.Holder, Disposable {
2728

2829
private final State myState = new State();
2930

3031
public ZenUmlApplicationSettings() {
3132
final MarkdownLAFListener lafListener = new MarkdownLAFListener();
32-
LafManager.getInstance().addLafManagerListener(lafListener);
33+
ApplicationManager
34+
.getApplication().getMessageBus().connect(this)
35+
.subscribe(LafManagerListener.TOPIC, lafListener);
3336
// Let's init proper CSS scheme
3437
ApplicationManager.getApplication().invokeLater(() -> lafListener.updateCssSettingsForced(UIUtil.isUnderDarcula()));
3538
}
@@ -90,6 +93,10 @@ public boolean isDisableInjections() {
9093
return myState.myDisableInjections;
9194
}
9295

96+
@Override
97+
public void dispose() {
98+
}
99+
93100

94101
public static class State {
95102
@Property(surroundWithTag = false)

src/org/intellij/plugins/markdown/ui/preview/MarkdownPreviewFileEditor.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public class MarkdownPreviewFileEditor extends UserDataHolderBase implements Fil
4545

4646
private final static long RENDERING_DELAY_MS = 20L;
4747

48-
final static NotNullLazyValue<PolicyFactory> SANITIZER_VALUE = new NotNullLazyValue<PolicyFactory>() {
49-
@NotNull
50-
@Override
51-
protected PolicyFactory compute() {
48+
final static NotNullLazyValue<PolicyFactory> SANITIZER_VALUE = NotNullLazyValue.lazy(() -> {
5249
return Sanitizers.BLOCKS
5350
.and(Sanitizers.FORMATTING)
5451
.and(new HtmlPolicyBuilder()
@@ -74,8 +71,8 @@ protected PolicyFactory compute() {
7471
.allowAttributes(HtmlGenerator.Companion.getSRC_ATTRIBUTE_NAME()).globally()
7572
.allowAttributes("class").onElements("code", "tr", "span")
7673
.toFactory());
77-
}
78-
};
74+
});
75+
7976
@NotNull
8077
private final JPanel myHtmlPanelWrapper;
8178
@Nullable

src/org/intellij/plugins/markdown/ui/preview/MarkdownPreviewFileEditorProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.intellij.plugins.markdown.ui.preview;
22

3-
import com.intellij.ide.scratch.ScratchFileType;
3+
import com.intellij.ide.scratch.ScratchUtil;
44
import com.intellij.lang.LanguageUtil;
55
import com.intellij.openapi.fileEditor.FileEditor;
66
import com.intellij.openapi.fileEditor.FileEditorPolicy;
@@ -18,7 +18,7 @@ public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
1818
final FileType fileType = file.getFileType();
1919

2020
return (fileType == ZenUmlFileType.INSTANCE ||
21-
fileType == ScratchFileType.INSTANCE && LanguageUtil.getLanguageForPsi(project, file) == ZenUmlLanguage.INSTANCE) &&
21+
ScratchUtil.isScratch(file) && LanguageUtil.getLanguageForPsi(project, file) == ZenUmlLanguage.INSTANCE) &&
2222
MarkdownHtmlPanelProvider.hasAvailableProviders();
2323
}
2424

src/org/intellij/plugins/markdown/ui/preview/MarkdownSplitEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void navigateTo(@NotNull Navigatable navigatable) {
6969
@Override
7070
@NotNull
7171
public VirtualFile getFile() {
72-
return FILE_KEY.get(this);
72+
return getMainEditor().getFile();
7373
}
7474

7575
public boolean isAutoScrollPreview() {

src/org/intellij/plugins/markdown/ui/preview/javafx/JavaFXInstallator.java

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/org/intellij/plugins/markdown/ui/preview/javafx/MarkdownJavaFxHtmlPanel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.zenuml.sequence.plugins.jetbrains.html.ZenUmlHtmlGenerator;
77
import org.apache.commons.io.FileUtils;
88
import org.intellij.plugins.markdown.html.AddProtocolAndHost;
9+
import org.intellij.plugins.markdown.settings.ZenUmlApplicationSettings;
910
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanel;
1011
import org.intellij.plugins.markdown.ui.preview.PreviewStaticServer2;
1112
import org.jetbrains.annotations.NotNull;
@@ -24,6 +25,7 @@ public class MarkdownJavaFxHtmlPanel extends JCEFHtmlPanel implements MarkdownHt
2425

2526
public MarkdownJavaFxHtmlPanel() {
2627
super(null);
28+
2729
String resource = "/html/zenuml/index.html";
2830
InputStream inputStream = this.getClass().getResourceAsStream(resource);
2931
if (inputStream == null) {

src/org/intellij/sequencer/SequencePlugin2.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ private String generateZenUML(PsiMethod psiMethod) {
139139
private void createZenUMLScratch(String dsl, AnActionEvent event) {
140140
NewZenUmlBufferAction newBufferAction = new NewZenUmlBufferAction();
141141

142-
HashMap<String, Object> map = new HashMap<>();
143-
map.put(CommonDataKeys.PROJECT.getName(), event.getData(CommonDataKeys.PROJECT));
144-
map.put(LangDataKeys.IDE_VIEW.getName(), event.getData(LangDataKeys.IDE_VIEW));
145-
map.put(PlatformDataKeys.PREDEFINED_TEXT.getName(), dsl);
142+
DataContext context = SimpleDataContext.builder()
143+
.add(CommonDataKeys.PROJECT, event.getData(CommonDataKeys.PROJECT))
144+
.add(LangDataKeys.IDE_VIEW, event.getData(LangDataKeys.IDE_VIEW))
145+
.add(PlatformDataKeys.PREDEFINED_TEXT, dsl)
146+
.build();
146147
AnActionEvent anActionEvent = AnActionEvent.createFromAnAction(newBufferAction,
147148
null,
148149
event.getPlace(),
149-
SimpleDataContext.getSimpleContext(map, null));
150+
context);
150151
newBufferAction.actionPerformed(anActionEvent);
151152
}
152153

0 commit comments

Comments
 (0)