Browse Source

Update for Java8

Signed-off-by: weisj <weisj@arcor.de>
pull/15/head v1.3.1.3
weisj 5 years ago
parent
commit
480e5f340f
  1. 5
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  2. 12
      src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java
  3. 14
      src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java
  4. 4
      src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java
  5. 1
      src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java
  6. 1
      src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java
  7. 4
      src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java
  8. 53
      src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java
  9. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll
  10. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.exp
  11. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.lib
  12. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll
  13. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.exp
  14. BIN
      src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.lib
  15. 2
      src/test/java/ColorChooserDemo.java
  16. 2
      src/test/java/SVGTest.java
  17. 5
      src/test/java/ScrollPaneDemo.java
  18. 2
      src/test/java/SplitPaneDemo.java
  19. 3
      src/test/java/TabFrameDemo.java
  20. 3
      src/test/java/TabbedPaneDemo.java
  21. 2
      src/test/java/UIDemo.java
  22. 2
      src/test/java/UIManagerDefaults.java

5
src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -47,6 +47,9 @@ import java.awt.event.KeyEvent;
*/
public class DarkColorChooserPanel extends AbstractColorChooserPanel implements ColorListener {
public static final String TRANSPARENCY_ENABLED_PROPERTY
= "TransparencyEnabled";
private final ColorPipette pipette;
private final ColorWheelPanel colorWheelPanel;
private final JFormattedTextField textHex;
@ -330,7 +333,6 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
return null;
}
@Override
public boolean isColorTransparencySelectionEnabled() {
return colorWheelPanel.isColorTransparencySelectionEnabled();
}
@ -356,7 +358,6 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
isChanging = false;
}
@Override
public void setColorTransparencySelectionEnabled(final boolean b) {
boolean oldValue = isColorTransparencySelectionEnabled();
if (b != oldValue) {

12
src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java

@ -126,10 +126,22 @@ public class DarkComboPopup extends BasicComboPopup {
hide();
} else if (lastEvent == 0 || (System.currentTimeMillis() - lastEvent) > 250) {
visible = true;
System.out.println("here");
SwingUtilities.invokeLater(this::show);
}
}
@Override
public void show() {
super.show();
}
@Override
public void hide() {
super.hide();
}
protected void reset() {
lastEvent = 0;
if (visible) {

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

@ -25,6 +25,7 @@ package com.github.weisj.darklaf.ui.list;
import com.github.weisj.darklaf.ui.BasicTransferable;
import com.github.weisj.darklaf.ui.DragRecognitionSupport;
import com.github.weisj.darklaf.util.DarkSwingUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import org.jetbrains.annotations.NotNull;
@ -243,8 +244,8 @@ public class DarkListUIBridge extends BasicListUI {
final Graphics g,
final int row,
final Rectangle rowBounds,
final ListCellRenderer<Object> cellRenderer,
final ListModel<Object> dataModel,
final ListCellRenderer cellRenderer,
final ListModel dataModel,
final ListSelectionModel selModel,
final int leadIndex) {
Object value = dataModel.getElementAt(row);
@ -769,7 +770,7 @@ public class DarkListUIBridge extends BasicListUI {
*
* @throws NullPointerException {@inheritDoc}
*/
public int locationToIndex(final JList<?> list, final Point location) {
public int locationToIndex(final JList list, final Point location) {
maybeUpdateLayoutState();
return convertLocationToModel(location.x, location.y);
}
@ -777,7 +778,7 @@ public class DarkListUIBridge extends BasicListUI {
/**
* {@inheritDoc}
*/
public Point indexToLocation(final JList<?> list, final int index) {
public Point indexToLocation(final JList list, final int index) {
maybeUpdateLayoutState();
Rectangle rect = getCellBounds(list, index, index);
@ -790,7 +791,7 @@ public class DarkListUIBridge extends BasicListUI {
/**
* {@inheritDoc}
*/
public Rectangle getCellBounds(final JList<?> list, final int index1, final int index2) {
public Rectangle getCellBounds(final JList list, final int index1, final int index2) {
maybeUpdateLayoutState();
int minIndex = Math.min(index1, index2);
@ -1962,7 +1963,7 @@ public class DarkListUIBridge extends BasicListUI {
updateLayoutStateNeeded |= cellRendererChanged;
redrawList();
} else if (Objects.equals(propertyName, "font")
|| SwingUtilities2.isScaleChanged(e)) {
|| DarkSwingUtil.isScaleChanged(e)) {
updateLayoutStateNeeded |= fontChanged;
redrawList();
} else if (Objects.equals(propertyName, "prototypeCellValue")) {
@ -2843,7 +2844,6 @@ public class DarkListUIBridge extends BasicListUI {
}
}
@Override
public boolean accept(final Object c) {
Object name = getName();
if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD ||

4
src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java

@ -23,9 +23,9 @@
*/
package com.github.weisj.darklaf.ui.tabbedpane;
import com.github.weisj.darklaf.util.DarkSwingUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -107,7 +107,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc
} else if (Objects.equals(name, "indexForNullComponent")) {
ui.isRunsDirty = true;
updateHtmlViews((Integer) e.getNewValue(), true);
} else if (Objects.equals(name, "font") || SwingUtilities2.isScaleChanged(e)) {
} else if (Objects.equals(name, "font") || DarkSwingUtil.isScaleChanged(e)) {
ui.calculatedBaseline = false;
}
}

1
src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java

@ -268,7 +268,6 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI {
super(name);
}
@Override
public boolean accept(final Object sender) {
if (sender instanceof JTableHeader) {
JTableHeader th = (JTableHeader) sender;

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

@ -1535,7 +1535,6 @@ public abstract class TableUIBridge extends TableUI {
}
}
@Override
public boolean accept(final Object sender) {
String key = getName();

4
src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -23,11 +23,11 @@
*/
package com.github.weisj.darklaf.ui.text;
import com.github.weisj.darklaf.util.DarkSwingUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import sun.awt.SunToolkit;
import sun.swing.DefaultLookup;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.plaf.ActionMapUIResource;
@ -192,7 +192,7 @@ public abstract class DarkTextUI extends BasicTextUI {
if (accelerator != '\0') {
km.put(KeyStroke.getKeyStroke(accelerator, getFocusAcceleratorKeyMask()), "requestFocus");
km.put(KeyStroke.getKeyStroke(accelerator,
SwingUtilities2.setAltGraphMask(getFocusAcceleratorKeyMask())),
DarkSwingUtil.setAltGraphMask(getFocusAcceleratorKeyMask())),
"requestFocus");
}
}

53
src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java

@ -0,0 +1,53 @@
/*
* 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.util;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.geom.AffineTransform;
import java.beans.PropertyChangeEvent;
import java.util.Objects;
public class DarkSwingUtil {
public static int setAltGraphMask(final int modifier) {
return (modifier | InputEvent.ALT_GRAPH_DOWN_MASK);
}
public static boolean isScaleChanged(final PropertyChangeEvent ev) {
return isScaleChanged(ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
}
public static boolean isScaleChanged(final String name, final Object oldValue, final Object newValue) {
if (oldValue != newValue && "graphicsConfiguration".equals(name)) {
GraphicsConfiguration newGC = (GraphicsConfiguration) oldValue;
GraphicsConfiguration oldGC = (GraphicsConfiguration) newValue;
AffineTransform newTx = newGC != null ? newGC.getDefaultTransform() : null;
AffineTransform oldTx = oldGC != null ? oldGC.getDefaultTransform() : null;
return !Objects.equals(newTx, oldTx);
} else {
return false;
}
}
}

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll

Binary file not shown.

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.exp

Binary file not shown.

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.lib

Binary file not shown.

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll

Binary file not shown.

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.exp

Binary file not shown.

BIN
src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.lib

Binary file not shown.

2
src/test/java/ColorChooserDemo.java

@ -9,7 +9,7 @@ public final class ColorChooserDemo {
SwingUtilities.invokeLater(() -> {
LafManager.install();
JColorChooser.showDialog(null, "Color Chooser with transparency",
Color.RED, true);
Color.RED);
});
}
}

2
src/test/java/SVGTest.java

@ -22,7 +22,7 @@ public class SVGTest {
JFrame frame = new JFrame();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
var svgPanel = new SVGPanel() {
SVGPanel svgPanel = new SVGPanel() {
};
frame.setContentPane(svgPanel);
svgPanel.setAntiAlias(true);

5
src/test/java/ScrollPaneDemo.java

@ -1,4 +1,5 @@
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.util.StringUtil;
import org.jdesktop.swingx.MultiSplitLayout;
import javax.swing.*;
@ -15,8 +16,8 @@ public final class ScrollPaneDemo extends MultiSplitLayout {
LafManager.install();
final JFrame frame = new JFrame();
frame.setSize(500, 500);
var overlayScroll = new JTextPane() {{
setText(TestResources.LOREM_IPSUM.repeat(10));
JTextPane overlayScroll = new JTextPane() {{
setText(StringUtil.repeat(TestResources.LOREM_IPSUM, 10));
setFont(Font.getFont(Font.MONOSPACED));
// setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
// SimpleAttributeSet attribs = new SimpleAttributeSet();

2
src/test/java/SplitPaneDemo.java

@ -10,7 +10,7 @@ public final class SplitPaneDemo {
LafManager.install();
final JFrame frame = new JFrame();
frame.setSize(500, 500);
var splitPane = new JSplitPane() {
JSplitPane splitPane = new JSplitPane() {
};
splitPane.setLeftComponent(new JPanel() {{
setBackground(Color.RED);

3
src/test/java/TabFrameDemo.java

@ -8,6 +8,7 @@ import com.github.weisj.darklaf.components.text.NonWrappingTextPane;
import com.github.weisj.darklaf.components.text.NumberedTextComponent;
import com.github.weisj.darklaf.components.text.NumberingPane;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -125,7 +126,7 @@ public class TabFrameDemo {
@NotNull
private static Component createTextArea() {
NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() {{
setText((TestResources.LOREM_IPSUM).repeat(10));
setText(StringUtil.repeat(TestResources.LOREM_IPSUM, 10));
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
}});
NumberingPane numbering = numberPane.getNumberingPane();

3
src/test/java/TabbedPaneDemo.java

@ -1,5 +1,6 @@
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.components.ClosableTabbedPane;
import com.github.weisj.darklaf.util.StringUtil;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@ -23,7 +24,7 @@ public class TabbedPaneDemo extends JFrame {
for (int i = 0; i < 4; i++) {
JTextPane editor = new JTextPane();
editor.setText("TabPaneDemo TabPane-" + j + "\n".repeat(i + 1));
editor.setText(StringUtil.repeat("TabPaneDemo TabPane-" + j + "\n", i + 1));
tabbedPane.addTab("Tab (" + i + "," + j + ")", editor);
}
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

2
src/test/java/UIDemo.java

@ -53,7 +53,7 @@ public final class UIDemo {
statusBar.add(new JLabel("test3"));
content.add(statusBar, BorderLayout.SOUTH);
var defaultButton = new JButton("default") {{
JButton defaultButton = new JButton("default") {{
setDefaultCapable(true);
}};

2
src/test/java/UIManagerDefaults.java

@ -154,7 +154,7 @@ public class UIManagerDefaults implements ItemListener {
*/
@NotNull
private JComponent buildNorthComponent() {
comboBox = new JComboBox<>() {
comboBox = new JComboBox<String>() {
@Override
public Dimension getPreferredSize() {
return new Dimension(200, getUI().getPreferredSize(this).height);

Loading…
Cancel
Save