Beispiel #1
0
 /**
  * Builds a field for a directory, with a button for bringing the file chooser.
  *
  * @param locale The locale to use for creating the panel.
  * @param label An optional label to put before the directory field, or {@code null}.
  * @param vertical {@code true} if the button should be on the bottom instead than on the right
  *     side.
  */
 public FileField(final Locale locale, final String label, final boolean vertical) {
   setLayout(new BorderLayout());
   if (label != null) {
     add(
         new JLabel(label),
         vertical ? BorderLayout.BEFORE_FIRST_LINE : BorderLayout.BEFORE_LINE_BEGINS);
   }
   add(file, BorderLayout.CENTER);
   final JButton open =
       new JButton(
           vertical
               ? Vocabulary.getResources(locale).getMenuLabel(Vocabulary.Keys.Choose)
               : "...");
   add(open, vertical ? BorderLayout.AFTER_LAST_LINE : BorderLayout.AFTER_LINE_ENDS);
   open.addActionListener(this);
 }
 /**
  * Returns the name of the given column. The columns shall matches the ones documented in {@link
  * MetadataTreeTable}.
  */
 @Override
 public String getColumnName(int column) {
   final short key;
   if (column >= VALUE_COLUMN) {
     column += COLUMN_COUNT - getColumnCount();
     // Skip the "values" column if it doesn't exist.
   }
   switch (column) {
     case 0:
       key = Vocabulary.Keys.Name;
       break;
     case 1:
       key = Vocabulary.Keys.Description;
       break;
     case 2:
       key = Vocabulary.Keys.Type;
       break;
     case 3:
       key = Vocabulary.Keys.Occurrence;
       break;
     case VALUE_COLUMN:
       key = Vocabulary.Keys.Value;
       break;
     case 5:
       key = Vocabulary.Keys.Default;
       break;
     case 6:
       key = Vocabulary.Keys.ValidValues;
       break;
     case COLUMN_COUNT:
       // The later is added only for making sure at compile-time that
       // we are not declaring more columns than the expected number.
     default:
       return super.getColumnName(column);
   }
   final Component owner = this.owner;
   return Vocabulary.getResources(owner != null ? owner.getLocale() : null).getString(key);
 }