Source Code Cross Referenced for CellTextDialog.java in  » Web-Framework » argun » biz » hammurapi » web » diagrameditor » 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 » Web Framework » argun » biz.hammurapi.web.diagrameditor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * argun 1.0
003:         * Web 2.0 delivery framework 
004:         * Copyright (C) 2007  Hammurapi Group
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * URL: http://www.hammurapi.biz
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package biz.hammurapi.web.diagrameditor;
024:
025:        import java.awt.Font;
026:        import java.awt.GridBagConstraints;
027:        import java.awt.GridBagLayout;
028:        import java.awt.Insets;
029:        import java.awt.event.ActionEvent;
030:        import java.awt.event.ActionListener;
031:        import java.awt.event.KeyAdapter;
032:        import java.awt.event.KeyEvent;
033:
034:        import javax.swing.JButton;
035:        import javax.swing.JFrame;
036:        import javax.swing.JScrollPane;
037:        import javax.swing.JTextPane;
038:        import javax.swing.text.Element;
039:        import javax.swing.text.SimpleAttributeSet;
040:        import javax.swing.text.StyleConstants;
041:        import javax.swing.text.StyledDocument;
042:        import javax.swing.tree.DefaultMutableTreeNode;
043:
044:        import com.jgraph.pad.graph.JGraphpadBusinessObject;
045:        import com.jgraph.pad.graph.JGraphpadRichTextValue;
046:
047:        /**
048:         * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
049:         * Builder, which is free for non-commercial use. If Jigloo is being used
050:         * commercially (ie, by a corporation, company or business for any purpose
051:         * whatever) then you should purchase a license for each developer using Jigloo.
052:         * Please visit www.cloudgarden.com for details. Use of Jigloo implies
053:         * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
054:         * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
055:         * ANY CORPORATE OR COMMERCIAL PURPOSE.
056:         */
057:        public class CellTextDialog extends javax.swing.JDialog {
058:            private JButton okButton;
059:
060:            private JButton cancelButton;
061:
062:            private JTextPane textPane;
063:
064:            private JScrollPane scrollPane;
065:
066:            private DefaultMutableTreeNode node;
067:
068:            /**
069:             * Defines the underline font style. This font style is only available for
070:             * rich text values.
071:             */
072:            protected static final int FONT_UNDERLINE = -1;
073:
074:            public CellTextDialog(JFrame frame, DefaultMutableTreeNode node) {
075:                super (frame);
076:                initGUI();
077:                this .node = node;
078:                Object value = node.getUserObject();
079:                if (value instanceof  JGraphpadBusinessObject
080:                        && ((JGraphpadBusinessObject) value).isRichText())
081:                    try {
082:                        StyledDocument document = (StyledDocument) textPane
083:                                .getDocument();
084:
085:                        ((JGraphpadRichTextValue) ((JGraphpadBusinessObject) value)
086:                                .getValue()).insertInto(document);
087:
088:                        // Workaround for trailing newline
089:                        if (document.getLength() > 0) {
090:                            document.remove(document.getLength() - 1, 1);
091:                        }
092:                    } catch (Exception e) {
093:                        e.printStackTrace();
094:                    }
095:                else {
096:                    textPane.setText(value.toString());
097:                }
098:            }
099:
100:            private void initGUI() {
101:                try {
102:                    GridBagLayout this Layout = new GridBagLayout();
103:                    this Layout.rowWeights = new double[] { 0.1, 0.0 };
104:                    this Layout.rowHeights = new int[] { 303, 7 };
105:                    this Layout.columnWeights = new double[] { 0.1, 0.0 };
106:                    this Layout.columnWidths = new int[] { 107, 7 };
107:                    getContentPane().setLayout(this Layout);
108:                    this .setName("Properties");
109:                    this .setModal(true);
110:                    this .setTitle("Shape text");
111:                    this .setFocusable(false);
112:                    {
113:                        scrollPane = new JScrollPane();
114:                        getContentPane().add(
115:                                scrollPane,
116:                                new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
117:                                        GridBagConstraints.CENTER,
118:                                        GridBagConstraints.BOTH, new Insets(0,
119:                                                0, 0, 0), 0, 0));
120:                        scrollPane.setPreferredSize(new java.awt.Dimension(360,
121:                                159));
122:                        scrollPane.setAutoscrolls(true);
123:                        {
124:                            textPane = new JTextPane();
125:                            scrollPane.setViewportView(textPane);
126:                            textPane.setText("Description");
127:                            textPane.setPreferredSize(new java.awt.Dimension(
128:                                    218, 152));
129:                            textPane.addKeyListener(new KeyAdapter() {
130:                                public void keyTyped(KeyEvent evt) {
131:                                    if (evt.isControlDown()) {
132:                                        int keyChar = evt.getKeyChar();
133:                                        switch (keyChar) {
134:                                        case 2:
135:                                            toggleFont(Font.BOLD);
136:                                            break;
137:                                        case 9:
138:                                            toggleFont(Font.ITALIC);
139:                                            break;
140:                                        case 21:
141:                                            toggleFont(FONT_UNDERLINE);
142:                                            break;
143:                                        }
144:                                    }
145:                                }
146:                            });
147:                        }
148:                    }
149:                    {
150:                        okButton = new JButton();
151:                        getContentPane().add(
152:                                okButton,
153:                                new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
154:                                        GridBagConstraints.EAST,
155:                                        GridBagConstraints.NONE, new Insets(3,
156:                                                0, 3, 5), 0, 0));
157:                        okButton.setText("OK");
158:                        okButton.addActionListener(new ActionListener() {
159:                            public void actionPerformed(ActionEvent evt) {
160:                                okButtonActionPerformed(evt);
161:                            }
162:                        });
163:                    }
164:                    {
165:                        cancelButton = new JButton();
166:                        getContentPane().add(
167:                                cancelButton,
168:                                new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
169:                                        GridBagConstraints.WEST,
170:                                        GridBagConstraints.NONE, new Insets(3,
171:                                                0, 3, 3), 0, 0));
172:                        cancelButton.setText("Cancel");
173:                        cancelButton.addActionListener(new ActionListener() {
174:                            public void actionPerformed(ActionEvent evt) {
175:                                cancelButtonActionPerformed(evt);
176:                            }
177:                        });
178:                    }
179:                    this .setSize(237, 151);
180:                } catch (Exception e) {
181:                    e.printStackTrace();
182:                }
183:            }
184:
185:            private void okButtonActionPerformed(ActionEvent evt) {
186:                if (node.getUserObject() instanceof  JGraphpadBusinessObject) {
187:                    JGraphpadBusinessObject bo = (JGraphpadBusinessObject) node
188:                            .getUserObject();
189:                    bo.setValue(new JGraphpadRichTextValue(textPane
190:                            .getDocument()));
191:                } else {
192:                    node.setUserObject(textPane.getText());
193:                }
194:                cancelButtonActionPerformed(evt);
195:            }
196:
197:            private void cancelButtonActionPerformed(ActionEvent evt) {
198:                setVisible(false);
199:                dispose();
200:            }
201:
202:            private void toggleFont(int style) {
203:                StyledDocument doc = (StyledDocument) textPane.getDocument();
204:                int start = textPane.getSelectionStart();
205:                int len = textPane.getSelectionEnd() - start;
206:                Element ce = doc.getCharacterElement(start);
207:                SimpleAttributeSet sas = new SimpleAttributeSet();
208:                switch (style) {
209:                case Font.BOLD:
210:                    StyleConstants.setBold(sas, !StyleConstants.isBold(ce
211:                            .getAttributes()));
212:                    break;
213:                case Font.ITALIC:
214:                    StyleConstants.setItalic(sas, !StyleConstants.isItalic(ce
215:                            .getAttributes()));
216:                    break;
217:                case FONT_UNDERLINE:
218:                    StyleConstants.setUnderline(sas, !StyleConstants
219:                            .isUnderline(ce.getAttributes()));
220:                    break;
221:                }
222:                doc.setCharacterAttributes(start, len, sas, false);
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.