001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.swing.plaf.winxp;
043:
044: import javax.swing.UIManager;
045: import javax.swing.plaf.ColorUIResource;
046: import org.netbeans.swing.plaf.LFCustoms;
047: import org.netbeans.swing.plaf.util.GuaranteedValue;
048: import org.netbeans.swing.plaf.util.UIBootstrapValue;
049: import org.netbeans.swing.plaf.util.UIUtils;
050:
051: import javax.swing.*;
052: import javax.swing.border.EmptyBorder;
053: import javax.swing.border.MatteBorder;
054: import java.awt.*;
055: import java.util.logging.Level;
056: import java.util.logging.Logger;
057: import java.util.ResourceBundle;
058:
059: /** Default system-provided customizer for Windows XP LF
060: * Public only to be accessible by ProxyLazyValue, please don't abuse.
061: */
062: public final class XPLFCustoms extends LFCustoms {
063: private static final String TAB_FOCUS_FILL_DARK = "tab_focus_fill_dark"; //NOI18N
064: private static final String TAB_FOCUS_FILL_BRIGHT = "tab_focus_fill_bright"; //NOI18N
065: private static final String TAB_UNSEL_FILL_DARK = "tab_unsel_fill_dark"; //NOI18N
066: private static final String TAB_UNSEL_FILL_BRIGHT = "tab_unsel_fill_bright"; //NOI18N
067: private static final String TAB_SEL_FILL = "tab_sel_fill"; //NOI18N
068: private static final String TAB_SEL_FILL_BRIGHT = "tab_sel_fill_bright"; //NOI18N
069: private static final String TAB_SEL_FILL_DARK = "tab_sel_fill_dark"; //NOI18N
070: private static final String TAB_BORDER = "tab_border"; //NOI18N
071: private static final String TAB_BOTTOM_BORDER = "tab_bottom_border"; //NOI18N
072: private static final String TAB_SEL_BORDER = "tab_sel_border"; //NOI18N
073: private static final String TAB_HIGHLIGHT_HEADER = "tab_highlight_header"; //NOI18N
074: private static final String TAB_HIGHLIGHT_HEADER_FILL = "tab_highlight_header_fill"; //NOI18N
075: private static final String STANDARD_BORDER = "standard_border"; //NOI18N
076: private static final String TAB_CLOSE_BUTTON = "close_button"; //NOI18N
077: private static final String TAB_CLOSE_BUTTON_HIGHLIGHT = "close_button_highlight"; //NOI18N
078: private static final String TAB_CLOSE_BUTTON_BORDER_FOCUS = "close_button_border_focus"; //NOI18N
079: private static final String TAB_CLOSE_BUTTON_BORDER_SELECTED = "close_button_border_selected"; //NOI18N
080: private static final String TAB_CLOSE_BUTTON_BORDER_UNSEL = "close_button_border_unsel"; //NOI18N
081: private static final String TAB_SEL_BOTTOM_BORDER = "tab_sel_bottom_border"; //NOI18N
082:
083: static final String SCROLLPANE_BORDER_COLOR = "scrollpane_border"; //NOI18N
084:
085: public Object[] createLookAndFeelCustomizationKeysAndValues() {
086: int fontsize = 11;
087: Integer in = (Integer) UIManager.get(CUSTOM_FONT_SIZE); //NOI18N
088: if (in != null) {
089: fontsize = in.intValue();
090: }
091:
092: Object[] result = new Object[] {
093: //Work around a bug in windows which sets the text area font to
094: //"MonoSpaced", causing all accessible dialogs to have monospaced text
095: "TextArea.font",
096: new GuaranteedValue("Label.font", new Font("Dialog",
097: Font.PLAIN, fontsize)),
098:
099: EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS,
100: new Insets(17, 0, 17, 0), };
101:
102: tahomaWarning();
103:
104: String version = System.getProperty("java.version");
105: if (version.startsWith("1.5")) {
106: //#112473 - wrong password text field height
107: UIManager.put("PasswordField.font", UIManager
108: .get("TextField.font"));
109: }
110: return result;
111: }
112:
113: public Object[] createApplicationSpecificKeysAndValues() {
114: UIBootstrapValue editorTabsUI = new XPEditorColorings(
115: "org.netbeans.swing.tabcontrol.plaf.WinXPEditorTabDisplayerUI");
116:
117: Object viewTabsUI = editorTabsUI
118: .createShared("org.netbeans.swing.tabcontrol.plaf.WinXPViewTabDisplayerUI");
119:
120: Image explorerIcon = UIUtils
121: .loadImage("org/netbeans/swing/plaf/resources/xp-explorer-folder.gif");
122:
123: Object propertySheetValues = new XPPropertySheetColorings();
124:
125: Object[] uiDefaults = {
126: EDITOR_TAB_DISPLAYER_UI,
127: editorTabsUI,
128: VIEW_TAB_DISPLAYER_UI,
129: viewTabsUI,
130:
131: DESKTOP_BACKGROUND,
132: new Color(226, 223, 214), //NOI18N
133: SCROLLPANE_BORDER_COLOR,
134: new Color(127, 157, 185),
135: DESKTOP_BORDER,
136: new EmptyBorder(6, 5, 4, 6),
137: SCROLLPANE_BORDER,
138: UIManager.get("ScrollPane.border"),
139: EXPLORER_STATUS_BORDER,
140: new StatusLineBorder(StatusLineBorder.TOP),
141: EXPLORER_FOLDER_ICON,
142: explorerIcon,
143: EXPLORER_FOLDER_OPENED_ICON,
144: explorerIcon,
145: EDITOR_STATUS_LEFT_BORDER,
146: new StatusLineBorder(StatusLineBorder.TOP
147: | StatusLineBorder.RIGHT),
148: EDITOR_STATUS_RIGHT_BORDER,
149: new StatusLineBorder(StatusLineBorder.TOP
150: | StatusLineBorder.LEFT),
151: EDITOR_STATUS_INNER_BORDER,
152: new StatusLineBorder(StatusLineBorder.TOP
153: | StatusLineBorder.LEFT
154: | StatusLineBorder.RIGHT),
155: EDITOR_STATUS_ONLYONEBORDER,
156: new StatusLineBorder(StatusLineBorder.TOP),
157: EDITOR_TOOLBAR_BORDER,
158: new EditorToolbarBorder(),
159: OUTPUT_SELECTION_BACKGROUND,
160: new Color(164, 180, 255),
161:
162: PROPERTYSHEET_BOOTSTRAP,
163: propertySheetValues,
164:
165: WORKPLACE_FILL,
166: new Color(226, 223, 214),
167:
168: DESKTOP_SPLITPANE_BORDER,
169: BorderFactory.createEmptyBorder(4, 0, 0, 0),
170: SLIDING_BUTTON_UI,
171: "org.netbeans.swing.tabcontrol.plaf.WinXPSlidingButtonUI",
172:
173: // progress component related
174: "nbProgressBar.Foreground",
175: new Color(49, 106, 197),
176: "nbProgressBar.Background",
177: Color.WHITE,
178: "nbProgressBar.popupDynaText.foreground",
179: new Color(141, 136, 122),
180: "nbProgressBar.popupText.background",
181: new Color(249, 249, 249),
182: "nbProgressBar.popupText.foreground",
183: UIManager.getColor("TextField.foreground"),
184: "nbProgressBar.popupText.selectBackground",
185: UIManager.getColor("List.selectionBackground"),
186: "nbProgressBar.popupText.selectForeground",
187: UIManager.getColor("List.selectionForeground"),
188: PROGRESS_CANCEL_BUTTON_ICON,
189: UIUtils
190: .loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_xp.png")
191:
192: }; //NOI18N
193:
194: //Workaround for JDK 1.5.0 bug 5080144 - Disabled JTextFields stay white
195: //XPTheme uses Color instead of ColorUIResource
196: convert("TextField.background"); //NOI18N
197: convert("TextField.inactiveBackground"); //NOI18N
198: convert("TextField.disabledBackground"); //NOI18N
199:
200: //#108517 - turn off ctrl+page_up and ctrl+page_down mapping
201: return UIUtils
202: .addInputMapsWithoutCtrlPageUpAndCtrlPageDown(uiDefaults);
203: }
204:
205: /**
206: * Takes a UIManager color key and ensures that it is stored as a
207: * ColorUIResource, not a Color.
208: */
209: private static final void convert(String key) {
210: Color c = UIManager.getColor(key);
211: if (c != null && !(c instanceof ColorUIResource)) {
212: UIManager.put(key, new ColorUIResource(c));
213: }
214: }
215:
216: protected Object[] additionalKeys() {
217: Object[] kv = new XPEditorColorings("").createKeysAndValues();
218: Object[] kv2 = new XPPropertySheetColorings()
219: .createKeysAndValues();
220: Object[] result = new Object[(kv.length / 2) + (kv2.length / 2)];
221: int ct = 0;
222: for (int i = 0; i < kv.length; i += 2) {
223: result[ct] = kv[i];
224: ct++;
225: }
226: for (int i = 0; i < kv2.length; i += 2) {
227: result[ct] = kv2[i];
228: ct++;
229: }
230: return result;
231: }
232:
233: /** Prints warning of JDK bug if jdk 1.5.0 or 1.5.0_01 is used -
234: * fonts aren't set to Tahoma, which looks bad.
235: */
236: private void tahomaWarning() {
237: String version = System.getProperty("java.version");
238: if ("1.5.0".equals(version) || version.startsWith("1.5.0_01")) {
239: Logger.getLogger(XPLFCustoms.class.getName()).log(
240: Level.WARNING,
241: ResourceBundle.getBundle(
242: "org.netbeans.swing.plaf.winxp.Bundle")
243: .getString("MSG_TahomaWarning"));
244: }
245: }
246:
247: private class XPEditorColorings extends UIBootstrapValue.Lazy {
248: public XPEditorColorings(String name) {
249: super (name);
250: }
251:
252: public Object[] createKeysAndValues() {
253: return new Object[] {
254: //Tab control - XXX REPLACE WITH RelativeColor - need to figure out base
255: //colors for each color
256: TAB_FOCUS_FILL_DARK,
257: new Color(210, 220, 243),
258: TAB_FOCUS_FILL_BRIGHT,
259: new Color(238, 242, 253),
260: TAB_UNSEL_FILL_DARK,
261: new Color(236, 235, 229),
262: TAB_UNSEL_FILL_BRIGHT,
263: new Color(252, 251, 246),
264: TAB_SEL_FILL,
265: Color.white,
266: TAB_SEL_FILL_BRIGHT,
267: Color.white,
268: TAB_SEL_FILL_DARK,
269: new Color(243, 241, 224),
270: TAB_BORDER,
271: new Color(145, 167, 180),
272: TAB_BOTTOM_BORDER,
273: new Color(127, 157, 185),
274: TAB_SEL_BORDER,
275: new Color(145, 155, 156),
276: TAB_HIGHLIGHT_HEADER,
277: new Color(230, 139, 44),
278: TAB_HIGHLIGHT_HEADER_FILL,
279: new Color(255, 199, 60),
280: STANDARD_BORDER,
281: new Color(127, 157, 185),
282: TAB_CLOSE_BUTTON,
283: Color.black,
284: TAB_CLOSE_BUTTON_HIGHLIGHT,
285: new Color(172, 57, 28),
286: TAB_CLOSE_BUTTON_BORDER_FOCUS,
287: new Color(181, 201, 243),
288: TAB_CLOSE_BUTTON_BORDER_SELECTED,
289: new Color(203, 202, 187),
290: TAB_CLOSE_BUTTON_BORDER_UNSEL,
291: new Color(200, 201, 192),
292: TAB_SEL_BOTTOM_BORDER,
293: new Color(238, 235, 218),
294:
295: //Borders for the tab control
296: EDITOR_TAB_OUTER_BORDER,
297: BorderFactory.createEmptyBorder(),
298: EDITOR_TAB_CONTENT_BORDER,
299: new MatteBorder(0, 1, 1, 1,
300: new Color(127, 157, 185)),
301: EDITOR_TAB_TABS_BORDER,
302: BorderFactory.createEmptyBorder(),
303:
304: VIEW_TAB_OUTER_BORDER,
305: BorderFactory.createEmptyBorder(),
306: VIEW_TAB_CONTENT_BORDER,
307: new MatteBorder(0, 1, 1, 1,
308: new Color(127, 157, 185)),
309: VIEW_TAB_TABS_BORDER,
310: BorderFactory.createEmptyBorder(), };
311: }
312: }
313:
314: private class XPPropertySheetColorings extends
315: UIBootstrapValue.Lazy {
316: public XPPropertySheetColorings() {
317: super ("propertySheet"); //NOI18N
318: }
319:
320: public Object[] createKeysAndValues() {
321: return new Object[] { PROPSHEET_SET_BACKGROUND,
322: new Color(49, 106, 197),
323: PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
324: PROPSHEET_SET_BACKGROUND, new Color(212, 208, 200),
325: PROPSHEET_SET_FOREGROUND, Color.BLACK,
326: PROPSHEET_SELECTED_SET_BACKGROUND,
327: new Color(49, 106, 197),
328: PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
329: PROPSHEET_DISABLED_FOREGROUND,
330: new Color(161, 161, 146),
331: PROPSHEET_BUTTON_FOREGROUND, Color.BLACK, };
332: }
333:
334: }
335: }
|