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.plugin.wms;
034:
035: import java.awt.BorderLayout;
036: import java.util.Collection;
037: import java.util.Map;
038:
039: import javax.swing.JPanel;
040:
041: import com.vividsolutions.jump.I18N;
042: import com.vividsolutions.jump.workbench.WorkbenchException;
043: import com.vividsolutions.jump.workbench.ui.InputChangedListener;
044: import com.vividsolutions.jump.workbench.ui.wizard.WizardPanel;
045: import com.vividsolutions.wms.WMService;
046:
047: public class MapLayerWizardPanel extends JPanel implements WizardPanel {
048: public static final String LAYERS_KEY = "LAYERS";
049: public static final String COMMON_SRS_LIST_KEY = "COMMON_SRS_LIST";
050: public final static String INITIAL_LAYER_NAMES_KEY = "INITIAL_LAYER_NAMES";
051: public final static String NO_COMMON_SRS_MESSAGE = I18N
052: .get("ui.plugin.wms.MapLayerWizardPanel.the-chosen-layers-do-not-have-a-common-epsg-coordinate-reference-system");
053: private MapLayerPanel addRemovePanel = new MapLayerPanel();
054: private Map dataMap;
055: private String nextID = SRSWizardPanel.class.getName();
056: private BorderLayout borderLayout1 = new BorderLayout();
057:
058: public MapLayerWizardPanel() {
059: try {
060: jbInit();
061: } catch (Exception e) {
062: e.printStackTrace();
063: }
064: }
065:
066: public void add(InputChangedListener listener) {
067: addRemovePanel.add(listener);
068: }
069:
070: public void remove(InputChangedListener listener) {
071: addRemovePanel.remove(listener);
072: }
073:
074: public String getInstructions() {
075: // return "Please choose the WMS layers that should appear on the image. You " +
076: // "can change the ordering of the WMS layers using the up and down buttons.";
077: return I18N
078: .get("ui.plugin.wms.MapLayerWizardPanel.please-choose-the-wms-layers-that-should-appear-on-the-image");
079: }
080:
081: public void exitingToRight() throws WorkbenchException {
082: dataMap.put(LAYERS_KEY, addRemovePanel.getChosenMapLayers());
083:
084: if (addRemovePanel.commonSRSList().isEmpty()) {
085: throw new WorkbenchException(NO_COMMON_SRS_MESSAGE);
086: }
087:
088: dataMap
089: .put(COMMON_SRS_LIST_KEY, addRemovePanel
090: .commonSRSList());
091: if (addRemovePanel.commonSRSList().size() == 1) {
092: nextID = OneSRSWizardPanel.class.getName();
093: } else {
094: nextID = SRSWizardPanel.class.getName();
095: }
096: }
097:
098: public void enteredFromLeft(Map dataMap) {
099: this .dataMap = dataMap;
100: addRemovePanel.init((WMService) dataMap
101: .get(URLWizardPanel.SERVICE_KEY), (Collection) dataMap
102: .get(INITIAL_LAYER_NAMES_KEY));
103: }
104:
105: public String getTitle() {
106: return I18N
107: .get("ui.plugin.wms.MapLayerWizardPanel.choose-wms-layers");
108: }
109:
110: public String getID() {
111: return getClass().getName();
112: }
113:
114: public boolean isInputValid() {
115: return !addRemovePanel.getChosenMapLayers().isEmpty();
116: }
117:
118: public String getNextID() {
119: return nextID;
120: }
121:
122: private void jbInit() throws Exception {
123: this.setLayout(borderLayout1);
124: add(addRemovePanel, BorderLayout.CENTER);
125: }
126: }
|