public AvailablePluginsManagerMain(
      PluginManagerMain installed, PluginManagerUISettings uiSettings, String vendorFilter) {
    super(uiSettings);
    this.installed = installed;
    myVendorFilter = vendorFilter;
    init();
    final JButton manageRepositoriesBtn = new JButton(MANAGE_REPOSITORIES);
    if (myVendorFilter == null) {
      manageRepositoriesBtn.setMnemonic('m');
      manageRepositoriesBtn.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (ShowSettingsUtil.getInstance()
                  .editConfigurable(myActionsPanel, new PluginHostsConfigurable())) {
                final ArrayList<String> pluginHosts = UpdateSettings.getInstance().myPluginHosts;
                if (!pluginHosts.contains(
                    ((AvailablePluginsTableModel) pluginsModel).getRepository())) {
                  ((AvailablePluginsTableModel) pluginsModel)
                      .setRepository(
                          AvailablePluginsTableModel.ALL, myFilter.getFilter().toLowerCase());
                }
                loadAvailablePlugins();
              }
            }
          });
      myActionsPanel.add(manageRepositoriesBtn, BorderLayout.EAST);
    }

    final JButton httpProxySettingsButton =
        new JButton(IdeBundle.message("button.http.proxy.settings"));
    httpProxySettingsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            HTTPProxySettingsDialog settingsDialog = new HTTPProxySettingsDialog();
            settingsDialog.pack();
            settingsDialog.show();
            if (settingsDialog.isOK()) {
              loadAvailablePlugins();
            }
          }
        });
    myActionsPanel.add(httpProxySettingsButton, BorderLayout.WEST);
  }
Example #2
0
  private void initReplaceToolBars() {
    DefaultActionGroup actionGroup1 = new DefaultActionGroup("replace bar 1", false);
    myReplaceActionsToolbar1 =
        (ActionToolbarImpl)
            ActionManager.getInstance()
                .createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup1, true);
    myReplaceActionsToolbar1.setForceMinimumSize(true);
    final JButton myReplaceButton = new JButton("Replace");
    myReplaceButton.setFocusable(false);
    myReplaceButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            replaceCurrent();
          }
        });

    final JButton myReplaceAllButton = new JButton("Replace all");
    myReplaceAllButton.setFocusable(false);
    myReplaceAllButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            myLivePreviewController.performReplaceAll();
          }
        });

    final JButton myExcludeButton = new JButton("");
    myExcludeButton.setFocusable(false);
    myExcludeButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            myLivePreviewController.exclude();
            moveCursor(SearchResults.Direction.DOWN);
          }
        });

    if (!UISettings.getInstance().DISABLE_MNEMONICS_IN_CONTROLS) {
      myReplaceButton.setMnemonic('p');
      myReplaceAllButton.setMnemonic('a');
      myExcludeButton.setMnemonic('l');
    }

    actionGroup1.addAction(
        new DefaultCustomComponentAction(myReplaceButton) {
          @Override
          public void update(AnActionEvent e) {
            myReplaceButton.setEnabled(canReplaceCurrent());
          }
        });
    actionGroup1.addAction(
        new DefaultCustomComponentAction(myReplaceAllButton) {
          @Override
          public void update(AnActionEvent e) {
            myReplaceAllButton.setEnabled(mySearchResults != null && mySearchResults.hasMatches());
          }
        });
    actionGroup1.addAction(
        new DefaultCustomComponentAction(myExcludeButton) {
          @Override
          public void update(AnActionEvent e) {
            FindResult cursor = mySearchResults != null ? mySearchResults.getCursor() : null;
            myExcludeButton.setEnabled(cursor != null);
            myExcludeButton.setText(
                cursor != null && mySearchResults.isExcluded(cursor) ? "Include" : "Exclude");
          }
        });

    myReplaceActionsToolbar1.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY);
    myReplaceActionsToolbar1.setBorder(null);
    myReplaceActionsToolbar1.setOpaque(false);
    DefaultActionGroup actionGroup2 = new DefaultActionGroup("replace bar 2", false);
    myReplaceActionsToolbar2 =
        (ActionToolbarImpl)
            ActionManager.getInstance()
                .createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup2, true);
    actionGroup2.addAction(new TogglePreserveCaseAction(this));
    actionGroup2.addAction(new ToggleSelectionOnlyAction(this));
    myReplaceActionsToolbar2.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY);
    myReplaceActionsToolbar2.setBorder(null);
    myReplaceActionsToolbar2.setOpaque(false);
    Utils.setSmallerFontForChildren(myReplaceActionsToolbar1);
    Utils.setSmallerFontForChildren(myReplaceActionsToolbar2);
  }