Beispiel #1
0
 public void addTool(
     final NewStatsConfiguration newStatsConfiguration,
     ToolListView<IEquipmentStats> statsListView) {
   final Tool newTool = statsListView.addTool();
   newTool.setTooltip(resources.getString(newStatsConfiguration.getTooltipKey()));
   newTool.setIcon(newStatsConfiguration.getIconPath());
   newTool.setOverlay(new RelativePath("icons/ButtonPlus16.png"));
   newTool.setCommand(
       new Command() {
         @Override
         public void execute() {
           List<String> definedNames = new ArrayList<>();
           for (IEquipmentStats stats : editModel.getStats()) {
             definedNames.add(stats.getName().getId());
           }
           String nameProposal = resources.getString(newStatsConfiguration.getNameKey());
           String[] nameArray = definedNames.toArray(new String[definedNames.size()]);
           IEquipmentStats equipmentStats =
               statsFactory.createNewStats(
                   nameArray, nameProposal, newStatsConfiguration.getType());
           editModel.addStatistics(equipmentStats);
         }
       });
   controlAvailability(newStatsConfiguration, newTool);
   editModel.addCompositionChangeListener(
       new ChangeListener() {
         @Override
         public void changeOccurred() {
           controlAvailability(newStatsConfiguration, newTool);
         }
       });
 }
Beispiel #2
0
 private void controlAvailability(NewStatsConfiguration newStatsConfiguration, Tool newTool) {
   if (statsFactory.canHaveThisKindOfStats(
       newStatsConfiguration.getType(), editModel.getMaterialComposition())) {
     newTool.enable();
   } else {
     newTool.disable();
   }
 }