コード例 #1
0
  private void initPointPresentation() {
    OverviewCategory overview =
        view.addOverview(resources.getString("Linguistics.Overview.Border"));
    final IValueView<Integer> familyView =
        overview.addIntegerValueView(resources.getString("Linguistics.Overview.Families"), 1);
    final IValueView<Integer> barbarianView =
        overview.addIntegerValueView(resources.getString("Linguistics.Overview.Barbarian"), 2);
    final LabelledAllotmentView totalView =
        overview.addAlotmentView(resources.getString("Linguistics.Overview.Total"), 2);
    model.addModelChangeListener(
        new RemovableEntryListener<Identifier>() {
          @Override
          public void entryAdded(Identifier entry) {
            updateOverview(familyView, totalView, barbarianView);
          }

          @Override
          public void entryAllowed(boolean complete) {
            // nothing to do;
          }

          @Override
          public void entryRemoved(Identifier entry) {
            updateOverview(familyView, totalView, barbarianView);
          }
        });
    model.addCharacterChangedListener(
        new ChangeListener() {
          @Override
          public void changeOccurred() {
            updateOverview(familyView, totalView, barbarianView);
          }
        });
    updateOverview(familyView, totalView, barbarianView);
  }
コード例 #2
0
 @Override
 public String getLabel(T value) {
   if (isUnselected(value)) {
     return resources.getString("ComboBox.SelectLabel");
   }
   return resources.getString(getKeyForObject(value));
 }
コード例 #3
0
ファイル: AddNewStats.java プロジェクト: Eznoka/anathema
 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);
         }
       });
 }
コード例 #4
0
  @Override
  public void initPresentation() {
    final SmartAction action =
        new SmartAction(
            resources.getString("AnathemaCore.Tools.RepositoryView.DeleteName"),
            new FileUi().getRemoveFileIcon()) {

          @Override
          protected void execute(final Component parentComponent) {
            String message = resources.getString("AnathemaCore.Tools.RepositoryView.DeleteMessage");
            String okButton = resources.getString("AnathemaCore.Tools.RepositoryView.DeleteOk");
            ConfigurableVetor vetor = new ConfigurableVetor(parentComponent, message, okButton);
            vetor.requestPermissionFor(
                new Command() {
                  @Override
                  public void execute() {
                    try {
                      int itemCount = repositoryModel.getPrintNameFilesInSelection().length;
                      repositoryModel.deleteSelection();
                      messaging.addMessage(
                          "AnathemaCore.Tools.RepositoryView.DeleteDoneMessage", itemCount);
                    } catch (RepositoryException e) {
                      MessageDialogFactory.showMessageDialog(
                          parentComponent,
                          new Message(
                              resources.getString(
                                  "AnathemaCore.Tools.RepositoryView.RepositoryError"),
                              e));
                      Logger.getLogger(getClass()).error(e);
                    }
                  }
                });
          }
        };
    action.setToolTipText(resources.getString("AnathemaCore.Tools.RepositoryView.DeleteToolTip"));
    treeView.addActionButton(action);
    repositoryModel.addTreeSelectionChangeListener(
        new ChangeListener() {
          @Override
          public void changeOccurred() {
            action.setEnabled(repositoryModel.canSelectionBeDeleted());
          }
        });
    action.setEnabled(false);
  }
コード例 #5
0
 private String getDisplayString(Object object) {
   if (object == null) {
     return null;
   }
   if (model.isPredefinedLanguage(object)) {
     return resources.getString("Language." + ((Identifier) object).getId());
   }
   return object.toString();
 }
コード例 #6
0
 @Override
 public void initPresentation() {
   String labelText = resources.getString("Intimacies.SelectionLabel");
   BasicUi basicUi = new BasicUi();
   IStringSelectionView selectionView = view.addSelectionView(labelText, basicUi.getAddIcon());
   initSelectionViewListening(selectionView);
   initOverviewView();
   initModelListening(basicUi, selectionView);
   for (IIntimacy intimacy : model.getEntries()) {
     addSubView(basicUi, intimacy);
   }
   reset(selectionView);
 }
コード例 #7
0
ファイル: NewItemCommand.java プロジェクト: engaric/anathema
 @Override
 public void execute() {
   IDialogModelTemplate template = templateFactory.createTemplate();
   if (template == ItemTemplateFactory.NO_TEMPLATE) {
     return;
   }
   try {
     itemCreator.operate(template);
   } catch (PersistenceException e) {
     Message message =
         new Message(resources.getString("AnathemaPersistence.NewMenu.Message.Error"), e);
     MessageUtilities.indicateMessage(
         NewItemCommand.class, SwingApplicationFrame.getParentComponent(), message);
   }
 }
コード例 #8
0
  private void initOverviewView() {
    final IOverviewCategory creationOverview =
        view.createOverview(resources.getString("Intimacies.Overview.BorderLabel"));
    final ILabelledAlotmentView freeIntimaciesView =
        creationOverview.addAlotmentView(resources.getString("Intimacies.Overview.Free"), 2);
    final ILabelledAlotmentView totalIntimaciesView =
        creationOverview.addAlotmentView(resources.getString("Intimacies.Overview.Maximum"), 2);
    final IValueView<Integer> bonusPointsView =
        creationOverview.addIntegerValueView(
            resources.getString("Intimacies.Overview.BonusPoints"), 2);
    final IOverviewCategory experienceOverview =
        view.createOverview(resources.getString("Intimacies.Overview.BorderLabel"));
    final ILabelledAlotmentView experienceMaximumView =
        experienceOverview.addAlotmentView(resources.getString("Intimacies.Overview.Maximum"), 2);
    model.addModelChangeListener(
        new IChangeListener() {
          @Override
          public void changeOccurred() {
            recalculateOverview(
                freeIntimaciesView, totalIntimaciesView, bonusPointsView, experienceMaximumView);
          }
        });
    model.addModelChangeListener(
        new IRemovableEntryListener<IIntimacy>() {
          @Override
          public void entryAdded(IIntimacy entry) {
            recalculateOverview(
                freeIntimaciesView, totalIntimaciesView, bonusPointsView, experienceMaximumView);
          }

          @Override
          public void entryAllowed(boolean complete) {
            // Nothing to do
          }

          @Override
          public void entryRemoved(IIntimacy entry) {
            recalculateOverview(
                freeIntimaciesView, totalIntimaciesView, bonusPointsView, experienceMaximumView);
          }
        });
    model.addCharacterChangeListener(
        new DedicatedCharacterChangeAdapter() {
          @Override
          public void experiencedChanged(boolean experienced) {
            setOverview(experienced, experienceOverview, creationOverview);
          }
        });
    setOverview(model.isCharacterExperienced(), experienceOverview, creationOverview);
    recalculateOverview(
        freeIntimaciesView, totalIntimaciesView, bonusPointsView, experienceMaximumView);
  }
コード例 #9
0
 private void initializeAppearance() {
   interaction.setTooltip(resources.getString("AnathemaCore.Tools.New.Name"));
   interaction.setIcon(new BasicUi().getNewIconPathForTaskbar());
 }
コード例 #10
0
ファイル: AmountMessaging.java プロジェクト: Eznoka/anathema
 public AmountMessaging(IMessaging messaging, Resources resources) {
   this.messaging = messaging;
   this.singleItem = resources.getString("AnathemaCore.Tools.RepositoryView.Item");
   this.multiItem = resources.getString("AnathemaCore.Tools.RepositoryView.Items");
 }
コード例 #11
0
 private String getString(String string) {
   return resources.getString(string);
 }
コード例 #12
0
  @SuppressWarnings("serial")
  private void initEntryPresentation() {
    String labelText = resources.getString("Linguistics.SelectionView.Label");
    AgnosticUIConfiguration<Object> uiConfiguration = new LanguageUiConfiguration();
    final ObjectSelectionViewWithTool<Object> selectionView =
        view.addSelectionView(labelText, uiConfiguration);
    selectionView.setObjects(model.getPredefinedLanguages());
    selectionView.addObjectSelectionChangedListener(
        new ObjectValueListener<Object>() {
          @Override
          public void valueChanged(Object newValue) {
            if (newValue == null) {
              return;
            }
            Identifier definedLanguage = getLanguage(newValue);
            if (definedLanguage == null) {
              model.selectBarbarianLanguage(newValue.toString());
            } else {
              model.selectLanguage(definedLanguage);
            }
          }
        });
    final Tool addButton = selectionView.addTool();
    addButton.setIcon(new BasicUi().getAddIconPath());
    addButton.setCommand(
        new Command() {
          @Override
          public void execute() {
            if (!model.isEntryAllowed()) {
              return;
            }
            model.commitSelection();
          }
        });
    model.addModelChangeListener(
        new RemovableEntryListener<Identifier>() {
          @Override
          public void entryAdded(Identifier entry) {
            addEntry(entry);
            selectionView.setSelectedObject(null);
          }

          @Override
          public void entryAllowed(boolean complete) {
            selectionView.setSelectedObject(model.getSelectedEntry());
            if (complete) {
              addButton.enable();
            } else {
              addButton.disable();
            }
          }

          @Override
          public void entryRemoved(Identifier entry) {
            RemovableEntryView entryView = viewsByEntry.remove(entry);
            entryView.delete();
          }
        });
    for (Identifier language : model.getPredefinedLanguages()) {
      languagesByDisplayName.put(getDisplayString(language), language);
    }
    for (Identifier language : model.getEntries()) {
      addEntry(language);
    }
  }