Exemplo n.º 1
0
 private void setValueToEditor(LafParameterStorage storage) {
   this.storage = storage;
   if (parameter.getParameterClass() == boolean.class
       || parameter.getParameterClass() == Boolean.class) {
     Boolean value =
         (Boolean) LafParameterProvider.getInstance().getValue(parameter, entityId, storage);
     if (value == null) {
       jcbEditor.setSelectedIndex(0);
     } else if (value) {
       jcbEditor.setSelectedIndex(1);
     } else {
       jcbEditor.setSelectedIndex(2);
     }
   } else {
     Object o = LafParameterProvider.getInstance().getValue(parameter, entityId, storage);
     if (parameter.getFixedValueList() != null) {
       jcbEditor.setSelectedIndex(0);
       for (int i = 0; i < parameter.getFixedValueList().length; i++) {
         if (LangUtils.equals(o, parameter.getFixedValueList()[i])) {
           jcbEditor.setSelectedIndex(i + 1);
         }
       }
     } else {
       jtfEditor.setText(o == null ? "" : o.toString());
     }
   }
 }
Exemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   LafParameterEditor editor = new LafParameterEditor(parameter, entityId, parent);
   editor.run();
   if (editor.okay()) {
     String value = editor.getValueFromEditor();
     LafParameterStorage storage = editor.getSelectedStorage();
     LafParameterProvider.getInstance().setValue(parameter, entityId, storage, value);
   }
 }
Exemplo n.º 3
0
 private void initStorage(
     LafParameterStorage storage, String label, TableLayoutBuilder tbllayStorage) {
   if (LafParameterProvider.getInstance().isStorageAllowed(parameter, storage)) {
     JRadioButton jrb = new JRadioButton(label);
     jrb.setActionCommand(storage.name());
     jrb.addActionListener(this);
     bgStorages.add(jrb);
     tbllayStorage.newRow();
     tbllayStorage.add(jrb);
     if (this.storage == null) {
       jrb.setSelected(true);
       setValueToEditor(storage);
     }
   }
 }
Exemplo n.º 4
0
  public static void installPopup(JComponent c, LafParameter<?> parameter, Long entityId) {
    boolean changeAllowed = false;
    for (LafParameterStorage storage : LafParameterStorage.values()) {
      if (LafParameterProvider.getInstance().isStorageAllowed(parameter, storage)) {
        changeAllowed = true;
      }
    }

    if (changeAllowed) {
      JPopupMenu pm = c.getComponentPopupMenu();
      if (pm == null) {
        pm = new JPopupMenu();
        c.setComponentPopupMenu(pm);
      }
      pm.add(new LafParameterAction(parameter, entityId, c));
    }
  }