Source Code Cross Referenced for Sidebar.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
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 » J » org.armedbear.j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Sidebar.java
003:         *
004:         * Copyright (C) 2000-2003 Peter Graves
005:         * $Id: Sidebar.java,v 1.4 2003/08/07 17:34:07 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.Color;
025:        import javax.swing.BorderFactory;
026:        import javax.swing.BoxLayout;
027:        import javax.swing.JComponent;
028:        import javax.swing.JScrollPane;
029:        import javax.swing.SwingUtilities;
030:
031:        public final class Sidebar extends JComponent implements  Constants {
032:            private final Frame frame;
033:            private final SplitPane splitPane;
034:            private final SidebarPanel topPanel;
035:            private final SidebarPanel bottomPanel;
036:            private final SidebarBufferTree bufferTree;
037:
038:            private NavigationComponent bottomComponent;
039:            private int updateFlag;
040:
041:            public Sidebar(Frame frame) {
042:                this .frame = frame;
043:                setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
044:                topPanel = new SidebarPanel(this );
045:                bufferTree = new SidebarBufferTree(this );
046:                JScrollPane bufferListScrollPane = new JScrollPane(bufferTree);
047:                bufferListScrollPane.setAlignmentX(LEFT_ALIGNMENT);
048:                bufferListScrollPane
049:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
050:                bufferListScrollPane.setBorder(BorderFactory
051:                        .createEmptyBorder());
052:                topPanel.addScrollPane(bufferListScrollPane);
053:                bottomPanel = new SidebarPanel(this );
054:                splitPane = new SplitPane(SplitPane.VERTICAL_SPLIT, topPanel,
055:                        bottomPanel);
056:                splitPane.setBorder(BorderFactory.createEmptyBorder());
057:                splitPane.setDividerLocation(Editor.getSessionProperties()
058:                        .getSidebarDividerLocation(frame));
059:                add(splitPane);
060:            }
061:
062:            public final Frame getFrame() {
063:                return frame;
064:            }
065:
066:            public final Editor getEditor() {
067:                return frame.getCurrentEditor();
068:            }
069:
070:            public final SidebarBufferTree getBufferList() {
071:                return bufferTree;
072:            }
073:
074:            public final SidebarBufferTree getBufferTree() {
075:                return bufferTree;
076:            }
077:
078:            public NavigationComponent getBottomComponent() {
079:                return bottomComponent;
080:            }
081:
082:            public void activateBufferList() {
083:                if (bufferTree != null)
084:                    frame.setFocus(bufferTree);
085:            }
086:
087:            public void activateNavigationComponent() {
088:                if (bottomComponent != null)
089:                    frame.setFocus((JComponent) bottomComponent);
090:            }
091:
092:            public int getDividerLocation() {
093:                if (splitPane == null)
094:                    return -1;
095:
096:                return splitPane.getDividerLocation();
097:            }
098:
099:            public final void setBufferListLabelText(String s) {
100:                topPanel.setLabelText(s);
101:            }
102:
103:            public static void repaintBufferListInAllFrames() {
104:                for (int i = 0; i < Editor.getFrameCount(); i++) {
105:                    Frame frame = Editor.getFrame(i);
106:                    if (frame != null) {
107:                        Sidebar sidebar = frame.getSidebar();
108:                        if (sidebar != null)
109:                            sidebar.getBufferList().repaint();
110:                    }
111:                }
112:            }
113:
114:            public void setBuffer() {
115:                if (bufferTree != null) {
116:                    Buffer buffer = frame.getCurrentEditor().getBuffer();
117:                    if (buffer != bufferTree.getSelectedBuffer())
118:                        bufferTree.setSelectedBuffer(buffer);
119:                }
120:            }
121:
122:            public void updatePosition() {
123:                if (bottomComponent != null)
124:                    bottomComponent.updatePosition();
125:            }
126:
127:            public static final boolean isTaggable(Buffer buffer) {
128:                Mode mode = buffer.getMode();
129:                return mode != null && mode.isTaggable();
130:            }
131:
132:            public synchronized final void setUpdateFlag(int mask) {
133:                updateFlag |= mask;
134:                if (bufferTree != null)
135:                    bufferTree.setUpdateFlag(updateFlag
136:                            & SIDEBAR_BUFFER_LIST_ALL);
137:            }
138:
139:            public static void setUpdateFlagInAllFrames(int mask) {
140:                for (int i = 0; i < Editor.getFrameCount(); i++) {
141:                    Frame frame = Editor.getFrame(i);
142:                    Sidebar sidebar = frame.getSidebar();
143:                    if (sidebar != null)
144:                        sidebar.setUpdateFlag(mask);
145:                }
146:            }
147:
148:            private void setBottomComponent() {
149:                if (!SwingUtilities.isEventDispatchThread())
150:                    Debug
151:                            .bug("Sidebar.setBottomComponent() called from background thread!");
152:                if (bottomComponent != null) {
153:                    Editor editor = frame.getCurrentEditor();
154:                    Buffer buffer = editor.getBuffer();
155:                    if (frame.getEditorCount() == 2 && buffer.isTransient()) {
156:                        editor = frame.getOtherEditor();
157:                        buffer = editor.getBuffer();
158:                    }
159:                    if (isTaggable(buffer)
160:                            && bottomComponent instanceof  SidebarTagList) {
161:                        SidebarTagList list = (SidebarTagList) bottomComponent;
162:                        list.setEditor(editor);
163:                        if (list.getBuffer() == buffer)
164:                            return;
165:                    } else {
166:                        View view = editor.getCurrentView();
167:                        if (view != null
168:                                && bottomComponent == view
169:                                        .getSidebarComponent())
170:                            return;
171:                    }
172:                    // Reaching here, we need to remove the old bottom component.
173:                    bottomComponent = null;
174:                    bottomPanel.removeAll();
175:                }
176:                Debug.assertTrue(bottomComponent == null);
177:                final Editor editor = getEditor();
178:                bottomComponent = editor.getMode().getSidebarComponent(editor);
179:                if (bottomComponent != null) {
180:                    JScrollPane scrollPane = new JScrollPane(
181:                            (JComponent) bottomComponent);
182:                    if (bottomComponent instanceof  SidebarList)
183:                        scrollPane
184:                                .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
185:                    scrollPane.setAlignmentX(LEFT_ALIGNMENT);
186:                    scrollPane.setBorder(BorderFactory.createEmptyBorder());
187:                    bottomPanel.addScrollPane(scrollPane);
188:                    bottomPanel.validate();
189:                } else
190:                    bottomPanel.repaint();
191:            }
192:
193:            public synchronized void refreshSidebar() {
194:                if (updateFlag != 0) {
195:                    if ((updateFlag & SIDEBAR_BUFFER_LIST_ALL) != 0) {
196:                        SidebarBufferTree bufferTree = getBufferTree();
197:                        if (bufferTree != null
198:                                && bufferTree != frame.getFocusedComponent())
199:                            bufferTree.updateBufferList();
200:                    }
201:                    if (bottomComponent == null
202:                            || bottomComponent != frame.getFocusedComponent()) {
203:                        setBottomComponent();
204:                        if (bottomComponent != null) {
205:                            bottomPanel.setLabelText(bottomComponent
206:                                    .getLabelText());
207:                            // This might start a thread.
208:                            bottomComponent.refresh();
209:                            if ((updateFlag & SIDEBAR_POSITION) != 0)
210:                                bottomComponent.updatePosition();
211:                        }
212:                    }
213:                    updateFlag = 0;
214:                }
215:            }
216:
217:            public static void refreshSidebarInAllFrames() {
218:                if (!SwingUtilities.isEventDispatchThread())
219:                    Debug
220:                            .bug("refreshSidebarInAllFrames() called from background thread!");
221:                for (int i = 0; i < Editor.getFrameCount(); i++) {
222:                    Frame frame = Editor.getFrame(i);
223:                    Sidebar sidebar = frame.getSidebar();
224:                    if (sidebar != null)
225:                        sidebar.refreshSidebar();
226:                }
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.