1 /* ====================================================================
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2000 The Apache Software Foundation. All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
53 *
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
57 */
58 package com.bonevich.eclipse.logging;
59
60 import org.eclipse.core.resources.IWorkspace;
61 import org.eclipse.core.resources.ResourcesPlugin;
62 import org.eclipse.core.runtime.IPluginDescriptor;
63 import org.eclipse.jface.preference.IPreferenceStore;
64 import org.eclipse.ui.plugin.AbstractUIPlugin;
65
66 import java.util.ResourceBundle;
67
68 /***
69 * The main plugin class to be used in the desktop.
70 * @author jbonevic
71 */
72 public class LoggingPlugin extends AbstractUIPlugin implements LoggingPluginResources
73 {
74 public static final String PREFERENCE_API = "logging.prefs.api";
75 public static final String PREFERENCE_FIELD = "logging.prefs.field";
76 public static final String PREFERENCE_AUTOSAVE = "logging.prefs.autosave";
77 public static final String PREFERENCE_TRACE_CONDITIONALS = "logging.prefs.trace.conditionals";
78 public static final String PREFERENCE_DEBUG_CONDITIONALS = "logging.prefs.debug.conditionals";
79 public static final String PREFERENCE_INFO_CONDITIONALS = "logging.prefs.info.conditionals";
80 public static final String PREFERENCE_WARN_CONDITIONALS = "logging.prefs.warn.conditionals";
81 public static final String PREFERENCE_ERROR_CONDITIONALS = "logging.prefs.error.conditionals";
82 public static final String PREFERENCE_FATAL_CONDITIONALS = "logging.prefs.fatal.conditionals";
83
84 // api implementation values
85 public static final String LOGGING_PREFS_API_COMMONS = "commons";
86 public static final String LOGGING_PREFS_API_JDK_1_4 = "jdk14";
87 public static final String LOGGING_PREFS_API_LOG4J = "log4j";
88 public static final String LOGGING_PREFS_API_AVALON = "avalon";
89
90 public static final String DEFAULT_API_PREF = LOGGING_PREFS_API_COMMONS;
91 public static final String DEFAULT_FIELD_PREF = "_logger";
92 public static final boolean DEFAULT_AUTOSAVE_PREF = false;
93 public static final boolean DEFAULT_TRACE_CONDITIONALS_PREF = true;
94 public static final boolean DEFAULT_DEBUG_CONDITIONALS_PREF = true;
95 public static final boolean DEFAULT_INFO_CONDITIONALS_PREF = true;
96 public static final boolean DEFAULT_WARN_CONDITIONALS_PREF = false;
97 public static final boolean DEFAULT_ERROR_CONDITIONALS_PREF = false;
98 public static final boolean DEFAULT_FATAL_CONDITIONALS_PREF = false;
99
100
101 //The shared instance.
102 private static LoggingPlugin _currentInstance;
103
104 public LoggingPlugin(IPluginDescriptor descriptor)
105 {
106 super(descriptor);
107 _currentInstance = this;
108 }
109
110 public static LoggingPlugin getPlugin()
111 {
112 return _currentInstance;
113 }
114
115 public static IWorkspace getWorkspace()
116 {
117 return ResourcesPlugin.getWorkspace();
118 }
119
120 public ResourceBundle getResourceBundle()
121 {
122 return LoggingPluginMessages.getResourceBundle();
123 }
124
125 protected void initializeDefaultPreferences(IPreferenceStore store)
126 {
127 store.setDefault(PREFERENCE_API, DEFAULT_API_PREF);
128 store.setDefault(PREFERENCE_FIELD, DEFAULT_FIELD_PREF);
129 store.setDefault(PREFERENCE_AUTOSAVE, DEFAULT_AUTOSAVE_PREF);
130 store.setDefault(PREFERENCE_TRACE_CONDITIONALS, DEFAULT_TRACE_CONDITIONALS_PREF);
131 store.setDefault(PREFERENCE_DEBUG_CONDITIONALS, DEFAULT_DEBUG_CONDITIONALS_PREF);
132 store.setDefault(PREFERENCE_INFO_CONDITIONALS, DEFAULT_INFO_CONDITIONALS_PREF);
133 store.setDefault(PREFERENCE_WARN_CONDITIONALS, DEFAULT_WARN_CONDITIONALS_PREF);
134 store.setDefault(PREFERENCE_ERROR_CONDITIONALS, DEFAULT_ERROR_CONDITIONALS_PREF);
135 store.setDefault(PREFERENCE_FATAL_CONDITIONALS, DEFAULT_FATAL_CONDITIONALS_PREF);
136 }
137
138 public String getLoggingImplementationPreference()
139 {
140 return LoggingPlugin.getPlugin().getPreferenceStore().getString(
141 LoggingPlugin.PREFERENCE_API
142 );
143 }
144
145 public String getFieldNamePreference()
146 {
147 return LoggingPlugin.getPlugin().getPreferenceStore().getString(
148 LoggingPlugin.PREFERENCE_FIELD
149 );
150 }
151
152 public boolean getAutoSavePreference()
153 {
154 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
155 LoggingPlugin.PREFERENCE_AUTOSAVE
156 );
157 }
158
159 public boolean getTraceConditionalsPreference()
160 {
161 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
162 LoggingPlugin.PREFERENCE_TRACE_CONDITIONALS
163 );
164 }
165
166 public boolean getDebugConditionalsPreference()
167 {
168 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
169 LoggingPlugin.PREFERENCE_DEBUG_CONDITIONALS
170 );
171 }
172
173 public boolean getInfoConditionalsPreference()
174 {
175 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
176 LoggingPlugin.PREFERENCE_INFO_CONDITIONALS
177 );
178 }
179
180 public boolean getWarnConditionalsPreference()
181 {
182 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
183 LoggingPlugin.PREFERENCE_WARN_CONDITIONALS
184 );
185 }
186
187 public boolean getErrorConditionalsPreference()
188 {
189 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
190 LoggingPlugin.PREFERENCE_ERROR_CONDITIONALS
191 );
192 }
193
194 public boolean getFatalConditionalsPreference()
195 {
196 return LoggingPlugin.getPlugin().getPreferenceStore().getBoolean(
197 LoggingPlugin.PREFERENCE_FATAL_CONDITIONALS
198 );
199 }
200
201 }
This page was automatically generated by Maven