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 Project: consulo   Author: consulo   File: SubCompositeConfigurable.java    License: 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 #2
Source Project: p4ic4idea   Author: groboclown   File: P4SyncUpdateEnvironment.java    License: 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 #3
Source Project: consulo   Author: consulo   File: OptionsTree.java    License: 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 Project: consulo   Author: consulo   File: XDebuggerConfigurableProvider.java    License: 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 #5
Source Project: consulo   Author: consulo   File: SingleConfigurableEditor.java    License: 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 #6
Source Project: consulo   Author: consulo   File: SingleConfigurableEditor.java    License: 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 Project: consulo   Author: consulo   File: SubCompositeConfigurable.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public final Configurable[] getConfigurables() {
  if (children == null) {
    Collection<Configurable> configurables = XDebuggerConfigurableProvider.getConfigurables(getCategory());
    children = configurables.toArray(new Configurable[configurables.size()]);
  }
  return isChildrenMerged() ? DebuggerConfigurable.EMPTY_CONFIGURABLES : children;
}
 
Example #8
Source Project: idea-php-generics-plugin   Author: Haehnchen   File: PhpStanAnnotatorQualityToolAnnotator.java    License: 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 #9
Source Project: consulo   Author: consulo   File: DesktopShowSettingsUtilImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private static Configurable containsId(String id2Select, Configurable configurable) {
  if (configurable instanceof SearchableConfigurable && id2Select.equals(((SearchableConfigurable)configurable).getId())) {
    return configurable;
  }
  if (configurable instanceof SearchableConfigurable.Parent) {
    for (Configurable subConfigurable : ((SearchableConfigurable.Parent)configurable).getConfigurables()) {
      final Configurable config = containsId(id2Select, subConfigurable);
      if (config != null) return config;
    }
  }
  return null;
}
 
Example #10
Source Project: consulo   Author: consulo   File: MergedCompositeConfigurable.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Nullable
@Override
public Component createUIComponent() {
  if (myRootComponent == null) {
    Configurable firstConfigurable = children[0];
    if (children.length == 1) {
      myRootComponent = firstConfigurable.createUIComponent();
    }
    else {
      VerticalLayout verticalLayout = VerticalLayout.create();
      for (Configurable configurable : children) {
        Component uiComponent = configurable.createUIComponent();
        if (uiComponent == null) {
          continue;
        }

        String displayName = configurable.getDisplayName();
        if (StringUtil.isEmpty(displayName)) {
          verticalLayout.add(uiComponent);
        }
        else {
          LabeledLayout labeledLayout = LabeledLayout.create(displayName);
          labeledLayout.set(uiComponent);
          verticalLayout.add(labeledLayout);
        }
      }
      myRootComponent = verticalLayout;
    }
  }
  return myRootComponent;
}
 
Example #11
Source Project: intellij   Author: bazelbuild   File: SdkUtil.java    License: Apache License 2.0 5 votes vote down vote up
/** Opens the SDK manager settings page */
public static void openSdkManager() {
  Configurable configurable =
      ConfigurableExtensionPointUtil.createApplicationConfigurableForProvider(
          SdkUpdaterConfigurableProvider.class);
  ShowSettingsUtil.getInstance().showSettingsDialog(null, configurable.getClass());
}
 
Example #12
Source Project: consulo   Author: consulo   File: OptionsEditor.java    License: Apache License 2.0 5 votes vote down vote up
private String[] getBannerText(Configurable configurable) {
  final List<Configurable> list = myTree.getPathToRoot(configurable);
  final String[] result = new String[list.size()];
  int add = 0;
  for (int i = list.size() - 1; i >= 0; i--) {
    result[add++] = list.get(i).getDisplayName().replace('\n', ' ');
  }
  return result;
}
 
Example #13
Source Project: android-codegenerator-plugin-intellij   Author: tmorcinek   File: MainConfigurable.java    License: 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 #14
Source Project: consulo   Author: consulo   File: ProjectStructureConfigurable.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void disposeUIResources() {
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
  propertiesComponent.setValue("project.structure.last.edited", myUiState.lastEditedConfigurable);

  myContext.getDaemonAnalyzer().stop();
  for (Configurable each : myName2Config) {
    each.disposeUIResources();
  }
  myProjectStructureDialog = null;
  myContext.clear();
  myName2Config.clear();
}
 
Example #15
Source Project: consulo   Author: consulo   File: DesktopProjectStructureDialog.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public void select(@Nonnull Configurable configurable) {
  List<StripeTabPanel.TabInfo> tabs = myStripeTabPanel.getTabs();
  for (StripeTabPanel.TabInfo tab : tabs) {
    Configurable other = tab.getUserData(CONFIGURABLE_KEY);
    if (other == configurable) {
      tab.select();
      break;
    }
  }
}
 
Example #16
Source Project: consulo   Author: consulo   File: DesktopSettingsDialog.java    License: 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 #17
Source Project: consulo   Author: consulo   File: VcsConfigurationsDialog.java    License: 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 #18
Source Project: consulo   Author: consulo   File: PostfixTemplatesConfigurable.java    License: 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 #19
Source Project: consulo   Author: consulo   File: ConfigurableUIMigrationUtil.java    License: 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 #20
Source Project: consulo   Author: consulo   File: OptionsEditor.java    License: 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 #21
Source Project: consulo   Author: consulo   File: OptionsEditor.java    License: 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 #22
Source Project: consulo   Author: consulo   File: BaseShowSettingsUtil.java    License: 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 #23
Source Project: consulo   Author: consulo   File: SearchUtil.java    License: 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 #24
Source Project: consulo   Author: consulo   File: OptionsEditor.java    License: 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 #25
Source Project: consulo   Author: consulo   File: OptionsTree.java    License: 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 #26
Source Project: consulo   Author: consulo   File: DesktopSettingsDialog.java    License: 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 #27
Source Project: consulo   Author: consulo   File: DesktopSettingsDialog.java    License: 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 #28
Source Project: consulo   Author: consulo   File: UpdateOrStatusOptionsDialog.java    License: 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 #29
Source Project: consulo   Author: consulo   File: SingleConfigurableEditor.java    License: 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 #30
Source Project: consulo   Author: consulo   File: OptionsEditor.java    License: 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);
}