This commit is contained in:
Alexey Kudravtsev
2014-04-07 14:00:08 +04:00
parent 12c80e771b
commit 34e550f643
26 changed files with 140 additions and 91 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -31,6 +31,7 @@ public interface Profile extends JDOMExternalizable, Comparable, Scheme {
boolean isLocal();
void setName(@NotNull String name);
@Override
@NotNull
String getName();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -21,5 +21,5 @@ public interface ExternalizableScheme extends Scheme{
@NotNull
ExternalInfo getExternalInfo();
void setName(String newName);
void setName(@NotNull String newName);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -15,6 +15,9 @@
*/
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
public interface Scheme {
@NotNull
String getName();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -70,6 +70,7 @@ public abstract class AbstractSchemesManager<T extends Scheme, E extends Externa
}
}
@NotNull
private String generateUniqueName(final T scheme) {
return UniqueNameGenerator.generateUniqueName(UniqueFileNamesProvider.convertName(scheme.getName()), collectExistingNames(mySchemes));
}
@@ -167,7 +168,7 @@ public abstract class AbstractSchemesManager<T extends Scheme, E extends Externa
protected abstract void onSchemeAdded(final T scheme);
protected void renameScheme(final E scheme, String newName){
protected void renameScheme(final E scheme, @NotNull String newName){
if (!Comparing.equal(newName,scheme.getName())) {
scheme.setName(newName);
LOG.assertTrue(Comparing.equal(newName,scheme.getName()));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -118,6 +118,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
return c != null ? c : Color.black;
}
@NotNull
@Override
public String getName() {
return mySchemeName;
@@ -183,7 +184,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
}
@Override
public void setName(String name) {
public void setName(@NotNull String name) {
mySchemeName = name;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -26,6 +26,7 @@ import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.InvalidDataException;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -65,6 +66,7 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl
myName = parentNode.getAttributeValue(NAME_ATTR);
}
@NotNull
@Override
public String getName() {
return myName;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -16,6 +16,7 @@
package com.intellij.psi.codeStyle;
import com.intellij.openapi.options.Scheme;
import org.jetbrains.annotations.NotNull;
/**
* @author MYakovlev
@@ -23,6 +24,7 @@ import com.intellij.openapi.options.Scheme;
*/
public interface CodeStyleScheme extends Scheme {
@Override
@NotNull
String getName();
boolean isDefault();
CodeStyleSettings getCodeStyleSettings();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -26,6 +26,7 @@ import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeImpl;
import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemesImpl;
import com.intellij.util.EventDispatcher;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -43,7 +44,7 @@ public class CodeStyleSchemesModel {
private final Project myProject;
private boolean myUsePerProjectSettings;
public final static String PROJECT_SCHEME_NAME = "Project";
public static final String PROJECT_SCHEME_NAME = "Project";
public CodeStyleSchemesModel(Project project) {
myProject = project;
@@ -153,13 +154,12 @@ public class CodeStyleSchemesModel {
CodeStyleSchemes schemes = CodeStyleSchemes.getInstance();
if (getProjectSettings().USE_PER_PROJECT_SETTINGS != myUsePerProjectSettings) return true;
if (!myUsePerProjectSettings &&
(getSelectedScheme() != schemes.findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE))) {
getSelectedScheme() != schemes.findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE)) {
return true;
}
Set<CodeStyleScheme> configuredSchemesSet = new HashSet<CodeStyleScheme>(getSchemes());
Set<CodeStyleScheme> savedSchemesSet = new HashSet<CodeStyleScheme>(Arrays.asList(schemes.getSchemes()));
if (!configuredSchemesSet.equals(savedSchemesSet)) return true;
return false;
return !configuredSchemesSet.equals(savedSchemesSet);
}
public void apply() {
@@ -220,26 +220,9 @@ public class CodeStyleSchemesModel {
public void copyToProject(final CodeStyleScheme selectedScheme) {
myProjectScheme.getCodeStyleSettings().copyFrom(selectedScheme.getCodeStyleSettings());
myDispatcher.getMulticaster().schemeChanged(myProjectScheme);
//if (mySettingsToClone.containsKey(myProjectScheme)) {
// CodeStyleSettings projectSettings = mySettingsToClone.get(myProjectScheme);
// projectSettings.copyFrom(getEditedSchemeSettings(selectedScheme));
//}
//else {
// mySettingsToClone.put(myProjectScheme, getEditedSchemeSettings(selectedScheme).clone());
//}
//myDispatcher.getMulticaster().schemeChanged(myProjectScheme);
}
private CodeStyleSettings getEditedSchemeSettings(final CodeStyleScheme selectedScheme) {
if (mySettingsToClone.containsKey(selectedScheme)) {
return mySettingsToClone.get(selectedScheme);
}
else {
return selectedScheme.getCodeStyleSettings();
}
}
public CodeStyleScheme exportProjectScheme(final String name) {
public CodeStyleScheme exportProjectScheme(@NotNull String name) {
CodeStyleScheme newScheme = createNewScheme(name, myProjectScheme);
((CodeStyleSchemeImpl)newScheme).setCodeStyleSettings(getCloneSettings(myProjectScheme));
addScheme(newScheme, false);
@@ -250,11 +233,12 @@ public class CodeStyleSchemesModel {
public CodeStyleScheme createNewScheme(final String preferredName, final CodeStyleScheme parentScheme) {
String name;
if (preferredName == null) {
if (parentScheme == null) throw new IllegalArgumentException("parentScheme must not be null");
// Generate using parent name
name = null;
for (int i = 1; name == null; i++) {
String currName = parentScheme.getName() + " (" + i + ")";
if (null == findSchemeByName(currName)) {
if (findSchemeByName(currName) == null) {
name = currName;
}
}
@@ -263,7 +247,7 @@ public class CodeStyleSchemesModel {
name = null;
for (int i = 0; name == null; i++) {
String currName = i == 0 ? preferredName : preferredName + " (" + i + ")";
if (null == findSchemeByName(currName)) {
if (findSchemeByName(currName) == null) {
name = currName;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -1022,13 +1022,14 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
initFonts();
}
@NotNull
@Override
public String getName() {
return myName;
}
@Override
public void setName(String name) {
public void setName(@NotNull String name) {
myName = name;
}
@@ -104,14 +104,14 @@ public class TemplateImpl extends Template implements SchemeElement {
public TemplateImpl(@NotNull String key, String group) {
public TemplateImpl(@NotNull String key, @NotNull String group) {
this(key, null, group);
toParseSegments = false;
myTemplateText = "";
mySegments = new ArrayList<Segment>();
}
public TemplateImpl(@NotNull String key, String string, String group) {
public TemplateImpl(@NotNull String key, String string, @NotNull String group) {
myKey = key;
myString = string;
myGroupName = group;
@@ -414,7 +414,7 @@ public class TemplateImpl extends Template implements SchemeElement {
}
@Override
public void setGroupName(String groupName) {
public void setGroupName(@NotNull String groupName) {
myGroupName = groupName;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -389,7 +389,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
return null;
}
private void moveTemplates(Map<TemplateImpl, DefaultMutableTreeNode> map, String newGroupName) {
private void moveTemplates(Map<TemplateImpl, DefaultMutableTreeNode> map, @NotNull String newGroupName) {
List<TreePath> toSelect = new ArrayList<TreePath>();
for (TemplateImpl template : map.keySet()) {
DefaultMutableTreeNode oldTemplateNode = map.get(template);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -56,26 +56,26 @@ public class CodeStyleSchemeImpl implements JDOMExternalizable, CodeStyleScheme,
private volatile CodeStyleSettings myCodeStyleSettings;
private final ExternalInfo myExternalInfo = new ExternalInfo();
public CodeStyleSchemeImpl(String name, String parentSchemeName, Element rootElement) {
public CodeStyleSchemeImpl(@NotNull String name, String parentSchemeName, Element rootElement) {
myName = name;
myRootElement = rootElement;
myIsDefault = false;
myParentSchemeName = parentSchemeName;
}
public void init(CodeStyleSchemes schemesManager) {
public CodeStyleSchemeImpl(@NotNull String name, boolean isDefault, CodeStyleScheme parentScheme){
myName = name;
myIsDefault = isDefault;
init(parentScheme, null);
}
public void init(@NotNull CodeStyleSchemes schemesManager) {
LOG.assertTrue(myCodeStyleSettings == null, "Already initialized");
init(schemesManager.findSchemeByName(myParentSchemeName), myRootElement);
myParentSchemeName = null;
myRootElement = null;
}
public CodeStyleSchemeImpl(String name, boolean isDefault, CodeStyleScheme parentScheme){
myName = name;
myIsDefault = isDefault;
init(parentScheme, null);
}
private void init(CodeStyleScheme parentScheme, Element root) {
CodeStyleSettings parentSettings = parentScheme == null ? null : parentScheme.getCodeStyleSettings();
if (parentSettings == null){
@@ -107,6 +107,7 @@ public class CodeStyleSchemeImpl implements JDOMExternalizable, CodeStyleScheme,
}
@Override
@NotNull
public String getName(){
return myName;
}
@@ -169,7 +170,7 @@ public class CodeStyleSchemeImpl implements JDOMExternalizable, CodeStyleScheme,
}
@Override
public void setName(final String name) {
public void setName(@NotNull final String name) {
myName = name;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -101,11 +101,12 @@ public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements E
public CodeStyleScheme createNewScheme(String preferredName, CodeStyleScheme parentScheme) {
String name;
if (preferredName == null) {
if (parentScheme == null) throw new IllegalArgumentException("parentScheme must not be null");
// Generate using parent name
name = null;
for (int i = 1; name == null; i++) {
String currName = parentScheme.getName() + " (" + i + ")";
if (null == findSchemeByName(currName)) {
if (findSchemeByName(currName) == null) {
name = currName;
}
}
@@ -114,7 +115,7 @@ public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements E
name = null;
for (int i = 0; name == null; i++) {
String currName = i == 0 ? preferredName : preferredName + " (" + i + ")";
if (null == findSchemeByName(currName)) {
if (findSchemeByName(currName) == null) {
name = currName;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -34,13 +34,13 @@ import com.intellij.ide.macro.MacroManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.options.SchemeElement;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -48,11 +48,11 @@ import java.util.ArrayList;
import java.util.Arrays;
public class Tool implements SchemeElement {
@NonNls public final static String ACTION_ID_PREFIX = "Tool_";
@NonNls public static final String ACTION_ID_PREFIX = "Tool_";
private String myName;
private String myDescription;
private String myGroup;
@NotNull private String myGroup;
private boolean myShownInMainMenu;
private boolean myShownInEditor;
private boolean myShownInProjectViews;
@@ -81,6 +81,7 @@ public class Tool implements SchemeElement {
return myDescription;
}
@NotNull
public String getGroup() {
return myGroup;
}
@@ -133,7 +134,7 @@ public class Tool implements SchemeElement {
myDescription = description;
}
void setGroup(String group) {
void setGroup(@NotNull String group) {
myGroup = group;
}
@@ -256,10 +257,8 @@ public class Tool implements SchemeElement {
public String getActionId() {
StringBuilder name = new StringBuilder(getActionIdPrefix());
if (myGroup != null) {
name.append(myGroup);
name.append('_');
}
name.append(myGroup);
name.append('_');
if (myName != null) {
name.append(myName);
}
@@ -354,7 +353,7 @@ public class Tool implements SchemeElement {
}
@Override
public void setGroupName(final String name) {
public void setGroupName(@NotNull final String name) {
setGroup(name);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.MouseShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.options.Scheme;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
@@ -27,6 +28,8 @@ import java.util.Map;
public interface Keymap extends Scheme {
//think about name
@NotNull
@Override
String getName();
//think about name
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -52,11 +52,12 @@ public class CompoundScheme<T extends SchemeElement> implements ExternalizableSc
return Collections.unmodifiableList(new ArrayList<T>(myElements));
}
@NotNull
public String getName() {
return myName;
}
public void setName(final String name) {
public void setName(@NotNull final String name) {
myName = name;
for (T template : myElements) {
template.setGroupName(name);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -16,8 +16,10 @@
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
public interface SchemeElement {
void setGroupName(final String name);
void setGroupName(@NotNull String name);
String getKey();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -43,6 +43,7 @@ public class SaveSchemeDialog extends DialogWrapper {
return mySchemeName.getText();
}
@Override
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
@@ -65,8 +66,9 @@ public class SaveSchemeDialog extends DialogWrapper {
return panel;
}
@Override
protected void doOKAction() {
if (getSchemeName().trim().length()==0) {
if (getSchemeName().trim().isEmpty()) {
Messages.showMessageDialog(getContentPane(), ApplicationBundle.message("error.scheme.must.have.a.name"),
CommonBundle.getErrorTitle(), Messages.getErrorIcon());
return;
@@ -89,10 +91,12 @@ public class SaveSchemeDialog extends DialogWrapper {
super.doOKAction();
}
@Override
protected JComponent createCenterPanel() {
return null;
}
@Override
public JComponent getPreferredFocusedComponent() {
return mySchemeName;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -97,6 +97,7 @@ public class QuickList implements ExternalizableScheme {
@NotNull
public String getName() {
return getDisplayName();
@@ -239,7 +240,7 @@ public class QuickList implements ExternalizableScheme {
public void setName(final String newName) {
public void setName(@NotNull final String newName) {
setDisplayName(newName);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -151,6 +151,7 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
public void writeExternal(Element element) throws WriteExternalException {
}
@NotNull
@Override
public String getName() {
return myDelegate.getName();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -394,10 +394,6 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
return new Document(root);
}
public void renameScheme(final String name, final EditorColorsScheme scheme) {
scheme.setName(name);
}
@Override
public boolean shouldBeSaved(@NotNull final EditorColorsSchemeImpl scheme) {
return !(scheme instanceof ReadOnlyColorsScheme);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -317,7 +317,8 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
@NonNls private static final String ELEMENT_REMOVED_MAPPING = "removed_mapping";
@NonNls private static final String ATTRIBUTE_TYPE = "type";
public static List<Pair<FileNameMatcher, String>> readAssociations(final Element e) {
@NotNull
public static List<Pair<FileNameMatcher, String>> readAssociations(@NotNull Element e) {
ArrayList<Pair<FileNameMatcher, String>> result = new ArrayList<Pair<FileNameMatcher, String>>();
List mappings = e.getChildren(ELEMENT_MAPPING);
@@ -333,7 +334,8 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
return result;
}
public static List<Trinity<FileNameMatcher, String, Boolean>> readRemovedAssociations(final Element e) {
@NotNull
public static List<Trinity<FileNameMatcher, String, Boolean>> readRemovedAssociations(@NotNull Element e) {
ArrayList<Trinity<FileNameMatcher, String, Boolean>> result = new ArrayList<Trinity<FileNameMatcher, String, Boolean>>();
List removedMappings = e.getChildren(ELEMENT_REMOVED_MAPPING);
for (Object removedMapping : removedMappings) {
@@ -349,7 +351,7 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
return result;
}
public static Element writeMapping(final FileType type, final FileNameMatcher matcher, boolean specifyTypeName) {
public static Element writeMapping(@NotNull FileType type, final FileNameMatcher matcher, boolean specifyTypeName) {
Element mapping = new Element(ELEMENT_MAPPING);
if (matcher instanceof ExtensionFileNameMatcher) {
mapping.setAttribute(ATTRIBUTE_EXT, ((ExtensionFileNameMatcher)matcher).getExtension());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -117,15 +117,19 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
}
}
@NotNull
@Override
public String getName() {
return myName;
}
@Override
public String getPresentableName() {
return getName();
}
public void setName(String name) {
@Override
public void setName(@NotNull String name) {
myName = name;
}
@@ -184,10 +188,12 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return hashCode;
}
@Override
public Keymap getParent() {
return myParent;
}
@Override
public boolean canModify() {
return myCanModify;
}
@@ -200,6 +206,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return myParent.getShortcuts(actionId);
}
@Override
public void addShortcut(String actionId, Shortcut shortcut) {
addShortcutSilently(actionId, shortcut, true);
fireShortcutChanged(actionId);
@@ -226,6 +233,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
myMouseShortcut2ListOfIds = null;
}
@Override
public void removeAllActionShortcuts(String actionId) {
Shortcut[] allShortcuts = getShortcuts(actionId);
for (Shortcut shortcut : allShortcuts) {
@@ -233,6 +241,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
}
}
@Override
public void removeShortcut(String actionId, Shortcut shortcut) {
LinkedHashSet<Shortcut> list = myActionId2ListOfShortcuts.get(actionId);
if (list != null) {
@@ -391,6 +400,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return sortInOrderOfRegistration(ArrayUtil.toStringArray(list));
}
@Override
public String[] getActionIds(KeyStroke firstKeyStroke) {
// first, get keystrokes from own map
List<String> list = getKeystroke2ListOfIds().get(firstKeyStroke);
@@ -418,6 +428,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return sortInOrderOfRegistration(ArrayUtil.toStringArray(list));
}
@Override
public String[] getActionIds(KeyStroke firstKeyStroke, KeyStroke secondKeyStroke) {
String[] ids = getActionIds(firstKeyStroke);
ArrayList<String> actualBindings = new ArrayList<String>();
@@ -437,6 +448,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return ArrayUtil.toStringArray(actualBindings);
}
@Override
public String[] getActionIds(final Shortcut shortcut) {
if (shortcut instanceof KeyboardShortcut) {
final KeyboardShortcut kb = (KeyboardShortcut)shortcut;
@@ -460,6 +472,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
}
@Override
public String[] getActionIds(MouseShortcut shortcut) {
// first, get shortcuts from own map
List<String> list = getMouseShortcut2ListOfIds().get(shortcut);
@@ -497,6 +510,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return getKeymapManager().getBoundActions().contains(actionId);
}
@Override
public Shortcut[] getShortcuts(String actionId) {
LinkedHashSet<Shortcut> shortcuts = myActionId2ListOfShortcuts.get(actionId);
@@ -815,6 +829,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
myActionId2ListOfShortcuts.clear();
}
@Override
public String[] getActionIds() {
ArrayList<String> ids = new ArrayList<String>();
if (myParent != null) {
@@ -835,6 +850,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
}
@Override
public HashMap<String, ArrayList<KeyboardShortcut>> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
HashMap<String, ArrayList<KeyboardShortcut>> result = new HashMap<String, ArrayList<KeyboardShortcut>>();
@@ -887,10 +903,12 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
return result;
}
@Override
public void addShortcutChangeListener(Listener listener) {
myListeners.add(listener);
}
@Override
public void removeShortcutChangeListener(Listener listener) {
myListeners.remove(listener);
}
@@ -916,6 +934,7 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
}
@Override
@NotNull
public ExternalInfo getExternalInfo() {
return myExternalInfo;
@@ -600,11 +600,11 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
private static class SharedSchemeData {
@NotNull private final Document original;
private final String name;
@NotNull private final String name;
private final String user;
private final String description;
private SharedSchemeData(@NotNull Document original, String name, String user, String description) {
private SharedSchemeData(@NotNull Document original, @NotNull String name, String user, String description) {
this.original = original;
this.name = name;
this.user = user;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package com.intellij.util.text;
import com.intellij.openapi.util.Condition;
import com.intellij.util.Function;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -29,7 +30,7 @@ import java.util.Set;
public class UniqueNameGenerator implements Condition<String> {
private final Set<String> myExistingNames = new HashSet<String>();
public <T> UniqueNameGenerator(final Collection<T> elements, @Nullable Function<T, String> namer) {
public <T> UniqueNameGenerator(@NotNull Collection<T> elements, @Nullable Function<T, String> namer) {
for (final T t : elements) {
addExistingName(namer != null ? namer.fun(t) : t.toString());
}
@@ -47,10 +48,12 @@ public class UniqueNameGenerator implements Condition<String> {
return value(prefix + name + suffix);
}
@NotNull
public static String generateUniqueName(final String defaultName, final Collection<String> existingNames) {
return generateUniqueName(defaultName, "", "", existingNames);
}
@NotNull
public static String generateUniqueName(final String defaultName, final String prefix, final String suffix, final Collection<String> existingNames) {
return generateUniqueName(defaultName, prefix, suffix, new Condition<String>() {
@Override
@@ -59,15 +62,18 @@ public class UniqueNameGenerator implements Condition<String> {
}
});
}
@NotNull
public static String generateUniqueName(final String defaultName, final Condition<String> validator) {
return generateUniqueName(defaultName, "", "", validator);
}
@NotNull
public static String generateUniqueName(final String defaultName, final String prefix, final String suffix, final Condition<String> validator) {
return generateUniqueName(defaultName, prefix, suffix, "", "", validator);
}
@NotNull
public static String generateUniqueName(final String defaultName, final String prefix, final String suffix,
final String beforeNumber, final String afterNumber, final Condition<String> validator) {
final String defaultFullName = prefix + defaultName + suffix;
@@ -83,10 +89,12 @@ public class UniqueNameGenerator implements Condition<String> {
}
}
@NotNull
public String generateUniqueName(final String defaultName, final String prefix, final String suffix) {
return generateUniqueName(defaultName, prefix, suffix, "", "");
}
@NotNull
public String generateUniqueName(final String defaultName, final String prefix, final String suffix, final String beforeNumber, final String afterNumber) {
final String result = generateUniqueName(defaultName, prefix, suffix, beforeNumber, afterNumber, this);
addExistingName(result);
@@ -1,3 +1,18 @@
/*
* 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 org.jetbrains.plugins.terminal;
import com.google.common.collect.Sets;
@@ -238,6 +253,7 @@ class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvider imp
return myGlobalScheme;
}
@NotNull
@Override
public String getName() {
return getGlobal().getName();