Example #1
1
 public Controller(Action toggleAction) {
   itemList.setModel(new DefaultComboBoxModel());
   itemList.setPrototypeDisplayValue("------------------------");
   enableEditor(false);
   this.toggleAction = toggleAction;
 }
  private void lookupViewComboAction(ActionEvent e) {
    ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView();
    ObjEntityView selectedLookupView = (ObjEntityView) lookupViewCombo.getSelectedItem();

    if (selectedLookupView != fieldLookupView) {
      objEntityViewField.getLookup().setLookupObjEntityView(selectedLookupView);

      dataViewTreeModel.fieldChanged(objEntityViewField);
      dataMapTreeModel.fieldChanged(objEntityViewField);
      fieldsTableModel.fireTableCellUpdated(
          objEntityViewField.getObjEntityView().getIndexOfObjEntityViewField(objEntityViewField),
          4);
    }

    if (selectedLookupView != null) {
      ObjEntityViewField nullField = null;
      java.util.List lookupFields = new ArrayList();
      lookupFields.add(nullField);
      lookupFields.addAll(selectedLookupView.getObjEntityViewFields());

      DefaultComboBoxModel lookupFieldsDefaultModel =
          new DefaultComboBoxModel(lookupFields.toArray());
      lookupFieldCombo.setModel(lookupFieldsDefaultModel);
      ObjEntityViewField fieldLookupField = objEntityViewField.getLookup().getLookupField();
      if (fieldLookupField != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = lookupFields.iterator(); itr.hasNext(); ) {
          ObjEntityViewField field = (ObjEntityViewField) itr.next();
          if ((field != null) && (fieldLookupField.getName().equals(field.getName()))) {
            lookupFieldCombo.setSelectedItem(fieldLookupField);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          lookupFieldCombo.setSelectedIndex(0);
        }
      } else {
        lookupFieldCombo.setSelectedIndex(0);
      }
    } else {
      ObjEntityViewField nullField = null;
      ObjEntityViewField[] fields = new ObjEntityViewField[] {nullField};

      DefaultComboBoxModel fieldsModel = new DefaultComboBoxModel(fields);
      lookupFieldCombo.setModel(fieldsModel);
      lookupFieldCombo.setSelectedIndex(0);
    }
  }
  public static void isiCombo() {
    // data dimasukkan ke dalam class model
    DefaultComboBoxModel model = new DefaultComboBoxModel(dfrMhs.toArray());

    // pasang model di combo
    cmbMhs.setModel(model);
  }
 private void _setUpResources() {
   DefaultComboBoxModel dlm = new DefaultComboBoxModel();
   Set<String> keys = HEADING_LIST.keySet();
   for (String key : keys) {
     dlm.addElement(key);
   }
   mHeadingComboBox.setModel(dlm);
 }
  private void objRelationshipComboAction(ActionEvent e) {
    ObjRelationship selectedObjRelationship =
        (ObjRelationship) objRelationshipCombo.getSelectedItem();
    ObjRelationship fieldObjRelationship = objEntityViewField.getObjRelationship();

    if (selectedObjRelationship != fieldObjRelationship) {
      objEntityViewField.setObjRelationship(selectedObjRelationship);
    }

    if (selectedObjRelationship != null) {
      ObjEntity targetObjEntity = selectedObjRelationship.getTargetObjEntity();

      ObjEntityView nullView = null;
      java.util.List lookupViews = new ArrayList();
      lookupViews.add(nullView);
      lookupViews.addAll(targetObjEntity.getObjEntityViews());

      DefaultComboBoxModel lookupViewModel = new DefaultComboBoxModel(lookupViews.toArray());
      lookupViewCombo.setModel(lookupViewModel);
      ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView();
      if (fieldLookupView != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = lookupViews.iterator(); itr.hasNext(); ) {
          ObjEntityView view = (ObjEntityView) itr.next();
          if (fieldLookupView == view) {
            lookupViewCombo.setSelectedItem(fieldLookupView);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          lookupViewCombo.setSelectedIndex(0);
        }
      } else {
        lookupViewCombo.setSelectedIndex(0);
      }
    } else {
      ObjEntityView nullView = null;
      ObjEntityView[] views = new ObjEntityView[] {nullView};
      DefaultComboBoxModel viewsModel = new DefaultComboBoxModel(views);
      lookupViewCombo.setModel(viewsModel);
      lookupViewCombo.setSelectedIndex(0);
    }
  }
 private void setStudentsComboBox() {
   // call to get Students
   // studentList = ReportGenerator.staticList;
   // studentList = Arrays.asList();
   DefaultComboBoxModel model = new DefaultComboBoxModel(studentList.toArray());
   if (model.getSize() == 0) {
     model.addElement("No items");
   } else {
     model.setSelectedItem(studentList.get(0));
   }
   studentsComboBox.setModel(model);
   studentsComboBox.updateUI();
 }
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   contentPane = new JPanel();
   contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1));
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel1,
       new GridConstraints(
           3,
           0,
           1,
           1,
           GridConstraints.ANCHOR_SOUTH,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
   panel1.add(
       panel2,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_VERTICAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   btImport = new JButton();
   btImport.setText("Import");
   panel2.add(
       btImport,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   btCancel = new JButton();
   btCancel.setEnabled(false);
   btCancel.setText("Cancel");
   panel2.add(
       btCancel,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   btClose = new JButton();
   btClose.setText("Close");
   panel2.add(
       btClose,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JSeparator separator1 = new JSeparator();
   panel1.add(
       separator1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_NORTH,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel3 = new JPanel();
   panel3.setLayout(new GridLayoutManager(4, 4, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel3,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("File path:");
   panel3.add(
       label1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   tfFilePath = new JTextField();
   panel3.add(
       tfFilePath,
       new GridConstraints(
           1,
           1,
           1,
           2,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   btBrowse = new JButton();
   btBrowse.setText("Browse");
   panel3.add(
       btBrowse,
       new GridConstraints(
           1,
           3,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("Delimiter:");
   panel3.add(
       label2,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   cmbDelimiter = new JComboBox();
   cmbDelimiter.setEditable(true);
   final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
   defaultComboBoxModel1.addElement(",");
   defaultComboBoxModel1.addElement("|");
   defaultComboBoxModel1.addElement("-");
   defaultComboBoxModel1.addElement(":");
   cmbDelimiter.setModel(defaultComboBoxModel1);
   panel3.add(
       cmbDelimiter,
       new GridConstraints(
           2,
           1,
           1,
           2,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Table name:");
   panel3.add(
       label3,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   tfTableName = new JTextField();
   panel3.add(
       tfTableName,
       new GridConstraints(
           0,
           1,
           1,
           2,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   final JPanel panel4 = new JPanel();
   panel4.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
   panel3.add(
       panel4,
       new GridConstraints(
           3,
           0,
           1,
           4,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel5 = new JPanel();
   panel5.setLayout(new GridLayoutManager(2, 4, new Insets(0, 0, 0, 0), -1, -1));
   panel4.add(
       panel5,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Select types for columns:");
   panel5.add(
       label4,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer1 = new Spacer();
   panel5.add(
       spacer1,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   btRemoveColumn = new JButton();
   btRemoveColumn.setEnabled(false);
   btRemoveColumn.setText("Remove");
   panel5.add(
       btRemoveColumn,
       new GridConstraints(
           1,
           3,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   btAddColumn = new JButton();
   btAddColumn.setText("Add...");
   panel5.add(
       btAddColumn,
       new GridConstraints(
           1,
           2,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JSeparator separator2 = new JSeparator();
   panel5.add(
       separator2,
       new GridConstraints(
           0,
           0,
           1,
           4,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           null,
           null,
           0,
           false));
   final JScrollPane scrollPane1 = new JScrollPane();
   panel4.add(
       scrollPane1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(400, 200),
           null,
           0,
           false));
   rowsTable = new JTable();
   scrollPane1.setViewportView(rowsTable);
   final JLabel label5 = new JLabel();
   label5.setFont(new Font(label5.getFont().getName(), Font.BOLD, label5.getFont().getSize()));
   label5.setText("* Note: data for not listed columns will be treated as of String type.");
   panel4.add(
       label5,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_SOUTHWEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JSeparator separator3 = new JSeparator();
   contentPane.add(
       separator3,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel6 = new JPanel();
   panel6.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel6,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label6 = new JLabel();
   label6.setText("Written rows:");
   panel6.add(
       label6,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer2 = new Spacer();
   panel6.add(
       spacer2,
       new GridConstraints(
           1,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   writtenRowsCount = new JLabel();
   writtenRowsCount.setText("?");
   panel6.add(
       writtenRowsCount,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label7 = new JLabel();
   label7.setText("Read rows:");
   panel6.add(
       label7,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_EAST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   readRowsCount = new JLabel();
   readRowsCount.setText("?");
   panel6.add(
       readRowsCount,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
 }
  // ambil data dari database untuk tabel
  public void setDataTabel() {
    // combobox jenis
    JComboBox cbJenis = new JComboBox();
    cbJenis.setModel(new DefaultComboBoxModel(dataJenis.toArray()));

    dataProduk = new ArrayList<Produk>();
    try {
      String qry =
          "SELECT * FROM produk,suplier,jenis,stok_produk WHERE produk.id_jenis = jenis.id_jenis AND produk.id_suplier = suplier.id_suplier AND produk.id_produk=stok_produk.id_produk";
      ResultSet rs = stm.executeQuery(qry);
      while (rs.next()) {
        Produk p = new Produk();
        p.setIdProduk(rs.getInt("id_produk"));
        p.setNamaProduk(rs.getString("nama_produk"));
        p.setJenis(rs.getString("nama_jenis"));
        p.setHarga(rs.getInt("harga"));
        p.setStok(rs.getInt("stok"));
        p.setNamaSuplier(rs.getString("nama_suplier"));

        p.setComboJenis(cbJenis);

        dataProduk.add(p);
      }
    } catch (Exception err) {
      err.printStackTrace();
    }

    model = new TableModelProduk(dataProduk);
    tabel.setModel(model);
    tabel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    class EditProdukListener implements TableModelListener {
      public void tableChanged(TableModelEvent tme) {
        int baris = tme.getFirstRow();
        int kolom = tme.getColumn();

        TableModel model = (TableModel) tme.getSource();
        int id = (Integer) model.getValueAt(baris, 0);

        String query = "";
        switch (kolom) {
          case 1:
            String nama = (String) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET nama_produk='" + nama + "' WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 2:
            String jenis = (String) model.getValueAt(baris, kolom);
            try {
              query = "select * from jenis where nama_jenis='" + jenis + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idJenis = rs.getInt("id_jenis");
                query = "UPDATE produk SET id_jenis=" + idJenis + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,jenis tidak ada");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          case 3:
            int stok = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE `stok_produk` SET stok=" + stok + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 4:
            int harga = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET harga=" + harga + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 5:
            String suplier = (String) model.getValueAt(baris, kolom);
            try {
              query = "SELECT * FROM suplier WHERE nama_suplier='" + suplier + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idSuplier = rs.getInt("id_suplier");
                query = "UPDATE produk SET id_suplier=" + idSuplier + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,suplier belum terdaftar");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          default:
            break;
        }
      }

      private void prosesEdit(String query) {
        try {
          int hasil = stm.executeUpdate(query);
          if (hasil == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "edit berhasil");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        }
      }
    }
    model.addTableModelListener(new EditProdukListener());
  }
  /** Create the arrow head choicebox. */
  private JPanel createArrowChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbArrows = new JComboBox();
    cbArrows.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$
    cbArrows.setOpaque(true);
    cbArrows.setEditable(false);
    cbArrows.setEnabled(false);
    cbArrows.setMaximumRowCount(4);
    cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    Vector arrows = new Vector(5);
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"),
        0); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"),
        1); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"),
        2); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"),
        3); //$NON-NLS-1$
    DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows);
    cbArrows.setModel(comboModel);
    cbArrows.setSelectedIndex(0);

    DefaultListCellRenderer comboRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (isSelected) {
              setBackground(list.getSelectionBackground());
              setForeground(list.getSelectionForeground());
            } else {
              setBackground(list.getBackground());
              setForeground(list.getForeground());
            }

            setText((String) value);

            return this;
          }
        };
    cbArrows.setRenderer(comboRenderer);

    cbArrows.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateArrowType(cbArrows.getSelectedIndex());
          }
        });

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbArrows, BorderLayout.CENTER);
    return drawPanel;
  }
Example #10
0
    private void initComponents() {
      label1 = new JLabel();
      comboBox1 = new JComboBox();
      button1 = new JButton();

      // ======== this ========
      setTitle("SneakyFarmer");
      Container contentPane = getContentPane();
      contentPane.setLayout(null);

      // ---- label1 ----
      label1.setText("Which herb to farm:");
      label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 1f));
      contentPane.add(label1);
      label1.setBounds(10, 10, 125, 35);

      // ---- comboBox1 ----
      comboBox1.setModel(
          new DefaultComboBoxModel(
              new String[] {
                "Guam",
                "Marrentill",
                "Tarromin",
                "Harralander",
                "Ranarr",
                "Toadflax",
                "Irit",
                "Avantoe",
                "Kwuarm",
                "Snapdragon",
                "Cadantine",
                "Lantadyme",
                "Dwarf Weed",
                "Torstol"
              }));
      contentPane.add(comboBox1);
      comboBox1.setBounds(135, 10, 90, 35);

      // ---- button1 ----
      button1.setText("Start Farming!");
      button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 7f));
      contentPane.add(button1);
      button1.setBounds(10, 50, 215, 35);
      button1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              startActionPerformed(e);
            }
          });

      { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
          Rectangle bounds = contentPane.getComponent(i).getBounds();
          preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
          preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
      }
      pack();
      setLocationRelativeTo(getOwner());
    }
Example #11
0
  /**
   * Creates basic controls for a type (AUDIO or VIDEO).
   *
   * @param type the type.
   * @return the build Component.
   */
  public static Component createBasicControls(final int type) {
    final JComboBox deviceComboBox = new JComboBox();

    deviceComboBox.setEditable(false);
    deviceComboBox.setModel(
        new DeviceConfigurationComboBoxModel(
            deviceComboBox, mediaService.getDeviceConfiguration(), type));

    JLabel deviceLabel = new JLabel(getLabelText(type));

    deviceLabel.setDisplayedMnemonic(getDisplayedMnemonic(type));
    deviceLabel.setLabelFor(deviceComboBox);

    final Container devicePanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    devicePanel.setMaximumSize(new Dimension(WIDTH, 25));
    devicePanel.add(deviceLabel);
    devicePanel.add(deviceComboBox);

    final JPanel deviceAndPreviewPanel = new TransparentPanel(new BorderLayout());
    int preferredDeviceAndPreviewPanelHeight;

    switch (type) {
      case DeviceConfigurationComboBoxModel.AUDIO:
        preferredDeviceAndPreviewPanelHeight = 225;
        break;
      case DeviceConfigurationComboBoxModel.VIDEO:
        preferredDeviceAndPreviewPanelHeight = 305;
        break;
      default:
        preferredDeviceAndPreviewPanelHeight = 0;
        break;
    }
    if (preferredDeviceAndPreviewPanelHeight > 0)
      deviceAndPreviewPanel.setPreferredSize(
          new Dimension(WIDTH, preferredDeviceAndPreviewPanelHeight));
    deviceAndPreviewPanel.add(devicePanel, BorderLayout.NORTH);

    final ActionListener deviceComboBoxActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            boolean revalidateAndRepaint = false;

            for (int i = deviceAndPreviewPanel.getComponentCount() - 1; i >= 0; i--) {
              Component c = deviceAndPreviewPanel.getComponent(i);

              if (c != devicePanel) {
                deviceAndPreviewPanel.remove(i);
                revalidateAndRepaint = true;
              }
            }

            Component preview = null;

            if ((deviceComboBox.getSelectedItem() != null) && deviceComboBox.isShowing()) {
              preview =
                  createPreview(type, deviceComboBox, deviceAndPreviewPanel.getPreferredSize());
            }

            if (preview != null) {
              deviceAndPreviewPanel.add(preview, BorderLayout.CENTER);
              revalidateAndRepaint = true;
            }

            if (revalidateAndRepaint) {
              deviceAndPreviewPanel.revalidate();
              deviceAndPreviewPanel.repaint();
            }
          }
        };

    deviceComboBox.addActionListener(deviceComboBoxActionListener);
    /*
     * We have to initialize the controls to reflect the configuration
     * at the time of creating this instance. Additionally, because the
     * video preview will stop when it and its associated controls
     * become unnecessary, we have to restart it when the mentioned
     * controls become necessary again. We'll address the two goals
     * described by pretending there's a selection in the video combo
     * box when the combo box in question becomes displayable.
     */
    deviceComboBox.addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent event) {
            if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      deviceComboBoxActionListener.actionPerformed(null);
                    }
                  });
            }
          }
        });

    return deviceAndPreviewPanel;
  }
Example #12
0
  /**
   * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>.
   *
   * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details
   *     are to be created
   * @param container the <tt>JComponent</tt> into which the UI controls which are to control the
   *     details of the specified <tt>audioSystem</tt> are to be added
   */
  public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) {
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;

    int audioSystemFeatures = audioSystem.getFeatures();
    boolean featureNotifyAndPlaybackDevices =
        ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0);

    constraints.gridx = 0;
    constraints.insets = new Insets(3, 0, 3, 3);
    constraints.weightx = 0;

    constraints.gridy = 0;
    container.add(
        new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints);
    if (featureNotifyAndPlaybackDevices) {
      constraints.gridy = 2;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints);
      constraints.gridy = 3;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints);
    }

    constraints.gridx = 1;
    constraints.insets = new Insets(3, 3, 3, 0);
    constraints.weightx = 1;

    JComboBox captureCombo = null;

    if (featureNotifyAndPlaybackDevices) {
      captureCombo = new JComboBox();
      captureCombo.setEditable(false);
      captureCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_CAPTURE));
      constraints.gridy = 0;
      container.add(captureCombo, constraints);
    }

    int anchor = constraints.anchor;
    SoundLevelIndicator capturePreview =
        new SoundLevelIndicator(
            SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridy = (captureCombo == null) ? 0 : 1;
    container.add(capturePreview, constraints);
    constraints.anchor = anchor;

    constraints.gridy = GridBagConstraints.RELATIVE;

    if (featureNotifyAndPlaybackDevices) {
      JComboBox playbackCombo = new JComboBox();

      playbackCombo.setEditable(false);
      playbackCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK));
      container.add(playbackCombo, constraints);

      JComboBox notifyCombo = new JComboBox();

      notifyCombo.setEditable(false);
      notifyCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_NOTIFY));
      container.add(notifyCombo, constraints);
    }

    if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) {
      final SIPCommCheckBox echoCancelCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel());
      echoCancelCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected());
            }
          });
      container.add(echoCancelCheckBox, constraints);
    }

    if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) {
      final SIPCommCheckBox denoiseCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise());
      denoiseCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected());
            }
          });
      container.add(denoiseCheckBox, constraints);
    }

    createAudioPreview(audioSystem, captureCombo, capturePreview);
  }
Example #13
0
    OpPanel(PreferencesExt prefs, boolean isAccess) {
      this.prefs = prefs;
      this.isAccess = isAccess;
      ta = new TextHistoryPane(true);
      infoWindow =
          new IndependentWindow("Details", BAMutil.getImage("netcdfUI"), new JScrollPane(ta));
      Rectangle bounds = (Rectangle) prefs.getBean(FRAME_SIZE, new Rectangle(200, 50, 500, 700));
      infoWindow.setBounds(bounds);

      topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));

      // which server
      serverCB = new JComboBox();
      serverCB.setModel(manage.getServersCB().getModel());
      serverCB.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String server = (String) serverCB.getSelectedItem();
              setServer(server);
            }
          });

      // serverCB.setModel(manage.getServers().getModel());
      topPanel.add(new JLabel("server:"));
      topPanel.add(serverCB);

      // the date selectors
      startDateField = new JTextArea("                    ");
      endDateField = new JTextArea("                    ");

      topPanel.add(new JLabel("Start Date:"));
      topPanel.add(startDateField);
      topPanel.add(new JLabel("End Date:"));
      topPanel.add(endDateField);

      AbstractAction showAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showLogs();
            }
          };
      BAMutil.setActionProperties(showAction, "Import", "get logs", false, 'G', -1);
      BAMutil.addActionToContainer(topPanel, showAction);

      AbstractAction filterAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Boolean state = (Boolean) getValue(BAMutil.STATE);
              removeTestReq = state.booleanValue();
            }
          };
      BAMutil.setActionProperties(filterAction, "time", "remove test Requests", true, 'F', -1);
      BAMutil.addActionToContainer(topPanel, filterAction);

      AbstractAction filter2Action =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Boolean state = (Boolean) getValue(BAMutil.STATE);
              problemsOnly = state.booleanValue();
            }
          };
      BAMutil.setActionProperties(filter2Action, "time", "only show problems", true, 'F', -1);
      BAMutil.addActionToContainer(topPanel, filter2Action);

      AbstractAction infoAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Formatter f = new Formatter();
              showInfo(f);
              ta.setText(f.toString());
              infoWindow.show();
            }
          };
      BAMutil.setActionProperties(
          infoAction, "Information", "info on selected logs", false, 'I', -1);
      BAMutil.addActionToContainer(topPanel, infoAction);

      setLayout(new BorderLayout());
      add(topPanel, BorderLayout.NORTH);
    }
Example #14
0
  public NNNoGoodPartsPanel(LaneManager app) {
    this.app = app;

    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {61, 138, 117, 0};
    gridBagLayout.rowHeights = new int[] {16, 0, 27, 29, 0, 0, 0};
    gridBagLayout.columnWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    setLayout(gridBagLayout);

    JLabel lblNewLabel = new JLabel("No good parts in nest #");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 0;
    add(lblNewLabel, gbc_lblNewLabel);

    noGoodPartsComboBox = new JComboBox();
    noGoodPartsComboBox.setModel(
        new DefaultComboBoxModel(new String[] {"0", "1", "2", "3", "4", "5", "6", "7"}));
    GridBagConstraints gbc_comboBox = new GridBagConstraints();
    gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox.gridx = 1;
    gbc_comboBox.gridy = 0;
    add(noGoodPartsComboBox, gbc_comboBox);

    noPartsSubmitButton = new JButton("Submit");
    GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
    gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);
    gbc_btnNewButton.gridx = 2;
    gbc_btnNewButton.gridy = 0;
    add(noPartsSubmitButton, gbc_btnNewButton);

    JLabel lblNewLabel_1 = new JLabel("Parts unstable in nest #");
    GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
    gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_1.gridx = 0;
    gbc_lblNewLabel_1.gridy = 1;
    add(lblNewLabel_1, gbc_lblNewLabel_1);

    partsUnstableComboBox = new JComboBox();
    partsUnstableComboBox.setModel(
        new DefaultComboBoxModel(new String[] {"0", "1", "2", "3", "4", "5", "6", "7"}));
    GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
    gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_1.gridx = 1;
    gbc_comboBox_1.gridy = 1;
    add(partsUnstableComboBox, gbc_comboBox_1);

    partsUnstableSubmitButton = new JButton("Submit");
    GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
    gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 0);
    gbc_btnNewButton_1.gridx = 2;
    gbc_btnNewButton_1.gridy = 1;
    add(partsUnstableSubmitButton, gbc_btnNewButton_1);

    JLabel lblNewLabel_2 = new JLabel("Robot in way of nest #");
    GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
    gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_2.gridx = 0;
    gbc_lblNewLabel_2.gridy = 2;
    add(lblNewLabel_2, gbc_lblNewLabel_2);

    partsRobotComboBox = new JComboBox();
    partsRobotComboBox.setModel(
        new DefaultComboBoxModel(new String[] {"0", "1", "2", "3", "4", "5", "6", "7"}));
    GridBagConstraints gbc_parts_comboBox = new GridBagConstraints();
    gbc_parts_comboBox.insets = new Insets(0, 0, 5, 5);
    gbc_parts_comboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_parts_comboBox.gridx = 1;
    gbc_parts_comboBox.gridy = 2;
    add(partsRobotComboBox, gbc_parts_comboBox);

    partsRobotSubmitButton = new JButton("Submit");
    GridBagConstraints gbc_button = new GridBagConstraints();
    gbc_button.insets = new Insets(0, 0, 5, 0);
    gbc_button.gridx = 2;
    gbc_button.gridy = 2;
    add(partsRobotSubmitButton, gbc_button);

    JLabel lblNewLabel_3 = new JLabel("Parts Pile Up in Nest #");
    GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
    gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_3.gridx = 0;
    gbc_lblNewLabel_3.gridy = 3;
    add(lblNewLabel_3, gbc_lblNewLabel_3);

    partsPileUpComboBox = new JComboBox();
    partsPileUpComboBox.setModel(
        new DefaultComboBoxModel(new String[] {"0", "1", "2", "3", "4", "5", "6", "7"}));
    GridBagConstraints gbc_pileUp_comboBox = new GridBagConstraints();
    gbc_pileUp_comboBox.insets = new Insets(0, 0, 5, 5);
    gbc_pileUp_comboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_pileUp_comboBox.gridx = 1;
    gbc_pileUp_comboBox.gridy = 3;
    add(partsPileUpComboBox, gbc_pileUp_comboBox);

    partsPileUpSubmitButton = new JButton("Submit");
    GridBagConstraints gbc_pileUp = new GridBagConstraints();
    gbc_pileUp.insets = new Insets(0, 0, 5, 0);
    gbc_pileUp.gridx = 2;
    gbc_pileUp.gridy = 3;
    add(partsPileUpSubmitButton, gbc_pileUp);

    noPartsSubmitButton.addActionListener(this);
    partsUnstableSubmitButton.addActionListener(this);
    partsRobotSubmitButton.addActionListener(this);
    partsPileUpSubmitButton.addActionListener(this);
  }
  public CreateStorageAccountForm() {
    setContentPane(contentPane);
    setModal(true);
    getRootPane().setDefaultButton(buttonOK);

    setTitle("Create Storage Account");

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onOK();
          }
        });

    buttonCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    contentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    regionOrAffinityGroupComboBox.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList jList, Object o, int i, boolean b, boolean b1) {

            return (o instanceof String)
                ? super.getListCellRendererComponent(jList, o, i, b, b1)
                : super.getListCellRendererComponent(jList, "  " + o.toString(), i, b, b1);
          }
        });

    nameTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent documentEvent) {
                validateEmptyFields();
              }

              @Override
              public void removeUpdate(DocumentEvent documentEvent) {
                validateEmptyFields();
              }

              @Override
              public void changedUpdate(DocumentEvent documentEvent) {
                validateEmptyFields();
              }
            });

    regionOrAffinityGroupComboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent itemEvent) {
            validateEmptyFields();
          }
        });

    replicationComboBox.setModel(new DefaultComboBoxModel(ReplicationTypes.values()));
    replicationComboBox.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList jList, Object o, int i, boolean b, boolean b1) {
            return super.getListCellRendererComponent(
                jList, ((ReplicationTypes) o).getDescription(), i, b, b1);
          }
        });
  }
  public ResourceEditor(
      @Nullable ResourceType[] types, Set<AttributeFormat> formats, @Nullable String[] values) {
    myTypes = types;
    myIsDimension = formats.contains(AttributeFormat.Dimension);

    if (formats.contains(AttributeFormat.Boolean)) {
      myCheckBox = new JCheckBox();
      myEditor =
          new ComponentWithBrowseButton<JCheckBox>(myCheckBox, null) {
            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };
      myCheckBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              if (!myIgnoreCheckBoxValue) {
                myBooleanResourceValue = null;
                fireValueCommitted(false, true);
              }
            }
          });
    } else if (formats.contains(AttributeFormat.Enum)) {
      ComboboxWithBrowseButton editor =
          new ComboboxWithBrowseButton(SystemInfo.isWindows ? new MyComboBox() : new JComboBox()) {
            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };

      final JComboBox comboBox = editor.getComboBox();
      DefaultComboBoxModel model = new DefaultComboBoxModel(values);
      model.insertElementAt(StringsComboEditor.UNSET, 0);
      comboBox.setModel(model);
      comboBox.setEditable(true);
      ComboEditor.installListeners(
          comboBox,
          new ComboEditor.ComboEditorListener(this) {
            @Override
            protected void onValueChosen() {
              if (comboBox.getSelectedItem() == StringsComboEditor.UNSET) {
                comboBox.setSelectedItem(null);
              }
              super.onValueChosen();
            }
          });
      myEditor = editor;
      comboBox.setSelectedIndex(0);
    } else {
      myEditor =
          new TextFieldWithBrowseButton() {
            @Override
            protected void installPathCompletion(
                FileChooserDescriptor fileChooserDescriptor, @Nullable Disposable parent) {}

            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };
      myEditor.registerKeyboardAction(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {}
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
          JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

      JTextField textField = getComboText();
      textField.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              fireValueCommitted(false, true);
            }
          });
      textField
          .getDocument()
          .addDocumentListener(
              new DocumentAdapter() {
                @Override
                protected void textChanged(final DocumentEvent e) {
                  preferredSizeChanged();
                }
              });
      selectTextOnFocusGain(textField);
    }

    if (myCheckBox == null) {
      myEditor.registerKeyboardAction(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {}
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
          JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

    myEditor.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showDialog();
          }
        });
    myEditor.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            myEditor.getChildComponent().requestFocus();
          }
        });
  }
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   contentPane = new JPanel();
   contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
   contentPane.setMinimumSize(new Dimension(350, 280));
   contentPane.setPreferredSize(new Dimension(350, 280));
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer1 = new Spacer();
   panel1.add(
       spacer1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
   panel1.add(
       panel2,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   buttonOK = new JButton();
   buttonOK.setText("OK");
   panel2.add(
       buttonOK,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   buttonCancel = new JButton();
   buttonCancel.setText("Cancelar");
   panel2.add(
       buttonCancel,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel3 = new JPanel();
   panel3.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel3,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("Nome");
   panel3.add(
       label1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer2 = new Spacer();
   panel3.add(
       spacer2,
       new GridConstraints(
           6,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_VERTICAL,
           1,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           null,
           null,
           0,
           false));
   txtNome = new JTextField();
   panel3.add(
       txtNome,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("CPF");
   panel3.add(
       label2,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   txtCpf = new JTextField();
   panel3.add(
       txtCpf,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Endereco");
   panel3.add(
       label3,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   txtEndereco = new JTextField();
   panel3.add(
       txtEndereco,
       new GridConstraints(
           2,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Telefone");
   panel3.add(
       label4,
       new GridConstraints(
           3,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label5 = new JLabel();
   label5.setText("Status");
   panel3.add(
       label5,
       new GridConstraints(
           5,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   cboxStatusCliente = new JComboBox();
   final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
   defaultComboBoxModel1.addElement("Inativo");
   defaultComboBoxModel1.addElement("Ativo");
   cboxStatusCliente.setModel(defaultComboBoxModel1);
   panel3.add(
       cboxStatusCliente,
       new GridConstraints(
           5,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label6 = new JLabel();
   label6.setText("E-mail");
   panel3.add(
       label6,
       new GridConstraints(
           4,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   txtEmail = new JTextField();
   panel3.add(
       txtEmail,
       new GridConstraints(
           4,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
   txtTelefone = new JTextField();
   panel3.add(
       txtTelefone,
       new GridConstraints(
           3,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(150, -1),
           null,
           0,
           false));
 }
Example #18
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   contentPane = new JPanel();
   contentPane.setLayout(
       new com.intellij.uiDesigner.core.GridLayoutManager(
           2, 1, new Insets(10, 10, 10, 10), -1, -1));
   final JPanel panel1 = new JPanel();
   panel1.setLayout(
       new com.intellij.uiDesigner.core.GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel1,
       new com.intellij.uiDesigner.core.GridConstraints(
           1,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer();
   panel1.add(
       spacer1,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel2 = new JPanel();
   panel2.setLayout(
       new com.intellij.uiDesigner.core.GridLayoutManager(
           1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
   panel1.add(
       panel2,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   buttonOK = new JButton();
   buttonOK.setText("OK");
   panel2.add(
       buttonOK,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   buttonCancel = new JButton();
   buttonCancel.setText("Cancel");
   panel2.add(
       buttonCancel,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JPanel panel3 = new JPanel();
   panel3.setLayout(
       new com.intellij.uiDesigner.core.GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1));
   contentPane.add(
       panel3,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
           com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   spinnerTamanyHidato = new JSpinner();
   panel3.add(
       spinnerTamanyHidato,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   spinnerForats = new JSpinner();
   panel3.add(
       spinnerForats,
       new com.intellij.uiDesigner.core.GridConstraints(
           1,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   spinnerNumerosPrecolocats = new JSpinner();
   panel3.add(
       spinnerNumerosPrecolocats,
       new com.intellij.uiDesigner.core.GridConstraints(
           2,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("Tamany de l'Hidato");
   panel3.add(
       label1,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("\"Forats\" o caselles no usables");
   panel3.add(
       label2,
       new com.intellij.uiDesigner.core.GridConstraints(
           1,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Numeros pre-colocats");
   panel3.add(
       label3,
       new com.intellij.uiDesigner.core.GridConstraints(
           2,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   comboBoxDificultat = new JComboBox();
   final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
   defaultComboBoxModel1.addElement("Fàcil");
   defaultComboBoxModel1.addElement("Normal");
   defaultComboBoxModel1.addElement("Difícil");
   comboBoxDificultat.setModel(defaultComboBoxModel1);
   panel3.add(
       comboBoxDificultat,
       new com.intellij.uiDesigner.core.GridConstraints(
           3,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Dificultat");
   panel3.add(
       label4,
       new com.intellij.uiDesigner.core.GridConstraints(
           3,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
 }
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
  private void calcTypeComboAction(ActionEvent e) {
    String comboCalcType = (String) calcTypeCombo.getSelectedItem();
    ObjEntity objEntity = objEntityViewField.getObjEntityView().getObjEntity();

    if (comboCalcType.equals("No Calculation")) {
      objEntityViewField.setCalcType("nocalc");

      objRelationshipCombo.setEnabled(false);
      lookupViewCombo.setEnabled(false);
      lookupFieldCombo.setEnabled(false);

      ObjAttribute nullAttribute = null;
      java.util.List attributes = new ArrayList();
      attributes.add(nullAttribute);
      if (objEntity != null) {
        attributes.addAll(objEntity.getObjAttributes());
      }

      DefaultComboBoxModel attributesDefaultModel = new DefaultComboBoxModel(attributes.toArray());
      objAttributeCombo.setModel(attributesDefaultModel);
      objAttributeCombo.setEnabled(true);
      if (objEntity != null) {
        if (objEntityViewField.getObjAttribute() != null) {
          objAttributeCombo.setSelectedItem(objEntityViewField.getObjAttribute());
        } else {
          objAttributeCombo.setSelectedIndex(0);
        }
      } else {
        objAttributeCombo.setSelectedIndex(0);
      }
    }
    if (comboCalcType.equals("Lookup")) {
      objEntityViewField.setCalcType("lookup");

      objAttributeCombo.setEnabled(false);
      objRelationshipCombo.setEnabled(true);
      lookupViewCombo.setEnabled(true);
      lookupFieldCombo.setEnabled(true);

      ObjRelationship nullRelationship = null;
      java.util.List relationships = new ArrayList();
      relationships.add(nullRelationship);
      if (objEntity != null) {
        relationships.addAll(objEntity.getDataMap().getObjRelationshipsBySourceToOne(objEntity));
      }

      DefaultComboBoxModel relationshipsDefaultModel =
          new DefaultComboBoxModel(relationships.toArray());
      objRelationshipCombo.setModel(relationshipsDefaultModel);

      ObjRelationship fieldRelationship = objEntityViewField.getObjRelationship();
      if (fieldRelationship != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = relationships.iterator(); itr.hasNext(); ) {
          ObjRelationship relationship = (ObjRelationship) itr.next();
          if ((relationship != null)
              && (fieldRelationship.getName().equals(relationship.getName()))) {
            objRelationshipCombo.setSelectedItem(fieldRelationship);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          objRelationshipCombo.setSelectedIndex(0);
        }
      } else {
        objRelationshipCombo.setSelectedIndex(0);
      }
    }
  }