Revision 25750 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/LabelingManager.java

View differences:

LabelingManager.java
81 81
	private JPanel content;
82 82
	private JPanel pnlNorth;
83 83
	private JComboBox cmbStrategy;
84
	
85 84

  
85

  
86 86
	public LabelingManager() {
87 87
		super();
88 88
		initialize();
......
90 90

  
91 91
	private class LabelingStrategyItem {
92 92
		private ILabelingStrategyPanel strategyPanel;
93
		
93

  
94 94
		private LabelingStrategyItem(ILabelingStrategyPanel strategyPanel) {
95 95
			this.strategyPanel = strategyPanel;
96 96
		}
......
109 109
		}
110 110

  
111 111
	}
112
	
112

  
113 113
	private void initialize() {
114 114
		setLayout(new BorderLayout());
115 115
		strategyPanels = new Hashtable<Class<?>, ILabelingStrategyPanel>();
......
117 117
			try {
118 118
				ILabelingStrategyPanel pnl = (ILabelingStrategyPanel) it.next().newInstance();
119 119
				strategyPanels.put(pnl.getLabelingStrategyClass(), pnl);
120
			} catch (Exception e) { 
120
			} catch (Exception e) {
121 121
				/*
122
				 *  can't happen 
122
				 *  can't happen
123 123
				 *  this should never happen since instantiation and access exceptions have been
124 124
				 *	controlled in the addLabelingStrategy method
125 125
				 */
126 126
				NotificationManager.addError(e);
127 127
			}
128
			
128

  
129 129
		}
130 130
		content = new JPanel(new BorderLayout());
131 131
		content.setBorder(BorderFactory.createEtchedBorder());
......
180 180
					}
181 181
				}
182 182
			};
183
			
183

  
184 184
			cmbStrategy.setName("CMBMODE");
185 185
			cmbStrategy.addActionListener(this);
186 186
		}
......
213 213
			for (ILabelingStrategyPanel p : strategyPanels.values()) {
214 214
				p.setModel(layer,((ILabelable) layer).getLabelingStrategy() );
215 215
			}
216
					
216

  
217 217
			setComponentEnabled(this, true);
218 218
			refreshControls();
219
						
220
			
219

  
220

  
221 221
			ActionEvent evt = new ActionEvent(chkApplyLabels, 0, null);
222 222
			evt.setSource(chkApplyLabels);
223 223
			actionPerformed(evt);
224
			
224

  
225 225
			getCmbStrategy().setSelectedItem(this.layer.getLabelingStrategy());
226 226
			evt.setSource(getCmbStrategy());
227 227
			actionPerformed(evt);
......
230 230
		}
231 231
	}
232 232

  
233
	
234 233

  
234

  
235 235
	private void refreshControls() {
236 236
		if (layer == null) return;
237
		
237

  
238 238
		// enables labeling
239
		getChkApplyLabels().setSelected(layer.isLabeled());
239
		JCheckBox applyLabels = getChkApplyLabels();
240
		applyLabels.setSelected(layer.isLabeled());
240 241
	}
241 242

  
242 243

  
243
	
244
	
244

  
245

  
245 246
	public void actionPerformed(ActionEvent e) {
246 247
		JComponent c = (JComponent)e.getSource();
247 248

  
248 249
		if (c.equals(chkApplyLabels)) {
249 250
			boolean b = chkApplyLabels.isSelected();
250 251
			// enables/disables all components
252
			getCmbStrategy().setEnabled(b);
251 253
			for (int i = 0; i < content.getComponentCount(); i++) {
252 254
				Component c1 = content.getComponent(i);
253 255
				if (!c1.equals(c))
......
260 262
				if (panel!=null) {
261 263
					try {
262 264
						remove(content);
263
						
265

  
264 266
						content.removeAll();
265 267
						content.add((Component) panel);
266 268
						add(content, BorderLayout.CENTER);
......
274 276
			}
275 277
		}
276 278
	}
277
	
279

  
278 280
	public void acceptAction() {
279 281

  
280 282
	}
......
286 288
	public void applyAction() {
287 289
		if (layer != null) { // in other case the layer is not labelable
288 290
			ILabelingStrategyPanel panel = ((LabelingStrategyItem) getCmbStrategy().getSelectedItem()).strategyPanel;
289
			layer.setLabelingStrategy(panel.getLabelingStrategy());
291
			ILabelingStrategy strategy=panel.getLabelingStrategy();
292
			layer.setLabelingStrategy(strategy);
290 293
			layer.setIsLabeled(getChkApplyLabels().isSelected());
291 294
		}
292 295
	}
293 296

  
294
	
297

  
295 298
	public String getName() {
296 299
		return PluginServices.getText(this,"Etiquetados");
297 300
	}

Also available in: Unified diff