Source Code Cross Referenced for ListAutomationAction.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » main » htmleditor » action » 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 » Test Coverage » salome tmf » org.objectweb.salome_tmf.ihm.main.htmleditor.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        GNU Lesser General Public License
003:
004:        ListAutomationAction
005:        Copyright (C) 2000 Howard Kistler
006:
007:        This library is free software; you can redistribute it and/or
008:        modify it under the terms of the GNU Lesser General Public
009:        License as published by the Free Software Foundation; either
010:        version 2.1 of the License, or (at your option) any later version.
011:
012:        This library is distributed in the hope that it will be useful,
013:        but WITHOUT ANY WARRANTY; without even the implied warranty of
014:        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:        Lesser General Public License for more details.
016:
017:        You should have received a copy of the GNU Lesser General Public
018:        License along with this library; if not, write to the Free Software
019:        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:
022:        package org.objectweb.salome_tmf.ihm.main.htmleditor.action;
023:
024:        import java.awt.event.ActionEvent;
025:        import java.util.StringTokenizer;
026:
027:        import javax.swing.JEditorPane;
028:        import javax.swing.text.BadLocationException;
029:        import javax.swing.text.html.HTML;
030:        import javax.swing.text.html.HTMLDocument;
031:        import javax.swing.text.html.HTMLEditorKit;
032:
033:        import org.objectweb.salome_tmf.ihm.languages.Language;
034:        import org.objectweb.salome_tmf.ihm.main.htmleditor.EkitCore;
035:        import org.objectweb.salome_tmf.ihm.main.htmleditor.component.HTMLUtilities;
036:        import org.objectweb.salome_tmf.ihm.main.htmleditor.component.SimpleInfoDialog;
037:
038:        /**
039:         * Class for automatically creating bulleted lists from selected text
040:         */
041:        public class ListAutomationAction extends
042:                HTMLEditorKit.InsertHTMLTextAction {
043:
044:            protected EkitCore parentEkit;
045:            private HTML.Tag baseTag;
046:            private HTMLUtilities htmlUtilities;
047:
048:            public ListAutomationAction(EkitCore ekit, String sLabel,
049:                    HTML.Tag listType) {
050:                super (sLabel, "", listType, HTML.Tag.LI);
051:                parentEkit = ekit;
052:                baseTag = listType;
053:                htmlUtilities = new HTMLUtilities(ekit);
054:            }
055:
056:            public void actionPerformed(ActionEvent ae) {
057:                try {
058:                    JEditorPane jepEditor = (JEditorPane) (parentEkit
059:                            .getTextPane());
060:                    String selTextBase = jepEditor.getSelectedText();
061:                    int textLength = -1;
062:                    if (selTextBase != null) {
063:                        textLength = selTextBase.length();
064:                    }
065:                    if (selTextBase == null || textLength < 1) {
066:                        int pos = parentEkit.getCaretPosition();
067:                        parentEkit.setCaretPosition(pos);
068:                        if (ae.getActionCommand() != "newListPoint") {
069:                            if (htmlUtilities.checkParentsTag(HTML.Tag.OL)
070:                                    || htmlUtilities
071:                                            .checkParentsTag(HTML.Tag.UL)) {
072:                                new SimpleInfoDialog(null, Language
073:                                        .getInstance().getText("Error"), true,
074:                                        Language.getInstance().getText(
075:                                                "ErrorNestedListsNotSupported"));
076:                                return;
077:                            }
078:                        }
079:                        String sListType = (baseTag == HTML.Tag.OL ? "ol"
080:                                : "ul");
081:                        StringBuffer sbNew = new StringBuffer();
082:                        if (htmlUtilities.checkParentsTag(baseTag)) {
083:                            sbNew.append("<li></li>");
084:                            insertHTML(parentEkit.getTextPane(), parentEkit
085:                                    .getExtendedHtmlDoc(), parentEkit
086:                                    .getTextPane().getCaretPosition(), sbNew
087:                                    .toString(), 0, 0, HTML.Tag.LI);
088:                        } else {
089:                            sbNew.append("<" + sListType
090:                                    + " class=\"htmldesc\"><li></li></"
091:                                    + sListType + "><p>&nbsp;</p>");
092:                            insertHTML(parentEkit.getTextPane(), parentEkit
093:                                    .getExtendedHtmlDoc(), parentEkit
094:                                    .getTextPane().getCaretPosition(), sbNew
095:                                    .toString(), 0, 0,
096:                                    (sListType.equals("ol") ? HTML.Tag.OL
097:                                            : HTML.Tag.UL));
098:                        }
099:                        parentEkit.refreshOnUpdate();
100:                    } else {
101:                        String sListType = (baseTag == HTML.Tag.OL ? "ol"
102:                                : "ul");
103:                        HTMLDocument htmlDoc = (HTMLDocument) (jepEditor
104:                                .getDocument());
105:                        int iStart = jepEditor.getSelectionStart();
106:                        int iEnd = jepEditor.getSelectionEnd();
107:                        String selText = htmlDoc.getText(iStart, iEnd - iStart);
108:                        StringBuffer sbNew = new StringBuffer();
109:                        String sToken = ((selText.indexOf("\r") > -1) ? "\r"
110:                                : "\n");
111:                        StringTokenizer stTokenizer = new StringTokenizer(
112:                                selText, sToken);
113:                        sbNew.append("<" + sListType + " class=\"htmldesc\">");
114:                        while (stTokenizer.hasMoreTokens()) {
115:                            sbNew.append("<li>");
116:                            sbNew.append(stTokenizer.nextToken());
117:                            sbNew.append("</li>");
118:                        }
119:                        sbNew.append("</" + sListType + "><p>&nbsp;</p>");
120:                        htmlDoc.remove(iStart, iEnd - iStart);
121:                        insertHTML(jepEditor, htmlDoc, iStart,
122:                                sbNew.toString(), 1, 1, null);
123:                    }
124:                } catch (BadLocationException ble) {
125:                }
126:            }
127:        }
w__w___w.j___a___va___2__s___.c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.