Revision 37845 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/General.java

View differences:

General.java
60 60
import javax.swing.BorderFactory;
61 61
import javax.swing.ButtonGroup;
62 62
import javax.swing.JCheckBox;
63
import javax.swing.JComboBox;
64 63
import javax.swing.JLabel;
65 64
import javax.swing.JPanel;
66 65
import javax.swing.JRadioButton;
......
83 82
import com.iver.andami.messages.NotificationManager;
84 83
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
85 84
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
86
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver;
87
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver;
88 85
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
89 86
import com.iver.cit.gvsig.fmap.layers.FLayer;
90 87
import com.iver.cit.gvsig.fmap.layers.FLyrDefault;
......
93 90
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
94 91
import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter;
95 92
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter;
96
import com.iver.cit.gvsig.project.documents.view.IProjectView;
97 93
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask;
98 94
import com.iver.utiles.swing.threads.IMonitorableTask;
99 95

  
......
107 103
 * with the properties of the layer.
108 104
 * @author jmorell
109 105
 *
110
 * TODO To change the template for this generated type comment go to
111
 * Window - Preferences - Java - Code Style - Code Templates
112 106
 */
113 107
public class General extends AbstractThemeManagerPage {
114 108

  
115 109
	private static final long serialVersionUID = 1L;
116 110
    private FLayer layer;
117
	private IProjectView view;
118
	private NumberFormat nf = NumberFormat.getInstance();
111
    private NumberFormat nf = NumberFormat.getInstance();
119 112
	private JPanel pnlLayerName = null;
120 113
	private GridBagLayoutPanel pnlScale = null;
121 114
	private JPanel pnlProperties = null;
......
126 119
	private JRadioButton rdBtnShowAlways = null;
127 120
	private JRadioButton rdBtnDoNotShow = null;
128 121
	private JTextField txtMinScale = null;
129
	private JComboBox cmbLinkField = null;
130
    private JTextField txtLinkExtension = null;
131
    private JComboBox cmbLinkType = null;
132 122
    private JCheckBox jCheckBoxSpatialIndex = null;
133
	private JPanel pnlHyperLink;
134
	private JLabel lblLinkExtension;
135
	private JLabel lblLinkField;
136
	private JLabel lblDefaultAction;
137
	private JPanel pnlFieldAndExtension;
138
	private JPanel pnlHyperLinkAction;
139
	private JScrollPane scrlProperties;
123
    private JScrollPane scrlProperties;
140 124

  
141
    /**
142
	 * This is the default constructor.
143
	 */
125

  
144 126
	public General() {
145 127
		super();
146 128
		initialize();
147 129
	}
148
	/**
149
	 * This method initializes this
150
	 *
151
	 * @return void
152
	 */
130

  
153 131
	private  void initialize() {
154 132
		this.setLayout(new BorderLayout());
155 133
		GridBagLayoutPanel aux = new GridBagLayoutPanel();
......
157 135
		aux.addComponent(new JBlank(10, 10));
158 136
		aux.addComponent(getJCheckBoxSpatialIndex());
159 137
		aux.addComponent("", getPnlScale());
160
//		JPanel aux2 = new JPanel(new GridLayout(1,1));
161
//		aux2.add(getPnlProperties());
162
//		aux2.add(getPnlHyperLink());
163
//		aux.addComponent("", aux2);
164

  
165 138
		aux.addComponent("", getPnlProperties());
166

  
167

  
168

  
169 139
		aux.setPreferredSize(getPreferredSize());
170 140
		this.add(aux, BorderLayout.CENTER);
171 141
		this.add(new JBlank(5, 10), BorderLayout.WEST);
172 142
		this.add(new JBlank(5, 10), BorderLayout.EAST);
173

  
174 143
	}
175 144

  
176 145

  
......
209 178
		}
210 179
		txtLayerName.setText(layer.getName());
211 180
		showLayerInfo();
181
    }
212 182

  
213 183

  
214
		// old hyperlink stuff
215
//		if (PluginServices.getMainFrame() != null)
216
//		if  (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){
217
//		    BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow();
218
//		    view = theView.getModel();
219
//            try {
220
//                if (layer instanceof AlphanumericData) {
221
//                    AlphanumericData ad = (AlphanumericData) layer;
222
//                    DataSource ds;
223
//                    ds = ad.getRecordset();
224
//                    String[] names = new String[ds.getFieldCount()];
225
//                    for (int i = 0; i < ds.getFieldCount(); i++) {
226
//                        names[i] = ds.getFieldName(i);
227
//                    }
228
//                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
229
//                    cmbLinkField.setModel(defaultModel);
230
//
231
//                    if (layer.getLinkProperties().getField()!=null)
232
//                    	cmbLinkField.setSelectedItem(layer.getLinkProperties().getField());
233
//                    else
234
//                    	cmbLinkField.setSelectedItem(view.getSelectedField());
235
//                } else {
236
//                    cmbLinkField = new JComboBox();
237
//                }
238
//             } catch (ReadDriverException e) {
239
//                NotificationManager.addError("No se pudo obtener la tabla", e);
240
//            }
241
//
242
//
243
//            if(layer.getLinkProperties().getExt()!=null)
244
//            	getTxtLinkExtension().setText(layer.getLinkProperties().getExt());
245
//
246
//            getCmbLinkType().addItem(PluginServices.getText(this,
247
//               	"Enlazar_a_ficheros_de_imagen"));
248
//            getCmbLinkType().addItem(PluginServices.getText(this,
249
//            	"Enlazar_a_fichero_de_texto"));
250
//
251
//            getCmbLinkType().addItem(PluginServices.getText(this,
252
//            	"Enlazar_a_documento_PDF"));
253
//            getCmbLinkType().addItem(PluginServices.getText(this,
254
//        		"Enlazar_a_imagen_SVG"));
255
//
256
//            if (layer.getLinkProperties().getType()!=-1)
257
//            	getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType());
258
//
259
//		}
260

  
261
	}
262

  
263
	/**
264
	 * This method initializes jPanel
265
	 *
266
	 * @return javax.swing.JPanel
267
	 */
268 184
	private JPanel getPnlLayerName() {
269 185
		if (pnlLayerName == null) {
270 186
			lblLayerName = new JLabel();
......
277 193
		}
278 194
		return pnlLayerName;
279 195
	}
280
	/**
281
	 * This method initializes jPanel1
282
	 *
283
	 * @return javax.swing.JPanel
284
	 */
196

  
285 197
	private GridBagLayoutPanel getPnlScale() {
286 198
		if (pnlScale == null) {
287 199
			pnlScale = new GridBagLayoutPanel();
......
323 235
		}
324 236
		return pnlScale;
325 237
	}
326
	/**
327
	 * This method initializes jPanel2, this contains the ScrollPane with the
328
	 * properies.
329
	 *
330
	 * @return javax.swing.JPanel
331
	 */
238
	
239
    /**
240
     * This method initializes pnlProperties, the jpanel which contains the
241
     * ScrollPane with the properties.
242
     */
332 243
	private JPanel getPnlProperties() {
333 244
		if (pnlProperties == null) {
334 245
			pnlProperties = new JPanel(new GridBagLayout());
......
340 251
				);
341 252
			GridBagConstraints constraints = new GridBagConstraints();
342 253
			constraints.insets = new Insets(5, 5, 5, 5);
343
			constraints.fill = constraints.BOTH;
254
	    constraints.fill = GridBagConstraints.BOTH;
344 255
			constraints.weightx = 1.0;
345 256
			constraints.weighty = 1.0;
346 257
			pnlProperties.add(getScrlProperties(), constraints);
......
348 259
		return pnlProperties;
349 260
	}
350 261

  
351
	/**
352
	 * This method initializes jTextField
353
	 *
354
	 * @return javax.swing.JTextField
355
	 */
356 262
	private JTextField getTxtLayerName() {
357 263
		if (txtLayerName == null) {
358 264
			txtLayerName = new JTextField(25);
......
361 267
		return txtLayerName;
362 268
	}
363 269

  
364
	/**
365
	 * This method initializes TxtMaxScale
366
	 * @return jTextField1
367
	 */
368 270
	private JTextField getTxtMaxScale() {
369 271
		if (txtMaxScale == null) {
370 272
			txtMaxScale = new JTextField(15);
......
372 274
		}
373 275
		return txtMaxScale;
374 276
	}
375
	/**
376
	 * This method initilizes TxtArea, in this TextArea sets the text with
377
	 * the properties of the layer
378
	 * @return
379
	 */
277
	
278
    /**
279
     * This method initializes propertiesTextArea, where are display the
280
     * properties of the layer
281
     */
380 282
	private JTextArea getPropertiesTextArea() {
381 283
		if (propertiesTextArea == null) {
382 284
			propertiesTextArea = new JTextArea();
......
387 289
		return propertiesTextArea;
388 290
	}
389 291

  
390
	/**
391
	 * This method initializes jScrollPane
392
	 *
393
	 * @return javax.swing.JScrollPane
394
	 */
395 292
	private JScrollPane getScrlProperties() {
396 293
		if (scrlProperties == null) {
397 294
			scrlProperties = new JScrollPane();
......
401 298
		}
402 299
		return scrlProperties;
403 300
	}
404
	/**
405
	 * This method initializes jRadioButton
406
	 *
407
	 * @return javax.swing.JRadioButton
408
	 */
301

  
409 302
	private JRadioButton getRdBtnShowAlways() {
410 303
		if (rdBtnShowAlways == null) {
411 304
			rdBtnShowAlways = new JRadioButton();
......
420 313
		}
421 314
		return rdBtnShowAlways;
422 315
	}
423
	/**
424
	 * This method initializes jRadioButton1
425
	 *
426
	 * @return javax.swing.JRadioButton
427
	 */
316

  
428 317
	private JRadioButton getRdBtnDoNotShowWhen() {
429 318
		if (rdBtnDoNotShow == null) {
430 319
			rdBtnDoNotShow = new JRadioButton();
......
438 327
		}
439 328
		return rdBtnDoNotShow;
440 329
	}
441
	/**
442
	 * This method initializes jTextField2
443
	 *
444
	 * @return javax.swing.JTextField
445
	 */
330

  
446 331
	private JTextField getTxtMinScale() {
447 332
		if (txtMinScale == null) {
448 333
			txtMinScale = new JTextField(15);
......
454 339
	private String getLayerName(){
455 340
		return txtLayerName.getText().toString();
456 341
	}
457
    /**
458
     * This method initializes jPanel3, this panel contains the components of the
459
     * HyperLink
460
     *
461
     * @return javax.swing.JPanel
462
     */
463
    private JPanel getPnlHyperLink() {
464
    	if (pnlHyperLink == null) {
465
    		pnlHyperLink = new JPanel();
466
    		pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
467
    				BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
468
    					PluginServices.getText(this, "Hiperenlace"),
469
    					TitledBorder.DEFAULT_JUSTIFICATION,
470
    					TitledBorder.DEFAULT_POSITION, null, null)
471
    				);
472
    		JPanel aux = new JPanel(new BorderLayout());
473
    		pnlHyperLink.setLayout(new BorderLayout());
474
    		aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
475
    		aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
476
    		aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
477
    		pnlHyperLink.add(aux);
478
    	}
479
    	return pnlHyperLink;
480
    }
481 342

  
482 343

  
483
    private JPanel getPnlFieldAndExtension() {
484
    	if (pnlFieldAndExtension == null) {
485
    		lblLinkExtension = new JLabel();
486
    		lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension"));
487
    		lblLinkField = new JLabel();
488
    		lblLinkField.setText(PluginServices.getText(this, "Campo"));
489
    		pnlFieldAndExtension = new JPanel();
490
    		pnlFieldAndExtension.add(lblLinkField, null);
491
    		pnlFieldAndExtension.add(getCmbLinkField(), null);
492
    		pnlFieldAndExtension.add(lblLinkExtension, null);
493
    		pnlFieldAndExtension.add(getTxtLinkExtension(), null);
494
    	}
495
    	return pnlFieldAndExtension;
496
    }
497
    /**
498
     * This method initializes jPanel8. This panel contains the ComboBox to select
499
     * the action, (type of HyperLink)
500
     *
501
     * @return javax.swing.JPanel
502
     */
503
    private JPanel getPnlHyperLinkAction() {
504
    	if (pnlHyperLinkAction == null) {
505
    		lblDefaultAction = new JLabel();
506
    		lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
507
    		pnlHyperLinkAction = new JPanel();
508
    		pnlHyperLinkAction.add(lblDefaultAction, null);
509
    		pnlHyperLinkAction.add(getCmbLinkType(), null);
510
    	}
511
    	return pnlHyperLinkAction;
512
    }
513
    /**
514
     * This method initializes jComboBox
515
     *
516
     * @return javax.swing.JComboBox
517
     */
518
    private JComboBox getCmbLinkField() {
519
    	if (cmbLinkField == null) {
520
            cmbLinkField = new JComboBox();
521
    	}
522
    	return cmbLinkField;
523
    }
524
    /**
525
     * This method initializes jTextField
526
     *
527
     * @return javax.swing.JTextField
528
     */
529
    private JTextField getTxtLinkExtension() {
530
    	if (txtLinkExtension == null) {
531
    		txtLinkExtension = new JTextField();
532
            txtLinkExtension.setPreferredSize(new Dimension(40,20));
533
    	}
534
    	return txtLinkExtension;
535
    }
536
    /**
537
     * This method initializes jComboBox1
538
     *
539
     * @return javax.swing.JComboBox
540
     */
541
    private JComboBox getCmbLinkType() {
542
    	if (cmbLinkType == null) {
543
    		cmbLinkType = new JComboBox();
544
    	}
545
    	return cmbLinkType;
546
    }
547
    /**
548
     * @return Returns the view.
549
     */
550
    private IProjectView getView() {
551
        return view;
552
    }
553
    /**
554
     * This method initializes jCheckBox
555
     *
556
     * @return javax.swing.JCheckBox
557
     */
558 344
    private JCheckBox getJCheckBoxSpatialIndex() {
559 345
    	if (jCheckBoxSpatialIndex == null) {
560 346
    		jCheckBoxSpatialIndex = new JCheckBox();
......
564 350
    	return jCheckBoxSpatialIndex;
565 351
    }
566 352

  
567
    /**
568
     * Returns the selected Type in the ComboBox
569
     */
570
    private int getLinkType() {
571
        return getCmbLinkType().getSelectedIndex();
572 353

  
573
    }
574

  
575
    /**
576
     * Returns the Selected Field in the ComboBox
577
     */
578
    private String getSelectedLinkField() {
579
        return (String) getCmbLinkField().getSelectedItem();
580
    }
581

  
582
    /**
583
     * Returns the Extension in the TextField
584
     */
585
    private String getExtensionLink() {
586
        return getTxtLinkExtension().getText();
587
    }
588

  
589
    /**
590
     * Returns true or false if the CheckBox is marked or not
591
     */
592 354
    private boolean isSpatialIndexSelected() {
593 355
        return getJCheckBoxSpatialIndex().isSelected();
594 356
    }
......
643 405
							info = info +
644 406
							PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
645 407
						} catch (Exception e) {
646
							//TODO: Que hacer aqui?
647 408
							e.printStackTrace();
648 409
						}
649 410

  
......
672 433
    }
673 434

  
674 435
    /**
675
     * Returns true or false if the scale is activa
436
     * Returns true or false if the scale is selected
676 437
     */
677 438
	private boolean isScaleActive() {
678 439
		return getRdBtnDoNotShowWhen().isSelected();
679 440
	}
680 441

  
681 442
    /**
682
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
683
     * to create a spatial index for the selected layer in background.
684
     * This task also allow to monitor process evolution, and to cancel
685
     * this process.
443
     * Instantiates a ITask (@see com.iver.utiles.swing.threads.ITask) to create
444
     * a spatial index for the selected layer in background. This task also
445
     * allow to monitor process evolution, and to cancel this process.
446
     * 
686 447
     * @throws DriverException
687 448
     * @throws DriverIOException
688 449
     */
......
692 453
    }
693 454

  
694 455
	public void acceptAction() {
695
	     // Implementaci?n para hacer funcionar el hyperlink ...
696
        //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
697
        //ProjectView view = theView.getModel();
698
    	if (PluginServices.getMainFrame() != null)
699
    	{
700
    		IProjectView view = getView();
701
    		view.setTypeLink(getLinkType());
702
    		if (getSelectedLinkField()!=null)
703
    		{
704
    			view.setSelectedField(getSelectedLinkField().toString().trim());
705
    			view.setExtLink(getExtensionLink());
706

  
707
    		}
708
    	}
709

  
710

  
456
	// does nothing
711 457
	}
712 458

  
713 459
	public void cancelAction() {
714 460
		// does nothing
715 461
	}
716 462

  
717
	/**
718
	 * When we press the apply button, sets the new properties of the layer thar the
719
	 * user modified using the UI components
720
	 */
463
	    /**
464
     * When we press the apply button, sets the new properties of the layer that
465
     * the user modified using the UI components
466
     */
721 467
	public void applyAction() {
722 468
		if (isScaleActive()) {
723 469
			try	{
......
756 502
						PluginServices.
757 503
							cancelableBackgroundExecution(getCreateSpatialIndexTask());
758 504
					} catch (ReadDriverException e) {
759
						// TODO Auto-generated catch block
760 505
						NotificationManager.addError(e.getMessage(), e);
761 506
					}
762 507
                }
......
773 518

  
774 519

  
775 520
        }
776
        //Codigo relacionado
777
        if (layer instanceof FLyrVect ){
778
			FLyrVect vectlyr=(FLyrVect) layer;
779
			if (getSelectedLinkField()!=null){
780
				vectlyr.getLinkProperties().setExt(getExtensionLink());
781
				vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
782
				vectlyr.getLinkProperties().setType(getLinkType());
783 521

  
784
				System.out.println("Link Properties");
785
				System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
786
				System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
787
				System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
788
			}
789
        }
790 522
	}
791 523

  
792
	/*
793
	 *  (non-Javadoc)
794
	 * @see java.awt.Component#getName()
795
	 */
524

  
796 525
	public String getName() {
797 526
		return PluginServices.getText(this,"General");
798 527
	}
799
}  //  @jve:decl-index=0:visual-constraint="10,10"
800

  
528
}

Also available in: Unified diff