Skip to content

Commit

Permalink
Merge pull request #206 from couchbaselabs/1.1.0_fix
Browse files Browse the repository at this point in the history
fixing jebrains plugin error
  • Loading branch information
deniswsrosa authored May 24, 2024
2 parents ce366f7 + 25ed1f8 commit 71e578c
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/main/java/com/couchbase/intellij/tree/iq/ui/HtmlPanel.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be
// found in the LICENSE file.
package com.couchbase.intellij.tree.iq.ui;

import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.ui.FontUtil;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.ColorUtil;
import com.intellij.util.ui.HTMLEditorKitBuilder;
Expand Down Expand Up @@ -55,39 +55,34 @@ public String getSelectedText() {
getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset());

return StringUtil.removeHtmlTags(sw.toString());
}
catch (BadLocationException | IOException ignored) {
} catch (BadLocationException | IOException ignored) {
}
return super.getSelectedText();
}

public void setBody(@NotNull @Nls String text) {
if (text.isEmpty()) {
setText("");
}
else {
@NlsSafe String cssFontDeclaration = UIUtil.getCssFontDeclaration(getBodyFont());
setText(new HtmlBuilder()
.append(HtmlChunk.raw(cssFontDeclaration).wrapWith("head"))
.append(HtmlChunk.raw(text).wrapWith(HtmlChunk.body()))
.wrapWith(HtmlChunk.html()).toString());
}
}

@NotNull
protected Font getBodyFont() {
return FontUtil.getCommitMessageFont();
return new Font("SansSerif", Font.PLAIN, 12);
}

@NotNull
@Nls
protected abstract String getBody();

public void setBody(@NotNull @Nls String text) {
if (text.isEmpty()) {
setText("");
} else {
@NlsSafe String cssFontDeclaration = UIUtil.getCssFontDeclaration(getBodyFont());
setText(new HtmlBuilder().append(HtmlChunk.raw(cssFontDeclaration).wrapWith("head")).append(HtmlChunk.raw(text).wrapWith(HtmlChunk.body())).wrapWith(HtmlChunk.html()).toString());
}
}

@Override
public void updateUI() {
super.updateUI();

DefaultCaret caret = (DefaultCaret)getCaret();
DefaultCaret caret = (DefaultCaret) getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

update();
Expand All @@ -103,7 +98,7 @@ public void update() {
private void customizeLinksStyle() {
Document document = getDocument();
if (document instanceof HTMLDocument) {
StyleSheet styleSheet = ((HTMLDocument)document).getStyleSheet();
StyleSheet styleSheet = ((HTMLDocument) document).getStyleSheet();
String linkColor = "#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.ENABLED); // NON-NLS
styleSheet.addRule("a { color: " + linkColor + "; text-decoration: none;}"); // NON-NLS
}
Expand Down

0 comments on commit 71e578c

Please sign in to comment.