Пример #1
0
  private void updateComboBoxContent() {
    ignoreUiUpdates = true;
    Object selected = this.getSelectedItem();
    this.removeAllItems();
    this.addItem(NONE);
    this.addItem(ONE_PROFILE_FOR_EVERYTHING);
    MappingManager.getInstance().generateDefaultMappings().forEach(this::addItem);
    List<MappingSet> all = MappingManager.getInstance().getAll();
    if (all.size() > 0) {
      this.addItem(PREDEFINED_MAPPINGS);
      all.forEach(this::addItem);
    }

    if (VisicutModel.getInstance().getSelectedPart() != null) {
      Iterable<String> props =
          VisicutModel.getInstance()
              .getSelectedPart()
              .getGraphicObjects()
              .getInterestingAttributes();
      if (props.iterator().hasNext()) {
        this.addItem(BY_PROPERTY);
        int count = 0;
        for (String att : props) {
          if (++count > 4) {
            break;
          }
          this.addItem(new MapByPropertyEntry(att));
        }
      }
    }
    this.addItem(CUSTOM);
    this.setSelectedItem(selected);
    ignoreUiUpdates = false;
  }
Пример #2
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();
 }
Пример #3
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();
   }
 }