예제 #1
0
  BeanItemPanel usageDetails() {
    BeanItemPanel usage = new BeanItemPanel();

    usage.setName(Bundle.getMessage("Usage"));
    usage.setLayout(new BoxLayout(usage, BoxLayout.Y_AXIS));

    usage.addItem(
        new BeanEditItem(null, null, Bundle.getMessage("UsageText", bean.getDisplayName())));

    ArrayList<String> listeners = new ArrayList<String>();
    for (String ref : bean.getListenerRefs()) {
      if (!listeners.contains(ref)) {
        listeners.add(ref);
      }
    }

    Object[] strArray = new Object[listeners.size()];
    listeners.toArray(strArray);
    JList<Object> list = new JList<Object>(strArray);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setVisibleRowCount(-1);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black)));
    usage.addItem(new BeanEditItem(listScroller, Bundle.getMessage("ColumnLocation"), null));

    bei.add(usage);
    return usage;
  }
예제 #2
0
  public void actionPerformed(ActionEvent e) {
    if (bean == null) {
      log.error("No bean set so unable to edit a null bean"); // IN18N
      return;
    }
    if (f == null) {
      f = new JmriJFrame("Edit " + getBeanType() + " " + bean.getDisplayName(), false, false);
      f.addHelpMenu(helpTarget(), true);
      java.awt.Container containerPanel = f.getContentPane();
      initPanelsFirst();
      initPanels();
      initPanelsLast();

      for (BeanItemPanel bi : bei) {
        addToPanel(bi, bi.getListOfItems());
        detailsTab.addTab(bi.getName(), bi);
      }

      containerPanel.add(detailsTab, BorderLayout.CENTER);
      JPanel buttons = new JPanel();
      JButton applyBut = new JButton(Bundle.getMessage("ButtonApply"));
      applyBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              applyButtonAction(e);
            }
          });
      JButton okBut = new JButton(Bundle.getMessage("ButtonOK"));
      okBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              applyButtonAction(e);
              f.dispose();
            }
          });
      JButton cancelBut = new JButton(Bundle.getMessage("ButtonCancel"));
      cancelBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              cancelButtonAction(e);
            }
          });
      buttons.add(applyBut);
      buttons.add(okBut);
      buttons.add(cancelBut);
      containerPanel.add(buttons, BorderLayout.SOUTH);
    }
    for (BeanItemPanel bi : bei) {
      bi.resetField();
    }
    if (selectedTab != null) {
      detailsTab.setSelectedComponent(selectedTab);
    }
    f.pack();
    f.setVisible(true);
  }
예제 #3
0
  /**
   * Creates a generic panel that holds the basic bean information System Name, User Name and
   * Comment
   */
  BeanItemPanel basicDetails() {
    BeanItemPanel basic = new BeanItemPanel();

    basic.setName(Bundle.getMessage("Basic"));
    basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS));

    basic.addItem(
        new BeanEditItem(
            new JLabel(bean.getSystemName()), Bundle.getMessage("ColumnSystemName"), null));

    basic.addItem(new BeanEditItem(userNameField, Bundle.getMessage("ColumnUserName"), null));

    basic.addItem(new BeanEditItem(commentFieldScroller, Bundle.getMessage("ColumnComment"), null));

    basic.setSaveItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = -1823311798750191527L;

          public void actionPerformed(ActionEvent e) {
            saveBasicItems(e);
          }
        });
    basic.setResetItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = 2590436299984618901L;

          public void actionPerformed(ActionEvent e) {
            resetBasicItems(e);
          }
        });
    bei.add(basic);
    return basic;
  }
예제 #4
0
  BeanItemPanel propertiesDetails() {
    BeanItemPanel properties = new BeanItemPanel();
    properties.setName(Bundle.getMessage("Properties"));
    properties.addItem(
        new BeanEditItem(null, null, Bundle.getMessage("NamedBeanPropertiesTableDescription")));
    properties.setLayout(new BoxLayout(properties, BoxLayout.Y_AXIS));
    propertiesModel = new BeanPropertiesTableModel();
    JTable jtAttributes = new JTable();
    jtAttributes.setModel(propertiesModel);
    JScrollPane jsp = new JScrollPane(jtAttributes);
    Dimension tableDim = new Dimension(400, 200);
    jsp.setMinimumSize(tableDim);
    jsp.setMaximumSize(tableDim);
    jsp.setPreferredSize(tableDim);
    properties.addItem(new BeanEditItem(jsp, "", null));
    properties.setSaveItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = -5627203723098157467L;

          public void actionPerformed(ActionEvent e) {
            propertiesModel.updateModel(bean);
          }
        });
    properties.setResetItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = -956489116413677732L;

          public void actionPerformed(ActionEvent e) {
            propertiesModel.setModel(bean);
          }
        });

    bei.add(properties);
    return properties;
  }
예제 #5
0
 public void save() {
   for (BeanItemPanel bi : bei) {
     bi.saveItem();
   }
 }