diff --git a/images/src/org/intellij/images/options/impl/ImagesOptionsTopHitProvider.java b/images/src/org/intellij/images/options/impl/ImagesOptionsTopHitProvider.java new file mode 100644 index 000000000000..39675fc62d31 --- /dev/null +++ b/images/src/org/intellij/images/options/impl/ImagesOptionsTopHitProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.intellij.images.options.impl; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class ImagesOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new OptionsConfigurabe(); + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/AutoImportOptionsTopHitProvider.java b/platform/lang-impl/src/com/intellij/application/options/editor/AutoImportOptionsTopHitProvider.java new file mode 100644 index 000000000000..8778b9f27492 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/editor/AutoImportOptionsTopHitProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.editor; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class AutoImportOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new AutoImportOptionsConfigurable(); + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingOptionsTopHitProvider.java b/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingOptionsTopHitProvider.java new file mode 100644 index 000000000000..cedf5416d8a7 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingOptionsTopHitProvider.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.editor; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +import javax.swing.*; + +/** + * @author Sergey.Malenkov + */ +public class CodeFoldingOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + private int myCount; + + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + myCount = 0; + return new CodeFoldingConfigurable(); + } + + @Override + protected String getName(Configurable configurable) { + return null; + } + + @Override + protected String getOptionName(JCheckBox checkbox) { + String name = super.getOptionName(checkbox); + if (name != null && 0 < myCount++) { + name = "Collapse by default: " + name; + } + return name; + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsTopHitProvider.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsTopHitProvider.java new file mode 100644 index 000000000000..9828e92fc484 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsTopHitProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.editor; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class EditorOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new EditorOptions(); + } + + @Override + protected String getName(Configurable configurable) { + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysOptionsTopHitProvider.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysOptionsTopHitProvider.java new file mode 100644 index 000000000000..28b185b10197 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysOptionsTopHitProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.editor; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class EditorSmartKeysOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new EditorSmartKeysConfigurable(); + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsOptionsTopHitProvider.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsOptionsTopHitProvider.java new file mode 100644 index 000000000000..805412fbf4a7 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsOptionsTopHitProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.editor; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class EditorTabsOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new EditorTabsConfigurable(); + } + + @Override + protected String getName(Configurable configurable) { + return null; + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/ui/ConfigurableOptionsTopHitProvider.java b/platform/platform-impl/src/com/intellij/ide/ui/ConfigurableOptionsTopHitProvider.java new file mode 100644 index 000000000000..ff759f9ce0de --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/ConfigurableOptionsTopHitProvider.java @@ -0,0 +1,171 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.ui; + +import com.intellij.ide.ui.search.BooleanOptionDescription; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.options.ex.ConfigurableVisitor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.util.*; + +/** + * @author Sergey.Malenkov + */ +public abstract class ConfigurableOptionsTopHitProvider extends OptionsTopHitProvider { + private static final Logger LOG = Logger.getInstance(ConfigurableOptionsTopHitProvider.class); + private final Deque myPrefix = new ArrayDeque(); + + protected abstract Configurable getConfigurable(Project project); + + /** + * Returns a name that will be added to all option names. + * This implementation returns the display name of the configurable. + * + * @param configurable the configurable to process + * @return a main prefix or {@code null} to ignore + */ + protected String getName(Configurable configurable) { + return configurable.getDisplayName(); + } + + /** + * Returns a section name that will be added to some option names, + * which are located within the specified container. + * This implementation returns the border title of the component. + * + * @param component the component to process + * @return a section prefix or {@code null} to ignore + */ + protected String getSection(Component component) { + if (component instanceof JComponent) { + Border border = ((JComponent)component).getBorder(); + if (border instanceof TitledBorder) { + return ((TitledBorder)border).getTitle(); + } + } + return null; + } + + /** + * Returns an option name that will be used to create an option. + * + * @param checkbox the candidate to create an option + * @return an option prefix or {@code null} to ignore this option + */ + protected String getOptionName(JCheckBox checkbox) { + String name = StringUtil.stripHtml(checkbox.getText(), false); + if (StringUtil.isEmpty(name)) { + return null; + } + if (myPrefix.isEmpty()) { + return name; + } + StringBuilder sb = new StringBuilder(); + Iterator iterator = myPrefix.descendingIterator(); + while (iterator.hasNext()) { + sb.append(iterator.next()).append(": "); + } + return sb.append(name).toString(); + } + + protected void init(Collection options, Configurable configurable, Component component) { + initRecursively(options, configurable, component); + } + + private void initRecursively(Collection options, Configurable configurable, Component component) { + String section = getSection(component); + if (section != null) { + myPrefix.push(section); + } + if (component instanceof JCheckBox) { + JCheckBox checkbox = (JCheckBox)component; + String option = getOptionName(checkbox); + if (option != null) { + options.add(new Option(configurable, checkbox, option)); + } + } + else if (component instanceof Container) { + Container container = (Container)component; + for (int i = 0; i < container.getComponentCount(); i++) { + initRecursively(options, configurable, container.getComponent(i)); + } + } + if (section != null) { + myPrefix.pop(); + } + } + + @NotNull + @Override + public Collection getOptions(@Nullable Project project) { + try { + Configurable configurable = getConfigurable(project); + Component component = configurable.createComponent(); + configurable.reset(); + myPrefix.clear(); + String name = getName(configurable); + if (name != null) { + myPrefix.push(name); + } + Collection options = new ArrayList(); + init(options, configurable, component); + return Collections.unmodifiableCollection(options); + } + catch (Exception exception) { + LOG.debug(exception); + } + return Collections.emptyList(); + } + + private static final class Option extends BooleanOptionDescription { + private final Configurable myConfigurable; + private final JCheckBox myCheckBox; + + private Option(Configurable configurable, JCheckBox checkbox, String option) { + super(option, ConfigurableVisitor.ByID.getID(configurable)); + myConfigurable = configurable; + myCheckBox = checkbox; + } + + @Override + public boolean isOptionEnabled() { + return myCheckBox.isSelected(); + } + + @Override + public void setOptionState(boolean selected) { + if (selected != myCheckBox.isSelected()) { + myCheckBox.setSelected(selected); + try { + myConfigurable.apply(); + } + catch (ConfigurationException exception) { + LOG.debug(exception); + } + } + } + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java b/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java index 6ffe2489fb52..18627b077d52 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java @@ -16,10 +16,7 @@ package com.intellij.ide.ui; import com.intellij.ide.ui.search.BooleanOptionDescription; -import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; -import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.SystemInfo; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,54 +28,8 @@ import java.util.Collection; */ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider { private static final String ID = "editor"; - + private static final Collection ourOptions = ContainerUtil.immutableList( - editor("Mouse: " + messageApp("checkbox.honor.camelhumps.words.settings.on.double.click"), - "IS_MOUSE_CLICK_SELECTION_HONORS_CAMEL_WORDS"), - editor("Mouse: " + messageApp(SystemInfo.isMac - ? "checkbox.enable.ctrl.mousewheel.changes.font.size.macos" - : "checkbox.enable.ctrl.mousewheel.changes.font.size"), "IS_WHEEL_FONTCHANGE_ENABLED"), - editor("Mouse: " + messageApp("checkbox.enable.drag.n.drop.functionality.in.editor"), "IS_DND_ENABLED"), - new EditorOptionDescription(null, messageApp("checkbox.use.soft.wraps.at.editor.action.text"), "preferences.editor") { - @Override - public boolean isOptionEnabled() { - return EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR); - } - - @Override - public void setOptionState(boolean enabled) { - EditorSettingsExternalizable.getInstance().setUseSoftWraps(enabled, SoftWrapAppliancePlaces.MAIN_EDITOR); - fireUpdated(); - } - }, - new EditorOptionDescription(null, messageApp("checkbox.use.soft.wraps.at.console.action.text"), "preferences.editor") { - @Override - public boolean isOptionEnabled() { - return EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE); - } - - @Override - public void setOptionState(boolean enabled) { - EditorSettingsExternalizable.getInstance().setUseSoftWraps(enabled, SoftWrapAppliancePlaces.CONSOLE); - fireUpdated(); - } - }, - editor(messageApp("checkbox.use.custom.soft.wraps.indent.action.text"), "USE_CUSTOM_SOFT_WRAP_INDENT"), - new EditorOptionDescription(null, messageApp("checkbox.show.softwraps.only.for.caret.line.action.text"), "preferences.editor") { - @Override - public boolean isOptionEnabled() { - return !EditorSettingsExternalizable.getInstance().isAllSoftWrapsShown(); - } - - @Override - public void setOptionState(boolean enabled) { - EditorSettingsExternalizable.getInstance().setAllSoftwrapsShown(!enabled); - fireUpdated(); - } - }, - editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.after.end.of.line"), "IS_VIRTUAL_SPACE"), - editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.inside.tabs"), "IS_CARET_INSIDE_TABS"), - editor("Virtual Space: " + messageApp("checkbox.show.virtual.space.at.file.bottom"), "ADDITIONAL_PAGE_AT_BOTTOM"), editorUI("Appearance: " + messageIde("checkbox.use.antialiased.font.in.editor"), "ANTIALIASING_IN_EDITOR"), editorUI("Appearance: " + messageIde("checkbox.use.lcd.rendered.font.in.editor"), "USE_LCD_RENDERING_IN_EDITOR"), editorApp("Appearance: Caret blinking", "IS_CARET_BLINKING"), @@ -91,16 +42,8 @@ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider { editorApp("Appearance: Show trailing whitespaces", "IS_TRAILING_WHITESPACES_SHOWN"), editorApp("Appearance: Show vertical indent guides", "IS_INDENT_GUIDES_SHOWN"), editorCode("Appearance: " + messageApp("checkbox.show.small.icons.in.gutter"), "SHOW_SMALL_ICONS_IN_GUTTER"), - option("Appearance: " + messageApp("checkbox.show.code.folding.outline"), "IS_FOLDING_OUTLINE_SHOWN", "editor.preferences.folding"), - editorTabs("Tabs: " + messageApp("checkbox.editor.tabs.in.single.row"), "SCROLL_TAB_LAYOUT_IN_EDITOR"), - editorTabs("Tabs: " + messageApp("checkbox.editor.scroll.if.need"), "HIDE_TABS_IF_NEED"), - editorTabs("Tabs: " + messageApp("checkbox.hide.file.extension.in.editor.tabs"), "HIDE_KNOWN_EXTENSION_IN_TABS"), - editorTabs("Tabs: Show directory in editor tabs for non-unique filenames", "SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES"), - editorTabs("Tabs: " + messageApp("checkbox.editor.tabs.show.close.button"), "SHOW_CLOSE_BUTTON"), - editorTabs("Tabs: " + messageApp("checkbox.mark.modified.tabs.with.asterisk"), "MARK_MODIFIED_TABS_WITH_ASTERISK"), - editorTabs("Tabs: " + messageApp("checkbox.show.tabs.tooltips"), "SHOW_TABS_TOOLTIPS"), - editorTabs("Tabs: " + messageApp("checkbox.smart.tab.reuse"), "REUSE_NOT_MODIFIED_TABS"), - editorTabs("Tabs: " + messageApp("radio.close.non.modified.files.first"), "CLOSE_NON_MODIFIED_FILES_FIRST") + editorTabs(messageApp("group.tab.closing.policy") + ": " + + messageApp("radio.close.non.modified.files.first"), "CLOSE_NON_MODIFIED_FILES_FIRST") ); @NotNull @@ -137,7 +80,7 @@ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider { static BooleanOptionDescription editorCode(String option, String field) { return new DaemonCodeAnalyzerOptionDescription(field, option, "editor.preferences.appearance"); } - + public static class Ex extends OptionsTopHitProvider implements CoveredByToggleActions { private static final Collection ourOptions = ContainerUtil.immutableList( editorApp("Appearance: " + messageApp("checkbox.show.line.numbers"), "ARE_LINE_NUMBERS_SHOWN") diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 2038a55e0e27..17df98479bf3 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -377,6 +377,13 @@ + + + + + + + diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/GuiDesignerOptionsTopHitProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/GuiDesignerOptionsTopHitProvider.java new file mode 100644 index 000000000000..7413c94a96fb --- /dev/null +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/GuiDesignerOptionsTopHitProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.uiDesigner; + +import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +/** + * @author Sergey.Malenkov + */ +public class GuiDesignerOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider { + @Override + public String getId() { + return "editor"; + } + + @Override + protected Configurable getConfigurable(Project project) { + return new GuiDesignerConfigurable(project); + } +}