Source Code Cross Referenced for SAPopup.java in  » IDE » Schmortopf » Schmortopf » JavaSourceEditor » SituationalAwareness » 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 » IDE » Schmortopf » Schmortopf.JavaSourceEditor.SituationalAwareness 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package Schmortopf.JavaSourceEditor.SituationalAwareness;
002:
003:        /**                                                        
004:         *  The situational awareness popup  
005:         */
006:
007:        import java.awt.*;
008:        import java.awt.event.*;
009:        import javax.swing.*;
010:
011:        import Schmortopf.Utility.gui.JSmartPopupMenu;
012:        import Schmortopf.Main.IDE_ProjectFrame;
013:        import Schmortopf.ProjectFiles.ProjectFilesTree.ProjectFilesTree;
014:        import Schmortopf.FileStructure.Descriptions.*;
015:        import Schmortopf.JavaSourceEditor.*;
016:        import Schmortopf.Utility.gui.*;
017:        import Schmortopf.Utility.ThreadEngine.ThreadEngine;
018:        import Language.Language;
019:        import Shared.Logging.Log;
020:
021:        public class SAPopup extends JSmartPopupMenu {
022:
023:            private IDE_ProjectFrame projectFrame;
024:            private SituationalAwarenessManager situationalAwarenessManager;
025:            private int xMouseCoord;
026:            private int yMouseCoord;
027:            private JPanel methodInfoPanel;
028:            private int editorLineIndex;
029:            private SASearchResult searchResult;
030:            private SourceEditorDocument sourceDocument;
031:            private EditorPanel editorPanel;
032:
033:            public SAPopup(
034:                    final IDE_ProjectFrame theProjectFrame,
035:                    final SituationalAwarenessManager theSituationalAwarenessManager,
036:                    final int thexMouseCoord, final int theyMouseCoord,
037:                    final JPanel theMethodInfoPanel,
038:                    final int theEditorLineIndex,
039:                    final SASearchResult theSearchResult,
040:                    final SourceEditorDocument theSourceDocument,
041:                    final EditorPanel theEditorPanel) {
042:                this .projectFrame = theProjectFrame;
043:                this .situationalAwarenessManager = theSituationalAwarenessManager;
044:                this .xMouseCoord = thexMouseCoord;
045:                this .yMouseCoord = theyMouseCoord;
046:                this .methodInfoPanel = theMethodInfoPanel;
047:                this .editorLineIndex = theEditorLineIndex;
048:                this .searchResult = theSearchResult;
049:                this .sourceDocument = theSourceDocument;
050:                this .editorPanel = theEditorPanel;
051:            } // Constructor
052:
053:            public void showPopup() {
054:                int offset = UIManager.getFont("Menu.font").getSize();
055:                int xp = xMouseCoord + offset / 8;
056:                int yp = yMouseCoord - offset;
057:                this .setLocation(xp, yp); // prevents a flicker in the screen origin
058:                // methodInfoPanel can be null, in which case only the
059:                // selection of existing bookmarks is displayed.
060:                if (methodInfoPanel != null) {
061:                    TitlePanel titlePanel = new TitlePanel(methodInfoPanel);
062:                    this .add(titlePanel);
063:                    JCreateBookmarkEntry createBookMarkItem = new JCreateBookmarkEntry(
064:                            Language.Translate("Create a bookmark here"),
065:                            projectFrame);
066:                    createBookMarkItem.addActionListener(new ActionListener() {
067:                        public void actionPerformed(ActionEvent e) {
068:                            createNewBookMark(sourceDocument, editorLineIndex,
069:                                    searchResult);
070:                            // Close this popup:     
071:                            setVisible(false);
072:                        }
073:                    });
074:                    this .add(createBookMarkItem);
075:                }
076:                // Remove bookmarks, which do not exist (= point to a method, which doesn't exist) :
077:                this .situationalAwarenessManager.removeNonExistentBookmarks();
078:                // Get the existing ones:
079:                BookMark[] bookmarks = this .situationalAwarenessManager
080:                        .getBookMarks();
081:                if (bookmarks.length == 0) {
082:                    TitlePanel bookmarkTitlePanel = new TitlePanel(" "
083:                            + Language.Translate("Bookmarks"));
084:                    this .add(bookmarkTitlePanel);
085:                } else {
086:                    TitlePanel bookmarkTitlePanel = new TitlePanel(Language
087:                            .Translate("Jump to bookmark in"));
088:                    this .add(bookmarkTitlePanel);
089:                }
090:                if (bookmarks.length == 0) {
091:                    JMenuItem noBookMarkItem1 = new JMenuItem(Language
092:                            .Translate("No bookmarks created by you."));
093:                    noBookMarkItem1.setEnabled(false);
094:                    this .add(noBookMarkItem1);
095:                    if (methodInfoPanel == null) {
096:                        JMenuItem noBookMarkItem2 = new JMenuItem(
097:                                Language
098:                                        .Translate("Click red,green or blue regions for creating new ones."));
099:                        noBookMarkItem2.setEnabled(false);
100:                        this .add(noBookMarkItem2);
101:                    }
102:                } else {
103:                    JBookmarkMenuEntry bookmarkMenuEntry;
104:                    for (int i = 0; i < bookmarks.length; i++) {
105:                        final int bookmarkIndex = i;
106:                        final BookMark this BookMark = bookmarks[i];
107:                        bookmarkMenuEntry = new JBookmarkMenuEntry(this BookMark
108:                                .getDescription(), projectFrame);
109:                        bookmarkMenuEntry
110:                                .setEntryButtonReaction(new ActionListener() {
111:                                    public void actionPerformed(ActionEvent e) {
112:                                        // Close this popup:     
113:                                        setVisible(false);
114:                                        EventQueue.invokeLater(new Runnable() {
115:                                            public void run() {
116:                                                // One must leave the EDT, otherwise some visual areas
117:                                                // might not be restaured properly:
118:                                                Thread jumpThread = new Thread() {
119:                                                    public void run() {
120:                                                        // Time for Swing - This is required, otherwise the
121:                                                        // popup space isn't restored properly sometimes.
122:                                                        try {
123:                                                            Thread.sleep(77);
124:                                                        } catch (Exception e) {
125:                                                        }
126:                                                        jumpToBookMark(this BookMark);
127:                                                    }
128:                                                };
129:                                                ThreadEngine
130:                                                        .getInstance()
131:                                                        .addRunnable(
132:                                                                jumpThread,
133:                                                                "SA Jump Thread");
134:                                            }
135:                                        });
136:                                    }
137:                                });
138:                        bookmarkMenuEntry
139:                                .setMoveUpButtonReaction(new ActionListener() {
140:                                    public void actionPerformed(ActionEvent e) {
141:                                        moveUpBookmarkEntry(bookmarkIndex);
142:                                    }
143:                                });
144:                        bookmarkMenuEntry
145:                                .setMoveDownButtonReaction(new ActionListener() {
146:                                    public void actionPerformed(ActionEvent e) {
147:                                        moveDownBookmarkEntry(bookmarkIndex);
148:                                    }
149:                                });
150:                        bookmarkMenuEntry
151:                                .setRenameButtonReaction(new ActionListener() {
152:                                    public void actionPerformed(ActionEvent e) {
153:                                        renameBookmarkEntry(bookmarkIndex);
154:                                    }
155:                                });
156:                        this .add(bookmarkMenuEntry);
157:                        bookmarkMenuEntry
158:                                .setRemoveButtonReaction(new ActionListener() {
159:                                    public void actionPerformed(ActionEvent e) {
160:                                        removeBookmarkEntry(bookmarkIndex);
161:                                    }
162:                                });
163:                        this .add(bookmarkMenuEntry);
164:                    }
165:                }
166:                // coords in system of editorPanel.getEditor()
167:                this .show(editorPanel.getEditor(), xMouseCoord, yMouseCoord);
168:            } // showPopup
169:
170:            private void moveUpBookmarkEntry(final int bookmarkIndex) {
171:                this .situationalAwarenessManager
172:                        .moveUpBookmarkEntry(bookmarkIndex);
173:                this .setVisible(false);
174:                this .relaunch();
175:            }
176:
177:            private void moveDownBookmarkEntry(final int bookmarkIndex) {
178:                this .situationalAwarenessManager
179:                        .moveDownBookmarkEntry(bookmarkIndex);
180:                this .setVisible(false);
181:                this .relaunch();
182:            }
183:
184:            private void renameBookmarkEntry(final int bookmarkIndex) {
185:                this .situationalAwarenessManager
186:                        .renameBookmarkEntry(bookmarkIndex);
187:                this .relaunch();
188:            }
189:
190:            private void removeBookmarkEntry(final int bookmarkIndex) {
191:                this .situationalAwarenessManager
192:                        .removeBookmarkEntry(bookmarkIndex);
193:                this .setVisible(false);
194:                this .relaunch();
195:            }
196:
197:            private void relaunch() {
198:                SAPopup aNewOne = new SAPopup(this .projectFrame,
199:                        this .situationalAwarenessManager, this .xMouseCoord,
200:                        this .yMouseCoord, this .methodInfoPanel,
201:                        this .editorLineIndex, this .searchResult,
202:                        this .sourceDocument, this .editorPanel);
203:                aNewOne.showPopup();
204:            }
205:
206:            private final void createNewBookMark(
207:                    final SourceEditorDocument sourceDocument,
208:                    final int editorLineIndex, final SASearchResult searchResult) {
209:                situationalAwarenessManager.createNewBookMark(sourceDocument,
210:                        editorLineIndex, searchResult);
211:            } // createNewBookMark
212:
213:            private final void jumpToBookMark(final BookMark bookmark) {
214:                // Calculate the absolute line number in the editor:
215:                final int absoluteEditorLineIndex = this .situationalAwarenessManager
216:                        .getAbsoluteEditorLineNumberFor(bookmark);
217:                if (absoluteEditorLineIndex >= 0) {
218:                    final ProjectFilesTree projectFilesTree = projectFrame
219:                            .getProjectFilesManager().getProjectFilesTree();
220:                    EventQueue.invokeLater(new Runnable() {
221:                        public void run() {
222:                            projectFilesTree.showLeafFor(bookmark
223:                                    .getSourceFilePathName(),
224:                                    absoluteEditorLineIndex, 0, false);
225:                        }
226:                    });
227:                } // if
228:                else {
229:                    // This should not occure, unless the current source has syntax errors, and
230:                    // the associated fsd therefore isn't complete at this time.
231:                    if (absoluteEditorLineIndex != this .situationalAwarenessManager.FileStructureDescriptionHasSyntaxErrors) {
232:                        Log.Warn("No target for bookmark "
233:                                + bookmark.getMethodSignature()
234:                                + " in correct sourcefile.");
235:                    }
236:                }
237:            } // jumpToBookMark
238:
239:        } // SAPopup
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.