Revision 2372
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/tools/util/impl/BaseInformationBuilder.java | ||
---|---|---|
1 |
package org.gvsig.tools.util.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
|
|
9 |
import org.gvsig.tools.ToolsLocator; |
|
10 |
import org.gvsig.tools.util.InformationBuilder; |
|
11 |
|
|
12 |
|
|
13 |
public class BaseInformationBuilder implements InformationBuilder { |
|
14 |
|
|
15 |
private String backgroundColor = "\"#FFFFFF\""; |
|
16 |
private String backgroundColorTitle = "\"#FBFFE1\""; // light yellow |
|
17 |
private String backgroundColorPropertyLabel = "\"#D6D6D6\""; // Gris |
|
18 |
private String backgroundColorPropertyValue1 = "\"#FEEDD6\""; // light salmon |
|
19 |
private String backgroundColorPropertyValue2 = "\"#EAEAEA\""; // light grey |
|
20 |
|
|
21 |
protected int propertyCount = 0; |
|
22 |
protected final List<Element> elements; |
|
23 |
|
|
24 |
protected class BaseTitleElement implements TitleElement { |
|
25 |
|
|
26 |
protected String label; |
|
27 |
|
|
28 |
@Override |
|
29 |
public TitleElement value(String format, Object... args) { |
|
30 |
if (args == null) { |
|
31 |
this.label = format; |
|
32 |
} else { |
|
33 |
this.label = String.format(format, args); |
|
34 |
} |
|
35 |
return this; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public TitleElement label(String label) { |
|
40 |
this.label = StringEscapeUtils.escapeHtml3(label); |
|
41 |
return this; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public TitleElement labelkey(String labelkey) { |
|
46 |
return label(ToolsLocator.getI18nManager().getTranslation(labelkey)); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public String build() { |
|
51 |
propertyCount = 0; |
|
52 |
return "<tr valign=\"middle\" >" |
|
53 |
+ "<td bgcolor=" + backgroundColorTitle + " align=\"center\" colspan=\"2\"><font face=\"Arial\" size=\"3\"><b> " + this.label + "</b></font></td>" |
|
54 |
+ "</tr>"; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
protected class BaseRawElement implements RawElement { |
|
59 |
|
|
60 |
protected String value; |
|
61 |
|
|
62 |
@Override |
|
63 |
public RawElement value(String format, Object... args) { |
|
64 |
if (args == null) { |
|
65 |
this.value = format; |
|
66 |
} else { |
|
67 |
this.value = String.format(format, args); |
|
68 |
} |
|
69 |
return this; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String build() { |
|
74 |
String color = ((propertyCount++ % 2) == 0) ? backgroundColorPropertyValue1 : backgroundColorPropertyValue2; |
|
75 |
String content = "<tr valign=\"top\">\n"; |
|
76 |
content += "<td bgcolor=" + color + "align=\"left\" colspan=\"2\"><font face=\"Arial\" size=\"3\"><div>" + value.replace("\\n", "<br>\n") + "</div></font></td>\n"; |
|
77 |
content += "</tr>\n"; |
|
78 |
return content; |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
protected class BaseTextElement implements TextElement { |
|
83 |
|
|
84 |
protected String value; |
|
85 |
|
|
86 |
@Override |
|
87 |
public TextElement value(String format, Object... args) { |
|
88 |
if (args == null) { |
|
89 |
this.value = StringEscapeUtils.escapeHtml3(format); |
|
90 |
} else { |
|
91 |
this.value = StringEscapeUtils.escapeHtml3(String.format(format, args)); |
|
92 |
} |
|
93 |
return this; |
|
94 |
} |
|
95 |
|
|
96 |
@Override |
|
97 |
public String build() { |
|
98 |
String color = ((propertyCount++ % 2) == 0) ? backgroundColorPropertyValue1 : backgroundColorPropertyValue2; |
|
99 |
String content = "<tr valign=\"top\">\n"; |
|
100 |
content += "<td bgcolor=" + color + "align=\"left\" colspan=\"2\"><font face=\"Arial\" size=\"3\">" + value.replace("\n", "<br>\n") + "</font></td>\n"; |
|
101 |
content += "</tr>\n"; |
|
102 |
return content; |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
protected class BasePropertyElement implements PropertyElement { |
|
107 |
|
|
108 |
protected String label; |
|
109 |
protected boolean monospace = false; |
|
110 |
protected String value; |
|
111 |
|
|
112 |
@Override |
|
113 |
public PropertyElement value(String format, Object... args) { |
|
114 |
if (args == null) { |
|
115 |
this.value = StringEscapeUtils.escapeHtml3(format); |
|
116 |
} else { |
|
117 |
this.value = StringEscapeUtils.escapeHtml3(String.format(format, args)); |
|
118 |
} |
|
119 |
return this; |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public PropertyElement label(String label) { |
|
124 |
this.label = StringEscapeUtils.escapeHtml3(label); |
|
125 |
return this; |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public PropertyElement labelkey(String labelkey) { |
|
130 |
return label(ToolsLocator.getI18nManager().getTranslation(labelkey)); |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public PropertyElement monospace() { |
|
135 |
this.monospace = true; |
|
136 |
return this; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public String build() { |
|
141 |
String color = ((propertyCount++ % 2) == 0) ? backgroundColorPropertyValue1 : backgroundColorPropertyValue2; |
|
142 |
String content = "<tr valign=\"top\">\n"; |
|
143 |
if (!StringUtils.isEmpty(label)) { |
|
144 |
content += "<td nowrap bgcolor=" + backgroundColorPropertyLabel + "align=\"right\" width=\"140\"><font face=\"Arial\" size=\"3\">" + label + ": </font></td>\n"; |
|
145 |
} |
|
146 |
if( this.monospace ) { |
|
147 |
content += "<td bgcolor=" + color + "align=\"left\"><font face=\"Monospaced\" size=\"3\">" + value.replace("\\n", "<br>\n") + "</font></td>"; |
|
148 |
} else { |
|
149 |
content += "<td bgcolor=" + color + "align=\"left\"><font face=\"Arial\" size=\"3\">" + value.replace("\\n", "<br>\n") + "</font></td>"; |
|
150 |
} |
|
151 |
content += "</tr>\n"; |
|
152 |
return content; |
|
153 |
} |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
public BaseInformationBuilder() { |
|
158 |
this.elements = new ArrayList<>(); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public InformationBuilder backgroundColor(String color) { |
|
163 |
this.backgroundColor = color; |
|
164 |
return this; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public InformationBuilder backgroundColorTitle(String color) { |
|
169 |
this.backgroundColorTitle = color; |
|
170 |
return this; |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public InformationBuilder backgroundColorPropertyLabel(String color) { |
|
175 |
this.backgroundColorPropertyLabel = color; |
|
176 |
return this; |
|
177 |
} |
|
178 |
|
|
179 |
@Override |
|
180 |
public InformationBuilder backgroundColorPropertyValue1(String color) { |
|
181 |
this.backgroundColorPropertyValue1 = color; |
|
182 |
return this; |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public InformationBuilder backgroundColorPropertyValue2(String color) { |
|
187 |
this.backgroundColorPropertyValue2 = color; |
|
188 |
return this; |
|
189 |
} |
|
190 |
|
|
191 |
@Override |
|
192 |
public TitleElement title() { |
|
193 |
TitleElement element = new BaseTitleElement(); |
|
194 |
this.elements.add(element); |
|
195 |
return element; |
|
196 |
} |
|
197 |
|
|
198 |
@Override |
|
199 |
public PropertyElement property() { |
|
200 |
PropertyElement element = new BasePropertyElement(); |
|
201 |
this.elements.add(element); |
|
202 |
return element; |
|
203 |
} |
|
204 |
|
|
205 |
@Override |
|
206 |
public TextElement text() { |
|
207 |
TextElement element = new BaseTextElement(); |
|
208 |
this.elements.add(element); |
|
209 |
return element; |
|
210 |
} |
|
211 |
|
|
212 |
@Override |
|
213 |
public RawElement raw() { |
|
214 |
RawElement element = new BaseRawElement(); |
|
215 |
this.elements.add(element); |
|
216 |
return element; |
|
217 |
} |
|
218 |
|
|
219 |
@Override |
|
220 |
public String build() { |
|
221 |
StringBuilder html = new StringBuilder(); |
|
222 |
html.append("<html>\n"); |
|
223 |
html.append("<body bgcolor=").append(backgroundColor).append(" topmargin=\"0\" marginheight=\"0\">\n"); |
|
224 |
html.append("<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"100%\">"); |
|
225 |
boolean first = true; |
|
226 |
for (Element element : elements) { |
|
227 |
if( element instanceof TitleElement ) { |
|
228 |
if( first ) { |
|
229 |
first = false; |
|
230 |
} else { |
|
231 |
html.append("<tr>\n<td><br></td>\n<td></td></tr>\n"); |
|
232 |
} |
|
233 |
} |
|
234 |
html.append(element.build()); |
|
235 |
} |
|
236 |
html.append("</table>"); |
|
237 |
html.append("</body>"); |
|
238 |
html.append("</html>"); |
|
239 |
return html.toString(); |
|
240 |
} |
|
241 |
|
|
242 |
@Override |
|
243 |
public String toString() { |
|
244 |
return this.build(); |
|
245 |
} |
|
246 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/tools/util/impl/DefaultToolsUtilManager.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.tools.util.impl; |
|
3 |
|
|
4 |
import org.gvsig.desktopopen.DefaultDesktopOpen; |
|
5 |
import org.gvsig.desktopopen.DesktopOpen; |
|
6 |
import org.gvsig.htmlbuilder.HTMLBuilder; |
|
7 |
import org.gvsig.htmlbuilder.impl.DefaultHTMLBuilder; |
|
8 |
import org.gvsig.tools.util.InformationBuilder; |
|
9 |
import org.gvsig.tools.util.ToolsUtilManager; |
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* @author fdiaz |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class DefaultToolsUtilManager implements ToolsUtilManager { |
|
17 |
|
|
18 |
@Override |
|
19 |
public InformationBuilder createInformationBuilder() { |
|
20 |
return new BaseInformationBuilder(); |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public DesktopOpen createDesktopOpen() { |
|
25 |
return new DefaultDesktopOpen(); |
|
26 |
} |
|
27 |
|
|
28 |
public HTMLBuilder createHTMLBuilder() { |
|
29 |
DefaultHTMLBuilder x = new DefaultHTMLBuilder(); |
|
30 |
return x; |
|
31 |
} |
|
32 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/tools/util/impl/ToolsUtilLibraryImpl.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 2 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.tools.util.impl; |
|
24 |
|
|
25 |
import org.gvsig.configurableactions.DefaultConfigurableActionsMamager; |
|
26 |
import org.gvsig.euclidean.DefaultEuclideanManager; |
|
27 |
import org.gvsig.filedialogchooser.impl.DefaultFileDialogChooserManager; |
|
28 |
import org.gvsig.imageviewer.DefaultImageViewerManager; |
|
29 |
import org.gvsig.json.JsonManagerImpl; |
|
30 |
import org.gvsig.propertypage.impl.DefaultPropertiesPageManager; |
|
31 |
import org.gvsig.svgsupport.DumbSVGSupportManager; |
|
32 |
import org.gvsig.texteditor.DefaultTextEditorManager; |
|
33 |
import org.gvsig.tools.library.AbstractLibrary; |
|
34 |
import org.gvsig.tools.library.Library; |
|
35 |
import org.gvsig.tools.library.LibraryException; |
|
36 |
import org.gvsig.tools.util.ToolsUtilLibrary; |
|
37 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
38 |
import org.gvsig.webbrowser2.cssbox.CSSBoxWebBrowserManager; |
|
39 |
import org.gvsig.webbrowser2.impl.DefaultWebBrowserManager; |
|
40 |
|
|
41 |
/** |
|
42 |
* {@link Library} for the default tools util implementation. |
|
43 |
* |
|
44 |
* @author gvSIG team |
|
45 |
*/ |
|
46 |
public class ToolsUtilLibraryImpl extends AbstractLibrary { |
|
47 |
|
|
48 |
@Override |
|
49 |
public void doRegistration() { |
|
50 |
super.doRegistration(); |
|
51 |
registerAsImplementationOf(ToolsUtilLibrary.class); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
protected void doInitialize() throws LibraryException { |
|
56 |
ToolsUtilLocator.registerDefaultToolsUtilManager(DefaultToolsUtilManager.class); |
|
57 |
ToolsUtilLocator.registerDefaultFileDialogChooserManager(DefaultFileDialogChooserManager.class); |
|
58 |
ToolsUtilLocator.registerDefaultSVGSupportManager(DumbSVGSupportManager.class); |
|
59 |
ToolsUtilLocator.registerDefaultImageViewerManager(DefaultImageViewerManager.class); |
|
60 |
ToolsUtilLocator.registerDefaultConfigurableActionsMamager(DefaultConfigurableActionsMamager.class); |
|
61 |
ToolsUtilLocator.registerDefaultPropertiesPageManager(DefaultPropertiesPageManager.class); |
|
62 |
ToolsUtilLocator.registerDefaultTextEditorManager(DefaultTextEditorManager.class); |
|
63 |
|
|
64 |
ToolsUtilLocator.registerDefaultWebBrowserManager(DefaultWebBrowserManager.class); |
|
65 |
ToolsUtilLocator.registerWebBrowserManager(CSSBoxWebBrowserManager.class); |
|
66 |
|
|
67 |
ToolsUtilLocator.registerEuclideanManager(DefaultEuclideanManager.class); |
|
68 |
|
|
69 |
ToolsUtilLocator.registerJsonManager(JsonManagerImpl.class); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
protected void doPostInitialize() throws LibraryException { |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/configurableactions/DefaultConfigurableActionsMamager.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.configurableactions; |
|
3 |
|
|
4 |
import java.lang.ref.WeakReference; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collection; |
|
7 |
import java.util.HashMap; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Map; |
|
10 |
import javax.swing.Action; |
|
11 |
import javax.swing.JComponent; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
|
|
14 |
|
|
15 |
public class DefaultConfigurableActionsMamager implements ConfigurableActionsMamager { |
|
16 |
|
|
17 |
private class PanelActions { |
|
18 |
List<Action> actions; |
|
19 |
WeakReference<ActionsComponent> component; |
|
20 |
private final String panelid; |
|
21 |
|
|
22 |
public PanelActions(String panelid) { |
|
23 |
this.panelid = panelid; |
|
24 |
this.actions = new ArrayList<>(); |
|
25 |
} |
|
26 |
|
|
27 |
public void setComponent(ActionsComponent component) { |
|
28 |
this.component = new WeakReference<>(component); |
|
29 |
} |
|
30 |
|
|
31 |
public ActionsComponent getComponent() { |
|
32 |
if( this.component == null ) { |
|
33 |
return null; |
|
34 |
} |
|
35 |
ActionsComponent component = this.component.get(); |
|
36 |
return component; |
|
37 |
} |
|
38 |
|
|
39 |
public void updateComponent() { |
|
40 |
ActionsComponent component = this.getComponent(); |
|
41 |
if( component == null ) { |
|
42 |
return; |
|
43 |
} |
|
44 |
component.update(actions); |
|
45 |
} |
|
46 |
|
|
47 |
public int size() { |
|
48 |
return this.actions.size(); |
|
49 |
} |
|
50 |
|
|
51 |
public Action get(int i) { |
|
52 |
return this.actions.get(i); |
|
53 |
} |
|
54 |
|
|
55 |
public void set(int i, Action action) { |
|
56 |
this.actions.set(i, action); |
|
57 |
this.updateComponent(); |
|
58 |
} |
|
59 |
|
|
60 |
public void add(Action action) { |
|
61 |
this.actions.add(action); |
|
62 |
this.updateComponent(); |
|
63 |
} |
|
64 |
|
|
65 |
public void remove(int i) { |
|
66 |
this.actions.remove(i); |
|
67 |
this.updateComponent(); |
|
68 |
} |
|
69 |
|
|
70 |
public Collection<Action> getActions() { |
|
71 |
return this.actions; |
|
72 |
} |
|
73 |
|
|
74 |
private void removeAll() { |
|
75 |
this.actions.clear(); |
|
76 |
this.updateComponent(); |
|
77 |
} |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
private Map<String,PanelActions> panelsActions; |
|
82 |
|
|
83 |
|
|
84 |
public DefaultConfigurableActionsMamager() { |
|
85 |
this.panelsActions = new HashMap<>(); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public void addConfigurableAction(String panelid, Action action) { |
|
90 |
PanelActions panelActions = this.panelsActions.get(panelid); |
|
91 |
if( panelActions==null ) { |
|
92 |
panelActions = new PanelActions(panelid); |
|
93 |
this.panelsActions.put(panelid, panelActions); |
|
94 |
} |
|
95 |
for( int i=0; i<panelActions.size(); i++ ) { |
|
96 |
Action currentAction = panelActions.get(i); |
|
97 |
if( StringUtils.equalsIgnoreCase( |
|
98 |
(String)currentAction.getValue(Action.ACTION_COMMAND_KEY), |
|
99 |
(String)action.getValue(Action.ACTION_COMMAND_KEY) ) ) { |
|
100 |
panelActions.set(i, action); |
|
101 |
return; |
|
102 |
} |
|
103 |
} |
|
104 |
panelActions.add(action); |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public void removeConfigurableAction(String panelid, String actionName) { |
|
109 |
PanelActions panelActions = this.panelsActions.get(panelid); |
|
110 |
if( panelActions==null ) { |
|
111 |
return; |
|
112 |
} |
|
113 |
for( int i=0; i<panelActions.size(); i++ ) { |
|
114 |
Action currentAction = panelActions.get(i); |
|
115 |
if( StringUtils.equalsIgnoreCase( |
|
116 |
(String)currentAction.getValue(Action.ACTION_COMMAND_KEY), |
|
117 |
actionName ) ) { |
|
118 |
panelActions.remove(i); |
|
119 |
return; |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public void removeAllConfigurableActions(String panelid) { |
|
126 |
PanelActions panelActions = this.panelsActions.get(panelid); |
|
127 |
if( panelActions==null ) { |
|
128 |
return; |
|
129 |
} |
|
130 |
panelActions.removeAll(); |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public Collection<Action> getConfigurableActions(String panelid) { |
|
135 |
PanelActions panelActions = this.panelsActions.get(panelid); |
|
136 |
if( panelActions==null ) { |
|
137 |
panelActions = new PanelActions(panelid); |
|
138 |
this.panelsActions.put(panelid, panelActions); |
|
139 |
} |
|
140 |
return panelActions.getActions(); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public JComponent getConfigurableActionsComponent(String panelid, Object source) { |
|
145 |
PanelActions panelActions = this.panelsActions.get(panelid); |
|
146 |
if( panelActions==null ) { |
|
147 |
panelActions = new PanelActions(panelid); |
|
148 |
this.panelsActions.put(panelid, panelActions); |
|
149 |
} |
|
150 |
ActionsComponent component = new ActionsComponent(panelActions.getActions(), source); |
|
151 |
panelActions.setComponent(component); |
|
152 |
return component; |
|
153 |
} |
|
154 |
|
|
155 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/configurableactions/ActionsComponent.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.configurableactions; |
|
3 |
|
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.MouseAdapter; |
|
6 |
import java.awt.event.MouseEvent; |
|
7 |
import java.net.URL; |
|
8 |
import java.util.Collection; |
|
9 |
import javax.swing.AbstractAction; |
|
10 |
import javax.swing.Action; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.JMenuItem; |
|
14 |
import javax.swing.JPopupMenu; |
|
15 |
import org.gvsig.tools.ToolsLocator; |
|
16 |
import org.gvsig.tools.i18n.I18nManager; |
|
17 |
|
|
18 |
|
|
19 |
public class ActionsComponent extends JLabel { |
|
20 |
|
|
21 |
private final Object source; |
|
22 |
private Collection<Action> actions; |
|
23 |
|
|
24 |
private class ActionListenerAdapter extends AbstractAction { |
|
25 |
|
|
26 |
private final Action action; |
|
27 |
|
|
28 |
public ActionListenerAdapter(Action action) { |
|
29 |
this.action = action; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public void actionPerformed(ActionEvent e) { |
|
34 |
e.setSource(source); |
|
35 |
action.actionPerformed(e); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Object getValue(String key) { |
|
40 |
return action.getValue(key); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public void putValue(String key, Object newValue) { |
|
45 |
action.putValue(key, newValue); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public boolean isEnabled() { |
|
50 |
return action.isEnabled(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void setEnabled(boolean newValue) { |
|
55 |
action.setEnabled(newValue); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
60 |
public ActionsComponent(Collection<Action> actions, Object source) { |
|
61 |
this.source = source; |
|
62 |
this.update(actions); |
|
63 |
this.initComponent(); |
|
64 |
} |
|
65 |
|
|
66 |
private void initComponent() { |
|
67 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
68 |
this.setToolTipText(i18n.getTranslation("_Click_to_see_more_action_in_this_panel")); |
|
69 |
URL url = this.getClass().getResource("/org/gvsig/configurableactions/images/configurableactions.png"); |
|
70 |
this.setIcon(new ImageIcon(url)); |
|
71 |
this.setBorder(null); |
|
72 |
this.addMouseListener(new MouseAdapter() { |
|
73 |
@Override |
|
74 |
public void mouseClicked(MouseEvent e) { |
|
75 |
if( e.getClickCount()==1 && e.getButton()==MouseEvent.BUTTON1 ) { |
|
76 |
doShowMenu(); |
|
77 |
} |
|
78 |
} |
|
79 |
}); |
|
80 |
// this.addActionListener(new ActionListener() { |
|
81 |
// @Override |
|
82 |
// public void actionPerformed(ActionEvent e) { |
|
83 |
// doShowMenu(); |
|
84 |
// } |
|
85 |
// }); |
|
86 |
} |
|
87 |
|
|
88 |
public void update(Collection<Action> actions) { |
|
89 |
this.actions = actions; |
|
90 |
if( actions==null || actions.isEmpty() ) { |
|
91 |
this.setVisible(false); |
|
92 |
} else { |
|
93 |
this.setVisible(true); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
private void doShowMenu() { |
|
98 |
JPopupMenu menu = new JPopupMenu(); |
|
99 |
for (Action action : actions) { |
|
100 |
JMenuItem item = new JMenuItem(new ActionListenerAdapter(action)); |
|
101 |
menu.add(item); |
|
102 |
} |
|
103 |
menu.show(this, 0,this.getHeight()); |
|
104 |
} |
|
105 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/propertypage/impl/DefaultPropertiesPageManager.java | ||
---|---|---|
1 |
package org.gvsig.propertypage.impl; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.lang.reflect.InvocationTargetException; |
|
5 |
import java.lang.reflect.Method; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.Collection; |
|
8 |
import java.util.Collections; |
|
9 |
import java.util.Comparator; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.gvsig.propertypage.PropertiesPage; |
|
15 |
import org.gvsig.propertypage.PropertiesPage.SetPageEnabledEvent; |
|
16 |
import org.gvsig.propertypage.PropertiesPageFactory; |
|
17 |
import org.gvsig.propertypage.PropertiesPageManager; |
|
18 |
import org.gvsig.tools.ToolsLocator; |
|
19 |
import org.gvsig.tools.identitymanagement.SimpleIdentity; |
|
20 |
import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
|
21 |
import org.gvsig.tools.util.Invocable; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class DefaultPropertiesPageManager implements PropertiesPageManager { |
|
26 |
|
|
27 |
private static class DefaultSetPageEnabledEvent extends ActionEvent { |
|
28 |
|
|
29 |
private Invocable filter; |
|
30 |
private boolean enabled; |
|
31 |
|
|
32 |
public DefaultSetPageEnabledEvent(Object source, Invocable filter, boolean enabled ) { |
|
33 |
super(source, SetPageEnabledEvent.ID, SetPageEnabledEvent.ACTION_COMMAND); |
|
34 |
this.filter = filter; |
|
35 |
this.enabled = enabled; |
|
36 |
} |
|
37 |
|
|
38 |
public Invocable getFilter() { |
|
39 |
return filter; |
|
40 |
} |
|
41 |
|
|
42 |
public boolean isEnabled() { |
|
43 |
return enabled; |
|
44 |
} |
|
45 |
|
|
46 |
} |
|
47 |
|
|
48 |
public static final String ACCESS_PAGE_AUTHORIZATION = "propertypage-access"; |
|
49 |
|
|
50 |
private static final Logger logger = LoggerFactory.getLogger(DefaultPropertiesPageManager.class); |
|
51 |
|
|
52 |
private final Map<String, Map<String, PropertiesPageFactory>> groups = new HashMap<>(); |
|
53 |
|
|
54 |
public DefaultPropertiesPageManager() { |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
private String getFactoryName(PropertiesPageFactory factory) { |
|
59 |
String factoryName = factory.getClass().getName(); |
|
60 |
try { |
|
61 |
factoryName = factory.getName(); |
|
62 |
} catch(Throwable ex) { |
|
63 |
|
|
64 |
} |
|
65 |
return factoryName; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public void registerFactory(PropertiesPageFactory factory) { |
|
70 |
logger.info("Register PropertisPageFactory " + factory.getClass().getName() + " , groupID=" + factory.getGroupID() + " (" + factory.toString() + ")."); |
|
71 |
Map<String, PropertiesPageFactory> group = this.getFactories(factory.getGroupID()); |
|
72 |
group.put(getFactoryName(factory), factory); |
|
73 |
} |
|
74 |
|
|
75 |
private Map<String, PropertiesPageFactory> getFactories(String groupID) { |
|
76 |
logger.info("get propeties page factories for groupID '" + groupID + "'"); |
|
77 |
Map<String,PropertiesPageFactory> group = this.groups.get(groupID); |
|
78 |
if (group == null) { |
|
79 |
group = new HashMap<>(); |
|
80 |
this.groups.put(groupID, group); |
|
81 |
} |
|
82 |
return group; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public List<PropertiesPage> getPages(String groupID, Object container, Object data) { |
|
87 |
logger.info("get propeties page for groupID '" + groupID + "', and object '" + ((data==null)?"null":data.toString()) + "'."); |
|
88 |
List<PropertiesPage> pages = new ArrayList<>(); |
|
89 |
SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
|
90 |
SimpleIdentity currentUser = identityManager.getCurrentIdentity(); |
|
91 |
if (!currentUser.isAuthorized(ACCESS_PAGE_AUTHORIZATION,null,groupID ) ) { |
|
92 |
return pages; // Empty list, no access to pages authoriced |
|
93 |
} |
|
94 |
|
|
95 |
Collection<PropertiesPageFactory> factories = this.getFactories(groupID).values(); |
|
96 |
String authorizationId = ACCESS_PAGE_AUTHORIZATION+"-"+groupID; |
|
97 |
for (PropertiesPageFactory factory : factories) { |
|
98 |
String factoryName = getFactoryName(factory); |
|
99 |
try { |
|
100 |
if (factory.isVisible(data)) { |
|
101 |
PropertiesPage page = createPage(factory, container, data); |
|
102 |
if (currentUser.isAuthorized(authorizationId,page, page.getTitle()) ) { |
|
103 |
pages.add(page); |
|
104 |
} |
|
105 |
} |
|
106 |
} catch(Throwable ex) { |
|
107 |
logger.warn("Can't get properties page from factory '"+factoryName+"'.",ex); |
|
108 |
} |
|
109 |
} |
|
110 |
Collections.sort(pages, new Comparator<PropertiesPage>() { |
|
111 |
@Override |
|
112 |
public int compare(PropertiesPage f1, PropertiesPage f2) { |
|
113 |
int n = f2.getPriority() - f1.getPriority(); |
|
114 |
if (n != 0) { |
|
115 |
return n; |
|
116 |
} |
|
117 |
return StringUtils.compareIgnoreCase(f1.getTitle(), f2.getTitle()); |
|
118 |
} |
|
119 |
}); |
|
120 |
return pages; |
|
121 |
} |
|
122 |
|
|
123 |
private PropertiesPage createPage(PropertiesPageFactory factory, Object container, Object data) |
|
124 |
throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException |
|
125 |
{ |
|
126 |
PropertiesPage page; |
|
127 |
try { |
|
128 |
page = factory.create(container, data); |
|
129 |
return page; |
|
130 |
} catch(AbstractMethodError ex) { |
|
131 |
} |
|
132 |
// Antes factory.create llevaba solo un argumento, data. Probamos |
|
133 |
// invocando a ese create. |
|
134 |
Method method = factory.getClass().getMethod("create", Object.class); |
|
135 |
page = (PropertiesPage) method.invoke(factory, data); |
|
136 |
return page; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public ActionEvent createSetPageEnableEvent(PropertiesPage source, Invocable filter, boolean enabled) { |
|
141 |
return new DefaultSetPageEnabledEvent(source, filter, enabled); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public ActionEvent createSetPageEnableEvent(final PropertiesPage source, final Class filterClass, final boolean enabled) { |
|
146 |
return new DefaultSetPageEnabledEvent( |
|
147 |
source, |
|
148 |
new Invocable() { |
|
149 |
@Override |
|
150 |
public Object call(Object... propertiesPages) { |
|
151 |
return filterClass.isInstance(propertiesPages[0]); |
|
152 |
} |
|
153 |
}, |
|
154 |
enabled |
|
155 |
); |
|
156 |
} |
|
157 |
|
|
158 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/filedialogchooser/impl/VFSJFileChooserBased.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.filedialogchooser.impl; |
|
7 |
|
|
8 |
import com.googlecode.vfsjfilechooser2.VFSJFileChooser; |
|
9 |
import com.googlecode.vfsjfilechooser2.filechooser.AbstractVFSFileFilter; |
|
10 |
import java.awt.Component; |
|
11 |
import java.beans.PropertyChangeListener; |
|
12 |
import java.io.File; |
|
13 |
import javax.swing.JComponent; |
|
14 |
import javax.swing.filechooser.FileFilter; |
|
15 |
import org.apache.commons.vfs2.FileObject; |
|
16 |
import org.apache.commons.vfs2.provider.local.LocalFile; |
|
17 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
18 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
|
19 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
20 |
|
|
21 |
|
|
22 |
public class VFSJFileChooserBased implements FileDialogChooser { |
|
23 |
|
|
24 |
private static class FileFilterAdapter extends AbstractVFSFileFilter { |
|
25 |
|
|
26 |
private final FileFilter filter; |
|
27 |
|
|
28 |
FileFilterAdapter(FileFilter filter) { |
|
29 |
this.filter = filter; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public boolean accept(FileObject f) { |
|
34 |
if( f instanceof LocalFile ) { |
|
35 |
return this.filter.accept( new File(f.getName().getPath())); |
|
36 |
} |
|
37 |
return false; |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public String getDescription() { |
|
42 |
return this.filter.getDescription(); |
|
43 |
} |
|
44 |
|
|
45 |
public FileFilter getFilter() { |
|
46 |
return this.filter; |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
private final VFSJFileChooser jfc; |
|
51 |
private final String fileChooserID; |
|
52 |
|
|
53 |
public VFSJFileChooserBased(String fileChooserID) { |
|
54 |
super(); |
|
55 |
this.jfc = new VFSJFileChooser(); |
|
56 |
this.fileChooserID = fileChooserID; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public void setCurrentDirectory(File dir) { |
|
61 |
if( dir == null ) { |
|
62 |
dir = new File(System.getProperty("user.home")); |
|
63 |
} |
|
64 |
this.jfc.setCurrentDirectory(dir); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public File getCurrentDirectory() { |
|
69 |
return this.jfc.getCurrentDirectory(); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public void setDialogTitle(String dialogTitle) { |
|
74 |
this.jfc.setDialogTitle(dialogTitle); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void setDialogType(int dialogType) { |
|
79 |
switch(dialogType) { |
|
80 |
default: |
|
81 |
case OPEN_DIALOG: |
|
82 |
this.jfc.setDialogType(VFSJFileChooser.DIALOG_TYPE.OPEN); |
|
83 |
break; |
|
84 |
case SAVE_DIALOG: |
|
85 |
this.jfc.setDialogType(VFSJFileChooser.DIALOG_TYPE.SAVE); |
|
86 |
break; |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void setDragEnabled(boolean b) { |
|
92 |
this.jfc.setDragEnabled(b); |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public void setFileFilter(FileFilter filter) { |
|
97 |
if( filter == null ) { |
|
98 |
this.jfc.setFileFilter(null); |
|
99 |
} else { |
|
100 |
this.jfc.setFileFilter(new FileFilterAdapter(filter)); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public FileFilter getFileFilter() { |
|
106 |
FileFilterAdapter f = (FileFilterAdapter) this.jfc.getFileFilter(); |
|
107 |
return f.getFilter(); |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public void setFileSelectionMode(int mode) { |
|
112 |
switch(mode) { |
|
113 |
case FILES_ONLY: |
|
114 |
this.jfc.setFileSelectionMode(VFSJFileChooser.SELECTION_MODE.FILES_ONLY); |
|
115 |
break; |
|
116 |
case DIRECTORIES_ONLY: |
|
117 |
this.jfc.setFileSelectionMode(VFSJFileChooser.SELECTION_MODE.DIRECTORIES_ONLY); |
|
118 |
break; |
|
119 |
default: |
|
120 |
case FILES_AND_DIRECTORIES: |
|
121 |
this.jfc.setFileSelectionMode(VFSJFileChooser.SELECTION_MODE.FILES_AND_DIRECTORIES); |
|
122 |
break; |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public File getSelectedFile() { |
|
128 |
return this.jfc.getSelectedFile(); |
|
129 |
} |
|
130 |
|
|
131 |
@Override |
|
132 |
public File[] getSelectedFiles() { |
|
133 |
return this.jfc.getSelectedFiles(); |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public void setFileHidingEnabled(boolean b) { |
|
138 |
this.jfc.setFileHidingEnabled(b); |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public void setMultiSelectionEnabled(boolean b) { |
|
143 |
this.jfc.setMultiSelectionEnabled(b); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public boolean isMultiSelectionEnabled() { |
|
148 |
return this.jfc.isMultiSelectionEnabled(); |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public int showOpenDialog(Component parent) { |
|
153 |
FileDialogChooserManager manager = ToolsUtilLocator.getFileDialogChooserManager(); |
|
154 |
File f = this.getCurrentDirectory(); |
|
155 |
if( f==null ) { |
|
156 |
f = manager.getLastPath(fileChooserID, null); |
|
157 |
this.jfc.setCurrentDirectory(f); |
|
158 |
} |
|
159 |
VFSJFileChooser.RETURN_TYPE r = this.jfc.showOpenDialog(parent); |
|
160 |
if( r == VFSJFileChooser.RETURN_TYPE.CANCEL ) { |
|
161 |
return CANCEL_OPTION; |
|
162 |
} |
|
163 |
if( r == VFSJFileChooser.RETURN_TYPE.APPROVE ) { |
|
164 |
manager.setLastPath(fileChooserID, this.getCurrentDirectory()); |
|
165 |
return APPROVE_OPTION; |
|
166 |
} |
|
167 |
if( r == VFSJFileChooser.RETURN_TYPE.ERROR ) { |
|
168 |
return ERROR_OPTION; |
|
169 |
} |
|
170 |
return ERROR_OPTION; |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public int showSaveDialog(Component parent) { |
|
175 |
FileDialogChooserManager manager = ToolsUtilLocator.getFileDialogChooserManager(); |
|
176 |
File f = manager.getLastPath(fileChooserID, this.getCurrentDirectory()); |
|
177 |
this.jfc.setCurrentDirectory(f); |
|
178 |
VFSJFileChooser.RETURN_TYPE r = this.jfc.showSaveDialog(parent); |
|
179 |
if( r == VFSJFileChooser.RETURN_TYPE.CANCEL ) { |
|
180 |
return CANCEL_OPTION; |
|
181 |
} |
|
182 |
if( r == VFSJFileChooser.RETURN_TYPE.APPROVE ) { |
|
183 |
manager.setLastPath(fileChooserID, this.getCurrentDirectory()); |
|
184 |
return APPROVE_OPTION; |
|
185 |
} |
|
186 |
if( r == VFSJFileChooser.RETURN_TYPE.ERROR ) { |
|
187 |
return ERROR_OPTION; |
|
188 |
} |
|
189 |
return ERROR_OPTION; |
|
190 |
} |
|
191 |
|
|
192 |
@Override |
|
193 |
public void setAcceptAllFileFilterUsed(boolean b) { |
|
194 |
this.jfc.setAcceptAllFileFilterUsed(b); |
|
195 |
} |
|
196 |
|
|
197 |
@Override |
|
198 |
public void addChoosableFileFilter(FileFilter next) { |
|
199 |
this.jfc.addChoosableFileFilter(new FileFilterAdapter(next)); |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
204 |
this.jfc.addPropertyChangeListener(listener); |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void setAccessory(JComponent newAccessory) { |
|
209 |
this.jfc.setAccessory(newAccessory); |
|
210 |
} |
|
211 |
|
|
212 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/filedialogchooser/impl/JFileChooserBased.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.filedialogchooser.impl; |
|
7 |
|
|
8 |
import java.awt.Component; |
|
9 |
import java.awt.HeadlessException; |
|
10 |
import java.io.File; |
|
11 |
import javax.swing.JFileChooser; |
|
12 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
13 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
|
14 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
public class JFileChooserBased extends JFileChooser implements FileDialogChooser { |
|
20 |
|
|
21 |
private static final long serialVersionUID = 2825200958209418322L; |
|
22 |
private final String fileChooserID; |
|
23 |
|
|
24 |
public JFileChooserBased(String fileChooserID) { |
|
25 |
super(); |
|
26 |
this.fileChooserID = fileChooserID; |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
public int showOpenDialog(Component parent) throws HeadlessException { |
|
31 |
FileDialogChooserManager manager = ToolsUtilLocator.getFileDialogChooserManager(); |
|
32 |
File f = this.getCurrentDirectory(); |
|
33 |
if( f==null ) { |
|
34 |
f = manager.getLastPath(fileChooserID, null); |
|
35 |
super.setCurrentDirectory(f); |
|
36 |
} |
|
37 |
int r = super.showOpenDialog(parent); |
|
38 |
if( r == JFileChooser.APPROVE_OPTION ) { |
|
39 |
manager.setLastPath(fileChooserID, this.getCurrentDirectory()); |
|
40 |
} |
|
41 |
return r; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public int showSaveDialog(Component parent) throws HeadlessException { |
|
46 |
FileDialogChooserManager manager = ToolsUtilLocator.getFileDialogChooserManager(); |
|
47 |
File f = manager.getLastPath(fileChooserID, this.getCurrentDirectory()); |
|
48 |
super.setCurrentDirectory(f); int r = super.showSaveDialog(parent); |
|
49 |
if( r == JFileChooser.APPROVE_OPTION ) { |
|
50 |
manager.setLastPath(fileChooserID, this.getCurrentDirectory()); |
|
51 |
} |
|
52 |
return r; |
|
53 |
} |
|
54 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/filedialogchooser/impl/DefaultFileDialogChooserManager.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.filedialogchooser.impl; |
|
3 |
|
|
4 |
import java.io.File; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.Map; |
|
7 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
|
8 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
|
9 |
import org.gvsig.tools.ToolsLocator; |
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
public class DefaultFileDialogChooserManager implements FileDialogChooserManager { |
|
14 |
|
|
15 |
private Map<String,File> lastPaths; |
|
16 |
private boolean useNativeFileChooser = true; |
|
17 |
|
|
18 |
public DefaultFileDialogChooserManager() { |
|
19 |
this.lastPaths = new HashMap<>(); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public void setUseNativeFileChooser(boolean b) { |
|
24 |
useNativeFileChooser = b; |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public boolean useNativeFileChooser() { |
|
29 |
return useNativeFileChooser; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public FileDialogChooser create(String fileChooserID) { |
|
34 |
if( useNativeFileChooser ) { |
|
35 |
return new JFileChooserBased(fileChooserID); |
|
36 |
} |
|
37 |
return new VFSJFileChooserBased(fileChooserID); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public FileDialogChooser create() { |
|
42 |
String fileChooserID = "DEFAULT_ID"; |
|
43 |
if( useNativeFileChooser ) { |
|
44 |
return new JFileChooserBased(fileChooserID); |
|
45 |
} |
|
46 |
return new VFSJFileChooserBased(fileChooserID); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public File getLastPath(String fileChooserID, File defaultDirectory) { |
|
51 |
return ToolsLocator.getFoldersManager().getLastPath(fileChooserID, defaultDirectory); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void setLastPath(String fileChooserID, File path) { |
|
56 |
ToolsLocator.getFoldersManager().setLastPath(fileChooserID, path); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/webbrowser2/cssbox/CSSBoxWebBrowserManager.java | ||
---|---|---|
1 |
package org.gvsig.webbrowser2.cssbox; |
|
2 |
|
|
3 |
import org.gvsig.webbrowser2.WebBrowserManager; |
|
4 |
import org.gvsig.webbrowser2.WebBrowserPanel; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author gvSIG Team |
|
9 |
*/ |
|
10 |
public class CSSBoxWebBrowserManager implements WebBrowserManager { |
|
11 |
|
|
12 |
@Override |
|
13 |
public WebBrowserPanel createWebBrowserPanel() { |
|
14 |
// return new CSSBoxWebBrowserPanel(); |
|
15 |
return null; |
|
16 |
} |
|
17 |
|
|
18 |
|
|
19 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/webbrowser2/cssbox/CSSBoxWebBrowserPanel.java | ||
---|---|---|
1 |
package org.gvsig.webbrowser2.cssbox; |
|
2 |
|
|
3 |
import javax.swing.JComponent; |
|
4 |
//import org.fit.cssbox.swingbox.BrowserPane; |
|
5 |
import org.gvsig.webbrowser2.WebBrowserPanel; |
|
6 |
import org.gvsig.webbrowser2.impl.DefaultWebBrowserPanel; |
|
7 |
|
|
8 |
public class CSSBoxWebBrowserPanel extends DefaultWebBrowserPanel implements WebBrowserPanel { |
|
9 |
|
|
10 |
public CSSBoxWebBrowserPanel() { |
|
11 |
|
|
12 |
} |
|
13 |
|
|
14 |
@Override |
|
15 |
protected JComponent createBrowserPanel() { |
|
16 |
// return new BrowserPane(); |
|
17 |
return null; |
|
18 |
} |
|
19 |
// |
|
20 |
// @Override |
|
21 |
// protected BrowserPane getBrowser() { |
|
22 |
// return (BrowserPane) super.getBrowser(); |
|
23 |
// } |
|
24 |
|
|
25 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.257/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/webbrowser2/impl/DefaultWebBrowserPanelView.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<object classname="com.jeta.forms.store.memento.FormPackage"> |
|
4 |
<at name="fileversion"> |
|
5 |
<object classname="com.jeta.forms.store.memento.FormsVersion2"> |
|
6 |
<at name="major">2</at> |
|
7 |
<at name="minor">0</at> |
|
8 |
<at name="sub">0</at> |
|
9 |
</object> |
|
10 |
</at> |
|
11 |
<at name="form"> |
|
12 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
13 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
14 |
<at name="cellconstraints"> |
|
15 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
16 |
<at name="column">1</at> |
|
17 |
<at name="row">1</at> |
|
18 |
<at name="colspan">1</at> |
|
19 |
<at name="rowspan">1</at> |
|
20 |
<at name="halign">default</at> |
|
21 |
<at name="valign">default</at> |
|
22 |
<at name="insets" object="insets">0,0,0,0</at> |
|
23 |
</object> |
|
24 |
</at> |
|
25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
26 |
</super> |
|
27 |
<at name="id">/home/jjdelcerro/gvSIG/plugins/org.gvsig.scripting.app.mainplugin/scripts/addons/ScriptingComposerTools/javadocviewer/webbrowserpanel/browserpanel.xml</at> |
|
28 |
<at name="path">addons/ScriptingComposerTools/javadocviewer/webbrowserpanel/browserpanel.xml</at> |
|
29 |
<at name="rowspecs">CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE</at> |
|
30 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE</at> |
|
31 |
<at name="components"> |
|
32 |
<object classname="java.util.LinkedList"> |
|
33 |
<item > |
|
34 |
<at name="value"> |
|
35 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
36 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
37 |
<at name="cellconstraints"> |
|
38 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
39 |
<at name="column">8</at> |
|
40 |
<at name="row">2</at> |
|
41 |
<at name="colspan">1</at> |
|
42 |
<at name="rowspan">1</at> |
|
43 |
<at name="halign">default</at> |
|
44 |
<at name="valign">default</at> |
|
45 |
<at name="insets" object="insets">0,0,0,0</at> |
|
46 |
</object> |
|
47 |
</at> |
|
48 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
49 |
</super> |
|
50 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
51 |
<at name="beanclass">javax.swing.JTextField</at> |
|
52 |
<at name="beanproperties"> |
|
53 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
54 |
<at name="classname">javax.swing.JTextField</at> |
|
55 |
<at name="properties"> |
|
56 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
57 |
<at name="border"> |
|
58 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
59 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
60 |
<at name="name">border</at> |
|
61 |
</super> |
|
62 |
<at name="borders"> |
|
63 |
<object classname="java.util.LinkedList"> |
|
64 |
<item > |
|
65 |
<at name="value"> |
|
66 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
67 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
68 |
<at name="name">border</at> |
|
69 |
</super> |
|
70 |
</object> |
|
71 |
</at> |
|
72 |
</item> |
|
73 |
</object> |
|
74 |
</at> |
|
75 |
</object> |
|
76 |
</at> |
|
77 |
<at name="name">txtURL</at> |
|
78 |
<at name="width">843</at> |
|
79 |
<at name="height">20</at> |
|
80 |
</object> |
|
81 |
</at> |
|
82 |
</object> |
|
83 |
</at> |
|
84 |
</object> |
|
85 |
</at> |
|
86 |
</item> |
|
87 |
<item > |
|
88 |
<at name="value"> |
|
89 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
90 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
91 |
<at name="cellconstraints"> |
|
92 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
93 |
<at name="column">2</at> |
|
94 |
<at name="row">4</at> |
|
95 |
<at name="colspan">9</at> |
|
96 |
<at name="rowspan">1</at> |
|
97 |
<at name="halign">fill</at> |
|
98 |
<at name="valign">fill</at> |
|
99 |
<at name="insets" object="insets">0,0,0,0</at> |
|
100 |
</object> |
|
101 |
</at> |
|
102 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
103 |
</super> |
|
104 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
105 |
<at name="beanclass">javax.swing.JPanel</at> |
|
106 |
<at name="beanproperties"> |
|
107 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
108 |
<at name="classname">javax.swing.JPanel</at> |
|
109 |
<at name="properties"> |
|
110 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
111 |
<at name="name">containerBrowser</at> |
|
112 |
<at name="width">935</at> |
|
113 |
<at name="height">466</at> |
|
114 |
</object> |
|
115 |
</at> |
|
116 |
</object> |
|
117 |
</at> |
|
118 |
</object> |
|
119 |
</at> |
|
120 |
</item> |
|
121 |
<item > |
|
122 |
<at name="value"> |
|
123 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
124 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
125 |
<at name="cellconstraints"> |
|
126 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
127 |
<at name="column">2</at> |
|
128 |
<at name="row">6</at> |
|
129 |
<at name="colspan">9</at> |
|
130 |
<at name="rowspan">1</at> |
|
131 |
<at name="halign">default</at> |
|
132 |
<at name="valign">default</at> |
|
133 |
<at name="insets" object="insets">0,0,0,0</at> |
|
134 |
</object> |
|
135 |
</at> |
|
136 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
137 |
</super> |
|
138 |
<at name="id">embedded.1838006420</at> |
|
139 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
|
140 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MIN(12DLU;DEFAULT):GROW(0.3),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.7)</at> |
|
141 |
<at name="components"> |
|
142 |
<object classname="java.util.LinkedList"> |
|
143 |
<item > |
|
144 |
<at name="value"> |
|
145 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
146 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
147 |
<at name="cellconstraints"> |
|
148 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
149 |
<at name="column">3</at> |
|
150 |
<at name="row">1</at> |
|
151 |
<at name="colspan">1</at> |
|
152 |
<at name="rowspan">1</at> |
|
153 |
<at name="halign">default</at> |
|
154 |
<at name="valign">default</at> |
|
155 |
<at name="insets" object="insets">0,0,0,0</at> |
|
156 |
</object> |
|
157 |
</at> |
|
158 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
159 |
</super> |
|
160 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
161 |
<at name="beanclass">javax.swing.JTextField</at> |
|
162 |
<at name="beanproperties"> |
|
163 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
164 |
<at name="classname">javax.swing.JTextField</at> |
|
165 |
<at name="properties"> |
|
166 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
167 |
<at name="border"> |
|
168 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
169 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
170 |
<at name="name">border</at> |
|
171 |
</super> |
|
172 |
<at name="borders"> |
|
173 |
<object classname="java.util.LinkedList"> |
|
174 |
<item > |
|
175 |
<at name="value"> |
|
176 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
177 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
178 |
<at name="name">border</at> |
|
179 |
</super> |
|
180 |
</object> |
|
181 |
</at> |
|
182 |
</item> |
|
183 |
</object> |
|
184 |
</at> |
|
185 |
</object> |
|
186 |
</at> |
|
187 |
<at name="name">txtSearch</at> |
|
188 |
<at name="width">259</at> |
|
189 |
<at name="height">20</at> |
|
190 |
</object> |
|
191 |
</at> |
|
192 |
</object> |
|
193 |
</at> |
|
194 |
</object> |
|
195 |
</at> |
|
196 |
</item> |
|
197 |
<item > |
|
198 |
<at name="value"> |
|
199 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
200 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
201 |
<at name="cellconstraints"> |
|
202 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
203 |
<at name="column">9</at> |
|
204 |
<at name="row">1</at> |
|
205 |
<at name="colspan">1</at> |
|
206 |
<at name="rowspan">1</at> |
|
207 |
<at name="halign">fill</at> |
|
208 |
<at name="valign">fill</at> |
|
209 |
<at name="insets" object="insets">0,0,0,0</at> |
|
210 |
</object> |
|
211 |
</at> |
|
212 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
213 |
</super> |
|
214 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
215 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
216 |
<at name="beanproperties"> |
|
217 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
218 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
219 |
<at name="properties"> |
|
220 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
221 |
<at name="border"> |
|
222 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
223 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
224 |
<at name="name">border</at> |
|
225 |
</super> |
|
226 |
<at name="borders"> |
|
227 |
<object classname="java.util.LinkedList"> |
|
228 |
<item > |
|
229 |
<at name="value"> |
|
230 |
<object classname="com.jeta.forms.store.properties.LineBorderProperty"> |
|
231 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
232 |
<at name="name">border</at> |
|
233 |
</super> |
|
234 |
<at name="thickness">1</at> |
|
235 |
<at name="color"> |
|
236 |
<object classname="com.jeta.forms.store.properties.ColorProperty"> |
|
237 |
<at name="name">dyncolor</at> |
|
238 |
<at name="colorkey">Button.shadow</at> |
|
239 |
</object> |
|
240 |
</at> |
|
241 |
<at name="curved">false</at> |
|
242 |
</object> |
|
243 |
</at> |
|
244 |
</item> |
|
245 |
<item > |
|
246 |
<at name="value"> |
|
247 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
248 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
249 |
<at name="name">border</at> |
|
250 |
</super> |
|
251 |
</object> |
|
252 |
</at> |
|
253 |
</item> |
|
254 |
</object> |
|
255 |
</at> |
|
256 |
</object> |
|
257 |
</at> |
|
258 |
<at name="name">lblStatus</at> |
|
259 |
<at name="width">587</at> |
|
260 |
<at name="fill"> |
|
261 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
262 |
<at name="name">fill</at> |
|
263 |
</object> |
|
264 |
</at> |
|
265 |
<at name="height">20</at> |
|
266 |
</object> |
|
267 |
</at> |
|
268 |
</object> |
|
269 |
</at> |
|
270 |
</object> |
|
271 |
</at> |
|
272 |
</item> |
|
273 |
<item > |
|
274 |
<at name="value"> |
|
275 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
276 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
277 |
<at name="cellconstraints"> |
|
278 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
279 |
<at name="column">1</at> |
|
280 |
<at name="row">1</at> |
|
281 |
<at name="colspan">1</at> |
|
282 |
<at name="rowspan">1</at> |
|
283 |
<at name="halign">default</at> |
|
284 |
<at name="valign">default</at> |
|
285 |
<at name="insets" object="insets">0,0,0,0</at> |
|
286 |
</object> |
|
287 |
</at> |
|
288 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
289 |
</super> |
|
290 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
291 |
<at name="beanclass">com.jeta.forms.components.image.ImageComponent</at> |
|
292 |
<at name="beanproperties"> |
|
293 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
294 |
<at name="classname">com.jeta.forms.components.image.ImageComponent</at> |
|
295 |
<at name="properties"> |
|
296 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
297 |
<at name="border"> |
|
298 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
Also available in: Unified diff