Source Code Cross Referenced for WorkbenchToolBar.java in  » GIS » openjump » com » vividsolutions » jump » workbench » ui » 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 » GIS » openjump » com.vividsolutions.jump.workbench.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
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:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:
033:        package com.vividsolutions.jump.workbench.ui;
034:
035:        import java.awt.event.ActionEvent;
036:        import java.awt.event.ActionListener;
037:        import java.awt.event.MouseEvent;
038:        import java.util.Enumeration;
039:        import java.util.HashMap;
040:
041:        import javax.swing.AbstractButton;
042:        import javax.swing.ButtonGroup;
043:        import javax.swing.Icon;
044:        import javax.swing.JButton;
045:        import javax.swing.JComponent;
046:        import javax.swing.JToggleButton;
047:
048:        import com.vividsolutions.jts.util.Assert;
049:        import com.vividsolutions.jump.workbench.WorkbenchContext;
050:        import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
051:        import com.vividsolutions.jump.workbench.plugin.EnableCheck;
052:        import com.vividsolutions.jump.workbench.plugin.PlugIn;
053:        import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;
054:        import com.vividsolutions.jump.workbench.ui.cursortool.QuasimodeTool;
055:        import com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager;
056:
057:        /**
058:         * Makes it easy to add CursorTools and PlugIns as toolbar buttons.
059:         * An "EnableCheck" is used to specify whether to enable or disable the
060:         * CursorTool buttons. Moreover, CursorTools are added as mutually exclusive
061:         * toggle buttons (that is, JToggleButtons in a ButtonGroup). When a CursorTool
062:         * button is pressed, the current CursorTool is unregistered and the new one
063:         * is registered with the LayerViewPanel.
064:         * <P>
065:         * Set the cursor-tool-enable-check to use context-sensitive enabling of toolbar
066:         * buttons.
067:         * <P>
068:         * Set the task-monitor-manager to report the progress of threaded plug-ins.
069:         */
070:        public class WorkbenchToolBar extends EnableableToolBar {
071:            private HashMap cursorToolClassToButtonMap = new HashMap();
072:
073:            private LayerViewPanelProxy layerViewPanelProxy;
074:            private TaskMonitorManager taskMonitorManager = null;
075:
076:            public AbstractButton getButton(Class cursorToolClass) {
077:                Assert.isTrue(CursorTool.class
078:                        .isAssignableFrom(cursorToolClass));
079:                return (AbstractButton) cursorToolClassToButtonMap
080:                        .get(cursorToolClass);
081:            }
082:
083:            // By default, CursorTool buttons are always enabled. [Jon Aquino]
084:            private EnableCheck cursorToolEnableCheck = new EnableCheck() {
085:                public String check(JComponent component) {
086:                    return null;
087:                }
088:            };
089:
090:            private ButtonGroup cursorToolButtonGroup;
091:
092:            public WorkbenchToolBar(LayerViewPanelProxy layerViewPanelProxy) {
093:                this (layerViewPanelProxy, new ButtonGroup());
094:            }
095:
096:            public WorkbenchToolBar(LayerViewPanelProxy layerViewPanelProxy,
097:                    ButtonGroup cursorToolButtonGroup) {
098:                this .cursorToolButtonGroup = cursorToolButtonGroup;
099:                this .layerViewPanelProxy = layerViewPanelProxy;
100:            }
101:
102:            public void setCursorToolEnableCheck(
103:                    EnableCheck cursorToolEnableCheck) {
104:                this .cursorToolEnableCheck = cursorToolEnableCheck;
105:            }
106:
107:            public void setTaskMonitorManager(
108:                    TaskMonitorManager taskMonitorManager) {
109:                this .taskMonitorManager = taskMonitorManager;
110:            }
111:
112:            public ToolConfig addCursorTool(final CursorTool cursorTool) {
113:                return addCursorTool(cursorTool.getName(), cursorTool,
114:                        new JToggleButton() {
115:                            public String getToolTipText(MouseEvent event) {
116:                                //Get tooltip text dynamically [Jon Aquino 11/13/2003]
117:                                return cursorTool.getName();
118:                            }
119:                        });
120:            }
121:
122:            public static class ToolConfig {
123:                private JToggleButton button;
124:                private QuasimodeTool quasimodeTool;
125:
126:                public ToolConfig(JToggleButton button,
127:                        QuasimodeTool quasimodeTool) {
128:                    this .button = button;
129:                    this .quasimodeTool = quasimodeTool;
130:                }
131:
132:                public JToggleButton getButton() {
133:                    return button;
134:                }
135:
136:                public QuasimodeTool getQuasimodeTool() {
137:                    return quasimodeTool;
138:                }
139:
140:            }
141:
142:            public ToolConfig addCursorTool(String tooltip,
143:                    final CursorTool cursorTool) {
144:                JToggleButton button = new JToggleButton();
145:                return addCursorTool(tooltip, cursorTool, button);
146:            }
147:
148:            private ToolConfig addCursorTool(String tooltip,
149:                    final CursorTool cursorTool, JToggleButton button) {
150:                cursorToolButtonGroup.add(button);
151:                cursorToolClassToButtonMap.put(cursorTool.getClass(), button);
152:                final QuasimodeTool quasimodeTool = QuasimodeTool
153:                        .addStandardQuasimodes(cursorTool);
154:                add(button, tooltip, cursorTool.getIcon(),
155:                        new ActionListener() {
156:                            public void actionPerformed(ActionEvent e) {
157:                                //It's null when the Workbench starts up. [Jon Aquino]
158:                                //Or the active frame may not have a LayerViewPanel. [Jon Aquino]
159:                                if (layerViewPanelProxy.getLayerViewPanel() != null) {
160:                                    layerViewPanelProxy
161:                                            .getLayerViewPanel()
162:                                            .setCurrentCursorTool(quasimodeTool);
163:                                }
164:
165:                                //<<TODO:DESIGN>> We really shouldn't create a new LeftClickFilter on each
166:                                //click of the tool button. Not a big deal though. [Jon Aquino]
167:                            }
168:                        }, cursorToolEnableCheck);
169:                if (cursorToolButtonGroup.getButtonCount() == 1) {
170:                    cursorToolButtonGroup.setSelected(button.getModel(), true);
171:                    reClickSelectedCursorToolButton();
172:                }
173:                return new ToolConfig(button, quasimodeTool);
174:            }
175:
176:            public ButtonGroup getButtonGroup() {
177:                return cursorToolButtonGroup;
178:            }
179:
180:            public JToggleButton getSelectedCursorToolButton() {
181:                for (Enumeration e = cursorToolButtonGroup.getElements(); e
182:                        .hasMoreElements();) {
183:                    JToggleButton button = (JToggleButton) e.nextElement();
184:
185:                    if (button.getModel() == cursorToolButtonGroup
186:                            .getSelection()) {
187:                        return button;
188:                    }
189:                }
190:
191:                Assert.shouldNeverReachHere();
192:
193:                return null;
194:            }
195:
196:            public void reClickSelectedCursorToolButton() {
197:                if (cursorToolButtonGroup.getButtonCount() == 0) {
198:                    return;
199:                }
200:                getSelectedCursorToolButton().doClick();
201:            }
202:
203:            //<<TODO:REFACTOR>> This method duplicates code in FeatureInstaller, with the
204:            //result that when the latter was updated (to handle ThreadedPlugIns), the
205:            //changes were left out from the former. [Jon Aquino]
206:            public JButton addPlugIn(Icon icon, final PlugIn plugIn,
207:                    EnableCheck enableCheck, WorkbenchContext workbenchContext) {
208:                JButton button = new JButton();
209:                add(button, plugIn.getName(), icon, AbstractPlugIn
210:                        .toActionListener(plugIn, workbenchContext,
211:                                taskMonitorManager), enableCheck);
212:
213:                return button;
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.