California State University, Northridge
Total Page:16
File Type:pdf, Size:1020Kb
CALIFORNIA STATE UNIVERSITY, NORTHRIDGE IMPLEMENTATION OF A CUSTOMIZED STRUCTURE EDITOR FOR JAVA, JAVASCRIPT AND HTML A graduate project submitted in partial fulfillment of the requirements For the degree of Master of Science in Computer Science By Marian Neagoie December 2014 The graduate project of Marian Neagoie is approved: ____________________________ _____________ Dr. Taehyung Wang Date ____________________________ _____________ Dr. Robert McIlhenny Date ____________________________ _____________ Dr. Richard Covington, Chair Date California State University, Northridge ii DEDICATION This graduate project is dedicated to my parents who have provided me with the greatest support throughout my life. iii ACKNOWLEDGEMENTS I would like to express my sincere gratitude to my advisor Prof. Rick Covington for the continuous support of my study and research, for his patience, enthusiasm, and immense knowledge. His guidance helped me in all the time of research and writing of this graduate project as well as throughout the years. Besides my advisor, I would like to thank the rest of my thesis committee: Prof. Taehyung Wang and Prof. Robert McIlhenny, for their encouragement, insightful comments and invaluable help in all the courses in which they were my instructors. iv ABSTRACT IMPROVED TEXT EDITOR CAPABLE OF RENDERING HTML AND RUNNING JAVASCRIPT By Marian Neagoie Master of Science in Computer Science This defense presents the results of a project intended to develop a structure editor that supports source in the following formats: plaint text, HTML, JavaScript, and Java. The editor is implemented in pure Java, with an emphasis on the Swing packages. Some rendering support for some formats (HTML) is built into Swing. Other rendering support (Java source) is provided by customized tools to generate parse trees that allow keyword highlighting and indentation levels. JavaScript is interpreted and converted to HTML by the built-in eval(). Java source is compiled and interpreted by built-in compile() and exec() methods. The project is compared to existing tools for feature comparison. The Swing GroupLayout feature was chosen as the foundation of the UI, which has been used by code generators in the past. The Nimbus look-and-feel was used. The relationships between Swing and JavaFX was considered but not used in the implementation. v Table of Contents Signature Page ii Dedication iii Acknowledgements iv Abstract v Chapter 1: Introduction 1 1.1 Summary 1 Chapter 2: Current Similar Applications 3 2.1 Text Editors 3 2.1.1 TextMate 3 2.1.2 Notepad++ 4 2.1.3 TextPad 4 2.1.4 Coda 5 2.1.5 gedit 6 2.1.6 PSPad 6 2.2 Integrated Development Environments with Text Editing Features 7 2.2.1 Dreamweaver 7 2.2.2 Aptana 8 2.3 Content Management Systems 9 Chapter 3: Requirement Analysis and Prototyping 10 Chapter 4: Overview and Technology Used 12 vi 4.1 UI Architecture 12 4.2 Java Swing Library 12 4.3 Implementation 13 Chapter 5: Functional Details 17 5.1 General Look and Feel 17 5.2 Getting Started with a New Document 19 5.3 Opening an existing file 20 5.4 Saving a File 23 5.5 Undo Editing 25 5.6 Redo Editing 26 5.7 Cut Text 28 5.8 Copy Text 29 5.9 Paste Text 31 5.10 Delete Text 32 5.11 Select All Text 34 5.12 Bold, Italic, Underline 36 5.13 Font Color 37 5.14 Font Style 38 5.15 Font Size 40 5.16 Rendering HTML 41 5.17 Running JavaScript 45 5.18 Running Java 49 5.19 Help 53 vii 5.20 About 54 5.21 Printing 56 5.22 Quit 57 Conclusion 58 Future Enhancements 59 Bibliography 60 Appendix A: 61 viii CHAPTER 1 INTRODUCTION 1.1 SUMMARY This application is a Java-based desktop application that is an example of a structure editor. Text editing is defined as the process of taking some input, changing it, and producing some output. Today there are many different editors available capable of satisfying the necessities of different types of users. Most of these products allow users to manage collections of files. Professionals such as Web developers or software engineers as a broader category need more advanced tools to perform tasks which simple text editors cannot achieve. Advanced editors are capable of handling more complex tasks, such as parsing different programming languages, editing files of very large sizes, and/or of different encodings, etc. Another important feature of generic structure editors is the fact that they are cognizant of the document’s underlying structure making them ery useful in editing hierarchical or marked up text, or any other type of content with clear and well- defined structure. In parallel to the advancements of these applications, the processing capabilities of the computers are improving exponentially, according to Moore’s Law which states that the number of transistors on integrated circuits doubles approximately every two years. This allows completing larger tasks much faster. This project describes the implementation of a specific structure editor and the lessons learned. The features include rendering and editing of HTML, JavaScript, and Java, 1 plus the ability to compile and execute Java source. Implementation uses pure Java, with an emphasis on Swing. Rendering of HTML is provided as a built-in feature of the JTextPane component. JavaScript interpretation is provided by the built-in eval() mthod. Structured rendering of HTML, JavaScript and Java source is provided by a specialized syntax highlighting text component called RSyntaxTextArea, which extends JtextComponent, so it integrates completely with the standard javax.swing.text package. In the remainder of this thesis, Chapter 2 is presenting a review of the literature, discussing some current similar applications, such as TextPad, which is a tool capable of handling HTML and “lightly” parsing Java, such as highlighting comments or matching brackets. In Chapter 3, the requirement analysis is described and the specifications of the application are listed. Chapter 4 is discussing the Java Programming Language and Java technologies used in the development of the application. Also, a brief comparison between Eclipse and NetBeans is conveyed. In Chapter 5, the functional details are provided with screenshots and description for each task that a user can perform. Chapter 6 is the conclusion of the thesis and the application, its purpose and results. Chapter 7 explains and lists some future enhancements that I would like to include in the application. The Appendix contains the full Java implementation code of the application. 2 CHAPTER 2 CURRENT SIMILAR APPLICATIONS 2.1 TEXT EDITORS This section discusses current similar text editing applications and their competitive advantages are analyzed. A total of six subsections are presenting in order the following popular applications: TextMate, Notepad++, TextPad, Coda, gedit, and PSPad. 2.1.1 TextMate TextMate is a popular Macintosh editor for programmers and designers. It allows the users to theme the interface to their preference. It performs auto completing character pairs like parenthesis and brackets, and allows users to run shell commands from within a document. It was developed by a UNIX geek who was lured to the Mac platform by its ease of use and elegance. TextMate has been considered to be the culmination of Emacs and OS X and has resulted in countless requests for both a Windows and Linux port, but TextMate has remained exclusive for Mac. TextMate is not an IDE but by using its unique scoping system, macros, and powerful snippets it can often provide features that even a language specific IDE is lacking. Even though it has been kept fairly lightweight with a clean and minimalistic GUI, TextMate has enough project management features to keep most users happy. As positive capabilities we can list the following: - Customizable themes; - Capability of running shell commands within a document. The most important weakness is that it is not available for Windows platforms. 3 2.1.2 Notepad++ Notepad ++ is amongst the most popular text editors for a wide range of users. Notepad++ is a simple and open-source application that is available for Windows under the GPL license. Notepad++ is written in C++ and it is focused towards obtaining higher execution speeds and smaller program sizes by using pure Win32 API and STL. Notepad++ is also trying to reduce the world carbon dioxide emissions by using less CPU power. This is achieved by optimizing as many routines as possible without losing user friendliness. Notepad++ supports many languages and it is very easy to download and install. The download is about 7MB and the installation requires less than 23MB of disk space. Because it is so lightweight, Notepad++ can be run from iPods, thumb drives, or any portable device that accepts applications, making it one of the most portable in its class. One of the most notable strengths of Notepad++ is the powerful regular expression search and replace functionality. As an important weakness we can note that there is no version available for Linux. 2.1.3 TextPad TextPad is a general purpose text editor for Microsoft Windows Operating System created by Helios Software Solutions in England. It contains a variety of features including a macro recorder which allows users to define margins, a powerful spell checker for several languages, withdrawal and line alignment of the content, and a feature named “Warm Start”, allowing users to start the application from where it was aborted. TextPad is a versatile text editor which runs on most versions of Microsoft Windows. Many developers use TextPad for things like creating XML files but also for editing Pearl or Java source 4 code. It is also very often utilized as an HTML editor and a free copy is available for evaluation. TextPad is shareware software, so if the users like it after testing it they have to buy the license, which is fairly reasonable (about $21 for a single license and down to $10-15 each for bulk).