This commit is contained in:
Gregory.Shrago
2014-06-24 20:50:57 +04:00
parent f925163410
commit 8c082fc6cb
@@ -113,11 +113,12 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
private final EventListenerList myListenerList;
private final UIManager.LookAndFeelInfo[] myLaFs;
private UIManager.LookAndFeelInfo myCurrentLaf;
private final HashMap<UIManager.LookAndFeelInfo, HashMap<String, Object>> myStoredDefaults = new HashMap<UIManager.LookAndFeelInfo, HashMap<String, Object>>();
private final Map<UIManager.LookAndFeelInfo, HashMap<String, Object>> myStoredDefaults = ContainerUtil.newHashMap();
private final UISettings myUiSettings;
private String myLastWarning = null;
private PropertyChangeListener myThemeChangeListener = null;
private static final HashMap<String, String> ourLafClassesAliases = new HashMap<String, String>();
private static final Map<String, String> ourLafClassesAliases = ContainerUtil.newHashMap();
static {
ourLafClassesAliases.put("idea.dark.laf.classname", DarculaLookAndFeelInfo.CLASS_NAME);
}
@@ -137,16 +138,17 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
else {
if (isIntelliJLafEnabled()) {
lafList.add(new IntelliJLookAndFeelInfo());
} else {
}
else {
lafList.add(new IdeaLookAndFeelInfo());
}
for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
String name = laf.getName();
if ( !"Metal".equalsIgnoreCase(name)
&& !"CDE/Motif".equalsIgnoreCase(name)
&& !"Nimbus".equalsIgnoreCase(name)
&& !"Windows Classic".equalsIgnoreCase(name)
&& !name.startsWith("JGoodies")) {
if (!"Metal".equalsIgnoreCase(name)
&& !"CDE/Motif".equalsIgnoreCase(name)
&& !"Nimbus".equalsIgnoreCase(name)
&& !"Windows Classic".equalsIgnoreCase(name)
&& !name.startsWith("JGoodies")) {
lafList.add(laf);
}
}
@@ -161,7 +163,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
if (!SystemInfo.isMac) {
// do not sort LaFs on mac - the order is determined as Default, Darcula.
// when we leave only system LaFs on other OSes, the order also should be determined as Default, Darcula
Arrays.sort(myLaFs, new Comparator<UIManager.LookAndFeelInfo>() {
@Override
public int compare(UIManager.LookAndFeelInfo obj1, UIManager.LookAndFeelInfo obj2) {
@@ -287,8 +289,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
Element element = new Element("state");
if (myCurrentLaf != null) {
String className = myCurrentLaf.getClassName();
if (className != null){
Element child=new Element(ELEMENT_LAF);
if (className != null) {
Element child = new Element(ELEMENT_LAF);
child.setAttribute(ATTRIBUTE_CLASS_NAME, className);
element.addContent(child);
}
@@ -297,12 +299,12 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
}
@Override
public UIManager.LookAndFeelInfo[] getInstalledLookAndFeels(){
public UIManager.LookAndFeelInfo[] getInstalledLookAndFeels() {
return myLaFs.clone();
}
@Override
public UIManager.LookAndFeelInfo getCurrentLookAndFeel(){
public UIManager.LookAndFeelInfo getCurrentLookAndFeel() {
return myCurrentLaf;
}
@@ -326,7 +328,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
if (PlatformUtils.isRubyMine() || PlatformUtils.isPyCharm()) {
final String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
if ("gnome".equals(desktop)) {
UIManager.LookAndFeelInfo laf=findLaf(systemLafClassName);
UIManager.LookAndFeelInfo laf = findLaf(systemLafClassName);
if (laf != null) {
return laf;
}
@@ -445,14 +447,14 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
@Nullable
private static Icon getAquaMenuInvertedIcon() {
if (!UIUtil.isUnderAquaLookAndFeel()) return null;
final Icon arrow = (Icon) UIManager.get("Menu.arrowIcon");
final Icon arrow = (Icon)UIManager.get("Menu.arrowIcon");
if (arrow == null) return null;
try {
final Method method = arrow.getClass().getMethod("getInvertedIcon");
if (method != null) {
method.setAccessible(true);
return (Icon) method.invoke(arrow);
return (Icon)method.invoke(arrow);
}
return null;
@@ -655,27 +657,28 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();
SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
@Override
public SynthStyle getStyle(final JComponent c, final Region id) {
final SynthStyle style = original.getStyle(c, id);
if (id == Region.POPUP_MENU) {
try {
Field f = style.getClass().getDeclaredField("xThickness");
@Override
public SynthStyle getStyle(final JComponent c, final Region id) {
final SynthStyle style = original.getStyle(c, id);
if (id == Region.POPUP_MENU) {
try {
Field f = style.getClass().getDeclaredField("xThickness");
f.setAccessible(true);
final Object x = f.get(style);
if (x instanceof Integer && (Integer)x == 0) {
// workaround for Sun bug #6636964
f.set(style, 1);
f = style.getClass().getDeclaredField("yThickness");
f.setAccessible(true);
final Object x = f.get(style);
if (x instanceof Integer && (Integer)x == 0) {
// workaround for Sun bug #6636964
f.set(style, 1);
f = style.getClass().getDeclaredField("yThickness");
f.setAccessible(true);
f.set(style, 3);
}
f.set(style, 3);
}
catch (Exception ignore) { }
}
return style;
catch (Exception ignore) {
}
}
});
return style;
}
});
new JBPopupMenu(); // invokes updateUI() -> updateStyle()
@@ -740,12 +743,12 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
}
}
private static void updateUI(Window window){
if(!window.isDisplayable()){
private static void updateUI(Window window) {
if (!window.isDisplayable()) {
return;
}
IJSwingUtilities.updateComponentTreeUI(window);
Window[] children=window.getOwnedWindows();
Window[] children = window.getOwnedWindows();
for (Window aChildren : children) {
updateUI(aChildren);
}
@@ -755,19 +758,19 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
* Repaints all displayable window.
*/
@Override
public void repaintUI(){
Frame[] frames=Frame.getFrames();
public void repaintUI() {
Frame[] frames = Frame.getFrames();
for (Frame frame : frames) {
repaintUI(frame);
}
}
private static void repaintUI(Window window){
if(!window.isDisplayable()){
private static void repaintUI(Window window) {
if (!window.isDisplayable()) {
return;
}
window.repaint();
Window[] children=window.getOwnedWindows();
Window[] children = window.getOwnedWindows();
for (Window aChildren : children) {
repaintUI(aChildren);
}
@@ -788,30 +791,30 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
}
@SuppressWarnings({"HardCodedStringLiteral"})
public static void initInputMapDefaults(UIDefaults defaults){
public static void initInputMapDefaults(UIDefaults defaults) {
// Make ENTER work in JTrees
InputMap treeInputMap = (InputMap)defaults.get("Tree.focusInputMap");
if(treeInputMap!=null){ // it's really possible. For example, GTK+ doesn't have such map
treeInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),"toggle");
if (treeInputMap != null) { // it's really possible. For example, GTK+ doesn't have such map
treeInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "toggle");
}
// Cut/Copy/Paste in JTextAreas
InputMap textAreaInputMap=(InputMap)defaults.get("TextArea.focusInputMap");
if(textAreaInputMap!=null){ // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
InputMap textAreaInputMap = (InputMap)defaults.get("TextArea.focusInputMap");
if (textAreaInputMap != null) { // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
installCutCopyPasteShortcuts(textAreaInputMap, false);
}
// Cut/Copy/Paste in JTextFields
InputMap textFieldInputMap=(InputMap)defaults.get("TextField.focusInputMap");
if(textFieldInputMap!=null){ // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
InputMap textFieldInputMap = (InputMap)defaults.get("TextField.focusInputMap");
if (textFieldInputMap != null) { // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
installCutCopyPasteShortcuts(textFieldInputMap, false);
}
// Cut/Copy/Paste in JPasswordField
InputMap passwordFieldInputMap=(InputMap)defaults.get("PasswordField.focusInputMap");
if(passwordFieldInputMap!=null){ // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
InputMap passwordFieldInputMap = (InputMap)defaults.get("PasswordField.focusInputMap");
if (passwordFieldInputMap != null) { // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
installCutCopyPasteShortcuts(passwordFieldInputMap, false);
}
// Cut/Copy/Paste in JTables
InputMap tableInputMap=(InputMap)defaults.get("Table.ancestorInputMap");
if(tableInputMap!=null){ // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
InputMap tableInputMap = (InputMap)defaults.get("Table.ancestorInputMap");
if (tableInputMap != null) { // It really can be null, for example when LAF isn't properly initialized (Alloy license problem)
installCutCopyPasteShortcuts(tableInputMap, true);
}
}
@@ -902,7 +905,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
}
break;
}
catch (Exception ignored) { }
catch (Exception ignored) {
}
}
}
}