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


001:        /*
002:         * MouseHandler.java - jEdit's text component
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 1999, 2005 Slava Pestov
007:         * Portions copyright (C) 2000 Ollie Rutherfurd
008:         *
009:         * This program is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; either version 2
012:         * of the License, or any later version.
013:         *
014:         * This program is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         * GNU General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU General Public License
020:         * along with this program; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
022:         */
023:
024:        package org.gjt.sp.jedit.textarea;
025:
026:        //{{{ Imports
027:        import java.awt.event.*;
028:
029:        import org.gjt.sp.jedit.Registers;
030:        import org.gjt.sp.jedit.OperatingSystem;
031:
032:        //}}}
033:
034:        /**
035:         * The mouseHandler used for jEdit.
036:         */
037:        public class MouseHandler extends TextAreaMouseHandler {
038:            //{{{ MouseHandler constructor
039:            public MouseHandler(JEditTextArea textArea) {
040:                super (textArea);
041:                this .textArea = textArea;
042:            } //}}}
043:
044:            //{{{ mousePressed() method
045:            public void mousePressed(MouseEvent evt) {
046:                showCursor();
047:
048:                control = (OperatingSystem.isMacOS() && evt.isMetaDown())
049:                        || (!OperatingSystem.isMacOS() && evt.isControlDown());
050:
051:                ctrlForRectangularSelection = textArea
052:                        .isCtrlForRectangularSelection();
053:
054:                // so that Home <mouse click> Home is not the same
055:                // as pressing Home twice in a row
056:                textArea.getInputHandler().resetLastActionCount();
057:
058:                quickCopyDrag = (textArea.isQuickCopyEnabled() && isMiddleButton(evt
059:                        .getModifiers()));
060:
061:                if (!quickCopyDrag) {
062:                    textArea.requestFocus();
063:                    TextArea.focusedComponent = textArea;
064:                }
065:
066:                if (textArea.getBuffer().isLoading())
067:                    return;
068:
069:                int x = evt.getX();
070:                int y = evt.getY();
071:
072:                dragStart = textArea
073:                        .xyToOffset(x, y, !(textArea.getPainter()
074:                                .isBlockCaretEnabled() || textArea
075:                                .isOverwriteEnabled()));
076:                dragStartLine = textArea.getLineOfOffset(dragStart);
077:                dragStartOffset = dragStart
078:                        - textArea.getLineStartOffset(dragStartLine);
079:
080:                if (isPopupTrigger(evt)
081:                        && textArea.getRightClickPopup() != null) {
082:                    if (textArea.isRightClickPopupEnabled())
083:                        textArea.handlePopupTrigger(evt);
084:                    return;
085:                }
086:
087:                dragged = false;
088:
089:                textArea.blink = true;
090:                textArea.invalidateLine(textArea.getCaretLine());
091:
092:                clickCount = evt.getClickCount();
093:
094:                if (textArea.isDragEnabled()
095:                        && textArea.selectionManager.insideSelection(x, y)
096:                        && clickCount == 1 && !evt.isShiftDown()) {
097:                    maybeDragAndDrop = true;
098:                    textArea.moveCaretPosition(dragStart, false);
099:                    return;
100:                }
101:
102:                maybeDragAndDrop = false;
103:
104:                if (quickCopyDrag) {
105:                    // ignore double clicks of middle button
106:                    doSingleClick(evt);
107:                } else {
108:                    switch (clickCount) {
109:                    case 1:
110:                        doSingleClick(evt);
111:                        break;
112:                    case 2:
113:                        doDoubleClick();
114:                        break;
115:                    default: //case 3:
116:                        doTripleClick();
117:                        break;
118:                    }
119:                }
120:            } //}}}
121:
122:            //{{{ mouseReleased() method
123:            public void mouseReleased(MouseEvent evt) {
124:                // middle mouse button drag inserts selection
125:                // at caret position
126:                Selection sel = textArea.getSelectionAtOffset(dragStart);
127:                if (dragged && sel != null) {
128:                    Registers.setRegister('%', textArea.getSelectedText(sel));
129:                    if (quickCopyDrag) {
130:                        textArea.removeFromSelection(sel);
131:                        Registers.paste(TextArea.focusedComponent, '%',
132:                                sel instanceof  Selection.Rect);
133:
134:                        TextArea.focusedComponent.requestFocus();
135:                    }
136:                } else if (!dragged && textArea.isQuickCopyEnabled()
137:                        && isMiddleButton(evt.getModifiers())) {
138:                    textArea.requestFocus();
139:                    TextArea.focusedComponent = textArea;
140:
141:                    textArea.setCaretPosition(dragStart, false);
142:                    if (!textArea.isEditable())
143:                        textArea.getToolkit().beep();
144:                    else
145:                        Registers.paste(textArea, '%', control);
146:                } else if (maybeDragAndDrop
147:                        && !textArea.isMultipleSelectionEnabled()) {
148:                    textArea.selectNone();
149:                }
150:
151:                dragged = false;
152:            } //}}}
153:
154:            //{{{ Private members
155:            private JEditTextArea textArea;
156:            //}}}
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.