This is an automated email from the ASF dual-hosted git repository. ntimofeev pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/master by this push: new 2cb18a1 CAY-2703 Modeler: incorrect active tab style on the MacOS version 2cb18a1 is described below commit 2cb18a1df022bbea2b77d2b7fd9f557d46972966 Author: Nikita Timofeev <stari...@gmail.com> AuthorDate: Thu Apr 22 10:36:11 2021 +0300 CAY-2703 Modeler: incorrect active tab style on the MacOS version --- RELEASE-NOTES.txt | 1 + .../modeler/osx/OSXPlatformInitializer.java | 10 ++- .../org/apache/cayenne/modeler/osx/OSXVersion.java | 77 ++++++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 17fa781..5b9ba34 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -16,6 +16,7 @@ Changes/New Features: Bug Fixes: CAY-2702 Modeler: Callbacks table has too small default width +CAY-2703 Modeler: incorrect active tab style on the MacOS version CAY-2705 Performance of callback annotation processing CAY-2706 Modeler: object attribute dialog doesn't properly initialized for the embeddable type CAY-2707 Modeler: code generation is broken in the DataDomain tab diff --git a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXPlatformInitializer.java b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXPlatformInitializer.java index bc5f390..6651e96 100644 --- a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXPlatformInitializer.java +++ b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXPlatformInitializer.java @@ -98,6 +98,15 @@ public class OSXPlatformInitializer implements PlatformInitializer { UIManager.put("Table.selectionBackground", lightGrey); UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder()); + // MacOS BigSur needs additional style tweaking for the tabs active state + OSXVersion version = OSXVersion.fromSystemProperties(); + if(version.gt(OSXVersion.CATALINA)) { + UIManager.put("TabbedPane.selectedTabTitlePressedColor", Color.BLACK); + UIManager.put("TabbedPane.selectedTabTitleNormalColor", Color.BLACK); + UIManager.put("TabbedPane.selectedTabTitleShadowDisabledColor", new Color(0, 0, 0, 0)); + UIManager.put("TabbedPane.selectedTabTitleShadowNormalColor", new Color(0, 0, 0, 0)); + } + Border backgroundPainter = new AbstractBorder() { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { @@ -107,7 +116,6 @@ public class OSXPlatformInitializer implements PlatformInitializer { }; UIManager.put("MenuItem.selectedBackgroundPainter", backgroundPainter); UIManager.put("MenuItem.selectionForeground", Color.BLACK); - } public void setupMenus(JFrame frame) { diff --git a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXVersion.java b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXVersion.java new file mode 100644 index 0000000..5d0c0c9 --- /dev/null +++ b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXVersion.java @@ -0,0 +1,77 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ + +package org.apache.cayenne.modeler.osx; + +/** + * @since 4.2 + */ +public class OSXVersion { + + public static final OSXVersion UNKNOWN = new OSXVersion(-1, -1); + public static final OSXVersion CATALINA = new OSXVersion(10, 15); + public static final OSXVersion BIG_SUR = new OSXVersion(10, 16); + + private final int major; + private final int minor; + + public static OSXVersion fromSystemProperties() { + // sanity check in case this code executed not on macOS + String osName = System.getProperty("os.name").toLowerCase(); + if(!osName.contains("mac")) { + return UNKNOWN; + } + + String osVersion = System.getProperty("os.version"); + String[] osVersionComponents = osVersion.split("\\."); + if(osVersionComponents.length != 2) { + return UNKNOWN; + } + try { + int major = Integer.parseInt(osVersionComponents[0]); + int minor = Integer.parseInt(osVersionComponents[1]); + return new OSXVersion(major, minor); + } catch (Exception ex) { + return UNKNOWN; + } + } + + public OSXVersion(int major, int minor) { + this.major = major; + this.minor = minor; + } + + public boolean gt(OSXVersion version) { + return getMajor() >= version.getMajor() + && getMinor() > version.getMinor(); + } + + public boolean eq(OSXVersion version) { + return getMajor() == version.getMajor() + && getMinor() == version.getMinor(); + } + + public int getMajor() { + return major; + } + + public int getMinor() { + return minor; + } +}