Revision 102

View differences:

org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.swing.impl.mapserver/src/main/resources/org/gvsig/publish/swing/impl/MapserverLayerPropertiesForm.xml
1850 1850
					<description>Enables debugging of a layer in the current map.
1851 1851
					</description>
1852 1852
					<availableValues>
1853
						<value label="BitMap">BITMAP</value>
1854
						<value label="TrueType">TRUETYPE</value>
1853
						<value label="BITMAP">BITMAP</value>
1854
						<value label="TRUETYPE">TRUETYPE</value>
1855 1855
					</availableValues>
1856 1856
				</field>
1857 1857
				<field name="Font" type="string" mandatory="false"
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.swing.impl.mapserver/src/main/java/org/gvsig/tools/dynform/services/dynformfield/DynFormForCombo/CopyOfJDynFormFieldCacheType.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
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.services.dynformfield.DynFormForCombo;
25

  
26
import java.awt.Dimension;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.util.ArrayList;
30
import java.util.Arrays;
31
import java.util.HashMap;
32
import java.util.List;
33
import java.util.Map;
34

  
35
import javax.swing.BoxLayout;
36
import javax.swing.ComboBoxModel;
37
import javax.swing.DefaultComboBoxModel;
38
import javax.swing.JComboBox;
39
import javax.swing.JComponent;
40
import javax.swing.JPanel;
41
import javax.swing.SwingUtilities;
42

  
43
import org.gvsig.tools.dynform.DynFormFieldDefinition;
44
import org.gvsig.tools.dynform.DynFormLocator;
45
import org.gvsig.tools.dynform.JDynForm;
46
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField;
47
import org.gvsig.tools.dynobject.DynField_v2;
48
import org.gvsig.tools.dynobject.DynObject;
49
import org.gvsig.tools.dynobject.DynObjectValueItem;
50
import org.gvsig.tools.dynobject.DynStruct;
51
import org.gvsig.tools.service.spi.ServiceManager;
52
import org.slf4j.Logger;
53
import org.slf4j.LoggerFactory;
54

  
55
public class CopyOfJDynFormFieldCacheType extends AbstractJDynFormField {
56

  
57
	//	public static String ATTRIBUTE_DISK = "Disk";
58
	//	public static String ATTRIBUTE_DISKLAYOUT = "Disk.Layout";
59
	//	public static String ATTRIBUTE_MEMCACHE = "MemCache";
60
	//	public static String ATTRIBUTE_SQLITE3 = "Sqlite3";
61
	//	public static String ATTRIBUTE_MBTILES = "MBTiles";
62

  
63
	private static final Logger LOG = LoggerFactory
64
			.getLogger(CopyOfJDynFormFieldCacheType.class);
65

  
66
	private static final String TAG_PANEL_ID = "publish.mapcache.choicepanel";
67
	private static final String TAG_FIELD_ID = "publish.mapcache.choicepanel.fieldToMakeCombo";
68

  
69

  
70
	private String FIELD_MODEL = null;
71

  
72
	private String[] attributeNames;
73

  
74
	private DynObject cacheType;
75
	private Map<String, JDynForm> paneles;
76
	private JComboBox combo;
77

  
78
	private DynStruct cacheTypeStruct;
79

  
80
	public CopyOfJDynFormFieldCacheType(DynObject parameters,
81
			ServiceManager serviceManager) {
82
		super(parameters, serviceManager);
83

  
84
		DynFormFieldDefinition def = this.getDefinition();
85
		DynField_v2 cacheTypeDef = (DynField_v2)def;
86
		cacheTypeStruct = cacheTypeDef.getDynClassOfValue();
87

  
88
		if(cacheTypeDef.getTags().has(TAG_FIELD_ID)){
89
			FIELD_MODEL = (String) cacheTypeDef.getTags().get(TAG_FIELD_ID);
90
			initComponent();
91
		}
92

  
93
	}
94

  
95
	public Object getValue() {
96
		DynObjectValueItem valueItem = (DynObjectValueItem) getCombo().getSelectedItem();
97
		cacheType.setDynValue(FIELD_MODEL, valueItem.getValue());
98
		if(this.paneles != null){
99
			JDynForm panel = paneles.get(valueItem.getLabel());
100
			panel.getValues((DynObject) cacheType.getDynValue(valueItem.getLabel()));
101
		}
102
		return cacheType;
103
	}
104

  
105
	public boolean hasValidValue() {
106
		return true;
107
	}
108

  
109
	public void setValue(Object value) {
110
		if( value == null ) {
111
			clear();
112
		} else {
113
			if( !(value instanceof DynObject) ) {
114
				logger.info("setValue invoked with non DynObject value ("+value.toString()+").");
115
				return;
116
			}
117
		}
118

  
119
		if(value instanceof DynObject){
120
			cacheType = (DynObject) value;
121
			if(this.paneles != null){
122
				for(int i=0;i<attributeNames.length; i++){
123
					JDynForm panel = paneles.get(attributeNames[i]);
124
					panel.setValues((DynObject) cacheType.getDynValue(attributeNames[i]));
125
				}
126
			}
127
			String typeName = (String) cacheType.getDynValue(FIELD_MODEL);
128
			ComboBoxModel model = getCombo().getModel();
129
			for(int k=0; k<model.getSize(); k++){
130
				DynObjectValueItem elem = (DynObjectValueItem) model.getElementAt(k);
131
				if(typeName.equalsIgnoreCase((String) elem.getValue())){
132
					this.getCombo().setSelectedIndex(k);
133
					break;
134
				}
135
			}
136

  
137

  
138
		}
139
	}
140

  
141
	@Override
142
	public Object getAssignedValue() {
143
		return getValue();
144
	}
145

  
146
	public void clear(){
147
		if(this.paneles != null){
148
			for(int i=0;i<attributeNames.length; i++){
149
				JDynForm panel = paneles.get(attributeNames[i]);
150
				panel.clear();
151
			}
152
		}
153
		this.getCombo().setSelectedItem(0);
154
	}
155

  
156

  
157
	public void fillAttributeNames(){
158
		if(attributeNames == null){
159
			DynField_v2 typeField = (DynField_v2) cacheTypeStruct.getDynField(FIELD_MODEL);
160
			DynObjectValueItem[] availableValues = typeField.getAvailableValues();
161
			attributeNames = new String[availableValues.length];
162

  
163
			for(int i=0;i<availableValues.length; i++){
164
				attributeNames[i] = (String) typeField.getTags().get(TAG_PANEL_ID+"."+availableValues[i].getLabel());
165
			}
166
		}
167
	}
168

  
169
	public void initComponent() {
170
		fillAttributeNames();
171

  
172
		combo = getCombo();
173
		paneles = new HashMap<String, JDynForm>();
174

  
175
		int height = combo.getPreferredSize().height;
176
		int maxheight = 0;
177
		this.contents = new JPanel();
178
		this.contents.setLayout(new BoxLayout(this.contents, BoxLayout.Y_AXIS));
179
		this.contents.add(combo);
180

  
181
		for(int i=0;i<attributeNames.length; i++){
182
			String panelId = attributeNames[i];
183
			paneles.put(panelId, getPanel(panelId));
184
			JComponent panel = paneles.get(panelId).asJComponent();
185
			this.contents.add(panel);
186
			if( panel.getPreferredSize().height>maxheight) {
187
				maxheight = panel.getPreferredSize().height;
188
			}
189
		}
190

  
191
		maxheight += height;
192
		this.contents.setPreferredSize(new Dimension(this.contents.getPreferredSize().width,maxheight));
193

  
194
		int initialIndex = 0;
195
		List<String> aux = new ArrayList<String>(Arrays.asList(attributeNames));
196
		if(aux.contains(this.getDefinition().getDefaultValue())){
197
			initialIndex = aux.indexOf(this.getDefinition().getDefaultValue());
198
		}
199
		getCombo().setSelectedIndex(initialIndex);
200
	}
201

  
202
	static class TypeItem {
203
		String label;
204
		String value;
205

  
206
		public TypeItem(String label, String value){
207
			this.label = label;
208
			this.value = value;
209
		}
210

  
211
		public String getValue(){
212
			return value;
213
		}
214

  
215
		public String toString(){
216
			return label;
217
		}
218
	}
219

  
220
	@Override
221
	public String getLabel() {
222
		return super.getLabel();
223
	}
224

  
225

  
226
	private JComboBox getCombo() {
227
		if(combo==null){
228
			combo = new JComboBox();
229

  
230
			DynField_v2 fielddef = (DynField_v2)cacheTypeStruct.getDynField(FIELD_MODEL);
231
			DefaultComboBoxModel comboModel = 
232
					new DefaultComboBoxModel(fielddef.getAvailableValues());
233
			combo.setModel(comboModel);
234
			combo.addActionListener(new ActionListener() {
235
				public void actionPerformed(ActionEvent arg0) {
236
					Thread th = new Thread(new Runnable() {
237
						public void run() {
238
							SwingUtilities.invokeLater(new Runnable() {
239
								public void run() {
240
									changeTypeCombo();
241
								}
242
							});
243
						}
244
					});
245
					th.start();
246
				}
247
			});
248
		}
249
		return combo;
250
	}
251

  
252
	protected void changeTypeCombo() {
253
		DynObjectValueItem item = (DynObjectValueItem) getCombo().getSelectedItem();
254
		if(item == null){
255
			return;
256
		}
257
		String selected = item.getLabel();
258
		DynField_v2 fielddef = (DynField_v2)cacheTypeStruct.getDynField(FIELD_MODEL);
259
		String panelID = (String) fielddef.getTags().get(TAG_PANEL_ID+"."+selected);
260
		for(int i=0;i<attributeNames.length; i++){
261
			JDynForm panel = paneles.get(attributeNames[i]);
262
			if(panelID.equalsIgnoreCase(attributeNames[i])){
263
				panel.asJComponent().setVisible(true);
264
			}else{
265
				panel.asJComponent().setVisible(false);
266
			}
267
		}
268
	}
269

  
270
	private JDynForm getPanel(String fieldName) {
271
		JDynForm panel;
272
		DynField_v2 field = (DynField_v2)cacheTypeStruct.getDynField(fieldName);
273
		DynStruct struct = field.getDynClassOfValue();
274
		panel = getJDynComponent(struct);
275

  
276
		panel.setUseScrollBars(false);
277
		panel.asJComponent().setVisible(false);
278
		return panel;
279
	}
280

  
281
	private JDynForm getJDynComponent(DynStruct struct) {
282
		try {
283
			JDynForm owsForm = DynFormLocator.getDynFormManager().createJDynForm(struct);
284
			owsForm.setLayoutMode(JDynForm.USE_PLAIN);
285
			return owsForm;
286
		} catch (Exception e) {
287
			LOG.warn("Error creating the JDynForm with the definition ", e);
288
		}
289

  
290
		return null;
291
	}
292

  
293

  
294

  
295
}
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.swing.impl.mapserver/src/main/java/org/gvsig/publish/swing/impl/mapserver/gui/properties/mapfile/MapserverLayerPropertiesPanel.java
230 230

  
231 231
				DynObject symbolformdata = dynManager.createDynObject(helper.getSymbolDefinition());
232 232
				symbolForm.getValues(symbolformdata);
233

  
233
				int iji =0;
234 234
				helper.copyTo(symbolformdata, symbol);
235 235
				symbolSet.getSymbol().add(symbol);
236 236
			}
......
337 337
	@Override
338 338
	public void applyAction() {
339 339
		if(isEnabledPanel()){
340
			loadAllElements(layerNode);
341
			
340 342
			Layer layer = setPanelsIntoLayer();
341 343
			SymbolSet symbols = setPanelsIntoSymbolSet();
342 344
			if(gvSIGLayer != null){
......
351 353
		gvSIGLayer.setProperty(MAPSERVER_LAYERPANEL_PROPERTIES, isEnabledPanel());
352 354
	}
353 355

  
356
	private void loadAllElements(CustomMutableTreeNode node) {
357
		if (node == null) return;
358

  
359
		for(int i=0; i<node.getChildCount(); i++){
360
			if (node.getChildAt(i) instanceof CustomMutableTreeNode) {
361
				CustomMutableTreeNode customNode = (CustomMutableTreeNode) node.getChildAt(i);
362
				refreshPanel(customNode.getJDynComponent().asJComponent(), customNode);
363
				loadAllElements(customNode);
364
			} 
365
		}
366
	}
367

  
354 368
	private boolean isEnabledPanel() {
355 369
		return getEnablePanelCB().isSelected();
356 370
	}
......
447 461
//				mapserver.getPublishProperties().setConfigureWFSServer(true);
448 462
//				mapserver.getPublishProperties().setConfigureWCSServer(true);
449 463
				mapserver.getMapServer().loadAllServices();
450
				layer = mapserver.makeMapserverPublish(lyr);
464
				layer = mapserver.makeMapserverPublish(lyr, true);
451 465
			}
452 466
			JDynForm layerForm = DynFormLocator.getDynFormManager().createJDynForm(helper.getLayerDefinition());
453 467
			layerForm.setLayoutMode(JDynForm.USE_SEPARATORS);
......
504 518
			top.add(layerNode);
505 519

  
506 520
			symbolNode = new DefaultMutableTreeNode(getSwingManager().getTranslation("Layer Symbols"));
521
			symbolNode.removeAllChildren();
507 522

  
508

  
509 523
			for(int l=0; l<getCurrentSymbolSet(lyr).getSymbol().size();l++){
510 524
				Symbol sym = getCurrentSymbolSet(lyr).getSymbol().get(l);
511 525
				sym = getSharedWithOtherViews(lyr, sym);
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.lib.impl.mapserver/src/main/java/org/gvsig/publish/impl/mapserver/utils/MapServer.java
171 171
	private boolean isEditedLayer;
172 172
	private boolean hasLayer;
173 173
	private boolean hasLabels;
174
	private boolean isPropertiesPanel = false;
174 175

  
175 176

  
176 177

  
......
515 516

  
516 517
					SymbolSet sset = getPublishedSymbol(layer);
517 518
					List<Symbol> symIt = sset.getSymbol();
518
					List<Symbol> aux = new ArrayList<Symbol>();
519 519
					int m=0;
520 520
					while(m<symIt.size()){
521 521
						Symbol sm = (Symbol) symIt.get(m);
522 522
						if(!isSharedWithOtherViews(layer, sm)){
523
							aux.add(sm);
523
							if(!isSymbolInSet(sset, sm)){
524
								sset.getSymbol().add(sm);
525
							}
524 526
						}
525 527
						m++;
526 528
					}
527
					sset.getSymbol().addAll(aux);
528 529

  
529 530
					if(file != null){
530 531
						if(!isAllInSameDocument && isSplitByLayer){
......
556 557
		Layer lyr = new Layer();
557 558
		ItemType itemType = new ItemType();
558 559
		
559
//		if(layer.getParentLayer() != null && layer.getParentLayer().getName() != "root layer"){
560
//			lyr.setGroup("/"+layer.getParentLayer().getName());
560
		if(layer.getParentLayer() != null && layer.getParentLayer().getName() != null && layer.getParentLayer().getName() != "root layer"){
561
			lyr.setGroup("/"+layer.getParentLayer().getName());
561 562
//		}else{
562 563
//			lyr.setGroup("/"+view.getName());
563
//		}
564
		}
564 565

  
565 566
		lyr.setDebug(DEBUG);
566 567
		String extent = "";
......
610 611
			addItemProperty(itemType, "wms_abstract", MapServerUtils.getNameWithoutExtension(layer.getName()));
611 612
			
612 613
			String group = "";
613
			if(layer.getParentLayer() != null && layer.getParentLayer().getName() != "root layer"){
614
			if(layer.getParentLayer() != null && layer.getParentLayer().getName() != null && layer.getParentLayer().getName() != "root layer"){
614 615
				group = "/"+layer.getParentLayer().getName();
615 616
			}else{
616 617
				group= "/"+view.getName();
......
1480 1481
			if (!StringUtils.isBlank(symbolStyle.getType())) {
1481 1482
				String name = null;
1482 1483
				// Busco si existe en el SymbolSet general
1483
				for(int j=0; j<getSymbolSet().getSymbol().size(); j++){
1484
					name = MapserverToDynObjectHelper.equals(getSymbolSet().getSymbol().get(j), symbolStyle);
1484
				if(!this.isPropertiesPanel ){
1485
					for(int j=0; j<getSymbolSet().getSymbol().size(); j++){
1486
						name = MapserverToDynObjectHelper.equals(getSymbolSet().getSymbol().get(j), symbolStyle);
1487
					}
1485 1488
				}
1486 1489
				if( name == null){
1487 1490
					//Busco coincidencias en el symbolset local
......
2283 2286
		}
2284 2287

  
2285 2288
	}
2289

  
2290
	public Layer makepublish(FLayer lyr, boolean b) {
2291
		this.isPropertiesPanel = b;
2292
		return makepublish(lyr);
2293
	}
2286 2294
}
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.lib.impl.mapserver/src/main/java/org/gvsig/publish/impl/mapserver/utils/MapProxy.java
95 95
			writer.write(caches);
96 96
			writer.write("gvsig_additional_caches");
97 97
			
98
			writer.getConfig().setPropertyElementType(
99
					MapProxyConfigurationGlobals.class, "globals", Globals.class);
100 98
			MapProxyConfigurationGlobals globals = new MapProxyConfigurationGlobals();
101 99
			globals.setGlobals(proxy.getGlobals());
102 100
			writer.getConfig().writeConfig.setAutoAnchor(false);
......
153 151
			writer.close();
154 152
			
155 153
			removeHeader(file.getAbsolutePath());
154
			
155
			
156 156
		
157 157
		} catch (Exception e) {
158 158
			// TODO Auto-generated catch block
159 159
			e.printStackTrace();
160 160
		}
161
	
162 161

  
163 162
	}
164 163

  
......
179 178
			boolean isFirst = true;
180 179
			
181 180
			while ((line = br.readLine()) != null) {
182
				if (!isFirst && 
181
				if(line.startsWith("---")){
182
					if(!line.startsWith("--- !")){
183
						line = line.replace("--- ", "#");
184
						pw.println(line);
185
						pw.flush();
186
					}
187
				}else{if (!isFirst && 
183 188
						(!line.contains("{}") && !line.contains("[]")) ) {
184 189
					line = line.replace("'''", "'");
185 190
					pw.println(line);
186 191
					pw.flush();
187
				}
192
				}}
188 193
				isFirst = false;
189 194
			}
190 195
			pw.close();
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.mapserver/org.gvsig.publish.lib.impl.mapserver/src/main/java/org/gvsig/publish/impl/mapserver/MapserverService.java
602 602
		}
603 603
		return map;
604 604
	}
605
	
606
	public Layer makeMapserverPublish(FLayer lyr, boolean b) {
607
		return getMapServer().makepublish(lyr, b);
608
	}
605 609

  
606 610
	public Layer makeMapserverPublish(FLayer lyr) {
607 611
		return getMapServer().makepublish(lyr);
......
639 643
		this.getMapServer().resetCurrentFile();
640 644
	}
641 645

  
646
	
647

  
642 648
}
org.gvsig.publish/trunk/org.gvsig.publish/org.gvsig.publish.app/org.gvsig.publish.app.mainplugin/buildNumber.properties
1 1
#Tue Feb 24 11:26:00 CET 2015
2
buildNumber=28
2
buildNumber=30

Also available in: Unified diff