예제 #1
0
  private JPanel createFeaturesPanel() {
    JPanel container = new JPanel();
    SwingHelper.removeOpaqueness(container);
    container.setLayout(new MigLayout("fill, insets dialog"));

    JButton newButton = new JButton("New...");
    JButton editButton = new JButton("Edit...");
    JButton deleteButton = new JButton("Delete...");

    container.add(newButton, "span, split 3, sizegroup bttn");
    container.add(editButton, "sizegroup bttn");
    container.add(deleteButton, "sizegroup bttn");

    container.add(SwingHelper.wrapScrollPane(featuresTable), "grow, w 10:100:null, gaptop 10");

    newButton.addActionListener(
        e -> {
          FeaturePattern pattern = new FeaturePattern();
          if (FeaturePatternDialog.showEditor(BuilderConfigDialog.this, pattern)) {
            featuresModel.addFeature(pattern);
          }
        });

    editButton.addActionListener(
        e -> {
          int index = featuresTable.getSelectedRow();
          if (index > -1) {
            FeaturePattern pattern = featuresModel.getFeature(index);
            FeaturePatternDialog.showEditor(BuilderConfigDialog.this, pattern);
            featuresModel.fireTableDataChanged();
          } else {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this, "Select a feature first.", "No Selection");
          }
        });

    deleteButton.addActionListener(
        e -> {
          int index = featuresTable.getSelectedRow();
          if (index > -1) {
            FeaturePattern pattern = featuresModel.getFeature(index);
            if (SwingHelper.confirmDialog(
                BuilderConfigDialog.this,
                "Are you sure that you want to delete '" + pattern.getFeature().getName() + "'?",
                "Delete")) {
              featuresModel.removeFeature(index);
            }
          } else {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this, "Select a feature first.", "No Selection");
          }
        });

    return container;
  }
예제 #2
0
 private void copyFrom() {
   SwingHelper.setTextAndResetCaret(nameText, config.getName());
   SwingHelper.setTextAndResetCaret(titleText, config.getTitle());
   SwingHelper.setTextAndResetCaret(gameVersionText, config.getGameVersion());
   SwingHelper.setTextAndResetCaret(
       launchFlagsArea, SwingHelper.listToLines(config.getLaunchModifier().getFlags()));
   SwingHelper.setTextAndResetCaret(
       userFilesIncludeArea, SwingHelper.listToLines(config.getUserFiles().getInclude()));
   SwingHelper.setTextAndResetCaret(
       userFilesExcludeArea, SwingHelper.listToLines(config.getUserFiles().getExclude()));
   featuresModel = new FeaturePatternTableModel(config.getFeatures());
   featuresTable.setModel(featuresModel);
 }