Exemplo n.º 1
0
  private JPanel buildCheckboxPanel() {
    JPanel tp = new JPanel();

    tp.setBorder(BorderFactory.createTitledBorder("Webserver Options"));
    tp.setLayout(new GridLayout(1, 2));
    String doLocalServer = JConfig.queryConfiguration("server.enabled", "false");
    String doAllowSyndication = JConfig.queryConfiguration("allow.syndication", "true");

    localServerBrowseBox = new JCheckBox("Use internal web server");
    localServerBrowseBox.setToolTipText(
        "<html><body>Turning this on enables JBidwatchers internal web server; 'Show in Browser' will go through JBidwatcher<br>first, in order to allow it to show old/deleted auctions,and to avoid the need to log in regularly.<br>The internal web server is password protected with your auction server username/password.</body></html>");
    // localServerBrowseBox.setToolTipText("Turning this on enables JBidwatchers internal web
    // server; 'Show in Browser' will go through JBidwatcher first, in order to allow it to show
    // old/deleted auctions, and to avoid the need to log in regularly.  The internal web server is
    // password protected with your auction server username/password.");
    localServerBrowseBox.setSelected(doLocalServer.equals("true"));
    tp.add(localServerBrowseBox);

    openSyndication = new JCheckBox("Allow syndication to bypass authentication");
    openSyndication.setToolTipText(
        "Allows syndication requests and thumbnail requests to be resolved without requiring a username/password.");
    openSyndication.setSelected(doAllowSyndication.equals("true"));
    tp.add(openSyndication);

    return tp;
  }
Exemplo n.º 2
0
 // Modifies button text and tool tips
 private void setPrintButtonText() {
   if (printPreviewBox.isSelected()) {
     printButton.setText(Bundle.getMessage("Preview"));
     printButton.setToolTipText(Bundle.getMessage("PreviewSelectedTip"));
     buildReportBox.setToolTipText(Bundle.getMessage("BuildReportPreviewTip"));
   } else {
     printButton.setText(Bundle.getMessage("Print"));
     printButton.setToolTipText(Bundle.getMessage("PrintSelectedTip"));
     buildReportBox.setToolTipText(Bundle.getMessage("BuildReportPrintTip"));
   }
 }
Exemplo n.º 3
0
 private JCheckBox getChkInverse() {
   if (chkInverse == null) {
     chkInverse = new JCheckBox();
     chkInverse.setToolTipText(Constant.messages.getString("search.toolbar.tooltip.inverse"));
   }
   return chkInverse;
 }
Exemplo n.º 4
0
  public static JCheckBox addCheckBox(
      String text,
      Function method,
      boolean selected,
      String tooltip,
      boolean enabled,
      boolean visible,
      final IClientPluginAccess pluginAccess) {
    JCheckBox box = new JCheckBox(text);
    box.setSelected(selected);
    box.setEnabled(enabled);
    box.setVisible(visible);
    box.setToolTipText(tooltip);

    final FunctionDefinition functionDef = new FunctionDefinition(method);
    box.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JCheckBox source = (JCheckBox) e.getSource();

            Object args[] = new Object[4];

            args[0] = ((Toolbar) source.getParent()).getName();
            args[1] = ((Toolbar) source.getParent()).getDisplayName();
            args[2] = new Boolean(source.isSelected());
            args[3] = source.getText();

            functionDef.executeAsync(pluginAccess, args);
          }
        });

    return box;
  }
Exemplo n.º 5
0
 /**
  * Creates a new checkbox with manageable width.
  *
  * @param aText Text of the checkbox.
  * @param aToolTip Tooltip text for the checkbox. Set this to <code>null</code> if no tooltip is
  *     to be displayed.
  * @param aListener Checkbox click's listener.
  * @return Newly created instance of <code>JCheckBox</code>.
  */
 public static JCheckBox createCheckBox(String aText, String aToolTip, ActionListener aListener) {
   JCheckBox button = new JCheckBox(aText);
   button.setToolTipText(aToolTip);
   button.addActionListener(aListener);
   button.setMaximumSize(new Dimension(Short.MAX_VALUE, button.getHeight()));
   return button;
 }
Exemplo n.º 6
0
  private void refreshLanguage() {
    uploadPrioLabel.setText(language.getString("Options.news.1.messageUploadPriority") + " (2)");
    downloadPrioLabel.setText(
        language.getString("Options.news.1.messageDownloadPriority") + " (2)");
    useOneConnectionForMessagesCheckBox.setText(
        language.getString("Options.news.1.useOneConnectionForMessages"));
    displayDaysLabel.setText(language.getString("Options.news.1.numberOfDaysToDisplay") + " (15)");
    downloadDaysLabel.setText(
        language.getString("Options.news.1.numberOfDaysToDownloadBackwards") + " (5)");
    messageBaseLabel.setText(language.getString("Options.news.1.messageBase") + " (news)");
    alwaysDownloadBackloadCheckBox.setText(
        language.getString("Options.news.1.alwaysDownloadBackload"));
    alwaysDownloadBackloadCheckBox.setToolTipText(
        language.getString("Options.news.1.alwaysDownloadBackload.tooltip"));

    final String minutes = language.getString("Options.common.minutes");

    minimumIntervalLabel.setText(
        language.getString("Options.news.3.minimumUpdateInterval") + " (" + minutes + ") (45)");
    concurrentUpdatesLabel.setText(
        language.getString("Options.news.3.numberOfConcurrentlyUpdatingBoards") + " (6)");

    automaticBoardUpdateCheckBox.setText(language.getString("Options.news.3.automaticBoardUpdate"));

    storeSentMessagesCheckBox.setText(language.getString("Options.news.1.storeSentMessages"));
    silentlyRetryCheckBox.setText(language.getString("Options.news.3.silentlyRetryFailedMessages"));

    final String off = language.getString("Options.common.off");
    altEditCheckBox.setText(
        language.getString("Options.miscellaneous.useEditorForWritingMessages") + " (" + off + ")");
  }
Exemplo n.º 7
0
  public CommandLine(DoOperationActionListener opListener) {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0, 0, 0, 5);
    add(new JLabel("cmd>"), gbc);

    cmdText.setBorder(new LineBorder(Color.BLACK));
    cmdText.setText("/");
    cmdText.setLineWrap(true);
    cmdText.setRows(1);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 100.0;
    add(cmdText, gbc);

    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    cmdText.getInputMap().put(enterKey, SUBMIT_ACTION);
    cmdText.getActionMap().put(SUBMIT_ACTION, opListener);

    JPanel submitPanel = new JPanel(new GridLayout(2, 1));
    submitButton.addActionListener(opListener);
    submitButton.setToolTipText("Submit the command to the server.");
    submitPanel.add(submitButton);

    isVerbose.setToolTipText("Show the command's DMR request.");
    submitPanel.add(isVerbose);

    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gbc.weightx = 1.0;
    add(submitPanel, gbc);
  }
Exemplo n.º 8
0
  public void actionPerformed(ActionEvent e) {

    JCheckBox layer = new JCheckBox(tr("Separate Layer"));
    layer.setToolTipText(tr("Select if the data should be downloaded into a new layer"));
    layer.setSelected(Main.pref.getBoolean("download.newlayer"));
    JPanel all = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;
    gc.anchor = GridBagConstraints.FIRST_LINE_START;
    all.add(new JLabel(tr("Enter URL to download:")), gc);
    HistoryComboBox uploadAdresses = new HistoryComboBox();
    uploadAdresses.setToolTipText(tr("Enter an URL from where data should be downloaded"));
    restoreUploadAddressHistory(uploadAdresses);
    gc.gridy = 1;
    all.add(uploadAdresses, gc);
    gc.gridy = 2;
    gc.fill = GridBagConstraints.BOTH;
    gc.weighty = 1.0;
    all.add(layer, gc);
    ExtendedDialog dialog =
        new ExtendedDialog(
            Main.parent, tr("Download Location"), new String[] {tr("Download URL"), tr("Cancel")});
    dialog.setContent(all, false /* don't embedded content in JScrollpane  */);
    dialog.setButtonIcons(new String[] {"download.png", "cancel.png"});
    dialog.setToolTipTexts(
        new String[] {tr("Start downloading data"), tr("Close dialog and cancel downloading")});
    dialog.configureContextsensitiveHelp("/Action/OpenLocation", true /* show help button */);
    dialog.showDialog();
    if (dialog.getValue() != 1) return;
    remindUploadAddressHistory(uploadAdresses);
    openUrl(layer.isSelected(), uploadAdresses.getText());
  }
Exemplo n.º 9
0
  public void crearPropiedad(
      int min, int max, int defecto, String unidades, String nombrePropiedad) {

    final SelectorPropiedad sp = new SelectorPropiedad(min, max);
    sp.setLabelUnidades(unidades);

    if (this.selectoresPropiedad.size() == 0) {
      MouseAdapter ma =
          new MouseAdapter() {

            public void mouseClicked(MouseEvent mouseEvent) {

              if (mouseEvent.getButton() == MouseEvent.BUTTON1 && mouseEvent.isControlDown()) {
                CheckBoxMedida.super.setSelected(true);
                for (int i = 0; i < CheckBoxMedida.this.selectoresPropiedad.size(); i++) {

                  JDialog jd = CheckBoxMedida.this.getDialogoSeleccionPropiedad(i);
                  jd.setVisible(true);
                }
              }
            }
          };
      super.addMouseListener(ma);
    }

    sp.slider.setValue(defecto);
    this.selectoresPropiedad.add(sp);
    this.nombrePropiedad.add(nombrePropiedad);
    super.setToolTipText("Ctrl + click to select " + nombrePropiedad);
  }
Exemplo n.º 10
0
 public VcsGeneratedFilesPanel(Project project) {
   myProject = project;
   setLayout(new BorderLayout());
   JPanel generatedFilesPanel = new JPanel(new BorderLayout());
   generatedFilesPanel.setBorder(new TitledBorder("Generated Files"));
   myIgnoreGeneratedFilesCheckBox.setToolTipText(
       "Do not store generated files and model caches (source_gen/*, source_gen.caches/*) in repository");
   generatedFilesPanel.add(myIgnoreGeneratedFilesCheckBox);
   add(generatedFilesPanel, BorderLayout.NORTH);
 }
Exemplo n.º 11
0
  /**
   * Allow the tester to manage its own preferences
   *
   * @param testPanel The panel to add any preferences component
   */
  public void addGui(JPanel testPanel) {
    checkEnabled = new JCheckBox(name, enabled);
    checkEnabled.setToolTipText(description);
    testPanel.add(checkEnabled, GBC.std());

    GBC a = GBC.eol();
    a.anchor = GridBagConstraints.EAST;
    checkBeforeUpload = new JCheckBox();
    checkBeforeUpload.setSelected(testBeforeUpload);
    testPanel.add(checkBeforeUpload, a);
  }
Exemplo n.º 12
0
  private JPanel buildExtraSettings() {
    JPanel tp = new JPanel();
    tp.setBorder(BorderFactory.createTitledBorder("Snipe Settings"));
    tp.setLayout(new BorderLayout());

    autoSubtractShippingBox =
        new JCheckBox("Subtract shipping/insurance from bid amounts by default");
    autoSubtractShippingBox.setToolTipText(
        "Determines the default behaviour of deducting shipping/insurance from bid amounts. This behaviour can be overridden on a per-bid basis.");

    tp.add(autoSubtractShippingBox);
    return tp;
  }
Exemplo n.º 13
0
  private JCheckBox addCheckBoxRow(String name, String tip, boolean value, JPanel parent) {
    JPanel box = new JPanel();
    box.setLayout(new FlowLayout(FlowLayout.LEFT));

    JCheckBox checkBox = new JCheckBox(name);
    checkBox.setEnabled(true);
    checkBox.addItemListener(this);
    checkBox.setToolTipText(tip);
    box.add(checkBox);
    parent.add(box);
    if (value) checkBox.setSelected(true);
    else checkBox.setSelected(false);
    return checkBox;
  }
Exemplo n.º 14
0
    public SchemaTabs() {
      super();
      conflicts = new JPanel();
      conflicts.setLayout(new BorderLayout());
      auto = new JCheckBox("Auto-Resolve");
      auto.setToolTipText("Automatically modify inferred schema from received Responses");
      auto.setOpaque(false);
      UISupport.setFixedSize(auto, 120, 20);
      XmlBeansSettingsImpl settings = getRequest().getSettings();
      if (settings.isSet(AUTO_INFER_SCHEMAS)) {
        auto.setSelected(settings.getBoolean(AUTO_INFER_SCHEMAS));
      }
      auto.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              getRequest().getSettings().setBoolean(AUTO_INFER_SCHEMAS, auto.isSelected());
            }
          });
      resolveButton = new JButton("Resolve conflicts");
      resolveButton.setEnabled(false);
      resolveButton.setActionCommand("resolve");
      resolveButton.addActionListener(this);

      JXToolBar toolbar = UISupport.createToolbar();
      toolbar.addFixed(auto);
      toolbar.addFixed(resolveButton);

      log = new JLogList("Schema log");
      conflicts.add(toolbar, BorderLayout.NORTH);
      conflicts.add(log, BorderLayout.CENTER);
      addTab("Conflicts", conflicts);

      schemaList = new JList(InferredSchemaManager.getInferredSchema(service).getNamespaces());
      schemaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      schemaList.addListSelectionListener(this);

      toolbar = UISupport.createToolbar();
      toolbar.addFixed(UISupport.createToolbarButton(new RemoveNamespaceAction()));

      JPanel listPanel = new JPanel();
      listPanel.setLayout(new BorderLayout());
      listPanel.add(toolbar, BorderLayout.NORTH);
      listPanel.add(new JScrollPane(schemaList), BorderLayout.CENTER);
      xsd = JXEditTextArea.createXmlEditor(false);
      xsd.setEditable(false);
      update();
      addTab(
          "Schemas", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listPanel, new JScrollPane(xsd)));
    }
  public DvcsCommitAdditionalComponent(
      @NotNull final Project project, @NotNull CheckinProjectPanel panel) {
    myCheckinPanel = panel;
    myPanel = new JPanel(new GridBagLayout());
    final Insets insets = new Insets(2, 2, 2, 2);
    // add amend checkbox
    GridBagConstraints c = new GridBagConstraints();
    // todo change to MigLayout
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = insets;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;

    myAmend = new NonFocusableCheckBox(DvcsBundle.message("commit.amend"));
    myAmend.setMnemonic('m');
    myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip"));
    myPreviousMessage = myCheckinPanel.getCommitMessage();

    myAmend.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (myAmend.isSelected()) {
              if (myPreviousMessage.equals(
                  myCheckinPanel
                      .getCommitMessage())) { // if user has already typed something, don't revert
                                              // it
                if (myMessagesForRoots == null) {
                  loadMessagesInModalTask(project); // load all commit messages for all repositories
                }
                String message = constructAmendedMessage();
                if (!StringUtil.isEmptyOrSpaces(message)) {
                  myAmendedMessage = message;
                  substituteCommitMessage(myAmendedMessage);
                }
              }
            } else {
              // there was the amended message, but user has changed it => not reverting
              if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) {
                myCheckinPanel.setCommitMessage(myPreviousMessage);
              }
            }
          }
        });
    myPanel.add(myAmend, c);
  }
Exemplo n.º 16
0
  protected void addPostQueryCheckBox(JXToolBar toolbar) {
    postQueryCheckBox = new JCheckBox("Post QueryString", httpRequest.isPostQueryString());
    postQueryCheckBox.setToolTipText("Controls if Query-parameters should be put in message body");
    postQueryCheckBox.setOpaque(false);
    postQueryCheckBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            httpRequest.setPostQueryString(postQueryCheckBox.isSelected());
            enableBodyComponents();
          }
        });

    postQueryCheckBox.setPreferredSize(new Dimension(130, 20));
    toolbar.addFixed(postQueryCheckBox);
  }
  @Override
  public void update(final AnActionEvent e) {
    super.update(e);
    Presentation presentation = e.getPresentation();
    Object property = presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY);
    if (property instanceof JCheckBox) {
      JCheckBox checkBox = (JCheckBox) property;

      checkBox.setText(presentation.getText());
      checkBox.setToolTipText(presentation.getDescription());
      checkBox.setMnemonic(presentation.getMnemonic());
      checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex());
      checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)));

      checkBox.setEnabled(presentation.isEnabled());
      checkBox.setVisible(presentation.isVisible());
    }
  }
 public SkeinforgeBooleanPreference(
     String name, final String preferenceName, boolean defaultState, String toolTip) {
   isSet = defaultState;
   if (preferenceName != null) {
     isSet = Base.preferences.getBoolean(preferenceName, defaultState);
   }
   component = new JCheckBox(name, isSet);
   component.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           isSet = component.isSelected();
           if (preferenceName != null) {
             Base.preferences.putBoolean(preferenceName, isSet);
           }
         }
       });
   if (toolTip != null) {
     component.setToolTipText(toolTip);
   }
 }
Exemplo n.º 19
0
  public AmendComponent(
      @NotNull Project project,
      @NotNull RepositoryManager<? extends Repository> repoManager,
      @NotNull CheckinProjectPanel panel,
      @NotNull String title) {
    myRepoManager = repoManager;
    myCheckinPanel = panel;
    myAmend = new NonFocusableCheckBox(title);
    myAmend.setMnemonic('m');
    myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip"));
    myPreviousMessage = myCheckinPanel.getCommitMessage();

    myAmend.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (myAmend.isSelected()) {
              if (myPreviousMessage.equals(
                  myCheckinPanel
                      .getCommitMessage())) { // if user has already typed something, don't revert
                                              // it
                if (myMessagesForRoots == null) {
                  loadMessagesInModalTask(project); // load all commit messages for all repositories
                }
                String message = constructAmendedMessage();
                if (!StringUtil.isEmptyOrSpaces(message)) {
                  myAmendedMessage = message;
                  substituteCommitMessage(myAmendedMessage);
                }
              }
            } else {
              // there was the amended message, but user has changed it => not reverting
              if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) {
                myCheckinPanel.setCommitMessage(myPreviousMessage);
              }
            }
          }
        });
  }
Exemplo n.º 20
0
  private void setupCheckboxes(List<SearchEngine> searchEngines, JPanel parent) {

    final Map<JCheckBox, BooleanSetting> cBoxes = new HashMap<JCheckBox, BooleanSetting>();

    ItemListener listener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (areAll(false)) {
              ((JCheckBox) e.getItemSelectable()).setSelected(true);
            }

            if (resultPanel != null) {
              resultPanel.filterChanged(new SearchEngineFilter(engineCheckboxes), 0);
            }
          }
        };

    for (SearchEngine se : searchEngines) {
      JCheckBox cBox = new JCheckBox(se.getName());
      cBox.setSelected(se.isEnabled());
      cBox.setEnabled(se.isEnabled());

      if (!cBox.isEnabled()) {
        cBox.setToolTipText(
            se.getName()
                + " "
                + I18n.tr(
                    "has been disabled on your FrostWire Search Options. (Go to Tools > Options > Search to enable)"));
      }

      parent.add(cBox);

      cBoxes.put(cBox, se.getEnabledSetting());
      cBox.addItemListener(listener);

      engineCheckboxes.put(se, cBox);
    }
  }
Exemplo n.º 21
0
  public IECheckBoxWidgetView(
      IEController ieController,
      IECheckBoxWidget model,
      boolean addDnDSupport,
      IEWOComponentView view) {
    super(ieController, model, addDnDSupport, view);
    FlowLayout layout = new FlowLayout(FlowLayout.LEFT, 0, 0);
    setLayout(layout);
    _jCheckBox = new JCheckBox();
    _jCheckBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            isUpdatingModel = true;
            getCheckBoxModel().setValue(((JCheckBox) e.getSource()).isSelected());
            isUpdatingModel = false;
          }
        });
    _jCheckBox.setFont(TEXTFIELD_FONT);
    container = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4));
    container.setOpaque(false);
    container.add(_jCheckBox);
    add(container);
    _jCheckBox.setEnabled(true);
    _jCheckBox.setFocusable(false);
    _jCheckBox.setOpaque(false);
    if (getCheckBoxModel().getDescription() != null) {
      _jCheckBox.setToolTipText(getCheckBoxModel().getDescription());
    }
    TransparentMouseListener tml = new TransparentMouseListener(_jCheckBox, this);
    _jCheckBox.addMouseListener(tml);
    _jCheckBox.addMouseMotionListener(tml);
    _jCheckBox.setSelected(getCheckBoxModel().getValue());
    _jCheckBox.setBackground(getBackgroundColor());
    setBackground(getBackgroundColor());
    revalidate();
  }
Exemplo n.º 22
0
  /** Initializes the toolbar buttons */
  protected void init() {

    super.init();

    markerButton.setEnabled(false);

    quickFilterTextField.setMaximumSize(new Dimension(250, 20));
    quickFilterTextField.setToolTipText("Quick filter");

    regularExpressionCheckBox.setOpaque(false);
    regularExpressionCheckBox.setToolTipText("Treat the filter text as a regular expression");

    add(quickFilterTextField);
    add(regularExpressionCheckBox);

    addDividerButton();

    add(debugButton);
    add(infoButton);
    add(warnButton);
    add(errorButton);
    add(fatalButton);

    addDividerButton();

    add(markerButton);
    add(prevMarkedButton);
    add(nextMarkedButton);

    addDividerButton();

    add(playButton);
    add(deleteButton);

    registerListeners();
  }
Exemplo n.º 23
0
  /** @param driver Needed for the Replicator-specific options */
  public PreferencesWindow(final MachineInterface machine) {
    super("Preferences");
    setResizable(true);

    Image icon = Base.getImage("images/icon.gif", this);
    setIconImage(icon);

    JTabbedPane prefTabs = new JTabbedPane();

    JPanel basic = new JPanel();

    //		Container content = this.getContentPane();
    Container content = basic;
    content.setLayout(new MigLayout("fill"));

    content.add(new JLabel("MainWindow font size: "), "split");
    fontSizeField = new JFormattedTextField(Base.getLocalFormat());
    fontSizeField.setColumns(4);
    content.add(fontSizeField);
    content.add(new JLabel("  (requires restart of ReplicatorG)"), "wrap");

    boolean checkTempDuringBuild = Base.preferences.getBoolean("build.monitor_temp", true);
    boolean displaySpeedWarning = Base.preferences.getBoolean("build.speed_warning", true);

    addCheckboxForPref(
        content, "Monitor temperature during builds", "build.monitor_temp", checkTempDuringBuild);
    addCheckboxForPref(
        content, "Display Accelerated Speed Warnings", "build.speed_warning", displaySpeedWarning);
    addCheckboxForPref(
        content, "Automatically connect to machine at startup", "replicatorg.autoconnect", true);
    addCheckboxForPref(
        content, "Show experimental machine profiles", "machine.showExperimental", false);
    addCheckboxForPref(
        content,
        "Review GCode for potential toolhead problems before building",
        "build.safetyChecks",
        true);
    addCheckboxForPref(
        content,
        "Break Z motion into separate moves (normally false)",
        "replicatorg.parser.breakzmoves",
        false);
    addCheckboxForPref(
        content, "Show starfield in model preview window", "ui.show_starfield", false);
    addCheckboxForPref(
        content, "Notifications in System tray", "ui.preferSystemTrayNotifications", false);
    addCheckboxForPref(
        content,
        "Automatically regenerate gcode when building from model view.",
        "build.autoGenerateGcode",
        true);
    addCheckboxForPref(
        content, "Use native avrdude for uploading code", "uploader.useNative", false);

    JPanel advanced = new JPanel();
    content = advanced;
    content.setLayout(new MigLayout("fill"));

    JButton modelColorButton;
    modelColorButton = new JButton("Choose model color");
    modelColorButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Note that this color is also defined in EditingModel.java
            Color modelColor = new Color(Base.preferences.getInt("ui.modelColor", -19635));
            modelColor = JColorChooser.showDialog(null, "Choose Model Color", modelColor);
            if (modelColor == null) return;

            Base.preferences.putInt("ui.modelColor", modelColor.getRGB());
            Base.getEditor().refreshPreviewPanel();
          }
        });
    modelColorButton.setVisible(true);
    content.add(modelColorButton, "split");

    JButton backgroundColorButton;
    backgroundColorButton = new JButton("Choose background color");
    backgroundColorButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Note that this color is also defined in EditingModel.java
            Color backgroundColor = new Color(Base.preferences.getInt("ui.backgroundColor", 0));
            backgroundColor =
                JColorChooser.showDialog(null, "Choose Background Color", backgroundColor);
            if (backgroundColor == null) return;

            Base.preferences.putInt("ui.backgroundColor", backgroundColor.getRGB());
            Base.getEditor().refreshPreviewPanel();
          }
        });
    backgroundColorButton.setVisible(true);
    content.add(backgroundColorButton, "wrap");

    content.add(new JLabel("Firmware update URL: "), "split");
    firmwareUpdateUrlField = new JTextField(34);
    content.add(firmwareUpdateUrlField, "growx, wrap");

    {
      JLabel arcResolutionLabel = new JLabel("Arc resolution (in mm): ");
      content.add(arcResolutionLabel, "split");
      double value = Base.preferences.getDouble("replicatorg.parser.curve_segment_mm", 1.0);
      JFormattedTextField arcResolutionField = new JFormattedTextField(Base.getLocalFormat());
      arcResolutionField.setValue(new Double(value));
      content.add(arcResolutionField);
      String arcResolutionHelp =
          "<html><small><em>"
              + "The arc resolution is the default segment length that the gcode parser will break arc codes <br>"
              + "like G2 and G3 into.  Drivers that natively handle arcs will ignore this setting."
              + "</em></small></html>";
      arcResolutionField.setToolTipText(arcResolutionHelp);
      arcResolutionLabel.setToolTipText(arcResolutionHelp);
      //			content.add(new JLabel(arcResolutionHelp),"growx,wrap");
      arcResolutionField.setColumns(10);
      arcResolutionField.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                try {
                  Double v = (Double) evt.getNewValue();
                  if (v == null) return;
                  Base.preferences.putDouble(
                      "replicatorg.parser.curve_segment_mm", v.doubleValue());
                } catch (ClassCastException cce) {
                  Base.logger.warning(
                      "Unexpected value type: " + evt.getNewValue().getClass().toString());
                }
              }
            }
          });
    }

    {
      JLabel sfTimeoutLabel = new JLabel("Skeinforge timeout: ");
      content.add(sfTimeoutLabel, "split, gap unrelated");
      int value = Base.preferences.getInt("replicatorg.skeinforge.timeout", -1);
      JFormattedTextField sfTimeoutField = new JFormattedTextField(Base.getLocalFormat());
      sfTimeoutField.setValue(new Integer(value));
      content.add(sfTimeoutField, "wrap 10px, growx");
      String sfTimeoutHelp =
          "<html><small><em>"
              + "The Skeinforge timeout is the number of seconds that replicatorg will wait while the<br>"
              + "Skeinforge preferences window is open. If you find that RepG freezes after editing profiles<br>"
              + "you can set this number greater than -1 (-1 means no timeout)."
              + "</em></small></html>";
      sfTimeoutField.setToolTipText(sfTimeoutHelp);
      sfTimeoutLabel.setToolTipText(sfTimeoutHelp);
      //			content.add(new JLabel(sfTimeoutHelp),"growx,wrap");
      sfTimeoutField.setColumns(10);
      sfTimeoutField.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                try {
                  Integer v = ((Number) evt.getNewValue()).intValue();
                  if (v == null) return;
                  Base.preferences.putInt("replicatorg.skeinforge.timeout", v.intValue());
                } catch (ClassCastException cce) {
                  Base.logger.warning(
                      "Unexpected value type: " + evt.getNewValue().getClass().toString());
                }
              }
            }
          });
    }

    {
      content.add(new JLabel("Debugging level (default INFO):"), "split");
      content.add(makeDebugLevelDropdown(), "wrap");

      final JCheckBox logCb = new JCheckBox("Log to file");
      logCb.setSelected(Base.preferences.getBoolean("replicatorg.useLogFile", false));
      content.add(logCb, "split");
      logCb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Base.preferences.putBoolean("replicatorg.useLogFile", logCb.isSelected());
            }
          });

      final JLabel logPathLabel = new JLabel("Log file name: ");
      content.add(logPathLabel, "split");
      logPathField = new JTextField(34);
      content.add(logPathField, "growx, wrap 10px");
      logPathField.setEnabled(logCb.isSelected());
      logPathLabel.setEnabled(logCb.isSelected());

      logCb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              JCheckBox box = (JCheckBox) e.getSource();
              logPathField.setEnabled(box.isSelected());
              logPathLabel.setEnabled(box.isSelected());
            }
          });
    }

    {
      final int defaultTemp = 75;
      final String tooltipGeneral =
          "When enabled, starting all builds heats components to this temperature";
      final String tooltipHead = "Set preheat temperature for the specified toolhead";
      final String tooltipPlatform = "Set preheat temperature for the build platfom";

      final JCheckBox preheatCb = new JCheckBox("Preheat builds");
      preheatCb.setToolTipText(tooltipGeneral);
      content.add(preheatCb, "split");

      preheatCb.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
              Base.preferences.putBoolean("build.doPreheat", preheatCb.isSelected());
            }
          });
      preheatCb.setSelected(Base.preferences.getBoolean("build.doPreheat", false));

      final JLabel t0Label = new JLabel("Toolhead Right: ");
      final JLabel t1Label = new JLabel("Toolhead Left: ");
      final JLabel pLabel = new JLabel("Platform: ");

      Integer t0Value = Base.preferences.getInt("build.preheatTool0", defaultTemp);
      Integer t1Value = Base.preferences.getInt("build.preheatTool1", defaultTemp);
      Integer pValue = Base.preferences.getInt("build.preheatPlatform", defaultTemp);

      final JFormattedTextField t0Field = new JFormattedTextField(Base.getLocalFormat());
      final JFormattedTextField t1Field = new JFormattedTextField(Base.getLocalFormat());
      final JFormattedTextField pField = new JFormattedTextField(Base.getLocalFormat());

      t0Field.setToolTipText(tooltipHead);
      t0Label.setToolTipText(tooltipHead);
      t1Field.setToolTipText(tooltipHead);
      t1Label.setToolTipText(tooltipHead);
      pField.setToolTipText(tooltipPlatform);
      pLabel.setToolTipText(tooltipPlatform);

      t0Field.setValue(t0Value);
      t1Field.setValue(t1Value);
      pField.setValue(pValue);

      // let's avoid creating too many Anon. inner Listeners, also is fewer lines (and just as
      // clear)!
      PropertyChangeListener p =
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                double target;
                if (evt.getSource() == t0Field) {
                  target = ((Number) t0Field.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit", 200.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatTool0", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatTool0", (int) target);
                } else if (evt.getSource() == t1Field) {
                  target = ((Number) t1Field.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit", 200.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatTool1", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatTool1", (int) target);
                } else if (evt.getSource() == pField) {
                  target = ((Number) pField.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit.bed", 110.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatPlatform", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatPlatform", (int) target);
                }
              }
            }
          };

      t0Field.addPropertyChangeListener(p);
      t1Field.addPropertyChangeListener(p);
      pField.addPropertyChangeListener(p);

      content.add(t0Label, "split, gap 20px");
      content.add(t0Field, "split, growx");
      content.add(t1Label, "split, gap unrelated");
      content.add(t1Field, "split, growx");
      content.add(pLabel, "split, gap unrelated");
      content.add(pField, "split, growx, wrap 10px");
    }

    {
      JButton b = new JButton("Select Python interpreter...");
      content.add(b, "spanx,wrap 10px");
      b.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              SwingPythonSelector sps = new SwingPythonSelector(PreferencesWindow.this);
              String path = sps.selectFreeformPath();
              if (path != null) {
                PythonUtils.setPythonPath(path);
              }
            }
          });
    }

    addInitialFilePrefs(content);

    prefTabs.add(basic, "Basic");
    prefTabs.add(advanced, "Advanced");

    content = getContentPane();
    content.setLayout(new MigLayout());

    content.add(prefTabs, "wrap");

    JButton allPrefs = new JButton("View Preferences Table");
    content.add(allPrefs, "split");
    allPrefs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFrame advancedPrefs = new AdvancedPrefs();
            advancedPrefs.setVisible(true);
          }
        });

    // Also available as a menu item in the main gui.
    JButton delPrefs = new JButton("Reset all preferences");
    content.add(delPrefs);
    delPrefs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            editor.resetPreferences();
          }
        });

    JButton button;
    button = new JButton("Close");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyFrame();
            dispose();
          }
        });
    content.add(button, "tag ok");

    showCurrentSettings();

    // closing the window is same as hitting cancel button
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dispose();
          }
        });

    ActionListener disposer =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
          }
        };
    Base.registerWindowCloseKeys(getRootPane(), disposer);

    pack();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);

    // handle window closing commands for ctrl/cmd-W or hitting ESC.

    getContentPane()
        .addKeyListener(
            new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                KeyStroke wc = MainWindow.WINDOW_CLOSE_KEYSTROKE;
                if ((e.getKeyCode() == KeyEvent.VK_ESCAPE)
                    || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
                  dispose();
                }
              }
            });
  }
Exemplo n.º 24
0
 private void jbInit() throws Exception {
   titledBorder1 =
       new TitledBorder(
           BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)),
           appContext.getI18nString("snappingSnapOptions"));
   border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140));
   titledBorder2 = new TitledBorder(border2, appContext.getI18nString("gridSnapOptions"));
   this.setLayout(borderLayout1);
   jPanel1.setLayout(gridBagLayout1);
   jPanel2.setLayout(gridBagLayout2);
   jPanel2.setBorder(titledBorder1);
   snapToFeaturesCheckBox.setText(appContext.getI18nString("snapLinesSnapOptions"));
   snapToVerticesCheckBox.setText(appContext.getI18nString("snapVertivesSnapOptions"));
   snapToGridCheckBox.setText(appContext.getI18nString("snapGridSnapOptions"));
   jPanel4.setLayout(gridBagLayout3);
   jPanel5.setBorder(titledBorder2);
   jPanel5.setLayout(gridBagLayout4);
   gridSizeTextField.setText("20");
   gridSizeTextField.setHorizontalAlignment(SwingConstants.TRAILING);
   jPanel7.setLayout(gridBagLayout6);
   showGridDotsRadioButton.setSelected(true);
   showGridDotsRadioButton.setText(appContext.getI18nString("snapDotsSnapOptions"));
   showGridLinesRadioButton.setText(appContext.getI18nString("snapLinesSnapOptions"));
   showGridCheckBox.setToolTipText("");
   showGridCheckBox.setText(appContext.getI18nString("snapSizeSnapOptions"));
   showGridCheckBox.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           showGridCheckBox_actionPerformed(e);
         }
       });
   tolerancePanel.setLayout(gridBagLayout5);
   toleranceLabel.setText(appContext.getI18nString("toleranceSnapOptions"));
   toleranceUnitsLabel.setText(appContext.getI18nString("unitsSnapOptions"));
   showGridUnitsLabel.setText(appContext.getI18nString("unitsModelSnapOptions"));
   this.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(
       jPanel2,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(10, 10, 10, 10),
           0,
           0));
   jPanel2.add(
       snapToFeaturesCheckBox,
       new GridBagConstraints(
           0,
           2,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       snapToVerticesCheckBox,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       jPanel3,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       jPanel4,
       new GridBagConstraints(
           0,
           3,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel4.add(
       snapToGridCheckBox,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       tolerancePanel,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   tolerancePanel.add(
       toleranceLabel,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 5),
           0,
           0));
   tolerancePanel.add(
       toleranceTextField,
       new GridBagConstraints(
           2,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 5),
           0,
           0));
   tolerancePanel.add(
       toleranceUnitsLabel,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel1.add(
       jPanel5,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 10, 10, 10),
           0,
           0));
   jPanel5.add(
       jPanel7,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel7.add(
       gridSizeTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 5),
           0,
           0));
   jPanel7.add(
       showGridCheckBox,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel5.add(
       showGridDotsRadioButton,
       new GridBagConstraints(
           0,
           2,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel5.add(
       showGridLinesRadioButton,
       new GridBagConstraints(
           0,
           3,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel1.add(
       jPanel6,
       new GridBagConstraints(
           0,
           2,
           1,
           1,
           0.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.VERTICAL,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel7.add(
       showGridUnitsLabel,
       new GridBagConstraints(
           2,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
Exemplo n.º 25
0
 public void mouseEntered(MouseEvent arg0) {
   manual.setToolTipText("Check to enable temporary manual mode.");
 }
Exemplo n.º 26
0
  /** Initializes and binds the components related to modeling codon positions. */
  private void initCodonPartitionComponents() {

    PanelUtils.setupComponent(substUnlinkCheck);

    substUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedSubstitutionModel(substUnlinkCheck.isSelected());
          }
        });
    substUnlinkCheck.setEnabled(false);
    substUnlinkCheck.setToolTipText(
        ""
            + "<html>Gives each codon position partition different<br>"
            + "substitution model parameters.</html>");

    PanelUtils.setupComponent(heteroUnlinkCheck);
    heteroUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedHeterogeneityModel(heteroUnlinkCheck.isSelected());
          }
        });
    heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 0);
    heteroUnlinkCheck.setToolTipText(
        "<html>Gives each codon position partition different<br>rate heterogeneity model parameters.</html>");

    PanelUtils.setupComponent(freqsUnlinkCheck);
    freqsUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedFrequencyModel(freqsUnlinkCheck.isSelected());
          }
        });
    freqsUnlinkCheck.setEnabled(false);
    freqsUnlinkCheck.setToolTipText(
        "<html>Gives each codon position partition different<br>nucleotide frequency parameters.</html>");

    PanelUtils.setupComponent(codingCombo);
    codingCombo.setToolTipText("<html>Select how to partition the codon positions.</html>");
    codingCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            switch (codingCombo.getSelectedIndex()) {
              case 0:
                model.setCodonHeteroPattern(null);
                break;
              case 1:
                model.setCodonHeteroPattern("112");
                break;
              default:
                model.setCodonHeteroPattern("123");
                break;
            }

            if (codingCombo.getSelectedIndex() != 0) {
              // codon position partitioning
              substUnlinkCheck.setEnabled(true);
              heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 3);
              freqsUnlinkCheck.setEnabled(true);
              substUnlinkCheck.setSelected(true);
              heteroUnlinkCheck.setSelected(heteroCombo.getSelectedIndex() != 0);
              freqsUnlinkCheck.setSelected(true);

            } else {
              substUnlinkCheck.setEnabled(false);
              substUnlinkCheck.setSelected(false);
              heteroUnlinkCheck.setEnabled(false);
              heteroUnlinkCheck.setSelected(false);
              freqsUnlinkCheck.setEnabled(false);
              freqsUnlinkCheck.setSelected(false);
            }
          }
        });
  }
Exemplo n.º 27
0
  public PartitionModelPanel(final PartitionSubstitutionModel partitionModel) {

    super(12, (OSType.isMac() ? 6 : 24));

    this.model = partitionModel;

    initCodonPartitionComponents();

    PanelUtils.setupComponent(nucSubstCombo);
    nucSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setNucSubstitutionModel((NucModelType) nucSubstCombo.getSelectedItem());
          }
        });
    nucSubstCombo.setToolTipText("<html>Select the type of nucleotide substitution model.</html>");

    PanelUtils.setupComponent(aaSubstCombo);
    aaSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
            model.setAaSubstitutionModel(type);
            citationText.setText(type.getCitation().toString());
          }
        });
    aaSubstCombo.setToolTipText("<html>Select the type of amino acid substitution model.</html>");

    PanelUtils.setupComponent(binarySubstCombo);
    binarySubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setBinarySubstitutionModel((BinaryModelType) binarySubstCombo.getSelectedItem());
            useAmbiguitiesTreeLikelihoodCheck.setSelected(
                binarySubstCombo.getSelectedItem() == BinaryModelType.BIN_COVARION);
            useAmbiguitiesTreeLikelihoodCheck.setEnabled(
                binarySubstCombo.getSelectedItem() != BinaryModelType.BIN_COVARION);
          }
        });
    binarySubstCombo.setToolTipText("<html>Select the type of binary substitution model.</html>");

    PanelUtils.setupComponent(useAmbiguitiesTreeLikelihoodCheck);
    useAmbiguitiesTreeLikelihoodCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUseAmbiguitiesTreeLikelihood(useAmbiguitiesTreeLikelihoodCheck.isSelected());
          }
        });
    useAmbiguitiesTreeLikelihoodCheck.setToolTipText(
        "<html>Detemine useAmbiguities in &lt treeLikelihood &gt .</html>");

    PanelUtils.setupComponent(frequencyCombo);
    frequencyCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setFrequencyPolicy((FrequencyPolicyType) frequencyCombo.getSelectedItem());
          }
        });
    frequencyCombo.setToolTipText(
        "<html>Select the policy for determining the base frequencies.</html>");

    PanelUtils.setupComponent(heteroCombo);
    heteroCombo.setToolTipText(
        "<html>Select the type of site-specific rate<br>heterogeneity model.</html>");
    heteroCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            boolean gammaHetero =
                heteroCombo.getSelectedIndex() == 1 || heteroCombo.getSelectedIndex() == 3;

            model.setGammaHetero(gammaHetero);
            model.setInvarHetero(
                heteroCombo.getSelectedIndex() == 2 || heteroCombo.getSelectedIndex() == 3);

            if (gammaHetero) {
              gammaCatLabel.setEnabled(true);
              gammaCatCombo.setEnabled(true);
            } else {
              gammaCatLabel.setEnabled(false);
              gammaCatCombo.setEnabled(false);
            }

            if (codingCombo.getSelectedIndex() != 0) {
              heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 0);
              heteroUnlinkCheck.setSelected(heteroCombo.getSelectedIndex() != 0);
            }
          }
        });

    PanelUtils.setupComponent(gammaCatCombo);
    gammaCatCombo.setToolTipText(
        "<html>Select the number of categories to use for<br>the discrete gamma rate heterogeneity model.</html>");
    gammaCatCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            model.setGammaCategories(gammaCatCombo.getSelectedIndex() + 4);
          }
        });

    setYang96Button = new JButton("Use Yang96 model");
    setYang96Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setYang96Model();
          }
        });
    PanelUtils.setupComponent(setYang96Button);
    setYang96Button.setToolTipText(
        "<html>Sets a 3 codon-position model with independent GTR and Gamma as described in<br>"
            + "Yang (1996) <i>J Mol Evol</i> <b>42</b>: 587–596. This model is named 3' in this paper.</html>");

    setSRD06Button = new JButton("Use SRD06 model");
    setSRD06Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setSRD06Model();
          }
        });
    PanelUtils.setupComponent(setSRD06Button);
    setSRD06Button.setToolTipText(
        "<html>Sets the SRD06 model as described in<br>"
            + "Shapiro, Rambaut & Drummond (2006) <i>MBE</i> <b>23</b>: 7-9.</html>");

    citationText = new JTextArea(1, 40);
    citationText.setLineWrap(true);
    citationText.setWrapStyleWord(true);
    citationText.setEditable(false);
    citationText.setFont(this.getFont());
    citationText.setOpaque(false);
    AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
    citationText.setText(type.getCitation().toString());

    dolloCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (dolloCheck.isSelected()) {
              binarySubstCombo.setSelectedIndex(0);
              binarySubstCombo.setEnabled(false);
              useAmbiguitiesTreeLikelihoodCheck.setSelected(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(false);
              frequencyCombo.setEnabled(false);
              frequencyCombo.setSelectedItem(FrequencyPolicyType.EMPIRICAL);
              heteroCombo.setSelectedIndex(0);
              heteroCombo.setEnabled(false);
              model.setBinarySubstitutionModel(BinaryModelType.BIN_DOLLO);
              model.setDolloModel(true);
              DolloComponentOptions comp =
                  (DolloComponentOptions)
                      model.getOptions().getComponentOptions(DolloComponentOptions.class);
              comp.createParameters(model.getOptions());
              comp.setActive(true);

            } else {
              binarySubstCombo.setEnabled(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(true);
              frequencyCombo.setEnabled(true);
              heteroCombo.setEnabled(true);
              model.setBinarySubstitutionModel(
                  (BinaryModelType) binarySubstCombo.getSelectedItem());
              model.setDolloModel(false);
            }
          }
        });

    PanelUtils.setupComponent(dolloCheck);
    //        dolloCheck.addChangeListener(new ChangeListener() {
    //            public void stateChanged(ChangeEvent e) {
    //                model.setDolloModel(true);
    //            }
    //        });
    dolloCheck.setEnabled(true);
    dolloCheck.setToolTipText(
        "<html>Activates a Stochastic Dollo model as described in<br>"
            + "Alekseyenko, Lee & Suchard (2008) <i>Syst Biol</i> <b>57</b>: 772-784.</html>");

    PanelUtils.setupComponent(discreteTraitSiteModelCombo);
    discreteTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setDiscreteSubstType(
                (DiscreteSubstModelType) discreteTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(continuousTraitSiteModelCombo);
    continuousTraitSiteModelCombo.setToolTipText(
        "<html>Select the model of continuous random walk, either homogenous<br>"
            + "or relaxed random walk (RRW) with a choice of distributions.</html>");
    continuousTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setContinuousSubstModelType(
                (ContinuousSubstModelType) continuousTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(latLongCheck);
    latLongCheck.setToolTipText(
        "<html>Specify whether this is a geographical trait representing <br>"
            + "latitude and longitude. Provides appropriate statistics to log file.</html>");

    latLongCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setIsLatitudeLongitude(latLongCheck.isSelected());
          }
        });
    latLongCheck.setEnabled(false);

    PanelUtils.setupComponent(useLambdaCheck);
    useLambdaCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            ContinuousComponentOptions component =
                (ContinuousComponentOptions)
                    model.getOptions().getComponentOptions(ContinuousComponentOptions.class);
            component.setUseLambda(model, useLambdaCheck.isSelected());
          }
        });
    useLambdaCheck.setToolTipText(
        "<html>Estimate degree of phylogenetic correlation in continuous traits using <br>"
            + "a tree transform. Inspired by Pagel (1999), described in Lemey et al (2013) <i>in prep</i></html>");

    PanelUtils.setupComponent(activateBSSVS);
    activateBSSVS.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setActivateBSSVS(activateBSSVS.isSelected());
          }
        });
    activateBSSVS.setToolTipText(
        "<html>Activates Bayesian stochastic search variable selection on the rates as described in<br>"
            + "Lemey, Rambaut, Drummond & Suchard (2009) <i>PLoS Computational Biology</i> <b>5</b>: e1000520</html>");

    // ============ micro-sat ================
    microsatName.setColumns(30);
    microsatName.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setName(microsatName.getText());
          }
        });
    microsatMax.setColumns(10);
    microsatMax.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMax(Integer.parseInt(microsatMax.getText()));
          }
        });
    microsatMin.setColumns(10);
    microsatMin.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMin(Integer.parseInt(microsatMin.getText()));
          }
        });

    PanelUtils.setupComponent(shareMicroSatCheck);
    shareMicroSatCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            model.getOptions().shareMicroSat = shareMicroSatCheck.isSelected();
            if (shareMicroSatCheck.isSelected()) {
              model.getOptions().shareMicroSat();
            } else {
              model.getOptions().unshareMicroSat();
            }
            setOptions();
          }
        });

    PanelUtils.setupComponent(rateProportionCombo);
    rateProportionCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setRatePorportion(
                (MicroSatModelType.RateProportionality) rateProportionCombo.getSelectedItem());
          }
        });
    // rateProportionCombo.setToolTipText("<html>Select the type of microsatellite substitution
    // model.</html>");
    PanelUtils.setupComponent(mutationBiasCombo);
    mutationBiasCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setMutationBias(
                (MicroSatModelType.MutationalBias) mutationBiasCombo.getSelectedItem());
          }
        });
    PanelUtils.setupComponent(phaseCombo);
    phaseCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setPhase((MicroSatModelType.Phase) phaseCombo.getSelectedItem());
          }
        });

    setupPanel();
    setOpaque(false);
  }
Exemplo n.º 28
0
  /**
   * Constructor
   *
   * @param s
   */
  public LayersPanel(State s) {
    super("Layers");
    state = s;

    setLayout(new BorderLayout());

    Landscape landscape = Landscape.getInstance();
    LayerInfo[] currentSelection = landscape.getLayerManager().getLayerSelection();

    JPanel topPanel = new JPanel(new FlowLayout());
    showLayersCheckBox = new JCheckBox("Show Layers");
    showLayersCheckBox.setToolTipText("display the visible layers");
    showLayersCheckBox.setSelected(landscape.isLayersEnabled());
    showLayersCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            Landscape.getInstance().enableLayers(showLayersCheckBox.isSelected());
          }
        });
    topPanel.add(showLayersCheckBox);
    configureButton = new JButton("Change Configuration");
    configureButton.setToolTipText("add and remove visible layers");
    configureButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            LayerConfigurationDialog dialog =
                new LayerConfigurationDialog((Dialog) state.getViewData().getViewWindow());
            dialog.open();
            LayerInfo[] current = (LayerInfo[]) dialog.getResult();
            if (current != null) {
              Landscape.getInstance().getLayerManager().setLayerSelection(current);
              adjustBlendFactors(1, -1);
              for (int i = 0; i < current.length; ++i) {
                fillLayerSelection(i, current[i]);
              }
              Landscape.getInstance().resetLayers();
            }
          }
        });
    topPanel.add(configureButton);
    distributeButton = new JButton("Distribute");
    distributeButton.setToolTipText(
        "distribute total color contribution equally among unlocked layers");
    distributeButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            adjustBlendFactors(1, -1);
            Landscape.getInstance().markDirty(DirtyType.RenderState);
          }
        });
    topPanel.add(distributeButton);
    add(topPanel, BorderLayout.NORTH);

    // create the layer selections
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(LayerManager.NUM_LAYERS, 1, 0, 0));

    layer = new JLabel[LayerManager.NUM_LAYERS];
    blendFactorSpinner = new IntSpinner[LayerManager.NUM_LAYERS];
    lockBox = new JCheckBox[LayerManager.NUM_LAYERS];

    for (int i = 0; i < LayerManager.NUM_LAYERS; ++i) {
      JPanel p = new JPanel();
      p.setLayout(new FlowLayout(FlowLayout.LEFT));
      p.add(new JLabel(" " + i + " "));
      addLockBox(p, i);
      addBlendFactorSpinner(p, i);
      layer[i] = new JLabel();
      p.add(layer[i]);
      panel.add(p);
      fillLayerSelection(i, currentSelection[i]);
    }
    add(new JScrollPane(panel), BorderLayout.CENTER);
  }
Exemplo n.º 29
0
  /**
   * Called when preparing this settings pane for display the first time. Can be overriden to
   * implement the look of the settings pane.
   */
  @Override
  protected void prepareComponent() {
    FormLayout layout =
        new FormLayout(
            "10dlu, right:d, 2dlu, d, 2dlu:grow", // columns
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p"); // rows
    layout.setRowGroups(new int[][] {{3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23}});
    setLayout(layout);

    PanelBuilder builder = new PanelBuilder(layout, this);
    CellConstraints cc = new CellConstraints();

    builder.addSeparator(Localizer.getString("GeneralDownloadSettings"), cc.xywh(1, 1, 5, 1));

    JLabel label =
        builder.addLabel(
            Localizer.getString("DownloadSettings_TotalParallelDownloads") + ": ", cc.xy(2, 3));
    label.setToolTipText(Localizer.getString("DownloadSettings_TTTTotalParallelDownloads"));
    totalWorkersTF =
        new IntegerTextField(DownloadPrefs.MaxTotalDownloadWorker.get().toString(), 6, 2);
    totalWorkersTF.setToolTipText(
        Localizer.getString("DownloadSettings_TTTTotalParallelDownloads"));
    builder.add(totalWorkersTF, cc.xy(4, 3));

    label =
        builder.addLabel(
            Localizer.getString("DownloadSettings_ParallelDownloadsPerFile") + ": ", cc.xy(2, 5));
    label.setToolTipText(Localizer.getString("DownloadSettings_TTTParallelDownloadsPerFile"));
    workerPerDownloadTF =
        new IntegerTextField(DownloadPrefs.MaxWorkerPerDownload.get().toString(), 6, 2);
    workerPerDownloadTF.setToolTipText(
        Localizer.getString("DownloadSettings_TTTParallelDownloadsPerFile"));
    builder.add(workerPerDownloadTF, cc.xy(4, 5));

    label =
        builder.addLabel(
            Localizer.getString("DownloadSettings_InitialSegmentSizeKb") + ": ", cc.xy(2, 7));
    label.setToolTipText(Localizer.getString("DownloadSettings_TTTInitialSegmentSizeKb"));
    initialSegmentSizeTF =
        new IntegerTextField(
            String.valueOf(DownloadPrefs.SegmentInitialSize.get().intValue() / 1024), 6, 4);
    initialSegmentSizeTF.setToolTipText(
        Localizer.getString("DownloadSettings_TTTInitialSegmentSizeKb"));
    builder.add(initialSegmentSizeTF, cc.xy(4, 7));

    label =
        builder.addLabel(
            Localizer.getString("DownloadSettings_SegmentTransferTimeSec") + ": ", cc.xy(2, 9));
    label.setToolTipText(Localizer.getString("DownloadSettings_TTTSegmentTransferTimeSec"));
    segmentTransferTimeTF =
        new IntegerTextField(DownloadPrefs.SegmentTransferTargetTime.get().toString(), 6, 3);
    segmentTransferTimeTF.setToolTipText(
        Localizer.getString("DownloadSettings_TTTSegmentTransferTimeSec"));
    builder.add(segmentTransferTimeTF, cc.xy(4, 9));

    builder.addLabel(Localizer.getString("PushTimeout") + ": ", cc.xy(2, 11));
    pushTimeoutTF =
        new IntegerTextField(
            String.valueOf(DownloadPrefs.PushRequestTimeout.get().intValue() / 1000), 6, 3);
    builder.add(pushTimeoutTF, cc.xy(4, 11));

    readoutMagmaChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_ReadoutDownloadedMagmas"),
            DownloadPrefs.AutoReadoutMagmaFiles.get().booleanValue());
    readoutMagmaChkbx.setToolTipText(
        Localizer.getString("DownloadSettings_TTTReadoutDownloadedMagmas"));
    builder.add(readoutMagmaChkbx, cc.xywh(2, 13, 4, 1));

    readoutMetalinkChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_ReadoutDownloadedMetalink"),
            DownloadPrefs.AutoReadoutMetalinkFiles.get().booleanValue());
    readoutMetalinkChkbx.setToolTipText(
        Localizer.getString("DownloadSettings_TTTReadoutDownloadedMetalink"));
    builder.add(readoutMetalinkChkbx, cc.xywh(2, 15, 4, 1));

    readoutRSSChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_ReadoutDownloadedRSS"),
            DownloadPrefs.AutoReadoutRSSFiles.get().booleanValue());
    readoutRSSChkbx.setToolTipText(Localizer.getString("DownloadSettings_TTTReadoutDownloadedRSS"));
    builder.add(readoutRSSChkbx, cc.xywh(2, 17, 4, 1));

    silentSubscriptionsChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_DownloadSubscriptionsSilently"),
            SubscriptionPrefs.DownloadSilently.get().booleanValue());
    silentSubscriptionsChkbx.setToolTipText(
        Localizer.getString("DownloadSettings_TTTDownloadSubscriptionsSilently"));
    builder.add(silentSubscriptionsChkbx, cc.xywh(2, 19, 4, 1));

    removeCompletedDownloadsChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_AutoRemoveCompletedDownloads"),
            DownloadPrefs.AutoRemoveCompleted.get().booleanValue());
    removeCompletedDownloadsChkbx.setToolTipText(
        Localizer.getString("DownloadSettings_TTTAutoRemoveCompletedDownloads"));
    builder.add(removeCompletedDownloadsChkbx, cc.xywh(2, 21, 4, 1));

    enableHitSnoopingChkbx =
        new JCheckBox(
            Localizer.getString("DownloadSettings_EnableHitSnooping"),
            ConnectionPrefs.EnableQueryHitSnooping.get().booleanValue());
    enableHitSnoopingChkbx.setToolTipText(
        Localizer.getString("DownloadSettings_TTTEnableHitSnooping"));
    builder.add(enableHitSnoopingChkbx, cc.xywh(2, 23, 4, 1));

    initConfigValues();
    refreshEnableState();
  }
  @Override
  protected void init() {
    super.init();

    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();

    initReplaceFieldsWithGetters(settings);

    myDeclareFinalCheckBox.setSelected(hasFinalModifier());
    myDelegateViaOverloadingMethodCheckBox.setVisible(myInfo.getToSearchFor() != null);

    setTitle(RefactoringBundle.message("introduce.parameter.title"));

    myTable.init(myInfo);

    final GrParameter[] parameters = myInfo.getToReplaceIn().getParameters();
    toRemoveCBs.forEachEntry(
        new TObjectIntProcedure<JCheckBox>() {
          @Override
          public boolean execute(JCheckBox checkbox, int index) {
            checkbox.setSelected(true);

            final GrParameter param = parameters[index];
            final ParameterInfo pinfo = findParamByOldName(param.getName());
            if (pinfo != null) {
              pinfo.setPassAsParameter(false);
            }
            return true;
          }
        });

    updateSignature();

    if (myCanIntroduceSimpleParameter) {
      mySignaturePanel.setVisible(false);

      // action to hide signature panel if we have variants to introduce simple parameter
      myTypeComboBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              mySignaturePanel.setVisible(myTypeComboBox.isClosureSelected());
              pack();
            }
          });
    }

    final PsiType closureReturnType = inferClosureReturnType();
    if (PsiType.VOID.equals(closureReturnType)) {
      myForceReturnCheckBox.setEnabled(false);
      myForceReturnCheckBox.setSelected(false);
    } else {
      myForceReturnCheckBox.setSelected(isForceReturn());
    }

    if (myInfo.getToReplaceIn() instanceof GrClosableBlock) {
      myDelegateViaOverloadingMethodCheckBox.setEnabled(false);
      myDelegateViaOverloadingMethodCheckBox.setToolTipText(
          "Delegating is not allowed in closure context");
    }

    pack();
  }