001 // This file is part of AceWiki.
002 // Copyright 2008-2012, AceWiki developers.
003 //
004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006 // the License, or (at your option) any later version.
007 //
008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010 // Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013 // not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.preditor;
016
017 import java.util.Collections;
018 import java.util.Comparator;
019 import java.util.HashMap;
020 import java.util.List;
021 import java.util.Map;
022
023 import ch.uzh.ifi.attempto.base.ConcreteOption;
024 import ch.uzh.ifi.attempto.base.NextTokenOptions;
025
026 /**
027 * This class is the default implementation of a menu creator.
028 *
029 * @author Tobias Kuhn
030 */
031 public class DefaultMenuCreator implements MenuCreator {
032
033 private DefaultMenuItemComparator comparator = new DefaultMenuItemComparator();
034 private Map<String, Integer> colors = new HashMap<String, Integer>();
035
036 public MenuEntry createMenuEntry(ConcreteOption option) {
037 return new MenuEntry(option, "word");
038 }
039
040 public List<SpecialMenuItem> createSpecialMenuItems(NextTokenOptions options) {
041 return Collections.emptyList();
042 }
043
044 public List<String> getMenuGroupOrdering() {
045 return Collections.emptyList();
046 }
047
048 public int getColorShift(String menuBlockName) {
049 if (colors.containsKey(menuBlockName)) {
050 return colors.get(menuBlockName);
051 } else {
052 return 0;
053 }
054 }
055
056 /**
057 * This methods sets the color shift for the given menu block. It defines the color in which
058 * the menu block is to be displayed.
059 *
060 * @see MenuCreator#getColorShift
061 * @param menuBlockName The name of the menu block for which the color shift should be set.
062 * @param colorShift The color shift value.
063 */
064 public void setColorShift(String menuBlockName, int colorShift) {
065 colors.put(menuBlockName, colorShift);
066 }
067
068 public Comparator<MenuItem> getMenuItemComparator() {
069 return comparator;
070 }
071
072 }