Source Code Cross Referenced for ToolboxDialog.java in  » GIS » openjump » com » vividsolutions » jump » workbench » ui » toolbox » 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.toolbox 
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.toolbox;
034:
035:        import java.awt.BorderLayout;
036:        import java.awt.GridLayout;
037:        import java.awt.event.*;
038:        import java.util.ArrayList;
039:        import java.util.Iterator;
040:
041:        import javax.swing.*;
042:
043:        import com.vividsolutions.jump.workbench.WorkbenchContext;
044:        import com.vividsolutions.jump.workbench.plugin.EnableCheck;
045:        import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
046:        import com.vividsolutions.jump.workbench.plugin.PlugIn;
047:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
048:        import com.vividsolutions.jump.workbench.ui.WorkbenchToolBar;
049:        import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;
050:
051:        /**
052:         * An always-on-top modeless dialog with a WorkbenchToolBar (for CursorTools,
053:         * PlugIns, and other buttons). Takes care of unpressing the CursorTools (if
054:         * necessary) when the dialog is closed (and pressing the first CursorTool on
055:         * the main toolbar).
056:         */
057:
058:        //Must use modeless dialog rather than JInternalFrame; otherwise, if we
059:        // implement
060:        //it as an internal frame, when we click it, the original TaskFrame will
061:        // deactivate,
062:        //thus deactivating the current CursorTool. [Jon Aquino]
063:        public class ToolboxDialog extends JDialog {
064:            public AbstractButton getButton(Class cursorToolClass) {
065:                for (Iterator i = toolBars.iterator(); i.hasNext();) {
066:                    WorkbenchToolBar toolBar = (WorkbenchToolBar) i.next();
067:                    AbstractButton button = toolBar.getButton(cursorToolClass);
068:                    if (button != null) {
069:                        return button;
070:                    }
071:                }
072:                return null;
073:            }
074:
075:            public WorkbenchToolBar getToolBar() {
076:                if (toolBars.isEmpty()) {
077:                    addToolBar();
078:                }
079:                return (WorkbenchToolBar) toolBars.get(toolBars.size() - 1);
080:            }
081:
082:            public WorkbenchContext getContext() {
083:                return context;
084:            }
085:
086:            public WorkbenchToolBar.ToolConfig add(CursorTool tool) {
087:                return add(tool, null);
088:            }
089:
090:            /**
091:             * @param enableCheck
092:             *            null to leave unspecified
093:             */
094:            public WorkbenchToolBar.ToolConfig add(CursorTool tool,
095:                    EnableCheck enableCheck) {
096:                WorkbenchToolBar.ToolConfig config = getToolBar()
097:                        .addCursorTool(tool);
098:                JToggleButton button = config.getButton();
099:                getToolBar().setEnableCheck(
100:                        button,
101:                        enableCheck != null ? enableCheck
102:                                : new MultiEnableCheck());
103:                registerButton(button, enableCheck);
104:                return config;
105:            }
106:
107:            public void addPlugIn(PlugIn plugIn, EnableCheck enableCheck,
108:                    Icon icon) {
109:                registerButton(getToolBar().addPlugIn(icon, plugIn,
110:                        enableCheck, context), enableCheck);
111:            }
112:
113:            private void registerButton(AbstractButton button,
114:                    EnableCheck enableCheck) {
115:                buttons.add(button);
116:            }
117:
118:            private ArrayList buttons = new ArrayList();
119:
120:            private ArrayList toolBars = new ArrayList();
121:
122:            public void addToolBar() {
123:                toolBars.add(new WorkbenchToolBar(context, context
124:                        .getWorkbench().getFrame().getToolBar()
125:                        .getButtonGroup()));
126:                getToolBar().setBorder(null);
127:                getToolBar().setFloatable(false);
128:                gridLayout1.setRows(toolBars.size());
129:                toolbarsPanel.add(getToolBar());
130:            }
131:
132:            public ToolboxDialog(final WorkbenchContext context) {
133:                super (context.getWorkbench().getFrame(), "", false);
134:                try {
135:                    jbInit();
136:                } catch (Exception e) {
137:                    e.printStackTrace();
138:                }
139:                this .context = context;
140:                setResizable(true);
141:                setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
142:                this .addComponentListener(new ComponentAdapter() {
143:                    public void componentHidden(ComponentEvent e) {
144:                        if (buttons.contains(context.getWorkbench().getFrame()
145:                                .getToolBar().getSelectedCursorToolButton())) {
146:                            ((AbstractButton) context.getWorkbench().getFrame()
147:                                    .getToolBar().getButtonGroup()
148:                                    .getElements().nextElement()).doClick();
149:                        }
150:                    }
151:                });
152:            }
153:
154:            /**
155:             * Call this method after all the CursorTools have been added.
156:             */
157:            public void finishAddingComponents() {
158:                pack();
159:                // #initializeLocation will be called again in #setVisible, but
160:                // call it here just in case the window is realized by some other
161:                // means than #setVisible (unlikely). [Jon Aquino 2005-03-14]
162:                initializeLocation();
163:            }
164:
165:            public void setVisible(boolean visible) {
166:                if (visible && !locationInitializedBeforeMakingDialogVisible) {
167:                    // #initializeLocation was called in #finishAddingComponents,
168:                    // but the Workbench may have moved since then, so call
169:                    // #initializeLocation again just before making the dialog
170:                    // visible. [Jon Aquino 2005-03-14]
171:                    initializeLocation();
172:                    locationInitializedBeforeMakingDialogVisible = true;
173:                }
174:                super .setVisible(visible);
175:            }
176:
177:            private boolean locationInitializedBeforeMakingDialogVisible = false;
178:
179:            private void initializeLocation() {
180:                GUIUtil.setLocation(this , initialLocation, context
181:                        .getWorkbench().getFrame().getDesktopPane());
182:            }
183:
184:            private GUIUtil.Location initialLocation = new GUIUtil.Location(0,
185:                    false, 0, false);
186:
187:            private WorkbenchContext context;
188:
189:            private BorderLayout borderLayout1 = new BorderLayout();
190:
191:            private JPanel centerPanel = new JPanel();
192:
193:            private BorderLayout borderLayout2 = new BorderLayout();
194:
195:            private JPanel toolbarsPanel = new JPanel();
196:
197:            private GridLayout gridLayout1 = new GridLayout();
198:
199:            private void jbInit() throws Exception {
200:                this .getContentPane().setLayout(borderLayout1);
201:                centerPanel.setLayout(borderLayout2);
202:                toolbarsPanel.setLayout(gridLayout1);
203:                gridLayout1.setColumns(1);
204:                this .getContentPane().add(centerPanel, BorderLayout.CENTER);
205:                centerPanel.add(toolbarsPanel, BorderLayout.NORTH);
206:            }
207:
208:            public JPanel getCenterPanel() {
209:                return centerPanel;
210:            }
211:
212:            public void updateEnabledState() {
213:                for (Iterator i = toolBars.iterator(); i.hasNext();) {
214:                    WorkbenchToolBar toolBar = (WorkbenchToolBar) i.next();
215:                    toolBar.updateEnabledState();
216:                }
217:            }
218:
219:            public void setInitialLocation(GUIUtil.Location location) {
220:                initialLocation = location;
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.