00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.console.gui.constants;
00026
00027 import java.awt.Color;
00028 import java.awt.Cursor;
00029 import java.awt.Dimension;
00030 import java.awt.Font;
00031 import java.awt.Point;
00032 import java.awt.Toolkit;
00033 import java.awt.Window;
00034
00035 import javax.swing.BorderFactory;
00036 import javax.swing.border.Border;
00037
00038 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00039
00040
00041
00042
00043
00044
00045
00046 public final class GuiConstants
00047 {
00048
00049 public static final String BACKEND_STATE_ENABLED = GuiTranslate
00050 .get("gui.backend.enabled");
00051
00052 public static final String BACKEND_STATE_DISABLED = GuiTranslate
00053 .get("gui.backend.disabled");
00054
00055 public static final String BACKEND_STATE_DISABLING = GuiTranslate
00056 .get("gui.backend.disabling");
00057
00058 public static final String BACKEND_STATE_RESTORE = GuiTranslate
00059 .get("gui.backend.restore");
00060
00061 public static final String BACKEND_STATE_BACKUP = GuiTranslate
00062 .get("gui.backend.backup");
00063
00064 public static final String BACKEND_STATE_RECOVERY = GuiTranslate
00065 .get("gui.backend.recovery");
00066
00067 public static final String BACKEND_STATE_NEW = GuiTranslate
00068 .get("gui.backend.new");
00069
00070
00071 public static final int DEBUG_ALL = 0;
00072
00073 public static final int DEBUG_NO_EXCEPTION_WINDOW = 1;
00074
00075 public static final int DEBUG_INFO = 2;
00076
00077 public static final int DEBUG_NONE = 3;
00078
00079 public static final int DEBUG_LEVEL = DEBUG_ALL;
00080
00081
00082 public static final int MAIN_FRAME_WIDTH = 1024;
00083
00084 public static final int MAIN_FRAME_HEIGHT = 600;
00085
00086
00087 public static final String LIST_CONTROLLER = "ListController";
00088
00089
00090 public static final String LIST_DATABASE = "ListDatabase";
00091
00092 public static final String LIST_FILES = "ListFiles";
00093
00094
00095 public static final String CONTROLLER_STATE_UP = "Controller_UP";
00096
00097 public static final String CONTROLLER_STATE_DOWN = "Controller_DOWN";
00098
00099 public static final String CJDBC_URL_DOC = "http://c-jdbc.objectweb.org/current/doc/userGuide/html/userGuide.html";
00100
00101 public static final String CJDBC_DEFAULT_SESSION_NAME = "session";
00102
00103 public static final String CJDBC_DEFAULT_SESSION_FILE = CJDBC_DEFAULT_SESSION_NAME
00104 + ".properties";
00105
00106
00107 public static final Font CENTER_PANE_FONT = new Font("Verdana",
00108 Font.PLAIN, 9);
00109
00110
00111
00112
00113 public static final Font DEFAULT_FONT = new Font("Verdana",
00114 Font.PLAIN, 9);
00115
00116
00117
00118
00119 public static final Color BACKEND_STATE_ENABLED_COLOR = new Color(180, 238,
00120 180);
00121
00122
00123
00124 public static final Color BACKEND_STATE_RECOVERY_COLOR = new Color(255, 211,
00125 155);
00126
00127
00128
00129
00130 public static final Color BACKEND_STATE_DISABLED_COLOR = new Color(238, 180,
00131 180);
00132
00133
00134
00135
00136 public static final Color NICE_COLOR = new Color(99, 184,
00137 255);
00138
00139
00140
00141
00142 public static final Border LOWERED_BORDER = BorderFactory
00143 .createLoweredBevelBorder();
00144
00145
00146
00147
00148 public static final Border LINE_BORDER = BorderFactory
00149 .createLineBorder(Color.BLACK);
00150
00151
00152
00153
00154 public static final Border TITLED_BORDER = BorderFactory
00155 .createTitledBorder(
00156 LOWERED_BORDER,
00157 GuiTranslate
00158 .get("gui.border.selected"));
00159
00160
00161
00162
00163 public static Cursor customCursor;
00164
00165 private static final Color BACKEND_STATE_NEW_COLOR = new Color(185, 211,
00166 238);
00167 private static final Color BACKEND_STATE_BACKUP_COLOR = new Color(255, 193,
00168 193);
00169 private static final Color BACKEND_STATE_RESTORE_COLOR = new Color(255, 174,
00170 185);
00171
00172
00173
00174 public static final String BACKEND_NO_CHECKPOINT = GuiTranslate
00175 .get("gui.backend.no.checkpoint");
00176
00177
00178 public static final String TABLE_JMX_ATTRIBUTES = GuiTranslate
00179 .get("table.jmx.attributes");
00180
00181 public static final String TABLE_JMX_OPERATIONS = GuiTranslate
00182 .get("table.jmx.operations");
00183
00184 static
00185 {
00186 Toolkit tk = Toolkit.getDefaultToolkit();
00187 Point p = new Point(0, 0);
00188 try
00189 {
00190 customCursor = tk.createCustomCursor(GuiIcons.CUSTOM_CURSOR_ICON
00191 .getImage(), p, "CustomCursor");
00192 }
00193 catch (Exception e)
00194 {
00195
00196 }
00197 }
00198
00199
00200
00201
00202
00203
00204
00205 public static final Color getBackendBgColor(String paneName)
00206 {
00207 if (paneName.equals(BACKEND_STATE_ENABLED))
00208 return BACKEND_STATE_ENABLED_COLOR;
00209 else if (paneName.equals(BACKEND_STATE_DISABLED))
00210 return BACKEND_STATE_DISABLED_COLOR;
00211 else if (paneName.equals(BACKEND_STATE_RECOVERY))
00212 return BACKEND_STATE_RECOVERY_COLOR;
00213 else if (paneName.equals(BACKEND_STATE_NEW))
00214 return BACKEND_STATE_NEW_COLOR;
00215 else if (paneName.equals(BACKEND_STATE_RESTORE))
00216 return BACKEND_STATE_RESTORE_COLOR;
00217 else if (paneName.equals(BACKEND_STATE_BACKUP))
00218 return BACKEND_STATE_BACKUP_COLOR;
00219 else
00220 return Color.white;
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230 public static final boolean isValidBackendState(String state)
00231 {
00232 if (state.equals(BACKEND_STATE_ENABLED))
00233 return true;
00234 else if (state.equals(BACKEND_STATE_DISABLED))
00235 return true;
00236 else if (state.equals(BACKEND_STATE_RESTORE))
00237 return true;
00238 else if (state.equals(BACKEND_STATE_RECOVERY))
00239 return true;
00240 else if (state.equals(BACKEND_STATE_BACKUP))
00241 return true;
00242 else if (state.equals(BACKEND_STATE_NEW))
00243 return true;
00244 else
00245 return false;
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255 public static final void centerComponent(Window comp, int width, int height)
00256 {
00257 Toolkit toolkit = Toolkit.getDefaultToolkit();
00258 Dimension dim = toolkit.getScreenSize();
00259 int screenHeight = dim.height;
00260 int screenWidth = dim.width;
00261 int frameWidth = width;
00262 int frameHeight = height;
00263 comp.setSize(width, height);
00264 comp.setBounds((screenWidth - frameWidth) / 2,
00265 (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00266 comp.validate();
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 public static final Object convertType(String value, String type)
00279 {
00280 if (type.equals("int"))
00281 return new Integer(value);
00282 if (type.equals("boolean"))
00283 return new Boolean(value);
00284 else
00285 return value;
00286 }
00287
00288
00289
00290
00291
00292
00293
00294 public static final String getParameterType(String tmp)
00295 {
00296 int indexOf = tmp.indexOf(";");
00297 if (indexOf != -1)
00298 tmp = tmp.substring(0, indexOf);
00299 while (tmp.charAt(0) == '[')
00300 tmp = tmp.substring(1) + "[]";
00301 if (tmp.charAt(0) == 'L')
00302 tmp = tmp.substring(1);
00303 if (tmp.indexOf(".") != -1)
00304 tmp = tmp.substring(tmp.lastIndexOf(".") + 1);
00305 return tmp;
00306 }
00307
00308 }