001 /* 002 * $Id: ScrollBarContextMenuSource.java,v 1.4 2005/10/10 18:02:13 rbair Exp $ 003 * 004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 005 * Santa Clara, California 95054, U.S.A. All rights reserved. 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 020 */ 021 package org.jdesktop.swingx.plaf; 022 023 import java.util.Map; 024 025 import javax.swing.ActionMap; 026 import javax.swing.JComponent; 027 import javax.swing.JScrollBar; 028 029 /** 030 * @author Jeanette Winzenburg 031 */ 032 public class ScrollBarContextMenuSource extends ContextMenuSource { 033 034 String[] keys = { /*null, null, need to add scrollHere!*/ 035 "minScroll", "maxScroll", 036 null, 037 "negativeUnitIncrement", "positiveUnitIncrement", 038 null, 039 "negativeBlockIncrement", "positiveBlockIncrement", 040 }; 041 042 String[] defaultValuesVertical = { 043 "Top", "Bottom", 044 null, 045 "Scroll Up", "Scroll Down", 046 null, 047 "Page Up", "Page Down", 048 }; 049 050 String[] defaultValuesHorizontal = { 051 "Left Edge", "Right Edge", 052 null, 053 "Scroll Left", "Scroll Right", 054 null, 055 "Page Left", "Page Right", 056 }; 057 058 private int orientation; 059 060 public ScrollBarContextMenuSource(int orientation) { 061 this.orientation = orientation; 062 } 063 064 public String[] getKeys() { 065 // TODO Auto-generated method stub 066 return keys; 067 } 068 069 public void updateActionEnabled(JComponent component, ActionMap map) { 070 // TODO Auto-generated method stub 071 072 } 073 074 protected void initNames(Map<String, String> names) { 075 for (int i = 0; i < keys.length; i++) { 076 if (keys[i] != null) { 077 names.put(keys[i], getValue(keys[i], 078 orientation == JScrollBar.VERTICAL ? 079 defaultValuesVertical[i] : defaultValuesHorizontal[i])); 080 } 081 } 082 083 } 084 085 protected String getResourcePrefix() { 086 return "JScrollBar." + getOrientationToken(); 087 } 088 089 private String getOrientationToken() { 090 return orientation == JScrollBar.VERTICAL ? "vertical." : "horizontal."; 091 } 092 093 }