Coverage Report - org.argouml.application.api.Argo
 
Classes in this File Line Coverage Branch Coverage Complexity
Argo
88%
40/45
N/A
1
 
 1  
 /* $Id: Argo.java 17749 2010-01-11 18:49:17Z linus $
 2  
  *******************************************************************************
 3  
  * Copyright (c) 2009 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    tfmorris
 11  
  *******************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 1996-2008 The Regents of the University of California. All
 17  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 18  
 // software and its documentation without fee, and without a written
 19  
 // agreement is hereby granted, provided that the above copyright notice
 20  
 // and this paragraph appear in all copies.  This software program and
 21  
 // documentation are copyrighted by The Regents of the University of
 22  
 // California. The software program and documentation are supplied "AS
 23  
 // IS", without any accompanying services from The Regents. The Regents
 24  
 // does not warrant that the operation of the program will be
 25  
 // uninterrupted or error-free. The end-user understands that the program
 26  
 // was developed for research purposes and is advised not to rely
 27  
 // exclusively on the program for any reason.  IN NO EVENT SHALL THE
 28  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 29  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 30  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 31  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 32  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 33  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 34  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 35  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 36  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 37  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 38  
 
 39  
 package org.argouml.application.api;
 40  
 
 41  
 import org.apache.log4j.Category;
 42  
 import org.apache.log4j.Level;
 43  
 import org.argouml.configuration.Configuration;
 44  
 import org.argouml.configuration.ConfigurationKey;
 45  
 
 46  
 /**
 47  
  * The <code>Argo</code> class provides static methods and definitions
 48  
  * that can be used as helpers throughout the Argo code.<p>
 49  
  *
 50  
  * This class is a variation of the <em>Expert</em> design pattern
 51  
  * [Grand].  By incorporating a number of unrelated but commonly
 52  
  * used methods in a single class, it attempts to decrease the
 53  
  * complexity of the overall code while increasing its own complexity.<p>
 54  
  *
 55  
  * These include
 56  
  * <ul>
 57  
  * <li>definitions of configuration keys
 58  
  * <li>definitions of resource bundle identifier strings
 59  
  * <li>methods for localization using <code>gef</code>
 60  
  * <li>methods for environment manipulation
 61  
  * </ul>
 62  
  *
 63  
  */
 64  
 public final class Argo {
 65  
 
 66  
     /**
 67  
      * argo.ini path.
 68  
      * @deprecated for 0.25.4 by tfmorris.  No longer used.
 69  
      */
 70  
     @Deprecated
 71  
     public static final String ARGOINI = "/org/argouml/argo.ini";
 72  
 
 73  
     /**
 74  
      * Key for default startup directory.
 75  
      */
 76  900
     public static final ConfigurationKey KEY_STARTUP_DIR =
 77  
         Configuration.makeKey("default", "user", "dir");
 78  
 
 79  
     /**
 80  
      * Key to show splash screen.
 81  
      */
 82  900
     public static final ConfigurationKey KEY_SPLASH =
 83  
         Configuration.makeKey("init", "splash");
 84  
 
 85  
     /**
 86  
      * Key to report usage statistics.
 87  
      */
 88  900
     public static final ConfigurationKey KEY_EDEM =
 89  
         Configuration.makeKey("init", "edem");
 90  
 
 91  
     /**
 92  
      * Key for last saved project URI.
 93  
      */
 94  900
     public static final ConfigurationKey KEY_MOST_RECENT_PROJECT_FILE =
 95  
         Configuration.makeKey("project", "mostrecent", "file");
 96  
 
 97  
     /**
 98  
      * Key for last generated class/classes directory.
 99  
      */
 100  900
     public static final ConfigurationKey KEY_MOST_RECENT_EXPORT_DIRECTORY =
 101  
         Configuration.makeKey("project", "mostrecent", "exportdirectory");
 102  
 
 103  
     /**
 104  
      * Key to reload last saved project on startup.
 105  
      */
 106  900
     public static final ConfigurationKey KEY_RELOAD_RECENT_PROJECT =
 107  
         Configuration.makeKey("init", "project", "loadmostrecent");
 108  
 
 109  
     /**
 110  
      * Key for number of last recently used file entries in menu list.
 111  
      */
 112  900
     public static final ConfigurationKey KEY_NUMBER_LAST_RECENT_USED =
 113  
         Configuration.makeKey("project", "mostrecent", "maxNumber");
 114  
 
 115  
     /**
 116  
      * Key for screen top.
 117  
      */
 118  900
     public static final ConfigurationKey KEY_SCREEN_TOP_Y =
 119  
         Configuration.makeKey("screen", "top");
 120  
 
 121  
     /**
 122  
      * Key for screen left.
 123  
      */
 124  900
     public static final ConfigurationKey KEY_SCREEN_LEFT_X =
 125  
         Configuration.makeKey("screen", "left");
 126  
 
 127  
     /**
 128  
      * Key for screen width.
 129  
      */
 130  900
     public static final ConfigurationKey KEY_SCREEN_WIDTH =
 131  
         Configuration.makeKey("screen", "width");
 132  
 
 133  
     /**
 134  
      * Key for screen height.
 135  
      */
 136  900
     public static final ConfigurationKey KEY_SCREEN_HEIGHT =
 137  
         Configuration.makeKey("screen", "height");
 138  
 
 139  
     /**
 140  
      * Key for screen extended state, i.e. NORMAL, MAXIMIZED;
 141  
      * (see Frame documentation).
 142  
      */
 143  900
     public static final ConfigurationKey KEY_SCREEN_MAXIMIZED =
 144  
         Configuration.makeKey("screen", "maximized");
 145  
     
 146  
     /**
 147  
      * Key for southwest pane width.
 148  
      */
 149  900
     public static final ConfigurationKey KEY_SCREEN_SOUTHWEST_WIDTH =
 150  
         Configuration.makeKey("screen", "southwest", "width");
 151  
 
 152  
     /**
 153  
      * Key for northwest pane width.
 154  
      */
 155  900
     public static final ConfigurationKey KEY_SCREEN_NORTHWEST_WIDTH =
 156  
         Configuration.makeKey("screen", "northwest", "width");
 157  
 
 158  
     /**
 159  
      * Key for southeast pane width.
 160  
      */
 161  900
     public static final ConfigurationKey KEY_SCREEN_SOUTHEAST_WIDTH =
 162  
         Configuration.makeKey("screen", "southeast", "width");
 163  
 
 164  
     /**
 165  
      * Key for northeast pane width.
 166  
      */
 167  900
     public static final ConfigurationKey KEY_SCREEN_NORTHEAST_WIDTH =
 168  
         Configuration.makeKey("screen", "northeast", "width");
 169  
 
 170  
     /**
 171  
      * Key for west pane width.
 172  
      */
 173  900
     public static final ConfigurationKey KEY_SCREEN_WEST_WIDTH =
 174  
         Configuration.makeKey("screen", "west", "width");
 175  
 
 176  
     /**
 177  
      * Key for east pane width.
 178  
      */
 179  900
     public static final ConfigurationKey KEY_SCREEN_EAST_WIDTH =
 180  
         Configuration.makeKey("screen", "east", "width");
 181  
 
 182  
     /**
 183  
      * Key for south pane height.
 184  
      */
 185  900
     public static final ConfigurationKey KEY_SCREEN_SOUTH_HEIGHT =
 186  
         Configuration.makeKey("screen", "south", "height");
 187  
 
 188  
     /**
 189  
      * Key for north pane height.
 190  
      */
 191  900
     public static final ConfigurationKey KEY_SCREEN_NORTH_HEIGHT =
 192  
         Configuration.makeKey("screen", "north", "height");
 193  
 
 194  
     /**
 195  
      * Key for theme.
 196  
      */
 197  900
     public static final ConfigurationKey KEY_SCREEN_THEME =
 198  
         Configuration.makeKey("screen", "theme");
 199  
 
 200  
     /**
 201  
      * Key for look and feel class name.
 202  
      */
 203  900
     public static final ConfigurationKey KEY_LOOK_AND_FEEL_CLASS =
 204  
         Configuration.makeKey("screen", "lookAndFeelClass");
 205  
 
 206  
     /**
 207  
      * Key for theme class name.
 208  
      */
 209  900
     public static final ConfigurationKey KEY_THEME_CLASS =
 210  
         Configuration.makeKey("screen", "themeClass");
 211  
 
 212  
     /**
 213  
      * Key to enable smooth edges of diagram text and lines (anti-aliasing).
 214  
      */
 215  900
     public static final ConfigurationKey KEY_SMOOTH_EDGES =
 216  
         Configuration.makeKey("screen", "diagram-antialiasing");
 217  
 
 218  
     /**
 219  
      * Key for user email address.
 220  
      */
 221  900
     public static final ConfigurationKey KEY_USER_EMAIL =
 222  
         Configuration.makeKey("user", "email");
 223  
 
 224  
     /**
 225  
      * Key for user full name.
 226  
      */
 227  900
     public static final ConfigurationKey KEY_USER_FULLNAME =
 228  
         Configuration.makeKey("user", "fullname");
 229  
 
 230  
     /**
 231  
      * Key for user java reverse engineering classpath.
 232  
      */
 233  900
     public static final ConfigurationKey KEY_USER_IMPORT_CLASSPATH =
 234  
         Configuration.makeKey("import", "clazzpath");
 235  
 
 236  
     /**
 237  
      * Key for RE general settings checkbox values.
 238  
      * CSV format (values are true/false):
 239  
      * 1. descend directories recursively
 240  
      * 2. changed/new files only
 241  
      * 3. create diagrams from imported code
 242  
      * 4. minimise class icons in diagrams
 243  
      * 5. perform automatic diagram layout
 244  
      */
 245  900
     public static final ConfigurationKey KEY_IMPORT_GENERAL_SETTINGS_FLAGS =
 246  
         Configuration.makeKey("import", "general", "flags");
 247  
 
 248  
     /**
 249  
      * Key for RE general settings: level of import detail. Values:
 250  
      * 0: classifiers only
 251  
      * 1: classifiers plus feature specifications
 252  
      * 2: full import
 253  
      */
 254  900
     public static final ConfigurationKey KEY_IMPORT_GENERAL_DETAIL_LEVEL =
 255  
         Configuration.makeKey("import", "general", "detail", "level");
 256  
 
 257  
     /**
 258  
      * Key for input source file encoding used in RE.
 259  
      *  Will be used for generated file also.
 260  
      */
 261  900
     public static final ConfigurationKey KEY_INPUT_SOURCE_ENCODING =
 262  
         Configuration.makeKey("import", "file", "encoding");
 263  
     
 264  
     /**
 265  
      * Key to store setting of stripping diagrams on XMI import.
 266  
      */
 267  900
     public static final ConfigurationKey KEY_XMI_STRIP_DIAGRAMS =
 268  
         Configuration.makeKey("import", "xmi", "stripDiagrams");
 269  
 
 270  
     /**
 271  
      * Key to store profile/default model.
 272  
      */
 273  900
     public static final ConfigurationKey KEY_DEFAULT_MODEL =
 274  
         Configuration.makeKey("defaultModel");
 275  
 
 276  
     /**
 277  
      * Key for user explorer perspectives.
 278  
      *<pre>
 279  
      * format:
 280  
      * perspective name,rule,rule,rule;perspective name, etc
 281  
      *</pre>
 282  
      */
 283  900
     public static final ConfigurationKey KEY_USER_EXPLORER_PERSPECTIVES =
 284  
         Configuration.makeKey("explorer", "perspectives");
 285  
 
 286  
     /**
 287  
      * Key for selecting the locale.
 288  
      */
 289  900
     public static final ConfigurationKey KEY_LOCALE =
 290  
         Configuration.makeKey("locale");
 291  
 
 292  
     /**
 293  
      * Key for selecting the grid size and if it shows lines, dots or none. 
 294  
      */
 295  900
     public static final ConfigurationKey KEY_GRID =
 296  
         Configuration.makeKey("grid");
 297  
 
 298  
     /**
 299  
      * Key for selecting the snap size. 
 300  
      */
 301  900
     public static final ConfigurationKey KEY_SNAP =
 302  
         Configuration.makeKey("snap");
 303  
 
 304  
     /**
 305  
      * Standard definition of the logging category for the console. (unused)
 306  
      */
 307  
     public static final String CONSOLE_LOG = "argo.console.log";
 308  
 
 309  
     /**
 310  
      * Standard definition of the logging category for the console.
 311  
      */
 312  
     public static final String ARGO_CONSOLE_SUPPRESS = "argo.console.suppress";
 313  
 
 314  
     /**
 315  
      * Standard definition of system variable to add text prefix to
 316  
      * console log. (unused)
 317  
      */
 318  
     public static final String ARGO_CONSOLE_PREFIX = "argo.console.prefix";
 319  
     
 320  
     /**
 321  
      * Name of the TagDefinition which is used as the type of tagged values
 322  
      * containing documentation for a model element.
 323  
      */
 324  
     public static final String DOCUMENTATION_TAG = "documentation";
 325  
 
 326  
     /**
 327  
      * Name of the TagDefinition for tagged values containing
 328  
      * the author's name.
 329  
      */
 330  
     public static final String AUTHOR_TAG = "author";
 331  
 
 332  
     /**
 333  
      * Name of the TagDefinition for tagged values containing
 334  
      * since date.
 335  
      */
 336  
     public static final String SINCE_TAG = "since";
 337  
 
 338  
     /**
 339  
      * Name of the TagDefinition for tagged values containing
 340  
      * "see" reference.
 341  
      */
 342  
     public static final String SEE_TAG = "see";
 343  
 
 344  
     /**
 345  
      * Name of the TagDefinition for tagged values containing
 346  
      * deprecated flag.
 347  
      */
 348  
     public static final String DEPRECATED_TAG = "deprecated";
 349  
 
 350  
     /**
 351  
      * Name of the TagDefinition for tagged values containing
 352  
      * version string.
 353  
      */
 354  
     public static final String VERSION_TAG = "version";
 355  
 
 356  
     /**
 357  
      * Alternate name for the TagDefinition which presumably was used at some 
 358  
      * point in the past to contain documentation for a model element.  Only
 359  
      * used for backward compatibilty.
 360  
      * @deprecated for 0.25.1 by tfmorris - don't use for new code.
 361  
      */
 362  
     @Deprecated
 363  
     public static final String DOCUMENTATION_TAG_ALT = "javadocs";
 364  
 
 365  
     /**
 366  
      * The scope of the settings: this setting is stored 
 367  
      * in the userdirectory and valid for the application.
 368  
      */
 369  
     public static final int SCOPE_APPLICATION = 0;
 370  
 
 371  
     /**
 372  
      * The scope of the setting: this setting is stored with the project, 
 373  
      * i.e. in e.g. a zargo file. This setting will also apply 
 374  
      * when the zargo file is opened by another user, 
 375  
      * on another computer. 
 376  
      */
 377  
     public static final int SCOPE_PROJECT = 1;
 378  
     
 379  
     /**
 380  
      * Don't let this class be instantiated.
 381  
      */
 382  0
     private Argo() {
 383  0
     }
 384  
 
 385  
     /**
 386  
      * Change the default startup directory.
 387  
      *
 388  
      * @param dir the directory to save
 389  
      */
 390  
     public static void setDirectory(String dir) {
 391  
         // Store in the user configuration, and
 392  
         // let gef know also.
 393  0
         org.tigris.gef.base.Globals.setLastDirectory(dir);
 394  
 
 395  
         // Configuration.setString(KEY_STARTUP_DIR, dir);
 396  0
     }
 397  
 
 398  
     /**
 399  
      * Get the default startup directory.
 400  
      *
 401  
      * @return the startup directory
 402  
      */
 403  
     public static String getDirectory() {
 404  
         // Use the configuration if it exists, otherwise
 405  
         // use what gef thinks.
 406  919
         return Configuration.getString(KEY_STARTUP_DIR,
 407  
                                        org.tigris.gef.base.Globals
 408  
                                            .getLastDirectory());
 409  
     }
 410  
 
 411  
     static {
 412  900
         if (System.getProperty(ARGO_CONSOLE_SUPPRESS) != null) {
 413  0
             Category.getRoot().getLoggerRepository().setThreshold(Level.OFF);
 414  
         }
 415  900
     }
 416  
 
 417  
     /**
 418  
      * Supply the encoding to be used throughout the persistence
 419  
      * mechanism.
 420  
      * @return the encoding.
 421  
      */
 422  
     public static String getEncoding() {
 423  900
         return "UTF-8";
 424  
     }
 425  
 }