Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

GuiConstants.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk
00022  * Contributor(s): ______________________.
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  * This class defines all the GuiConstants
00042  * 
00043  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00044  * @version 1.0
00045  */
00046 public final class GuiConstants
00047 {
00048   /** Backend state enabled */
00049   public static final String BACKEND_STATE_ENABLED        = GuiTranslate
00050                                                               .get("gui.backend.enabled");
00051   /** Backend state disabled */
00052   public static final String BACKEND_STATE_DISABLED       = GuiTranslate
00053                                                               .get("gui.backend.disabled");
00054   /** Backend state disabling */
00055   public static final String BACKEND_STATE_DISABLING      = GuiTranslate
00056                                                               .get("gui.backend.disabling");
00057   /** Backend state restore */
00058   public static final String BACKEND_STATE_RESTORE        = GuiTranslate
00059                                                               .get("gui.backend.restore");
00060   /** Backend state backup */
00061   public static final String BACKEND_STATE_BACKUP         = GuiTranslate
00062                                                               .get("gui.backend.backup");
00063   /** Backend state recovery */
00064   public static final String BACKEND_STATE_RECOVERY       = GuiTranslate
00065                                                               .get("gui.backend.recovery");
00066   /** Backend state new */
00067   public static final String BACKEND_STATE_NEW            = GuiTranslate
00068                                                               .get("gui.backend.new");
00069 
00070   /** Debug Level All */
00071   public static final int    DEBUG_ALL                    = 0;
00072   /** Debug level all but do not show exception window */
00073   public static final int    DEBUG_NO_EXCEPTION_WINDOW    = 1;
00074   /** Debug level info */
00075   public static final int    DEBUG_INFO                   = 2;
00076   /** No Debug */
00077   public static final int    DEBUG_NONE                   = 3;
00078   /** Level of output of the debug */
00079   public static final int    DEBUG_LEVEL                  = DEBUG_ALL;
00080 
00081   /** Main frame width */
00082   public static final int    MAIN_FRAME_WIDTH             = 1024;
00083   /** Main gui frame height */
00084   public static final int    MAIN_FRAME_HEIGHT            = 600;
00085 
00086   /** Component Name for the list of controllers */
00087   public static final String LIST_CONTROLLER              = "ListController";
00088 
00089   /** Component Name for the list of databases */
00090   public static final String LIST_DATABASE                = "ListDatabase";
00091   /** Component Name for the files list */
00092   public static final String LIST_FILES                   = "ListFiles";
00093 
00094   /** Controller state up */
00095   public static final String CONTROLLER_STATE_UP          = "Controller_UP";
00096   /** Controller state down */
00097   public static final String CONTROLLER_STATE_DOWN        = "Controller_DOWN";
00098   /** URL to the help of CJDBC */
00099   public static final String CJDBC_URL_DOC                = "http://c-jdbc.objectweb.org/current/doc/userGuide/html/userGuide.html";
00100   /** Default save session file */
00101   public static final String CJDBC_DEFAULT_SESSION_NAME   = "session";
00102   /** Default save session file */
00103   public static final String CJDBC_DEFAULT_SESSION_FILE   = CJDBC_DEFAULT_SESSION_NAME
00104                                                               + ".properties";
00105 
00106   /** Font used for the center panel */
00107   public static final Font   CENTER_PANE_FONT             = new Font("Verdana",
00108                                                               Font.PLAIN, 9);
00109 
00110   /**
00111    * Default Font
00112    */
00113   public static final Font   DEFAULT_FONT                 = new Font("Verdana",
00114                                                               Font.PLAIN, 9);
00115 
00116   /**
00117    * Final Color for backend state enabled
00118    */
00119   public static final Color  BACKEND_STATE_ENABLED_COLOR  = new Color(180, 238,
00120                                                               180);
00121   /**
00122    * Final Color for backend state recovery
00123    */
00124   public static final Color  BACKEND_STATE_RECOVERY_COLOR = new Color(255, 211,
00125                                                               155);
00126 
00127   /**
00128    * Final Color for backend state disabled
00129    */
00130   public static final Color  BACKEND_STATE_DISABLED_COLOR = new Color(238, 180,
00131                                                               180);
00132 
00133   /**
00134    * Nice color
00135    */
00136   public static final Color  NICE_COLOR                   = new Color(99, 184,
00137                                                               255);
00138 
00139   /**
00140    * Lowered border
00141    */
00142   public static final Border LOWERED_BORDER               = BorderFactory
00143                                                               .createLoweredBevelBorder();
00144 
00145   /**
00146    * Line border
00147    */
00148   public static final Border LINE_BORDER                  = BorderFactory
00149                                                               .createLineBorder(Color.BLACK);
00150 
00151   /**
00152    * Titled border
00153    */
00154   public static final Border TITLED_BORDER                = BorderFactory
00155                                                               .createTitledBorder(
00156                                                                   LOWERED_BORDER,
00157                                                                   GuiTranslate
00158                                                                       .get("gui.border.selected"));
00159 
00160   /**
00161    * Default Custom Cursor for drags
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    * Do not use any checkpoint for enable or disable of a backend
00173    */
00174   public static final String BACKEND_NO_CHECKPOINT        = GuiTranslate
00175                                                               .get("gui.backend.no.checkpoint");
00176 
00177   /** JMX attributes table */
00178   public static final String TABLE_JMX_ATTRIBUTES         = GuiTranslate
00179                                                               .get("table.jmx.attributes");
00180   /** JMX operations table */
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       // Ignore
00196     }
00197   }
00198 
00199   /**
00200    * Get colors for backend panels
00201    * 
00202    * @param paneName name of the panel
00203    * @return <code>Color</code> NEVER <code>null</code>
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    * Test whether the given backend state is a valid state Since all the backend
00225    * states are defined here, this test method should also be defined here.
00226    * 
00227    * @param state the test to validate
00228    * @return true if valid state, false otherwise.
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    * Centers a new component on the screen
00250    * 
00251    * @param comp the window to center
00252    * @param width the width of the window
00253    * @param height the height of the window
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    * Convert a parameter value depending on its type. Supported types are int
00271    * and boolean.
00272    * 
00273    * @param value value to convert
00274    * @param type "int" or "boolean"
00275    * @return value converted to an Integer or a Boolean object, or value as is
00276    *         for any other type
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    * Get the parameter type.
00290    * 
00291    * @param tmp paramter to extract type from
00292    * @return the parameter type
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 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1