Exemplo n.º 1
0
  /** Does pre-miraclegrue generation tasks */
  protected boolean configureGenerator() {
    if (!parentGenerator.runSanityChecks()) {
      return false;
    }

    int idx = prefPulldown.getSelectedIndex();

    if (idx == -1) {
      return false;
    }

    MgProfile p = ProfileUtils.getListedProfile(prefPulldown.getModel(), profiles, idx);
    Base.preferences.put("lastGeneratorProfileSelected", p.toString());
    parentGenerator.profile = p.getFullPath();
    MiracleGrueGenerator.setSelectedProfile(p.toString());
    return true;
  }
Exemplo n.º 2
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);
          }
        });
  }
Exemplo n.º 3
0
  /**
   * Fills a combo box with a list of miraclegrue profiles
   *
   * @param comboBox to fill with list of miraclegrue profiles
   */
  private void loadList(JComboBox comboBox) {
    comboBox.removeAllItems();
    profiles = parentGenerator.getProfiles();
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    int i = 0;
    int foundLastProfile = -1;
    for (MgProfile p : profiles) {
      // Check that this profile says it's for this machine
      if (ProfileUtils.shouldDisplay(p)) {
        model.addElement(p.toString());

        if (p.toString().equals(Base.preferences.get("lastGeneratorProfileSelected", "---"))) {
          Base.logger.fine("Selecting last used element: " + p);
          foundLastProfile = i;
        }
        i++;
      }
    }
    comboBox.setModel(model);
    if (foundLastProfile != -1) {
      comboBox.setSelectedIndex(foundLastProfile);
    }
  }