001: /*
002: * Created on 30.11.2004
003: *
004: * SVN header information:
005: * $Author: javamap $
006: * $Rev: 856 $
007: * $Date: 2007-06-18 21:15:27 -0700 (Mon, 18 Jun 2007) $
008: * $Id: PirolPlugInSettings.java 856 2007-06-19 04:15:27Z javamap $s
009: * $Author: javamap $
010: */
011: package de.fho.jump.pirol.utilities.settings;
012:
013: import java.io.File;
014: import java.text.DecimalFormat;
015: import java.text.NumberFormat;
016:
017: import de.fho.jump.pirol.utilities.debugOutput.DebugUserIds;
018: import de.fho.jump.pirol.utilities.debugOutput.PersonalLogger;
019: import de.fho.jump.pirol.utilities.i18n.PirolPlugInMessages;
020:
021: /**
022: * Holds general information, that have to be available everywhere in the project.
023: *
024: * @author Ole Rahn
025: * <br>
026: * <br>FH Osnabrück - University of Applied Sciences Osnabrück,
027: * <br>Project: PIROL (2005),
028: * <br>Subproject: Daten- und Wissensmanagement
029: *
030: * @version $Rev: 856 $
031: */
032: public class PirolPlugInSettings {
033:
034: protected static PersonalLogger logger = new PersonalLogger(
035: DebugUserIds.ALL);
036:
037: private static final String KEY_PIROLMENUNAME = "PirolMenuName";
038:
039: private static final String KEY_RESULTCATEGORYNAME = "ResultCategoryName";
040:
041: private static final String KEY_COORDINATEMENUNAME = "CoordinateMenuName";
042: private static final String KEY_ATTRIBUTEMENUNAME = "AttributeMenuName";
043: private static final String KEY_SELECTIONMENUNAME = "SelectionMenuName";
044: private static final String KEY_VISUALTOOLSMENUNAME = "VisualTools";
045: private static final String KEY_CONTEXTMENUNAME = "ContextInformation";
046: private static final String KEY_TRANSFERMENUNAME = "TransferTools";
047: private static final String KEY_DATAPRCESSINGMENUNAME = "DataProcessingMenuName";
048:
049: public final static int StandardPlugInIconWidth = 16,
050: StandardPlugInIconHeight = 16;
051: public final static int StandardToolIconWidth = 24,
052: StandardToolIconHeight = 24;
053:
054: private final static String DIRECTORYNAME_OPENJUMP_IN_HOME = ".OpenJump_PIROL";
055:
056: private static String USERSHOMEDIR = null;
057:
058: /**
059: * Default key to store a workbench context in a blackboard.
060: */
061: public final static String KEY_WORKBENCHCONTEXT_IN_BLACKBOARD = "workbenchContext";
062:
063: public static String getName_PirolMenu() {
064: return PirolPlugInMessages.getString(KEY_PIROLMENUNAME);
065: }
066:
067: public static String getName_ProcessingMenu() {
068: return PirolPlugInMessages.getString(KEY_DATAPRCESSINGMENUNAME);
069: }
070:
071: public static String getName_CoordinateMenu() {
072: return PirolPlugInMessages.getString(KEY_COORDINATEMENUNAME);
073: }
074:
075: public static String getName_AttributeMenu() {
076: return PirolPlugInMessages.getString(KEY_ATTRIBUTEMENUNAME);
077: }
078:
079: public static String getName_ContextInformationMenu() {
080: return PirolPlugInMessages.getString(KEY_CONTEXTMENUNAME);
081: }
082:
083: public static String getName_TransferMenu() {
084: return PirolPlugInMessages.getString(KEY_TRANSFERMENUNAME);
085: }
086:
087: public static String getName_SelectionMenu() {
088: return PirolPlugInMessages.getString(KEY_SELECTIONMENUNAME);
089: }
090:
091: /**
092: *@return Name for the tools sub menu containing tools that display something
093: */
094: public static String getName_VisualToolsMenu() {
095: return PirolPlugInMessages.getString(KEY_VISUALTOOLSMENUNAME);
096: }
097:
098: public static String resultLayerCategory() {
099: return PirolPlugInMessages.getString(KEY_RESULTCATEGORYNAME);
100: }
101:
102: public static File configDirectory() {
103: String usersHomeDir = getUsersHomeDir();
104:
105: File dir = null;
106:
107: dir = new File(usersHomeDir + File.separator
108: + DIRECTORYNAME_OPENJUMP_IN_HOME + File.separator
109: + "config" + File.separator);
110:
111: if (!dir.exists()) {
112: dir.mkdirs();
113: }
114:
115: return dir;
116: }
117:
118: public static File tempDirectory() {
119: String usersHomeDir = getUsersHomeDir();
120:
121: File dir = null;
122:
123: dir = new File(usersHomeDir + File.separator
124: + DIRECTORYNAME_OPENJUMP_IN_HOME + File.separator
125: + "tmp" + File.separator);
126:
127: if (!dir.exists()) {
128: dir.mkdirs();
129: }
130:
131: return dir;
132: }
133:
134: private final static String getUsersHomeDir() {
135: while (USERSHOMEDIR == null) {
136: try {
137: if (USERSHOMEDIR == null) {
138: USERSHOMEDIR = System.getProperty("user.home");
139: }
140:
141: if (USERSHOMEDIR != null) {
142: USERSHOMEDIR = new String(USERSHOMEDIR);
143: break;
144: }
145:
146: System.out
147: .println("... waiting to receive the user's HOME directory");
148: Thread.sleep(100);
149:
150: } catch (InterruptedException e) {
151: }
152: }
153: return USERSHOMEDIR;
154: }
155:
156: /**
157: *
158: *@return the standard number format to be used in all dialogs, etc. (... from now on)
159: */
160: public static NumberFormat getDefaultNumberFormat() {
161: DecimalFormat doubleFormat = new DecimalFormat();
162: doubleFormat.setGroupingUsed(false);
163:
164: return doubleFormat;
165: }
166:
167: }
|