summaryrefslogtreecommitdiff
path: root/plugins/properties
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/properties')
-rw-r--r--plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties5
-rw-r--r--plugins/properties/properties-psi-impl/properties-psi-impl.iml2
-rw-r--r--plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java8
-rw-r--r--plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java2
-rw-r--r--plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java5
-rw-r--r--plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java13
-rw-r--r--plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java18
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java2
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java (renamed from plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java)0
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java62
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java18
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java (renamed from plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java)0
-rw-r--r--plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleFromEditorRenameHandler.java2
13 files changed, 86 insertions, 51 deletions
diff --git a/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties b/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties
index 06e0c2e3ae03..61b69161c5e3 100644
--- a/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties
+++ b/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties
@@ -50,4 +50,7 @@ new.property.dialog.name.prompt.text=Enter new property key name
resource.bundle.renamer=Rename resource bundle properties files
resource.bundle.renamer.dialog.description=Rename resource bundle properties files with the following names to:
resource.bundle.renamer.entity.name=Resource bundle
-resource.bundle.renamer.option=Rename bound &resource bundle \ No newline at end of file
+resource.bundle.renamer.option=Rename bound &resource bundle
+
+inline.property.refactoring=Inline Property
+inline.property.confirmation=Inline property ''{0}'' with value ''{1}''?
diff --git a/plugins/properties/properties-psi-impl/properties-psi-impl.iml b/plugins/properties/properties-psi-impl/properties-psi-impl.iml
index 76596cc333fe..d297116cb114 100644
--- a/plugins/properties/properties-psi-impl/properties-psi-impl.iml
+++ b/plugins/properties/properties-psi-impl/properties-psi-impl.iml
@@ -14,8 +14,8 @@
<orderEntry type="module" module-name="xml-psi-api" />
<orderEntry type="module" module-name="xml-psi-impl" />
<orderEntry type="module" module-name="indexing-impl" />
- <orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="structure-view-impl" />
+ <orderEntry type="module" module-name="analysis-impl" />
</component>
</module>
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java
index 8f5084b87391..f667b1a93da0 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java
+++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java
@@ -61,7 +61,13 @@ public class PropertiesImplUtil extends PropertiesUtil {
@Nullable
private static ResourceBundle getResourceBundle(@NotNull final String baseName, @NotNull final PsiDirectory baseDirectory) {
PropertiesFile defaultPropertiesFile = null;
- for (final PsiFile psiFile : baseDirectory.getFiles()) {
+ final PsiFile[] files = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
+ @Override
+ public PsiFile[] compute() {
+ return baseDirectory.getFiles();
+ }
+ });
+ for (final PsiFile psiFile : files) {
if (baseName.equals(getBaseName(psiFile))) {
final PropertiesFile propertiesFile = getPropertiesFile(psiFile);
if (propertiesFile != null) {
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java
index 58932d1fd4c5..8a8d3b0390d4 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java
+++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java
@@ -16,9 +16,7 @@
package com.intellij.lang.properties.editor;
-import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Batkovich
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java
index ed660536d052..724a794ca3bb 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java
+++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java
@@ -24,6 +24,7 @@ import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.PropertiesHighlighter;
import com.intellij.lang.properties.PropertiesUtil;
import com.intellij.lang.properties.ResourceBundle;
+import com.intellij.lang.properties.psi.Property;
import com.intellij.navigation.ColoredItemPresentation;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.editor.colors.EditorColorsManager;
@@ -69,8 +70,8 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
}
@Override
- public String getValue() {
- return myProperty.getName();
+ public Property getValue() {
+ return (Property)myProperty.getPsiElement();
}
@Override
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java
index b67f6bfbea3f..efdbeaf3e863 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java
+++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java
@@ -16,6 +16,7 @@
package com.intellij.lang.properties.structureView;
import com.intellij.icons.AllIcons;
+import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.smartTree.*;
import com.intellij.lang.properties.IProperty;
@@ -65,14 +66,14 @@ public class GroupByWordPrefixes implements Grouper, Sorter {
parentPrefixLength = 0;
}
for (TreeElement element : children) {
- String text = null;
- if (element instanceof PropertiesStructureViewElement) {
- IProperty property = ((PropertiesStructureViewElement)element).getValue();
- text = property.getUnescapedKey();
+ if (!(element instanceof StructureViewTreeElement)) {
+ continue;
}
- else if (element instanceof ResourceBundlePropertyStructureViewElement) {
- text = ((ResourceBundlePropertyStructureViewElement)element).getValue();
+ final Object value = ((StructureViewTreeElement)element).getValue();
+ if (!(value instanceof IProperty)) {
+ continue;
}
+ final String text = ((IProperty) value).getUnescapedKey();
if (text == null) continue;
LOG.assertTrue(text.startsWith(parentPrefix) || text.startsWith(mySeparator));
List<String> words = StringUtil.split(text, mySeparator);
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java
index 61b3c0202619..c4958502c25a 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java
+++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java
@@ -16,11 +16,13 @@
package com.intellij.lang.properties.structureView;
import com.intellij.icons.AllIcons;
+import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.util.treeView.smartTree.Group;
import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.editor.ResourceBundleEditorViewElement;
import com.intellij.lang.properties.editor.ResourceBundlePropertyStructureViewElement;
+import com.intellij.lang.properties.psi.Property;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
@@ -90,20 +92,14 @@ public class PropertiesPrefixGroup implements Group, ResourceBundleEditorViewEle
Collection<TreeElement> result = new ArrayList<TreeElement>();
List<String> prefixWords = StringUtil.split(myPrefix, mySeparator);
for (TreeElement treeElement : myProperties) {
- String key;
- if (treeElement instanceof PropertiesStructureViewElement) {
- PropertiesStructureViewElement propertiesElement = (PropertiesStructureViewElement)treeElement;
- IProperty property = propertiesElement.getValue();
-
- key = property.getUnescapedKey();
- }
- else if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
- key = ((ResourceBundlePropertyStructureViewElement)treeElement).getValue();
+ if (!(treeElement instanceof StructureViewTreeElement)) {
+ continue;
}
- else {
+ final Object value = ((StructureViewTreeElement)treeElement).getValue();
+ if (!(value instanceof IProperty)) {
continue;
}
-
+ final String key = ((IProperty) value).getUnescapedKey();
if (key == null || key.equals(myPrefix)) {
continue;
}
diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java b/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java
index d25b780bd769..2218b7598884 100644
--- a/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java
@@ -60,7 +60,7 @@ class NewPropertyAction extends AnAction {
prefix = null;
separator = null;
} else {
- final ResourceBundleEditorViewElement selectedElement = resourceBundleEditor.getSelectedElement();
+ final ResourceBundleEditorViewElement selectedElement = resourceBundleEditor.getSelectedElementIfOnlyOne();
if (selectedElement == null) {
return;
}
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java
index 36915e7e6962..36915e7e6962 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java
diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
index e9eb9e9f72d2..39e9ed67e7b2 100644
--- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
@@ -57,7 +57,10 @@ import com.intellij.ui.JBColor;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.Alarm;
+import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.NullableFunction;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.Stack;
import com.intellij.util.ui.UIUtil;
@@ -129,7 +132,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
@Override
public void valueChanged(TreeSelectionEvent e) {
// filter out temp unselect/select events
- if (getSelectedProperty() == null) return;
+ if (Comparing.equal(e.getNewLeadSelectionPath(), e.getOldLeadSelectionPath()) || getSelectedProperty() == null) return;
if (!arePropertiesEquivalent(selectedProperty, getSelectedProperty()) ||
!Comparing.equal(selectedPropertiesFile, getSelectedPropertiesFile())) {
@@ -167,7 +170,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
TreeElement[] children = myStructureViewComponent.getTreeModel().getRoot().getChildren();
if (children.length != 0) {
TreeElement child = children[0];
- String propName = ((ResourceBundlePropertyStructureViewElement)child).getValue();
+ String propName = ((ResourceBundlePropertyStructureViewElement)child).getValue().getUnescapedKey();
setState(new ResourceBundleEditorState(propName));
}
myDataProviderPanel = new DataProviderPanel(splitPanel);
@@ -245,7 +248,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
DefaultMutableTreeNode node = toCheck.pop();
final ResourceBundleEditorViewElement element = getSelectedElement(node);
String value = element instanceof ResourceBundlePropertyStructureViewElement
- ? ((ResourceBundlePropertyStructureViewElement)element).getValue()
+ ? ((ResourceBundlePropertyStructureViewElement)element).getValue().getUnescapedKey()
: null;
if (propertyName.equals(value)) {
nodeToSelect = node;
@@ -570,13 +573,21 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
document.replaceString(0, document.getTextLength(), text);
}
- @Nullable
- private DefaultMutableTreeNode getSelectedNode() {
+ @NotNull
+ private Collection<DefaultMutableTreeNode> getSelectedNodes() {
+ if (!isValid()) {
+ return Collections.emptyList();
+ }
JTree tree = myStructureViewComponent.getTree();
- if (tree == null) return null;
- TreePath selected = tree.getSelectionModel().getSelectionPath();
- if (selected == null) return null;
- return (DefaultMutableTreeNode)selected.getLastPathComponent();
+ if (tree == null) return Collections.emptyList();
+ TreePath[] selected = tree.getSelectionModel().getSelectionPaths();
+ if (selected == null || selected.length == 0) return Collections.emptyList();
+ return ContainerUtil.map(selected, new Function<TreePath, DefaultMutableTreeNode>() {
+ @Override
+ public DefaultMutableTreeNode fun(TreePath treePath) {
+ return (DefaultMutableTreeNode)treePath.getLastPathComponent();
+ }
+ });
}
@Nullable
@@ -587,25 +598,34 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
@Nullable
private IProperty getSelectedProperty() {
- final DefaultMutableTreeNode selectedNode = getSelectedNode();
- if (selectedNode == null) {
+ final Collection<DefaultMutableTreeNode> selectedNode = getSelectedNodes();
+ if (selectedNode.isEmpty()) {
return null;
}
- final ResourceBundleEditorViewElement element = getSelectedElement(selectedNode);
+ final ResourceBundleEditorViewElement element = getSelectedElement(ContainerUtil.getFirstItem(selectedNode));
return element instanceof ResourceBundlePropertyStructureViewElement ? ((ResourceBundlePropertyStructureViewElement)element).getProperty()
: null;
}
+ @NotNull
+ public Collection<ResourceBundleEditorViewElement> getSelectedElements() {
+ final Collection<DefaultMutableTreeNode> selectedNodes = getSelectedNodes();
+ return ContainerUtil.mapNotNull(selectedNodes, new NullableFunction<DefaultMutableTreeNode, ResourceBundleEditorViewElement>() {
+ @Nullable
+ @Override
+ public ResourceBundleEditorViewElement fun(DefaultMutableTreeNode selectedNode) {
+ Object userObject = selectedNode.getUserObject();
+ if (!(userObject instanceof AbstractTreeNode)) return null;
+ Object value = ((AbstractTreeNode)userObject).getValue();
+ return value instanceof ResourceBundleEditorViewElement ? (ResourceBundleEditorViewElement) value : null;
+ }
+ });
+ }
+
@Nullable
- public ResourceBundleEditorViewElement getSelectedElement() {
- final DefaultMutableTreeNode selectedNode = getSelectedNode();
- if (selectedNode == null) {
- return null;
- }
- Object userObject = selectedNode.getUserObject();
- if (!(userObject instanceof AbstractTreeNode)) return null;
- Object value = ((AbstractTreeNode)userObject).getValue();
- return value instanceof ResourceBundleEditorViewElement ? (ResourceBundleEditorViewElement) value : null;
+ public ResourceBundleEditorViewElement getSelectedElementIfOnlyOne() {
+ final Collection<ResourceBundleEditorViewElement> selectedElements = getSelectedElements();
+ return selectedElements.size() == 1 ? ContainerUtil.getFirstItem(selectedElements) : null;
}
@Override
diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java
index 0985f35a5e12..da376abe05b2 100644
--- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java
@@ -25,7 +25,6 @@ import com.intellij.lang.properties.psi.Property;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ide.CopyPasteManager;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
@@ -34,10 +33,13 @@ import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
import com.intellij.ui.PopupHandler;
import com.intellij.usages.UsageTarget;
import com.intellij.usages.UsageView;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.datatransfer.StringSelection;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
/**
@@ -74,9 +76,17 @@ class ResourceBundleStructureViewComponent extends PropertiesGroupingStructureVi
} else if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return getFileEditor();
} else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
- final ResourceBundleEditorViewElement selectedElement = ((ResourceBundleEditor)getFileEditor()).getSelectedElement();
- if (selectedElement != null) {
- return selectedElement.getPsiElements();
+ final Collection<ResourceBundleEditorViewElement> selectedElements = ((ResourceBundleEditor)getFileEditor()).getSelectedElements();
+ if (selectedElements.isEmpty()) {
+ return null;
+ } else if (selectedElements.size() == 1) {
+ return ContainerUtil.getFirstItem(selectedElements).getPsiElements();
+ } else {
+ final List<PsiElement> psiElements = new ArrayList<PsiElement>();
+ for (ResourceBundleEditorViewElement selectedElement : selectedElements) {
+ Collections.addAll(psiElements, selectedElement.getPsiElements());
+ }
+ return psiElements.toArray(new PsiElement[psiElements.size()]);
}
} else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
final PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(this);
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java
index e4a35e7e677c..e4a35e7e677c 100644
--- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java
diff --git a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleFromEditorRenameHandler.java b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleFromEditorRenameHandler.java
index 0c04bec80620..e105195cb9b3 100644
--- a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleFromEditorRenameHandler.java
+++ b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleFromEditorRenameHandler.java
@@ -74,7 +74,7 @@ public class ResourceBundleFromEditorRenameHandler implements RenameHandler {
public void invoke(final @NotNull Project project, Editor editor, final PsiFile file, DataContext dataContext) {
final ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)PlatformDataKeys.FILE_EDITOR.getData(dataContext);
assert resourceBundleEditor != null;
- final ResourceBundleEditorViewElement selectedElement = resourceBundleEditor.getSelectedElement();
+ final ResourceBundleEditorViewElement selectedElement = resourceBundleEditor.getSelectedElementIfOnlyOne();
if (selectedElement != null) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override