Source Code Cross Referenced for WindowTab.java in  » Swing-Library » InfoNode-Docking-Windows » net » infonode » docking » 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 » InfoNode Docking Windows » net.infonode.docking 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 NNL Technology AB
003:         * Visit www.infonode.net for information about InfoNode(R) 
004:         * products and how to contact NNL Technology AB.
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
019:         * MA 02111-1307, USA.
020:         */
021:
022:        // $Id: WindowTab.java,v 1.57 2007/01/28 21:25:10 jesper Exp $
023:        package net.infonode.docking;
024:
025:        import net.infonode.docking.internalutil.*;
026:        import net.infonode.docking.properties.WindowTabProperties;
027:        import net.infonode.docking.properties.WindowTabStateProperties;
028:        import net.infonode.gui.ContainerList;
029:        import net.infonode.gui.panel.DirectionPanel;
030:        import net.infonode.gui.panel.SimplePanel;
031:        import net.infonode.properties.propertymap.PropertyMap;
032:        import net.infonode.properties.propertymap.PropertyMapListener;
033:        import net.infonode.properties.propertymap.PropertyMapTreeListener;
034:        import net.infonode.properties.propertymap.PropertyMapWeakListenerManager;
035:        import net.infonode.tabbedpanel.titledtab.TitledTab;
036:        import net.infonode.tabbedpanel.titledtab.TitledTabStateProperties;
037:        import net.infonode.util.Direction;
038:
039:        import javax.swing.*;
040:        import java.awt.*;
041:        import java.awt.event.MouseAdapter;
042:        import java.awt.event.MouseEvent;
043:        import java.util.Map;
044:
045:        /**
046:         * @author $Author: jesper $
047:         * @version $Revision: 1.57 $
048:         */
049:        class WindowTab extends TitledTab {
050:            private static final TitledTabStateProperties EMPTY_PROPERTIES = new TitledTabStateProperties();
051:            private static final WindowTabProperties EMPTY_TAB_PROPERTIES = new WindowTabProperties();
052:
053:            private static final ButtonInfo[] buttonInfos = {
054:                    new UndockButtonInfo(
055:                            WindowTabStateProperties.UNDOCK_BUTTON_PROPERTIES),
056:                    new DockButtonInfo(
057:                            WindowTabStateProperties.DOCK_BUTTON_PROPERTIES),
058:                    new MinimizeButtonInfo(
059:                            WindowTabStateProperties.MINIMIZE_BUTTON_PROPERTIES),
060:                    new RestoreButtonInfo(
061:                            WindowTabStateProperties.RESTORE_BUTTON_PROPERTIES),
062:                    new CloseButtonInfo(
063:                            WindowTabStateProperties.CLOSE_BUTTON_PROPERTIES) };
064:
065:            private final DockingWindow window;
066:            private AbstractButton[][] buttons = new AbstractButton[WindowTabState
067:                    .getStateCount()][];
068:            private DirectionPanel[] buttonBoxes = new DirectionPanel[WindowTabState
069:                    .getStateCount()];
070:            private DirectionPanel customComponents = new DirectionPanel();
071:            private DirectionPanel highlightedFocusedPanel = new DirectionPanel() {
072:                public Dimension getMinimumsize() {
073:                    return new Dimension(0, 0);
074:                }
075:            };
076:            private WindowTabProperties windowTabProperties = new WindowTabProperties(
077:                    EMPTY_TAB_PROPERTIES);
078:            private ContainerList tabComponentsList;
079:            private boolean isFocused;
080:
081:            private PropertyMapListener windowPropertiesListener = new PropertyMapListener() {
082:                public void propertyValuesChanged(PropertyMap propertyObject,
083:                        Map changes) {
084:                    updateTabButtons(null);
085:                }
086:            };
087:
088:            private PropertyMapTreeListener windowTabPropertiesListener = new PropertyMapTreeListener() {
089:                public void propertyValuesChanged(Map changes) {
090:                    updateTabButtons(changes);
091:                }
092:            };
093:
094:            WindowTab(DockingWindow window, boolean emptyContent) {
095:                super (window.getTitle(), window.getIcon(), emptyContent ? null
096:                        : new SimplePanel(window), null);
097:                this .window = window;
098:
099:                for (int i = 0; i < WindowTabState.getStateCount(); i++) {
100:                    buttonBoxes[i] = new DirectionPanel() {
101:                        public Dimension getMinimumSize() {
102:                            return new Dimension(0, 0);
103:                        }
104:                    };
105:                    buttons[i] = new AbstractButton[buttonInfos.length];
106:                }
107:
108:                highlightedFocusedPanel.add(customComponents);
109:                highlightedFocusedPanel
110:                        .add(buttonBoxes[WindowTabState.HIGHLIGHTED.getValue()]);
111:                setHighlightedStateTitleComponent(highlightedFocusedPanel);
112:                setNormalStateTitleComponent(buttonBoxes[WindowTabState.NORMAL
113:                        .getValue()]);
114:
115:                addMouseListener(new MouseAdapter() {
116:                    public void mousePressed(MouseEvent e) {
117:                        getWindow().fireTabWindowMouseButtonEvent(e);
118:                        checkPopupMenu(e);
119:                    }
120:
121:                    public void mouseClicked(MouseEvent e) {
122:                        getWindow().fireTabWindowMouseButtonEvent(e);
123:                    }
124:
125:                    public void mouseReleased(MouseEvent e) {
126:                        getWindow().fireTabWindowMouseButtonEvent(e);
127:                        checkPopupMenu(e);
128:                    }
129:
130:                    private void checkPopupMenu(MouseEvent e) {
131:                        if (e.isPopupTrigger() && contains(e.getPoint())) {
132:                            WindowTab.this .window.showPopupMenu(e);
133:                        }
134:                    }
135:
136:                });
137:
138:                getProperties().addSuperObject(
139:                        windowTabProperties.getTitledTabProperties());
140:
141:                PropertyMapWeakListenerManager.addWeakTreeListener(
142:                        windowTabProperties.getMap(),
143:                        windowTabPropertiesListener);
144:
145:                PropertyMapWeakListenerManager.addWeakListener(this .window
146:                        .getWindowProperties().getMap(),
147:                        windowPropertiesListener);
148:
149:                windowTabProperties.getTitledTabProperties()
150:                        .getHighlightedProperties().addSuperObject(
151:                                EMPTY_PROPERTIES);
152:            }
153:
154:            public void updateUI() {
155:                super .updateUI();
156:
157:                if (buttonBoxes != null)
158:                    for (int i = 0; i < WindowTabState.getStateCount(); i++)
159:                        if (buttonBoxes[i] != null)
160:                            SwingUtilities
161:                                    .updateComponentTreeUI(buttonBoxes[i]);
162:            }
163:
164:            void setFocused(boolean focused) {
165:                if (isFocused != focused) {
166:                    isFocused = focused;
167:                    TitledTabStateProperties properties = focused ? windowTabProperties
168:                            .getFocusedProperties()
169:                            : EMPTY_PROPERTIES;
170:                    windowTabProperties.getTitledTabProperties()
171:                            .getHighlightedProperties().getMap()
172:                            .replaceSuperMap(
173:                                    windowTabProperties
174:                                            .getTitledTabProperties()
175:                                            .getHighlightedProperties()
176:                                            .getMap().getSuperMap(),
177:                                    properties.getMap());
178:                    highlightedFocusedPanel.remove(1);
179:                    highlightedFocusedPanel
180:                            .add(buttonBoxes[focused ? WindowTabState.FOCUSED
181:                                    .getValue() : WindowTabState.HIGHLIGHTED
182:                                    .getValue()]);
183:                    highlightedFocusedPanel.revalidate();
184:                }
185:            }
186:
187:            void setProperties(WindowTabProperties properties) {
188:                windowTabProperties.getMap().replaceSuperMap(
189:                        windowTabProperties.getMap().getSuperMap(),
190:                        properties.getMap());
191:            }
192:
193:            void unsetProperties() {
194:                setProperties(EMPTY_TAB_PROPERTIES);
195:            }
196:
197:            void updateTabButtons(Map changes) {
198:                WindowTabState[] states = WindowTabState.getStates();
199:
200:                for (int i = 0; i < states.length; i++) {
201:                    WindowTabState state = states[i];
202:                    WindowTabStateProperties buttonProperties = state == WindowTabState.FOCUSED ? windowTabProperties
203:                            .getFocusedButtonProperties()
204:                            : state == WindowTabState.HIGHLIGHTED ? windowTabProperties
205:                                    .getHighlightedButtonProperties()
206:                                    : windowTabProperties
207:                                            .getNormalButtonProperties();
208:
209:                    InternalDockingUtil.updateButtons(buttonInfos, buttons[i],
210:                            buttonBoxes[i], window, buttonProperties.getMap(),
211:                            changes);
212:
213:                    buttonBoxes[i]
214:                            .setDirection((state == WindowTabState.NORMAL ? getProperties()
215:                                    .getNormalProperties()
216:                                    : getProperties()
217:                                            .getHighlightedProperties())
218:                                    .getDirection());
219:                }
220:
221:                Direction dir = getProperties().getHighlightedProperties()
222:                        .getDirection();
223:                highlightedFocusedPanel.setDirection(dir);
224:                customComponents.setDirection(dir);
225:            }
226:
227:            DockingWindow getWindow() {
228:                return window;
229:            }
230:
231:            void windowTitleChanged() {
232:                setText(getWindow().getTitle());
233:                setIcon(getWindow().getIcon());
234:            }
235:
236:            public String toString() {
237:                return window != null ? window.toString() : null;
238:            }
239:
240:            void setContentComponent(Component component) {
241:                ((SimplePanel) getContentComponent()).setComponent(component);
242:            }
243:
244:            java.util.List getCustomTabComponentsList() {
245:                if (tabComponentsList == null)
246:                    tabComponentsList = new ContainerList(customComponents);
247:
248:                return tabComponentsList;
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.