Revision 2406 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/scalemanager/FPanelScaleManager.java

View differences:

FPanelScaleManager.java
46 46
import java.text.NumberFormat;
47 47

  
48 48
import javax.swing.ButtonGroup;
49
import javax.swing.ComboBoxModel;
49 50
import javax.swing.DefaultComboBoxModel;
50 51
import javax.swing.JComboBox;
51 52
import javax.swing.JLabel;
......
74 75
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.AbstractPanel;
75 76
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.FPanelLegendValues;
76 77
import com.iver.cit.gvsig.project.ProjectView;
78
import java.awt.BorderLayout;
77 79
/**
78 80
 * @author jmorell
79 81
 *
......
82 84
 */
83 85
public class FPanelScaleManager extends AbstractPanel {
84 86

  
85
	private static Logger logger = Logger.getLogger(FPanelLegendValues.class.getName());
87
	/**
88
     * 
89
     */
90
    private static final long serialVersionUID = 1L;
91
    private static Logger logger = Logger.getLogger(FPanelLegendValues.class.getName());
86 92
	private FMap mapContext;
87 93
	private FLayer layer;
88 94
    //private ComandosListener actionListener = new ComandosListener(this);
......
92 98
	private JPanel jPanel = null;
93 99
	private JPanel jPanel1 = null;
94 100
	private JPanel jPanel2 = null;
95
	private JPanel jPanel3 = null;
96 101
	private JPanel jPanel4 = null;
97 102
	private JPanel jPanel5 = null;
98 103
	private JLabel jLabel = null;
......
101 106
	private JTextField jTextField1 = null;
102 107
	private JLabel jLabel2 = null;
103 108
	private JTextArea jTextArea = null;
104
	private JLabel jLabel5 = null;
105
	private JComboBox jComboBox = null;
106 109
	private JScrollPane jScrollPane = null;
107 110
	private ButtonGroup buttonGroup = null;
108 111
	private JRadioButton jRadioButton = null;
......
110 113
	private JLabel jLabel3 = null;
111 114
	private JTextField jTextField2 = null;
112 115
	private JLabel jLabel4 = null;
113
	private String layerName = null;
114
	/**
116
	//private String layerName = null;
117
    private JPanel jPanel3 = null;
118
    private JPanel jPanel6 = null;
119
    private JPanel jPanel7 = null;
120
    private JPanel jPanel8 = null;
121
    private JLabel jLabel5 = null;
122
    private JComboBox jComboBox = null;
123
    private JLabel jLabel6 = null;
124
    private JTextField jTextField = null;
125
    private JLabel jLabel7 = null;
126
    private JComboBox jComboBox1 = null;
127
    private String layerName = null;
128
    /**
115 129
	 * This is the default constructor
116 130
	 */
117 131
	public FPanelScaleManager() {
......
127 141
		//setView();
128 142
		this.setLayout(null);
129 143
		//this.setLayer(null);
130
		this.setBounds(0, 0, 445, 332);
144
		this.setBounds(0, 0, 589, 332);
131 145
		this.add(getJPanel(), null);
132 146
		this.add(getJPanel1(), null);
133 147
		this.add(getJPanel2(), null);
......
155 169
     */
156 170
    public void setMapContext(FMap mapContext) throws DriverException {
157 171
        this.mapContext = mapContext;
172
         //layer = getFirstActiveLayerVect();
173
        //layerName = layer.getName();
158 174
        layer = getFirstActiveLayerVect(mapContext.getLayers());
159 175
        layerName = layer.getName();
160 176
			/*try {
......
222 238
				nomFields[i] = rs.getFieldName(i).trim();
223 239
			}
224 240
			rs.stop();
225
			DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields);
226
			getJComboBox().setModel(cM);
227 241
		// fieldsListValor.setSelectedIndex(0);
228 242
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
229 243
			// TODO Auto-generated catch block
......
265 279
			// TODO Auto-generated catch block
266 280
			e.printStackTrace();
267 281
		}
282
        
283
        // Me parece que es aqu? donde hay que montar el jComboBox ...
284
        com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
285
        view = theView.getModel();
286
        try {
287
            if (layer instanceof AlphanumericData) {
288
                AlphanumericData ad = (AlphanumericData) layer;
289
                DataSource ds;
290
                ds = ad.getRecordset();
291
                String[] names = new String[ds.getFieldCount()];
292
                for (int i = 0; i < ds.getFieldCount(); i++) {
293
                    names[i] = ds.getFieldName(i);
294
                }
295
                //jComboBox = new javax.swing.JComboBox(names);
296
                DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
297
                jComboBox.setModel(defaultModel);
298
                if (view.getSelectedField() != null) {
299
                    jComboBox.setSelectedItem(view.getSelectedField());
300
                }
301
            }else{
302
                jComboBox = new javax.swing.JComboBox();
303
            }
304
        } catch (DriverException e) {
305
            NotificationManager.addError("No se pudo obtener la tabla", e);
306
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
307
            NotificationManager.addError("No se pudo obtener la tabla", e);
308
        }
309
        //
310
        
311
        // y aqu? el jTextField ...
312
        if (view.getSelectedField() != null) {
313
            getJTextField2().setText(view.getExtLink());
314
        }
315
        //
316
        
317
        // y aqu? el jComboBox1 ...
318
        //jComboBox1 = new javax.swing.JComboBox();
319
        getJComboBox1().addItem(PluginServices.getText(this,
320
                "Enlazar_a_ficheros_de_imagen"));
321
        getJComboBox1().addItem(PluginServices.getText(this,
322
        "Enlazar_a_fichero_de_texto"));
323
        if (view.getSelectedField() != null) {
324
            getJComboBox1().setSelectedIndex(view.getTypeLink());
325
        }
326
        //
268 327
		
269 328
		// Si es de valor ?nico, rellenamos la tabla
270 329
		// y seleccionamos el campo que estamos usando
......
341 400
			jPanel2 = new JPanel();
342 401
			jPanel2.setLayout(null);
343 402
			jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Propiedades", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
344
			jPanel2.setBounds(5, 170, 361, 127);
403
			jPanel2.setBounds(5, 170, 303, 155);
345 404
			jPanel2.add(getJScrollPane(), null);
346 405
		}
347 406
		return jPanel2;
348 407
	}
349 408
	/**
350
	 * This method initializes jPanel3	
351
	 * 	
352
	 * @return javax.swing.JPanel	
353
	 */    
354
	private JPanel getJPanel3() {
355
		if (jPanel3 == null) {
356
			jLabel5 = new JLabel();
357
			jPanel3 = new JPanel();
358
			jPanel3.setLayout(null);
359
			jLabel5.setText(PluginServices.getText(this,"campo_de_documentos_asociados") + ":");
360
			jLabel5.setBounds(0, 2, 234, 15);
361
			jPanel3.setLocation(5, 304);
362
			jPanel3.setSize(432, 20);
363
			jPanel3.add(jLabel5, null);
364
			jPanel3.add(getJComboBox(), null);
365
		}
366
		return jPanel3;
367
	}
368
	/**
369 409
	 * This method initializes jPanel4	
370 410
	 * 	
371 411
	 * @return javax.swing.JPanel	
......
462 502
		return jTextArea;
463 503
	}
464 504

  
465
	/**
466
	 * This method initializes jComboBox
467
	 *
468
	 * @return javax.swing.JComboBox
469
	 */
470
	public javax.swing.JComboBox getJComboBox() {
471
		if (jComboBox == null) {
472
			try {
473
				if (layer instanceof AlphanumericData) {
474
					AlphanumericData lyr = (AlphanumericData) layer;
475
					DataSource ds;
476
					ds = lyr.getRecordset();
477

  
478
					String[] names = new String[ds.getFieldCount()];
479

  
480
					for (int i = 0; i < ds.getFieldCount(); i++) {
481
						names[i] = ds.getFieldName(i);
482
					}
483

  
484
					jComboBox = new javax.swing.JComboBox(names);
485

  
486
					if (view.getSelectedField() != null) {
487
						jComboBox.setSelectedItem(view.getSelectedField());
488
					}
489
				}else{
490
					jComboBox = new javax.swing.JComboBox();
491
				}
492
			} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
493
				NotificationManager.addError(PluginServices.getText(this,"Error_accediendo_a_los_datos"), e);
494
			} catch (DriverException e) {
495
				NotificationManager.addError(PluginServices.getText(this,"Error_accediendo_a_los_datos"), e);
496
			}
497
		}
498
		jComboBox.setBounds(220, 0, 192, 20);
499
		jComboBox.addActionListener(new java.awt.event.ActionListener() { 
500
			public void actionPerformed(java.awt.event.ActionEvent e) {    
501
				//JComboBox cb = (JComboBox) e.getSource();
502
				/*String fieldName = (String) cb.getSelectedItem();
503
				System.out.println("Nombre del campo: " + fieldName);
504
				m_symbolTable.removeAllItems();
505
				if (fieldName != m_Renderer.getFieldName())
506
					m_bCacheDirty = true;
507
				m_Renderer.setFieldName(fieldName);*/
508
			}
509
		});
510
		return jComboBox;
511
	}
512

  
513 505
	/*public void setLayer(FLayer layer) {
514 506
		this.layer = layer;
515 507
	}*/
......
524 516
			jScrollPane.setViewportView(getJTextArea());
525 517
			jScrollPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
526 518
			jScrollPane.setPreferredSize(new java.awt.Dimension(100,100));
527
			jScrollPane.setBounds(6, 21, 335, 100);
519
			jScrollPane.setBounds(6, 21, 283, 120);
528 520
		}
529 521
		return jScrollPane;
530 522
	}
......
593 585
	public String getLayerName(){
594 586
		return txtLayerName.getText().toString();
595 587
	}
588
    /**
589
     * This method initializes jPanel3	
590
     * 	
591
     * @return javax.swing.JPanel	
592
     */    
593
    private JPanel getJPanel3() {
594
    	if (jPanel3 == null) {
595
    		jPanel3 = new JPanel();
596
    		jPanel3.setLayout(null);
597
    		jPanel3.setBounds(315, 170, 266, 154);
598
    		jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED), PluginServices.getText(this, "Hiperenlace"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
599
    		jPanel3.add(getJPanel6(), null);
600
    	}
601
    	return jPanel3;
602
    }
603
    /**
604
     * This method initializes jPanel6	
605
     * 	
606
     * @return javax.swing.JPanel	
607
     */    
608
    private JPanel getJPanel6() {
609
    	if (jPanel6 == null) {
610
    		jPanel6 = new JPanel();
611
    		jPanel6.setLayout(new BorderLayout());
612
    		jPanel6.setBounds(7, 22, 245, 119);
613
    		jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
614
    		jPanel6.add(getJPanel7(), java.awt.BorderLayout.NORTH);
615
    		jPanel6.add(getJPanel8(), java.awt.BorderLayout.CENTER);
616
    	}
617
    	return jPanel6;
618
    }
619
    /**
620
     * This method initializes jPanel7	
621
     * 	
622
     * @return javax.swing.JPanel	
623
     */    
624
    private JPanel getJPanel7() {
625
    	if (jPanel7 == null) {
626
    		jLabel6 = new JLabel();
627
    		jLabel6.setText(PluginServices.getText(this,"extension"));
628
    		jLabel5 = new JLabel();
629
    		jLabel5.setText(PluginServices.getText(this, "Campo") + "   ");
630
    		jPanel7 = new JPanel();
631
    		jPanel7.add(jLabel5, null);
632
    		jPanel7.add(getJComboBox(), null);
633
    		jPanel7.add(jLabel6, null);
634
    		jPanel7.add(getJTextField(), null);
635
    	}
636
    	return jPanel7;
637
    }
638
    /**
639
     * This method initializes jPanel8	
640
     * 	
641
     * @return javax.swing.JPanel	
642
     */    
643
    private JPanel getJPanel8() {
644
    	if (jPanel8 == null) {
645
    		jLabel7 = new JLabel();
646
    		jLabel7.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
647
    		jPanel8 = new JPanel();
648
    		jPanel8.add(jLabel7, null);
649
    		jPanel8.add(getJComboBox1(), null);
650
    	}
651
    	return jPanel8;
652
    }
653
    /**
654
     * This method initializes jComboBox	
655
     * 	
656
     * @return javax.swing.JComboBox	
657
     */    
658
    private JComboBox getJComboBox() {
659
    	if (jComboBox == null) {
660
            jComboBox = new JComboBox();
661
    	}
662
    	return jComboBox;
663
    }
664
    /**
665
     * This method initializes jTextField	
666
     * 	
667
     * @return javax.swing.JTextField	
668
     */    
669
    private JTextField getJTextField() {
670
    	if (jTextField == null) {
671
    		jTextField = new JTextField();
672
            jTextField.setPreferredSize(new java.awt.Dimension(40,20));
673
    	}
674
    	return jTextField;
675
    }
676
    /**
677
     * This method initializes jComboBox1	
678
     * 	
679
     * @return javax.swing.JComboBox	
680
     */    
681
    private JComboBox getJComboBox1() {
682
    	if (jComboBox1 == null) {
683
    		jComboBox1 = new JComboBox();
684
    	}
685
    	return jComboBox1;
686
    }
687
    /**
688
     * @return Returns the view.
689
     */
690
    public ProjectView getView() {
691
        return view;
692
    }
596 693
    }  //  @jve:decl-index=0:visual-constraint="10,10"

Also available in: Unified diff