feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
741
jdkSrc/jdk8/sun/swing/plaf/GTKKeybindings.java
Normal file
741
jdkSrc/jdk8/sun/swing/plaf/GTKKeybindings.java
Normal file
@@ -0,0 +1,741 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.swing.plaf;
|
||||
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
|
||||
/**
|
||||
* GTKKeybindings - The standard set of keymaps for the GTK Platform
|
||||
*
|
||||
* @author Jasper Potts
|
||||
*/
|
||||
public class GTKKeybindings {
|
||||
|
||||
/**
|
||||
* Install all GTK keybindings into the provided UIDefaults table
|
||||
*
|
||||
* @param table The UiDefaults table to install into
|
||||
*/
|
||||
public static void installKeybindings(UIDefaults table) {
|
||||
Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", DefaultEditorKit.copyAction,
|
||||
"ctrl V", DefaultEditorKit.pasteAction,
|
||||
"ctrl X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"ctrl LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl A", DefaultEditorKit.selectAllAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", DefaultEditorKit.copyAction,
|
||||
"ctrl V", DefaultEditorKit.pasteAction,
|
||||
"ctrl X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"ctrl LEFT", DefaultEditorKit.beginLineAction,
|
||||
"ctrl KP_LEFT", DefaultEditorKit.beginLineAction,
|
||||
"ctrl RIGHT", DefaultEditorKit.endLineAction,
|
||||
"ctrl KP_RIGHT", DefaultEditorKit.endLineAction,
|
||||
"ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction,
|
||||
"ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction,
|
||||
"ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction,
|
||||
"ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction,
|
||||
"ctrl A", DefaultEditorKit.selectAllAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", DefaultEditorKit.copyAction,
|
||||
"ctrl V", DefaultEditorKit.pasteAction,
|
||||
"ctrl X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"ctrl LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl A", DefaultEditorKit.selectAllAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
|
||||
"UP", DefaultEditorKit.upAction,
|
||||
"KP_UP", DefaultEditorKit.upAction,
|
||||
"DOWN", DefaultEditorKit.downAction,
|
||||
"KP_DOWN", DefaultEditorKit.downAction,
|
||||
"PAGE_UP", DefaultEditorKit.pageUpAction,
|
||||
"PAGE_DOWN", DefaultEditorKit.pageDownAction,
|
||||
"shift PAGE_UP", "selection-page-up",
|
||||
"shift PAGE_DOWN", "selection-page-down",
|
||||
"ctrl shift PAGE_UP", "selection-page-left",
|
||||
"ctrl shift PAGE_DOWN", "selection-page-right",
|
||||
"shift UP", DefaultEditorKit.selectionUpAction,
|
||||
"shift KP_UP", DefaultEditorKit.selectionUpAction,
|
||||
"shift DOWN", DefaultEditorKit.selectionDownAction,
|
||||
"shift KP_DOWN", DefaultEditorKit.selectionDownAction,
|
||||
"ENTER", DefaultEditorKit.insertBreakAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"TAB", DefaultEditorKit.insertTabAction,
|
||||
"ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"ctrl HOME", DefaultEditorKit.beginAction,
|
||||
"ctrl END", DefaultEditorKit.endAction,
|
||||
"ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
|
||||
"ctrl shift END", DefaultEditorKit.selectionEndAction,
|
||||
"ctrl T", "next-link-action",
|
||||
"ctrl shift T", "previous-link-action",
|
||||
"ctrl SPACE", "activate-link-action",
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
|
||||
Object[] defaults = new Object[]{
|
||||
"Button.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released",
|
||||
"ENTER", "pressed",
|
||||
"released ENTER", "released"
|
||||
}),
|
||||
"CheckBox.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"ComboBox.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "hidePopup",
|
||||
"PAGE_UP", "pageUpPassThrough",
|
||||
"PAGE_DOWN", "pageDownPassThrough",
|
||||
"HOME", "homePassThrough",
|
||||
"END", "endPassThrough",
|
||||
"DOWN", "selectNext",
|
||||
"KP_DOWN", "selectNext",
|
||||
"alt DOWN", "togglePopup",
|
||||
"alt KP_DOWN", "togglePopup",
|
||||
"alt UP", "togglePopup",
|
||||
"alt KP_UP", "togglePopup",
|
||||
"SPACE", "spacePopup",
|
||||
"ENTER", "enterPressed",
|
||||
"UP", "selectPrevious",
|
||||
"KP_UP", "selectPrevious"
|
||||
|
||||
}),
|
||||
"EditorPane.focusInputMap", multilineInputMap,
|
||||
"FileChooser.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "cancelSelection",
|
||||
"F2", "editFileName",
|
||||
"F5", "refresh",
|
||||
"BACK_SPACE", "Go Up",
|
||||
"ENTER", "approveSelection",
|
||||
"ctrl ENTER", "approveSelection"
|
||||
}),
|
||||
"FormattedTextField.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", DefaultEditorKit.copyAction,
|
||||
"ctrl V", DefaultEditorKit.pasteAction,
|
||||
"ctrl X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"ctrl LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl A", DefaultEditorKit.selectAllAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"ctrl BACK_SLASH", "unselect",
|
||||
"control shift O", "toggle-componentOrientation",
|
||||
"ESCAPE", "reset-field-edit",
|
||||
"UP", "increment",
|
||||
"KP_UP", "increment",
|
||||
"DOWN", "decrement",
|
||||
"KP_DOWN", "decrement",
|
||||
}),
|
||||
"InternalFrame.windowBindings",
|
||||
new Object[]{
|
||||
"shift ESCAPE", "showSystemMenu",
|
||||
"ctrl SPACE", "showSystemMenu",
|
||||
"ESCAPE", "hideSystemMenu"
|
||||
},
|
||||
"List.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"UP", "selectPreviousRow",
|
||||
"KP_UP", "selectPreviousRow",
|
||||
"shift UP", "selectPreviousRowExtendSelection",
|
||||
"shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl UP", "selectPreviousRowChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousRowChangeLead",
|
||||
"DOWN", "selectNextRow",
|
||||
"KP_DOWN", "selectNextRow",
|
||||
"shift DOWN", "selectNextRowExtendSelection",
|
||||
"shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl DOWN", "selectNextRowChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextRowChangeLead",
|
||||
"LEFT", "selectPreviousColumn",
|
||||
"KP_LEFT", "selectPreviousColumn",
|
||||
"shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl LEFT", "selectPreviousColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectPreviousColumnChangeLead",
|
||||
"RIGHT", "selectNextColumn",
|
||||
"KP_RIGHT", "selectNextColumn",
|
||||
"shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl RIGHT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_RIGHT", "selectNextColumnChangeLead",
|
||||
"HOME", "selectFirstRow",
|
||||
"shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl HOME", "selectFirstRowChangeLead",
|
||||
"END", "selectLastRow",
|
||||
"shift END", "selectLastRowExtendSelection",
|
||||
"ctrl shift END", "selectLastRowExtendSelection",
|
||||
"ctrl END", "selectLastRowChangeLead",
|
||||
"PAGE_UP", "scrollUp",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollUpChangeLead",
|
||||
"PAGE_DOWN", "scrollDown",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollDownChangeLead",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo"
|
||||
}),
|
||||
"List.focusInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"LEFT", "selectNextColumn",
|
||||
"KP_LEFT", "selectNextColumn",
|
||||
"shift LEFT", "selectNextColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl LEFT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectNextColumnChangeLead",
|
||||
"RIGHT", "selectPreviousColumn",
|
||||
"KP_RIGHT", "selectPreviousColumn",
|
||||
"shift RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl RIGHT", "selectPreviousColumnChangeLead",
|
||||
"ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
|
||||
}),
|
||||
"MenuBar.windowBindings", new Object[]{
|
||||
"F10", "takeFocus"
|
||||
},
|
||||
"OptionPane.windowBindings", new Object[]{
|
||||
"ESCAPE", "close"
|
||||
},
|
||||
"PasswordField.focusInputMap", passwordInputMap,
|
||||
"PopupMenu.selectedWindowInputMapBindings",
|
||||
new Object[]{
|
||||
"ESCAPE", "cancel",
|
||||
"DOWN", "selectNext",
|
||||
"KP_DOWN", "selectNext",
|
||||
"UP", "selectPrevious",
|
||||
"KP_UP", "selectPrevious",
|
||||
"LEFT", "selectParent",
|
||||
"KP_LEFT", "selectParent",
|
||||
"RIGHT", "selectChild",
|
||||
"KP_RIGHT", "selectChild",
|
||||
"ENTER", "return",
|
||||
"SPACE", "return"
|
||||
},
|
||||
"PopupMenu.selectedWindowInputMapBindings.RightToLeft",
|
||||
new Object[]{
|
||||
"LEFT", "selectChild",
|
||||
"KP_LEFT", "selectChild",
|
||||
"RIGHT", "selectParent",
|
||||
"KP_RIGHT", "selectParent",
|
||||
},
|
||||
"RadioButton.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released",
|
||||
"RETURN", "pressed"
|
||||
}),
|
||||
"RootPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"shift F10", "postPopup",
|
||||
"CONTEXT_MENU", "postPopup"
|
||||
}),
|
||||
// These bindings are only enabled when there is a default
|
||||
// button set on the rootpane.
|
||||
"RootPane.defaultButtonWindowKeyBindings", new Object[]{
|
||||
"ENTER", "press",
|
||||
"released ENTER", "release",
|
||||
"ctrl ENTER", "press",
|
||||
"ctrl released ENTER", "release"
|
||||
},
|
||||
"ScrollBar.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "positiveUnitIncrement",
|
||||
"KP_RIGHT", "positiveUnitIncrement",
|
||||
"DOWN", "positiveUnitIncrement",
|
||||
"KP_DOWN", "positiveUnitIncrement",
|
||||
"PAGE_DOWN", "positiveBlockIncrement",
|
||||
"LEFT", "negativeUnitIncrement",
|
||||
"KP_LEFT", "negativeUnitIncrement",
|
||||
"UP", "negativeUnitIncrement",
|
||||
"KP_UP", "negativeUnitIncrement",
|
||||
"PAGE_UP", "negativeBlockIncrement",
|
||||
"HOME", "minScroll",
|
||||
"END", "maxScroll"
|
||||
}),
|
||||
"ScrollBar.ancestorInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "negativeUnitIncrement",
|
||||
"KP_RIGHT", "negativeUnitIncrement",
|
||||
"LEFT", "positiveUnitIncrement",
|
||||
"KP_LEFT", "positiveUnitIncrement",
|
||||
}),
|
||||
"ScrollPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "unitScrollRight",
|
||||
"KP_RIGHT", "unitScrollRight",
|
||||
"DOWN", "unitScrollDown",
|
||||
"KP_DOWN", "unitScrollDown",
|
||||
"LEFT", "unitScrollLeft",
|
||||
"KP_LEFT", "unitScrollLeft",
|
||||
"UP", "unitScrollUp",
|
||||
"KP_UP", "unitScrollUp",
|
||||
"PAGE_UP", "scrollUp",
|
||||
"PAGE_DOWN", "scrollDown",
|
||||
"ctrl PAGE_UP", "scrollLeft",
|
||||
"ctrl PAGE_DOWN", "scrollRight",
|
||||
"ctrl HOME", "scrollHome",
|
||||
"ctrl END", "scrollEnd"
|
||||
}),
|
||||
"ScrollPane.ancestorInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl PAGE_UP", "scrollRight",
|
||||
"ctrl PAGE_DOWN", "scrollLeft",
|
||||
}),
|
||||
"Slider.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "positiveUnitIncrement",
|
||||
"KP_RIGHT", "positiveUnitIncrement",
|
||||
"DOWN", "negativeUnitIncrement",
|
||||
"KP_DOWN", "negativeUnitIncrement",
|
||||
"PAGE_DOWN", "negativeBlockIncrement",
|
||||
"LEFT", "negativeUnitIncrement",
|
||||
"KP_LEFT", "negativeUnitIncrement",
|
||||
"UP", "positiveUnitIncrement",
|
||||
"KP_UP", "positiveUnitIncrement",
|
||||
"PAGE_UP", "positiveBlockIncrement",
|
||||
"HOME", "minScroll",
|
||||
"END", "maxScroll"
|
||||
}),
|
||||
"Slider.focusInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "negativeUnitIncrement",
|
||||
"KP_RIGHT", "negativeUnitIncrement",
|
||||
"LEFT", "positiveUnitIncrement",
|
||||
"KP_LEFT", "positiveUnitIncrement",
|
||||
}),
|
||||
"Spinner.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "increment",
|
||||
"KP_UP", "increment",
|
||||
"DOWN", "decrement",
|
||||
"KP_DOWN", "decrement",
|
||||
}),
|
||||
"SplitPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "negativeIncrement",
|
||||
"DOWN", "positiveIncrement",
|
||||
"LEFT", "negativeIncrement",
|
||||
"RIGHT", "positiveIncrement",
|
||||
"KP_UP", "negativeIncrement",
|
||||
"KP_DOWN", "positiveIncrement",
|
||||
"KP_LEFT", "negativeIncrement",
|
||||
"KP_RIGHT", "positiveIncrement",
|
||||
"HOME", "selectMin",
|
||||
"END", "selectMax",
|
||||
"F8", "startResize",
|
||||
"F6", "toggleFocus",
|
||||
"ctrl TAB", "focusOutForward",
|
||||
"ctrl shift TAB", "focusOutBackward"
|
||||
}),
|
||||
"TabbedPane.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "navigateRight",
|
||||
"KP_RIGHT", "navigateRight",
|
||||
"LEFT", "navigateLeft",
|
||||
"KP_LEFT", "navigateLeft",
|
||||
"UP", "navigateUp",
|
||||
"KP_UP", "navigateUp",
|
||||
"DOWN", "navigateDown",
|
||||
"KP_DOWN", "navigateDown",
|
||||
"ctrl DOWN", "requestFocusForVisibleComponent",
|
||||
"ctrl KP_DOWN", "requestFocusForVisibleComponent",
|
||||
"SPACE", "selectTabWithFocus"
|
||||
}),
|
||||
"TabbedPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl TAB", "navigateNext",
|
||||
"ctrl shift TAB", "navigatePrevious",
|
||||
"ctrl PAGE_DOWN", "navigatePageDown",
|
||||
"ctrl PAGE_UP", "navigatePageUp",
|
||||
"ctrl UP", "requestFocus",
|
||||
"ctrl KP_UP", "requestFocus",
|
||||
}),
|
||||
"TableHeader.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[] {
|
||||
"SPACE", "toggleSortOrder",
|
||||
"LEFT", "selectColumnToLeft",
|
||||
"KP_LEFT", "selectColumnToLeft",
|
||||
"RIGHT", "selectColumnToRight",
|
||||
"KP_RIGHT", "selectColumnToRight",
|
||||
"alt LEFT", "moveColumnLeft",
|
||||
"alt KP_LEFT", "moveColumnLeft",
|
||||
"alt RIGHT", "moveColumnRight",
|
||||
"alt KP_RIGHT", "moveColumnRight",
|
||||
"alt shift LEFT", "resizeLeft",
|
||||
"alt shift KP_LEFT", "resizeLeft",
|
||||
"alt shift RIGHT", "resizeRight",
|
||||
"alt shift KP_RIGHT", "resizeRight",
|
||||
"ESCAPE", "focusTable",
|
||||
}),
|
||||
"Table.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"RIGHT", "selectNextColumn",
|
||||
"KP_RIGHT", "selectNextColumn",
|
||||
"shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl RIGHT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_RIGHT", "selectNextColumnChangeLead",
|
||||
"LEFT", "selectPreviousColumn",
|
||||
"KP_LEFT", "selectPreviousColumn",
|
||||
"shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl LEFT", "selectPreviousColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectPreviousColumnChangeLead",
|
||||
"DOWN", "selectNextRow",
|
||||
"KP_DOWN", "selectNextRow",
|
||||
"shift DOWN", "selectNextRowExtendSelection",
|
||||
"shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl DOWN", "selectNextRowChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextRowChangeLead",
|
||||
"UP", "selectPreviousRow",
|
||||
"KP_UP", "selectPreviousRow",
|
||||
"shift UP", "selectPreviousRowExtendSelection",
|
||||
"shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl UP", "selectPreviousRowChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousRowChangeLead",
|
||||
"HOME", "selectFirstColumn",
|
||||
"shift HOME", "selectFirstColumnExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl HOME", "selectFirstRow",
|
||||
"END", "selectLastColumn",
|
||||
"shift END", "selectLastColumnExtendSelection",
|
||||
"ctrl shift END", "selectLastRowExtendSelection",
|
||||
"ctrl END", "selectLastRow",
|
||||
"PAGE_UP", "scrollUpChangeSelection",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollLeftExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollLeftChangeSelection",
|
||||
"PAGE_DOWN", "scrollDownChangeSelection",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollRightChangeSelection",
|
||||
"TAB", "selectNextColumnCell",
|
||||
"shift TAB", "selectPreviousColumnCell",
|
||||
"ENTER", "selectNextRowCell",
|
||||
"shift ENTER", "selectPreviousRowCell",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"ESCAPE", "cancel",
|
||||
"F2", "startEditing",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo",
|
||||
"F8", "focusHeader"
|
||||
}),
|
||||
"Table.ancestorInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "selectPreviousColumn",
|
||||
"KP_RIGHT", "selectPreviousColumn",
|
||||
"shift RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
|
||||
"shift RIGHT", "selectPreviousColumnChangeLead",
|
||||
"shift KP_RIGHT", "selectPreviousColumnChangeLead",
|
||||
"LEFT", "selectNextColumn",
|
||||
"KP_LEFT", "selectNextColumn",
|
||||
"shift LEFT", "selectNextColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
|
||||
"ctrl LEFT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectNextColumnChangeLead",
|
||||
"ctrl PAGE_UP", "scrollRightChangeSelection",
|
||||
"ctrl PAGE_DOWN", "scrollLeftChangeSelection",
|
||||
"ctrl shift PAGE_UP", "scrollRightExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
|
||||
}),
|
||||
"TextArea.focusInputMap", multilineInputMap,
|
||||
"TextField.focusInputMap", fieldInputMap,
|
||||
"TextPane.focusInputMap", multilineInputMap,
|
||||
"ToggleButton.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"ToolBar.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "navigateUp",
|
||||
"KP_UP", "navigateUp",
|
||||
"DOWN", "navigateDown",
|
||||
"KP_DOWN", "navigateDown",
|
||||
"LEFT", "navigateLeft",
|
||||
"KP_LEFT", "navigateLeft",
|
||||
"RIGHT", "navigateRight",
|
||||
"KP_RIGHT", "navigateRight"
|
||||
}),
|
||||
"Tree.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"UP", "selectPrevious",
|
||||
"KP_UP", "selectPrevious",
|
||||
"shift UP", "selectPreviousExtendSelection",
|
||||
"shift KP_UP", "selectPreviousExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousExtendSelection",
|
||||
"ctrl UP", "selectPreviousChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousChangeLead",
|
||||
"DOWN", "selectNext",
|
||||
"KP_DOWN", "selectNext",
|
||||
"shift DOWN", "selectNextExtendSelection",
|
||||
"shift KP_DOWN", "selectNextExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextExtendSelection",
|
||||
"ctrl DOWN", "selectNextChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextChangeLead",
|
||||
"RIGHT", "selectChild",
|
||||
"KP_RIGHT", "selectChild",
|
||||
"LEFT", "selectParent",
|
||||
"KP_LEFT", "selectParent",
|
||||
"typed +", "expand",
|
||||
"typed -", "collapse",
|
||||
"BACK_SPACE", "moveSelectionToParent",
|
||||
"PAGE_UP", "scrollUpChangeSelection",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollUpChangeLead",
|
||||
"PAGE_DOWN", "scrollDownChangeSelection",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollDownChangeLead",
|
||||
"HOME", "selectFirst",
|
||||
"shift HOME", "selectFirstExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstExtendSelection",
|
||||
"ctrl HOME", "selectFirstChangeLead",
|
||||
"END", "selectLast",
|
||||
"shift END", "selectLastExtendSelection",
|
||||
"ctrl shift END", "selectLastExtendSelection",
|
||||
"ctrl END", "selectLastChangeLead",
|
||||
"F2", "startEditing",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"ctrl LEFT", "scrollLeft",
|
||||
"ctrl KP_LEFT", "scrollLeft",
|
||||
"ctrl RIGHT", "scrollRight",
|
||||
"ctrl KP_RIGHT", "scrollRight",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo"
|
||||
}),
|
||||
"Tree.focusInputMap.RightToLeft",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "selectParent",
|
||||
"KP_RIGHT", "selectParent",
|
||||
"LEFT", "selectChild",
|
||||
"KP_LEFT", "selectChild",
|
||||
}),
|
||||
"Tree.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "cancel"
|
||||
}),
|
||||
};
|
||||
table.putDefaults(defaults);
|
||||
}
|
||||
}
|
||||
648
jdkSrc/jdk8/sun/swing/plaf/WindowsKeybindings.java
Normal file
648
jdkSrc/jdk8/sun/swing/plaf/WindowsKeybindings.java
Normal file
@@ -0,0 +1,648 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.swing.plaf;
|
||||
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
|
||||
/**
|
||||
* WindowsKeybindings - The standard set of keymaps for the Windows Platform
|
||||
*
|
||||
* @author Jasper Potts
|
||||
*/
|
||||
public class WindowsKeybindings {
|
||||
|
||||
/**
|
||||
* Install all Windows keybindings into the provided UIDefaults table
|
||||
*
|
||||
* @param table The UiDefaults table to install into
|
||||
*/
|
||||
public static void installKeybindings(UIDefaults table) {
|
||||
// *** Text
|
||||
Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"control C", DefaultEditorKit.copyAction,
|
||||
"control V", DefaultEditorKit.pasteAction,
|
||||
"control X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"control A", DefaultEditorKit.selectAllAction,
|
||||
"control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"control LEFT", DefaultEditorKit.previousWordAction,
|
||||
"control RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"control C", DefaultEditorKit.copyAction,
|
||||
"control V", DefaultEditorKit.pasteAction,
|
||||
"control X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"control A", DefaultEditorKit.selectAllAction,
|
||||
"control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"control LEFT", DefaultEditorKit.beginLineAction,
|
||||
"control RIGHT", DefaultEditorKit.endLineAction,
|
||||
"control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
|
||||
"control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[]{
|
||||
"control C", DefaultEditorKit.copyAction,
|
||||
"control V", DefaultEditorKit.pasteAction,
|
||||
"control X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"control LEFT", DefaultEditorKit.previousWordAction,
|
||||
"control RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"control A", DefaultEditorKit.selectAllAction,
|
||||
"control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"control HOME", DefaultEditorKit.beginAction,
|
||||
"control END", DefaultEditorKit.endAction,
|
||||
"control shift HOME", DefaultEditorKit.selectionBeginAction,
|
||||
"control shift END", DefaultEditorKit.selectionEndAction,
|
||||
"UP", DefaultEditorKit.upAction,
|
||||
"DOWN", DefaultEditorKit.downAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"PAGE_UP", DefaultEditorKit.pageUpAction,
|
||||
"PAGE_DOWN", DefaultEditorKit.pageDownAction,
|
||||
"shift PAGE_UP", "selection-page-up",
|
||||
"shift PAGE_DOWN", "selection-page-down",
|
||||
"ctrl shift PAGE_UP", "selection-page-left",
|
||||
"ctrl shift PAGE_DOWN", "selection-page-right",
|
||||
"shift UP", DefaultEditorKit.selectionUpAction,
|
||||
"shift DOWN", DefaultEditorKit.selectionDownAction,
|
||||
"ENTER", DefaultEditorKit.insertBreakAction,
|
||||
"TAB", DefaultEditorKit.insertTabAction,
|
||||
"control T", "next-link-action",
|
||||
"control shift T", "previous-link-action",
|
||||
"control SPACE", "activate-link-action",
|
||||
"control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
|
||||
});
|
||||
Object[] defaults = {
|
||||
"TextField.focusInputMap", fieldInputMap,
|
||||
"PasswordField.focusInputMap", passwordInputMap,
|
||||
"TextArea.focusInputMap", multilineInputMap,
|
||||
"TextPane.focusInputMap", multilineInputMap,
|
||||
"EditorPane.focusInputMap", multilineInputMap,
|
||||
"Button.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"CheckBox.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "hidePopup",
|
||||
"PAGE_UP", "pageUpPassThrough",
|
||||
"PAGE_DOWN", "pageDownPassThrough",
|
||||
"HOME", "homePassThrough",
|
||||
"END", "endPassThrough",
|
||||
"DOWN", "selectNext2",
|
||||
"KP_DOWN", "selectNext2",
|
||||
"UP", "selectPrevious2",
|
||||
"KP_UP", "selectPrevious2",
|
||||
"ENTER", "enterPressed",
|
||||
"F4", "togglePopup",
|
||||
"alt DOWN", "togglePopup",
|
||||
"alt KP_DOWN", "togglePopup",
|
||||
"alt UP", "togglePopup",
|
||||
"alt KP_UP", "togglePopup"
|
||||
}),
|
||||
"Desktop.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl F5", "restore",
|
||||
"ctrl F4", "close",
|
||||
"ctrl F7", "move",
|
||||
"ctrl F8", "resize",
|
||||
"RIGHT", "right",
|
||||
"KP_RIGHT", "right",
|
||||
"LEFT", "left",
|
||||
"KP_LEFT", "left",
|
||||
"UP", "up",
|
||||
"KP_UP", "up",
|
||||
"DOWN", "down",
|
||||
"KP_DOWN", "down",
|
||||
"ESCAPE", "escape",
|
||||
"ctrl F9", "minimize",
|
||||
"ctrl F10", "maximize",
|
||||
"ctrl F6", "selectNextFrame",
|
||||
"ctrl TAB", "selectNextFrame",
|
||||
"ctrl alt F6", "selectNextFrame",
|
||||
"shift ctrl alt F6", "selectPreviousFrame",
|
||||
"ctrl F12", "navigateNext",
|
||||
"shift ctrl F12", "navigatePrevious"
|
||||
}),
|
||||
"FileChooser.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "cancelSelection",
|
||||
"F2", "editFileName",
|
||||
"F5", "refresh",
|
||||
"BACK_SPACE", "Go Up",
|
||||
"ENTER", "approveSelection",
|
||||
"ctrl ENTER", "approveSelection"
|
||||
}),
|
||||
"InternalFrame.windowBindings", new Object[]{
|
||||
"shift ESCAPE", "showSystemMenu",
|
||||
"ctrl SPACE", "showSystemMenu",
|
||||
"ESCAPE", "hideSystemMenu"
|
||||
},
|
||||
"List.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"UP", "selectPreviousRow",
|
||||
"KP_UP", "selectPreviousRow",
|
||||
"shift UP", "selectPreviousRowExtendSelection",
|
||||
"shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl UP", "selectPreviousRowChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousRowChangeLead",
|
||||
"DOWN", "selectNextRow",
|
||||
"KP_DOWN", "selectNextRow",
|
||||
"shift DOWN", "selectNextRowExtendSelection",
|
||||
"shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl DOWN", "selectNextRowChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextRowChangeLead",
|
||||
"LEFT", "selectPreviousColumn",
|
||||
"KP_LEFT", "selectPreviousColumn",
|
||||
"shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl LEFT", "selectPreviousColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectPreviousColumnChangeLead",
|
||||
"RIGHT", "selectNextColumn",
|
||||
"KP_RIGHT", "selectNextColumn",
|
||||
"shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl RIGHT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_RIGHT", "selectNextColumnChangeLead",
|
||||
"HOME", "selectFirstRow",
|
||||
"shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl HOME", "selectFirstRowChangeLead",
|
||||
"END", "selectLastRow",
|
||||
"shift END", "selectLastRowExtendSelection",
|
||||
"ctrl shift END", "selectLastRowExtendSelection",
|
||||
"ctrl END", "selectLastRowChangeLead",
|
||||
"PAGE_UP", "scrollUp",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollUpChangeLead",
|
||||
"PAGE_DOWN", "scrollDown",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollDownChangeLead",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo"
|
||||
}),
|
||||
"MenuBar.windowBindings", new Object[]{
|
||||
"F10", "takeFocus"
|
||||
},
|
||||
"RadioButton.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"OptionPane.windowBindings", new Object[]{
|
||||
"ESCAPE", "close"
|
||||
},
|
||||
"FormattedTextField.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", DefaultEditorKit.copyAction,
|
||||
"ctrl V", DefaultEditorKit.pasteAction,
|
||||
"ctrl X", DefaultEditorKit.cutAction,
|
||||
"COPY", DefaultEditorKit.copyAction,
|
||||
"PASTE", DefaultEditorKit.pasteAction,
|
||||
"CUT", DefaultEditorKit.cutAction,
|
||||
"control INSERT", DefaultEditorKit.copyAction,
|
||||
"shift INSERT", DefaultEditorKit.pasteAction,
|
||||
"shift DELETE", DefaultEditorKit.cutAction,
|
||||
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
|
||||
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
|
||||
"ctrl LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
|
||||
"ctrl RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
|
||||
"ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
|
||||
"ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
|
||||
"ctrl A", DefaultEditorKit.selectAllAction,
|
||||
"HOME", DefaultEditorKit.beginLineAction,
|
||||
"END", DefaultEditorKit.endLineAction,
|
||||
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
|
||||
"shift END", DefaultEditorKit.selectionEndLineAction,
|
||||
"BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
|
||||
"ctrl H", DefaultEditorKit.deletePrevCharAction,
|
||||
"DELETE", DefaultEditorKit.deleteNextCharAction,
|
||||
"ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
|
||||
"ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
|
||||
"RIGHT", DefaultEditorKit.forwardAction,
|
||||
"LEFT", DefaultEditorKit.backwardAction,
|
||||
"KP_RIGHT", DefaultEditorKit.forwardAction,
|
||||
"KP_LEFT", DefaultEditorKit.backwardAction,
|
||||
"ENTER", JTextField.notifyAction,
|
||||
"ctrl BACK_SLASH", "unselect",
|
||||
"control shift O", "toggle-componentOrientation",
|
||||
"ESCAPE", "reset-field-edit",
|
||||
"UP", "increment",
|
||||
"KP_UP", "increment",
|
||||
"DOWN", "decrement",
|
||||
"KP_DOWN", "decrement",
|
||||
}),
|
||||
"RootPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"shift F10", "postPopup",
|
||||
"CONTEXT_MENU", "postPopup"
|
||||
}),
|
||||
// These bindings are only enabled when there is a default
|
||||
// button set on the rootpane.
|
||||
"RootPane.defaultButtonWindowKeyBindings", new Object[]{
|
||||
"ENTER", "press",
|
||||
"released ENTER", "release",
|
||||
"ctrl ENTER", "press",
|
||||
"ctrl released ENTER", "release"
|
||||
},
|
||||
"ScrollBar.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "positiveUnitIncrement",
|
||||
"KP_RIGHT", "positiveUnitIncrement",
|
||||
"DOWN", "positiveUnitIncrement",
|
||||
"KP_DOWN", "positiveUnitIncrement",
|
||||
"PAGE_DOWN", "positiveBlockIncrement",
|
||||
"ctrl PAGE_DOWN", "positiveBlockIncrement",
|
||||
"LEFT", "negativeUnitIncrement",
|
||||
"KP_LEFT", "negativeUnitIncrement",
|
||||
"UP", "negativeUnitIncrement",
|
||||
"KP_UP", "negativeUnitIncrement",
|
||||
"PAGE_UP", "negativeBlockIncrement",
|
||||
"ctrl PAGE_UP", "negativeBlockIncrement",
|
||||
"HOME", "minScroll",
|
||||
"END", "maxScroll"
|
||||
}),
|
||||
"ScrollPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "unitScrollRight",
|
||||
"KP_RIGHT", "unitScrollRight",
|
||||
"DOWN", "unitScrollDown",
|
||||
"KP_DOWN", "unitScrollDown",
|
||||
"LEFT", "unitScrollLeft",
|
||||
"KP_LEFT", "unitScrollLeft",
|
||||
"UP", "unitScrollUp",
|
||||
"KP_UP", "unitScrollUp",
|
||||
"PAGE_UP", "scrollUp",
|
||||
"PAGE_DOWN", "scrollDown",
|
||||
"ctrl PAGE_UP", "scrollLeft",
|
||||
"ctrl PAGE_DOWN", "scrollRight",
|
||||
"ctrl HOME", "scrollHome",
|
||||
"ctrl END", "scrollEnd"
|
||||
}),
|
||||
"Slider.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "positiveUnitIncrement",
|
||||
"KP_RIGHT", "positiveUnitIncrement",
|
||||
"DOWN", "negativeUnitIncrement",
|
||||
"KP_DOWN", "negativeUnitIncrement",
|
||||
"PAGE_DOWN", "negativeBlockIncrement",
|
||||
"LEFT", "negativeUnitIncrement",
|
||||
"KP_LEFT", "negativeUnitIncrement",
|
||||
"UP", "positiveUnitIncrement",
|
||||
"KP_UP", "positiveUnitIncrement",
|
||||
"PAGE_UP", "positiveBlockIncrement",
|
||||
"HOME", "minScroll",
|
||||
"END", "maxScroll"
|
||||
}),
|
||||
"Spinner.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "increment",
|
||||
"KP_UP", "increment",
|
||||
"DOWN", "decrement",
|
||||
"KP_DOWN", "decrement",
|
||||
}),
|
||||
"SplitPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "negativeIncrement",
|
||||
"DOWN", "positiveIncrement",
|
||||
"LEFT", "negativeIncrement",
|
||||
"RIGHT", "positiveIncrement",
|
||||
"KP_UP", "negativeIncrement",
|
||||
"KP_DOWN", "positiveIncrement",
|
||||
"KP_LEFT", "negativeIncrement",
|
||||
"KP_RIGHT", "positiveIncrement",
|
||||
"HOME", "selectMin",
|
||||
"END", "selectMax",
|
||||
"F8", "startResize",
|
||||
"F6", "toggleFocus",
|
||||
"ctrl TAB", "focusOutForward",
|
||||
"ctrl shift TAB", "focusOutBackward"
|
||||
}),
|
||||
"TabbedPane.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"RIGHT", "navigateRight",
|
||||
"KP_RIGHT", "navigateRight",
|
||||
"LEFT", "navigateLeft",
|
||||
"KP_LEFT", "navigateLeft",
|
||||
"UP", "navigateUp",
|
||||
"KP_UP", "navigateUp",
|
||||
"DOWN", "navigateDown",
|
||||
"KP_DOWN", "navigateDown",
|
||||
"ctrl DOWN", "requestFocusForVisibleComponent",
|
||||
"ctrl KP_DOWN", "requestFocusForVisibleComponent",
|
||||
}),
|
||||
"TabbedPane.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl TAB", "navigateNext",
|
||||
"ctrl shift TAB", "navigatePrevious",
|
||||
"ctrl PAGE_DOWN", "navigatePageDown",
|
||||
"ctrl PAGE_UP", "navigatePageUp",
|
||||
"ctrl UP", "requestFocus",
|
||||
"ctrl KP_UP", "requestFocus",
|
||||
}),
|
||||
"TableHeader.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[] {
|
||||
"SPACE", "toggleSortOrder",
|
||||
"LEFT", "selectColumnToLeft",
|
||||
"KP_LEFT", "selectColumnToLeft",
|
||||
"RIGHT", "selectColumnToRight",
|
||||
"KP_RIGHT", "selectColumnToRight",
|
||||
"alt LEFT", "moveColumnLeft",
|
||||
"alt KP_LEFT", "moveColumnLeft",
|
||||
"alt RIGHT", "moveColumnRight",
|
||||
"alt KP_RIGHT", "moveColumnRight",
|
||||
"alt shift LEFT", "resizeLeft",
|
||||
"alt shift KP_LEFT", "resizeLeft",
|
||||
"alt shift RIGHT", "resizeRight",
|
||||
"alt shift KP_RIGHT", "resizeRight",
|
||||
"ESCAPE", "focusTable",
|
||||
}),
|
||||
"Table.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"RIGHT", "selectNextColumn",
|
||||
"KP_RIGHT", "selectNextColumn",
|
||||
"shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
|
||||
"ctrl RIGHT", "selectNextColumnChangeLead",
|
||||
"ctrl KP_RIGHT", "selectNextColumnChangeLead",
|
||||
"LEFT", "selectPreviousColumn",
|
||||
"KP_LEFT", "selectPreviousColumn",
|
||||
"shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
|
||||
"ctrl LEFT", "selectPreviousColumnChangeLead",
|
||||
"ctrl KP_LEFT", "selectPreviousColumnChangeLead",
|
||||
"DOWN", "selectNextRow",
|
||||
"KP_DOWN", "selectNextRow",
|
||||
"shift DOWN", "selectNextRowExtendSelection",
|
||||
"shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextRowExtendSelection",
|
||||
"ctrl DOWN", "selectNextRowChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextRowChangeLead",
|
||||
"UP", "selectPreviousRow",
|
||||
"KP_UP", "selectPreviousRow",
|
||||
"shift UP", "selectPreviousRowExtendSelection",
|
||||
"shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousRowExtendSelection",
|
||||
"ctrl UP", "selectPreviousRowChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousRowChangeLead",
|
||||
"HOME", "selectFirstColumn",
|
||||
"shift HOME", "selectFirstColumnExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstRowExtendSelection",
|
||||
"ctrl HOME", "selectFirstRow",
|
||||
"END", "selectLastColumn",
|
||||
"shift END", "selectLastColumnExtendSelection",
|
||||
"ctrl shift END", "selectLastRowExtendSelection",
|
||||
"ctrl END", "selectLastRow",
|
||||
"PAGE_UP", "scrollUpChangeSelection",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollLeftExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollLeftChangeSelection",
|
||||
"PAGE_DOWN", "scrollDownChangeSelection",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollRightChangeSelection",
|
||||
"TAB", "selectNextColumnCell",
|
||||
"shift TAB", "selectPreviousColumnCell",
|
||||
"ENTER", "selectNextRowCell",
|
||||
"shift ENTER", "selectPreviousRowCell",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"ESCAPE", "cancel",
|
||||
"F2", "startEditing",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo",
|
||||
"F8", "focusHeader"
|
||||
}),
|
||||
"ToggleButton.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"SPACE", "pressed",
|
||||
"released SPACE", "released"
|
||||
}),
|
||||
"ToolBar.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"UP", "navigateUp",
|
||||
"KP_UP", "navigateUp",
|
||||
"DOWN", "navigateDown",
|
||||
"KP_DOWN", "navigateDown",
|
||||
"LEFT", "navigateLeft",
|
||||
"KP_LEFT", "navigateLeft",
|
||||
"RIGHT", "navigateRight",
|
||||
"KP_RIGHT", "navigateRight"
|
||||
}),
|
||||
"Tree.focusInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ADD", "expand",
|
||||
"SUBTRACT", "collapse",
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
"control INSERT", "copy",
|
||||
"shift INSERT", "paste",
|
||||
"shift DELETE", "cut",
|
||||
"UP", "selectPrevious",
|
||||
"KP_UP", "selectPrevious",
|
||||
"shift UP", "selectPreviousExtendSelection",
|
||||
"shift KP_UP", "selectPreviousExtendSelection",
|
||||
"ctrl shift UP", "selectPreviousExtendSelection",
|
||||
"ctrl shift KP_UP", "selectPreviousExtendSelection",
|
||||
"ctrl UP", "selectPreviousChangeLead",
|
||||
"ctrl KP_UP", "selectPreviousChangeLead",
|
||||
"DOWN", "selectNext",
|
||||
"KP_DOWN", "selectNext",
|
||||
"shift DOWN", "selectNextExtendSelection",
|
||||
"shift KP_DOWN", "selectNextExtendSelection",
|
||||
"ctrl shift DOWN", "selectNextExtendSelection",
|
||||
"ctrl shift KP_DOWN", "selectNextExtendSelection",
|
||||
"ctrl DOWN", "selectNextChangeLead",
|
||||
"ctrl KP_DOWN", "selectNextChangeLead",
|
||||
"RIGHT", "selectChild",
|
||||
"KP_RIGHT", "selectChild",
|
||||
"LEFT", "selectParent",
|
||||
"KP_LEFT", "selectParent",
|
||||
"PAGE_UP", "scrollUpChangeSelection",
|
||||
"shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl shift PAGE_UP", "scrollUpExtendSelection",
|
||||
"ctrl PAGE_UP", "scrollUpChangeLead",
|
||||
"PAGE_DOWN", "scrollDownChangeSelection",
|
||||
"shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
|
||||
"ctrl PAGE_DOWN", "scrollDownChangeLead",
|
||||
"HOME", "selectFirst",
|
||||
"shift HOME", "selectFirstExtendSelection",
|
||||
"ctrl shift HOME", "selectFirstExtendSelection",
|
||||
"ctrl HOME", "selectFirstChangeLead",
|
||||
"END", "selectLast",
|
||||
"shift END", "selectLastExtendSelection",
|
||||
"ctrl shift END", "selectLastExtendSelection",
|
||||
"ctrl END", "selectLastChangeLead",
|
||||
"F2", "startEditing",
|
||||
"ctrl A", "selectAll",
|
||||
"ctrl SLASH", "selectAll",
|
||||
"ctrl BACK_SLASH", "clearSelection",
|
||||
"ctrl LEFT", "scrollLeft",
|
||||
"ctrl KP_LEFT", "scrollLeft",
|
||||
"ctrl RIGHT", "scrollRight",
|
||||
"ctrl KP_RIGHT", "scrollRight",
|
||||
"SPACE", "addToSelection",
|
||||
"ctrl SPACE", "toggleAndAnchor",
|
||||
"shift SPACE", "extendTo",
|
||||
"ctrl shift SPACE", "moveSelectionTo"
|
||||
}),
|
||||
"Tree.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
"ESCAPE", "cancel"
|
||||
}),
|
||||
};
|
||||
table.putDefaults(defaults);
|
||||
}
|
||||
|
||||
}
|
||||
927
jdkSrc/jdk8/sun/swing/plaf/synth/DefaultSynthStyle.java
Normal file
927
jdkSrc/jdk8/sun/swing/plaf/synth/DefaultSynthStyle.java
Normal file
@@ -0,0 +1,927 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.synth;
|
||||
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
/**
|
||||
* Default implementation of SynthStyle. Has setters for the various
|
||||
* SynthStyle methods. Many of the properties can be specified for all states,
|
||||
* using SynthStyle directly, or a specific state using one of the StateInfo
|
||||
* methods.
|
||||
* <p>
|
||||
* Beyond the constructor a subclass should override the <code>addTo</code>
|
||||
* and <code>clone</code> methods, these are used when the Styles are being
|
||||
* merged into a resulting style.
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public class DefaultSynthStyle extends SynthStyle implements Cloneable {
|
||||
|
||||
private static final Object PENDING = new Object();
|
||||
|
||||
/**
|
||||
* Should the component be opaque?
|
||||
*/
|
||||
private boolean opaque;
|
||||
/**
|
||||
* Insets.
|
||||
*/
|
||||
private Insets insets;
|
||||
/**
|
||||
* Information specific to ComponentState.
|
||||
*/
|
||||
private StateInfo[] states;
|
||||
/**
|
||||
* User specific data.
|
||||
*/
|
||||
private Map data;
|
||||
|
||||
/**
|
||||
* Font to use if there is no matching StateInfo, or the StateInfo doesn't
|
||||
* define one.
|
||||
*/
|
||||
private Font font;
|
||||
|
||||
/**
|
||||
* SynthGraphics, may be null.
|
||||
*/
|
||||
private SynthGraphicsUtils synthGraphics;
|
||||
|
||||
/**
|
||||
* Painter to use if the StateInfo doesn't have one.
|
||||
*/
|
||||
private SynthPainter painter;
|
||||
|
||||
|
||||
/**
|
||||
* Nullary constructor, intended for subclassers.
|
||||
*/
|
||||
public DefaultSynthStyle() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new DefaultSynthStyle that is a copy of the passed in
|
||||
* style. Any StateInfo's of the passed in style are clonsed as well.
|
||||
*
|
||||
* @param style Style to duplicate
|
||||
*/
|
||||
public DefaultSynthStyle(DefaultSynthStyle style) {
|
||||
opaque = style.opaque;
|
||||
if (style.insets != null) {
|
||||
insets = new Insets(style.insets.top, style.insets.left,
|
||||
style.insets.bottom, style.insets.right);
|
||||
}
|
||||
if (style.states != null) {
|
||||
states = new StateInfo[style.states.length];
|
||||
for (int counter = style.states.length - 1; counter >= 0;
|
||||
counter--) {
|
||||
states[counter] = (StateInfo)style.states[counter].clone();
|
||||
}
|
||||
}
|
||||
if (style.data != null) {
|
||||
data = new HashMap();
|
||||
data.putAll(style.data);
|
||||
}
|
||||
font = style.font;
|
||||
synthGraphics = style.synthGraphics;
|
||||
painter = style.painter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new DefaultSynthStyle.
|
||||
*
|
||||
* @param insets Insets for the Style
|
||||
* @param opaque Whether or not the background is completely painted in
|
||||
* an opaque color
|
||||
* @param states StateInfos describing properties per state
|
||||
* @param data Style specific data.
|
||||
*/
|
||||
public DefaultSynthStyle(Insets insets, boolean opaque,
|
||||
StateInfo[] states, Map data) {
|
||||
this.insets = insets;
|
||||
this.opaque = opaque;
|
||||
this.states = states;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Color getColor(SynthContext context, ColorType type) {
|
||||
return getColor(context.getComponent(), context.getRegion(),
|
||||
context.getComponentState(), type);
|
||||
}
|
||||
|
||||
public Color getColor(JComponent c, Region id, int state,
|
||||
ColorType type) {
|
||||
// For the enabled state, prefer the widget's colors
|
||||
if (!id.isSubregion() && state == SynthConstants.ENABLED) {
|
||||
if (type == ColorType.BACKGROUND) {
|
||||
return c.getBackground();
|
||||
}
|
||||
else if (type == ColorType.FOREGROUND) {
|
||||
return c.getForeground();
|
||||
}
|
||||
else if (type == ColorType.TEXT_FOREGROUND) {
|
||||
// If getForeground returns a non-UIResource it means the
|
||||
// developer has explicitly set the foreground, use it over
|
||||
// that of TEXT_FOREGROUND as that is typically the expected
|
||||
// behavior.
|
||||
Color color = c.getForeground();
|
||||
if (!(color instanceof UIResource)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Then use what we've locally defined
|
||||
Color color = getColorForState(c, id, state, type);
|
||||
if (color == null) {
|
||||
// No color, fallback to that of the widget.
|
||||
if (type == ColorType.BACKGROUND ||
|
||||
type == ColorType.TEXT_BACKGROUND) {
|
||||
return c.getBackground();
|
||||
}
|
||||
else if (type == ColorType.FOREGROUND ||
|
||||
type == ColorType.TEXT_FOREGROUND) {
|
||||
return c.getForeground();
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
protected Color getColorForState(SynthContext context, ColorType type) {
|
||||
return getColorForState(context.getComponent(), context.getRegion(),
|
||||
context.getComponentState(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color for the specified state.
|
||||
*
|
||||
* @param c JComponent the style is associated with
|
||||
* @param id Region identifier
|
||||
* @param state State of the region.
|
||||
* @param type Type of color being requested.
|
||||
* @return Color to render with
|
||||
*/
|
||||
protected Color getColorForState(JComponent c, Region id, int state,
|
||||
ColorType type) {
|
||||
// Use the best state.
|
||||
StateInfo si = getStateInfo(state);
|
||||
Color color;
|
||||
if (si != null && (color = si.getColor(type)) != null) {
|
||||
return color;
|
||||
}
|
||||
if (si == null || si.getComponentState() != 0) {
|
||||
si = getStateInfo(0);
|
||||
if (si != null) {
|
||||
return si.getColor(type);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font that is used if there is no matching StateInfo, or
|
||||
* it does not define a font.
|
||||
*
|
||||
* @param font Font to use for rendering
|
||||
*/
|
||||
public void setFont(Font font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public Font getFont(SynthContext state) {
|
||||
return getFont(state.getComponent(), state.getRegion(),
|
||||
state.getComponentState());
|
||||
}
|
||||
|
||||
public Font getFont(JComponent c, Region id, int state) {
|
||||
if (!id.isSubregion() && state == SynthConstants.ENABLED) {
|
||||
return c.getFont();
|
||||
}
|
||||
Font cFont = c.getFont();
|
||||
if (cFont != null && !(cFont instanceof UIResource)) {
|
||||
return cFont;
|
||||
}
|
||||
return getFontForState(c, id, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font for the specified state. This should NOT callback
|
||||
* to the JComponent.
|
||||
*
|
||||
* @param c JComponent the style is associated with
|
||||
* @param id Region identifier
|
||||
* @param state State of the region.
|
||||
* @return Font to render with
|
||||
*/
|
||||
protected Font getFontForState(JComponent c, Region id, int state) {
|
||||
if (c == null) {
|
||||
return this.font;
|
||||
}
|
||||
// First pass, look for the best match
|
||||
StateInfo si = getStateInfo(state);
|
||||
Font font;
|
||||
if (si != null && (font = si.getFont()) != null) {
|
||||
return font;
|
||||
}
|
||||
if (si == null || si.getComponentState() != 0) {
|
||||
si = getStateInfo(0);
|
||||
if (si != null && (font = si.getFont()) != null) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
// Fallback font.
|
||||
return this.font;
|
||||
}
|
||||
|
||||
protected Font getFontForState(SynthContext context) {
|
||||
return getFontForState(context.getComponent(), context.getRegion(),
|
||||
context.getComponentState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SynthGraphicsUtils that will be used for rendering.
|
||||
*
|
||||
* @param graphics SynthGraphics
|
||||
*/
|
||||
public void setGraphicsUtils(SynthGraphicsUtils graphics) {
|
||||
this.synthGraphics = graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SynthGraphicsUtils.
|
||||
*
|
||||
* @param context SynthContext identifying requestor
|
||||
* @return SynthGraphicsUtils
|
||||
*/
|
||||
public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
|
||||
if (synthGraphics == null) {
|
||||
return super.getGraphicsUtils(context);
|
||||
}
|
||||
return synthGraphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the insets.
|
||||
*
|
||||
* @param Insets.
|
||||
*/
|
||||
public void setInsets(Insets insets) {
|
||||
this.insets = insets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Insets. If <code>to</code> is non-null the resulting
|
||||
* insets will be placed in it, otherwise a new Insets object will be
|
||||
* created and returned.
|
||||
*
|
||||
* @param context SynthContext identifying requestor
|
||||
* @param to Where to place Insets
|
||||
* @return Insets.
|
||||
*/
|
||||
public Insets getInsets(SynthContext state, Insets to) {
|
||||
if (to == null) {
|
||||
to = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
if (insets != null) {
|
||||
to.left = insets.left;
|
||||
to.right = insets.right;
|
||||
to.top = insets.top;
|
||||
to.bottom = insets.bottom;
|
||||
}
|
||||
else {
|
||||
to.left = to.right = to.top = to.bottom = 0;
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Painter to use for the border.
|
||||
*
|
||||
* @param painter Painter for the Border.
|
||||
*/
|
||||
public void setPainter(SynthPainter painter) {
|
||||
this.painter = painter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Painter for the passed in Component. This may return null.
|
||||
*
|
||||
* @param ss SynthContext identifying requestor
|
||||
* @return Painter for the border
|
||||
*/
|
||||
public SynthPainter getPainter(SynthContext ss) {
|
||||
return painter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the JComponent should be opaque.
|
||||
*
|
||||
* @param opaque Whether or not the JComponent should be opaque.
|
||||
*/
|
||||
public void setOpaque(boolean opaque) {
|
||||
this.opaque = opaque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to initialize the opacity property of the Component
|
||||
* to. A Style should NOT assume the opacity will remain this value, the
|
||||
* developer may reset it or override it.
|
||||
*
|
||||
* @param ss SynthContext identifying requestor
|
||||
* @return opaque Whether or not the JComponent is opaque.
|
||||
*/
|
||||
public boolean isOpaque(SynthContext ss) {
|
||||
return opaque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets style specific values. This does NOT copy the data, it
|
||||
* assigns it directly to this Style.
|
||||
*
|
||||
* @param data Style specific values
|
||||
*/
|
||||
public void setData(Map data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the style specific data.
|
||||
*
|
||||
* @return Style specific data.
|
||||
*/
|
||||
public Map getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for a region specific style property.
|
||||
*
|
||||
* @param state SynthContext identifying requestor
|
||||
* @param key Property being requested.
|
||||
* @return Value of the named property
|
||||
*/
|
||||
public Object get(SynthContext state, Object key) {
|
||||
// Look for the best match
|
||||
StateInfo si = getStateInfo(state.getComponentState());
|
||||
if (si != null && si.getData() != null && getKeyFromData(si.getData(), key) != null) {
|
||||
return getKeyFromData(si.getData(), key);
|
||||
}
|
||||
si = getStateInfo(0);
|
||||
if (si != null && si.getData() != null && getKeyFromData(si.getData(), key) != null) {
|
||||
return getKeyFromData(si.getData(), key);
|
||||
}
|
||||
if(getKeyFromData(data, key) != null)
|
||||
return getKeyFromData(data, key);
|
||||
return getDefaultValue(state, key);
|
||||
}
|
||||
|
||||
|
||||
private Object getKeyFromData(Map stateData, Object key) {
|
||||
Object value = null;
|
||||
if (stateData != null) {
|
||||
|
||||
synchronized(stateData) {
|
||||
value = stateData.get(key);
|
||||
}
|
||||
while (value == PENDING) {
|
||||
synchronized(stateData) {
|
||||
try {
|
||||
stateData.wait();
|
||||
} catch (InterruptedException ie) {}
|
||||
value = stateData.get(key);
|
||||
}
|
||||
}
|
||||
if (value instanceof UIDefaults.LazyValue) {
|
||||
synchronized(stateData) {
|
||||
stateData.put(key, PENDING);
|
||||
}
|
||||
value = ((UIDefaults.LazyValue)value).createValue(null);
|
||||
synchronized(stateData) {
|
||||
stateData.put(key, value);
|
||||
stateData.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value for a particular property. This is only
|
||||
* invoked if this style doesn't define a property for <code>key</code>.
|
||||
*
|
||||
* @param state SynthContext identifying requestor
|
||||
* @param key Property being requested.
|
||||
* @return Value of the named property
|
||||
*/
|
||||
public Object getDefaultValue(SynthContext context, Object key) {
|
||||
return super.get(context, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of this style.
|
||||
*
|
||||
* @return Clone of this style
|
||||
*/
|
||||
public Object clone() {
|
||||
DefaultSynthStyle style;
|
||||
try {
|
||||
style = (DefaultSynthStyle)super.clone();
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
return null;
|
||||
}
|
||||
if (states != null) {
|
||||
style.states = new StateInfo[states.length];
|
||||
for (int counter = states.length - 1; counter >= 0; counter--) {
|
||||
style.states[counter] = (StateInfo)states[counter].clone();
|
||||
}
|
||||
}
|
||||
if (data != null) {
|
||||
style.data = new HashMap();
|
||||
style.data.putAll(data);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the contents of this Style with that of the passed in Style,
|
||||
* returning the resulting merged syle. Properties of this
|
||||
* <code>DefaultSynthStyle</code> will take precedence over those of the
|
||||
* passed in <code>DefaultSynthStyle</code>. For example, if this
|
||||
* style specifics a non-null font, the returned style will have its
|
||||
* font so to that regardless of the <code>style</code>'s font.
|
||||
*
|
||||
* @param style Style to add our styles to
|
||||
* @return Merged style.
|
||||
*/
|
||||
public DefaultSynthStyle addTo(DefaultSynthStyle style) {
|
||||
if (insets != null) {
|
||||
style.insets = this.insets;
|
||||
}
|
||||
if (font != null) {
|
||||
style.font = this.font;
|
||||
}
|
||||
if (painter != null) {
|
||||
style.painter = this.painter;
|
||||
}
|
||||
if (synthGraphics != null) {
|
||||
style.synthGraphics = this.synthGraphics;
|
||||
}
|
||||
style.opaque = opaque;
|
||||
if (states != null) {
|
||||
if (style.states == null) {
|
||||
style.states = new StateInfo[states.length];
|
||||
for (int counter = states.length - 1; counter >= 0; counter--){
|
||||
if (states[counter] != null) {
|
||||
style.states[counter] = (StateInfo)states[counter].
|
||||
clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Find the number of new states in unique, merging any
|
||||
// matching states as we go. Also, move any merge styles
|
||||
// to the end to give them precedence.
|
||||
int unique = 0;
|
||||
// Number of StateInfos that match.
|
||||
int matchCount = 0;
|
||||
int maxOStyles = style.states.length;
|
||||
for (int thisCounter = states.length - 1; thisCounter >= 0;
|
||||
thisCounter--) {
|
||||
int state = states[thisCounter].getComponentState();
|
||||
boolean found = false;
|
||||
|
||||
for (int oCounter = maxOStyles - 1 - matchCount;
|
||||
oCounter >= 0; oCounter--) {
|
||||
if (state == style.states[oCounter].
|
||||
getComponentState()) {
|
||||
style.states[oCounter] = states[thisCounter].
|
||||
addTo(style.states[oCounter]);
|
||||
// Move StateInfo to end, giving it precedence.
|
||||
StateInfo tmp = style.states[maxOStyles - 1 -
|
||||
matchCount];
|
||||
style.states[maxOStyles - 1 - matchCount] =
|
||||
style.states[oCounter];
|
||||
style.states[oCounter] = tmp;
|
||||
matchCount++;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
unique++;
|
||||
}
|
||||
}
|
||||
if (unique != 0) {
|
||||
// There are states that exist in this Style that
|
||||
// don't exist in the other style, recreate the array
|
||||
// and add them.
|
||||
StateInfo[] newStates = new StateInfo[
|
||||
unique + maxOStyles];
|
||||
int newIndex = maxOStyles;
|
||||
|
||||
System.arraycopy(style.states, 0, newStates, 0,maxOStyles);
|
||||
for (int thisCounter = states.length - 1; thisCounter >= 0;
|
||||
thisCounter--) {
|
||||
int state = states[thisCounter].getComponentState();
|
||||
boolean found = false;
|
||||
|
||||
for (int oCounter = maxOStyles - 1; oCounter >= 0;
|
||||
oCounter--) {
|
||||
if (state == style.states[oCounter].
|
||||
getComponentState()) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
newStates[newIndex++] = (StateInfo)states[
|
||||
thisCounter].clone();
|
||||
}
|
||||
}
|
||||
style.states = newStates;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data != null) {
|
||||
if (style.data == null) {
|
||||
style.data = new HashMap();
|
||||
}
|
||||
style.data.putAll(data);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the array of StateInfo's which are used to specify properties
|
||||
* specific to a particular style.
|
||||
*
|
||||
* @param states StateInfos
|
||||
*/
|
||||
public void setStateInfo(StateInfo[] states) {
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of StateInfo's that that are used to specify
|
||||
* properties specific to a particular style.
|
||||
*
|
||||
* @return Array of StateInfos.
|
||||
*/
|
||||
public StateInfo[] getStateInfo() {
|
||||
return states;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the best matching StateInfo for a particular state.
|
||||
*
|
||||
* @param state Component state.
|
||||
* @return Best matching StateInfo, or null
|
||||
*/
|
||||
public StateInfo getStateInfo(int state) {
|
||||
// Use the StateInfo with the most bits that matches that of state.
|
||||
// If there is none, than fallback to
|
||||
// the StateInfo with a state of 0, indicating it'll match anything.
|
||||
|
||||
// Consider if we have 3 StateInfos a, b and c with states:
|
||||
// SELECTED, SELECTED | ENABLED, 0
|
||||
//
|
||||
// Input Return Value
|
||||
// ----- ------------
|
||||
// SELECTED a
|
||||
// SELECTED | ENABLED b
|
||||
// MOUSE_OVER c
|
||||
// SELECTED | ENABLED | FOCUSED b
|
||||
// ENABLED c
|
||||
|
||||
if (states != null) {
|
||||
int bestCount = 0;
|
||||
int bestIndex = -1;
|
||||
int wildIndex = -1;
|
||||
|
||||
if (state == 0) {
|
||||
for (int counter = states.length - 1; counter >= 0;counter--) {
|
||||
if (states[counter].getComponentState() == 0) {
|
||||
return states[counter];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
for (int counter = states.length - 1; counter >= 0; counter--) {
|
||||
int oState = states[counter].getComponentState();
|
||||
|
||||
if (oState == 0) {
|
||||
if (wildIndex == -1) {
|
||||
wildIndex = counter;
|
||||
}
|
||||
}
|
||||
else if ((state & oState) == oState) {
|
||||
// This is key, we need to make sure all bits of the
|
||||
// StateInfo match, otherwise a StateInfo with
|
||||
// SELECTED | ENABLED would match ENABLED, which we
|
||||
// don't want.
|
||||
|
||||
// This comes from BigInteger.bitCnt
|
||||
int bitCount = oState;
|
||||
bitCount -= (0xaaaaaaaa & bitCount) >>> 1;
|
||||
bitCount = (bitCount & 0x33333333) + ((bitCount >>> 2) &
|
||||
0x33333333);
|
||||
bitCount = bitCount + (bitCount >>> 4) & 0x0f0f0f0f;
|
||||
bitCount += bitCount >>> 8;
|
||||
bitCount += bitCount >>> 16;
|
||||
bitCount = bitCount & 0xff;
|
||||
if (bitCount > bestCount) {
|
||||
bestIndex = counter;
|
||||
bestCount = bitCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestIndex != -1) {
|
||||
return states[bestIndex];
|
||||
}
|
||||
if (wildIndex != -1) {
|
||||
return states[wildIndex];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(super.toString()).append(',');
|
||||
|
||||
buf.append("data=").append(data).append(',');
|
||||
|
||||
buf.append("font=").append(font).append(',');
|
||||
|
||||
buf.append("insets=").append(insets).append(',');
|
||||
|
||||
buf.append("synthGraphics=").append(synthGraphics).append(',');
|
||||
|
||||
buf.append("painter=").append(painter).append(',');
|
||||
|
||||
StateInfo[] states = getStateInfo();
|
||||
if (states != null) {
|
||||
buf.append("states[");
|
||||
for (StateInfo state : states) {
|
||||
buf.append(state.toString()).append(',');
|
||||
}
|
||||
buf.append(']').append(',');
|
||||
}
|
||||
|
||||
// remove last newline
|
||||
buf.deleteCharAt(buf.length() - 1);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* StateInfo represents Style information specific to the state of
|
||||
* a component.
|
||||
*/
|
||||
public static class StateInfo {
|
||||
private Map data;
|
||||
private Font font;
|
||||
private Color[] colors;
|
||||
private int state;
|
||||
|
||||
/**
|
||||
* Creates a new StateInfo.
|
||||
*/
|
||||
public StateInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new StateInfo with the specified properties
|
||||
*
|
||||
* @param state Component state(s) that this StateInfo should be used
|
||||
* for
|
||||
* @param painter Painter responsible for rendering
|
||||
* @param bgPainter Painter responsible for rendering the background
|
||||
* @param font Font for this state
|
||||
* @param colors Colors for this state
|
||||
*/
|
||||
public StateInfo(int state, Font font, Color[] colors) {
|
||||
this.state = state;
|
||||
this.font = font;
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new StateInfo that is a copy of the passed in
|
||||
* StateInfo.
|
||||
*
|
||||
* @param info StateInfo to copy.
|
||||
*/
|
||||
public StateInfo(StateInfo info) {
|
||||
this.state = info.state;
|
||||
this.font = info.font;
|
||||
if(info.data != null) {
|
||||
if(data == null) {
|
||||
data = new HashMap();
|
||||
}
|
||||
data.putAll(info.data);
|
||||
}
|
||||
if (info.colors != null) {
|
||||
this.colors = new Color[info.colors.length];
|
||||
System.arraycopy(info.colors, 0, colors, 0,info.colors.length);
|
||||
}
|
||||
}
|
||||
|
||||
public Map getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Map data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for this state.
|
||||
*
|
||||
* @param font Font to use for rendering
|
||||
*/
|
||||
public void setFont(Font font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font for this state.
|
||||
*
|
||||
* @return Returns the font to use for rendering this state
|
||||
*/
|
||||
public Font getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the array of colors to use for rendering this state. This
|
||||
* is indexed by <code>ColorType.getID()</code>.
|
||||
*
|
||||
* @param colors Array of colors
|
||||
*/
|
||||
public void setColors(Color[] colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of colors to use for rendering this state. This
|
||||
* is indexed by <code>ColorType.getID()</code>.
|
||||
*
|
||||
* @return Array of colors
|
||||
*/
|
||||
public Color[] getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Color to used for the specified ColorType.
|
||||
*
|
||||
* @return Color.
|
||||
*/
|
||||
public Color getColor(ColorType type) {
|
||||
if (colors != null) {
|
||||
int id = type.getID();
|
||||
|
||||
if (id < colors.length) {
|
||||
return colors[id];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the contents of this StateInfo with that of the passed in
|
||||
* StateInfo, returning the resulting merged StateInfo. Properties of
|
||||
* this <code>StateInfo</code> will take precedence over those of the
|
||||
* passed in <code>StateInfo</code>. For example, if this
|
||||
* StateInfo specifics a non-null font, the returned StateInfo will
|
||||
* have its font so to that regardless of the <code>StateInfo</code>'s
|
||||
* font.
|
||||
*
|
||||
* @param info StateInfo to add our styles to
|
||||
* @return Merged StateInfo.
|
||||
*/
|
||||
public StateInfo addTo(StateInfo info) {
|
||||
if (font != null) {
|
||||
info.font = font;
|
||||
}
|
||||
if(data != null) {
|
||||
if(info.data == null) {
|
||||
info.data = new HashMap();
|
||||
}
|
||||
info.data.putAll(data);
|
||||
}
|
||||
if (colors != null) {
|
||||
if (info.colors == null) {
|
||||
info.colors = new Color[colors.length];
|
||||
System.arraycopy(colors, 0, info.colors, 0,
|
||||
colors.length);
|
||||
}
|
||||
else {
|
||||
if (info.colors.length < colors.length) {
|
||||
Color[] old = info.colors;
|
||||
|
||||
info.colors = new Color[colors.length];
|
||||
System.arraycopy(old, 0, info.colors, 0, old.length);
|
||||
}
|
||||
for (int counter = colors.length - 1; counter >= 0;
|
||||
counter--) {
|
||||
if (colors[counter] != null) {
|
||||
info.colors[counter] = colors[counter];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state this StateInfo corresponds to.
|
||||
*
|
||||
* @see SynthConstants
|
||||
* @param state info.
|
||||
*/
|
||||
public void setComponentState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state this StateInfo corresponds to.
|
||||
*
|
||||
* @see SynthConstants
|
||||
* @return state info.
|
||||
*/
|
||||
public int getComponentState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of states that are similar between the
|
||||
* ComponentState this StateInfo represents and val.
|
||||
*/
|
||||
private int getMatchCount(int val) {
|
||||
// This comes from BigInteger.bitCnt
|
||||
val &= state;
|
||||
val -= (0xaaaaaaaa & val) >>> 1;
|
||||
val = (val & 0x33333333) + ((val >>> 2) & 0x33333333);
|
||||
val = val + (val >>> 4) & 0x0f0f0f0f;
|
||||
val += val >>> 8;
|
||||
val += val >>> 16;
|
||||
return val & 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy of this StateInfo.
|
||||
*
|
||||
* @return Copy of this StateInfo.
|
||||
*/
|
||||
public Object clone() {
|
||||
return new StateInfo(this);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(super.toString()).append(',');
|
||||
|
||||
buf.append("state=").append(Integer.toString(state)).append(',');
|
||||
|
||||
buf.append("font=").append(font).append(',');
|
||||
|
||||
if (colors != null) {
|
||||
buf.append("colors=").append(Arrays.asList(colors)).
|
||||
append(',');
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
340
jdkSrc/jdk8/sun/swing/plaf/synth/Paint9Painter.java
Normal file
340
jdkSrc/jdk8/sun/swing/plaf/synth/Paint9Painter.java
Normal file
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.synth;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import sun.swing.CachedPainter;
|
||||
|
||||
/**
|
||||
* Paint9Painter is used for painting images for both Synth and GTK's
|
||||
* pixmap/blueprint engines.
|
||||
*
|
||||
*/
|
||||
public class Paint9Painter extends CachedPainter {
|
||||
/**
|
||||
* Enumeration for the types of painting this class can handle.
|
||||
*/
|
||||
public enum PaintType {
|
||||
/**
|
||||
* Painting type indicating the image should be centered in
|
||||
* the space provided. When used the <code>mask</code> is ignored.
|
||||
*/
|
||||
CENTER,
|
||||
|
||||
/**
|
||||
* Painting type indicating the image should be tiled across the
|
||||
* specified width and height. When used the <code>mask</code> is
|
||||
* ignored.
|
||||
*/
|
||||
TILE,
|
||||
|
||||
/**
|
||||
* Painting type indicating the image should be split into nine
|
||||
* regions with the top, left, bottom and right areas stretched.
|
||||
*/
|
||||
PAINT9_STRETCH,
|
||||
|
||||
/**
|
||||
* Painting type indicating the image should be split into nine
|
||||
* regions with the top, left, bottom and right areas tiled.
|
||||
*/
|
||||
PAINT9_TILE
|
||||
};
|
||||
|
||||
private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
|
||||
|
||||
public static final int PAINT_TOP_LEFT = 1;
|
||||
public static final int PAINT_TOP = 2;
|
||||
public static final int PAINT_TOP_RIGHT = 4;
|
||||
public static final int PAINT_LEFT = 8;
|
||||
public static final int PAINT_CENTER = 16;
|
||||
public static final int PAINT_RIGHT = 32;
|
||||
public static final int PAINT_BOTTOM_RIGHT = 64;
|
||||
public static final int PAINT_BOTTOM = 128;
|
||||
public static final int PAINT_BOTTOM_LEFT = 256;
|
||||
/**
|
||||
* Specifies that all regions should be painted. If this is set any
|
||||
* other regions specified will not be painted. For example
|
||||
* PAINT_ALL | PAINT_CENTER will paint all but the center.
|
||||
*/
|
||||
public static final int PAINT_ALL = 512;
|
||||
|
||||
/**
|
||||
* Convenience method for testing the validity of an image.
|
||||
*
|
||||
* @param image Image to check.
|
||||
* @return true if <code>image</code> is non-null and has a positive
|
||||
* size.
|
||||
*/
|
||||
public static boolean validImage(Image image) {
|
||||
return (image != null && image.getWidth(null) > 0 &&
|
||||
image.getHeight(null) > 0);
|
||||
}
|
||||
|
||||
|
||||
public Paint9Painter(int cacheCount) {
|
||||
super(cacheCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints using the algorightm specified by <code>paintType</code>.
|
||||
* NOTE that this just invokes super.paint(...) with the same
|
||||
* argument ordering as this method.
|
||||
*
|
||||
* @param c Component rendering to
|
||||
* @param g Graphics to render to
|
||||
* @param x X-coordinate
|
||||
* @param y Y-coordinate
|
||||
* @param w Width to render to
|
||||
* @param h Height to render to
|
||||
* @param source Image to render from, if <code>null</code> this method
|
||||
* will do nothing
|
||||
* @param sInsets Insets specifying the portion of the image that
|
||||
* will be stretched or tiled, if <code>null</code> empty
|
||||
* <code>Insets</code> will be used.
|
||||
* @param dInsets Destination insets specifying the portion of the image
|
||||
* will be stretched or tiled, if <code>null</code> empty
|
||||
* <code>Insets</code> will be used.
|
||||
* @param paintType Specifies what type of algorithm to use in painting
|
||||
* @param mask Specifies portion of image to render, if
|
||||
* <code>PAINT_ALL</code> is specified, any other regions
|
||||
* specified will not be painted, for example
|
||||
* PAINT_ALL | PAINT_CENTER paints everything but the center.
|
||||
*/
|
||||
public void paint(Component c, Graphics g, int x,
|
||||
int y, int w, int h, Image source, Insets sInsets,
|
||||
Insets dInsets,
|
||||
PaintType type, int mask) {
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
super.paint(c, g, x, y, w, h, source, sInsets, dInsets, type, mask);
|
||||
}
|
||||
|
||||
protected void paintToImage(Component c, Image destImage, Graphics g,
|
||||
int w, int h, Object[] args) {
|
||||
int argIndex = 0;
|
||||
while (argIndex < args.length) {
|
||||
Image image = (Image)args[argIndex++];
|
||||
Insets sInsets = (Insets)args[argIndex++];
|
||||
Insets dInsets = (Insets)args[argIndex++];
|
||||
PaintType type = (PaintType)args[argIndex++];
|
||||
int mask = (Integer)args[argIndex++];
|
||||
paint9(g, 0, 0, w, h, image, sInsets, dInsets, type, mask);
|
||||
}
|
||||
}
|
||||
|
||||
protected void paint9(Graphics g, int x, int y, int w, int h,
|
||||
Image image, Insets sInsets,
|
||||
Insets dInsets, PaintType type, int componentMask) {
|
||||
if (!validImage(image)) {
|
||||
return;
|
||||
}
|
||||
if (sInsets == null) {
|
||||
sInsets = EMPTY_INSETS;
|
||||
}
|
||||
if (dInsets == null) {
|
||||
dInsets = EMPTY_INSETS;
|
||||
}
|
||||
int iw = image.getWidth(null);
|
||||
int ih = image.getHeight(null);
|
||||
|
||||
if (type == PaintType.CENTER) {
|
||||
// Center the image
|
||||
g.drawImage(image, x + (w - iw) / 2,
|
||||
y + (h - ih) / 2, null);
|
||||
}
|
||||
else if (type == PaintType.TILE) {
|
||||
// Tile the image
|
||||
int lastIY = 0;
|
||||
for (int yCounter = y, maxY = y + h; yCounter < maxY;
|
||||
yCounter += (ih - lastIY), lastIY = 0) {
|
||||
int lastIX = 0;
|
||||
for (int xCounter = x, maxX = x + w; xCounter < maxX;
|
||||
xCounter += (iw - lastIX), lastIX = 0) {
|
||||
int dx2 = Math.min(maxX, xCounter + iw - lastIX);
|
||||
int dy2 = Math.min(maxY, yCounter + ih - lastIY);
|
||||
g.drawImage(image, xCounter, yCounter, dx2, dy2,
|
||||
lastIX, lastIY, lastIX + dx2 - xCounter,
|
||||
lastIY + dy2 - yCounter, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int st = sInsets.top;
|
||||
int sl = sInsets.left;
|
||||
int sb = sInsets.bottom;
|
||||
int sr = sInsets.right;
|
||||
|
||||
int dt = dInsets.top;
|
||||
int dl = dInsets.left;
|
||||
int db = dInsets.bottom;
|
||||
int dr = dInsets.right;
|
||||
|
||||
// Constrain the insets to the size of the image
|
||||
if (st + sb > ih) {
|
||||
db = dt = sb = st = Math.max(0, ih / 2);
|
||||
}
|
||||
if (sl + sr > iw) {
|
||||
dl = dr = sl = sr = Math.max(0, iw / 2);
|
||||
}
|
||||
|
||||
// Constrain the insets to the size of the region we're painting
|
||||
// in.
|
||||
if (dt + db > h) {
|
||||
dt = db = Math.max(0, h / 2 - 1);
|
||||
}
|
||||
if (dl + dr > w) {
|
||||
dl = dr = Math.max(0, w / 2 - 1);
|
||||
}
|
||||
|
||||
boolean stretch = (type == PaintType.PAINT9_STRETCH);
|
||||
if ((componentMask & PAINT_ALL) != 0) {
|
||||
componentMask = (PAINT_ALL - 1) & ~componentMask;
|
||||
}
|
||||
|
||||
if ((componentMask & PAINT_LEFT) != 0) {
|
||||
drawChunk(image, g, stretch, x, y + dt, x + dl, y + h - db,
|
||||
0, st, sl, ih - sb, false);
|
||||
}
|
||||
if ((componentMask & PAINT_TOP_LEFT) != 0) {
|
||||
drawImage(image, g, x, y, x + dl, y + dt,
|
||||
0, 0, sl, st);
|
||||
}
|
||||
if ((componentMask & PAINT_TOP) != 0) {
|
||||
drawChunk(image, g, stretch, x + dl, y, x + w - dr, y + dt,
|
||||
sl, 0, iw - sr, st, true);
|
||||
}
|
||||
if ((componentMask & PAINT_TOP_RIGHT) != 0) {
|
||||
drawImage(image, g, x + w - dr, y, x + w, y + dt,
|
||||
iw - sr, 0, iw, st);
|
||||
}
|
||||
if ((componentMask & PAINT_RIGHT) != 0) {
|
||||
drawChunk(image, g, stretch,
|
||||
x + w - dr, y + dt, x + w, y + h - db,
|
||||
iw - sr, st, iw, ih - sb, false);
|
||||
}
|
||||
if ((componentMask & PAINT_BOTTOM_RIGHT) != 0) {
|
||||
drawImage(image, g, x + w - dr, y + h - db, x + w, y + h,
|
||||
iw - sr, ih - sb, iw, ih);
|
||||
}
|
||||
if ((componentMask & PAINT_BOTTOM) != 0) {
|
||||
drawChunk(image, g, stretch,
|
||||
x + dl, y + h - db, x + w - dr, y + h,
|
||||
sl, ih - sb, iw - sr, ih, true);
|
||||
}
|
||||
if ((componentMask & PAINT_BOTTOM_LEFT) != 0) {
|
||||
drawImage(image, g, x, y + h - db, x + dl, y + h,
|
||||
0, ih - sb, sl, ih);
|
||||
}
|
||||
if ((componentMask & PAINT_CENTER) != 0) {
|
||||
drawImage(image, g, x + dl, y + dt, x + w - dr, y + h - db,
|
||||
sl, st, iw - sr, ih - sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawImage(Image image, Graphics g,
|
||||
int dx1, int dy1, int dx2, int dy2, int sx1,
|
||||
int sy1, int sx2, int sy2) {
|
||||
// PENDING: is this necessary, will G2D do it for me?
|
||||
if (dx2 - dx1 <= 0 || dy2 - dy1 <= 0 || sx2 - sx1 <= 0 ||
|
||||
sy2 - sy1 <= 0) {
|
||||
// Bogus location, nothing to paint
|
||||
return;
|
||||
}
|
||||
g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a portion of an image, stretched or tiled.
|
||||
*
|
||||
* @param image Image to render.
|
||||
* @param g Graphics to render to
|
||||
* @param stretch Whether the image should be stretched or timed in the
|
||||
* provided space.
|
||||
* @param dx1 X origin to draw to
|
||||
* @param dy1 Y origin to draw to
|
||||
* @param dx2 End x location to draw to
|
||||
* @param dy2 End y location to draw to
|
||||
* @param sx1 X origin to draw from
|
||||
* @param sy1 Y origin to draw from
|
||||
* @param sx2 Max x location to draw from
|
||||
* @param sy2 Max y location to draw from
|
||||
* @param xDirection Used if the image is not stretched. If true it
|
||||
* indicates the image should be tiled along the x axis.
|
||||
*/
|
||||
private void drawChunk(Image image, Graphics g, boolean stretch,
|
||||
int dx1, int dy1, int dx2, int dy2, int sx1,
|
||||
int sy1, int sx2, int sy2,
|
||||
boolean xDirection) {
|
||||
if (dx2 - dx1 <= 0 || dy2 - dy1 <= 0 || sx2 - sx1 <= 0 ||
|
||||
sy2 - sy1 <= 0) {
|
||||
// Bogus location, nothing to paint
|
||||
return;
|
||||
}
|
||||
if (stretch) {
|
||||
g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
|
||||
}
|
||||
else {
|
||||
int xSize = sx2 - sx1;
|
||||
int ySize = sy2 - sy1;
|
||||
int deltaX;
|
||||
int deltaY;
|
||||
|
||||
if (xDirection) {
|
||||
deltaX = xSize;
|
||||
deltaY = 0;
|
||||
}
|
||||
else {
|
||||
deltaX = 0;
|
||||
deltaY = ySize;
|
||||
}
|
||||
while (dx1 < dx2 && dy1 < dy2) {
|
||||
int newDX2 = Math.min(dx2, dx1 + xSize);
|
||||
int newDY2 = Math.min(dy2, dy1 + ySize);
|
||||
|
||||
g.drawImage(image, dx1, dy1, newDX2, newDY2,
|
||||
sx1, sy1, sx1 + newDX2 - dx1,
|
||||
sy1 + newDY2 - dy1, null);
|
||||
dx1 += deltaX;
|
||||
dy1 += deltaY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclassed to always create a translucent image.
|
||||
*/
|
||||
protected Image createImage(Component c, int w, int h,
|
||||
GraphicsConfiguration config,
|
||||
Object[] args) {
|
||||
if (config == null) {
|
||||
return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
return config.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
|
||||
}
|
||||
}
|
||||
133
jdkSrc/jdk8/sun/swing/plaf/synth/StyleAssociation.java
Normal file
133
jdkSrc/jdk8/sun/swing/plaf/synth/StyleAssociation.java
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.synth;
|
||||
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* <b>WARNING:</b> This class is an implementation detail and is only
|
||||
* public so that it can be used by two packages. You should NOT consider
|
||||
* this public API.
|
||||
* <p>
|
||||
* StyleAssociation is used to lookup a style for a particular
|
||||
* component (or region).
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public class StyleAssociation {
|
||||
/**
|
||||
* The style
|
||||
*/
|
||||
private SynthStyle _style;
|
||||
|
||||
/**
|
||||
* Pattern used for matching.
|
||||
*/
|
||||
private Pattern _pattern;
|
||||
/**
|
||||
* Matcher used for testing if path matches that of pattern.
|
||||
*/
|
||||
private Matcher _matcher;
|
||||
|
||||
/**
|
||||
* Identifier for this association.
|
||||
*/
|
||||
private int _id;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a StyleAssociation that can be used to determine if
|
||||
* a particular string matches the returned association.
|
||||
*/
|
||||
public static StyleAssociation createStyleAssociation(
|
||||
String text, SynthStyle style)
|
||||
throws PatternSyntaxException {
|
||||
return createStyleAssociation(text, style, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a StyleAssociation that can be used to determine if
|
||||
* a particular string matches the returned association.
|
||||
*/
|
||||
public static StyleAssociation createStyleAssociation(
|
||||
String text, SynthStyle style, int id)
|
||||
throws PatternSyntaxException {
|
||||
return new StyleAssociation(text, style, id);
|
||||
}
|
||||
|
||||
|
||||
private StyleAssociation(String text, SynthStyle style, int id)
|
||||
throws PatternSyntaxException {
|
||||
_style = style;
|
||||
_pattern = Pattern.compile(text);
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the developer specified identifier for this association, will
|
||||
* be <code>0</code> if an identifier was not specified when this
|
||||
* <code>StyleAssociation</code> was created.
|
||||
*/
|
||||
public int getID() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this <code>StyleAssociation</code> matches the
|
||||
* passed in CharSequence.
|
||||
*
|
||||
* @return true if this <code>StyleAssociation</code> matches the
|
||||
* passed in CharSequence.if this StyleAssociation.
|
||||
*/
|
||||
public synchronized boolean matches(CharSequence path) {
|
||||
if (_matcher == null) {
|
||||
_matcher = _pattern.matcher(path);
|
||||
}
|
||||
else {
|
||||
_matcher.reset(path);
|
||||
}
|
||||
return _matcher.matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text used in matching the string.
|
||||
*
|
||||
* @return the text used in matching the string.
|
||||
*/
|
||||
public String getText() {
|
||||
return _pattern.pattern();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the style this association is mapped to.
|
||||
*
|
||||
* @return the style this association is mapped to.
|
||||
*/
|
||||
public SynthStyle getStyle() {
|
||||
return _style;
|
||||
}
|
||||
}
|
||||
586
jdkSrc/jdk8/sun/swing/plaf/synth/SynthFileChooserUI.java
Normal file
586
jdkSrc/jdk8/sun/swing/plaf/synth/SynthFileChooserUI.java
Normal file
@@ -0,0 +1,586 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.synth;
|
||||
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.io.File;
|
||||
import java.util.regex.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.filechooser.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicFileChooserUI;
|
||||
|
||||
/**
|
||||
* Synth FileChooserUI.
|
||||
*
|
||||
* Note: This class is abstract. It does not actually create the file chooser GUI.
|
||||
* <p>
|
||||
* Note that the classes in the com.sun.java.swing.plaf.synth
|
||||
* package are not
|
||||
* part of the core Java APIs. They are a part of Sun's JDK and JRE
|
||||
* distributions. Although other licensees may choose to distribute
|
||||
* these classes, developers cannot depend on their availability in
|
||||
* non-Sun implementations. Additionally this API may change in
|
||||
* incompatible ways between releases. While this class is public, it
|
||||
* shoud be considered an implementation detail, and subject to change.
|
||||
*
|
||||
* @author Leif Samuelsson
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public abstract class SynthFileChooserUI extends BasicFileChooserUI implements
|
||||
SynthUI {
|
||||
private JButton approveButton, cancelButton;
|
||||
|
||||
private SynthStyle style;
|
||||
|
||||
// Some generic FileChooser functions
|
||||
private Action fileNameCompletionAction = new FileNameCompletionAction();
|
||||
|
||||
private FileFilter actualFileFilter = null;
|
||||
private GlobFilter globFilter = null;
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new SynthFileChooserUIImpl((JFileChooser)c);
|
||||
}
|
||||
|
||||
public SynthFileChooserUI(JFileChooser b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
public SynthContext getContext(JComponent c) {
|
||||
return new SynthContext(c, Region.FILE_CHOOSER, style,
|
||||
getComponentState(c));
|
||||
}
|
||||
|
||||
protected SynthContext getContext(JComponent c, int state) {
|
||||
Region region = SynthLookAndFeel.getRegion(c);
|
||||
return new SynthContext(c, Region.FILE_CHOOSER, style, state);
|
||||
}
|
||||
|
||||
private Region getRegion(JComponent c) {
|
||||
return SynthLookAndFeel.getRegion(c);
|
||||
}
|
||||
|
||||
private int getComponentState(JComponent c) {
|
||||
if (c.isEnabled()) {
|
||||
if (c.isFocusOwner()) {
|
||||
return ENABLED | FOCUSED;
|
||||
}
|
||||
return ENABLED;
|
||||
}
|
||||
return DISABLED;
|
||||
}
|
||||
|
||||
private void updateStyle(JComponent c) {
|
||||
SynthStyle newStyle = SynthLookAndFeel.getStyleFactory().getStyle(c,
|
||||
Region.FILE_CHOOSER);
|
||||
if (newStyle != style) {
|
||||
if (style != null) {
|
||||
style.uninstallDefaults(getContext(c, ENABLED));
|
||||
}
|
||||
style = newStyle;
|
||||
SynthContext context = getContext(c, ENABLED);
|
||||
style.installDefaults(context);
|
||||
Border border = c.getBorder();
|
||||
if (border == null || border instanceof UIResource) {
|
||||
c.setBorder(new UIBorder(style.getInsets(context, null)));
|
||||
}
|
||||
|
||||
directoryIcon = style.getIcon(context, "FileView.directoryIcon");
|
||||
fileIcon = style.getIcon(context, "FileView.fileIcon");
|
||||
computerIcon = style.getIcon(context, "FileView.computerIcon");
|
||||
hardDriveIcon = style.getIcon(context, "FileView.hardDriveIcon");
|
||||
floppyDriveIcon = style.getIcon(context, "FileView.floppyDriveIcon");
|
||||
|
||||
newFolderIcon = style.getIcon(context, "FileChooser.newFolderIcon");
|
||||
upFolderIcon = style.getIcon(context, "FileChooser.upFolderIcon");
|
||||
homeFolderIcon = style.getIcon(context, "FileChooser.homeFolderIcon");
|
||||
detailsViewIcon = style.getIcon(context, "FileChooser.detailsViewIcon");
|
||||
listViewIcon = style.getIcon(context, "FileChooser.listViewIcon");
|
||||
}
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
SwingUtilities.replaceUIActionMap(c, createActionMap());
|
||||
}
|
||||
|
||||
public void installComponents(JFileChooser fc) {
|
||||
SynthContext context = getContext(fc, ENABLED);
|
||||
|
||||
cancelButton = new JButton(cancelButtonText);
|
||||
cancelButton.setName("SynthFileChooser.cancelButton");
|
||||
cancelButton.setIcon(context.getStyle().getIcon(context, "FileChooser.cancelIcon"));
|
||||
cancelButton.setMnemonic(cancelButtonMnemonic);
|
||||
cancelButton.setToolTipText(cancelButtonToolTipText);
|
||||
cancelButton.addActionListener(getCancelSelectionAction());
|
||||
|
||||
approveButton = new JButton(getApproveButtonText(fc));
|
||||
approveButton.setName("SynthFileChooser.approveButton");
|
||||
approveButton.setIcon(context.getStyle().getIcon(context, "FileChooser.okIcon"));
|
||||
approveButton.setMnemonic(getApproveButtonMnemonic(fc));
|
||||
approveButton.setToolTipText(getApproveButtonToolTipText(fc));
|
||||
approveButton.addActionListener(getApproveSelectionAction());
|
||||
|
||||
}
|
||||
|
||||
public void uninstallComponents(JFileChooser fc) {
|
||||
fc.removeAll();
|
||||
}
|
||||
|
||||
protected void installListeners(JFileChooser fc) {
|
||||
super.installListeners(fc);
|
||||
|
||||
getModel().addListDataListener(new ListDataListener() {
|
||||
public void contentsChanged(ListDataEvent e) {
|
||||
// Update the selection after JList has been updated
|
||||
new DelayedSelectionUpdater();
|
||||
}
|
||||
public void intervalAdded(ListDataEvent e) {
|
||||
new DelayedSelectionUpdater();
|
||||
}
|
||||
public void intervalRemoved(ListDataEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private class DelayedSelectionUpdater implements Runnable {
|
||||
DelayedSelectionUpdater() {
|
||||
SwingUtilities.invokeLater(this);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
updateFileNameCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ActionMap createActionMap();
|
||||
|
||||
|
||||
protected void installDefaults(JFileChooser fc) {
|
||||
super.installDefaults(fc);
|
||||
updateStyle(fc);
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(JFileChooser fc) {
|
||||
super.uninstallDefaults(fc);
|
||||
|
||||
SynthContext context = getContext(getFileChooser(), ENABLED);
|
||||
style.uninstallDefaults(context);
|
||||
style = null;
|
||||
}
|
||||
|
||||
protected void installIcons(JFileChooser fc) {
|
||||
// The icons are installed in updateStyle, not here
|
||||
}
|
||||
|
||||
public void update(Graphics g, JComponent c) {
|
||||
SynthContext context = getContext(c);
|
||||
|
||||
if (c.isOpaque()) {
|
||||
g.setColor(style.getColor(context, ColorType.BACKGROUND));
|
||||
g.fillRect(0, 0, c.getWidth(), c.getHeight());
|
||||
}
|
||||
|
||||
style.getPainter(context).paintFileChooserBackground(context,
|
||||
g, 0, 0, c.getWidth(), c.getHeight());
|
||||
paint(context, g);
|
||||
}
|
||||
|
||||
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) {
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
SynthContext context = getContext(c);
|
||||
|
||||
paint(context, g);
|
||||
}
|
||||
|
||||
protected void paint(SynthContext context, Graphics g) {
|
||||
}
|
||||
|
||||
abstract public void setFileName(String fileName);
|
||||
abstract public String getFileName();
|
||||
|
||||
protected void doSelectedFileChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
protected void doSelectedFilesChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
protected void doDirectoryChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
protected void doAccessoryChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
protected void doFileSelectionModeChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
protected void doMultiSelectionChanged(PropertyChangeEvent e) {
|
||||
if (!getFileChooser().isMultiSelectionEnabled()) {
|
||||
getFileChooser().setSelectedFiles(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doControlButtonsChanged(PropertyChangeEvent e) {
|
||||
if (getFileChooser().getControlButtonsAreShown()) {
|
||||
approveButton.setText(getApproveButtonText(getFileChooser()));
|
||||
approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
|
||||
approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void doAncestorChanged(PropertyChangeEvent e) {
|
||||
}
|
||||
|
||||
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
|
||||
return new SynthFCPropertyChangeListener();
|
||||
}
|
||||
|
||||
private class SynthFCPropertyChangeListener implements PropertyChangeListener {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String prop = e.getPropertyName();
|
||||
if (prop.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
|
||||
doFileSelectionModeChanged(e);
|
||||
} else if (prop.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
|
||||
doSelectedFileChanged(e);
|
||||
} else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
|
||||
doSelectedFilesChanged(e);
|
||||
} else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
|
||||
doDirectoryChanged(e);
|
||||
} else if (prop == JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY) {
|
||||
doMultiSelectionChanged(e);
|
||||
} else if (prop == JFileChooser.ACCESSORY_CHANGED_PROPERTY) {
|
||||
doAccessoryChanged(e);
|
||||
} else if (prop == JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY ||
|
||||
prop == JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY ||
|
||||
prop == JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY ||
|
||||
prop == JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY) {
|
||||
doControlButtonsChanged(e);
|
||||
} else if (prop.equals("componentOrientation")) {
|
||||
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
|
||||
JFileChooser cc = (JFileChooser)e.getSource();
|
||||
if (o != (ComponentOrientation)e.getOldValue()) {
|
||||
cc.applyComponentOrientation(o);
|
||||
}
|
||||
} else if (prop.equals("ancestor")) {
|
||||
doAncestorChanged(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Responds to a File Name completion request (e.g. Tab)
|
||||
*/
|
||||
private class FileNameCompletionAction extends AbstractAction {
|
||||
protected FileNameCompletionAction() {
|
||||
super("fileNameCompletion");
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser chooser = getFileChooser();
|
||||
|
||||
String fileName = getFileName();
|
||||
|
||||
if (fileName != null) {
|
||||
// Remove whitespace from beginning and end of filename
|
||||
fileName = fileName.trim();
|
||||
}
|
||||
|
||||
resetGlobFilter();
|
||||
|
||||
if (fileName == null || fileName.equals("") ||
|
||||
(chooser.isMultiSelectionEnabled() && fileName.startsWith("\""))) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileFilter currentFilter = chooser.getFileFilter();
|
||||
if (globFilter == null) {
|
||||
globFilter = new GlobFilter();
|
||||
}
|
||||
try {
|
||||
globFilter.setPattern(!isGlobPattern(fileName) ? fileName + "*" : fileName);
|
||||
if (!(currentFilter instanceof GlobFilter)) {
|
||||
actualFileFilter = currentFilter;
|
||||
}
|
||||
chooser.setFileFilter(null);
|
||||
chooser.setFileFilter(globFilter);
|
||||
fileNameCompletionString = fileName;
|
||||
} catch (PatternSyntaxException pse) {
|
||||
// Not a valid glob pattern. Abandon filter.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String fileNameCompletionString;
|
||||
|
||||
private void updateFileNameCompletion() {
|
||||
if (fileNameCompletionString != null) {
|
||||
if (fileNameCompletionString.equals(getFileName())) {
|
||||
File[] files = getModel().getFiles().toArray(new File[0]);
|
||||
String str = getCommonStartString(files);
|
||||
if (str != null && str.startsWith(fileNameCompletionString)) {
|
||||
setFileName(str);
|
||||
}
|
||||
fileNameCompletionString = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getCommonStartString(File[] files) {
|
||||
String str = null;
|
||||
String str2 = null;
|
||||
int i = 0;
|
||||
if (files.length == 0) {
|
||||
return null;
|
||||
}
|
||||
while (true) {
|
||||
for (int f = 0; f < files.length; f++) {
|
||||
String name = files[f].getName();
|
||||
if (f == 0) {
|
||||
if (name.length() == i) {
|
||||
return str;
|
||||
}
|
||||
str2 = name.substring(0, i+1);
|
||||
}
|
||||
if (!name.startsWith(str2)) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
str = str2;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private void resetGlobFilter() {
|
||||
if (actualFileFilter != null) {
|
||||
JFileChooser chooser = getFileChooser();
|
||||
FileFilter currentFilter = chooser.getFileFilter();
|
||||
if (currentFilter != null && currentFilter.equals(globFilter)) {
|
||||
chooser.setFileFilter(actualFileFilter);
|
||||
chooser.removeChoosableFileFilter(globFilter);
|
||||
}
|
||||
actualFileFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isGlobPattern(String fileName) {
|
||||
return ((File.separatorChar == '\\' && fileName.indexOf('*') >= 0)
|
||||
|| (File.separatorChar == '/' && (fileName.indexOf('*') >= 0
|
||||
|| fileName.indexOf('?') >= 0
|
||||
|| fileName.indexOf('[') >= 0)));
|
||||
}
|
||||
|
||||
|
||||
/* A file filter which accepts file patterns containing
|
||||
* the special wildcard '*' on windows, plus '?', and '[ ]' on Unix.
|
||||
*/
|
||||
class GlobFilter extends FileFilter {
|
||||
Pattern pattern;
|
||||
String globPattern;
|
||||
|
||||
public void setPattern(String globPattern) {
|
||||
char[] gPat = globPattern.toCharArray();
|
||||
char[] rPat = new char[gPat.length * 2];
|
||||
boolean isWin32 = (File.separatorChar == '\\');
|
||||
boolean inBrackets = false;
|
||||
int j = 0;
|
||||
|
||||
this.globPattern = globPattern;
|
||||
|
||||
if (isWin32) {
|
||||
// On windows, a pattern ending with *.* is equal to ending with *
|
||||
int len = gPat.length;
|
||||
if (globPattern.endsWith("*.*")) {
|
||||
len -= 2;
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (gPat[i] == '*') {
|
||||
rPat[j++] = '.';
|
||||
}
|
||||
rPat[j++] = gPat[i];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < gPat.length; i++) {
|
||||
switch(gPat[i]) {
|
||||
case '*':
|
||||
if (!inBrackets) {
|
||||
rPat[j++] = '.';
|
||||
}
|
||||
rPat[j++] = '*';
|
||||
break;
|
||||
|
||||
case '?':
|
||||
rPat[j++] = inBrackets ? '?' : '.';
|
||||
break;
|
||||
|
||||
case '[':
|
||||
inBrackets = true;
|
||||
rPat[j++] = gPat[i];
|
||||
|
||||
if (i < gPat.length - 1) {
|
||||
switch (gPat[i+1]) {
|
||||
case '!':
|
||||
case '^':
|
||||
rPat[j++] = '^';
|
||||
i++;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
rPat[j++] = gPat[++i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ']':
|
||||
rPat[j++] = gPat[i];
|
||||
inBrackets = false;
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
if (i == 0 && gPat.length > 1 && gPat[1] == '~') {
|
||||
rPat[j++] = gPat[++i];
|
||||
} else {
|
||||
rPat[j++] = '\\';
|
||||
if (i < gPat.length - 1 && "*?[]".indexOf(gPat[i+1]) >= 0) {
|
||||
rPat[j++] = gPat[++i];
|
||||
} else {
|
||||
rPat[j++] = '\\';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
//if ("+()|^$.{}<>".indexOf(gPat[i]) >= 0) {
|
||||
if (!Character.isLetterOrDigit(gPat[i])) {
|
||||
rPat[j++] = '\\';
|
||||
}
|
||||
rPat[j++] = gPat[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.pattern = Pattern.compile(new String(rPat, 0, j), Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
public boolean accept(File f) {
|
||||
if (f == null) {
|
||||
return false;
|
||||
}
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
return pattern.matcher(f.getName()).matches();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return globPattern;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *******************************************************
|
||||
// ************ FileChooser UI PLAF methods **************
|
||||
// *******************************************************
|
||||
|
||||
|
||||
// *****************************
|
||||
// ***** Directory Actions *****
|
||||
// *****************************
|
||||
|
||||
public Action getFileNameCompletionAction() {
|
||||
return fileNameCompletionAction;
|
||||
}
|
||||
|
||||
|
||||
protected JButton getApproveButton(JFileChooser fc) {
|
||||
return approveButton;
|
||||
}
|
||||
|
||||
protected JButton getCancelButton(JFileChooser fc) {
|
||||
return cancelButton;
|
||||
}
|
||||
|
||||
|
||||
// Overload to do nothing. We don't have and icon cache.
|
||||
public void clearIconCache() { }
|
||||
|
||||
// Copied as SynthBorder is package private in synth
|
||||
private class UIBorder extends AbstractBorder implements UIResource {
|
||||
private Insets _insets;
|
||||
UIBorder(Insets insets) {
|
||||
if (insets != null) {
|
||||
_insets = new Insets(insets.top, insets.left, insets.bottom,
|
||||
insets.right);
|
||||
}
|
||||
else {
|
||||
_insets = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (!(c instanceof JComponent)) {
|
||||
return;
|
||||
}
|
||||
JComponent jc = (JComponent)c;
|
||||
SynthContext context = getContext(jc);
|
||||
SynthStyle style = context.getStyle();
|
||||
if (style != null) {
|
||||
style.getPainter(context).paintFileChooserBorder(
|
||||
context, g, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
if (insets == null) {
|
||||
insets = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
if (_insets != null) {
|
||||
insets.top = _insets.top;
|
||||
insets.bottom = _insets.bottom;
|
||||
insets.left = _insets.left;
|
||||
insets.right = _insets.right;
|
||||
}
|
||||
else {
|
||||
insets.top = insets.bottom = insets.right = insets.left = 0;
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
1103
jdkSrc/jdk8/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
Normal file
1103
jdkSrc/jdk8/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
126
jdkSrc/jdk8/sun/swing/plaf/synth/SynthIcon.java
Normal file
126
jdkSrc/jdk8/sun/swing/plaf/synth/SynthIcon.java
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.synth;
|
||||
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
/**
|
||||
* An icon that is passed a SynthContext. Subclasses need only implement
|
||||
* the variants that take a SynthContext, but must be prepared for the
|
||||
* SynthContext to be null.
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public abstract class SynthIcon implements Icon {
|
||||
public static int getIconWidth(Icon icon, SynthContext context) {
|
||||
if (icon == null) {
|
||||
return 0;
|
||||
}
|
||||
if (icon instanceof SynthIcon) {
|
||||
return ((SynthIcon)icon).getIconWidth(context);
|
||||
}
|
||||
return icon.getIconWidth();
|
||||
}
|
||||
|
||||
public static int getIconHeight(Icon icon, SynthContext context) {
|
||||
if (icon == null) {
|
||||
return 0;
|
||||
}
|
||||
if (icon instanceof SynthIcon) {
|
||||
return ((SynthIcon)icon).getIconHeight(context);
|
||||
}
|
||||
return icon.getIconHeight();
|
||||
}
|
||||
|
||||
public static void paintIcon(Icon icon, SynthContext context, Graphics g,
|
||||
int x, int y, int w, int h) {
|
||||
if (icon instanceof SynthIcon) {
|
||||
((SynthIcon)icon).paintIcon(context, g, x, y, w, h);
|
||||
}
|
||||
else if (icon != null) {
|
||||
icon.paintIcon(context.getComponent(), g, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the icon at the specified location.
|
||||
*
|
||||
* @param context Identifies hosting region, may be null.
|
||||
* @param x x location to paint to
|
||||
* @param y y location to paint to
|
||||
* @param w Width of the region to paint to, may be 0
|
||||
* @param h Height of the region to paint to, may be 0
|
||||
*/
|
||||
public abstract void paintIcon(SynthContext context, Graphics g, int x,
|
||||
int y, int w, int h);
|
||||
|
||||
/**
|
||||
* Returns the desired width of the Icon.
|
||||
*
|
||||
* @param context SynthContext requesting the Icon, may be null.
|
||||
* @return Desired width of the icon.
|
||||
*/
|
||||
public abstract int getIconWidth(SynthContext context);
|
||||
|
||||
/**
|
||||
* Returns the desired height of the Icon.
|
||||
*
|
||||
* @param context SynthContext requesting the Icon, may be null.
|
||||
* @return Desired height of the icon.
|
||||
*/
|
||||
public abstract int getIconHeight(SynthContext context);
|
||||
|
||||
/**
|
||||
* Paints the icon. This is a cover method for
|
||||
* <code>paintIcon(null, g, x, y, 0, 0)</code>
|
||||
*/
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
paintIcon(null, g, x, y, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon's width. This is a cover methods for
|
||||
* <code>getIconWidth(null)</code>.
|
||||
*
|
||||
* @return an int specifying the fixed width of the icon.
|
||||
*/
|
||||
public int getIconWidth() {
|
||||
return getIconWidth(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon's height. This is a cover method for
|
||||
* <code>getIconHeight(null)</code>.
|
||||
*
|
||||
* @return an int specifying the fixed height of the icon.
|
||||
*/
|
||||
public int getIconHeight() {
|
||||
return getIconHeight(null);
|
||||
}
|
||||
}
|
||||
97
jdkSrc/jdk8/sun/swing/plaf/windows/ClassicSortArrowIcon.java
Normal file
97
jdkSrc/jdk8/sun/swing/plaf/windows/ClassicSortArrowIcon.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.swing.plaf.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.io.Serializable;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
/**
|
||||
* Classic sort icons.
|
||||
*
|
||||
*/
|
||||
public class ClassicSortArrowIcon implements Icon, UIResource, Serializable{
|
||||
private static final int X_OFFSET = 9;
|
||||
private boolean ascending;
|
||||
|
||||
public ClassicSortArrowIcon(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
x += X_OFFSET;
|
||||
if (ascending) {
|
||||
g.setColor(UIManager.getColor("Table.sortIconHighlight"));
|
||||
drawSide(g, x + 3, y, -1);
|
||||
|
||||
g.setColor(UIManager.getColor("Table.sortIconLight"));
|
||||
drawSide(g, x + 4, y, 1);
|
||||
|
||||
g.fillRect(x + 1, y + 6, 6, 1);
|
||||
}
|
||||
else {
|
||||
g.setColor(UIManager.getColor("Table.sortIconHighlight"));
|
||||
drawSide(g, x + 3, y + 6, -1);
|
||||
g.fillRect(x + 1, y, 6, 1);
|
||||
|
||||
g.setColor(UIManager.getColor("Table.sortIconLight"));
|
||||
drawSide(g, x + 4, y + 6, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawSide(Graphics g, int x, int y, int xIncrement) {
|
||||
int yIncrement = 2;
|
||||
if (ascending) {
|
||||
g.fillRect(x, y, 1, 2);
|
||||
y++;
|
||||
}
|
||||
else {
|
||||
g.fillRect(x, --y, 1, 2);
|
||||
yIncrement = -2;
|
||||
y -= 2;
|
||||
}
|
||||
x += xIncrement;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
g.fillRect(x, y, 1, 3);
|
||||
x += xIncrement;
|
||||
y += yIncrement;
|
||||
}
|
||||
if (!ascending) {
|
||||
y++;
|
||||
}
|
||||
g.fillRect(x, y, 1, 2);
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return X_OFFSET + 8;
|
||||
}
|
||||
public int getIconHeight() {
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user