Source Code Cross Referenced for BookmarksManagementDialog.java in  » IDE » tIDE » tide » editor » bookmarks » 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 » tIDE » tide.editor.bookmarks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package tide.editor.bookmarks;
002:
003:        import tide.sources.FileItem;
004:        import snow.utils.DateUtils;
005:        import tide.editor.linemessages.LineMessagesManager;
006:        import tide.editor.MainEditorFrame;
007:        import tide.project.*;
008:        import snow.sortabletable.*;
009:        import snow.utils.gui.*;
010:
011:        import javax.swing.*;
012:        import java.awt.BorderLayout;
013:        import java.awt.event.*;
014:        import javax.swing.border.*;
015:        import java.util.*;
016:        import java.io.*;
017:        import java.util.concurrent.*;
018:
019:        /** Not modal... but not updated ...
020:         * TODO: show/remove bookmarks that are no more valid
021:         */
022:        public class BookmarksManagementDialog extends JDialog {
023:            private final BookmarksTM tm = new BookmarksTM();
024:            private final SortableTableModel stm = new SortableTableModel(tm,
025:                    4, false); // so: first seen is the newest
026:            private final JTable table = new JTable(stm);
027:
028:            public BookmarksManagementDialog(String filterForBookmarkManagement) {
029:                super (MainEditorFrame.instance, "Bookmarks management", false);
030:                this .setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
031:
032:                add(new JScrollPane(table), BorderLayout.CENTER);
033:                stm.installGUI(table);
034:
035:                table.addMouseListener(new MouseAdapter() {
036:                    @Override
037:                    public void mousePressed(MouseEvent me) {
038:                        if (me.isPopupTrigger())
039:                            showPopup(me);
040:                        else if (me.getClickCount() == 2
041:                                && table.getSelectedRowCount() == 1) {
042:                            int ind = stm.getIndexInUnsortedFromTablePos(table
043:                                    .getSelectedRow());
044:                            SourceBookmark fbm = tm.getBookmarkAt(ind);
045:                            final FileItem sff = MainEditorFrame.instance
046:                                    .getFileItem(fbm.getJavaName(), "");
047:                            sff
048:                                    .setCaretPositionToRemember(fbm
049:                                            .getLinePosition(), fbm
050:                                            .getColumnPosition());
051:                            MainEditorFrame.instance
052:                                    .setSourceOrItemToEditOrView(sff, true);
053:                        }
054:                    }
055:
056:                    @Override
057:                    public void mouseReleased(MouseEvent me) {
058:                        if (me.isPopupTrigger())
059:                            showPopup(me);
060:                    }
061:
062:                    private void showPopup(MouseEvent me) {
063:                        JPopupMenu popup = new JPopupMenu();
064:                        JMenuItem remove = new JMenuItem("Remove",
065:                                Icons.sharedCross);
066:                        popup.add(remove);
067:                        remove.addActionListener(new ActionListener() {
068:                            public void actionPerformed(ActionEvent ae) {
069:                                Vector<Integer> rem = new Vector<Integer>();
070:                                for (int sel : table.getSelectedRows()) {
071:                                    int ind = stm
072:                                            .getIndexInUnsortedFromTablePos(sel);
073:                                    if (ind >= 0) {
074:                                        rem.add(ind);
075:                                    }
076:                                }
077:                                tm.remove(rem);
078:                            }
079:                        });
080:                        /*
081:                         JMenuItem up = new JMenuItem("Move up");
082:                         //popup.add(up);
083:                         // TODO:
084:                         up.addActionListener(new ActionListener()
085:                         {
086:                         public void actionPerformed(ActionEvent ae)
087:                         {
088:                         }
089:                         });
090:                         */
091:
092:                        popup.show(table, me.getX(), me.getY());
093:                    }
094:
095:                });
096:
097:                AdvancedSearchPanel asp = new AdvancedSearchPanel("", null,
098:                        stm, false);
099:                add(asp, BorderLayout.NORTH);
100:                asp.setSearchText(filterForBookmarkManagement, "");
101:
102:                // Todo: move up & down buttons
103:
104:                add(new CloseControlPanel(this , false, true, "close"),
105:                        BorderLayout.SOUTH);
106:
107:                ((JComponent) getContentPane()).registerKeyboardAction(
108:                        new ActionListener() {
109:                            public void actionPerformed(ActionEvent ae) {
110:                                setVisible(false);
111:                                return;
112:                            }
113:                        }, "Escape", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,
114:                                0, true),
115:                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
116:
117:                pack();
118:                this .setLocationRelativeTo(MainEditorFrame.instance);
119:                setVisible(true);
120:            } // Constructor
121:
122:            class BookmarksTM extends FineGrainTableModel {
123:                // Directly the project reference !! not cached !! be careful
124:                final List<SourceBookmark> bookmarks;
125:
126:                public BookmarksTM() {
127:                    bookmarks = MainEditorFrame.instance.getActualProject()
128:                            .getAllBookmarks_REF();
129:                }
130:
131:                @Override
132:                public String getColumnName(int col) {
133:                    if (col == 0)
134:                        return "Bookmark";
135:                    if (col == 1)
136:                        return "Remark";
137:                    if (col == 2)
138:                        return "Line";
139:                    if (col == 3)
140:                        return "Column";
141:                    if (col == 4)
142:                        return "Age";
143:                    return "?";
144:                }
145:
146:                public int getColumnCount() {
147:                    return 5;
148:                } // do not show the columns
149:
150:                public int getRowCount() {
151:                    return bookmarks.size();
152:                }
153:
154:                public SourceBookmark getBookmarkAt(int row) {
155:                    return bookmarks.get(row);
156:                }
157:
158:                public Object getValueAt(int row, int col) {
159:                    // must be protected because the dialog is not modal and bookmarks may be removed during show.
160:                    if (row < 0 || row >= bookmarks.size())
161:                        return "removed";
162:                    SourceBookmark bm = bookmarks.get(row);
163:                    if (col == 0)
164:                        return bm.getJavaName();
165:                    if (col == 1)
166:                        return bm.getRemark();
167:                    if (col == 2)
168:                        return bm.getLinePosition();
169:                    if (col == 3)
170:                        return bm.getColumnPosition();
171:                    if (col == 4)
172:                        return DateUtils.formatTimeDifference(System
173:                                .currentTimeMillis()
174:                                - bm.getCreated());
175:                    return "?";
176:
177:                }
178:
179:                @Override
180:                public int compareForColumnSort(int pos1, int pos2, int col) {
181:                    if (pos1 < 0 || pos1 >= bookmarks.size())
182:                        return 0;
183:                    if (pos2 < 0 || pos2 >= bookmarks.size())
184:                        return 0;
185:
186:                    if (col == 4) {
187:
188:                        SourceBookmark m1 = bookmarks.get(pos1);
189:                        SourceBookmark m2 = bookmarks.get(pos2);
190:                        return Long.valueOf(m1.getCreated()).compareTo(
191:                                m2.getCreated());
192:                    } else {
193:                        return super .compareForColumnSort(pos1, pos2, col);
194:                    }
195:                }
196:
197:                @Override
198:                public int getPreferredColumnWidth(int column) {
199:                    if (column == 0)
200:                        return 10;
201:                    if (column == 1)
202:                        return 10;
203:                    return 4;
204:                }
205:
206:                @Override
207:                public void setValueAt(Object o, int row, int col) {
208:                    if (row < 0 || row >= bookmarks.size())
209:                        return; // just ignore.
210:
211:                    SourceBookmark bm = bookmarks.get(row);
212:                    if (col == 1)
213:                        bm.setRemark("" + o);
214:
215:                    if (col == 2) {
216:                        try {
217:                            bm.setLinePosition(Integer.parseInt("" + o));
218:                        } catch (Exception e) {
219:                            e.printStackTrace();
220:                        }
221:                    }
222:
223:                    LineMessagesManager.getInstance().refreshView();
224:                }
225:
226:                @Override
227:                public boolean isCellEditable(int row, int col) {
228:                    return col == 1 || col == 2;
229:                }
230:
231:                public void remove(List<Integer> ind) {
232:                    this .fireTableModelWillChange();
233:                    Collections.sort(ind); // increasing {0,1,2,...}
234:                    for (int i = ind.size() - 1; i >= 0; i--) // start with the greatest index !!
235:                    {
236:                        bookmarks.remove((int) ind.get(i)); // #### (int) is important here !!!
237:                        LineMessagesManager.getInstance().refreshView();
238:                    }
239:                    this.fireTableDataChanged();
240:                    this.fireTableModelHasChanged();
241:                }
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.