1 24 25 package org.objectweb.cjdbc.console.gui.constants; 26 27 import java.awt.Color ; 28 import java.awt.Cursor ; 29 import java.awt.Dimension ; 30 import java.awt.Font ; 31 import java.awt.Point ; 32 import java.awt.Toolkit ; 33 import java.awt.Window ; 34 35 import javax.swing.BorderFactory ; 36 import javax.swing.border.Border ; 37 38 import org.objectweb.cjdbc.common.i18n.GuiTranslate; 39 40 46 public final class GuiConstants 47 { 48 49 public static final String BACKEND_STATE_ENABLED = GuiTranslate 50 .get("gui.backend.enabled"); 51 52 public static final String BACKEND_STATE_DISABLED = GuiTranslate 53 .get("gui.backend.disabled"); 54 55 public static final String BACKEND_STATE_DISABLING = GuiTranslate 56 .get("gui.backend.disabling"); 57 58 public static final String BACKEND_STATE_RESTORE = GuiTranslate 59 .get("gui.backend.restore"); 60 61 public static final String BACKEND_STATE_BACKUP = GuiTranslate 62 .get("gui.backend.backup"); 63 64 public static final String BACKEND_STATE_RECOVERY = GuiTranslate 65 .get("gui.backend.recovery"); 66 67 public static final String BACKEND_STATE_NEW = GuiTranslate 68 .get("gui.backend.new"); 69 70 71 public static final int DEBUG_ALL = 0; 72 73 public static final int DEBUG_NO_EXCEPTION_WINDOW = 1; 74 75 public static final int DEBUG_INFO = 2; 76 77 public static final int DEBUG_NONE = 3; 78 79 public static final int DEBUG_LEVEL = DEBUG_ALL; 80 81 82 public static final int MAIN_FRAME_WIDTH = 1024; 83 84 public static final int MAIN_FRAME_HEIGHT = 600; 85 86 87 public static final String LIST_CONTROLLER = "ListController"; 88 89 90 public static final String LIST_DATABASE = "ListDatabase"; 91 92 public static final String LIST_FILES = "ListFiles"; 93 94 95 public static final String CONTROLLER_STATE_UP = "Controller_UP"; 96 97 public static final String CONTROLLER_STATE_DOWN = "Controller_DOWN"; 98 99 public static final String CJDBC_URL_DOC = "http://c-jdbc.objectweb.org/current/doc/userGuide/html/userGuide.html"; 100 101 public static final String CJDBC_DEFAULT_SESSION_NAME = "session"; 102 103 public static final String CJDBC_DEFAULT_SESSION_FILE = CJDBC_DEFAULT_SESSION_NAME 104 + ".properties"; 105 106 107 public static final Font CENTER_PANE_FONT = new Font ("Verdana", 108 Font.PLAIN, 9); 109 110 113 public static final Font DEFAULT_FONT = new Font ("Verdana", 114 Font.PLAIN, 9); 115 116 119 public static final Color BACKEND_STATE_ENABLED_COLOR = new Color (180, 238, 120 180); 121 124 public static final Color BACKEND_STATE_RECOVERY_COLOR = new Color (255, 211, 125 155); 126 127 130 public static final Color BACKEND_STATE_DISABLED_COLOR = new Color (238, 180, 131 180); 132 133 136 public static final Color NICE_COLOR = new Color (99, 184, 137 255); 138 139 142 public static final Border LOWERED_BORDER = BorderFactory 143 .createLoweredBevelBorder(); 144 145 148 public static final Border LINE_BORDER = BorderFactory 149 .createLineBorder(Color.BLACK); 150 151 154 public static final Border TITLED_BORDER = BorderFactory 155 .createTitledBorder( 156 LOWERED_BORDER, 157 GuiTranslate 158 .get("gui.border.selected")); 159 160 163 public static Cursor customCursor; 164 165 private static final Color BACKEND_STATE_NEW_COLOR = new Color (185, 211, 166 238); 167 private static final Color BACKEND_STATE_BACKUP_COLOR = new Color (255, 193, 168 193); 169 private static final Color BACKEND_STATE_RESTORE_COLOR = new Color (255, 174, 170 185); 171 174 public static final String BACKEND_NO_CHECKPOINT = GuiTranslate 175 .get("gui.backend.no.checkpoint"); 176 177 178 public static final String TABLE_JMX_ATTRIBUTES = GuiTranslate 179 .get("table.jmx.attributes"); 180 181 public static final String TABLE_JMX_OPERATIONS = GuiTranslate 182 .get("table.jmx.operations"); 183 184 static 185 { 186 Toolkit tk = Toolkit.getDefaultToolkit(); 187 Point p = new Point (0, 0); 188 try 189 { 190 customCursor = tk.createCustomCursor(GuiIcons.CUSTOM_CURSOR_ICON 191 .getImage(), p, "CustomCursor"); 192 } 193 catch (Exception e) 194 { 195 } 197 } 198 199 205 public static Color getBackendBgColor(String paneName) 206 { 207 if (paneName.equals(BACKEND_STATE_ENABLED)) 208 return BACKEND_STATE_ENABLED_COLOR; 209 else if (paneName.equals(BACKEND_STATE_DISABLED)) 210 return BACKEND_STATE_DISABLED_COLOR; 211 else if (paneName.equals(BACKEND_STATE_RECOVERY)) 212 return BACKEND_STATE_RECOVERY_COLOR; 213 else if (paneName.equals(BACKEND_STATE_NEW)) 214 return BACKEND_STATE_NEW_COLOR; 215 else if (paneName.equals(BACKEND_STATE_RESTORE)) 216 return BACKEND_STATE_RESTORE_COLOR; 217 else if (paneName.equals(BACKEND_STATE_BACKUP)) 218 return BACKEND_STATE_BACKUP_COLOR; 219 else 220 return Color.white; 221 } 222 223 230 public static boolean isValidBackendState(String state) 231 { 232 if (state.equals(BACKEND_STATE_ENABLED)) 233 return true; 234 else if (state.equals(BACKEND_STATE_DISABLED)) 235 return true; 236 else if (state.equals(BACKEND_STATE_RESTORE)) 237 return true; 238 else if (state.equals(BACKEND_STATE_RECOVERY)) 239 return true; 240 else if (state.equals(BACKEND_STATE_BACKUP)) 241 return true; 242 else if (state.equals(BACKEND_STATE_NEW)) 243 return true; 244 else 245 return false; 246 } 247 248 255 public static void centerComponent(Window comp, int width, int height) 256 { 257 Toolkit toolkit = Toolkit.getDefaultToolkit(); 258 Dimension dim = toolkit.getScreenSize(); 259 int screenHeight = dim.height; 260 int screenWidth = dim.width; 261 int frameWidth = width; 262 int frameHeight = height; 263 comp.setSize(width, height); 264 comp.setBounds((screenWidth - frameWidth) / 2, 265 (screenHeight - frameHeight) / 2, frameWidth, frameHeight); 266 comp.validate(); 267 } 268 269 278 public static Object convertType(String value, String type) 279 { 280 if (type.equals("int")) 281 return new Integer (value); 282 if (type.equals("boolean")) 283 return new Boolean (value); 284 else 285 return value; 286 } 287 288 294 public static String getParameterType(String tmp) 295 { 296 int indexOf = tmp.indexOf(";"); 297 if (indexOf != -1) 298 tmp = tmp.substring(0, indexOf); 299 while (tmp.charAt(0) == '[') 300 tmp = tmp.substring(1) + "[]"; 301 if (tmp.charAt(0) == 'L') 302 tmp = tmp.substring(1); 303 if (tmp.indexOf(".") != -1) 304 tmp = tmp.substring(tmp.lastIndexOf(".") + 1); 305 return tmp; 306 } 307 308 } | Popular Tags |