1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*******************************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.html.core.internal;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.wst.common.encoding.CommonCharsetNames;
import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames;
import org.eclipse.wst.html.core.HTMLFilesPreferenceNames;
import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
/**
* The main plugin class to be used in the desktop.
*/
public class HTMLCorePlugin extends Plugin {
//The shared instance.
private static HTMLCorePlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
/**
* The constructor.
*/
public HTMLCorePlugin() {
super();
plugin = this;
try {
resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.html.core.HtmlPluginResources"); //$NON-NLS-1$
}
catch (MissingResourceException x) {
resourceBundle = null;
}
}
/**
* Returns the shared instance.
*/
public static HTMLCorePlugin getDefault() {
return plugin;
}
/**
* Returns the workspace instance.
*/
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle = HTMLCorePlugin.getDefault().getResourceBundle();
try {
return bundle.getString(key);
}
catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences()
*/
protected void initializeDefaultPluginPreferences() {
Preferences prefs = getDefault().getPluginPreferences();
// set model preference defaults
prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS);
prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS);
prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true);
prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true);
prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true);
prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true);
prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false);
prefs.setDefault(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
String defaultEnc = CommonModelPreferenceNames.UTF_8;
String systemEnc = System.getProperty("file.encoding"); //$NON-NLS-1$
if (systemEnc != null) {
defaultEnc = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, CommonModelPreferenceNames.UTF_8);
}
prefs.setDefault(CommonEncodingPreferenceNames.OUTPUT_CODESET, defaultEnc);
prefs.setDefault(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH);
prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, true);
prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72);
prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false);
prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true);
prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false);
prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, true);
prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.LOWER);
prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER);
prefs.setDefault(HTMLFilesPreferenceNames.DEFAULT_SUFFIX, HTMLFilesPreferenceNames.HTML_SUFFIX);
prefs.setDefault(HTMLFilesPreferenceNames.GENERATE_DOCUMENT_TYPE, true);
prefs.setDefault(HTMLFilesPreferenceNames.GENERATE_GENERATOR, true);
}
}
|