Ejemplo n.º 1
0
 /** Creates new form MappingPanel */
 public PredefinedMappingBox() {
   ListCellRenderer cbRenderer =
       new DefaultListCellRenderer() {
         @Override
         public Component getListCellRendererComponent(
             JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
           String mapBy = bundle.getString("MAP_BY");
           Component result =
               super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
           if (result instanceof JLabel) {
             if (value instanceof MappingSet) {
               ((JLabel) result).setText((isPopupVisible() ? "   " : "") + value.toString());
             } else if (value instanceof MapByPropertyEntry) {
               ((JLabel) result)
                   .setText(
                       "   "
                           + mapBy.replace(
                               "$property",
                               GraphicSet.translateAttVal(((MapByPropertyEntry) value).property)));
             }
           }
           return result;
         }
       };
   this.setRenderer(cbRenderer);
   PropertyChangeListener pl = pce -> propertyChanged(pce);
   MappingManager.getInstance().addPropertyChangeListener(pl);
   ProfileManager.getInstance().addPropertyChangeListener(pl);
   VisicutModel.getInstance().addPropertyChangeListener(pl);
   this.addActionListener(ae -> comboBoxActionPerformed(ae));
   updateComboBoxContent();
   updateUi();
 }
Ejemplo n.º 2
0
 private void propertyChanged(PropertyChangeEvent pce) {
   if (pce.getSource().equals(VisicutModel.getInstance())) {
     if (VisicutModel.PROP_SELECTEDPART.equals(pce.getPropertyName())) {
       updateComboBoxContent();
       updateUi();
     } else if (VisicutModel.PROP_PLF_PART_UPDATED.equals(pce.getPropertyName())
         && pce.getNewValue().equals(VisicutModel.getInstance().getSelectedPart())) {
       updateUi();
     }
   } else if (pce.getSource().equals(MappingManager.getInstance())
       || pce.getSource().equals(ProfileManager.getInstance())) {
     updateComboBoxContent();
   }
 }