Browse Source

Everywhere: Remove usage of internal API DefaultLookup.

pull/245/head
weisj 4 years ago
parent
commit
db7d560871
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 24
      core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java
  2. 10
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java
  4. 11
      core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java
  5. 7
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  6. 16
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  7. 6
      core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java

24
core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java

@ -1,8 +1,30 @@
/*
* MIT License
*
* Copyright (c) 2021 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;
import javax.swing.Action;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
public abstract class UIAction implements Action {
private final String name;

10
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java

@ -36,11 +36,9 @@ import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicListUI;
import javax.swing.text.Position;
import sun.swing.DefaultLookup;
import com.github.weisj.darklaf.ui.UIAction;
import com.github.weisj.darklaf.ui.BasicTransferable;
import com.github.weisj.darklaf.ui.DragRecognitionSupport;
import com.github.weisj.darklaf.ui.UIAction;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import com.github.weisj.darklaf.util.PropertyKey;
@ -615,11 +613,11 @@ public abstract class DarkListUIBridge extends BasicListUI {
*/
InputMap getInputMap(final int condition) {
if (condition == JComponent.WHEN_FOCUSED) {
InputMap keyMap = (InputMap) DefaultLookup.get(list, this, "List.focusInputMap");
InputMap keyMap = (InputMap) UIManager.get("List.focusInputMap", list.getLocale());
InputMap rtlKeyMap;
if (isLeftToRight || ((rtlKeyMap =
(InputMap) DefaultLookup.get(list, this, "List.focusInputMap.RightToLeft")) == null)) {
(InputMap) UIManager.get("List.focusInputMap.RightToLeft", list.getLocale())) == null)) {
return keyMap;
} else {
rtlKeyMap.setParent(keyMap);
@ -1248,7 +1246,7 @@ public abstract class DarkListUIBridge extends BasicListUI {
return;
}
Color c = DefaultLookup.getColor(list, this, "List.dropLineColor", null);
Color c = UIManager.getColor("List.dropLineColor");
if (c != null) {
g.setColor(c);
Rectangle rect = getDropLineRect(loc);

2
core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java

@ -29,8 +29,8 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuItemUI;
import sun.swing.MenuItemLayoutHelper;
import com.github.weisj.darklaf.ui.UIAction;
import com.github.weisj.darklaf.ui.UIAction;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import com.github.weisj.darklaf.util.StringUtil;

11
core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java

@ -28,7 +28,6 @@ import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicOptionPaneUI;
import sun.swing.DefaultLookup;
public class DarkOptionPaneUI extends BasicOptionPaneUI {
@ -39,16 +38,16 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI {
@Override
protected Container createButtonArea() {
JPanel bottom = new JPanel();
Border border = (Border) DefaultLookup.get(optionPane, this, "OptionPane.buttonAreaBorder");
Border border = (Border) UIManager.get("OptionPane.buttonAreaBorder");
bottom.setName("OptionPane.buttonArea");
if (border != null) {
bottom.setBorder(border);
}
bottom.setLayout(new DarkButtonAreaLayout(
DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", false),
DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6),
DefaultLookup.getInt(optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER),
DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false)));
UIManager.getBoolean("OptionPane.sameSizeButtons"),
UIManager.getInt("OptionPane.buttonPadding"),
UIManager.getInt("OptionPane.buttonOrientation"),
UIManager.getBoolean("OptionPane.isYesLast")));
addButtonComponents(bottom, getButtons(), getInitialValueIndex());
return bottom;
}

7
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java

@ -683,12 +683,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
// center component
int x = outerX + (outerWidth - width) / 2;
int y = outerY + (outerHeight - height) / 2;
int tabPlacement = tabPane.getTabPlacement();
boolean isSeleceted = i == tabPane.getSelectedIndex();
c.setBounds(x + getTabLabelShiftX(tabPlacement, i, isSeleceted),
y + getTabLabelShiftY(tabPlacement, i, isSeleceted), width, height);
c.setBounds(x, y, width, height);
}
}

16
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

@ -39,9 +39,7 @@ import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import sun.swing.DefaultLookup;
import com.github.weisj.darklaf.ui.UIAction;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import com.github.weisj.darklaf.util.PropertyKey;
@ -659,7 +657,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
protected int getTabLabelShiftX(final int tabPlacement, final int tabIndex, final boolean isSelected) {
Rectangle tabRect = rects[tabIndex];
String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
int nudge = DefaultLookup.getInt(tabPane, this, "TabbedPane." + propKey, 1);
int nudge = UIManager.getInt("TabbedPane." + propKey);
switch (tabPlacement) {
case LEFT:
@ -683,8 +681,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
*/
protected int getTabLabelShiftY(final int tabPlacement, final int tabIndex, final boolean isSelected) {
Rectangle tabRect = rects[tabIndex];
int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1)
: DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1));
int nudge = (isSelected ? UIManager.getInt("TabbedPane.selectedLabelShift")
: UIManager.getInt("TabbedPane.labelShift"));
switch (tabPlacement) {
case BOTTOM:
@ -857,9 +855,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
*/
InputMap getInputMap(final int condition) {
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
return (InputMap) DefaultLookup.get(tabPane, this, "TabbedPane.ancestorInputMap");
return (InputMap) UIManager.get("TabbedPane.ancestorInputMap", tabPane.getLocale());
} else if (condition == JComponent.WHEN_FOCUSED) {
return (InputMap) DefaultLookup.get(tabPane, this, "TabbedPane.focusInputMap");
return (InputMap) UIManager.get("TabbedPane.focusInputMap", tabPane.getLocale());
}
return null;
}
@ -1509,7 +1507,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
*/
protected void navigateSelectedTab(final int direction) {
int tabPlacement = tabPane.getTabPlacement();
int current = DefaultLookup.getBoolean(tabPane, this, "TabbedPane.selectionFollowsFocus", true)
int current = !Boolean.FALSE.equals(UIManager.get("TabbedPane.selectionFollowsFocus"))
? tabPane.getSelectedIndex()
: getFocusIndex();
int tabCount = tabPane.getTabCount();
@ -1682,7 +1680,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
* @param index the index
*/
protected void navigateTo(final int index) {
if (DefaultLookup.getBoolean(tabPane, this, "TabbedPane.selectionFollowsFocus", true)) {
if (!Boolean.FALSE.equals(UIManager.get("TabbedPane.selectionFollowsFocus"))) {
tabPane.setSelectedIndex(index);
} else {
// Just move focus (not selection)

6
core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java

@ -37,8 +37,6 @@ import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import sun.swing.DefaultLookup;
import com.github.weisj.darklaf.ui.DragRecognitionSupport;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
@ -179,11 +177,11 @@ public abstract class TableUIBridge extends BasicTableUI {
*/
InputMap getInputMap(final int condition) {
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
InputMap keyMap = (InputMap) DefaultLookup.get(table, this, "Table.ancestorInputMap");
InputMap keyMap = (InputMap) UIManager.get("Table.ancestorInputMap", table.getLocale());
InputMap rtlKeyMap;
if (table.getComponentOrientation().isLeftToRight() || ((rtlKeyMap =
(InputMap) DefaultLookup.get(table, this, "Table.ancestorInputMap.RightToLeft")) == null)) {
(InputMap) UIManager.get("Table.ancestorInputMap.RightToLeft", table.getLocale())) == null)) {
return keyMap;
} else {
rtlKeyMap.setParent(keyMap);

Loading…
Cancel
Save