From 5a7bd22a79197192d21b81bce3b523e96fcd26c1 Mon Sep 17 00:00:00 2001 From: weisj Date: Mon, 25 May 2020 00:13:00 +0200 Subject: [PATCH] Removed overriding of shared dummy ui. --- .../weisj/darklaf/ui/text/DarkTextPaneUI.java | 15 +++--- .../text/bridge/DarkEditorPaneUIBridge.java | 16 +++++- .../ui/text/bridge/DarkTextPaneUIBridge.java | 49 +++++++++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkTextPaneUIBridge.java diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java index ef4081e0..d7fad062 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java @@ -24,26 +24,25 @@ */ package com.github.weisj.darklaf.ui.text; -import java.awt.*; - import javax.swing.*; import javax.swing.plaf.ComponentUI; -import com.github.weisj.darklaf.ui.text.dummy.DummyTextPaneUI; +import com.github.weisj.darklaf.ui.text.bridge.DarkTextPaneUIBridge; /** * @author Jannis Weis */ -public class DarkTextPaneUI extends DarkEditorPaneUI { - - static { - basicEditorPaneUI = new DummyTextPaneUI(); - } +public class DarkTextPaneUI extends DarkTextPaneUIBridge { public static ComponentUI createUI(final JComponent c) { return new DarkTextPaneUI(); } + @Override + protected DarkCaret.CaretStyle getDefaultCaretStyle() { + return DarkCaret.CaretStyle.THICK_VERTICAL_LINE_STYLE; + } + @Override protected String getPropertyPrefix() { return "TextPane"; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java index 4172c601..d8bce34f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java @@ -42,19 +42,31 @@ import com.github.weisj.darklaf.util.PropertyKey; */ public abstract class DarkEditorPaneUIBridge extends DarkTextUI { - private static final DummyEditorPane editorPane = new DummyEditorPane(); - protected static DummyTextUIMethods basicEditorPaneUI = new DummyEditorPaneUI(); + private static final DummyEditorPane shareDummyEditorPane = new DummyEditorPane(); + private static final DummyTextUIMethods sharedDummyUI = new DummyEditorPaneUI(); + private DummyEditorPane editorPane; + private DummyTextUIMethods basicEditorPaneUI; private PropertyChangeListener propertyChangeListener; @Override public void installUI(final JComponent c) { + editorPane = createDummyEditorPane(); + basicEditorPaneUI = createDummyUI(); editorPane.setEditorPane((JEditorPane) c); basicEditorPaneUI.installUI(editorPane); super.installUI(c); updateDisplayProperties(); } + protected DummyTextUIMethods createDummyUI() { + return sharedDummyUI; + } + + protected DummyEditorPane createDummyEditorPane() { + return shareDummyEditorPane; + } + @Override protected void installListeners() { propertyChangeListener = editorPane.getPropertyChangeListener(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkTextPaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkTextPaneUIBridge.java new file mode 100644 index 00000000..7c271514 --- /dev/null +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkTextPaneUIBridge.java @@ -0,0 +1,49 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +package com.github.weisj.darklaf.ui.text.bridge; + +import javax.swing.*; + +import com.github.weisj.darklaf.ui.text.DarkEditorPaneUI; +import com.github.weisj.darklaf.ui.text.dummy.DummyEditorPane; +import com.github.weisj.darklaf.ui.text.dummy.DummyTextPaneUI; +import com.github.weisj.darklaf.ui.text.dummy.DummyTextUIMethods; + +/** + * @author Jannis Weis + */ +public abstract class DarkTextPaneUIBridge extends DarkEditorPaneUI { + + private static final DummyEditorPane sharedDummyTextPane = new DummyEditorPane(); + private static final DummyTextUIMethods sharedDummyUI = new DummyTextPaneUI(); + + protected DummyTextUIMethods createDummyUI() { + return sharedDummyUI; + } + + protected DummyEditorPane createDummyEditorPane() { + return sharedDummyTextPane; + } +}