Revision 27564 branches/v2_0_0_prep/extensions/extGeocoding/src/org/gvsig/geocoding/gui/GeocodingPanel.java

View differences:

GeocodingPanel.java
58 58
import org.gvsig.geocoding.gui.settings.SettingsPanel;
59 59
import org.gvsig.geocoding.pattern.Patterngeocoding;
60 60
import org.gvsig.geocoding.result.GeocodingResult;
61
import org.gvsig.geocoding.utils.Export;
61 62
import org.gvsig.geocoding.utils.GeocoUtils;
62 63
import org.gvsig.project.document.table.FeatureTableDocument;
63 64
import org.slf4j.Logger;
......
136 137
	 * 
137 138
	 */
138 139
	private void setImages() {
139
		String baseDir = PluginServices.getPluginServices(this)
140
				.getClassLoader().getBaseDir();
140
		PluginServices ps = PluginServices.getPluginServices(this);
141
		if (ps != null) {
142
			String baseDir = ps.getClassLoader().getBaseDir();
141 143

  
142
		jButLoad.setIcon(new ImageIcon(baseDir + File.separator + "images"
143
				+ File.separator + "icons16" + File.separator + "open.png"));
144
		jButNew.setIcon(new ImageIcon(baseDir + File.separator + "images"
145
				+ File.separator + "icons16" + File.separator + "new.png"));
144
			jButLoad
145
					.setIcon(new ImageIcon(baseDir + File.separator + "images"
146
							+ File.separator + "icons16" + File.separator
147
							+ "open.png"));
148
			jButNew.setIcon(new ImageIcon(baseDir + File.separator + "images"
149
					+ File.separator + "icons16" + File.separator + "new.png"));
146 150

  
147
		jButEdit.setIcon(new ImageIcon(baseDir + File.separator + "images"
148
				+ File.separator + "icons16" + File.separator + "edit.png"));
151
			jButEdit
152
					.setIcon(new ImageIcon(baseDir + File.separator + "images"
153
							+ File.separator + "icons16" + File.separator
154
							+ "edit.png"));
149 155

  
150
		jButNext.setIcon(new ImageIcon(baseDir + File.separator + "images"
151
				+ File.separator + "icons16" + File.separator + "next.png"));
156
			jButNext
157
					.setIcon(new ImageIcon(baseDir + File.separator + "images"
158
							+ File.separator + "icons16" + File.separator
159
							+ "next.png"));
152 160

  
153
		jButPrevious
154
				.setIcon(new ImageIcon(baseDir + File.separator + "images"
155
						+ File.separator + "icons16" + File.separator
156
						+ "previous.png"));
161
			jButPrevious.setIcon(new ImageIcon(baseDir + File.separator
162
					+ "images" + File.separator + "icons16" + File.separator
163
					+ "previous.png"));
157 164

  
158
		jButSearch.setIcon(new ImageIcon(baseDir + File.separator + "images"
159
				+ File.separator + "icons16" + File.separator + "search.png"));
165
			jButSearch.setIcon(new ImageIcon(baseDir + File.separator
166
					+ "images" + File.separator + "icons16" + File.separator
167
					+ "search.png"));
160 168

  
161
		jButExit.setIcon(new ImageIcon(baseDir + File.separator + "images"
162
				+ File.separator + "icons16" + File.separator + "out.png"));
169
			jButExit.setIcon(new ImageIcon(baseDir + File.separator + "images"
170
					+ File.separator + "icons16" + File.separator + "out.png"));
163 171

  
164
		jButExport.setIcon(new ImageIcon(baseDir + File.separator + "images"
165
				+ File.separator + "icons16" + File.separator + "up.png"));
166

  
172
			jButExport.setIcon(new ImageIcon(baseDir + File.separator
173
					+ "images" + File.separator + "icons16" + File.separator
174
					+ "up.png"));
175
		}
167 176
	}
168 177

  
169 178
	/**
......
172 181
	private void setMesages() {
173 182
		PluginServices ps = PluginServices.getPluginServices(this);
174 183

  
175
		jPanPattern
176
				.setBorder(GeocoUtils.getTitledBorder(ps.getText("pattern")));
184
		if (ps != null) {
185
			jPanPattern.setBorder(GeocoUtils.getTitledBorder(ps
186
					.getText("pattern")));
177 187

  
178
		this.jButLoad.setToolTipText(ps.getText("butloadpattern"));
188
			this.jButLoad.setToolTipText(ps.getText("butloadpattern"));
179 189

  
180
		this.jButNew.setToolTipText(ps.getText("butnewpattern"));
190
			this.jButNew.setToolTipText(ps.getText("butnewpattern"));
181 191

  
182
		this.jButEdit.setToolTipText(ps.getText("buteditpattern"));
192
			this.jButEdit.setToolTipText(ps.getText("buteditpattern"));
183 193

  
184
		this.jLabPatternPath.setText(ps.getText("patternpath"));
194
			this.jLabPatternPath.setText(ps.getText("patternpath"));
185 195

  
186
		jPanGeocodingType.setBorder(GeocoUtils.getTitledBorder(ps
187
				.getText("gtype")));
196
			jPanGeocodingType.setBorder(GeocoUtils.getTitledBorder(ps
197
					.getText("gtype")));
188 198

  
189
		this.jRadioSimple.setText(ps.getText("gsimple"));
190
		this.jRadioSimple.setToolTipText(ps.getText("gsimpletip"));
199
			this.jRadioSimple.setText(ps.getText("gsimple"));
200
			this.jRadioSimple.setToolTipText(ps.getText("gsimpletip"));
191 201

  
192
		this.jRadioTable.setText(ps.getText("gtable"));
193
		this.jRadioTable.setToolTipText(ps.getText("gtabletip"));
202
			this.jRadioTable.setText(ps.getText("gtable"));
203
			this.jRadioTable.setToolTipText(ps.getText("gtabletip"));
194 204

  
195
		jPanType.setBorder(GeocoUtils.getTitledBorder(ps.getText("atype")));
205
			jPanType.setBorder(GeocoUtils.getTitledBorder(ps.getText("atype")));
196 206

  
197
		jPanSettings.setBorder(GeocoUtils.getTitledBorder(ps
198
				.getText("settings")));
207
			jPanSettings.setBorder(GeocoUtils.getTitledBorder(ps
208
					.getText("settings")));
199 209

  
200
		jPanResults
201
				.setBorder(GeocoUtils.getTitledBorder(ps.getText("results")));
210
			jPanResults.setBorder(GeocoUtils.getTitledBorder(ps
211
					.getText("results")));
202 212

  
203
		this.jButPrevious.setToolTipText(ps.getText("previoustip"));
204
		this.jButNext.setToolTipText(ps.getText("nexttip"));
213
			this.jButPrevious.setToolTipText(ps.getText("previoustip"));
214
			this.jButNext.setToolTipText(ps.getText("nexttip"));
205 215

  
206
		this.jButExit.setText(ps.getText("exit"));
207
		this.jButSearch.setText(ps.getText("search"));
208
		this.jButExport.setText(ps.getText("export"));
216
			this.jButExit.setText(ps.getText("exit"));
217
			this.jButSearch.setText(ps.getText("search"));
218
			this.jButExport.setText(ps.getText("export"));
219
		}
209 220

  
210 221
	}
211 222

  
......
578 589

  
579 590
		jButExport.setText("Export");
580 591
		jButExport.setToolTipText("Export");
592
		jButExport.setEnabled(false);
581 593
		jButExport.addActionListener(new java.awt.event.ActionListener() {
582 594
			public void actionPerformed(java.awt.event.ActionEvent evt) {
583 595
				evExport(evt);
......
604 616
		boolean apto = control.loadPatternXML();
605 617

  
606 618
		if (apto) {
607

  
608 619
			/* update the url of the pattern in the panel */
609 620
			if (control.getGmodel().getPatternFile() != null) {
610 621
				jTextPatternPath.setText(control.getGmodel().getPatternFile()
......
616 627
					.getResultsNumber());
617 628
			settingsPanel.setScore(control.getPattern().getSettings()
618 629
					.getScore());
619

  
620 630
			// enable components
621 631
			if (control.getPattern() != null) {
622 632
				this.enableComponents();
......
655 665
		control.getGmodel().setSimple(true);
656 666
		activeTableGUIFeatures(false);
657 667
		jButExport.setEnabled(false);
658

  
659 668
		// insert address panel
660 669
		insertAddressPanel();
661 670
	}
......
677 686
		control.getGmodel().setSimple(false);
678 687
		jComboTable.setEnabled(true);
679 688
		jButExport.setEnabled(false);
680

  
681 689
		// save descriptor table in the model
682 690
		List<FeatureAttributeDescriptor> descs = getListOfDescriptorSelectedTable();
683 691
		control.getGmodel().setListDescriptorSelectedTable(descs);
684

  
685 692
		// insert address panel
686 693
		insertAddressPanel();
687 694

  
......
697 704
		// save descriptor table in the model
698 705
		List<FeatureAttributeDescriptor> descs = getListOfDescriptorSelectedTable();
699 706
		control.getGmodel().setListDescriptorSelectedTable(descs);
700

  
701 707
		// insert address panel
702 708
		insertAddressPanel();
703

  
704 709
	}
705 710

  
706 711
	/**
......
748 753
	 * @param evt
749 754
	 */
750 755
	private void evSearch(java.awt.event.ActionEvent evt) {
751

  
752 756
		jTableResults.setModel(new TableResultsModel(control));
753 757
		jTableResults.validate();
754 758
		// // GEOCODING PROCESS
755 759
		control.geocoding();
756
		// // GEOCODING PROCESS
757 760
	}
758 761

  
759 762
	/**
......
762 765
	 * @param evt
763 766
	 */
764 767
	private void evExport(java.awt.event.ActionEvent evt) {
765

  
768
		new Export(control).run();
766 769
	}
767 770

  
768 771
	/**
......
784 787
	 * get window info
785 788
	 */
786 789
	public WindowInfo getWindowInfo() {
787
		// WindowInfo info = new WindowInfo(WindowInfo.MODALDIALOG
788
		// | WindowInfo.RESIZABLE);
789 790
		WindowInfo info = new WindowInfo(WindowInfo.RESIZABLE);
790

  
791 791
		info.setMinimumSize(this.getMinimumSize());
792 792
		info.setWidth(600);
793 793
		info.setHeight(530);
794 794
		info.setTitle(PluginServices.getText(this, "geocoding"));
795

  
796 795
		return info;
797 796
	}
798 797

  
......
897 896
			jButNext.setEnabled(active);
898 897
			jButPrevious.setEnabled(active);
899 898
			jLabRow.setEnabled(active);
899
			jButExport.setEnabled(active);
900 900

  
901 901
		} else {
902 902
			jLabRow.setText("");
903 903
			jButNext.setEnabled(false);
904 904
			jButPrevious.setEnabled(false);
905
			jButExport.setEnabled(false);
905 906
		}
906 907
	}
907 908

  
......
939 940
	 * Mouse pressed events
940 941
	 */
941 942
	public void mousePressed(MouseEvent e) {
942

  
943
		int row = jTableResults.getSelectedRow();
944
		TableResultsModel model = (TableResultsModel) jTableResults.getModel();
945
		boolean sel = (Boolean) model.getValueAt(row, 1);
946
		if (sel) {
947
			model.setValueAt(new Boolean(false), row, 1);
948
			// update list of selected result elements
949
			int num = control.getGmodel().getNumResultShowed();
950
			control.getGmodel().getExportElements()[num] = -1;
951
		} else {
952
			model.setValueAt(new Boolean(true), row, 1);
953
			// update list of selected result elements
954
			int num = control.getGmodel().getNumResultShowed();
955
			control.getGmodel().getExportElements()[num] = row;
956
		}
943 957
	}
944 958

  
945 959
	/**
......
955 969
		for (int i = 0; i < cant; i++) {
956 970
			if (i != row) {
957 971
				model.setValueAt(new Boolean(false), i, 1);
972
				// update list of selected result elements
973
				int num = control.getGmodel().getNumResultShowed();
958 974
			}
959
		}		
975

  
976
		}
960 977
		// zoom to geom
961 978
		Point2D pto = model.getGeometry(row);
962 979
		try {

Also available in: Unified diff