コード例 #1
1
 public PropertyAction(RADProperty<?> aProperty) {
   super();
   property = (RADProperty<Object>) aProperty;
   String name = (String) aProperty.getValue("actionName"); // NOI18N
   if (name == null) {
     StringBuilder sb = new StringBuilder(aProperty.getName());
     sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
     name = sb.toString();
   }
   putValue(Action.NAME, name);
 }
コード例 #2
0
 @Override
 public void actionPerformed(java.awt.event.ActionEvent e) {
   try {
     PropertyEditor propEd = property.getPropertyEditor();
     propEd.setValue(property.getValue());
     final Component custEditor = propEd.getCustomEditor();
     Object[] options = buttons();
     DialogDescriptor descriptor =
         new DialogDescriptor(
             custEditor,
             (String) getValue(Action.NAME),
             true,
             options,
             DialogDescriptor.CANCEL_OPTION,
             DialogDescriptor.DEFAULT_ALIGN,
             HelpCtx.DEFAULT_HELP,
             (ActionEvent e1) -> {
               try {
                 String action = e1.getActionCommand();
                 switch (action) {
                   case OK_COMMAND:
                     Object value = property.getPropertyEditor().getValue();
                     property.setValue(value);
                     break;
                   case RESTORE_COMMAND:
                     property.restoreDefaultValue();
                     break;
                 }
                 dialog.dispose();
               } catch (Exception ex) {
                 NotifyDescriptor descriptor2 =
                     new NotifyDescriptor.Message(
                         NbBundle.getMessage(PropertyAction.class, "MSG_InvalidValue")); // NOI18N
                 DialogDisplayer.getDefault().notify(descriptor2);
               }
             });
     descriptor.setClosingOptions(new Object[0]);
     dialog = DialogDisplayer.getDefault().createDialog(descriptor);
     dialog.setVisible(true);
     dialog = null;
   } catch (Exception ex) {
     ErrorManager.getDefault().notify(ex);
   }
 }