public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    installMouseHandler();
    TreePath path = getPathForRow(row);
    state = UNCHECKABLE;
    if (path != null) {
      if (isChecked(path)) {
        state = FULLCHECKED;
      } else if (isPartiallyChecked(path)) {
        state = PARTIALCHECKED;
      } else if (isSelectable(path)) {
        state = UNCHECKED;
      }
    }
    checkBox.setSelected(state == FULLCHECKED);
    checkBox.getModel().setArmed(mouseRow == row && pressedRow == row && mouseInCheck);
    checkBox.getModel().setPressed(pressedRow == row && mouseInCheck);
    checkBox.getModel().setRollover(mouseRow == row && mouseInCheck);

    Component c =
        renderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    checkBox.setForeground(c.getForeground());
    if (c instanceof JLabel) {
      JLabel label = (JLabel) c;
      // Augment the icon to include the checkbox
      setAppropriateLabelAndIcon(value, label, selected, expanded);
    }
    return c;
  }
    private OptionsPanel() {
      super(new GridBagLayout());

      GridBagConstraints gc = new GridBagConstraints();
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1;
      gc.weighty = 0;
      gc.anchor = GridBagConstraints.NORTHWEST;

      myPackageLocalForMembersCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option"));
      myPackageLocalForMembersCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS);
      myPackageLocalForMembersCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS = myPackageLocalForMembersCheckbox.isSelected();
                }
              });

      gc.gridy = 0;
      add(myPackageLocalForMembersCheckbox, gc);

      myPackageLocalForTopClassesCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option1"));
      myPackageLocalForTopClassesCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES);
      myPackageLocalForTopClassesCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES =
                      myPackageLocalForTopClassesCheckbox.isSelected();
                }
              });

      gc.gridy = 1;
      add(myPackageLocalForTopClassesCheckbox, gc);

      myPrivateForInnersCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option2"));
      myPrivateForInnersCheckbox.setSelected(SUGGEST_PRIVATE_FOR_INNERS);
      myPrivateForInnersCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PRIVATE_FOR_INNERS = myPrivateForInnersCheckbox.isSelected();
                }
              });

      gc.gridy = 2;
      gc.weighty = 1;
      add(myPrivateForInnersCheckbox, gc);
    }
Example #3
0
    private OptionsPanel() {
      super(new GridBagLayout());

      GridBagConstraints gc = new GridBagConstraints();
      gc.weighty = 0;
      gc.weightx = 1;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.anchor = GridBagConstraints.NORTHWEST;

      myReportClassesCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option"));
      myReportClassesCheckbox.setSelected(REPORT_CLASSES);
      myReportClassesCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  REPORT_CLASSES = myReportClassesCheckbox.isSelected();
                }
              });
      gc.gridy = 0;
      add(myReportClassesCheckbox, gc);

      myReportMethodsCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option1"));
      myReportMethodsCheckbox.setSelected(REPORT_METHODS);
      myReportMethodsCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  REPORT_METHODS = myReportMethodsCheckbox.isSelected();
                }
              });
      gc.gridy++;
      add(myReportMethodsCheckbox, gc);

      myReportFieldsCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option2"));
      myReportFieldsCheckbox.setSelected(REPORT_FIELDS);
      myReportFieldsCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  REPORT_FIELDS = myReportFieldsCheckbox.isSelected();
                }
              });

      gc.weighty = 1;
      gc.gridy++;
      add(myReportFieldsCheckbox, gc);
    }
Example #4
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
    @Override
    @SuppressWarnings("unchecked")
    public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
      JCheckBox cb = (JCheckBox) c;
      javax.swing.ButtonModel model = cb.getModel();

      if (ThemeManager.isLookAndFeelNimbus()) {
        icon.paintIcon(c, g, x, y);

        if (c.hasFocus()) {
          nimbusFocusBorder.paintBorder(g, x, y, iconWidth, iconHeight);
        }

        drawIndeterminateNimbusLine(g, x, y);
      } else {
        if (model.isEnabled()) {
          if (model.isPressed() && model.isArmed()) {
            g.setColor(MetalLookAndFeel.getControlShadow());
            g.fillRect(x, y, iconWidth - 1, iconHeight - 1);
            drawPressed3DBorder(g, x, y, iconWidth, iconHeight);
          } else {
            drawFlush3DBorder(g, x, y, iconWidth, iconHeight);
          }
          g.setColor(MetalLookAndFeel.getControlInfo());
        } else {
          g.setColor(MetalLookAndFeel.getControlShadow());
          g.drawRect(x, y, iconWidth - 1, iconHeight - 1);
        }

        drawIndeterminateLine(g, x, y);
      }
    }
Example #6
0
 @Override
 public void stateChanged(ChangeEvent e) {
   JCheckBox t = (JCheckBox) e.getSource();
   if (t.getModel().isSelected()) {
     sendStrings = true;
   } else {
     sendStrings = false;
   }
 }
  @Override
  protected void doRefactoringAction() {
    final boolean needToRegenerate = myRegenerateLanguage.getModel().isSelected();

    final String fqName = getCurrentValue();
    if (MPSModuleRepository.getInstance().getModuleByFqName(fqName) != null) {
      setErrorText("Duplicate language name");
      return;
    }
    if (!((SourceVersion.isName(fqName)))) {
      setErrorText("Language namespace should be valid Java package");
      return;
    }
    final LanguageRenamer renamer = new LanguageRenamer(myProject, myLanguage, fqName);
    ModelAccess modelAccess = myProject.getRepository().getModelAccess();
    modelAccess.executeCommand(
        new Runnable() {
          public void run() {
            renamer.rename(needToRegenerate);
            renamer.update();
          }
        });
    if (needToRegenerate) {
      final Map<SModule, List<SModel>> langs = new LinkedHashMap<SModule, List<SModel>>();
      modelAccess.runReadAction(
          new Runnable() {
            public void run() {
              RefactoringUtil.fillLanguageAndItsExtendingLanguageModels(myLanguage, langs);
            }
          });
      for (final List<SModel> models : langs.values()) {
        ModuleContext context = new ModuleContext(myLanguage, myProject);
        MakeSession sess = new MakeSession(context);
        if (IMakeService.INSTANCE.get().openNewSession(sess)) {
          IMakeService.INSTANCE
              .get()
              .make(sess, new ModelsToResources(context, models).resources(false));
        }
        //         GeneratorUIFacade.getInstance().generateModels(new ModuleContext(myLanguage,
        // myProject), params.getModelDescriptors(),
        // GeneratorUIFacade.getInstance().getDefaultGenerationHandler(), true, false);
      }
    }
    super.doRefactoringAction();
  }
  public RenameLanguageDialog(Project project, Language language) throws HeadlessException {
    super(project, language.getModuleFqName(), "language");
    myLanguage = language;
    myProject = project;
    setTitle("Rename Language");

    myRegenerateLanguage
        .getModel()
        .setSelected(
            ModelAccess.instance()
                .runReadAction(
                    new Computable<Boolean>() {
                      @Override
                      public Boolean compute() {
                        return !(myLanguage.isBootstrap());
                      }
                    }));
  }
  public RenameLanguageDialog(com.intellij.openapi.project.Project project, Language language)
      throws HeadlessException {
    super(project, language.getModuleName(), "language");
    myLanguage = language;
    myProject = ProjectHelper.toMPSProject(project);
    setTitle("Rename Language");

    final boolean[] regenerateHolder = new boolean[] {false};
    myProject
        .getRepository()
        .getModelAccess()
        .runReadAction(
            new Runnable() {
              public void run() {
                regenerateHolder[0] = !(myLanguage.isBootstrap());
              }
            });
    myRegenerateLanguage.getModel().setSelected(regenerateHolder[0]);
  }
Example #10
0
  /** Create the dialog. */
  public SettingsDialog() {
    setBounds(100, 100, 400, 450);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
      contentPanel.add(tabbedPane, BorderLayout.CENTER);
      {
        generalTab = new JPanel();
        tabbedPane.addTab("General", null, generalTab, "General settings.");
        tabbedPane.setEnabledAt(0, true);

        JLabel lblLauncherFilename = new JLabel("Launcher Filename:");
        launcherFileTextField = new JTextField(AppSettings.getLauncherFilename());
        launcherFileTextField.setColumns(10);
        launcherFileTextField.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
              }
            });

        JLabel lblConsoleSettings = new JLabel("Console Settings:");

        chckbxShowConsole = new JCheckBox("Show console");
        chckbxShowConsole.getModel().setSelected(AppSettings.getShowConsole());
        chckbxShowConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setShowConsole(chckbxShowConsole.getModel().isSelected());
                  }
                });

        chckbxAutoCloseConsole = new JCheckBox("Close console when instance exits.");
        chckbxAutoCloseConsole.getModel().setSelected(AppSettings.getAutoCloseConsole());
        chckbxAutoCloseConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setAutoCloseConsole(chckbxAutoCloseConsole.getModel().isSelected());
                  }
                });

        chckbxAutoUpdate = new JCheckBox("Automatically check for updates when MultiMC starts");
        chckbxAutoUpdate.getModel().setSelected(AppSettings.getAutoUpdate());
        chckbxAutoUpdate
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setCheckUpdates(chckbxAutoUpdate.getModel().isSelected());
                  }
                });

        GroupLayout gl_generalTab = new GroupLayout(generalTab);
        gl_generalTab.setHorizontalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.LEADING)
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addComponent(lblLauncherFilename)
                                        .addPreferredGap(ComponentPlacement.RELATED)
                                        .addComponent(
                                            launcherFileTextField,
                                            GroupLayout.DEFAULT_SIZE,
                                            262,
                                            Short.MAX_VALUE))
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addGap(6)
                                        .addGroup(
                                            gl_generalTab
                                                .createParallelGroup(Alignment.LEADING)
                                                .addComponent(chckbxAutoCloseConsole)
                                                .addComponent(chckbxShowConsole)))
                                .addComponent(chckbxAutoUpdate)
                                .addComponent(lblConsoleSettings))
                        .addContainerGap()));
        gl_generalTab.setVerticalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblLauncherFilename)
                                .addComponent(
                                    launcherFileTextField,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addGap(18)
                        .addComponent(lblConsoleSettings)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxShowConsole)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxAutoCloseConsole)
                        .addGap(18)
                        .addComponent(chckbxAutoUpdate)
                        .addContainerGap(198, Short.MAX_VALUE)));
        generalTab.setLayout(gl_generalTab);
      }
      {
        advancedTab = new JPanel();
        tabbedPane.addTab(
            "Advanced", null, advancedTab, "Advanced settings such as memory allocations.");

        initialMemorySpinner = new JSpinner();
        initialMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getInitialMemAlloc(), new Integer(512), null, new Integer(512)));
        initialMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent arg0) {
                    AppSettings.setInitialMemAlloc(
                        (Integer) initialMemorySpinner.getModel().getValue());
                  }
                });

        JLabel lblInitialMemoryAllocation = new JLabel("Initial Memory Allocation (MB): ");

        maxMemorySpinner = new JSpinner();
        maxMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getMaxMemAlloc(), new Integer(1024), null, new Integer(512)));
        maxMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent e) {
                    AppSettings.setMaxMemAlloc((Integer) maxMemorySpinner.getModel().getValue());
                  }
                });

        JLabel labelMaxMemAlloc = new JLabel("Maximum Memory Allocation (MB): ");
        GroupLayout gl_advancedTab = new GroupLayout(advancedTab);
        gl_advancedTab.setHorizontalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(lblInitialMemoryAllocation))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING, false)
                                .addComponent(maxMemorySpinner)
                                .addComponent(initialMemorySpinner))
                        .addGap(144)));
        gl_advancedTab.setVerticalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblInitialMemoryAllocation)
                                .addComponent(
                                    initialMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(
                                    maxMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(276, Short.MAX_VALUE)));
        advancedTab.setLayout(gl_advancedTab);
      }
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("Close");
        okButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
                setVisible(false);
              }
            });
        okButton.setMnemonic('C');
        okButton.setActionCommand("OK");
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
  @Override
  protected void doRefactoringAction() {
    final boolean needToRegenerate = myRegenerateLanguage.getModel().isSelected();

    final String fqName = getCurrentValue();
    if (MPSModuleRepository.getInstance().getModuleByFqName(fqName) != null) {
      setErrorText("Duplicate language name");
      return;
    }
    if (!((SourceVersion.isName(fqName)))) {
      setErrorText("Language namespace should be valid Java package");
      return;
    }
    final LanguageRenamer renamer = new LanguageRenamer(myProject, myLanguage, fqName);
    ModelAccess.instance()
        .runWriteActionInCommand(
            new Runnable() {
              public void run() {
                renamer.rename(needToRegenerate);
                renamer.update();
              }
            });
    if (needToRegenerate) {
      final Set<Language> langs = new LinkedHashSet<Language>();
      ModelAccess.instance()
          .runReadAction(
              new Runnable() {
                @Override
                public void run() {
                  langs.add(myLanguage);
                  langs.addAll(
                      ModuleRepositoryFacade.getInstance().getAllExtendingLanguages(myLanguage));
                }
              });
      for (final Language l : langs) {
        GenParameters params =
            ModelAccess.instance()
                .runReadAction(
                    new Computable<GenParameters>() {
                      @Override
                      public GenParameters compute() {
                        ModuleTestConfiguration languageConfig = new ModuleTestConfiguration();
                        languageConfig.setModuleRef(l.getModuleReference());
                        languageConfig.setName("tmp");
                        try {
                          return languageConfig.getGenParams(
                              myProject.getComponent(MPSProject.class), true);
                        } catch (IllegalGeneratorConfigurationException e) {
                          return null;
                        }
                      }
                    });
        if (params == null) {
          setErrorText("Rebuild configuration is invalid");
          return;
        }
        ModuleContext context =
            new ModuleContext(myLanguage, ProjectHelper.toMPSProject(myProject));
        MakeSession sess = new MakeSession(context);
        if (IMakeService.INSTANCE.get().openNewSession(sess)) {
          IMakeService.INSTANCE
              .get()
              .make(
                  sess,
                  new ModelsToResources(
                          context,
                          ListSequence.fromListWithValues(
                              new ArrayList<SModel>(),
                              (Iterable<SModel>) params.getModelDescriptors()))
                      .resources(false));
        }
        //         GeneratorUIFacade.getInstance().generateModels(new ModuleContext(myLanguage,
        // myProject), params.getModelDescriptors(),
        // GeneratorUIFacade.getInstance().getDefaultGenerationHandler(), true, false);
      }
    }
    super.doRefactoringAction();
  }
Example #12
0
  protected final JPanel buildMainPanel() {
    JPanel pnl = new JPanel();
    pnl.setLayout(new GridBagLayout());

    final ChangeListener checkboxChangeListener =
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            // size check depends on selected data source
            updateSizeCheck();
          }
        };

    // adding the download tasks
    pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5, 5, 1, 5));
    cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true);
    cbDownloadOsmData.setToolTipText(
        tr("Select to download OSM data in the selected download area."));
    cbDownloadOsmData.getModel().addChangeListener(checkboxChangeListener);
    pnl.add(cbDownloadOsmData, GBC.std().insets(1, 5, 1, 5));
    cbDownloadGpxData = new JCheckBox(tr("Raw GPS data"));
    cbDownloadGpxData.setToolTipText(
        tr("Select to download GPS traces in the selected download area."));
    cbDownloadGpxData.getModel().addChangeListener(checkboxChangeListener);
    pnl.add(cbDownloadGpxData, GBC.std().insets(5, 5, 1, 5));
    cbDownloadNotes = new JCheckBox(tr("Notes"));
    cbDownloadNotes.setToolTipText(tr("Select to download notes in the selected download area."));
    cbDownloadNotes.getModel().addChangeListener(checkboxChangeListener);
    pnl.add(cbDownloadNotes, GBC.eol().insets(50, 5, 1, 5));

    // hook for subclasses
    buildMainPanelAboveDownloadSelections(pnl);

    slippyMapChooser = new SlippyMapChooser();

    // predefined download selections
    downloadSelections.add(slippyMapChooser);
    downloadSelections.add(new BookmarkSelection());
    downloadSelections.add(new BoundingBoxSelection());
    downloadSelections.add(new PlaceSelection());
    downloadSelections.add(new TileSelection());

    // add selections from plugins
    PluginHandler.addDownloadSelection(downloadSelections);

    // now everybody may add their tab to the tabbed pane
    // (not done right away to allow plugins to remove one of
    // the default selectors!)
    for (DownloadSelection s : downloadSelections) {
      s.addGui(this);
    }

    pnl.add(tpDownloadAreaSelectors, GBC.eol().fill());

    try {
      tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
    } catch (Exception ex) {
      Main.pref.putInteger("download.tab", 0);
    }

    Font labelFont = sizeCheck.getFont();
    sizeCheck.setFont(labelFont.deriveFont(Font.PLAIN, labelFont.getSize()));

    cbNewLayer = new JCheckBox(tr("Download as new layer"));
    cbNewLayer.setToolTipText(
        tr(
            "<html>Select to download data into a new data layer.<br>"
                + "Unselect to download into the currently active data layer.</html>"));

    cbStartup = new JCheckBox(tr("Open this dialog on startup"));
    cbStartup.setToolTipText(
        tr(
            "<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>"
                + "You can open it manually from File menu or toolbar.</html>"));
    cbStartup.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Main.pref.put("download.autorun", cbStartup.isSelected());
          }
        });

    pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
    pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));

    pnl.add(sizeCheck, GBC.eol().anchor(GBC.EAST).insets(5, 5, 5, 2));

    if (!ExpertToggleAction.isExpert()) {
      JLabel infoLabel =
          new JLabel(
              tr(
                  "Use left click&drag to select area, arrows or right mouse button to scroll map, wheel or +/- to zoom."));
      pnl.add(infoLabel, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 0, 0));
    }
    return pnl;
  }
    private OptionsPanel() {
      super(new GridBagLayout());

      GridBagConstraints gc = new GridBagConstraints();
      gc.weighty = 0;
      gc.weightx = 1;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.anchor = GridBagConstraints.NORTHWEST;

      mySuggestNullables =
          new JCheckBox(InspectionsBundle.message("inspection.data.flow.nullable.quickfix.option"));
      mySuggestNullables.setSelected(SUGGEST_NULLABLE_ANNOTATIONS);
      mySuggestNullables
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_NULLABLE_ANNOTATIONS = mySuggestNullables.isSelected();
                }
              });

      myDontReportTrueAsserts =
          new JCheckBox(InspectionsBundle.message("inspection.data.flow.true.asserts.option"));
      myDontReportTrueAsserts.setSelected(DONT_REPORT_TRUE_ASSERT_STATEMENTS);
      myDontReportTrueAsserts
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected();
                }
              });

      myIgnoreAssertions = new JCheckBox("Ignore assert statements");
      myIgnoreAssertions.setSelected(IGNORE_ASSERT_STATEMENTS);
      myIgnoreAssertions
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected();
                }
              });

      myReportConstantReferences =
          new JCheckBox("Warn when reading a value guaranteed to be constant");
      myReportConstantReferences.setSelected(REPORT_CONSTANT_REFERENCE_VALUES);
      myReportConstantReferences
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  REPORT_CONSTANT_REFERENCE_VALUES = myReportConstantReferences.isSelected();
                }
              });

      myTreatUnknownMembersAsNullable =
          new JCheckBox("Treat non-annotated members and parameters as @Nullable");
      myTreatUnknownMembersAsNullable.setSelected(TREAT_UNKNOWN_MEMBERS_AS_NULLABLE);
      myTreatUnknownMembersAsNullable
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = myTreatUnknownMembersAsNullable.isSelected();
                }
              });

      gc.insets = new Insets(0, 0, 0, 0);
      gc.gridy = 0;
      add(mySuggestNullables, gc);

      final JButton configureAnnotations =
          new JButton(InspectionsBundle.message("configure.annotations.option"));
      configureAnnotations.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Project project =
                  CommonDataKeys.PROJECT.getData(
                      DataManager.getInstance().getDataContext(OptionsPanel.this));
              if (project == null) project = ProjectManager.getInstance().getDefaultProject();
              final NullableNotNullDialog dialog = new NullableNotNullDialog(project);
              dialog.show();
            }
          });
      gc.gridy++;
      gc.fill = GridBagConstraints.NONE;
      gc.insets.left = 20;
      gc.insets.bottom = 15;
      add(configureAnnotations, gc);

      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weighty = 1;
      gc.insets.left = 0;
      gc.gridy++;
      add(myDontReportTrueAsserts, gc);

      gc.gridy++;
      add(myIgnoreAssertions, gc);

      gc.gridy++;
      add(myReportConstantReferences, gc);

      gc.gridy++;
      add(myTreatUnknownMembersAsNullable, gc);
    }
Example #14
0
  private static void createEnvironment(String aFilename, JFrame jframe) {
    JTextPane textPane =
        new JTextPane() {
          public boolean getScrollableTracksViewportWidth() {
            return getUI().getPreferredSize(this).width <= getParent().getSize().width;
          }
        };

    JTextField filenameTextField = new JTextField(aFilename);
    JSpinner skipSizeSpinner = new JSpinner(new SpinnerNumberModel(50, 0, 100000, 1000));
    JCheckBox skipSmall = new JCheckBox("skip productions smaller than:");
    JCheckBox skipAll = new JCheckBox("skip all  ");

    DebuggerParserListener debugListener =
        new DebuggerParserListener(
            skipSmall.getModel(), skipSizeSpinner.getModel(), skipAll.getModel());
    CallStackParserListener callStackParserListener = new CallStackParserListener(debugListener);
    HighlighterParserListener highlighterParserListener =
        new HighlighterParserListener(textPane, debugListener);
    ProductionsParserListener productionsParserListener =
        new ProductionsParserListener(debugListener);
    ExecutionParserListener treeParserListener = new ExecutionParserListener(debugListener);
    ParserListenerMultiplexer parserListenerMultiplexer =
        new ParserListenerMultiplexer(
            productionsParserListener,
            treeParserListener,
            highlighterParserListener,
            callStackParserListener,
            debugListener);
    debugListener.setProductionFrames(parserListenerMultiplexer.getProductionFrames());
    ListenedParser parser = new ListenedParser(parserListenerMultiplexer);
    debugListener.stepInto();

    parser.getLoggingMap().log("begin parsing");
    boolean initialized = false;

    while (true) {
      try {
        parser.setDisabled(false);

        String file = filenameTextField.getText();
        StringBuilder sourcecode =
            new StringBuilder(
                new Scanner(HumoTester.class.getResourceAsStream("/" + file))
                    .useDelimiter("\\Z")
                    .next());

        parserListenerMultiplexer.init(file, sourcecode, !initialized);
        treeParserListener.init(file, !initialized, sourcecode);
        productionsParserListener.init(file, !initialized);
        callStackParserListener.init(file, sourcecode, !initialized);
        textPane.setDocument(parserListenerMultiplexer.getCurrentFrame().getDocument());
        debugListener.stepInto();

        ((DefaultTreeModel) treeParserListener.getExecutionTree().getModel()).reload();
        ((DefaultTreeModel) callStackParserListener.getUsedProductionsTree().getModel()).reload();
        ((DefaultTreeModel) productionsParserListener.getProductionsTree().getModel()).reload();

        if (!initialized) {
          showTree(
              highlighterParserListener,
              debugListener,
              parser,
              sourcecode,
              textPane,
              callStackParserListener.getUsedProductionsTree(),
              treeParserListener.getExecutionTree(),
              productionsParserListener.getProductionsTree(),
              jframe,
              filenameTextField,
              skipSmall,
              skipSizeSpinner,
              parserListenerMultiplexer,
              skipAll);
          initialized = true;
        }
        parser.init();
        parser.parse(sourcecode, 0);
        parser.getLoggingMap().log("end parsing");
        debugListener.getStepper().pause();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }