Source Code Cross Referenced for SelectLineRange.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » gui » 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 » Swing Library » jEdit » org.gjt.sp.jedit.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SelectLineRange.java - Selects a range of lines
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 1999, 2000 Slava Pestov
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.gui;
024:
025:        //{{{ Imports
026:        import javax.swing.*;
027:        import javax.swing.border.*;
028:        import java.awt.*;
029:        import java.awt.event.*;
030:        import org.gjt.sp.jedit.textarea.*;
031:        import org.gjt.sp.jedit.*;
032:
033:        //}}}
034:
035:        public class SelectLineRange extends EnhancedDialog implements 
036:                ActionListener {
037:            //{{{ SelectLineRange constructor
038:            public SelectLineRange(View view) {
039:                super (view, jEdit.getProperty("selectlinerange.title"), true);
040:                this .view = view;
041:
042:                JPanel content = new JPanel(new BorderLayout());
043:                content.setBorder(new EmptyBorder(12, 12, 12, 0));
044:                setContentPane(content);
045:
046:                JLabel label = new JLabel(jEdit
047:                        .getProperty("selectlinerange.caption"));
048:                label.setBorder(new EmptyBorder(0, 0, 6, 12));
049:                content.add(BorderLayout.NORTH, label);
050:
051:                JPanel panel = createFieldPanel();
052:
053:                content.add(BorderLayout.CENTER, panel);
054:
055:                panel = new JPanel();
056:                panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
057:                panel.setBorder(new EmptyBorder(6, 0, 0, 12));
058:                panel.add(Box.createGlue());
059:                panel.add(Box.createGlue());
060:                ok = new JButton(jEdit.getProperty("common.ok"));
061:                ok.addActionListener(this );
062:                getRootPane().setDefaultButton(ok);
063:                panel.add(ok);
064:                panel.add(Box.createHorizontalStrut(6));
065:                cancel = new JButton(jEdit.getProperty("common.cancel"));
066:                cancel.addActionListener(this );
067:                panel.add(cancel);
068:                panel.add(Box.createGlue());
069:
070:                content.add(panel, BorderLayout.SOUTH);
071:
072:                GUIUtilities.requestFocus(this , startField);
073:
074:                pack();
075:                setLocationRelativeTo(view);
076:                setVisible(true);
077:            } //}}}
078:
079:            //{{{ ok() method
080:            public void ok() {
081:                int startLine;
082:                int endLine;
083:
084:                try {
085:                    startLine = Integer.parseInt(startField.getText()) - 1;
086:                    endLine = Integer.parseInt(endField.getText()) - 1;
087:                } catch (NumberFormatException nf) {
088:                    getToolkit().beep();
089:                    return;
090:                }
091:
092:                Buffer buffer = view.getBuffer();
093:
094:                if (startLine < 0 || endLine >= buffer.getLineCount()
095:                        || startLine > endLine) {
096:                    getToolkit().beep();
097:                    return;
098:                }
099:
100:                JEditTextArea textArea = view.getTextArea();
101:                Selection s = new Selection.Range(buffer
102:                        .getLineStartOffset(startLine), buffer
103:                        .getLineEndOffset(endLine) - 1);
104:                if (textArea.isMultipleSelectionEnabled())
105:                    textArea.addToSelection(s);
106:                else
107:                    textArea.setSelection(s);
108:                textArea
109:                        .moveCaretPosition(buffer.getLineEndOffset(endLine) - 1);
110:
111:                dispose();
112:            } //}}}
113:
114:            //{{{ cancel() method
115:            public void cancel() {
116:                dispose();
117:            } //}}}
118:
119:            //{{{ actionPerformed() method
120:            public void actionPerformed(ActionEvent evt) {
121:                Object source = evt.getSource();
122:                if (source == ok)
123:                    ok();
124:                else if (source == cancel)
125:                    cancel();
126:            } //}}}
127:
128:            //{{{ Private members
129:
130:            //{{{ Instance variables
131:            private View view;
132:            private JTextField startField;
133:            private JTextField endField;
134:            private JButton ok;
135:            private JButton cancel;
136:
137:            //}}}
138:
139:            //{{{ createFieldPanel() method
140:            private JPanel createFieldPanel() {
141:                GridBagLayout layout = new GridBagLayout();
142:                JPanel panel = new JPanel(layout);
143:
144:                GridBagConstraints cons = new GridBagConstraints();
145:                cons.insets = new Insets(0, 0, 6, 12);
146:                cons.gridwidth = cons.gridheight = 1;
147:                cons.gridx = cons.gridy = 0;
148:                cons.fill = GridBagConstraints.BOTH;
149:                JLabel label = new JLabel(jEdit
150:                        .getProperty("selectlinerange.start"),
151:                        SwingConstants.RIGHT);
152:                layout.setConstraints(label, cons);
153:                panel.add(label);
154:
155:                startField = new JTextField(10);
156:                cons.gridx = 1;
157:                cons.weightx = 1.0f;
158:                layout.setConstraints(startField, cons);
159:                panel.add(startField);
160:
161:                label = new JLabel(jEdit.getProperty("selectlinerange.end"),
162:                        SwingConstants.RIGHT);
163:                cons.gridx = 0;
164:                cons.weightx = 0.0f;
165:                cons.gridy = 1;
166:                layout.setConstraints(label, cons);
167:                panel.add(label);
168:
169:                endField = new JTextField(10);
170:                cons.gridx = 1;
171:                cons.weightx = 1.0f;
172:                layout.setConstraints(endField, cons);
173:                panel.add(endField);
174:
175:                return panel;
176:            } //}}}
177:
178:            //}}}
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.