Source Code Cross Referenced for JoinTablePlugIn.java in  » GIS » openjump » org » openjump » sigle » plugin » joinTable » 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 » org.openjump.sigle.plugin.joinTable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * @author Olivier BEDEL
003:         * 	Laboratoire RESO UMR 6590 CNRS
004:         * 	Bassin Versant du Jaudy-Guindy-Bizien
005:         * 	26 oct. 2004
006:         * 
007:         */package org.openjump.sigle.plugin.joinTable;
008:
009:        import java.util.ArrayList;
010:        import java.util.List;
011:
012:        import javax.swing.JComboBox;
013:        import javax.swing.JFileChooser;
014:        import javax.swing.JPanel;
015:        import javax.swing.filechooser.FileFilter;
016:
017:        import com.vividsolutions.jump.I18N;
018:        import com.vividsolutions.jump.feature.FeatureSchema;
019:        import com.vividsolutions.jump.task.TaskMonitor;
020:        import com.vividsolutions.jump.workbench.WorkbenchContext;
021:        import com.vividsolutions.jump.workbench.model.Layer;
022:        import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
023:        import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
024:        import com.vividsolutions.jump.workbench.plugin.PlugInContext;
025:        import com.vividsolutions.jump.workbench.plugin.ThreadedBasePlugIn;
026:        import com.vividsolutions.jump.workbench.ui.ErrorDialog;
027:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
028:        import com.vividsolutions.jump.workbench.ui.GenericNames;
029:        import com.vividsolutions.jump.workbench.ui.MenuNames;
030:        import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
031:        import com.vividsolutions.jump.workbench.ui.WorkbenchFrame;
032:        import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller;
033:        import com.vividsolutions.jump.workbench.ui.plugin.SaveProjectAsPlugIn;
034:
035:        /**
036:         * @author Olivier BEDEL
037:         * 	Laboratoire RESO UMR 6590 CNRS
038:         * 	Bassin Versant du Jaudy-Guindy-Bizien
039:         * 	26 oct. 2004
040:         * @license Licence CeCILL http://www.cecill.info/
041:         * 
042:         * [sstein 25.March.2007] modified for using it in normal menu and not layerpopupmenu
043:         * 
044:         */
045:        public class JoinTablePlugIn extends ThreadedBasePlugIn {
046:            protected static String name = "JoinTable";
047:            public static FileFilter JOIN_TABLE_FILE_FILTER = null;
048:            private Layer layer;
049:            private JFileChooser fileChooser;
050:            private MultiInputDialog dialog;
051:            private MultiInputDialog layerdialog;
052:            private String LAYER_ATTRIBUTES = null;
053:            private String TABLE_ATTRIBUTES = null;
054:            private String sLAYER = GenericNames.LAYER;
055:
056:            public void initialize(PlugInContext context) throws Exception {
057:
058:                // initialisation du filtre de fichier
059:                JoinTablePlugIn.JOIN_TABLE_FILE_FILTER = GUIUtil
060:                        .createFileFilter(
061:                                I18N
062:                                        .get("org.openjump.sigle.plugin.joinTable.text_file"),
063:                                new String[] { "txt", "text" });
064:                LAYER_ATTRIBUTES = I18N
065:                        .get("org.openjump.sigle.plugin.joinTable.layer_field");
066:                TABLE_ATTRIBUTES = I18N
067:                        .get("org.openjump.sigle.plugin.joinTable.table_field");
068:
069:                /*
070:                context.getFeatureInstaller().addPopupMenuItem(
071:                		context.getWorkbenchContext().getWorkbench().getFrame().getLayerNamePopupMenu(), 
072:                	    this, 
073:                		I18N.get("org.openjump.sigle.plugin.joinTable.Join_data")+"{pos:14}" , 
074:                		false, 
075:                		null, 
076:                		new EnableCheckFactory(context.getWorkbenchContext()).createAtLeastNLayersMustExistCheck(1));
077:                 */
078:
079:                FeatureInstaller featureInstaller = new FeatureInstaller(
080:                        context.getWorkbenchContext());
081:                featureInstaller.addMainMenuItem(this , //exe				
082:                        new String[] { MenuNames.TOOLS,
083:                                MenuNames.TOOLS_EDIT_ATTRIBUTES }, //menu path
084:                        this .getName(), //name methode .getName recieved by AbstractPlugIn 
085:                        false, //checkbox
086:                        null, //icon
087:                        new EnableCheckFactory(context.getWorkbenchContext())
088:                                .createAtLeastNLayersMustExistCheck(1)); //enable check        
089:
090:                //Joindre des données -> I18N.get(name,"org.OpenJUMP.layer.joinTable.JoinTablePlugin.MenuName")
091:                fileChooser = GUIUtil.createJFileChooserWithExistenceChecking();
092:                fileChooser
093:                        .setDialogTitle(I18N
094:                                .get("org.openjump.sigle.plugin.joinTable.Choose_file_data_to_join"));
095:                fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
096:                fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
097:                fileChooser.setMultiSelectionEnabled(false);
098:                GUIUtil.removeChoosableFileFilters(fileChooser);
099:                fileChooser.addChoosableFileFilter(JOIN_TABLE_FILE_FILTER);
100:                fileChooser.addChoosableFileFilter(GUIUtil.ALL_FILES_FILTER);
101:                fileChooser.setFileFilter(JOIN_TABLE_FILE_FILTER);
102:            }
103:
104:            public String getName() {
105:                return I18N
106:                        .get("org.openjump.sigle.plugin.joinTable.Join_data");
107:            }
108:
109:            public boolean execute(PlugInContext context) throws Exception {
110:                reportNothingToUndoYet(context);
111:
112:                if (JFileChooser.APPROVE_OPTION != fileChooser
113:                        .showOpenDialog(context.getWorkbenchFrame())) {
114:                    return false;
115:                }
116:
117:                //-- get Layer  -------------------------------------
118:                // load string again for correct language
119:                sLAYER = GenericNames.LAYER;
120:                //-- Unlike ValidatePlugIn, here we always call #initDialog because we want
121:                //   to update the layer comboboxes. [Jon Aquino]
122:                initLayerDialog(context);
123:                layerdialog.setVisible(true);
124:
125:                if (!layerdialog.wasOKPressed()) {
126:                    return false;
127:                } else {
128:                    layer = layerdialog.getLayer(sLAYER);
129:                }
130:                //-- check if attributes exist
131:                if (layer.getFeatureCollectionWrapper().getFeatureSchema()
132:                        .getAttributeCount() == 0) {
133:                    ErrorDialog
134:                            .show(
135:                                    context.getWorkbenchFrame(),
136:                                    I18N
137:                                            .get("org.openjump.sigle.plugin.joinTable.Unable_to_join_data"),
138:                                    I18N
139:                                            .get("org.openjump.sigle.plugin.joinTable.Layer_has_no_field"),
140:                                    "");
141:                    return false;
142:                }
143:
144:                JoinTable jt = new JoinTable(fileChooser.getSelectedFile()
145:                        .getAbsolutePath());
146:
147:                //-- get unique field/attribute --------------------
148:                initDialog(context, jt, layer);
149:                dialog.setVisible(true);
150:                if (!dialog.wasOKPressed()) {
151:                    jt.dispose();
152:                    return false;
153:                }
154:                //System.out.println("indice du champ de la table : " + dialog.getComboBox(TABLE_ATTRIBUTES).getSelectedIndex() );
155:                //System.out.println("indice du champ de la couche : " + dialog.getComboBox(LAYER_ATTRIBUTES).getSelectedIndex() );
156:                jt.setKeyIndex(dialog.getComboBox(TABLE_ATTRIBUTES)
157:                        .getSelectedIndex());
158:                jt.build();
159:                //jointure sur la couche en memoire
160:                jt.join(layer, dialog.getComboBox(LAYER_ATTRIBUTES)
161:                        .getSelectedIndex());
162:
163:                //liberation memoire
164:                jt.dispose();
165:                System.gc();
166:                return true;
167:            }
168:
169:            public void run(TaskMonitor monitor, PlugInContext context)
170:                    throws Exception {
171:                //left emtpy
172:            }
173:
174:            private void initDialog(PlugInContext context, JoinTable jt,
175:                    Layer layer) {
176:
177:                FeatureSchema schema = layer.getFeatureCollectionWrapper()
178:                        .getFeatureSchema();
179:
180:                ArrayList layerAttributes = new ArrayList(schema
181:                        .getAttributeCount());
182:
183:                for (int i = 0; i < schema.getAttributeCount(); i++)
184:                    layerAttributes.add(i, schema.getAttributeName(i));
185:
186:                dialog = new MultiInputDialog(
187:                        context.getWorkbenchFrame(),
188:                        I18N
189:                                .get("org.openjump.sigle.plugin.joinTable.Matching_fields"),
190:                        true);
191:
192:                dialog
193:                        .setSideBarDescription(I18N
194:                                .get("org.openjump.sigle.plugin.joinTable.Choose_fields_to_join"));
195:
196:                dialog.addComboBox(LAYER_ATTRIBUTES, layerAttributes.get(0),
197:                        layerAttributes, null);
198:                dialog.addComboBox(TABLE_ATTRIBUTES, jt.getFieldName(0), jt
199:                        .getFieldNames(), null);
200:                GUIUtil.centreOnWindow(dialog);
201:            }
202:
203:            private void initLayerDialog(PlugInContext context) {
204:                layerdialog = new MultiInputDialog(context.getWorkbenchFrame(),
205:                        "", true);
206:
207:                //dialog.setSideBarImage(IconLoader.icon("Overlay.gif"));
208:                layerdialog.setSideBarDescription(I18N
209:                        .get("org.openjump.sigle.plugin.joinTable.MenuName"));
210:                String fieldName = sLAYER;
211:                JComboBox addLayerComboBox = layerdialog.addLayerComboBox(
212:                        fieldName, context.getCandidateLayer(0), null, context
213:                                .getLayerManager());
214:                GUIUtil.centreOnWindow(layerdialog);
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.