Source Code Cross Referenced for WebMode.java in  » IDE » J » org » armedbear » j » 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
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » J » org.armedbear.j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * WebMode.java
003:         *
004:         * Copyright (C) 1998-2002 Peter Graves
005:         * $Id: WebMode.java,v 1.3 2003/01/18 17:46:52 piso Exp $
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program 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
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; 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.armedbear.j;
023:
024:        import java.awt.event.KeyEvent;
025:        import java.util.StringTokenizer;
026:
027:        public final class WebMode extends AbstractMode implements  Constants,
028:                Mode {
029:            private static final WebMode mode = new WebMode();
030:
031:            private WebMode() {
032:                super (WEB_MODE, WEB_MODE_NAME);
033:                setProperty(Property.VERTICAL_RULE, 0);
034:                setProperty(Property.SHOW_LINE_NUMBERS, false);
035:                setProperty(Property.HIGHLIGHT_MATCHING_BRACKET, false);
036:                setProperty(Property.HIGHLIGHT_BRACKETS, false);
037:                setProperty(Property.P4_AUTO_EDIT, false);
038:            }
039:
040:            public static final WebMode getMode() {
041:                return mode;
042:            }
043:
044:            protected void setKeyMapDefaults(KeyMap km) {
045:                km.mapKey(VK_MOUSE_1, 0, "mouseFollowLink");
046:                km.mapKey(KeyEvent.VK_ENTER, 0, "followLink");
047:                km.mapKey(KeyEvent.VK_G, CTRL_MASK | SHIFT_MASK, "followLink");
048:                km.mapKey('s', "viewSource");
049:                km.mapKey(KeyEvent.VK_BACK_SPACE, 0, "webBack");
050:                km.mapKey(KeyEvent.VK_B, 0, "webBack");
051:                km.mapKey(KeyEvent.VK_F, 0, "webForward");
052:                km.mapKey(KeyEvent.VK_R, 0, "webReload");
053:            }
054:
055:            public void populateMenu(Editor editor, Menu menu) {
056:                final String text = menu.getText();
057:                if (text == "File") {
058:                    menu.add(editor, "New", 'N', "newBuffer");
059:                    menu.add(editor, "Open...", 'O', "openFile");
060:                    menu.add(editor, "Recent Files...", 'R', "recentFiles");
061:                    menu.addSeparator();
062:                    menu.add(editor, "Save As...", 'E', "saveAs");
063:                    menu.add(editor, "Save a Copy...", 'Y', "saveCopy");
064:                    menu.add(editor, "Save All", 'A', "saveAll");
065:                    menu.add(editor, "Close", 'C', "killBuffer");
066:                    menu.add(editor, "Close All", 'L', "closeAll");
067:                    menu.add(editor, "Close Others", 'H', "closeOthers");
068:                    menu.addSeparator();
069:                    menu.add(editor, "Properties", 'I', "properties");
070:                    menu.addSeparator();
071:                    menu.add(editor, "Next Buffer", 'T', "nextBuffer");
072:                    menu.add(editor, "Previous Buffer", 'R', "prevBuffer");
073:                    menu.addSeparator();
074:                    menu.add(editor, "New Frame", 'M', "newFrame");
075:                    menu.add(editor, "Execute Command...", 'D',
076:                            "executeCommand");
077:                    menu.addSeparator();
078:                    menu.add(editor, "Print...", 'P', "print");
079:                    menu.addSeparator();
080:                    menu.add(editor, "Save All/Exit", '/', "saveAllExit");
081:                    menu.add(editor, "Exit", 'X', "quit");
082:                } else if (text == "Edit") {
083:                    menu.add(editor, "Copy", 'C', "copyRegion");
084:                    menu.add(editor, "Copy Append", 'D', "copyAppend");
085:                } else if (text == "Search") {
086:                    menu.add(editor, "Find...", 'F', "find");
087:                    menu.add(editor, "Find Next", 'T', "findNext");
088:                    menu.add(editor, "Find Previous", 'R', "findPrev");
089:                } else if (text == "Go") {
090:                    menu.add(editor, "Go Back", 'B', "webBack");
091:                    menu.add(editor, "Go Forward", 'F', "webForward");
092:                    menu.addSeparator();
093:                    menu.add(editor, "Go To Next Occurrence of Word", 'T',
094:                            "findNextWord");
095:                    menu.add(editor, "Go To Previous Occurrence of Word", 'R',
096:                            "findPrevWord");
097:                } else
098:                    super .populateMenu(editor, menu);
099:            }
100:
101:            public final Formatter getFormatter(Buffer buffer) {
102:                return new WebFormatter(buffer);
103:            }
104:
105:            protected ToolBar getDefaultToolBar(Frame frame) {
106:                return new WebModeToolBar(frame);
107:            }
108:
109:            public final String getContextString(Editor editor, boolean verbose /*ignored*/) {
110:                return getContextString(editor.getDot());
111:            }
112:
113:            public final String getMouseMovedContextString(Editor editor,
114:                    Position pos) {
115:                // We want to clear the status text if the mouse is not over a link, so
116:                // return "" instead of null.
117:                final String s = getContextString(pos);
118:                return s != null ? s : "";
119:            }
120:
121:            private String getContextString(Position pos) {
122:                if (pos != null && pos.getLine() instanceof  WebLine) {
123:                    HtmlLineSegment segment = ((WebLine) pos.getLine())
124:                            .findSegment(pos.getOffset());
125:                    if (segment != null) {
126:                        Link link = segment.getLink();
127:                        if (link != null)
128:                            return link.getTarget();
129:                    }
130:                }
131:                return null;
132:            }
133:
134:            public static void google() {
135:                final Editor editor = Editor.currentEditor();
136:                InputDialog d = new InputDialog(editor, "Search for:",
137:                        "Google Search", null);
138:                d.setHistory(new History("google.search"));
139:                editor.centerDialog(d);
140:                d.show();
141:                String s = d.getInput();
142:                if (s == null || s.length() == 0)
143:                    return;
144:                editor.repaintNow();
145:                google(s);
146:            }
147:
148:            public static void google(String s) {
149:                query("http://www.google.com/search?q=", s);
150:            }
151:
152:            public static void query(String prefix, String s) {
153:                s = s.trim();
154:                // Strip enclosing quotes if any.
155:                int length = s.length();
156:                if (length > 1
157:                        && ((s.charAt(0) == '"' && s.charAt(length - 1) == '"') || (s
158:                                .charAt(0) == '\'' && s.charAt(length - 1) == '\''))) {
159:                    s = s.substring(1, length - 1).trim();
160:                }
161:                FastStringBuffer sb = new FastStringBuffer(prefix);
162:                StringTokenizer st = new StringTokenizer(s);
163:                final int count = st.countTokens();
164:                for (int i = 0; i < count; i++) {
165:                    if (i != 0)
166:                        sb.append('+');
167:                    sb.append(st.nextToken());
168:                }
169:                HttpFile file = HttpFile.getHttpFile(sb.toString());
170:                if (file != null) {
171:                    Buffer buf = null;
172:                    // Look for existing buffer.
173:                    for (BufferIterator it = new BufferIterator(); it.hasNext();) {
174:                        Buffer b = it.nextBuffer();
175:                        if (b instanceof  WebBuffer && b.getFile().equals(file)) {
176:                            buf = b;
177:                            break;
178:                        }
179:                    }
180:                    if (buf == null)
181:                        buf = WebBuffer.createWebBuffer(file, null, null);
182:                    if (buf != null) {
183:                        final Editor editor = Editor.currentEditor();
184:                        editor.makeNext(buf);
185:                        editor.activate(buf);
186:                    }
187:                }
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.