Ticket #2445: theme-pack.patch
File theme-pack.patch, 113.6 KB (added by tanya, 15 years ago) |
---|
-
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/SaveBookItem.java
### Eclipse Workspace Patch 1.0 #P sophie
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.connectivity.resources.DelegatingServerAccess; 9 10 import org.sophie2.base.skins.SkinElementId; … … 27 28 private static void defineSkin(ElementPartCreator part) { 28 29 part.add(TITLE_PROP_ID, "Save Book"); 29 30 part.add(TOOL_TIP_PROP_ID, "Save the changes made to the current book"); 30 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_S);31 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_S)); 31 32 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_S, OSUtil.getDefaultMask())); 32 33 } 33 34 -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/PointValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 import org.sophie2.base.commons.util.position.ImmPoint; 4 5 /** 6 * Extension of the extension point defined with {@link SkinValueLoader} interface. 7 * Processes records which kind is <b>point</b> 8 * 9 * @author tanya 10 */ 11 public class PointValueLoader implements SkinValueLoader { 12 13 private static String KIND = "point"; 14 15 public Object createValue(String value, String path) { 16 String trimedPath = path.trim(); 17 String[] values = trimedPath.split(","); 18 19 float x = Float.parseFloat(values[0].trim()); 20 float y = Float.parseFloat(values[1].trim()); 21 22 ImmPoint res = new ImmPoint(x, y); 23 24 return res; 25 } 26 27 public String getKind() { 28 return KIND; 29 } 30 31 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/window/CascadeItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 20 21 private static void defineSkin(ElementPartCreator part) { 21 22 part.add(TITLE_PROP_ID, "Cascade"); 22 23 part.add(TOOL_TIP_PROP_ID, "Stack the book windows so that each title bar is visible"); 23 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_C);24 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_C)); 24 25 } 25 26 26 27 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/SizeValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 import org.sophie2.base.commons.util.position.ImmSize; 4 5 /** 6 * Extension of the extension point defined with {@link SkinValueLoader} interface. 7 * Processes records which kind is <b>size</b> 8 * 9 * @author tanya 10 */ 11 public class SizeValueLoader implements SkinValueLoader { 12 13 private static String KIND = "size"; 14 15 public Object createValue(String value, String path) { 16 17 String trimedPath = path.trim(); 18 String[] values = trimedPath.split(","); 19 20 float width = Float.parseFloat(values[0].trim()); 21 float height = Float.parseFloat(values[1].trim()); 22 23 ImmSize res = new ImmSize(width, height); 24 25 return res; 26 } 27 28 public String getKind() { 29 return KIND; 30 } 31 32 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/CopyItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.visual.skins.ElementPartCreator; 9 10 import org.sophie2.base.visual.skins.SkinPartDef; … … 27 28 part.add(TITLE_PROP_ID, "Copy"); 28 29 part.add(TOOL_TIP_PROP_ID, "Copy the current selection"); 29 30 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_C, OSUtil.getDefaultMask())); 30 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_C);31 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_C)); 31 32 } 32 33 33 34 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/ExitItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.skins.SkinElementId; 9 10 import org.sophie2.base.visual.skins.ElementPartCreator; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Quit Sophie2"); 25 26 part.add(TOOL_TIP_PROP_ID, "Exit Sophie"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_Q);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_Q)); 27 28 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_Q, OSUtil.getDefaultMask())); 28 29 } 29 30 -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/window/WindowMenu.java
4 4 import java.util.ArrayList; 5 5 import java.util.List; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.layout.model.DocView; 8 9 import org.sophie2.base.menus.MenuMember; 9 10 import org.sophie2.base.skins.SkinElementId; … … 42 43 private static void defineSkin(ElementPartCreator part) { 43 44 part.add(TITLE_PROP_ID, "Window"); 44 45 part.add(TOOL_TIP_PROP_ID, "Window menu (Alt+W)"); 45 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_W);46 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_W)); 46 47 } 47 48 48 49 @Override -
modules/org.sophie2.main.func.templates/src/main/java/org/sophie2/main/func/templates/book/SaveBookAsTemplateItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Save As Template"); 23 24 part.add(TOOL_TIP_PROP_ID, "Save current book as template"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_T);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_T)); 25 26 } 26 27 27 28 -
modules/org.sophie2.base.menus/src/main/java/org/sophie2/base/menus/MenuMember.java
5 5 import javax.swing.JMenuItem; 6 6 import javax.swing.KeyStroke; 7 7 8 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 8 9 import org.sophie2.base.commons.util.ImmImage; 9 10 import org.sophie2.base.visual.BaseVisualElement; 10 11 import org.sophie2.core.prolib.impl.AutoProperty; … … 75 76 * 76 77 * @return The property. 77 78 */ 78 public Prop< Integer> mnemonic() {79 class mnemonic extends AutoProperty< Integer> {79 public Prop<MenuMemberMnemonic> mnemonic() { 80 class mnemonic extends AutoProperty<MenuMemberMnemonic> { 80 81 81 82 @SuppressWarnings("synthetic-access") 82 83 @Override 83 protected Integercompute() {84 return getSkinValue(MNEMONIC_PROP_ID, Integer.class);84 protected MenuMemberMnemonic compute() { 85 return getSkinValue(MNEMONIC_PROP_ID, MenuMemberMnemonic.class); 85 86 } 86 87 } 87 88 return getBean().makeProp(mnemonic.class); -
modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/util/ImageUtil.java
44 44 public static ImmImage loadIcon(String iconName) { 45 45 Profiler.hit(); 46 46 String iconPath = ICON_HOME + iconName; 47 48 ImmImage res = loadIconByPath(iconPath); 49 50 assert res != null : "Cannot find the following icon: " + iconPath; 51 52 return res; 53 } 54 55 /** 56 * Loads an icon which is defined with its absolute path according to the 57 * distrib directory of the application. 58 * 59 * @param iconPath 60 * The absolute path of the icon according to the distrib 61 * directory of the application. 62 * @return 63 * The loaded icon. Can be null. 64 */ 65 public static ImmImage loadIconByPath(String iconPath) { 66 Profiler.hit(); 67 47 68 BufferedImage image; 48 69 URL iconURL = FileEntryManager.get().getReadableFileEntry(iconPath); 49 70 50 assert iconURL != null : "Cannot find the following icon: " + iconPath; 51 try { 52 image = ImageIO.read(iconURL); 53 } catch (IOException e) { 54 SophieLog.error("Cannot load icon", e); 55 throw new RuntimeException("Cannot load icon!", e); 71 if (iconURL != null) { 72 try { 73 image = ImageIO.read(iconURL); 74 } catch (IOException e) { 75 SophieLog.error("Cannot load icon", e); 76 throw new RuntimeException("Cannot load icon!", e); 77 } 78 79 ImmImage res = new ImmImage(image); 80 SophieLog.tracef("loadIcon(%s): %s(w=%d, h=%d)", iconPath, res, res 81 .getWidth(), res.getHeight()); 82 return res; 56 83 } 57 ImmImage res = new ImmImage(image); 58 SophieLog.tracef("loadIcon(%s): %s(w=%d, h=%d)", iconPath, 59 res, res.getWidth(), res.getHeight()); 60 return res; 84 return null; 61 85 } 62 86 63 87 /** -
modules/org.sophie2.extra.comment/src/main/java/org/sophie2/extra/comment/view/InsertCommentItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuItem; 6 7 import org.sophie2.base.skins.SkinElementId; 7 8 import org.sophie2.base.visual.skins.ElementPartCreator; … … 22 23 private static void defineSkin(ElementPartCreator part) { 23 24 part.add(TITLE_PROP_ID, "Comment"); 24 25 part.add(TOOL_TIP_PROP_ID, "Add a comment frame to the current page."); 25 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_C);26 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_C)); 26 27 } 27 28 28 29 @Override -
modules/org.sophie2.extra.func.print/src/main/java/org/sophie2/extra/func/print/pdf/export/ExportToPDFItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "PDF..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Export the book as a PDF"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_P);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_P)); 25 26 } 26 27 27 28 /** -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/view/FullScreenItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.ImageUtil; 8 9 import org.sophie2.base.commons.util.ImmImage; 9 10 import org.sophie2.base.layout.model.MainWindowOptions.ScreenMode; … … 29 30 private static void defineSkin(ElementPartCreator part) { 30 31 part.add(BaseVisualElement.TITLE_PROP_ID, "Full Screen Mode"); 31 32 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, "Use Sophie in full-screen mode"); 32 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_F);33 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_F)); 33 34 part.add(MenuMember.ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)); 34 35 part.add(ICON_PROP_ID, ImageUtil.loadIcon("tick.png")); 35 36 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/PasteItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.visual.skins.ElementPartCreator; 9 10 import org.sophie2.base.visual.skins.SkinPartDef; … … 24 25 part.add(TITLE_PROP_ID, "Paste"); 25 26 part.add(TOOL_TIP_PROP_ID, "Paste the contets of the clipboard"); 26 27 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_V, OSUtil.getDefaultMask())); 27 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_P);28 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_P)); 28 29 } 29 30 30 31 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/skins/SkinsMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Skin"); 23 24 part.add(TOOL_TIP_PROP_ID, "Skins Menu (Alt+S)"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_S);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_S)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.extra.func.embedded/src/main/java/org/sophie2/extra/func/embedded/view/InsertBookItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 50 51 private static void defineSkin(ElementPartCreator part) { 51 52 part.add(TITLE_PROP_ID, "Book..."); 52 53 part.add(TOOL_TIP_PROP_ID, "Add a Sophie book to the current page"); 53 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_B);54 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_B)); 54 55 } 55 56 56 57 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/BaseSkinsModule.java
5 5 import org.sophie2.base.config.ConfigKey; 6 6 import org.sophie2.base.skins.providers.SimpleSkinPartsProvider; 7 7 import org.sophie2.base.skins.providers.SkinPartsProvider; 8 import org.sophie2.base.skins.value.loaders.IconValueLoader; 8 9 import org.sophie2.base.skins.value.loaders.SkinValueLoader; 9 10 import org.sophie2.base.skins.value.loaders.TextValueLoader; 10 11 import org.sophie2.core.modularity.SimpleSophieExtension; … … 85 86 } 86 87 87 88 88 private SkinValueLoaderPoint skin EntryValuePoint = null;89 private SkinValueLoaderPoint skinValueLoaderPoint = null; 89 90 90 91 /** 91 92 * Creates an extension point with interface {@link SkinValueLoader}. … … 107 108 * An extension point. 108 109 */ 109 110 public SkinValueLoaderPoint getSkinValueLoaderPoint() { 110 if (this.skin EntryValuePoint == null) {111 this.skin EntryValuePoint = new SkinValueLoaderPoint();111 if (this.skinValueLoaderPoint == null) { 112 this.skinValueLoaderPoint = new SkinValueLoaderPoint(); 112 113 } 113 114 114 return this.skin EntryValuePoint;115 return this.skinValueLoaderPoint; 115 116 } 116 117 117 118 … … 140 141 protected void defineExtensions(List<SophieExtension<?>> res) { 141 142 res.add(getSimpleSkinPartsProvider().asExtension()); 142 143 res.add(new TextValueLoader().asExtension()); 144 res.add(new IconValueLoader().asExtension()); 143 145 res.add(new SimpleSophieExtension<ConfigKey>(ConfigKey.class, SkinManager.CURRENT_LANGUAGE_PACK)); 146 res.add(new SimpleSophieExtension<ConfigKey>(ConfigKey.class, SkinManager.CURRENT_THEME_PACK)); 147 res.add(new SimpleSophieExtension<ConfigKey>(ConfigKey.class, SkinManager.CURRENT_INTERACTION_PACK)); 144 148 } 145 149 } -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/utils/IconValueLoaderUtil.java
1 package org.sophie2.base.skins.utils; 2 3 import org.sophie2.base.commons.util.ImageUtil; 4 5 /** 6 * Utilities related to loading records of the skin which value is a path to an 7 * icon. 8 * 9 * @author tanya 10 */ 11 public class IconValueLoaderUtil { 12 13 /** 14 * Loads an icon. Gets value of the record and path to the skin home 15 * directory. The value of the record is the path - absolute or relative to 16 * an icon. It can be absolute according to the distrib directory of the 17 * application and can be relative to the skin home directory. 18 * 19 * @param value 20 * The value of the record. Absolute or relative path to and 21 * icon. If the value starts with "/", then tha path is absolute. 22 * Otherwise, the path is relative. 23 * @param skinHome 24 * The skin home directory of the skin which requires the icon to be loaded. 25 * @return 26 * Loaded icon. 27 */ 28 public static Object value (String value, String skinHome) { 29 if (value.startsWith("/")) { 30 String real = value.substring(1); 31 return ImageUtil.loadIconByPath(real); 32 } 33 34 return ImageUtil.loadIconByPath(skinHome+value); 35 } 36 } -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/BaseSkinPart.java
37 37 38 38 public RwProp<String> skinName() { 39 39 return getBean().makeValueProp("skinName", String.class, 40 SkinManager. DEFAULT_NAME);40 SkinManager.THEME_PACK_NAME); 41 41 } 42 42 43 43 /** -
modules/org.sophie2.extra.func.browser/src/main/java/org/sophie2/extra/func/browser/flash/view/InsertFlashItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 22 23 private static void defineSkin(ElementPartCreator part) { 23 24 part.add(TITLE_PROP_ID, "Flash..."); 24 25 part.add(TOOL_TIP_PROP_ID, "Add a flash frame to the current page."); 25 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_F);26 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_F)); 26 27 } 27 28 28 29 @Override -
modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/InsertTextItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Text"); 25 26 part.add(TOOL_TIP_PROP_ID, "Add an empty text frame to the current page"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_T);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_T)); 27 28 } 28 29 29 30 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/IntegerValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 /** 4 * Extension of the extension point defined with {@link SkinValueLoader} interface. 5 * Processes records which kind is <b>integer</b> 6 * 7 * @author tanya 8 */ 9 public class IntegerValueLoader implements SkinValueLoader { 10 11 private static String KIND = "Integer"; 12 13 public Object createValue(String value, String path) { 14 return Integer.parseInt(value); 15 } 16 17 public String getKind() { 18 return KIND; 19 } 20 21 } -
modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/view/InsertPDFItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Pdf..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Add a PDF to the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_P);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_P)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/providers/SkinPartsProvider.java
4 4 import org.sophie2.core.prolib.interfaces.ListProp; 5 5 6 6 /** 7 * Extension point providinga list of base skin parts which are to be used in8 * the current skin. 7 * Interface of an extension point that provides a list of base skin parts which are to be used in 8 * the current skin. 9 9 * 10 10 * @author tanya 11 11 */ -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/BooleanValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 /** 4 * Extension of the extension point defined with {@link SkinValueLoader} interface. 5 * Processes records which kind is <b>boolean</b> 6 * 7 * @author tanya 8 */ 9 public class BooleanValueLoader implements SkinValueLoader { 10 11 private static String KIND = "boolean"; 12 13 public Object createValue(String value, String path) { 14 String valueString = value.toLowerCase(); 15 String trueString = Boolean.TRUE.toString().toLowerCase(); 16 17 return valueString.equals(trueString) ? true : false; 18 } 19 20 public String getKind() { 21 return KIND; 22 } 23 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/SaveBookAsItem.java
5 5 6 6 import javax.swing.KeyStroke; 7 7 8 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 8 9 import org.sophie2.base.commons.util.OSUtil; 9 10 import org.sophie2.base.skins.SkinElementId; 10 11 import org.sophie2.base.visual.skins.ElementPartCreator; … … 27 28 private static void defineSkin(ElementPartCreator part) { 28 29 part.add(TITLE_PROP_ID, "Save Book As..."); 29 30 part.add(TOOL_TIP_PROP_ID, "Save the current book with a new name"); 30 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_A);31 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_A)); 31 32 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_S, 32 33 OSUtil.getDefaultMask() | InputEvent.SHIFT_MASK)); 33 34 } -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/SkinManager.java
72 72 }; 73 73 74 74 /** 75 * Config key for current language skin.75 * Config key for current language pack. 76 76 */ 77 77 public static final ConfigKey<String> CURRENT_LANGUAGE_PACK = ConfigKey.makeKey( 78 78 String.class, "currentLanguagePack", "skins.config", SkinManager.LANGUAGE_PACK_NAME); 79 80 /** 81 * Config key for current theme pack. 82 */ 83 public static final ConfigKey<String> CURRENT_THEME_PACK = ConfigKey.makeKey( 84 String.class, "currentThemePack", "skins.config", SkinManager.THEME_PACK_NAME); 85 86 /** 87 * Config key for current interaction pack. 88 */ 89 public static final ConfigKey<String> CURRENT_INTERACTION_PACK = ConfigKey.makeKey( 90 String.class, "currentInteractionPack", "skins.config", SkinManager.INTERACTION_PACK_NAME); 79 91 80 92 81 93 private Skin defaultLanguagePack = null; 82 private Skin defaultPack = null; 94 private Skin defaultThemePack = null; 95 private Skin defaultInteractionPack = null; 83 96 84 97 /** 85 * The name of the default skin.98 * The name of the default language pack. 86 99 */ 87 public final static String DEFAULT_NAME = "default:en"; 88 100 public final static String LANGUAGE_PACK_NAME = "language:default"; 101 102 /** 103 * The name of the default theme pack. 104 */ 105 public final static String THEME_PACK_NAME = "theme:default"; 106 89 107 /** 90 * The name of the default language skin.108 * The name of the default interaction pack. 91 109 */ 92 public final static String LANGUAGE_PACK_NAME = "language:default";110 public final static String INTERACTION_PACK_NAME = "interaction:default"; 93 111 94 112 /** 95 113 * Singleton method to return an instance of the default language skin. … … 99 117 */ 100 118 public Skin getDefaultLanguagePack() { 101 119 if (this.defaultLanguagePack == null) { 102 this.defaultLanguagePack = new Skin(SkinManager.LANGUAGE_PACK_NAME, getDefaultPack());120 this.defaultLanguagePack = new Skin(SkinManager.LANGUAGE_PACK_NAME, null); 103 121 } 104 122 105 123 return this.defaultLanguagePack; 106 124 } 107 125 108 126 /** 109 * Singleton method to return an instance of the default skin.127 * Singleton method to return an instance of the default theme pack. 110 128 * 111 129 * @return 112 * An instance of the default skin.130 * An instance of the default theme pack. 113 131 */ 114 public Skin getDefault Pack() {115 if (this.default Pack == null) {116 this.default Pack = new Skin(SkinManager.DEFAULT_NAME, null);132 public Skin getDefaultThemePack() { 133 if (this.defaultThemePack == null) { 134 this.defaultThemePack = new Skin(SkinManager.THEME_PACK_NAME, null); 117 135 } 118 136 119 return this.default Pack;137 return this.defaultThemePack; 120 138 } 121 139 122 140 /** 123 * Property for synchronizing skins. 141 * Singleton method to return an instance of the default interaction pack. 142 * 143 * @return 144 * An instance of the default interaction pack. 145 */ 146 public Skin getDefaultInteractionPack() { 147 if (this.defaultInteractionPack == null) { 148 this.defaultInteractionPack = new Skin(SkinManager.INTERACTION_PACK_NAME, null); 149 } 150 151 return this.defaultInteractionPack; 152 } 153 154 /** 155 * Property for synchronizing language packs. 124 156 * @return 125 157 * The property 126 158 */ 127 public Prop<Void> sync Skin() {128 class sync Skinextends ResourceProperty<Void> {159 public Prop<Void> syncLanguagePack() { 160 class syncLanguagePack extends ResourceProperty<Void> { 129 161 130 162 @Override 131 163 protected Void create() { … … 143 175 144 176 String currentLanguage = ConfigurationManager.get().getValue(CURRENT_LANGUAGE_PACK); 145 177 146 SophieLog.info("Loading skin" + currentLanguage);178 SophieLog.info("Loading language pack " + currentLanguage); 147 179 148 180 SimpleSkinPartsProvider provider = BaseSkinsModule.get() 149 181 .getSimpleSkinPartsProvider(); 150 Skin skin = createSkin(currentLanguage, provider.parts().get() , SkinManager.LANGUAGE_PACK_NAME);182 Skin skin = createSkin(currentLanguage, provider.parts().get()); 151 183 currentLanguagePack().set(skin); 152 184 } 153 185 } 154 return getBean().makeProp(syncSkin.class); 186 return getBean().makeProp(syncLanguagePack.class); 187 } 188 189 /** 190 * Property for synchronizing theme packs. 191 * @return 192 * The property 193 */ 194 public Prop<Void> syncThemePack() { 195 class syncThemePack extends ResourceProperty<Void> { 196 197 @Override 198 protected Void create() { 199 return null; 200 } 201 202 @Override 203 protected void destroy(Void res) { 204 //TODO 205 } 206 207 @SuppressWarnings("synthetic-access") 208 @Override 209 protected void setup(Void res) { 210 211 String currentTheme = ConfigurationManager.get().getValue(CURRENT_THEME_PACK); 212 213 SimpleSkinPartsProvider provider = BaseSkinsModule.get() 214 .getSimpleSkinPartsProvider(); 215 Skin skin = createSkin(currentTheme, provider.parts().get()); 216 currentThemePack().set(skin); 217 } 218 } 219 return getBean().makeProp(syncThemePack.class); 220 } 221 222 /** 223 * Property for synchronizing interaction packs. 224 * @return 225 * The property 226 */ 227 public Prop<Void> syncInteractionPack() { 228 class syncInteractionPack extends ResourceProperty<Void> { 229 230 @Override 231 protected Void create() { 232 return null; 233 } 234 235 @Override 236 protected void destroy(Void res) { 237 //TODO 238 } 239 240 @SuppressWarnings("synthetic-access") 241 @Override 242 protected void setup(Void res) { 243 244 String currentInteraction = ConfigurationManager.get().getValue(CURRENT_INTERACTION_PACK); 245 246 SophieLog.info("Loading interaction pack " + currentInteraction); 247 248 SimpleSkinPartsProvider provider = BaseSkinsModule.get() 249 .getSimpleSkinPartsProvider(); 250 Skin skin = createSkin(currentInteraction, provider.parts().get()); 251 252 currentInteractionPack().set(skin); 253 } 254 } 255 return getBean().makeProp(syncInteractionPack.class); 155 256 } 156 257 157 258 /** … … 164 265 * @return 165 266 * The new skin created. 166 267 */ 167 private static Skin createSkin(String skinName, List<SkinPart> parts , String packName) {268 private static Skin createSkin(String skinName, List<SkinPart> parts) { 168 269 169 270 if (SkinManager.skinCache.containsKey(skinName)) { 170 271 SophieLog.trace("Skin loaded from cache " + skinName); … … 176 277 SophieLog.trace(skinDef); 177 278 178 279 if (skinDef == null) { 179 return SkinManager.skinCache.get( packName);280 return SkinManager.skinCache.get(NONE_SKIN_VALUE); 180 281 } 181 282 182 283 loadSkinParts(skinName, parts); 183 284 184 285 String fallbackName = getFallbackSkinName(skinDef); 185 Skin fallbackSkin = createSkin(fallbackName, parts , packName);286 Skin fallbackSkin = createSkin(fallbackName, parts); 186 287 187 288 Skin skin = new Skin(skinName, fallbackSkin); 188 289 SkinManager.skinCache.put(skinName, skin); … … 208 309 String begin = skinName.substring(0, index); 209 310 String end = skinName.substring(index + 1); 210 311 String languagePackDir = begin + "_" + end; 211 212 List<String> partEntries = FileEntryManager.get().listFileEntries( "skins/" + languagePackDir);312 String path = "skins/" + languagePackDir; 313 List<String> partEntries = FileEntryManager.get().listFileEntries(path); 213 314 for (String part : partEntries) { 214 315 215 SophieLog.trace("Loading pa rt" + part);316 SophieLog.trace("Loading pack " + part); 216 317 217 318 int relativeIndex = part.lastIndexOf("skins"); 218 319 String relativePath = part.substring(relativeIndex); … … 220 321 URL partFile = FileEntryManager.get().getReadableFileEntry(relativePath); 221 322 222 323 BaseSkinPart skinPart = new BaseSkinPart(skinName); 223 loadPart(skinName, partFile, skinPart );324 loadPart(skinName, partFile, skinPart, path); 224 325 parts.add(skinPart); 225 326 } 226 327 } 227 328 228 329 private static void loadPart(String skinName, URL partFile, 229 BaseSkinPart skinPart ) {330 BaseSkinPart skinPart, String path) { 230 331 231 332 BufferedReader input = null; 232 333 … … 238 339 while ((line = input.readLine()) != null) { 239 340 String trimmed = line.trim(); 240 341 if (!trimmed.equals("") && !trimmed.startsWith("#")) { 241 initRecord(skinName, skinPart, line );342 initRecord(skinName, skinPart, line, path); 242 343 } 243 344 } 244 345 … … 255 356 } 256 357 } 257 358 258 private static void initRecord(String skinName, SkinPart part, String toPart ) {359 private static void initRecord(String skinName, SkinPart part, String toPart, String path) { 259 360 260 361 String[] idParts = toPart.trim().split(" : ", PARTS_NUMBER); 261 362 262 363 if (idParts.length == PARTS_NUMBER) { 263 Object value = createValue(idParts[1], idParts[2], skinName );364 Object value = createValue(idParts[1], idParts[2], skinName, path); 264 365 265 366 if (value != null) { 266 367 part.records().get().add( … … 273 374 } 274 375 275 376 private static final Object createValue(String kind, String value, 276 String skinName ) {377 String skinName, String path) { 277 378 278 379 assert kind != null && kind != "" : "The kind of the value that is to be created should " + 279 380 "not be null and should not be an empty string"; … … 283 384 284 385 for (SophieExtension<SkinValueLoader> entry : extensions) { 285 386 if (kind.equals(entry.getObject().getKind())) { 286 Object res = entry.getObject().createValue(value );387 Object res = entry.getObject().createValue(value, path); 287 388 return res; 288 389 } 289 390 } 290 391 291 392 return null; 292 } 393 } 293 394 294 395 /** 295 * The current Skinthat is in use.396 * The current language skin pack that is in use. 296 397 * 297 * @return 298 * The property.398 * @return 399 * The property. 299 400 */ 300 public RwProp<Skin> current Skin() {301 return getBean().makeValueProp("current Skin", Skin.class);401 public RwProp<Skin> currentLanguagePack() { 402 return getBean().makeValueProp("currentLanguagePack", Skin.class); 302 403 } 303 404 304 405 /** 305 * The current skinthat is in use.406 * The current theme skin pack that is in use. 306 407 * 307 408 * @return 308 409 * The property. 309 410 */ 310 public RwProp<Skin> currentLanguagePack() { 311 return getBean().makeValueProp("currentLanguagePack", Skin.class); 411 public RwProp<Skin> currentThemePack() { 412 return getBean().makeValueProp("currentThemePack", Skin.class); 413 } 414 415 /** 416 * The current interaction skin pack that is in use. 417 * 418 * @return 419 * The property. 420 */ 421 public RwProp<Skin> currentInteractionPack() { 422 return getBean().makeValueProp("currentInteractionPack", Skin.class); 312 423 } 313 424 314 425 /** … … 324 435 325 436 @Override 326 437 protected LookAndFeel compute() { 327 Skin currentSkin = currentSkin().get(); 328 329 LookAndFeel lookAndFeel = currentSkin.getValue(LOOK_AND_FEEL_SKIN_ID, 330 LookAndFeel.class); 438 Skin currentSkin = currentThemePack().get(); 439 LookAndFeel lookAndFeel = currentSkin.getValue(LOOK_AND_FEEL_SKIN_ID, LookAndFeel.class); 331 440 332 441 if (lookAndFeel != null) { 333 442 try { … … 365 474 // XXX: singleton 366 475 private SkinManager() { 367 476 skinCache.put(NONE_SKIN_VALUE, null); 477 skinCache.put(SkinManager.INTERACTION_PACK_NAME, getDefaultInteractionPack()); 478 skinCache.put(SkinManager.LANGUAGE_PACK_NAME, getDefaultLanguagePack()); 479 skinCache.put(SkinManager.THEME_PACK_NAME, getDefaultThemePack()); 480 481 currentThemePack().set(getDefaultThemePack()); 368 482 currentLanguagePack().set(getDefaultLanguagePack()); 369 current Skin().set(getDefaultPack());483 currentInteractionPack().set(getDefaultInteractionPack()); 370 484 } 371 485 372 486 private static SkinManager instance = null; -
modules/org.sophie2.main.func.help/src/main/java/org/sophie2/main/func/help/menuitems/AboutItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuMember; 6 7 import org.sophie2.base.skins.SkinElementId; 7 8 import org.sophie2.base.visual.BaseVisualElement; … … 23 24 part.add(BaseVisualElement.TITLE_PROP_ID, "About"); 24 25 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, 25 26 "Show version and license information"); 26 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_A);27 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_A)); 27 28 part.add(MenuMember.ACCELERATOR_PROP_ID, null); 28 29 } 29 30 -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/ShowConnectionsItem.java
1 1 package org.sophie2.main.app.menus.edit; 2 2 3 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 3 4 import org.sophie2.base.commons.util.ImageUtil; 4 5 import org.sophie2.base.commons.util.ImmImage; 5 6 import org.sophie2.base.skins.SkinElementId; … … 18 19 private static void defineSkin(ElementPartCreator part) { 19 20 part.add(TITLE_PROP_ID, "{generated}"); 20 21 part.add(TOOL_TIP_PROP_ID, "Toggle the display of text frame chain connections"); 21 part.add(MNEMONIC_PROP_ID, 0);22 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(0)); 22 23 part.add(ACCELERATOR_PROP_ID, null); 23 24 part.add(ICON_PROP_ID, ImageUtil.loadIcon("tick.png")); 24 25 } -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/TextValueLoader.java
3 3 import org.sophie2.core.modularity.SimpleSophieExtension; 4 4 5 5 /** 6 * Extension for the extension point defined with {@link SkinValueLoader} interface. 6 * Extension of the extension point defined with {@link SkinValueLoader} interface. 7 * Processes records which kind is <b>text</b> 7 8 * 8 9 * @author tanya 9 10 */ … … 11 12 12 13 private static String KIND = "text"; 13 14 14 public Object createValue(String value ) {15 public Object createValue(String value, String path) { 15 16 return value; 16 17 } 17 18 … … 28 29 public SimpleSophieExtension<SkinValueLoader> asExtension() { 29 30 return new SimpleSophieExtension<SkinValueLoader>(SkinValueLoader.class, this); 30 31 } 31 } 32 } 33 No newline at end of file -
modules/org.sophie2.base.menus/src/main/java/org/sophie2/base/menus/MenuItem.java
71 71 res.setAccelerator(accelerator().get()); 72 72 } 73 73 if (!OSUtil.isMacOS() && mnemonic().get() != null) { 74 res.setMnemonic(mnemonic().get() );74 res.setMnemonic(mnemonic().get().getMnemonic()); 75 75 } 76 76 } 77 77 -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/BookPropertiesItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Book Properties..."); 25 26 part.add(TOOL_TIP_PROP_ID, "Edit the current book's title and dimensions"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_R);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_R)); 27 28 } 28 29 29 30 -
modules/org.sophie2.base.skins/src/test/java/org/sophie2/base/skins/SkinsTest.java
1 package org.sophie2.base.skins;2 3 import java.util.List;4 5 import org.sophie2.base.skins.providers.SimpleSkinPartsProvider;6 import org.sophie2.core.modularity.FakeModuleRegistry;7 import org.sophie2.core.modularity.SophieExtension;8 import org.sophie2.core.modularity.SophieExtensionPoint;9 import org.sophie2.core.modularity.SophieModule;10 import org.sophie2.core.prolib.impl.AutoProperty;11 import org.sophie2.core.prolib.impl.BaseProObject;12 import org.sophie2.core.prolib.interfaces.Prop;13 import org.sophie2.core.testing.IntegrationTestBase;14 15 / **16 * A test for Skins. Should test whether {@link Skin}s are properly changing.17 *18 * @author peko19 */20 public class SkinsTest extends IntegrationTestBase {21 22 // create the skin values for both skins. These are just Strings but can be23 // any other types. =>24 25 // default Skin values.26 private final static String DEFAULT_SKIN_TOOLTIP = "This is a tool-tip for the SkinsTest";27 private final static String DEFAULT_SKIN_TITLE = "This is a title for the SkinsTest";28 private final static String DEFAULT_SKIN_STRING = "This is just a String...";29 30 // alternative Skin values.31 private final static String ALT_SKIN_TOOLTIP = "Th15 15 4 t00l-t1p f0r the Sk1n5Te5t";32 private final static String ALT_SKIN_TITLE = "Th15 15 4 t1tle f0r the 5k1n5Te5t";33 private final static String ALT_SKIN_STRING = "Th15 15 ju5t 4 5tr1ng...";34 35 // cool Skin value.36 private final static String COOL_SKIN_TITLE = "<html>This is<br>a test title with <br> three lines </html>";37 38 private final static String TITLE_ID = "test-title";39 private final static String TOOLTIP_ID = "test-tooltip";40 private final static String STRING_ID = "test-string";41 42 // the class for use in the record ids.43 private final static Class<DummySkinableComponent> CLAZZ = DummySkinableComponent.class;44 45 private Skin defaultSkin;46 private Skin alternativeSkin;47 48 // the third skin will be used to set part of the values49 // so that its fallback skin is used.50 private Skin coolSkin3;51 private static final String COOL_SKIN_NAME = "Cool Skin";52 53 private DummySkinableComponent component;54 55 56 57 /**58 * A module providing the needed extensions for the test.59 *60 * @author peko, nenko61 *62 */63 public static class DemoModule extends SophieModule {64 65 @Override66 protected void defineExtensionPoints(List<SophieExtensionPoint<?>> res) {67 // no extension points68 }69 70 @Override71 protected void defineExtensions(List<SophieExtension<?>> res) {72 makeSkinParts(res);73 }74 75 @SuppressWarnings("synthetic-access")76 private void makeSkinParts(List<SophieExtension<?>> list) {77 // the default skin will have two SkinParts.78 // create skin parts and add skin records to them.79 BaseSkinPart part1 = new BaseSkinPart(SkinManager.LANGUAGE_PACK_NAME);80 BaseSkinPart part2 = new BaseSkinPart(SkinManager.LANGUAGE_PACK_NAME);81 // the skinpart for the third skin.82 BaseSkinPart part4 = new BaseSkinPart(COOL_SKIN_NAME);83 84 part1.add(SkinUtil.getElementId(CLAZZ), TOOLTIP_ID,85 DEFAULT_SKIN_TOOLTIP);86 part1.add(SkinUtil.getElementId(CLAZZ), TITLE_ID,87 DEFAULT_SKIN_TITLE);88 part2.add(SkinUtil.getElementId(CLAZZ), STRING_ID,89 DEFAULT_SKIN_STRING);90 91 part4.add(SkinUtil.getElementId(CLAZZ), TITLE_ID, COOL_SKIN_TITLE);92 93 SimpleSkinPartsProvider provider = new SimpleSkinPartsProvider();94 provider.parts().add(part1);95 provider.parts().add(part2);96 provider.parts().add(part4);97 98 list.add(provider.asExtension());99 }100 }101 102 /**103 * A dummy implementation for a skinable component.104 *105 * @author peko106 */107 class DummySkinableComponent extends BaseProObject {108 109 /**110 * The tool-tip of this component.111 *112 * @return property.113 */114 public Prop<String> toolTip() {115 class toolTip extends AutoProperty<String> {116 117 @SuppressWarnings( { "synthetic-access", "static-access" })118 @Override119 protected String compute() {120 String res = SkinUtil.getSkinValue(SkinsTest.this.CLAZZ,121 TOOLTIP_ID, String.class);122 return res;123 }124 }125 return getBean().makeProp(toolTip.class);126 }127 128 /**129 * The title of this component.130 *131 * @return property.132 */133 public Prop<String> title() {134 class title extends AutoProperty<String> {135 136 @SuppressWarnings( "synthetic-access")137 @Override138 protected String compute() {139 String res = SkinUtil.getSkinValue(SkinsTest.CLAZZ,140 TITLE_ID, String.class);141 return res;142 }143 }144 return getBean().makeProp(title.class);145 }146 147 /**148 * A string containing property for this component.149 *150 * @return property.151 */152 public Prop<String> string() {153 class string extends AutoProperty<String> {154 155 @SuppressWarnings( "synthetic-access")156 @Override157 protected String compute() {158 String res = SkinUtil.getSkinValue(SkinsTest.CLAZZ,159 STRING_ID, String.class);160 return res;161 }162 }163 return getBean().makeProp(string.class);164 }165 166 }167 168 @SuppressWarnings("unchecked")169 @Override170 protected void setUp() throws Exception {171 super.setUp();172 173 FakeModuleRegistry.start(BaseSkinsModule.class, DemoModule.class);174 175 // the default skin.176 this.defaultSkin = new Skin(SkinManager.DEFAULT_NAME, null);177 178 // the third skin.179 this.coolSkin3 = new Skin(COOL_SKIN_NAME, this.defaultSkin);180 181 this.component = new DummySkinableComponent();182 }183 184 @Override185 protected void tearDown() throws Exception {186 FakeModuleRegistry.stop();187 super.tearDown();188 }189 190 /**191 * Tests the whether the changing of {@link Skin}s changes values properly.192 */193 public void testChangeSkin() {194 195 // setting the skin in the SkinManager.196 SkinManager.get().currentSkin().set(this.defaultSkin);197 198 assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get());199 assertSame(SkinsTest.DEFAULT_SKIN_TITLE, this.component.title().get());200 assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get());201 202 // changing the skin in the SkinManager.203 SkinManager.get().currentSkin().set(this.alternativeSkin);204 205 assertSame(SkinsTest.ALT_SKIN_TOOLTIP, this.component.toolTip().get());206 assertSame(SkinsTest.ALT_SKIN_TITLE, this.component.title().get());207 assertSame(SkinsTest.ALT_SKIN_STRING, this.component.string().get());208 209 // resetting the skin to the initial default skin value.210 SkinManager.get().currentSkin().set(this.defaultSkin);211 212 assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get());213 assertSame(SkinsTest.DEFAULT_SKIN_TITLE, this.component.title().get());214 assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get());215 216 // setting the cool skin so that the fallback skin is used (the default217 // one).218 SkinManager.get().currentSkin().set(this.coolSkin3);219 // from fallback skin.220 assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get());221 // from cool skin222 assertSame(SkinsTest.COOL_SKIN_TITLE, this.component.title().get());223 // from fallback skin again.224 assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get());225 }226 }1 //package org.sophie2.base.skins; 2 // 3 //import java.util.List; 4 // 5 //import org.sophie2.base.skins.providers.SimpleSkinPartsProvider; 6 //import org.sophie2.core.modularity.FakeModuleRegistry; 7 //import org.sophie2.core.modularity.SophieExtension; 8 //import org.sophie2.core.modularity.SophieExtensionPoint; 9 //import org.sophie2.core.modularity.SophieModule; 10 //import org.sophie2.core.prolib.impl.AutoProperty; 11 //import org.sophie2.core.prolib.impl.BaseProObject; 12 //import org.sophie2.core.prolib.interfaces.Prop; 13 //import org.sophie2.core.testing.IntegrationTestBase; 14 // 15 ///** 16 // * A test for Skins. Should test whether {@link Skin}s are properly changing. 17 // * 18 // * @author peko 19 // */ 20 //public class SkinsTest extends IntegrationTestBase { 21 // 22 // // create the skin values for both skins. These are just Strings but can be 23 // // any other types. => 24 // 25 // // default Skin values. 26 // private final static String DEFAULT_SKIN_TOOLTIP = "This is a tool-tip for the SkinsTest"; 27 // private final static String DEFAULT_SKIN_TITLE = "This is a title for the SkinsTest"; 28 // private final static String DEFAULT_SKIN_STRING = "This is just a String..."; 29 // 30 // // alternative Skin values. 31 // private final static String ALT_SKIN_TOOLTIP = "Th15 15 4 t00l-t1p f0r the Sk1n5Te5t"; 32 // private final static String ALT_SKIN_TITLE = "Th15 15 4 t1tle f0r the 5k1n5Te5t"; 33 // private final static String ALT_SKIN_STRING = "Th15 15 ju5t 4 5tr1ng..."; 34 // 35 // // cool Skin value. 36 // private final static String COOL_SKIN_TITLE = "<html>This is<br>a test title with <br> three lines </html>"; 37 // 38 // private final static String TITLE_ID = "test-title"; 39 // private final static String TOOLTIP_ID = "test-tooltip"; 40 // private final static String STRING_ID = "test-string"; 41 // 42 // // the class for use in the record ids. 43 // private final static Class<DummySkinableComponent> CLAZZ = DummySkinableComponent.class; 44 // 45 // private Skin defaultSkin; 46 // private Skin alternativeSkin; 47 // 48 // // the third skin will be used to set part of the values 49 // // so that its fallback skin is used. 50 // private Skin coolSkin3; 51 // private static final String COOL_SKIN_NAME = "Cool Skin"; 52 // 53 // private DummySkinableComponent component; 54 // 55 // 56 // 57 // /** 58 // * A module providing the needed extensions for the test. 59 // * 60 // * @author peko, nenko 61 // * 62 // */ 63 // public static class DemoModule extends SophieModule { 64 // 65 // @Override 66 // protected void defineExtensionPoints(List<SophieExtensionPoint<?>> res) { 67 // // no extension points 68 // } 69 // 70 // @Override 71 // protected void defineExtensions(List<SophieExtension<?>> res) { 72 // makeSkinParts(res); 73 // } 74 // 75 // @SuppressWarnings("synthetic-access") 76 // private void makeSkinParts(List<SophieExtension<?>> list) { 77 // // the default skin will have two SkinParts. 78 // // create skin parts and add skin records to them. 79 // BaseSkinPart part1 = new BaseSkinPart(SkinManager.LANGUAGE_PACK_NAME); 80 // BaseSkinPart part2 = new BaseSkinPart(SkinManager.LANGUAGE_PACK_NAME); 81 // // the skinpart for the third skin. 82 // BaseSkinPart part4 = new BaseSkinPart(COOL_SKIN_NAME); 83 // 84 // part1.add(SkinUtil.getElementId(CLAZZ), TOOLTIP_ID, 85 // DEFAULT_SKIN_TOOLTIP); 86 // part1.add(SkinUtil.getElementId(CLAZZ), TITLE_ID, 87 // DEFAULT_SKIN_TITLE); 88 // part2.add(SkinUtil.getElementId(CLAZZ), STRING_ID, 89 // DEFAULT_SKIN_STRING); 90 // 91 // part4.add(SkinUtil.getElementId(CLAZZ), TITLE_ID, COOL_SKIN_TITLE); 92 // 93 // SimpleSkinPartsProvider provider = new SimpleSkinPartsProvider(); 94 // provider.parts().add(part1); 95 // provider.parts().add(part2); 96 // provider.parts().add(part4); 97 // 98 // list.add(provider.asExtension()); 99 // } 100 // } 101 // 102 // /** 103 // * A dummy implementation for a skinable component. 104 // * 105 // * @author peko 106 // */ 107 // class DummySkinableComponent extends BaseProObject { 108 // 109 // /** 110 // * The tool-tip of this component. 111 // * 112 // * @return property. 113 // */ 114 // public Prop<String> toolTip() { 115 // class toolTip extends AutoProperty<String> { 116 // 117 // @SuppressWarnings( { "synthetic-access", "static-access" }) 118 // @Override 119 // protected String compute() { 120 // String res = SkinUtil.getSkinValue(SkinsTest.this.CLAZZ, 121 // TOOLTIP_ID, String.class); 122 // return res; 123 // } 124 // } 125 // return getBean().makeProp(toolTip.class); 126 // } 127 // 128 // /** 129 // * The title of this component. 130 // * 131 // * @return property. 132 // */ 133 // public Prop<String> title() { 134 // class title extends AutoProperty<String> { 135 // 136 // @SuppressWarnings( "synthetic-access") 137 // @Override 138 // protected String compute() { 139 // String res = SkinUtil.getSkinValue(SkinsTest.CLAZZ, 140 // TITLE_ID, String.class); 141 // return res; 142 // } 143 // } 144 // return getBean().makeProp(title.class); 145 // } 146 // 147 // /** 148 // * A string containing property for this component. 149 // * 150 // * @return property. 151 // */ 152 // public Prop<String> string() { 153 // class string extends AutoProperty<String> { 154 // 155 // @SuppressWarnings( "synthetic-access") 156 // @Override 157 // protected String compute() { 158 // String res = SkinUtil.getSkinValue(SkinsTest.CLAZZ, 159 // STRING_ID, String.class); 160 // return res; 161 // } 162 // } 163 // return getBean().makeProp(string.class); 164 // } 165 // 166 // } 167 // 168 // @SuppressWarnings("unchecked") 169 // @Override 170 // protected void setUp() throws Exception { 171 // super.setUp(); 172 // 173 // FakeModuleRegistry.start(BaseSkinsModule.class, DemoModule.class); 174 // 175 // // the default skin. 176 // this.defaultSkin = new Skin(SkinManager.DEFAULT_NAME, null); 177 // 178 // // the third skin. 179 // this.coolSkin3 = new Skin(COOL_SKIN_NAME, this.defaultSkin); 180 // 181 // this.component = new DummySkinableComponent(); 182 // } 183 // 184 // @Override 185 // protected void tearDown() throws Exception { 186 // FakeModuleRegistry.stop(); 187 // super.tearDown(); 188 // } 189 // 190 // /** 191 // * Tests the whether the changing of {@link Skin}s changes values properly. 192 // */ 193 // public void testChangeSkin() { 194 // 195 // // setting the skin in the SkinManager. 196 // SkinManager.get().currentSkin().set(this.defaultSkin); 197 // 198 // assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get()); 199 // assertSame(SkinsTest.DEFAULT_SKIN_TITLE, this.component.title().get()); 200 // assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get()); 201 // 202 // // changing the skin in the SkinManager. 203 // SkinManager.get().currentSkin().set(this.alternativeSkin); 204 // 205 // assertSame(SkinsTest.ALT_SKIN_TOOLTIP, this.component.toolTip().get()); 206 // assertSame(SkinsTest.ALT_SKIN_TITLE, this.component.title().get()); 207 // assertSame(SkinsTest.ALT_SKIN_STRING, this.component.string().get()); 208 // 209 // // resetting the skin to the initial default skin value. 210 // SkinManager.get().currentSkin().set(this.defaultSkin); 211 // 212 // assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get()); 213 // assertSame(SkinsTest.DEFAULT_SKIN_TITLE, this.component.title().get()); 214 // assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get()); 215 // 216 // // setting the cool skin so that the fallback skin is used (the default 217 // // one). 218 // SkinManager.get().currentSkin().set(this.coolSkin3); 219 // // from fallback skin. 220 // assertSame(SkinsTest.DEFAULT_SKIN_TOOLTIP, this.component.toolTip().get()); 221 // // from cool skin 222 // assertSame(SkinsTest.COOL_SKIN_TITLE, this.component.title().get()); 223 // // from fallback skin again. 224 // assertSame(SkinsTest.DEFAULT_SKIN_STRING, this.component.string().get()); 225 // } 226 //} -
modules/org.sophie2.extra.func.plain/src/main/java/org/sophie2/extra/func/plain/InsertPlainTextItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Plain Text..."); 25 26 part.add(TOOL_TIP_PROP_ID, "Import plain text into a text frame on the current page"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_L);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_L)); 27 28 } 28 29 29 30 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/UndoItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.model.resources.r4.changes.MetaChange; 9 10 import org.sophie2.base.skins.SkinElementId; … … 24 25 private static void defineSkin(ElementPartCreator part) { 25 26 part.add(TITLE_PROP_ID, "{generated}"); 26 27 part.add(TOOL_TIP_PROP_ID, "Undo the last action"); 27 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_U);28 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_U)); 28 29 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_Z, OSUtil.getDefaultMask())); 29 30 } 30 31 -
modules/org.sophie2.extra.func.browser/src/main/java/org/sophie2/extra/func/browser/view/InsertBrowserItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Browser"); 23 24 part.add(TOOL_TIP_PROP_ID, "Insert a browser frame on the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_W);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_W)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.main.func.resources/src/main/java/org/sophie2/main/func/resources/exports/ExportToPackageItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Sophie Package..."); 25 26 part.add(TOOL_TIP_PROP_ID, "Exports current book to package file"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_S);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_S)); 27 28 } 28 29 29 30 /** -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/view/ViewMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuMember; 6 7 import org.sophie2.base.skins.SkinElementId; 7 8 import org.sophie2.base.visual.BaseVisualElement; … … 29 30 part.add(BaseVisualElement.TITLE_PROP_ID, "View"); 30 31 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, 31 32 "View Menu (Alt+V)"); 32 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_V);33 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_V)); 33 34 part.add(MenuMember.ACCELERATOR_PROP_ID, null); 34 35 } 35 36 -
modules/org.sophie2.extra.func.html/src/main/java/org/sophie2/extra/func/html/view/InsertHtmlItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Html..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Import HTML text content into a frame on the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_H);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_H)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.extra.func.print/src/main/java/org/sophie2/extra/func/print/view/PrintItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.skins.SkinElementId; 9 10 import org.sophie2.base.visual.skins.ElementPartCreator; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Print..."); 25 26 part.add(TOOL_TIP_PROP_ID, "Print the book"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_P);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_P)); 27 28 part.add(ACCELERATOR_PROP_ID, 28 29 KeyStroke.getKeyStroke(KeyEvent.VK_P, OSUtil.getDefaultMask())); 29 30 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/NewBookItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.skins.SkinElementId; 9 10 import org.sophie2.base.visual.skins.ElementPartCreator; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "New Book"); 25 26 part.add(TOOL_TIP_PROP_ID, "Create a new book"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_N);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_N)); 27 28 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_N, OSUtil.getDefaultMask())); 28 29 } 29 30 -
modules/org.sophie2.main.func.media/src/main/java/org/sophie2/main/func/media/view/controls/InsertAudioRecordItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.visual.skins.ElementPartCreator; 6 7 import org.sophie2.base.visual.skins.SkinPartDef; 7 8 import org.sophie2.main.app.menus.insert.InsertResourceMenuItem; … … 19 20 private static void defineSkin(ElementPartCreator part) { 20 21 part.add(TITLE_PROP_ID, "Audio Record..."); 21 22 part.add(TOOL_TIP_PROP_ID, "Record audio and add it to the current page"); 22 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_R);23 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_R)); 23 24 } 24 25 25 26 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/OpenItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.skins.SkinElementId; 9 10 import org.sophie2.base.visual.skins.ElementPartCreator; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Open"); 25 26 part.add(TOOL_TIP_PROP_ID, "Open an existing resource"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_O);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_O)); 27 28 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_O, OSUtil.getDefaultMask())); 28 29 } 29 30 -
modules/org.sophie2.base.menus/src/main/java/org/sophie2/base/menus/testing/DummyMenu.java
2 2 3 3 import javax.swing.KeyStroke; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.Menu; 6 7 import org.sophie2.core.prolib.interfaces.RwProp; 7 8 … … 22 23 */ 23 24 public DummyMenu(String toolTip, int mnemonic, KeyStroke accelerator) { 24 25 toolTip().set(toolTip); 25 mnemonic().set( mnemonic);26 mnemonic().set(new MenuMemberMnemonic(mnemonic)); 26 27 accelerator().set(accelerator); 27 28 } 28 29 … … 51 52 52 53 53 54 @Override 54 public RwProp< Integer> mnemonic() {55 return getBean().makeValueProp("mnemonic", Integer.class, 0);55 public RwProp<MenuMemberMnemonic> mnemonic() { 56 return getBean().makeValueProp("mnemonic", MenuMemberMnemonic.class, new MenuMemberMnemonic(0)); 56 57 } 57 58 58 59 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/EditMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 20 21 private static void defineSkin(ElementPartCreator part) { 21 22 part.add(TITLE_PROP_ID, "Edit"); 22 23 part.add(TOOL_TIP_PROP_ID, "Edit menu (Alt+E)"); 23 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_E);24 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_E)); 24 25 } 25 26 26 27 @Override -
modules/org.sophie2.main.func.help/src/main/java/org/sophie2/main/func/help/HelpModule.java
7 7 8 8 import javax.swing.KeyStroke; 9 9 10 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 10 11 import org.sophie2.base.commons.util.OSUtil; 11 12 import org.sophie2.base.config.ConfigKey; 12 13 import org.sophie2.base.dialogs.Dialog; … … 195 196 BaseSkinPart res = new BaseSkinPart(); 196 197 197 198 res.add(SkinUtil.getElementId(HelpMenu.class), MenuMember.MNEMONIC_PROP_ID, 198 KeyEvent.VK_H);199 new MenuMemberMnemonic(KeyEvent.VK_H)); 199 200 res.add(SkinUtil.getElementId(HelpMenu.class), MenuMember.ACCELERATOR_PROP_ID, null); 200 201 201 res.add(SkinUtil.getElementId(InspectorItem.class), MenuMember.MNEMONIC_PROP_ID, -1);202 res.add(SkinUtil.getElementId(InspectorItem.class), MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(-1)); 202 203 if ( Boolean.valueOf(System.getProperty("sophie2.development")) ) { 203 204 res.add(SkinUtil.getElementId(InspectorItem.class), MenuMember.ACCELERATOR_PROP_ID, 204 205 KeyStroke.getKeyStroke(KeyEvent.VK_I, OSUtil.getDefaultMask())); -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/CloseBookItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.layout.model.DocView; 9 10 import org.sophie2.base.layout.model.MainWindow; … … 25 26 private static void defineSkin(ElementPartCreator part) { 26 27 part.add(TITLE_PROP_ID, "Close Book"); 27 28 part.add(TOOL_TIP_PROP_ID, "Close the current book"); 28 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_C);29 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_C)); 29 30 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_W, OSUtil.getDefaultMask())); 30 31 } 31 32 -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/window/TileItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 20 21 private static void defineSkin(ElementPartCreator part) { 21 22 part.add(TITLE_PROP_ID, "Tile"); 22 23 part.add(TOOL_TIP_PROP_ID, "Arrange the book windows so they are shown side by side"); 23 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_T);24 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_T)); 24 25 } 25 26 26 27 @Override -
modules/org.sophie2.main.func.media/src/main/java/org/sophie2/main/func/media/view/InsertAudioItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Audio..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Add an audio file to the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_A);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_A)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/window/DocumentItem.java
1 1 package org.sophie2.main.app.menus.window; 2 2 3 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 3 4 import org.sophie2.base.commons.util.ImageUtil; 4 5 import org.sophie2.base.commons.util.ImmImage; 5 6 import org.sophie2.base.layout.impl.DefaultDocView; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "{generated:document-title}"); 25 26 part.add(TOOL_TIP_PROP_ID, "Switch to this document window"); 26 part.add(MNEMONIC_PROP_ID, 0);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(0)); 27 28 part.add(ICON_PROP_ID, ImageUtil.loadIcon("tick.png")); 28 29 } 29 30 -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/view/NormalModeItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.commons.util.ImageUtil; 6 7 import org.sophie2.base.commons.util.ImmImage; 7 8 import org.sophie2.base.layout.model.MainWindowOptions.ScreenMode; … … 29 30 part.add(BaseVisualElement.TITLE_PROP_ID, "Normal mode"); 30 31 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, 31 32 "Use Sophie in a window"); 32 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_N);33 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_N)); 33 34 part.add(ICON_PROP_ID, ImageUtil.loadIcon("tick.png")); 34 35 } 35 36 -
modules/org.sophie2.main.func.media/src/main/java/org/sophie2/main/func/media/view/InsertVideoItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Video..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Add a video file to the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_V);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_V)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/skins/DefaultSkinItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.commons.util.ImageUtil; 6 7 import org.sophie2.base.commons.util.ImmImage; 7 8 import org.sophie2.base.menus.MenuItem; … … 25 26 private static void defineSkin(ElementPartCreator part) { 26 27 part.add(TITLE_PROP_ID, "Default Skin"); 27 28 part.add(TOOL_TIP_PROP_ID, "Switch to default skin"); 28 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_D);29 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_D)); 29 30 part.add(ICON_PROP_ID, ImageUtil.loadIcon("tick.png")); 30 31 } 31 32 … … 36 37 37 38 @Override 38 39 protected ImmImage computeIcon() { 39 if(SkinManager.get().currentSkin().get().skinName().get().equals(SkinManager.DEFAULT_NAME)) { 40 if(SkinManager.get().currentThemePack().get() != null && 41 SkinManager.get().currentThemePack().get().skinName().get().equals(SkinManager.THEME_PACK_NAME)) { 40 42 return super.computeIcon(); 41 43 } 42 44 -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/SkinUtil.java
3 3 import java.util.ArrayList; 4 4 import java.util.List; 5 5 6 import javax.swing.KeyStroke; 7 8 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 6 9 import org.sophie2.core.logging.SophieLog; 7 10 8 11 /** … … 91 94 Class<T> valueClass) { 92 95 assert valueClass != null : "valueClass must be not null"; 93 96 assert elementClass != null : "elementClass must be not null"; 97 98 Skin currentPack = currentPack(valueClass); 99 Skin defaultPack = defaultPack(valueClass); 94 100 95 Skin currentSkin;101 T res = searchSkin(elementClass, propId, valueClass, currentPack); 96 102 97 if (valueClass.equals(String.class)) { 98 99 currentSkin = SkinManager.get().currentLanguagePack().get(); 100 101 T res = searchSkin(elementClass, propId, valueClass, currentSkin); 102 103 if (res != null) { 104 return res; 105 } 106 107 Skin defaultLanguagePack = SkinManager.get().getDefaultLanguagePack(); 108 res = searchSkin(elementClass, propId, valueClass, defaultLanguagePack); 109 103 if (res != null) { 110 104 return res; 111 } 105 } 112 106 113 currentSkin = SkinManager.get().currentSkin().get(); 114 115 T res = searchSkin(elementClass, propId, valueClass, currentSkin); 116 107 res = searchSkin(elementClass, propId, valueClass, defaultPack); 108 117 109 if (res == null) { 118 110 SophieLog.debugf( 119 111 "Cannot get skin value for element class %s id %s and value" 120 112 + " class: %s", elementClass.getName(), propId, 121 113 valueClass.getName()); 122 114 } 115 123 116 return res; 124 117 } 125 118 … … 142 135 List<T> res = new ArrayList<T>(); 143 136 for (Class<?> c = elementClass; c != null; c = c.getSuperclass()) { 144 137 String id = SkinUtil.getElementId(c); 145 res.addAll( SkinManager.get().currentSkin().get().getValues(id,138 res.addAll(currentPack(valueClass).getValues(id, 146 139 propId, valueClass)); 147 140 } 141 148 142 return res; 149 143 } 144 145 private static <T> Skin currentPack(Class<T> valueClass) { 146 147 148 if (valueClass.equals(String.class)) { 149 return SkinManager.get().currentLanguagePack().get(); 150 } else if (valueClass.equals(valueClass.equals(KeyStroke.class) || valueClass.equals(MenuMemberMnemonic.class))){ 151 return SkinManager.get().currentInteractionPack().get(); 152 } 153 154 return SkinManager.get().currentThemePack().get(); 155 } 156 157 private static <T> Skin defaultPack(Class<T> valueClass) { 158 159 if (valueClass.equals(String.class)) { 160 return SkinManager.get().getDefaultLanguagePack(); 161 } else if (valueClass.equals(valueClass.equals(KeyStroke.class) || valueClass.equals(MenuMemberMnemonic.class))){ 162 return SkinManager.get().getDefaultInteractionPack(); 163 } 164 165 return SkinManager.get().getDefaultThemePack(); 166 } 150 167 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/CutItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.visual.skins.ElementPartCreator; 9 10 import org.sophie2.base.visual.skins.SkinPartDef; … … 27 28 part.add(TITLE_PROP_ID, "Cut"); 28 29 part.add(TOOL_TIP_PROP_ID, "Cut the current selection"); 29 30 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_X, OSUtil.getDefaultMask())); 30 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_T);31 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_T)); 31 32 } 32 33 33 34 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/SaveBookAsTemplateItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Save As Template"); 25 26 part.add(TOOL_TIP_PROP_ID, "Save the current book as a book template"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_T);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_T)); 27 28 } 28 29 29 30 -
modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/gui/MenuMemberMnemonic.java
1 package org.sophie2.base.commons.gui; 2 3 /** 4 * Wrapper class for the mnemonics of menu items of Sophie. 5 * 6 * @author tanya 7 */ 8 public class MenuMemberMnemonic { 9 10 private Integer mnemonic; 11 12 /** 13 * Constructor. Creates new object by integer which is the mnemonic itself. 14 * 15 * @param mnemonic 16 * The mnemonic itself. 17 */ 18 public MenuMemberMnemonic (int mnemonic) { 19 this.mnemonic = mnemonic; 20 } 21 22 /** 23 * Returns the mnemonic. 24 * 25 * @return 26 * The mnemonic. 27 */ 28 public Integer getMnemonic() { 29 return this.mnemonic; 30 } 31 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/edit/RedoItem.java
4 4 5 5 import javax.swing.KeyStroke; 6 6 7 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 7 8 import org.sophie2.base.commons.util.OSUtil; 8 9 import org.sophie2.base.model.resources.r4.changes.MetaChange; 9 10 import org.sophie2.base.skins.SkinElementId; … … 24 25 private static void defineSkin(ElementPartCreator part) { 25 26 part.add(TITLE_PROP_ID, "{generated}"); 26 27 part.add(TOOL_TIP_PROP_ID, "Redo the last undone action"); 27 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_R);28 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_R)); 28 29 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_Y, OSUtil.getDefaultMask())); 29 30 } 30 31 -
modules/org.sophie2.main.func.help/src/main/java/org/sophie2/main/func/help/menuitems/HelpContentsItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuMember; 6 7 import org.sophie2.base.skins.SkinElementId; 7 8 import org.sophie2.base.visual.BaseVisualElement; … … 22 23 private static void defineSkin(ElementPartCreator part) { 23 24 part.add(BaseVisualElement.TITLE_PROP_ID, "Help Contents"); 24 25 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, "Display the main help index"); 25 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_H);26 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_H)); 26 27 part.add(MenuMember.ACCELERATOR_PROP_ID, null); 27 28 } 28 29 -
modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/rtf/InsertRtfItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Rtf..."); 25 26 part.add(TOOL_TIP_PROP_ID, "Import RTF text content into a frame on the current page"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_R);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_R)); 27 28 } 28 29 29 30 @Override -
modules/org.sophie2.base.menus/src/main/java/org/sophie2/base/menus/testing/DummyMenuItem.java
2 2 3 3 import javax.swing.KeyStroke; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuItem; 6 7 import org.sophie2.core.logging.SophieLog; 7 8 import org.sophie2.core.mvc.EventFilterBuilder; … … 62 63 */ 63 64 public DummyMenuItem(String toolTip, int mnemonic, KeyStroke accelerator) { 64 65 toolTip().set(toolTip); 65 mnemonic().set( mnemonic);66 mnemonic().set(new MenuMemberMnemonic(mnemonic)); 66 67 accelerator().set(accelerator); 67 68 } 68 69 … … 82 83 } 83 84 84 85 @Override 85 public RwProp< Integer> mnemonic() {86 return getBean().makeValueProp("mnemonic", Integer.class, 0);86 public RwProp<MenuMemberMnemonic> mnemonic() { 87 return getBean().makeValueProp("mnemonic", MenuMemberMnemonic.class, new MenuMemberMnemonic(0)); 87 88 } 88 89 89 90 @Override -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/insert/InsertMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 23 24 private static void defineSkin(ElementPartCreator part) { 24 25 part.add(TITLE_PROP_ID, "Insert"); 25 26 part.add(TOOL_TIP_PROP_ID, "Insert menu (Alt+I)"); 26 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_I);27 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_I)); 27 28 } 28 29 @Override 29 30 protected boolean computeEnabled() { -
modules/org.sophie2.base.visual/src/main/java/org/sophie2/base/visual/InternalSkinPart.java
6 6 import java.util.HashSet; 7 7 import java.util.Set; 8 8 9 import javax.swing.KeyStroke; 10 11 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 9 12 import org.sophie2.base.skins.BaseSkinPart; 10 13 import org.sophie2.base.skins.SkinUtil; 11 14 import org.sophie2.base.visual.interaction.InteractionEntry; … … 62 65 public void add(String propId, Object value) { 63 66 if (value instanceof String) { 64 67 BaseVisualModule.get().getInternalLanguagePackPart().add(elementId, propId, value); 65 } else { 66 BaseVisualModule.get().getInternalSkinPart().add(elementId, propId, value); 68 } 69 else if (value instanceof KeyStroke || value instanceof MenuMemberMnemonic) { 70 BaseVisualModule.get().getInternalInteractionPackPart().add(elementId, propId, value); 71 } 72 else { 73 BaseVisualModule.get().getInternalThemePackPart().add(elementId, propId, value); 67 74 } 68 75 } 69 76 -
modules/org.sophie2.base.menus/src/main/java/org/sophie2/base/menus/Menu.java
73 73 protected void setupStaticThings(JMenu res) { 74 74 res.setToolTipText(toolTip().get()); 75 75 if (!OSUtil.isMacOS() && mnemonic().get() != null) { 76 res.setMnemonic(mnemonic().get() );76 res.setMnemonic(mnemonic().get().getMnemonic()); 77 77 } 78 78 res.setIcon(icon().get() == null ? null : icon().get().toIcon()); 79 79 } -
modules/org.sophie2.main.skin.alternative/src/main/java/org/sophie2/main/skin/alternative/SkinsMenuLogic.java
30 30 } 31 31 32 32 public boolean handle(EventR3 event) { 33 SkinManager.get().current Skin().set(34 new Skin(SkinManager. DEFAULT_NAME, null));33 SkinManager.get().currentThemePack().set( 34 new Skin(SkinManager.THEME_PACK_NAME, null)); 35 35 36 36 return true; 37 37 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/FileMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "File"); 23 24 part.add(TOOL_TIP_PROP_ID, "File menu (Alt+F)"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_F);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_F)); 25 26 } 26 27 27 28 -
modules/org.sophie2.extra.func.scripting/src/main/java/org/sophie2/extra/func/scripting/view/InsertScriptItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuItem; 6 7 import org.sophie2.base.menus.MenuMember; 7 8 import org.sophie2.base.skins.SkinElementId; … … 27 28 private static void defineSkin(ElementPartCreator part) { 28 29 part.add(BaseVisualElement.TITLE_PROP_ID, "Script"); 29 30 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, "Create a new script in this book"); 30 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_S);31 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_S)); 31 32 } 32 33 33 34 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/IconValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 import org.sophie2.base.skins.utils.IconValueLoaderUtil; 4 import org.sophie2.core.modularity.SimpleSophieExtension; 5 6 /** 7 * Extension of the extension point defined with {@link SkinValueLoader} interface. 8 * Processes records which kind is <b>icon</b> 9 * 10 * @author tanya 11 */ 12 public class IconValueLoader implements SkinValueLoader { 13 14 private static String KIND = "icon"; 15 16 public String getKind() { 17 return KIND; 18 } 19 20 public Object createValue(String value, String path) { 21 return IconValueLoaderUtil.value(value, path); 22 } 23 24 /** 25 * Creates an extension for this {@link SkinValueLoader}. 26 * 27 * @return 28 * The created extension. 29 */ 30 public SimpleSophieExtension<SkinValueLoader> asExtension() { 31 return new SimpleSophieExtension<SkinValueLoader>(SkinValueLoader.class, this); 32 } 33 } -
modules/org.sophie2.main.func.image/src/main/java/org/sophie2/main/func/image/view/InsertImageItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 21 22 private static void defineSkin(ElementPartCreator part) { 22 23 part.add(TITLE_PROP_ID, "Image..."); 23 24 part.add(TOOL_TIP_PROP_ID, "Add an image file to the current page"); 24 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_I);25 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_I)); 25 26 } 26 27 27 28 @Override -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/SkinValueLoader.java
1 1 package org.sophie2.base.skins.value.loaders; 2 2 3 3 /** 4 * An extension point for entries for the skin. (text, icon,..) 4 * Interface of an extension point for records for a skin. 5 * When the skin is to be loaded from a file, the values of the records are Strings that should be parsed. 6 * Depending on that whether the value of the record should be string (for titles or tool-tips for example), 7 * or should be an icon, it should be parsed in different way. The extension point helps to define whether 8 * the value should be parsed to string or icon and finds the appropriate extension that will parse the value. 5 9 * 6 10 * @author tanya 7 11 */ 8 12 public interface SkinValueLoader { 9 13 10 14 /** 11 * Returns the kind of the entry.15 * Returns the kind of the value of the record. The kind can be text or icon for example. 12 16 * 13 17 * @return 14 * The kind of the entry.18 * The kind of the value of the record. 15 19 */ 16 20 public String getKind(); 17 21 18 22 /** 19 * Creates an object and returns is. 23 * Creates an object and returns is. Parse the string to the desired object. 20 24 * 21 25 * @param value 22 * The value needed for an object to be created. 26 * The value needed for an object to be created. The string that should be parsed. 27 * @param path 28 * The home directory of the current skin 29 * (i.e. /distrib/skins/skin_id where skin_id is the id for the current skin) 23 30 * @return 24 * The object created .31 * The object created after parsing of the string. 25 32 */ 26 public Object createValue(String value );33 public Object createValue(String value, String path); 27 34 } -
modules/org.sophie2.main.func.help/src/main/java/org/sophie2/main/func/help/menuitems/BugReportItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.menus.MenuMember; 6 7 import org.sophie2.base.skins.SkinElementId; 7 8 import org.sophie2.base.visual.BaseVisualElement; … … 22 23 private static void defineSkin(ElementPartCreator part) { 23 24 part.add(BaseVisualElement.TITLE_PROP_ID, "Send an Error Report..."); 24 25 part.add(BaseVisualElement.TOOL_TIP_PROP_ID, "Report problems related to application use to the Sophie developers"); 25 part.add(MenuMember.MNEMONIC_PROP_ID, KeyEvent.VK_E);26 part.add(MenuMember.MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_E)); 26 27 part.add(MenuMember.ACCELERATOR_PROP_ID, null); 27 28 } 28 29 -
modules/org.sophie2.base.visual/src/main/java/org/sophie2/base/visual/BaseVisualElement.java
42 42 public BaseVisualElement() { 43 43 getBean(); 44 44 // XXX: Left here just in case. See BaseVisalModule$VisualPoint#extensionRegistered(SophieExtension<VisualProvider>). 45 BaseVisualModule.get().getInternal SkinPart().registerSkinRecords(getClass());45 BaseVisualModule.get().getInternalInteractionPackPart().registerSkinRecords(getClass()); 46 46 } 47 47 48 48 /** -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/MainAppMenusModule.java
3 3 import java.awt.event.KeyEvent; 4 4 import java.util.List; 5 5 6 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 6 7 import org.sophie2.base.menus.MenuItem; 7 8 import org.sophie2.base.menus.MenuMember; 8 9 import org.sophie2.base.skins.BaseSkinPart; … … 189 190 BaseSkinPart res = new BaseSkinPart(); 190 191 191 192 res.add(SkinUtil.getElementId(MinimizeAllItem.class), MenuMember.MNEMONIC_PROP_ID, 192 KeyEvent.VK_M);193 new MenuMemberMnemonic(KeyEvent.VK_M)); 193 194 res.add(SkinUtil.getElementId(MinimizeAllItem.class), MenuMember.ACCELERATOR_PROP_ID, null); 194 195 195 196 res.add(SkinUtil.getElementId(RestoreAllItem.class), MenuMember.MNEMONIC_PROP_ID, 196 KeyEvent.VK_R);197 new MenuMemberMnemonic(KeyEvent.VK_R)); 197 198 res.add(SkinUtil.getElementId(RestoreAllItem.class), MenuMember.ACCELERATOR_PROP_ID, null); 198 199 199 200 return res; -
modules/org.sophie2.base.visual/src/main/java/org/sophie2/base/visual/BaseVisualModule.java
3 3 import java.util.Comparator; 4 4 import java.util.List; 5 5 6 import javax.swing.KeyStroke; 7 8 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 6 9 import org.sophie2.base.skins.SkinManager; 7 10 import org.sophie2.base.skins.providers.SimpleSkinPartsProvider; 8 11 import org.sophie2.base.visual.interaction.InteractionLogic; … … 73 76 74 77 // XXX: copied for the BaseVisaulElement's constructor. Because we actually need the 75 78 // skin values before its invocation. In setup methods. 76 BaseVisualModule.get().getInternal SkinPart().registerSkinRecords(extension.getObject().getProvidedClass());79 BaseVisualModule.get().getInternalInteractionPackPart().registerSkinRecords(extension.getObject().getProvidedClass()); 77 80 } 78 81 79 82 } 80 83 81 84 private VisualPoint visualPoint; 82 private InternalSkinPart internalSkinPart;83 85 private InternalSkinPart internalLanguagePackPart; 86 private InternalSkinPart internalThemePackPart; 87 private InternalSkinPart internalInteractionPackPart; 84 88 85 89 /** 86 90 * Gets the extension point for visual element provides. … … 99 103 } 100 104 101 105 /** 102 * Gets the internal skin part (which holds all skin records defined in103 * classes).106 * Gets the internal language pack part. Holds all the {@link String} records - 107 * tool-tips, titles. 104 108 * 105 109 * @return 106 110 * The internal skin part. 107 111 */ 108 protected InternalSkinPart getInternalSkinPart() { 109 if (this.internalSkinPart == null) { 110 this.internalSkinPart = new InternalSkinPart(); 112 protected InternalSkinPart getInternalLanguagePackPart() { 113 if (this.internalLanguagePackPart == null) { 114 this.internalLanguagePackPart = new InternalSkinPart(); 115 this.internalLanguagePackPart.skinName().set(SkinManager.LANGUAGE_PACK_NAME); 111 116 } 112 return this.internal SkinPart;117 return this.internalLanguagePackPart; 113 118 } 114 119 115 120 /** 116 * Gets the internal language skin part. Holds all the string records -117 * tool-tips, titles.121 * Gets the internal theme pack part. Holds all the records that are not {@link String}, 122 * {@link KeyStroke} or {@link MenuMemberMnemonic}. 118 123 * 119 124 * @return The internal skin part. 120 125 */ 121 protected InternalSkinPart getInternal LanguagePackPart() {122 if (this.internal LanguagePackPart == null) {123 this.internal LanguagePackPart = new InternalSkinPart();124 this.internal LanguagePackPart.skinName().set(SkinManager.LANGUAGE_PACK_NAME);126 protected InternalSkinPart getInternalThemePackPart() { 127 if (this.internalThemePackPart == null) { 128 this.internalThemePackPart = new InternalSkinPart(); 129 this.internalThemePackPart.skinName().set(SkinManager.THEME_PACK_NAME); 125 130 } 126 return this.internal LanguagePackPart;131 return this.internalThemePackPart; 127 132 } 128 133 134 /** 135 * Gets the internal interaction pack part. Holds all the {@link KeyStroke} 136 * and {@link MenuMemberMnemonic} records. 137 * 138 * @return The internal skin part. 139 */ 140 protected InternalSkinPart getInternalInteractionPackPart() { 141 if (this.internalInteractionPackPart == null) { 142 this.internalInteractionPackPart = new InternalSkinPart(); 143 this.internalInteractionPackPart.skinName().set(SkinManager.INTERACTION_PACK_NAME); 144 } 145 return this.internalInteractionPackPart; 146 } 129 147 130 148 private SimpleSkinPartsProvider simpleSkinPartsProvider = null; 131 149 … … 138 156 if (this.simpleSkinPartsProvider == null) { 139 157 this.simpleSkinPartsProvider = new SimpleSkinPartsProvider(); 140 158 141 this.simpleSkinPartsProvider.parts().add(getInternalSkinPart()); 159 this.simpleSkinPartsProvider.parts().add(getInternalThemePackPart()); 160 this.simpleSkinPartsProvider.parts().add(getInternalInteractionPackPart()); 142 161 this.simpleSkinPartsProvider.parts().add(getInternalLanguagePackPart()); 143 162 } 144 163 -
modules/org.sophie2.base.skins/src/main/java/org/sophie2/base/skins/value/loaders/IconsetValueLoader.java
1 package org.sophie2.base.skins.value.loaders; 2 3 import org.sophie2.base.commons.skin.IconId; 4 import org.sophie2.base.commons.skin.IconsSet; 5 import org.sophie2.base.commons.util.ImmImage; 6 import org.sophie2.base.skins.utils.IconValueLoaderUtil; 7 import org.sophie2.core.modularity.SimpleSophieExtension; 8 9 /** 10 * Extension of the extension point defined with {@link SkinValueLoader} interface. 11 * Processes records which kind is <b>iconset</b>. 12 * 13 * @author tanya 14 */ 15 public class IconsetValueLoader implements SkinValueLoader { 16 17 private static String KIND = "iconset"; 18 19 public Object createValue(String value, String path) { 20 IconsSet icons = new IconsSet(); 21 String iconValues[] = value.split(","); 22 for (String record : iconValues) { 23 String recordEntry[] = record.split("="); 24 if (recordEntry.length == 2) { 25 icons.addIcon(IconId.valueOf(recordEntry[0].trim()), 26 (ImmImage)IconValueLoaderUtil.value(recordEntry[1].trim(), path)); 27 } 28 } 29 30 return icons; 31 } 32 33 public String getKind() { 34 return KIND; 35 } 36 37 /** 38 * Creates an extension for this {@link SkinValueLoader}. 39 * 40 * @return 41 * The created extension. 42 */ 43 public SimpleSophieExtension<SkinValueLoader> asExtension() { 44 return new SimpleSophieExtension<SkinValueLoader>(SkinValueLoader.class, this); 45 } 46 } -
modules/org.sophie2.extra.func.print/src/main/java/org/sophie2/extra/func/print/view/PageSetupItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.visual.skins.ElementPartCreator; 6 7 import org.sophie2.base.visual.skins.SkinPartDef; 7 8 import org.sophie2.main.app.menus.AppMenuItem; … … 18 19 private static void defineSkin(ElementPartCreator part) { 19 20 part.add(TITLE_PROP_ID, "Page Setup..."); 20 21 part.add(TOOL_TIP_PROP_ID, "Customize printing page format"); 21 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_A);22 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_A)); 22 23 } 23 24 24 25 @Override -
modules/org.sophie2.extra.func.html/src/main/java/org/sophie2/extra/func/html/view/ExportAsHtmlItem.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 20 21 private static void defineSkin(ElementPartCreator part) { 21 22 part.add(TITLE_PROP_ID, "HTML..."); 22 23 part.add(TOOL_TIP_PROP_ID, "Export the book as a webpage"); 23 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_H);24 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_H)); 24 25 } 25 26 26 27 @Override -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/view/SaveBookOnServerItem.java
5 5 6 6 import javax.swing.KeyStroke; 7 7 8 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 8 9 import org.sophie2.base.commons.util.OSUtil; 9 10 import org.sophie2.base.skins.SkinElementId; 10 11 import org.sophie2.base.visual.skins.ElementPartCreator; … … 27 28 private static void defineSkin(ElementPartCreator part) { 28 29 part.add(TITLE_PROP_ID, "Save On Server..."); 29 30 part.add(TOOL_TIP_PROP_ID, "Save current resource to a server"); 30 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_E);31 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_E)); 31 32 part.add(ACCELERATOR_PROP_ID, KeyStroke.getKeyStroke(KeyEvent.VK_S, 32 33 OSUtil.getDefaultMask() | InputEvent.ALT_MASK)); 33 34 } -
modules/org.sophie2.main.app.menus/src/main/java/org/sophie2/main/app/menus/file/ExportSubMenu.java
2 2 3 3 import java.awt.event.KeyEvent; 4 4 5 import org.sophie2.base.commons.gui.MenuMemberMnemonic; 5 6 import org.sophie2.base.skins.SkinElementId; 6 7 import org.sophie2.base.visual.skins.ElementPartCreator; 7 8 import org.sophie2.base.visual.skins.SkinPartDef; … … 45 46 @SkinPartDef 46 47 private static void defineSkin(ElementPartCreator part) { 47 48 part.add(TITLE_PROP_ID, "Export Book As"); 48 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_X);49 part.add(MNEMONIC_PROP_ID, new MenuMemberMnemonic(KeyEvent.VK_X)); 49 50 } 50 51 51 52