/* * (non-Javadoc) * * @see javax.swing.table.TableModel#getValueAt(int, int) */ public Object getValueAt(int rowIndex, int columnIndex) { if (rowIndex > this.valueObjects.size() || columnIndex > 1) { return ""; } else { if (columnIndex == 0) { return FacilityService.getInstance() .getFacilityNameFor( new Long(((Tariff2SeaportValue) getValueObjectAt(rowIndex)).getFacilityId())); } else { return FacilityService.getInstance() .getFacilityCityNameFor( new Long(((Tariff2SeaportValue) getValueObjectAt(rowIndex)).getFacilityId())); } } }
private void initComponents(Seaport2FixpointValue seaport2Fixpoint) { seaportCombo = new ContextJComboBox(this, true); seaportCombo.setName("Seaport"); mandatoryFields.add(seaportCombo); try { String regionID = ParameterService.getInstance() .getParameterValue(Constants.PARAM_SEAPORT_REGION_FOR_FIXPOINT_MAPPING); List seaports = new ArrayList(); if (seaport2Fixpoint.getClientValueObjectProxy().isNew()) { // Die Leer-auswahl nur beim Einfuegen anzeigen. seaports.add("-- Select --"); } seaports.addAll( FacilityService.getInstance() .findFacilitiesByTypeAndRegion( Constants.FACILITY_TYPE_SEAPORT, Long.parseLong(regionID))); seaportCombo.setModel(new DefaultComboBoxModel(seaports.toArray())); } catch (Exception x) { log.error( "Exception while retrieving seaport list for seaport2fixpoint table.\n " + "Parameter '" + Constants.PARAM_SEAPORT_REGION_FOR_FIXPOINT_MAPPING + "' not set?", x); } setSelectedItem(seaportCombo, seaport2Fixpoint.getSeaportId()); JLabel seaportLabel = new JLabel(seaportCombo.getName()); seaportLabel.setLabelFor(seaportCombo); seaportLabel.setDisplayedMnemonic('S'); fixpointCombo = new ContextJComboBox(this); fixpointCombo.setName("Fixpoint"); mandatoryFields.add(fixpointCombo); try { List fixpoints = new ArrayList(); fixpoints.add("-- n/a --"); fixpoints.addAll( FacilityService.getInstance().findFacilitiesByType(Constants.FACILITY_TYPE_FIXPOINT)); fixpointCombo.setModel(new DefaultComboBoxModel(fixpoints.toArray())); } catch (Exception e) { log.error("Exception while retrieving fixpoint list: ", e); } if (seaport2Fixpoint.getFixpointId() != null) { // D.h. seaport2Fixpoint.isActive(). setSelectedItem(fixpointCombo, seaport2Fixpoint.getFixpointId().longValue()); } JLabel fixpointLabel = new JLabel(fixpointCombo.getName()); fixpointLabel.setLabelFor(fixpointCombo); fixpointLabel.setDisplayedMnemonic('F'); validFromField = new DateJTextField(this); validFromField.setName("Valid From"); validFromField.setDate(seaport2Fixpoint.getValidityStart()); validFromField.setRequired(true); mandatoryFields.add(validFromField); JLabel validFromLabel = new JLabel(validFromField.getName()); validFromLabel.setLabelFor(validFromField); validFromLabel.setDisplayedMnemonic('F'); validToField = new DateJTextField(this); validToField.setName("Valid To"); validToField.setDate(seaport2Fixpoint.getValidityEnd()); // VERSION_TOGGLE ValidityModification.enabled Start ---------- if (!ResourceUtil.getBoolean("ValidityModification.enabled")) { validToField.setRequired(true); mandatoryFields.add(validToField); } // VERSION_TOGGLE ValidityModification.enabled End ---------- JLabel validToLabel = new JLabel(validToField.getName()); validToLabel.setLabelFor(validToField); validToLabel.setDisplayedMnemonic('T'); // Durch die Vorbelgung soll das Objekt noch nicht speicherbar sein. seaport2Fixpoint.getClientValueObjectProxy().setChanged(false); setTitle("Fixpoints"); setMaximizable(false); getContentPane().setLayout(new GridBagLayout()); ((JComponent) getContentPane()).setBorder(BorderFactory.createEmptyBorder(15, 15, 10, 15)); GridBagConstraints constraints = new GridBagConstraints(); // Spalte 1. constraints.gridx = 0; constraints.gridy = 0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 0, 5, 0); getContentPane().add(seaportLabel, constraints); constraints.gridx = 0; constraints.gridy = 1; constraints.anchor = GridBagConstraints.WEST; getContentPane().add(validFromLabel, constraints); constraints.gridx = 0; constraints.gridy = 2; constraints.anchor = GridBagConstraints.WEST; getContentPane().add(validToLabel, constraints); constraints.gridx = 0; constraints.gridy = 3; constraints.anchor = GridBagConstraints.WEST; getContentPane().add(fixpointLabel, constraints); // Spalte 2. constraints.gridx = 1; constraints.gridy = 0; constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; getContentPane().add(seaportCombo, constraints); constraints.gridx = 1; constraints.gridy = 1; constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; getContentPane().add(validFromField, constraints); constraints.gridx = 1; constraints.gridy = 2; constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; getContentPane().add(validToField, constraints); constraints.gridx = 1; constraints.gridy = 3; constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; getContentPane().add(fixpointCombo, constraints); pack(); }