Source Code Cross Referenced for OtherAction.java in  » GIS » udig-1.1 » net » refractions » udig » mapgraphic » internal » 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 » udig 1.1 » net.refractions.udig.mapgraphic.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.mapgraphic.internal;
016:
017:        import java.io.IOException;
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        import net.refractions.udig.catalog.CatalogPlugin;
023:        import net.refractions.udig.catalog.IGeoResource;
024:        import net.refractions.udig.catalog.IService;
025:        import net.refractions.udig.catalog.ui.ResolveLabelProviderSimple;
026:        import net.refractions.udig.catalog.ui.ResolveTitlesDecorator;
027:        import net.refractions.udig.mapgraphic.MapGraphicPlugin;
028:        import net.refractions.udig.project.ui.ApplicationGIS;
029:        import net.refractions.udig.ui.ProgressManager;
030:
031:        import org.eclipse.jface.action.IAction;
032:        import org.eclipse.jface.dialogs.IDialogConstants;
033:        import org.eclipse.jface.dialogs.TitleAreaDialog;
034:        import org.eclipse.jface.viewers.DecoratingLabelProvider;
035:        import org.eclipse.jface.viewers.DoubleClickEvent;
036:        import org.eclipse.jface.viewers.IDoubleClickListener;
037:        import org.eclipse.jface.viewers.ISelection;
038:        import org.eclipse.jface.viewers.ISelectionChangedListener;
039:        import org.eclipse.jface.viewers.IStructuredSelection;
040:        import org.eclipse.jface.viewers.ITreeContentProvider;
041:        import org.eclipse.jface.viewers.SelectionChangedEvent;
042:        import org.eclipse.jface.viewers.TreeViewer;
043:        import org.eclipse.jface.viewers.Viewer;
044:        import org.eclipse.swt.SWT;
045:        import org.eclipse.swt.graphics.Point;
046:        import org.eclipse.swt.layout.GridData;
047:        import org.eclipse.swt.widgets.Composite;
048:        import org.eclipse.swt.widgets.Control;
049:        import org.eclipse.swt.widgets.Display;
050:        import org.eclipse.swt.widgets.Shell;
051:        import org.eclipse.ui.IWorkbenchWindow;
052:        import org.eclipse.ui.IWorkbenchWindowActionDelegate;
053:
054:        /**
055:         * Opens a dialog with all the MapGraphics
056:         * 
057:         * @author Jesse
058:         * @since 1.1.0
059:         */
060:        public class OtherAction implements  IWorkbenchWindowActionDelegate,
061:                ITreeContentProvider {
062:
063:            public void dispose() {
064:            }
065:
066:            public void init(IWorkbenchWindow window) {
067:            }
068:
069:            public void run(IAction action) {
070:                TitleAreaDialog d = new TitleAreaDialog(Display.getCurrent()
071:                        .getActiveShell()) {
072:                    private TreeViewer viewer;
073:
074:                    @Override
075:                    protected int getShellStyle() {
076:                        return SWT.RESIZE | SWT.MAX | SWT.CLOSE | SWT.MIN
077:                                | SWT.APPLICATION_MODAL;
078:                    }
079:
080:                    @Override
081:                    protected void configureShell(Shell newShell) {
082:                        newShell.setText(Messages.OtherAction_shellText);
083:                        super .configureShell(newShell);
084:                    }
085:
086:                    @Override
087:                    protected Point getInitialSize() {
088:                        return new Point(400, 400);
089:                    }
090:
091:                    @Override
092:                    protected Control createContents(Composite parent) {
093:                        Control control = super .createContents(parent);
094:                        setTitle(Messages.OtherAction_wizardTitle);
095:                        setMessage(Messages.OtherAction_message1);
096:                        return control;
097:                    }
098:
099:                    @Override
100:                    protected Control createDialogArea(Composite parent) {
101:                        Composite composite = (Composite) super 
102:                                .createDialogArea(parent);
103:                        org.eclipse.swt.widgets.Tree tree = new org.eclipse.swt.widgets.Tree(
104:                                composite, SWT.V_SCROLL | SWT.MULTI);
105:                        viewer = new TreeViewer(tree);
106:
107:                        GridData gridData = new GridData(GridData.FILL_BOTH);
108:                        gridData.heightHint = SWT.DEFAULT;
109:                        gridData.widthHint = SWT.DEFAULT;
110:                        gridData.verticalSpan = 4;
111:                        tree.setLayoutData(gridData);
112:                        viewer.setContentProvider(OtherAction.this );
113:                        ResolveLabelProviderSimple resolveLabelProviderSimple = new ResolveLabelProviderSimple();
114:                        ResolveTitlesDecorator resolveTitlesDecorator = new ResolveTitlesDecorator(
115:                                resolveLabelProviderSimple, true);
116:                        viewer.setLabelProvider(new DecoratingLabelProvider(
117:                                resolveLabelProviderSimple,
118:                                resolveTitlesDecorator));
119:                        viewer.setInput(CatalogPlugin.getDefault()
120:                                .getLocalCatalog().getById(IService.class,
121:                                        MapGraphicService.SERVICE_URL,
122:                                        ProgressManager.instance().get()));
123:                        viewer
124:                                .addPostSelectionChangedListener(new ISelectionChangedListener() {
125:
126:                                    public void selectionChanged(
127:                                            SelectionChangedEvent event) {
128:                                        IStructuredSelection s = (IStructuredSelection) event
129:                                                .getSelection();
130:                                        if (s.isEmpty())
131:                                            return;
132:
133:                                        String title = null;
134:                                        try {
135:                                            title = ((IGeoResource) s
136:                                                    .getFirstElement())
137:                                                    .getInfo(null).getTitle();
138:                                        } catch (IOException e) {
139:                                            MapGraphicPlugin.log("", e); //$NON-NLS-1$
140:                                        }
141:                                        if (s.size() == 1 && title != null) {
142:                                            setMessage(Messages.OtherAction_p1
143:                                                    + title
144:                                                    + Messages.OtherAction_p2);
145:                                        } else {
146:                                            setMessage(Messages.OtherAction_addAll);
147:                                        }
148:                                    }
149:
150:                                });
151:                        viewer
152:                                .addDoubleClickListener(new IDoubleClickListener() {
153:
154:                                    public void doubleClick(
155:                                            DoubleClickEvent event) {
156:                                        buttonPressed(IDialogConstants.OK_ID);
157:                                    }
158:
159:                                });
160:                        return composite;
161:                    }
162:
163:                    @Override
164:                    protected void createButtonsForButtonBar(Composite parent) {
165:                        createButton(parent, IDialogConstants.CANCEL_ID,
166:                                IDialogConstants.CANCEL_LABEL, false);
167:                        createButton(parent, IDialogConstants.OK_ID,
168:                                Messages.OtherAction_addButton, true);
169:                    }
170:
171:                    @Override
172:                    protected void buttonPressed(int buttonId) {
173:                        if (buttonId == IDialogConstants.OK_ID) {
174:                            IStructuredSelection selection = (IStructuredSelection) viewer
175:                                    .getSelection();
176:                            Iterator iter = selection.iterator();
177:                            List<IGeoResource> resourceList = new ArrayList<IGeoResource>();
178:                            while (iter.hasNext())
179:                                resourceList.add((IGeoResource) iter.next());
180:                            ApplicationGIS.addLayersToMap(null, resourceList,
181:                                    -1);
182:                        }
183:                        super .buttonPressed(buttonId);
184:                    }
185:                };
186:                d.open();
187:
188:            }
189:
190:            public void selectionChanged(IAction action, ISelection selection) {
191:            }
192:
193:            public Object[] getElements(Object inputElement) {
194:                if (inputElement instanceof  IService) {
195:                    try {
196:                        return ((IService) inputElement).members(
197:                                ProgressManager.instance().get()).toArray();
198:                    } catch (IOException e) {
199:                        throw (RuntimeException) new RuntimeException()
200:                                .initCause(e);
201:                    }
202:                }
203:                return null;
204:            }
205:
206:            public void inputChanged(Viewer viewer, Object oldInput,
207:                    Object newInput) {
208:            }
209:
210:            public Object[] getChildren(Object parentElement) {
211:                return getElements(parentElement);
212:            }
213:
214:            public Object getParent(Object element) {
215:                return null;
216:            }
217:
218:            public boolean hasChildren(Object element) {
219:
220:                if (element instanceof  IService) {
221:                    return true;
222:                }
223:                return false;
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.