001: /**
002: * Miroslav Popov, Dec 2, 2005
003: * miroslav.popov@gmail.com
004: */package org.enhydra.jawe.components.simplenavigator;
005:
006: import java.awt.Color;
007: import java.util.Properties;
008:
009: import javax.swing.Action;
010: import javax.swing.ImageIcon;
011:
012: import org.enhydra.jawe.ActionBase;
013: import org.enhydra.jawe.AdditionalResourceManager;
014: import org.enhydra.jawe.JaWEAction;
015: import org.enhydra.jawe.JaWEComponent;
016: import org.enhydra.jawe.JaWEComponentSettings;
017: import org.enhydra.jawe.ResourceManager;
018: import org.enhydra.jawe.Utils;
019: import org.enhydra.jawe.components.simplenavigator.actions.CollapseAll;
020: import org.enhydra.jawe.components.simplenavigator.actions.ExpandAll;
021:
022: /**
023: * @author Miroslav Popov
024: *
025: */
026: public class SimpleNavigatorSettings extends JaWEComponentSettings {
027:
028: public void init(JaWEComponent comp) {
029: super .init(comp);
030: }
031:
032: public void loadDefault(JaWEComponent comp, Properties properties) {
033: // defaults
034: arm = new AdditionalResourceManager(properties);
035:
036: Color color;
037: try {
038: color = Utils.getColor(ResourceManager.getResourceString(
039: properties, "BackgroundColor"));
040: } catch (Exception e) {
041: color = Utils.getColor("R=245,G=245,B=245");
042: }
043: componentSettings.put("BackgroundColor", color);
044:
045: try {
046: color = Utils.getColor(ResourceManager.getResourceString(
047: properties, "SelectionColor"));
048: } catch (Exception e) {
049: color = Utils.getColor("R=40,G=150,B=240");
050: }
051: componentSettings.put("SelectionColor", color);
052:
053: loadDefaultMenusToolbarsAndActions(comp);
054: componentSettings.putAll(Utils
055: .loadAllMenusAndToolbars(properties));
056: componentAction.putAll(Utils.loadActions(properties, comp,
057: componentAction));
058: }
059:
060: protected void loadDefaultMenusToolbarsAndActions(JaWEComponent comp) {
061:
062: // menu
063: componentSettings
064: .put(
065: "defaultMenu",
066: "ExpandAll CollapseAll - jaweAction_Duplicate jaweAction_Cut jaweAction_Copy jaweAction_Paste jaweAction_Delete - jaweAction_EditProperties");
067:
068: // toolbar
069: componentSettings.put("defaultToolbarToolbar",
070: "ExpandAll CollapseAll");
071:
072: // actions
073: ActionBase action;
074: ImageIcon icon;
075: String langDepName;
076: JaWEAction ja;
077:
078: // CollapseAll
079: action = new CollapseAll(comp);
080: icon = new ImageIcon(ResourceManager.class.getClassLoader()
081: .getResource("org/enhydra/jawe/images/collapseall.png"));
082: langDepName = "CollapseAll";
083: ja = new JaWEAction(action, icon, langDepName);
084: componentAction.put(action.getValue(Action.NAME), ja);
085:
086: // ExpandAll
087: action = new ExpandAll(comp);
088: icon = new ImageIcon(ResourceManager.class.getClassLoader()
089: .getResource("org/enhydra/jawe/images/expandall.png"));
090: langDepName = "ExpandAll";
091: ja = new JaWEAction(action, icon, langDepName);
092: componentAction.put(action.getValue(Action.NAME), ja);
093: }
094:
095: public String getMenuActionOrder(String menuName) {
096: return (String) componentSettings.get(menuName + "Menu");
097: }
098:
099: public String getToolbarActionOrder(String toolbarName) {
100: return (String) componentSettings.get(toolbarName + "Toolbar");
101: }
102:
103: public Color getBackGroundColor() {
104: return (Color) componentSettings.get("BackgroundColor");
105: }
106:
107: public Color getSelectionColor() {
108: return (Color) componentSettings.get("SelectionColor");
109: }
110:
111: }
|