com.intellij.openapi.options.Configurable Java Examples

The following examples show how to use com.intellij.openapi.options.Configurable. 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: XDebuggerConfigurableProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Collection<Configurable> getConfigurables(@Nonnull DebuggerSettingsCategory category) {
  List<Configurable> list;
  if (category == DebuggerSettingsCategory.GENERAL) {
    list = new SmartList<>(new XDebuggerGeneralConfigurable());
  }
  else {
    list = null;
  }

  for (XDebuggerSettings<?> settings : XDebuggerSettingManagerImpl.getInstanceImpl().getSettingsList()) {
    Collection<? extends Configurable> configurables = settings.createConfigurables(category);
    if (!configurables.isEmpty()) {
      if (list == null) {
        list = new SmartList<>();
      }
      list.addAll(configurables);
    }
  }
  return ContainerUtil.notNullize(list);
}
 
Example #2
Source File: SubCompositeConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public final void apply() throws ConfigurationException {
  if (root != null) {
    root.apply(getSettings());
    XDebuggerConfigurableProvider.generalApplied(getCategory());
  }

  if (isChildrenMerged()) {
    for (Configurable child : children) {
      if (child.isModified()) {
        child.apply();
      }
    }
  }
}
 
Example #3
Source File: OptionsTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
private List<ConfigurableNode> buildChildren(final Configurable configurable, SimpleNode parent) {
  if (configurable instanceof Configurable.Composite) {
    final Configurable[] kids = ((Configurable.Composite)configurable).getConfigurables();
    final List<ConfigurableNode> result = new ArrayList<>(kids.length);
    for (Configurable child : kids) {
      if (isInvisibleNode(child)) {
        result.addAll(buildChildren(child, parent));
      }
      result.add(new ConfigurableNode(parent, child));
      myContext.registerKid(configurable, child);
    }

    result.sort(UnifiedConfigurableComparator.INSTANCE);
    return result;
  }
  else {
    return Collections.emptyList();
  }
}
 
Example #4
Source File: SingleConfigurableEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
public SingleConfigurableEditor(@Nullable Project project,
                                Configurable configurable,
                                @Nullable String title,
                                @NonNls String dimensionKey,
                                final boolean showApplyButton,
                                final IdeModalityType ideModalityType) {
  super(project, true, ideModalityType);
  myDimensionKey = dimensionKey;
  myShowApplyButton = showApplyButton;
  setTitle(title);

  myProject = project;
  myConfigurable = configurable;
  init();
  myConfigurable.reset();
}
 
Example #5
Source File: P4SyncUpdateEnvironment.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Configurable createConfigurable(Collection<FilePath> collection) {
    // Note the way this is currently implemented: synchronize options will always be reset.
    options = SyncOptions.createDefaultSyncOptions();

    ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project);
    if (registry == null || registry.isDisposed()) {
        return new SyncOptionConfigurable(project, options, Collections.emptyList());
    }
    Map<P4ServerName, ClientConfig> configMap = new HashMap<>();
    collection.forEach((fp) -> {
        ClientConfigRoot clientRoot = registry.getClientFor(fp);
        if (clientRoot != null) {
            configMap.put(clientRoot.getServerConfig().getServerName(), clientRoot.getClientConfig());
        }
    });
    return new SyncOptionConfigurable(project, options, configMap.values());
}
 
Example #6
Source File: SingleConfigurableEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
public SingleConfigurableEditor(Component parent,
                                Configurable configurable,
                                @Nullable String title,
                                String dimensionServiceKey,
                                final boolean showApplyButton,
                                final IdeModalityType ideModalityType) {
  super(parent, true);
  myDimensionKey = dimensionServiceKey;
  myShowApplyButton = showApplyButton;
  setTitle(StringUtil.notNullize(title, createTitleString(configurable)));

  myParentComponent = parent;
  myConfigurable = configurable;
  init();
  myConfigurable.reset();
}
 
Example #7
Source File: OptionsTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public SearchableConfigurable findConfigurableById(@Nonnull String configurableId) {
  for (Configurable configurable : myConfigurable2Node.keySet()) {
    if (configurable instanceof SearchableConfigurable) {
      SearchableConfigurable searchableConfigurable = (SearchableConfigurable)configurable;
      if (configurableId.equals(searchableConfigurable.getId())) {
        return searchableConfigurable;
      }
    }
  }
  return null;
}
 
Example #8
Source File: MainConfigurable.java    From android-codegenerator-plugin-intellij with Apache License 2.0 5 votes vote down vote up
public Configurable[] getConfigurables() {
    if (configurables == null) {
        configurables = new Configurable[]{
                new TemplateConfigurable("Activity Template", "Setup Template for Activity code generation:", "Activity_template"),
                new TemplateConfigurable("Adapter Template", "Setup Template for Adapter code generation:", "Adapter_template"),
                new TemplateConfigurable("Fragment Template", "Setup Template for Fragment code generation:", "Fragment_template"),
                new TemplateConfigurable("Menu Template", "Setup Template for Menu code generation:", "Menu_template")
        };
    }
    return configurables;
}
 
Example #9
Source File: DesktopSettingsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Configurable findLastSavedConfigurable(Configurable[] configurables, final Project project) {
  final String id = PropertiesComponent.getInstance(project).getValue(LAST_SELECTED_CONFIGURABLE);
  if (id == null) return null;

  return findConfigurableInGroups(id, configurables);
}
 
Example #10
Source File: VcsConfigurationsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addConfigurationPanelFor(final VcsDescriptor vcs) {
  String name = vcs.getName();
  final JPanel parentPanel = new JPanel();
  final LazyConfigurable lazyConfigurable = new LazyConfigurable(new Getter<Configurable>() {
    @Override
    public Configurable get() {
      return AllVcses.getInstance(myProject).getByName(vcs.getName()).getConfigurable();
    }
  }, parentPanel);
  myVcsNameToConfigurableMap.put(name, lazyConfigurable);
  myVcsConfigurationPanel.add(parentPanel, name);
}
 
Example #11
Source File: PostfixTemplatesConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected Configurable[] buildConfigurables() {
  LanguageExtensionPoint[] extensions = LanguagePostfixTemplate.EP_NAME.getExtensions();
  List<Configurable> list = new ArrayList<>(extensions.length);
  for (LanguageExtensionPoint extensionPoint : extensions) {
    list.add(new PostfixTemplatesChildConfigurable(extensionPoint));
  }
  Collections.sort(list, (o1, o2) -> StringUtil.compare(o1.getDisplayName(), o2.getDisplayName(), true));
  return list.toArray(new Configurable[list.size()]);
}
 
Example #12
Source File: ConfigurableUIMigrationUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public static JComponent getPreferredFocusedComponent(@Nonnull Configurable.HoldPreferredFocusedComponent component) {
  JComponent preferredFocusedComponent = component.getPreferredFocusedComponent();
  if(preferredFocusedComponent != null) {
    return preferredFocusedComponent;
  }
  consulo.ui.Component uiComponent = component.getPreferredFocusedUIComponent();
  if (uiComponent != null) {
    return (JComponent)TargetAWT.to(uiComponent);
  }
  return null;
}
 
Example #13
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public AsyncResult<Void> navigateTo(@Nullable final Place place, final boolean requestFocus) {
  final Configurable config = (Configurable)place.getPath("configurable");
  final String filter = (String)place.getPath("filter");

  final AsyncResult<Void> result = AsyncResult.undefined();

  myFilter.refilterFor(filter, false, true).onSuccess((c) -> myTree.select(config).notifyWhenDone(result));

  return result;
}
 
Example #14
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ActionCallback updateIfCurrent(final Configurable configurable) {
  if (getContext().getCurrentConfigurable() == configurable && configurable != null) {
    updateContent();
    return new ActionCallback.Done();
  }
  else {
    return new ActionCallback.Rejected();
  }
}
 
Example #15
Source File: BaseShowSettingsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String createDimensionKey(@Nonnull Configurable configurable) {
  String displayName = configurable.getDisplayName();
  if (displayName == null) {
    displayName = configurable.getClass().getName();
  }
  return '#' + StringUtil.replaceChar(StringUtil.replaceChar(displayName, '\n', '_'), ' ', '_');
}
 
Example #16
Source File: SearchUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void processConfigurables(final Configurable[] configurables,
                                         final HashMap<SearchableConfigurable, TreeSet<OptionDescription>> options) {
  for (Configurable configurable : configurables) {
    if (configurable instanceof SearchableConfigurable) {
      TreeSet<OptionDescription> configurableOptions = new TreeSet<OptionDescription>();

      if (configurable instanceof Configurable.Composite) {
        final Configurable[] children = ((Configurable.Composite)configurable).getConfigurables();
        processConfigurables(children, options);
      }

      //ignore invisible root nodes
      if (configurable instanceof SearchableConfigurable.Parent && !((SearchableConfigurable.Parent)configurable).isVisible()) {
        continue;
      }

      options.put((SearchableConfigurable)configurable, configurableOptions);

      if (configurable instanceof MasterDetails) {
        final MasterDetails md = (MasterDetails)configurable;
        md.initUi();
        _processComponent(configurable, configurableOptions, md.getMaster());
        _processComponent(configurable, configurableOptions, md.getDetails().getComponent());
      }
      else {
        _processComponent(configurable, configurableOptions, configurable.createComponent());
      }
    }
  }
}
 
Example #17
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void fireModification(final Configurable actual) {
  Collection<Configurable> toCheck = collectAllParentsAndSiblings(actual);

  for (Configurable configurable : toCheck) {
    fireModificationForItem(configurable);
  }
}
 
Example #18
Source File: PhpStanAnnotatorQualityToolAnnotator.java    From idea-php-generics-plugin with MIT License 5 votes vote down vote up
@Override
protected QualityToolMessageProcessor createMessageProcessor(@NotNull QualityToolAnnotatorInfo qualityToolAnnotatorInfo) {
    return new CheckstyleQualityToolMessageProcessor(qualityToolAnnotatorInfo) {
        @Override
        protected Configurable getToolConfigurable(@NotNull Project project) {
            return new PhpStanValidatorConfigurable(project);
        }
    };
}
 
Example #19
Source File: DesktopSettingsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void saveCurrentConfigurable() {
  final Configurable current = myEditor.getContext().getCurrentConfigurable();
  if (current == null) return;

  final PropertiesComponent props = PropertiesComponent.getInstance(myProject);

  if (current instanceof SearchableConfigurable) {
    props.setValue(LAST_SELECTED_CONFIGURABLE, ((SearchableConfigurable)current).getId());
  }
  else {
    props.setValue(LAST_SELECTED_CONFIGURABLE, current.getClass().getName());
  }
}
 
Example #20
Source File: DesktopSettingsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Configurable findPreselectedByDisplayName(final String preselectedConfigurableDisplayName, Configurable[] configurables) {
  final List<Configurable> all = SearchUtil.expand(configurables);
  for (Configurable each : all) {
    if (preselectedConfigurableDisplayName.equals(each.getDisplayName())) return each;
  }
  return null;
}
 
Example #21
Source File: UpdateOrStatusOptionsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Map<AbstractVcs, Configurable> revertMap(final Map<Configurable, AbstractVcs> confs) {
  final HashMap<AbstractVcs, Configurable> result = new HashMap<AbstractVcs, Configurable>();
  for (Configurable configurable : confs.keySet()) {
    result.put(confs.get(configurable), configurable);
  }
  return result;
}
 
Example #22
Source File: SingleConfigurableEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public JComponent getPreferredFocusedComponent() {
  if (myConfigurable instanceof Configurable.HoldPreferredFocusedComponent) {
    JComponent preferred = ConfigurableUIMigrationUtil.getPreferredFocusedComponent((Configurable.HoldPreferredFocusedComponent)myConfigurable);
    if (preferred != null) return preferred;
  }
  return IdeFocusTraversalPolicy.getPreferredFocusedComponent(myCenterPanel);
}
 
Example #23
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public ActionCallback select(Class<? extends Configurable> configurableClass) {
  final Configurable configurable = findConfigurable(configurableClass);
  if (configurable == null) {
    return new ActionCallback.Rejected();
  }
  return select(configurable);
}
 
Example #24
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
void setContent(final JComponent component, ConfigurationException e, @Nonnull Configurable configurable) {
  if (component != null && mySimpleContent == component && myException == e) {
    return;
  }

  removeAll();

  if (component != null) {
    boolean noMargin = ConfigurableWrapper.isNoMargin(configurable);
    JComponent wrapComponent = component;
    if (!noMargin) {
      wrapComponent = JBUI.Panels.simplePanel().addToCenter(wrapComponent);
      wrapComponent.setBorder(new EmptyBorder(UIUtil.PANEL_SMALL_INSETS));
    }


    boolean noScroll = ConfigurableWrapper.isNoScroll(configurable);
    if (!noScroll) {
      JScrollPane scroll = ScrollPaneFactory.createScrollPane(wrapComponent, true);
      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      add(scroll, BorderLayout.CENTER);
    }
    else {
      add(wrapComponent, BorderLayout.CENTER);
    }
  }

  if (e != null) {
    myErrorLabel.setText(UIUtil.toHtml(e.getMessage()));
    add(myErrorLabel, BorderLayout.NORTH);
  }

  mySimpleContent = component;
  myException = e;
}
 
Example #25
Source File: WholeWestSingleConfigurableEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public WholeWestSingleConfigurableEditor(Component parent,
                                         Configurable configurable,
                                         String dimensionServiceKey,
                                         final boolean showApplyButton,
                                         final IdeModalityType ideModalityType) {
  super(parent, true);
  myDimensionKey = dimensionServiceKey;
  myShowApplyButton = showApplyButton;
  setTitle(createTitleString(configurable));

  myParentComponent = parent;
  myConfigurable = configurable;
  init();
  myConfigurable.reset();
}
 
Example #26
Source File: SubCompositeConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public final void disposeUIResources() {
  root = null;
  rootComponent = null;

  if (isChildrenMerged()) {
    for (Configurable child : children) {
      child.disposeUIResources();
    }
  }
  children = null;
}
 
Example #27
Source File: WholeWestSingleConfigurableEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public JComponent getPreferredFocusedComponent() {
  if (myConfigurable instanceof Configurable.HoldPreferredFocusedComponent) {
    JComponent preferred = ConfigurableUIMigrationUtil.getPreferredFocusedComponent((Configurable.HoldPreferredFocusedComponent)myConfigurable);
    if (preferred != null) return preferred;
  }
  return IdeFocusTraversalPolicy.getPreferredFocusedComponent(myRootPanel);
}
 
Example #28
Source File: SubCompositeConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public final void reset() {
  if (root != null) {
    root.reset(getSettings());
  }

  if (isChildrenMerged()) {
    for (Configurable child : children) {
      child.reset();
    }
  }
}
 
Example #29
Source File: DesktopShowSettingsUtilImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Configurable findConfigurable2Select(String id2Select, Configurable[] configurables) {
  for (Configurable configurable : configurables) {
    final Configurable conf = containsId(id2Select, configurable);
    if (conf != null) return conf;
  }
  return null;
}
 
Example #30
Source File: UpdateOrStatusOptionsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected Action[] createActions() {
  for(Configurable conf: myEnvToConfMap.values()) {
    if (conf.getHelpTopic() != null) {
      return new Action[] { getOKAction(), getCancelAction(), getHelpAction() };
    }
  }
  return super.createActions();
}