Source Code Cross Referenced for StandardXPDLElementEditor.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » base » editor » 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.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.base.editor;
002:
003:        import java.awt.Component;
004:        import java.awt.Container;
005:        import java.awt.Window;
006:        import java.awt.event.ActionEvent;
007:        import java.awt.event.ActionListener;
008:        import java.awt.event.KeyEvent;
009:        import java.awt.event.WindowAdapter;
010:        import java.awt.event.WindowEvent;
011:        import java.awt.event.WindowListener;
012:        import java.util.ArrayList;
013:        import java.util.List;
014:        import java.util.Properties;
015:
016:        import javax.swing.AbstractAction;
017:        import javax.swing.Box;
018:        import javax.swing.BoxLayout;
019:        import javax.swing.JButton;
020:        import javax.swing.JComponent;
021:        import javax.swing.JDialog;
022:        import javax.swing.JOptionPane;
023:        import javax.swing.JPanel;
024:        import javax.swing.KeyStroke;
025:        import javax.swing.WindowConstants;
026:
027:        import org.enhydra.jawe.JaWEComponent;
028:        import org.enhydra.jawe.JaWEComponentSettings;
029:        import org.enhydra.jawe.JaWEComponentView;
030:        import org.enhydra.jawe.JaWEManager;
031:        import org.enhydra.jawe.ResourceManager;
032:        import org.enhydra.jawe.base.controller.JaWEController;
033:        import org.enhydra.jawe.base.panel.InlinePanel;
034:        import org.enhydra.jawe.base.panel.panels.XMLPanel;
035:        import org.enhydra.shark.xpdl.XMLCollection;
036:        import org.enhydra.shark.xpdl.XMLElement;
037:        import org.enhydra.shark.xpdl.elements.Package;
038:
039:        /**
040:         * The dialog for showing objects derived from {@link XMLPanel} classes. The
041:         * given XMLPanel object must have it's owner, which type is a class
042:         * derived from the {@link XMLElement} class, and serves as a representation
043:         * of an XML tag.
044:         * <p> The dialog enables editing of all editable fields contained
045:         * within given panel and after user presses OK button, the new values
046:         * contained within edited fields are set to corresponding members of
047:         * panel's owner.
048:         */
049:        public class StandardXPDLElementEditor extends JDialog implements 
050:                XPDLElementEditor {
051:            protected String type = JaWEComponent.OTHER_COMPONENT;
052:
053:            public final static int STATUS_OK = 0;
054:            public final static int STATUS_CANCEL = 1;
055:
056:            protected boolean isModified = false;
057:
058:            protected Properties properties = new Properties();
059:
060:            protected XPDLElementEditor parentEditor;
061:            protected XMLElement originalElement;
062:            protected JButton buttonOK;
063:            protected JButton buttonCancel;
064:
065:            protected int status = STATUS_OK;
066:
067:            protected InlinePanel inlinePanel;
068:
069:            protected boolean undoableChange = false;
070:
071:            private StandardXPDLElementEditorSettings settings;
072:
073:            public void configure() {
074:            }
075:
076:            public void setProperty(String key, String value) {
077:                properties.setProperty(key, value);
078:            }
079:
080:            public JaWEComponentSettings getSettings() {
081:                return settings;
082:            }
083:
084:            public StandardXPDLElementEditor() {
085:                super (JaWEManager.getInstance().getJaWEController()
086:                        .getJaWEFrame(), true);
087:                settings = new StandardXPDLElementEditorSettings();
088:                init();
089:            }
090:
091:            public StandardXPDLElementEditor(boolean undoableChange) {
092:                super (JaWEManager.getInstance().getJaWEController()
093:                        .getJaWEFrame(), true);
094:                settings = new StandardXPDLElementEditorSettings();
095:                this .undoableChange = undoableChange;
096:                init();
097:            }
098:
099:            public StandardXPDLElementEditor(
100:                    StandardXPDLElementEditor parentEditor) {
101:                super (parentEditor, true);
102:                settings = new StandardXPDLElementEditorSettings();
103:                init();
104:            }
105:
106:            protected void init() {
107:                try {
108:                    ClassLoader cl = getClass().getClassLoader();
109:                    inlinePanel = (InlinePanel) cl
110:                            .loadClass(
111:                                    JaWEManager.getInstance()
112:                                            .getInlinePanelClassName())
113:                            .newInstance();
114:                } catch (Exception ex) {
115:                    String msg = "StandardXPDLElementEditor --> Problems while instantiating InlinePanel class '"
116:                            + JaWEManager.getInstance()
117:                                    .getInlinePanelClassName()
118:                            + "' - using default implementation!";
119:                    JaWEManager.getInstance().getLoggingManager()
120:                            .error(msg, ex);
121:                    inlinePanel = new InlinePanel();
122:                }
123:                try {
124:                    inlinePanel.setJaWEComponent(this );
125:                    // settings must be initialized after creation of InlinePanel
126:                    settings.init(this );
127:                    inlinePanel.init();
128:
129:                    initDialog();
130:                } catch (Exception ex) {
131:                    ex.printStackTrace();
132:                }
133:            }
134:
135:            public String getLanguageDependentString(String nm) {
136:                return ResourceManager.getLanguageDependentString(nm);
137:            }
138:
139:            public void setTitle(String title) {
140:                super .setTitle(title);
141:            }
142:
143:            public XPDLElementEditor getParentEditor() {
144:                return parentEditor;
145:            }
146:
147:            /** Returns the panel that is currently beeing edited. */
148:            public XMLPanel getEditingPanel() {
149:                return inlinePanel.getViewPanel();
150:            }
151:
152:            public XMLElement getEditingElement() {
153:                return originalElement;
154:            }
155:
156:            public void editXPDLElement(XMLElement el) {
157:                inlinePanel.setActiveElement(el);
158:                if (el != null) {
159:                    String t = getEditingPanel().getTitle();
160:                    if (t == null || t.equals("")) {
161:                        t = JaWEManager.getInstance().getLabelGenerator()
162:                                .getLabel(el);
163:                    }
164:                    setTitle(t);
165:                }
166:                setSize(this .inlinePanel.getDisplay().getSize());
167:                pack();
168:                setLocationRelativeTo(getParentWindow());
169:                setVisible(true);
170:            }
171:
172:            public void editXPDLElement() {
173:                editXPDLElement(JaWEManager.getInstance().getJaWEController()
174:                        .getSelectionManager().getSelectedElement());
175:            }
176:
177:            public boolean canApplyChanges() {
178:                return inlinePanel.canApplyChanges();
179:            }
180:
181:            public void applyChanges() {
182:                XMLElement el = inlinePanel.getActiveElement();
183:                JaWEController jc = JaWEManager.getInstance()
184:                        .getJaWEController();
185:                if (undoableChange) {
186:                    jc.startUndouableChange();
187:                }
188:                inlinePanel.apply();
189:                if (undoableChange) {
190:                    List toSelect = new ArrayList();
191:                    toSelect.add(el);
192:                    jc.endUndouableChange(toSelect);
193:                }
194:            }
195:
196:            public int getStatus() {
197:                return status;
198:            }
199:
200:            public Window getWindow() {
201:                return this ;
202:            }
203:
204:            public Window getParentWindow() {
205:                if (parentEditor == null)
206:                    return JaWEManager.getInstance().getJaWEController()
207:                            .getJaWEFrame();
208:                return parentEditor.getWindow();
209:            }
210:
211:            protected void initDialog() {
212:                try {
213:                    JPanel buttonPanel = new JPanel();
214:                    buttonPanel.setLayout(new BoxLayout(buttonPanel,
215:                            BoxLayout.X_AXIS));
216:
217:                    buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
218:                    buttonPanel.setAlignmentY(Component.TOP_ALIGNMENT);
219:
220:                    buttonOK = new JButton(getLanguageDependentString("OKKey"));
221:
222:                    buttonCancel = new JButton(
223:                            getLanguageDependentString("CancelKey"));
224:
225:                    buttonPanel.add(Box.createHorizontalGlue());
226:                    buttonPanel.add(buttonOK);
227:                    buttonPanel.add(Box.createHorizontalStrut(4));
228:                    buttonPanel.add(buttonCancel);
229:                    buttonPanel.add(Box.createHorizontalStrut(4));
230:
231:                    Container cp = getContentPane();
232:                    cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
233:
234:                    cp.add(inlinePanel);
235:                    cp.add(Box.createVerticalStrut(5));
236:                    cp.add(buttonPanel);
237:
238:                    // action listener for confirming
239:                    buttonOK.addActionListener(okl);
240:
241:                    //       action listener for cancel
242:                    buttonCancel.addActionListener(al);
243:                    addWindowListener(wl);
244:
245:                    getRootPane()
246:                            .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
247:                            .put(
248:                                    KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,
249:                                            0, false), "Cancel");
250:                    getRootPane().getActionMap().put("Cancel",
251:                            new AbstractAction() {
252:                                public void actionPerformed(ActionEvent e) {
253:                                    al.actionPerformed(e);
254:                                }
255:                            });
256:
257:                } catch (Exception e) {
258:                    e.printStackTrace();
259:                }
260:                setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
261:                setResizable(true);
262:                buttonOK.setDefaultCapable(true);
263:                getRootPane().setDefaultButton(buttonOK);
264:            }
265:
266:            protected WindowListener wl = new WindowAdapter() {
267:                public void windowClosing(WindowEvent e) {
268:                    close();
269:                }
270:            };
271:
272:            JDialog dialog = this ;
273:            protected ActionListener al = new ActionListener() {
274:                public void actionPerformed(ActionEvent ae) {
275:                    close();
276:                }
277:            };
278:
279:            public void close() {
280:                if ((inlinePanel.isModified() || isModified)
281:                        && properties.getProperty(
282:                                "XPDLElementEditor.ConfirmCancelOnDataChange",
283:                                "true").equals("true")) {
284:                    int yn = JOptionPane.showConfirmDialog(dialog,
285:                            getLanguageDependentString("WarningReallyQuit"),
286:                            "", JOptionPane.YES_NO_OPTION,
287:                            JOptionPane.WARNING_MESSAGE);
288:
289:                    if (yn == JOptionPane.NO_OPTION) {
290:                        return;
291:                    }
292:                }
293:                status = STATUS_CANCEL;
294:                dispose();
295:            }
296:
297:            protected ActionListener okl = new ActionListener() {
298:                public void actionPerformed(ActionEvent ae) {
299:                    if (inlinePanel.getViewPanel().getOwner().isReadOnly()) {
300:                        status = STATUS_CANCEL;
301:                        dispose();
302:                    } else if (canApplyChanges()) {
303:                        applyChanges();
304:                        status = STATUS_OK;
305:                        dispose();
306:                        //            if (getParent() != null){
307:                        //               getParent().repaint();//do repaint
308:                        //            }
309:                        if (parentEditor != null) {
310:                            parentEditor.setModified(true);
311:                        }
312:
313:                    }
314:                }
315:            };
316:
317:            public void setModified(boolean modif) {
318:                isModified = true;
319:            }
320:
321:            public JaWEComponentView getView() {
322:                return inlinePanel;
323:            }
324:
325:            public JComponent getDisplay() {
326:                return inlinePanel.getDisplay();
327:            }
328:
329:            public String getType() {
330:                return type;
331:            }
332:
333:            public void setType(String type) {
334:                this .type = type;
335:            }
336:
337:            public String getName() {
338:                return "STANDARD_XPDL_EDITOR";
339:            }
340:
341:            public boolean adjustXPDL(Package pkg) {
342:                return false;
343:            }
344:
345:            public List checkValidity(XMLElement el, boolean fullCheck) {
346:                return null;
347:            }
348:
349:            public boolean canCreateElement(XMLCollection col) {
350:                return true;
351:            }
352:
353:            public boolean canInsertElement(XMLCollection col, XMLElement el) {
354:                return true;
355:            }
356:
357:            public boolean canModifyElement(XMLCollection col, XMLElement el) {
358:                return true;
359:            }
360:
361:            public boolean canModifyElement(XMLElement col) {
362:                return true;
363:            }
364:
365:            public boolean canRemoveElement(XMLCollection col, XMLElement el) {
366:                return true;
367:            }
368:
369:            public boolean canDuplicateElement(XMLCollection col, XMLElement el) {
370:                return true;
371:            }
372:
373:            public boolean canRepositionElement(XMLCollection col, XMLElement el) {
374:                return true;
375:            }
376:
377:            public Properties getProperties() {
378:                return properties;
379:            }
380:
381:            public void setUpdateInProgress(boolean inProgress) {
382:
383:            }
384:
385:            public boolean isUpdateInProgress() {
386:                return false;
387:            }
388:
389:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.