Source Code Cross Referenced for JaWEActions.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » base » controller » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » JaWE » org.enhydra.jawe.base.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Miroslav Popov, Sep 19, 2005 miroslav.popov@gmail.com
003:         */package org.enhydra.jawe.base.controller;
004:
005:        import java.awt.Insets;
006:        import java.util.HashMap;
007:        import java.util.Iterator;
008:        import java.util.Map;
009:
010:        import javax.swing.AbstractButton;
011:        import javax.swing.Action;
012:        import javax.swing.JButton;
013:        import javax.swing.JMenu;
014:        import javax.swing.JMenuItem;
015:        import javax.swing.JToolBar;
016:        import javax.swing.SwingConstants;
017:
018:        import org.enhydra.jawe.ActionBase;
019:        import org.enhydra.jawe.BarFactory;
020:        import org.enhydra.jawe.ButtonPropertyChangedListener;
021:        import org.enhydra.jawe.JaWEComponent;
022:        import org.enhydra.jawe.Utils;
023:        import org.enhydra.jawe.base.controller.actions.defaultactions.Copy;
024:        import org.enhydra.jawe.base.controller.actions.defaultactions.Cut;
025:        import org.enhydra.jawe.base.controller.actions.defaultactions.Delete;
026:        import org.enhydra.jawe.base.controller.actions.defaultactions.Duplicate;
027:        import org.enhydra.jawe.base.controller.actions.defaultactions.EditProperties;
028:        import org.enhydra.jawe.base.controller.actions.defaultactions.New;
029:        import org.enhydra.jawe.base.controller.actions.defaultactions.Paste;
030:        import org.enhydra.jawe.base.controller.actions.defaultactions.Redo;
031:        import org.enhydra.jawe.base.controller.actions.defaultactions.Undo;
032:
033:        /**
034:         * @author Miroslav Popov
035:         */
036:        public class JaWEActions {
037:
038:            public static final String EDIT_TOOLBAR = "jawe_edittoolbar";
039:
040:            public static final String UNDO_REDO_TOOLBAR = "jawe_undoredo_toolbar";
041:
042:            public static final String EDIT_MENU = "jawe_editmenu";
043:
044:            public static final String NEW_ACTION = "New";
045:
046:            public static final String DUPLICATE_ACTION = "Duplicate";
047:
048:            public static final String REFERENCES = "References";
049:
050:            public static final String UNDO_ACTION = "Undo";
051:
052:            public static final String REDO_ACTION = "Redo";
053:
054:            public static final String CUT_ACTION = "Cut";
055:
056:            public static final String COPY_ACTION = "Copy";
057:
058:            public static final String PASTE_ACTION = "Paste";
059:
060:            public static final String DELETE_ACTION = "Delete";
061:
062:            public static final String EDIT_PROPERTIES_ACTION = "EditProperties";
063:
064:            protected JaWEController controller;
065:
066:            protected Map commands = new HashMap();
067:
068:            public JaWEActions(JaWEController controller) {
069:                this .controller = controller;
070:            }
071:
072:            public void init() {
073:                Undo undo = new Undo(controller);
074:                Redo redo = new Redo(controller);
075:
076:                Cut cut = new Cut(controller);
077:                Copy copy = new Copy(controller);
078:                Paste paste = new Paste(controller);
079:                Delete delete = new Delete(controller);
080:                EditProperties eprop = new EditProperties(controller);
081:                New newA = new New(controller);
082:                Duplicate duplicate = new Duplicate(controller);
083:
084:                Action references = null;
085:                String clsName = "org.enhydra.jawe.base.controller.actions.defaultactions.References";
086:                try {
087:                    references = (ActionBase) Class
088:                            .forName(clsName)
089:                            .getConstructor(new Class[] { JaWEComponent.class })
090:                            .newInstance(new Object[] { controller });
091:                } catch (Exception e) {
092:                }
093:
094:                commands.put(JaWEActions.NEW_ACTION, newA);
095:                commands.put(JaWEActions.DUPLICATE_ACTION, duplicate);
096:                commands.put(JaWEActions.REFERENCES, references);
097:                commands.put(JaWEActions.UNDO_ACTION, undo);
098:                commands.put(JaWEActions.REDO_ACTION, redo);
099:                commands.put(JaWEActions.CUT_ACTION, cut);
100:                commands.put(JaWEActions.COPY_ACTION, copy);
101:                commands.put(JaWEActions.PASTE_ACTION, paste);
102:                commands.put(JaWEActions.DELETE_ACTION, delete);
103:                commands.put(JaWEActions.EDIT_PROPERTIES_ACTION, eprop);
104:            }
105:
106:            public Map getCommands() {
107:                return new HashMap(commands);
108:            }
109:
110:            public ActionBase getAction(String action_name) {
111:                if (action_name == null)
112:                    return null;
113:
114:                return (ActionBase) commands.get(action_name);
115:            }
116:
117:            public void disableAction(String action_name) {
118:                Action a = (Action) commands.get(action_name);
119:
120:                if (a != null)
121:                    a.setEnabled(false);
122:            }
123:
124:            public void enableAction(String action_name) {
125:                Action a = (Action) commands.get(action_name);
126:
127:                if (a != null)
128:                    a.setEnabled(true);
129:            }
130:
131:            public JButton getActionButton(String action_name) {
132:                Action a = (Action) commands.get(action_name);
133:
134:                String aname = action_name;
135:                if (a != null) {
136:                    aname = (String) a.getValue(Action.NAME);
137:                }
138:                // String label = controller.getSettings().getLanguageDependentString(aname +
139:                // BarFactory.LABEL_POSTFIX);
140:                // if (label == null) {
141:                // label = aname;
142:                // }
143:
144:                JButton b = null;
145:                // if (a instanceof NewActionBase) {
146:                // ImageIcon curIc = controller.getControllerSettings().getIconFor(action_name);
147:                // b = new JaWETypeChoiceButton(JaWEType.class,
148:                // ((NewActionBase)a).getXPDLTypeClass(), controller, curIc);
149:                // } else {
150:                b = new JButton(controller.getControllerSettings().getIconFor(
151:                        action_name)) {
152:                    public float getAlignmentY() {
153:                        return 0.5f;
154:                    }
155:                };
156:                // }
157:
158:                b.setName(aname);
159:                b.setMargin(new Insets(1, 1, 1, 1));
160:                b.setRequestFocusEnabled(false);
161:
162:                b.setActionCommand(aname);
163:                if (a != null) {
164:                    b.addActionListener(a);
165:                    b.setEnabled(a.isEnabled());
166:                    a
167:                            .addPropertyChangeListener(new ButtonPropertyChangedListener(
168:                                    b));
169:                } else {
170:                    b.setEnabled(false);
171:                }
172:                String tip = controller.getSettings()
173:                        .getLanguageDependentString(
174:                                aname + BarFactory.TOOLTIP_POSTFIX);
175:                if (tip != null) {
176:                    b.setToolTipText(tip);
177:                }
178:
179:                return b;
180:            }
181:
182:            public JMenuItem getActionMenuItem(String action_name,
183:                    boolean addBCListener) {
184:                Action a = (Action) commands.get(action_name);
185:
186:                String aname = action_name;
187:                if (a != null) {
188:                    aname = (String) a.getValue(Action.NAME);
189:                }
190:                String label = controller.getSettings()
191:                        .getLanguageDependentString(
192:                                aname + BarFactory.LABEL_POSTFIX);
193:                if (label == null) {
194:                    label = aname;
195:                }
196:
197:                JMenuItem mi = new JMenuItem(label);
198:                mi.setName(aname);
199:
200:                mi.setHorizontalTextPosition(SwingConstants.RIGHT);
201:                mi.setIcon(controller.getControllerSettings().getIconFor(
202:                        action_name));
203:
204:                BarFactory.setAccelerator(mi, controller.getSettings()
205:                        .getLanguageDependentString(
206:                                aname + BarFactory.ACCELERATION_POSTFIX));
207:                BarFactory.setMnemonic(mi, controller.getSettings()
208:                        .getLanguageDependentString(
209:                                aname + BarFactory.MNEMONIC_POSTFIX));
210:
211:                mi.setActionCommand(aname);
212:                if (a != null) {
213:                    mi.addActionListener(a);
214:                    if (addBCListener) {
215:                        a
216:                                .addPropertyChangeListener(new ButtonPropertyChangedListener(
217:                                        mi));
218:                    }
219:                    mi.setEnabled(a.isEnabled());
220:                } else {
221:                    mi.setEnabled(false);
222:                }
223:
224:                return mi;
225:            }
226:
227:            public JToolBar getActionToolbar(String toolbar_name) {
228:                if (toolbar_name == null)
229:                    return null;
230:
231:                JToolBar tcomp = new JToolBar();
232:                tcomp.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
233:
234:                if (toolbar_name.equals(JaWEActions.EDIT_TOOLBAR)) {
235:                    String actionOrder = controller.getControllerSettings()
236:                            .getDefaultActionsEditOrder();
237:
238:                    String[] act = Utils.tokenize(actionOrder,
239:                            BarFactory.ACTION_DELIMITER);
240:
241:                    for (int i = 0; i < act.length; i++) {
242:                        if (act[i].equals(BarFactory.ACTION_SEPARATOR)) {
243:                            tcomp.addSeparator();
244:                        } else {
245:                            AbstractButton co = getActionButton(act[i]);
246:                            if (co != null)
247:                                tcomp.add(co);
248:                        }
249:                    }
250:
251:                    tcomp.setName(controller.getSettings()
252:                            .getLanguageDependentString(
253:                                    "editToolbar" + BarFactory.LABEL_POSTFIX));
254:                } else if (toolbar_name.equals(JaWEActions.UNDO_REDO_TOOLBAR)) {
255:                    tcomp.add(getActionButton(JaWEActions.UNDO_ACTION));
256:                    tcomp.add(getActionButton(JaWEActions.REDO_ACTION));
257:                }
258:
259:                return tcomp;
260:            }
261:
262:            public JMenu getActionMenu(String menu_name, boolean addBCListener) {
263:                if (menu_name == null)
264:                    return null;
265:
266:                JMenu mcomp = new JMenu();
267:
268:                if (menu_name.equals(JaWEActions.EDIT_MENU)) {
269:                    mcomp.setText(controller.getSettings()
270:                            .getLanguageDependentString(
271:                                    "edit" + BarFactory.LABEL_POSTFIX));
272:
273:                    BarFactory.setMnemonic(mcomp, controller.getSettings()
274:                            .getLanguageDependentString(
275:                                    "edit" + BarFactory.MNEMONIC_POSTFIX));
276:
277:                    String actionOrder = controller.getControllerSettings()
278:                            .getDefaultActionsEditOrder();
279:                    String[] act = Utils.tokenize(actionOrder,
280:                            BarFactory.ACTION_DELIMITER);
281:
282:                    for (int i = 0; i < act.length; i++) {
283:                        if (act[i].equals(BarFactory.ACTION_SEPARATOR)) {
284:                            mcomp.addSeparator();
285:                        } else {
286:                            JMenuItem mi = getActionMenuItem(act[i],
287:                                    addBCListener);
288:                            if (mi != null)
289:                                mcomp.add(mi);
290:                        }
291:                    }
292:                }
293:
294:                return mcomp;
295:            }
296:
297:            public void enableDisableActions() {
298:                for (Iterator it = commands.values().iterator(); it.hasNext();) {
299:                    ActionBase ab = (ActionBase) it.next();
300:                    if (ab != null) {
301:                        ab.enableDisableAction();
302:                    }
303:                }
304:            }
305:
306:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.