Exemplo n.º 1
0
  public ConfigurationDialog(final Frame parent, final MiracleGrueGenerator parentGeneratorIn) {
    super(parent, true);

    parentGenerator = parentGeneratorIn;
    setTitle("GCode Generator");
    setLayout(new MigLayout("aligny, top, ins 5, fill"));

    add(new JLabel("Slicing Profile:"), "split 2");

    // This is intended to fix a bug where the "Generate Gcode" button doesn't get enabled
    prefPulldown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            generateButton.setEnabled(true);
            generateButton.requestFocusInWindow();
            generateButton.setFocusPainted(true);
          }
        });
    loadList(prefPulldown); // / Filles UI with the list of MiracleGrue settings/options
    add(prefPulldown, "wrap, growx, gapbottom 10");

    for (MiracleGruePreference preference : parentGenerator.getPreferences()) {
      add(preference.getUI(), "growx, wrap");
    }

    generateButton.setToolTipText("Generates GCode instructions for your machine.");

    add(generateButton, "tag ok, split 2");
    add(cancelButton, "tag cancel");
    generateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            parentGenerator.configSuccess = configureGenerator();
            setVisible(!parentGenerator.configSuccess);
          }
        });
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            parentGenerator.configSuccess = false;
            setVisible(false);
          }
        });
  }