Пример #1
0
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 private void cmdDeleteRowActionPerformed(
     final java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cmdDeleteRowActionPerformed
   if (tblMappings.isEditing()) { // GEN-LAST:event_cmdDeleteRowActionPerformed
     tblMappings.getCellEditor().stopCellEditing();
   }
   getMappingModel().addRow(new Mapping());
 }
Пример #2
0
 /**
  * DOCUMENT ME!
  *
  * @param mappings DOCUMENT ME!
  */
 public void setContent(List<Mapping> mappings) {
   if (mappings == null) {
     mappings = TypeSafeCollections.newArrayList();
   }
   // this.mappings = mappings;
   // TableSorter ts = new TableSorter(new MappingModel(mappings));
   // tblMappings.setModel(ts);
   if (tblMappings.getModel() != null) {
     tblMappings.getModel().removeTableModelListener(topComponent);
   }
   tblMappings.setModel(new MappingModel(mappings));
   tblMappings.getModel().addTableModelListener(topComponent);
 }
Пример #3
0
  /**
   * Creates a new MappingEditor object.
   *
   * @param mappings DOCUMENT ME!
   */
  public MappingEditor(final List<Mapping> mappings) {
    fldNames = null;
    initComponents();
    setContent(mappings);
    tblMappings.setModel(new MappingModel(mappings));
    // add alphanumeric sorting
    TableSortDecorator.decorate(tblMappings);
    scpMappings.setTransferHandler(tblMappings.getTransferHandler());
    this.tblMappings
        .getSelectionModel()
        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    final TableColumn col = tblMappings.getColumnModel().getColumn(3);
    col.getCellRenderer();
  }
Пример #4
0
 /**
  * DOCUMENT ME!
  *
  * @return DOCUMENT ME!
  */
 public boolean allMappingsComplete() {
   tblMappings.clearColors();
   final List<Mapping> content = getContent();
   for (final Mapping m : content) {
     if (m.getContent().equals(STRING_EMPTY) && !m.isAutoIncrement()) {
       return false;
     }
   }
   return true;
 }
Пример #5
0
  /**
   * DOCUMENT ME!
   *
   * @param fieldNames DOCUMENT ME!
   */
  public void prepareAutoComplete(final String[] fieldNames) {
    final List<String> tmp = TypeSafeCollections.newArrayList();
    if (codeProvider != null) {
      tmp.addAll(codeProvider.getFunctionList());
    }
    if (fieldNames != null) {
      this.fldNames = fieldNames.clone();
    }
    if (this.fldNames != null) {
      for (final String s : this.fldNames) {
        tmp.add(s);
      }
    }
    final TableColumn tc = tblMappings.getColumnModel().getColumn(1);
    Collections.sort(tmp);

    final SmartComboBox combo = new SmartComboBox(tmp.toArray(new String[] {}));
    combo.setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0));
    combo.setEditable(true);
    combo.setCaseSensitive(true);
    final MultiClickComboBoxCellEditor ed = new MultiClickComboBoxCellEditor(combo);
    tc.setCellEditor(ed);
    ed.addCellEditorListener(combo);
  }
Пример #6
0
 /**
  * DOCUMENT ME!
  *
  * @param toUpper DOCUMENT ME!
  */
 private void swichCase(final boolean toUpper) {
   if (tblMappings != null) {
     final int[] x = tblMappings.getSelectedColumns();
     final int[] y = tblMappings.getSelectedRows();
     if (toUpper) {
       for (final int i : y) {
         for (final int j : x) {
           tblMappings.setValueAt(tblMappings.getValueAt(i, j).toString().toUpperCase(), i, j);
         }
       }
     } else {
       for (final int i : y) {
         for (final int j : x) {
           tblMappings.setValueAt(tblMappings.getValueAt(i, j).toString().toLowerCase(), i, j);
         }
       }
     }
   }
 }
Пример #7
0
 /** DOCUMENT ME! */
 public void clearErrors() {
   tblMappings.clearColors();
 }
Пример #8
0
 /**
  * DOCUMENT ME!
  *
  * @param row DOCUMENT ME!
  * @param column DOCUMENT ME!
  */
 public void markPotentialError(final int row, final int column) {
   tblMappings.setColor(tblMappings.convertRowIndexToView(row), column, Color.RED);
 }
Пример #9
0
 /**
  * Marks potential error fields red in the table.
  *
  * @param errors s
  * @param column DOCUMENT ME!
  */
 public void markPotentialErrors(final List<String> errors, final int column) {
   tblMappings.markPotentialErrors(errors, column);
 }
Пример #10
0
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 private void cmdAddRowActionPerformed(
     final java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cmdAddRowActionPerformed
   tblMappings.deleteCurrentSelection();
 } // GEN-LAST:event_cmdAddRowActionPerformed
Пример #11
0
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    scpMappings = new javax.swing.JScrollPane();
    tblMappings = new MappingTable();
    cmdAddRow = new javax.swing.JButton();
    cmdDeleteRow = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();

    setBorder(
        javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory.createTitledBorder(
                null,
                "Mappings",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
                new java.awt.Font("Dialog", 0, 12),
                javax.swing.UIManager.getDefaults()
                    .getColor("CheckBoxMenuItem.selectionBackground")),
            javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))); // NOI18N
    setLayout(new java.awt.GridBagLayout());

    scpMappings.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    tblMappings.setModel(
        new javax.swing.table.DefaultTableModel(new Object[][] {{}, {}, {}, {}}, new String[] {}));
    scpMappings.setViewportView(tblMappings);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(scpMappings, gridBagConstraints);

    cmdAddRow.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/de/cismet/jpresso/project/res/edit-delete.png"))); // NOI18N
    cmdAddRow.setToolTipText("Remove selected Rows");
    cmdAddRow.setBorderPainted(false);
    cmdAddRow.setFocusPainted(false);
    cmdAddRow.setMargin(new java.awt.Insets(2, 5, 1, 5));
    cmdAddRow.addActionListener(
        new java.awt.event.ActionListener() {

          @Override
          public void actionPerformed(final java.awt.event.ActionEvent evt) {
            cmdAddRowActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(1, 8, 1, 0);
    add(cmdAddRow, gridBagConstraints);

    cmdDeleteRow.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/de/cismet/jpresso/project/res/edit-add.png"))); // NOI18N
    cmdDeleteRow.setToolTipText("Add new Row");
    cmdDeleteRow.setBorderPainted(false);
    cmdDeleteRow.setFocusPainted(false);
    cmdDeleteRow.setMargin(new java.awt.Insets(2, 5, 1, 5));
    cmdDeleteRow.addActionListener(
        new java.awt.event.ActionListener() {

          @Override
          public void actionPerformed(final java.awt.event.ActionEvent evt) {
            cmdDeleteRowActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(1, 8, 1, 0);
    add(cmdDeleteRow, gridBagConstraints);

    jButton1.setIcon(
        new javax.swing.ImageIcon(
            getClass()
                .getResource(
                    "/de/cismet/jpresso/project/res/format-font-size-more.png"))); // NOI18N
    jButton1.setToolTipText("To upper case");
    jButton1.setMaximumSize(new java.awt.Dimension(36, 29));
    jButton1.setMinimumSize(new java.awt.Dimension(36, 29));
    jButton1.setPreferredSize(new java.awt.Dimension(36, 29));
    jButton1.addActionListener(
        new java.awt.event.ActionListener() {

          @Override
          public void actionPerformed(final java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(1, 8, 1, 0);
    add(jButton1, gridBagConstraints);

    jButton2.setIcon(
        new javax.swing.ImageIcon(
            getClass()
                .getResource(
                    "/de/cismet/jpresso/project/res/format-font-size-less.png"))); // NOI18N
    jButton2.setToolTipText("To lower case");
    jButton2.setMaximumSize(new java.awt.Dimension(36, 29));
    jButton2.setMinimumSize(new java.awt.Dimension(36, 29));
    jButton2.setPreferredSize(new java.awt.Dimension(36, 29));
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {

          @Override
          public void actionPerformed(final java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(1, 8, 1, 0);
    add(jButton2, gridBagConstraints);
  } // </editor-fold>//GEN-END:initComponents
Пример #12
0
 /** stop cell editor. */
 public void stopEditing() {
   if (tblMappings.isEditing()) {
     tblMappings.getCellEditor().stopCellEditing();
   }
 }
Пример #13
0
 /**
  * DOCUMENT ME!
  *
  * @return the mapping model
  */
 private MappingModel getMappingModel() {
   return tblMappings.getModel();
 }
Пример #14
0
 /**
  * DOCUMENT ME!
  *
  * @param tml DOCUMENT ME!
  */
 public void setTableListener(final TableModelListener tml) {
   this.topComponent = tml;
   if ((tblMappings != null) && (tblMappings.getModel() != null)) {
     this.tblMappings.getModel().addTableModelListener(topComponent);
   }
 }