com.intellij.openapi.options.newEditor.OptionsEditor Java Examples

The following examples show how to use com.intellij.openapi.options.newEditor.OptionsEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SassLintInspection.java    From sass-lint-plugin with MIT License 6 votes vote down vote up
@NotNull
    private HyperlinkLabel createHyperLink() {
//        List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());
        List path = ContainerUtil.newArrayList("JavaScript", SassLintBundle.message("sasslint.inspection.group.name"), getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
                if (optionsEditor == null) {
                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
                    if (project != null) {
                        showSettings(project);
                    }
                    return;
                }
                Configurable configurable = optionsEditor.findConfigurableById(SassLintInspection.this.getId());
                if (configurable != null) {
                    optionsEditor.clearSearchAndSelect(configurable);
                }
            }
        });
        return settingsLink;
    }
 
Example #2
Source File: VcsUpdateInfoScopeFilterConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.Nullable
@Override
public JComponent createComponent() {
  final JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
  panel.add(myCheckbox);
  panel.add(myComboBox);
  panel.add(Box.createHorizontalStrut(UIUtil.DEFAULT_HGAP));
  panel.add(new LinkLabel("Edit scopes", null, new LinkListener() {
    @Override
    public void linkSelected(LinkLabel aSource, Object aLinkData) {
      final OptionsEditor optionsEditor = DataManager.getInstance().getDataContext(panel).getData(OptionsEditor.KEY);
      if (optionsEditor != null) {
        SearchableConfigurable configurable = optionsEditor.findConfigurableById(new ScopeChooserConfigurable(myProject).getId());
        if (configurable != null) {
          optionsEditor.select(configurable);
        }
      }
    }
  }));
  return panel;
}
 
Example #3
Source File: ScopeColorsPageFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static JPanel createChooseScopePanel() {
  Project[] projects = ProjectManager.getInstance().getOpenProjects();
  JPanel panel = new JPanel(new GridBagLayout());
  //panel.setBorder(new LineBorder(Color.red));
  if (projects.length == 0) return panel;
  GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                                 new Insets(0, 0, 0, 0), 0, 0);
  final Project contextProject = DataManager.getInstance().getDataContext().getData(CommonDataKeys.PROJECT);
  final Project project = contextProject != null ? contextProject : projects[0];

  JButton button = new JButton(ApplicationBundle.message("button.edit.scopes"));
  button.setPreferredSize(new Dimension(230, button.getPreferredSize().height));
  panel.add(button, gc);
  gc.gridx = GridBagConstraints.REMAINDER;
  gc.weightx = 1;
  panel.add(new JPanel(), gc);

  gc.gridy++;
  gc.gridx=0;
  gc.weighty = 1;
  panel.add(new JPanel(), gc);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final OptionsEditor optionsEditor = DataManager.getInstance().getDataContext().getData(OptionsEditor.KEY);
      if (optionsEditor != null) {
        try {
          Configurable configurable = optionsEditor.findConfigurableById(ScopeChooserConfigurable.PROJECT_SCOPES);
          if (configurable == null || optionsEditor.clearSearchAndSelect(configurable).isRejected()) {
            EditScopesDialog.showDialog(project, null);
          }
        } catch (IllegalStateException ex) {
          EditScopesDialog.showDialog(project, null);
        }
      }
    }
  });
  return panel;
}
 
Example #4
Source File: ColorAndFontOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean select(DataContext context, String search, Function<ColorAndFontOptions, SearchableConfigurable> function) {
  OptionsEditor settings = context.getData(OptionsEditor.KEY);
  if (settings == null) return false;

  ColorAndFontOptions options = settings.findConfigurable(ColorAndFontOptions.class);
  if (options == null) return false;

  SearchableConfigurable page = function.apply(options);
  if (page == null) return false;

  settings.select(page, search);
  return true;
}
 
Example #5
Source File: DesktopShowSettingsUtilImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
public void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) {
  Configurable[] configurables = buildConfigurables(project);

  final Configurable configurable2Select = findConfigurable2Select(id2Select, configurables);

  showSettingsImpl(project, it -> configurables, configurable2Select, dialog -> {
    final OptionsEditor editor = dialog.getDataUnchecked(OptionsEditor.KEY);
    LOG.assertTrue(editor != null);
    editor.select(configurable2Select, filter);
  });
}