gvsig-webmap / org.gvsig.googlemaps / trunk / org.gvsig.googlemaps / org.gvsig.googlemaps.swing / org.gvsig.googlemaps.swing.impl / src / main / java / org / gvsig / googlemaps / swing / impl / JStreetViewPreferencesController.java @ 135
History | View | Annotate | Download (3.82 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2016 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.googlemaps.swing.impl; |
24 |
|
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
import java.util.Locale; |
28 |
|
29 |
import javax.swing.JComponent; |
30 |
import javax.swing.event.HyperlinkEvent; |
31 |
import javax.swing.event.HyperlinkListener; |
32 |
|
33 |
import org.gvsig.googlemaps.swing.api.StreetViewPreferences; |
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
36 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
37 |
|
38 |
|
39 |
/**
|
40 |
* @author fdiaz
|
41 |
*
|
42 |
*/
|
43 |
public class JStreetViewPreferencesController extends JStreetViewPreferencesView implements StreetViewPreferences { |
44 |
|
45 |
private ActionListenerSupport listeners = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
|
46 |
private PanelAction selectedAction=null; |
47 |
/**
|
48 |
*
|
49 |
*/
|
50 |
private static final long serialVersionUID = -6203167077077822713L; |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
public JStreetViewPreferencesController(String apiKey) { |
56 |
super();
|
57 |
initialize(apiKey); |
58 |
} |
59 |
|
60 |
private void initialize(String apiKey) { |
61 |
|
62 |
translate(); |
63 |
apiKeyText.setText(apiKey); |
64 |
} |
65 |
|
66 |
/* (non-Javadoc)
|
67 |
* @see org.gvsig.googlemaps.swing.api.JStreetViewPreferences#getApiKey()
|
68 |
*/
|
69 |
@Override
|
70 |
public String getApiKey() { |
71 |
return apiKeyText.getText();
|
72 |
} |
73 |
|
74 |
/* (non-Javadoc)
|
75 |
* @see org.gvsig.tools.swing.api.Component#asJComponent()
|
76 |
*/
|
77 |
@Override
|
78 |
public JComponent asJComponent() { |
79 |
return this; |
80 |
} |
81 |
|
82 |
public void addActionListener(ActionListener listener) { |
83 |
listeners.addActionListener(listener); |
84 |
} |
85 |
|
86 |
public void removeActionListener(ActionListener listener) { |
87 |
listeners.removeActionListener(listener); |
88 |
} |
89 |
|
90 |
private void translate() { |
91 |
apiKeyLbl.setText(ToolsLocator.getI18nManager().getTranslation(apiKeyLbl.getText())); |
92 |
disclaimerText.setText(ToolsLocator.getI18nManager().getTranslation("_google_street_view_disclaimer"));
|
93 |
disclaimerText.addHyperlinkListener(new HyperlinkListener() { |
94 |
|
95 |
@Override
|
96 |
public void hyperlinkUpdate(HyperlinkEvent event) { |
97 |
if (!event.getInputEvent().isConsumed() &&
|
98 |
event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)){
|
99 |
event.getInputEvent().consume(); |
100 |
selectedAction=StreetViewPreferences.PanelAction.SHOW_DISCLAIMER; |
101 |
listeners.fireActionEvent(new ActionEvent(JStreetViewPreferencesController.this, 0, "disclaimer")); |
102 |
} |
103 |
|
104 |
} |
105 |
}); |
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see java.awt.Component#setLocale(java.util.Locale)
|
110 |
*/
|
111 |
@Override
|
112 |
public void setLocale(Locale l) { |
113 |
if(!l.equals(this.getLocale())){ |
114 |
translate(); |
115 |
} |
116 |
super.setLocale(l);
|
117 |
} |
118 |
|
119 |
@Override
|
120 |
public boolean isSelectedAction(PanelAction action) { |
121 |
return action.equals(this.selectedAction); |
122 |
} |
123 |
|
124 |
} |