520 * themes. This was added to allow tempory work arounds in the platform for bugs. 521 * 522 * @return true if using caspian stylesheet 523 */ 524 public static boolean isCaspian() { 525 return isCaspian; 526 } 527 528 /** 529 * Set the platform user agent stylesheet to the given URL. This method has special handling for platform theme 530 * name constants. 531 */ 532 public static void setPlatformUserAgentStylesheet(final String stylesheetUrl) { 533 if (isFxApplicationThread()) { 534 _setPlatformUserAgentStylesheet(stylesheetUrl); 535 } else { 536 runLater(() -> _setPlatformUserAgentStylesheet(stylesheetUrl)); 537 } 538 } 539 540 private static void _setPlatformUserAgentStylesheet(String stylesheetUrl) { 541 isModena = isCaspian = false; 542 // check for command line override 543 final String overrideStylesheetUrl = AccessController.doPrivileged( 544 (PrivilegedAction<String>) () -> System.getProperty("javafx.userAgentStylesheetUrl")); 545 546 if (overrideStylesheetUrl != null) { 547 stylesheetUrl = overrideStylesheetUrl; 548 } 549 550 // check for named theme constants for modena and caspian 551 if (Application.STYLESHEET_CASPIAN.equalsIgnoreCase(stylesheetUrl)) { 552 isCaspian = true; 553 AccessController.doPrivileged( 554 (PrivilegedAction) () -> { 555 StyleManager.getInstance().setDefaultUserAgentStylesheet("com/sun/javafx/scene/control/skin/caspian/caspian.css"); 556 557 if (isSupported(ConditionalFeature.INPUT_TOUCH)) { 558 StyleManager.getInstance().addUserAgentStylesheet("com/sun/javafx/scene/control/skin/caspian/embedded.css"); 559 if (com.sun.javafx.Utils.isQVGAScreen()) { 606 607 // check to see if there is an override to enable a high-contrast theme 608 final String highContrastName = AccessController.doPrivileged( 609 (PrivilegedAction<String>) () -> System.getProperty("com.sun.javafx.highContrastTheme")); 610 if (highContrastName != null) { 611 switch (highContrastName.toUpperCase()) { 612 case "BLACKONWHITE": StyleManager.getInstance().addUserAgentStylesheet( 613 "com/sun/javafx/scene/control/skin/modena/blackOnWhite.css"); 614 break; 615 case "WHITEONBLACK": StyleManager.getInstance().addUserAgentStylesheet( 616 "com/sun/javafx/scene/control/skin/modena/whiteOnBlack.css"); 617 break; 618 case "YELLOWONBLACK": StyleManager.getInstance().addUserAgentStylesheet( 619 "com/sun/javafx/scene/control/skin/modena/yellowOnBlack.css"); 620 break; 621 } 622 } 623 } else { 624 StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheetUrl); 625 } 626 } 627 628 public static void addNoTransparencyStylesheetToScene(final Scene scene) { 629 if (PlatformImpl.isCaspian()) { 630 AccessController.doPrivileged((PrivilegedAction) () -> { 631 StyleManager.getInstance().addUserAgentStylesheet(scene, 632 "com/sun/javafx/scene/control/skin/caspian/caspian-no-transparency.css"); 633 return null; 634 }); 635 } else if (PlatformImpl.isModena()) { 636 AccessController.doPrivileged((PrivilegedAction) () -> { 637 StyleManager.getInstance().addUserAgentStylesheet(scene, 638 "com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css"); 639 return null; 640 }); 641 } 642 } 643 644 private static boolean isSupportedImpl(ConditionalFeature feature) { 645 switch (feature) { | 520 * themes. This was added to allow tempory work arounds in the platform for bugs. 521 * 522 * @return true if using caspian stylesheet 523 */ 524 public static boolean isCaspian() { 525 return isCaspian; 526 } 527 528 /** 529 * Set the platform user agent stylesheet to the given URL. This method has special handling for platform theme 530 * name constants. 531 */ 532 public static void setPlatformUserAgentStylesheet(final String stylesheetUrl) { 533 if (isFxApplicationThread()) { 534 _setPlatformUserAgentStylesheet(stylesheetUrl); 535 } else { 536 runLater(() -> _setPlatformUserAgentStylesheet(stylesheetUrl)); 537 } 538 } 539 540 private static String accessibilityTheme; 541 public static boolean setAccessibilityTheme(String themeName) { 542 if (accessibilityTheme != null) { 543 StyleManager.getInstance().removeUserAgentStylesheet(accessibilityTheme); 544 accessibilityTheme = null; 545 } 546 if (themeName == null) return false; 547 if(isModena) { 548 //pick the right one based on themeName 549 if (themeName.equals("High Contrast White")) { 550 accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/whiteOnBlack.css"; 551 } else if (themeName.equals("High Contrast #1")) { 552 accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/yellowOnBlack.css"; 553 } else if (themeName.equals("High Contrast Black")) { 554 accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/blackOnWhite.css"; 555 } 556 } 557 if (isCaspian) { 558 // caspian only has one high contrast theme 559 accessibilityTheme = "com/sun/javafx/scene/control/skin/caspian/highcontrast.css"; 560 } 561 if (accessibilityTheme != null) { 562 StyleManager.getInstance().addUserAgentStylesheet(accessibilityTheme); 563 return true; 564 } 565 return false; 566 } 567 568 private static void _setPlatformUserAgentStylesheet(String stylesheetUrl) { 569 isModena = isCaspian = false; 570 // check for command line override 571 final String overrideStylesheetUrl = AccessController.doPrivileged( 572 (PrivilegedAction<String>) () -> System.getProperty("javafx.userAgentStylesheetUrl")); 573 574 if (overrideStylesheetUrl != null) { 575 stylesheetUrl = overrideStylesheetUrl; 576 } 577 578 // check for named theme constants for modena and caspian 579 if (Application.STYLESHEET_CASPIAN.equalsIgnoreCase(stylesheetUrl)) { 580 isCaspian = true; 581 AccessController.doPrivileged( 582 (PrivilegedAction) () -> { 583 StyleManager.getInstance().setDefaultUserAgentStylesheet("com/sun/javafx/scene/control/skin/caspian/caspian.css"); 584 585 if (isSupported(ConditionalFeature.INPUT_TOUCH)) { 586 StyleManager.getInstance().addUserAgentStylesheet("com/sun/javafx/scene/control/skin/caspian/embedded.css"); 587 if (com.sun.javafx.Utils.isQVGAScreen()) { 634 635 // check to see if there is an override to enable a high-contrast theme 636 final String highContrastName = AccessController.doPrivileged( 637 (PrivilegedAction<String>) () -> System.getProperty("com.sun.javafx.highContrastTheme")); 638 if (highContrastName != null) { 639 switch (highContrastName.toUpperCase()) { 640 case "BLACKONWHITE": StyleManager.getInstance().addUserAgentStylesheet( 641 "com/sun/javafx/scene/control/skin/modena/blackOnWhite.css"); 642 break; 643 case "WHITEONBLACK": StyleManager.getInstance().addUserAgentStylesheet( 644 "com/sun/javafx/scene/control/skin/modena/whiteOnBlack.css"); 645 break; 646 case "YELLOWONBLACK": StyleManager.getInstance().addUserAgentStylesheet( 647 "com/sun/javafx/scene/control/skin/modena/yellowOnBlack.css"); 648 break; 649 } 650 } 651 } else { 652 StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheetUrl); 653 } 654 // Ensure that accessibility starts right 655 setAccessibilityTheme(Toolkit.getToolkit().getThemeName()); 656 } 657 658 public static void addNoTransparencyStylesheetToScene(final Scene scene) { 659 if (PlatformImpl.isCaspian()) { 660 AccessController.doPrivileged((PrivilegedAction) () -> { 661 StyleManager.getInstance().addUserAgentStylesheet(scene, 662 "com/sun/javafx/scene/control/skin/caspian/caspian-no-transparency.css"); 663 return null; 664 }); 665 } else if (PlatformImpl.isModena()) { 666 AccessController.doPrivileged((PrivilegedAction) () -> { 667 StyleManager.getInstance().addUserAgentStylesheet(scene, 668 "com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css"); 669 return null; 670 }); 671 } 672 } 673 674 private static boolean isSupportedImpl(ConditionalFeature feature) { 675 switch (feature) { |