diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/application/options')
14 files changed, 144 insertions, 48 deletions
diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java index 760d17e67d24..758aef6a9065 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java @@ -302,6 +302,11 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent. @Override public boolean isModified() { if (myModel != null) { + if (Registry.is("ide.new.settings.dialog")) { + if (myPanels != null && myPanels.size() > 0 && myPanels.get(0).isModified()) { + return true; + } + } boolean schemeListModified = myModel.isSchemeListModified(); if (schemeListModified) { myApplyCompleted = false; diff --git a/platform/lang-impl/src/com/intellij/application/options/ModuleListCellRenderer.java b/platform/lang-impl/src/com/intellij/application/options/ModuleListCellRenderer.java index f544517bb5d4..6bc5f6505c92 100644 --- a/platform/lang-impl/src/com/intellij/application/options/ModuleListCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/application/options/ModuleListCellRenderer.java @@ -3,6 +3,7 @@ package com.intellij.application.options; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleType; import com.intellij.ui.ListCellRendererWrapper; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -10,10 +11,20 @@ import javax.swing.*; * @author yole */ public class ModuleListCellRenderer extends ListCellRendererWrapper<Module> { + private final String myEmptySelectionText; + + public ModuleListCellRenderer() { + this("[none]"); + } + + public ModuleListCellRenderer(@NotNull String emptySelectionText) { + myEmptySelectionText = emptySelectionText; + } + @Override public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) { if (module == null) { - setText("[none]"); + setText(myEmptySelectionText); } else { setIcon(ModuleType.get(module).getIcon()); diff --git a/platform/lang-impl/src/com/intellij/application/options/ModulesComboBox.java b/platform/lang-impl/src/com/intellij/application/options/ModulesComboBox.java index 17434cb0c7ba..4c2ef3a3d16c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/ModulesComboBox.java +++ b/platform/lang-impl/src/com/intellij/application/options/ModulesComboBox.java @@ -36,6 +36,7 @@ import java.util.List; */ public class ModulesComboBox extends ComboBox { private final SortedComboBoxModel<Module> myModel; + private boolean myAllowEmptySelection; public ModulesComboBox() { this(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE)); @@ -58,8 +59,17 @@ public class ModulesComboBox extends ComboBox { setRenderer(new ModuleListCellRenderer()); } + public void allowEmptySelection(@NotNull String emptySelectionText) { + myAllowEmptySelection = true; + myModel.add(null); + setRenderer(new ModuleListCellRenderer(emptySelectionText)); + } + public void setModules(@NotNull Collection<Module> modules) { myModel.setAll(modules); + if (myAllowEmptySelection) { + myModel.add(null); + } } public void fillModules(@NotNull Project project) { diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java index 653f6b51e8bd..282f44d04a60 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java @@ -214,7 +214,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper { return !file.isDirectory() && importer.getSourceExtension().equals(file.getExtension()); } }, null, myContentPane); - VirtualFile[] selection = fileChooser.choose(CodeStyleSchemesUIConfiguration.Util.getRecentImportFile(), null); + VirtualFile[] selection = fileChooser.choose(null, CodeStyleSchemesUIConfiguration.Util.getRecentImportFile()); if (selection.length == 1) { VirtualFile selectedFile = selection[0]; selectedFile.refresh(false, false); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java index c192d0e2893a..2972dacf2ceb 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java @@ -43,6 +43,7 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel { addOption("KEEP_SIMPLE_CLASSES_IN_ONE_LINE", ApplicationBundle.message("wrapping.keep.simple.classes.in.one.line"), WRAPPING_KEEP); addOption("WRAP_LONG_LINES", ApplicationBundle.message("wrapping.long.lines"), null); + addOption("WRAP_COMMENTS", ApplicationBundle.message("wrapping.comments.wrap.at.right.margin"), WRAPPING_COMMENTS); addOption("CLASS_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.class.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES); addOption("METHOD_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.method.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractArrangementRuleAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractArrangementRuleAction.java new file mode 100644 index 000000000000..3036ca9ed43e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractArrangementRuleAction.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 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.codeStyle.arrangement.action; + +import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl; +import com.intellij.openapi.actionSystem.AnAction; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; + +/** + * @author Svetlana.Zemlyanskaya + */ +public abstract class AbstractArrangementRuleAction extends AnAction { + + protected void scrollRowToVisible(@NotNull ArrangementMatchingRulesControl control, int row) { + final Rectangle rect = control.getCellRect(row, 0, false); + if (row != control.getEditingRow() - 1) { + control.scrollRectToVisible(rect); + } + else { + final Rectangle editorRect = control.getCellRect(row + 1, 0, false); + if(!rect.isEmpty() && !editorRect.isEmpty()) { + final int height = (int)(rect.getHeight() + editorRect.getHeight()); + final Rectangle visibleRect = new Rectangle((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), height); + control.scrollRectToVisible(visibleRect); + } + } + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractMoveArrangementRuleAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractMoveArrangementRuleAction.java index 0cbfa2265dc8..b790c17a659d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractMoveArrangementRuleAction.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AbstractMoveArrangementRuleAction.java @@ -17,7 +17,6 @@ package com.intellij.application.options.codeStyle.arrangement.action; import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl; import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel; -import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAware; import org.jetbrains.annotations.NotNull; @@ -30,7 +29,7 @@ import java.util.List; * @author Denis Zhdanov * @since 11/13/12 7:17 PM */ -public abstract class AbstractMoveArrangementRuleAction extends AnAction implements DumbAware { +public abstract class AbstractMoveArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware { @Override public void update(AnActionEvent e) { @@ -95,8 +94,17 @@ public abstract class AbstractMoveArrangementRuleAction extends AnAction impleme } + int visibleRow = -1; if (newRowToEdit >= 0) { control.showEditor(newRowToEdit); + visibleRow = newRowToEdit; + } + else if (!mappings.isEmpty()) { + visibleRow = mappings.get(0)[1]; + } + + if (visibleRow != -1) { + scrollRowToVisible(control, visibleRow); } } }); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AddArrangementRuleAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AddArrangementRuleAction.java index f19b4513a628..fdde6eab9cbc 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AddArrangementRuleAction.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/AddArrangementRuleAction.java @@ -19,7 +19,6 @@ import com.intellij.application.options.codeStyle.arrangement.match.ArrangementM import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel; import com.intellij.application.options.codeStyle.arrangement.match.EmptyArrangementRuleComponent; import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.project.DumbAware; @@ -31,7 +30,7 @@ import org.jetbrains.annotations.NotNull; * @author Denis Zhdanov * @since 8/24/12 1:54 PM */ -public class AddArrangementRuleAction extends AnAction implements DumbAware { +public class AddArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware { public AddArrangementRuleAction() { getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.add.text")); @@ -64,6 +63,7 @@ public class AddArrangementRuleAction extends AnAction implements DumbAware { } showEditor(control, rowToEdit); control.getSelectionModel().setSelectionInterval(rowToEdit, rowToEdit); + scrollRowToVisible(control, rowToEdit); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/EditArrangementRuleAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/EditArrangementRuleAction.java index ffccce252176..14beaa21a1d9 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/EditArrangementRuleAction.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/EditArrangementRuleAction.java @@ -16,7 +16,6 @@ package com.intellij.application.options.codeStyle.arrangement.action; import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl; -import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Toggleable; import com.intellij.openapi.application.ApplicationBundle; @@ -27,7 +26,7 @@ import gnu.trove.TIntArrayList; * @author Denis Zhdanov * @since 10/29/12 11:01 AM */ -public class EditArrangementRuleAction extends AnAction implements DumbAware, Toggleable { +public class EditArrangementRuleAction extends AbstractArrangementRuleAction implements DumbAware, Toggleable { public EditArrangementRuleAction() { getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.edit.text")); @@ -50,6 +49,8 @@ public class EditArrangementRuleAction extends AnAction implements DumbAware, To if (rows.size() != 1) { return; } - control.showEditor(rows.get(0)); + final int row = rows.get(0); + control.showEditor(row); + scrollRowToVisible(control, row); } } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RemoveArrangementRuleAction.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RemoveArrangementRuleAction.java index e1abf16f7eb1..5fbcdccd38e9 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RemoveArrangementRuleAction.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/action/RemoveArrangementRuleAction.java @@ -39,7 +39,7 @@ public class RemoveArrangementRuleAction extends AnAction implements DumbAware { @Override public void update(AnActionEvent e) { ArrangementMatchingRulesControl control = ArrangementMatchingRulesControl.KEY.getData(e.getDataContext()); - e.getPresentation().setEnabled(control != null && !control.getSelectedModelRows().isEmpty()); + e.getPresentation().setEnabled(control != null && !control.getSelectedModelRows().isEmpty() && control.getEditingRow() == -1); e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Remove : AllIcons.ToolbarDecorator.Remove); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/group/ArrangementGroupingRulesControl.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/group/ArrangementGroupingRulesControl.java index 581eb0aa96a2..a847aecd289f 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/group/ArrangementGroupingRulesControl.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/group/ArrangementGroupingRulesControl.java @@ -38,6 +38,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; /** * @author Denis Zhdanov @@ -95,17 +96,21 @@ public class ArrangementGroupingRulesControl extends JBTable { model.removeRow(model.getRowCount() - 1); } - List<ArrangementSettingsToken> types = ContainerUtilRt.newArrayList(myComponents.keySet()); + final Set<ArrangementSettingsToken> groupingTokens = ContainerUtilRt.newHashSet(myComponents.keySet()); + for (ArrangementGroupingRule rule : rules) { + final ArrangementSettingsToken groupingType = rule.getGroupingType(); + ArrangementGroupingComponent component = myComponents.get(groupingType); + component.setSelected(true); + component.setOrderType(rule.getOrderType()); + model.addRow(new Object[]{component}); + groupingTokens.remove(groupingType); + } + + List<ArrangementSettingsToken> types = ContainerUtilRt.newArrayList(groupingTokens); types = mySettingsManager.sort(types); for (ArrangementSettingsToken type : types) { model.addRow(new Object[]{myComponents.get(type)}); } - for (ArrangementGroupingRule rule : rules) { - ArrangementGroupingComponent component = myComponents.get(rule.getGroupingType()); - component.setSelected(true); - ArrangementSettingsToken orderType = rule.getOrderType(); - component.setOrderType(orderType); - } } @NotNull diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/match/ArrangementMatchingRulesControl.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/match/ArrangementMatchingRulesControl.java index 145ae1094e0b..a77e5cce28f0 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/match/ArrangementMatchingRulesControl.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/match/ArrangementMatchingRulesControl.java @@ -527,35 +527,52 @@ public class ArrangementMatchingRulesControl extends JBTable { private class MyValidator { @Nullable private String validate(int index) { - if (mySectionRuleManager == null || getModel().getSize() < index) { + if (getModel().getSize() < index) { return null; } + if (mySectionRuleManager != null) { + final ArrangementSectionRuleData data = extractSectionText(index); + if (data != null) { + return validateSectionRule(data, index); + } + } + + final Object target = getModel().getElementAt(index); + if (target instanceof StdArrangementMatchRule) { + for (int i = 0; i < index; i++) { + final Object element = getModel().getElementAt(i); + if (element instanceof StdArrangementMatchRule && target.equals(element)) { + return ApplicationBundle.message("arrangement.settings.validation.duplicate.matching.rule"); + } + } + } + return null; + } + + @Nullable + private String validateSectionRule(@NotNull ArrangementSectionRuleData data, int index) { int startSectionIndex = -1; - final Set<String> rules = ContainerUtil.newHashSet(); + final Set<String> sectionRules = ContainerUtil.newHashSet(); for (int i = 0; i < index; i++) { final ArrangementSectionRuleData section = extractSectionText(i); if (section != null) { startSectionIndex = section.isSectionStart() ? i : -1; if (StringUtil.isNotEmpty(section.getText())) { - rules.add(section.getText()); + sectionRules.add(section.getText()); } } } + if (StringUtil.isNotEmpty(data.getText()) && sectionRules.contains(data.getText())) { + return ApplicationBundle.message("arrangement.settings.validation.duplicate.section.text"); + } - final ArrangementSectionRuleData data = extractSectionText(index); - if (data != null) { - if (StringUtil.isNotEmpty(data.getText()) && rules.contains(data.getText())) { - return ApplicationBundle.message("arrangement.settings.validation.duplicate.section.text"); + if (!data.isSectionStart()) { + if (startSectionIndex == -1) { + return ApplicationBundle.message("arrangement.settings.validation.end.section.rule.without.start"); } - - if (!data.isSectionStart()) { - if (startSectionIndex == -1) { - return ApplicationBundle.message("arrangement.settings.validation.end.section.rule.without.start"); - } - else if (startSectionIndex == index - 1) { - return ApplicationBundle.message("arrangement.settings.validation.empty.section.rule"); - } + else if (startSectionIndex == index - 1) { + return ApplicationBundle.message("arrangement.settings.validation.empty.section.rule"); } } return null; diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form index edb9fcdb9e18..4bc9490d0090 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form @@ -109,7 +109,7 @@ <properties/> <border type="none"/> <children> - <component id="2479d" class="javax.swing.JLabel"> + <component id="2479d" class="javax.swing.JLabel" binding="myTabTitleLimitLabel"> <constraints> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/> </constraints> diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java index 35a34085d035..93cde6a72f6d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java @@ -46,6 +46,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { private JCheckBox myShowDirectoryInTabCheckBox; private JRadioButton myActivateRightNeighbouringTabRadioButton; private JTextField myTabTitleLimitField; + private JLabel myTabTitleLimitLabel; public EditorTabsConfigurable() { myEditorTabPlacement.setModel(new DefaultComboBoxModel(new Object[]{ @@ -69,21 +70,15 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { private void revalidateSingleRowCheckbox() { final int i = ((Integer)myEditorTabPlacement.getSelectedItem()).intValue(); - if (i == UISettings.TABS_NONE) { - myHideKnownExtensions.setEnabled(false); - myScrollTabLayoutInEditorCheckBox.setEnabled(false); - myCbModifiedTabsMarkedWithAsterisk.setEnabled(false); - myShowTabsTooltipsCheckBox.setEnabled(false); - myShowCloseButtonOnCheckBox.setEnabled(false); - myShowDirectoryInTabCheckBox.setEnabled(false); - } else { - myHideKnownExtensions.setEnabled(true); - myScrollTabLayoutInEditorCheckBox.setEnabled(true); - myCbModifiedTabsMarkedWithAsterisk.setEnabled(true); - myShowTabsTooltipsCheckBox.setEnabled(true); - myShowCloseButtonOnCheckBox.setEnabled(true); - myShowDirectoryInTabCheckBox.setEnabled(true); - } + boolean none = i == UISettings.TABS_NONE; + myHideKnownExtensions.setEnabled(!none); + myScrollTabLayoutInEditorCheckBox.setEnabled(!none); + myCbModifiedTabsMarkedWithAsterisk.setEnabled(!none); + myShowTabsTooltipsCheckBox.setEnabled(!none); + myShowCloseButtonOnCheckBox.setEnabled(!none); + myShowDirectoryInTabCheckBox.setEnabled(!none); + myTabTitleLimitField.setEnabled(!none); + myTabTitleLimitLabel.setEnabled(!none); if (SwingConstants.TOP == i) { myScrollTabLayoutInEditorCheckBox.setEnabled(true); |