コード例 #1
0
    /** @param menu */
    public void createFormatterMenuItem(JPopupMenu menu) {
      if (!dataObjFieldWrapper.isPureField()) {
        // can't define a formatter if it's not a real field,
        // so let's not create the menu item for it
        return;
      }

      ActionListener openFormatterAL =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              // open UI field formatter dialog to format this field
              DBFieldInfo fi = dataObjFieldWrapper.getFormatterField().getFieldInfo();
              UIFormatterListEdtDlg dlg =
                  new UIFormatterListEdtDlg(
                      (Frame) UIRegistry.getTopWindow(), fi, true, uiFieldFormatterMgrCache);
              dlg.setVisible(true);

              if (dlg.getBtnPressed() == CustomDialog.OK_BTN) {
                if (dlg.getSelectedFormat() != null) {
                  setFormatter(dlg.getSelectedFormat());
                }
              }
            }
          };

      JMenuItem item = new JMenuItem(getResourceString("DOF_CHANGE_FORMAT"));
      item.addActionListener(openFormatterAL);
      menu.add(item);
    }
コード例 #2
0
    public FieldDefinitionComp(DataObjDataFieldWrapper dataObjFieldWrapper) {
      this.dataObjFieldWrapper = dataObjFieldWrapper;

      // System.err.println("-------> ["+dataObjFieldWrapper.toString()+"]");
      setText(dataObjFieldWrapper.toString());
      setCursor(Cursor.getDefaultCursor());
      setFont(new Font("Arial", Font.PLAIN, 11));
      setAlignmentY(0.75f);
      setBackground(new Color(0, 0, 0, 30));
      setOpaque(true);
      setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

      // create popup menu
      final JPopupMenu menu = createPopupMenu();

      addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              JLabel thisBtn = FieldDefinitionComp.this;
              menu.show(thisBtn, thisBtn.getWidth() / 2, thisBtn.getHeight());
            }
          });
    }
コード例 #3
0
 /** @param fmt */
 protected void setFormatter(UIFieldFormatterIFace fmt) {
   dataObjFieldWrapper.getFormatterField().setUiFieldFormatter(fmt);
 }
コード例 #4
0
 /** @return */
 public DataObjDataField getValue() {
   return dataObjFieldWrapper.getFormatterField();
 }