コード例 #1
0
  public void startEditing(final PartType pt) {
    isEditing = true;
    isDeleting = false;
    setUpLeftPanel();

    selectedImagePath = new String(pt.getImagePath());

    leftTitle.setText("Editing Part " + pt.getName());
    nameField.setText(pt.getName());
    numField.setText(String.valueOf(pt.getPartNum()));
    descField.setText(pt.getDescription());
    badChanceScroller.setValue((int) (pt.getBadChance() * 100));
    imageClickablePanels.get(pt.getImagePath()).getHandler().mouseClicked();
    submitButton.setText("Edit >");

    removeAllActionListener(submitButton);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO try and get rid of this hack
            float newChance = (float) badChanceScroller.getValue();

            pt.setName(nameField.getText());
            pt.setPartNum(Integer.parseInt(numField.getText()));
            pt.setDescription(descField.getText());
            pt.setBadChance(newChance / 100);
            pt.setImagePath(selectedImagePath);

            manager.editPart(pt);
            restoreLeftPanel();
          }
        });
  }
コード例 #2
0
  public void startDeleting(final PartType pt) {
    isEditing = false;
    isDeleting = true;
    setUpLeftPanel();

    leftTitle.setText("Deleting Part " + pt.getName());
    nameField.setText(pt.getName());
    nameField.setEnabled(false);
    numField.setText(String.valueOf(pt.getPartNum()));
    numField.setEnabled(false);
    descField.setText(pt.getDescription());
    descField.setEnabled(false);
    badChanceScroller.setValue((int) (pt.getBadChance() * 100));
    badChanceScroller.setEnabled(false);
    imageClickablePanels.get(pt.getImagePath()).getHandler().mouseClicked();
    submitButton.setText("Confirm Delete >");

    removeAllActionListener(submitButton);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            manager.deletePart(pt);
            restoreLeftPanel();
          }
        });
  }