1 package rero.gui.windows; 2 3 import java.awt.*; 4 import javax.swing.*; 5 6 import java.util.*; 7 8 import rero.config.*; 9 10 public class SwitchBarOptions implements ClientStateListener 11 { 12 protected JComponent container; 13 protected JComponent switchbar; 14 protected JComponent panel; 15 16 protected static ColorListener color = null; 17 18 public SwitchBarOptions(JComponent c, JComponent s) 19 { 20 container = c; 21 switchbar = s; 22 23 ClientState.getClientState().addClientStateListener("switchbar.position", this); 24 ClientState.getClientState().addClientStateListener("switchbar.enabled", this); 25 26 rehash(); 27 28 if (color == null) 29 { 30 color = new ColorListener(); 31 } 32 } 33 34 public static Color getHighlightColor() 35 { 36 return color.getColor(); 37 } 38 39 public static boolean isHilightOn() 40 { 41 return color.isHilightOn(); 42 } 43 44 public void rehash() 45 { 46 container.remove(switchbar); 47 boolean enabled = ClientState.getClientState().isOption("switchbar.enabled", true); 48 int position = ClientState.getClientState().getInteger("switchbar.position", 0); 49 50 if (enabled) 51 { 52 switch (position) 53 { 54 case 0: 55 container.add(switchbar, BorderLayout.NORTH); 56 break; 57 case 1: 58 container.add(switchbar, BorderLayout.SOUTH); 59 break; 60 case 2: 61 container.add(switchbar, BorderLayout.WEST); 62 break; 63 case 3: 64 container.add(switchbar, BorderLayout.EAST); 65 break; 66 } 67 } 68 } 69 70 public void propertyChanged(String key, String value) 71 { 72 rehash(); 73 container.revalidate(); 74 } 75 76 private static class ColorListener implements ClientStateListener 77 { 78 protected Color theColor; 79 protected boolean hilight; 80 81 public ColorListener() 82 { 83 ClientState.getClientState().addClientStateListener("switchbar.color", this); 84 ClientState.getClientState().addClientStateListener("switchbar.hilight", this); 85 86 propertyChanged(null, null); 87 } 88 89 public void propertyChanged(String key, String value) 90 { 91 theColor = ClientState.getClientState().getColor("switchbar.color", ClientDefaults.switchbar_color); 92 hilight = ClientState.getClientState().isOption("switchbar.hilight", ClientDefaults.switchbar_hilight); 93 } 94 95 public boolean isHilightOn() 96 { 97 return hilight; 98 } 99 100 public Color getColor() 101 { 102 return theColor; 103 } 104 } 105 } 106 107 | Popular Tags |