mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract resource bundle editor module
GitOrigin-RevId: 95d85a367f102c601ce6b80e99d00c71c4077f87
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b9cef22caa
commit
44a4d4dc17
Generated
+1
@@ -701,6 +701,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/properties/intellij.properties.iml" filepath="$PROJECT_DIR$/plugins/properties/intellij.properties.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties-psi-api/intellij.properties.psi.iml" filepath="$PROJECT_DIR$/plugins/properties/properties-psi-api/intellij.properties.psi.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties-psi-impl/intellij.properties.psi.impl.iml" filepath="$PROJECT_DIR$/plugins/properties/properties-psi-impl/intellij.properties.psi.impl.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties-resource-bundle-editor/intellij.properties.resource.bundle.editor.iml" filepath="$PROJECT_DIR$/plugins/properties/properties-resource-bundle-editor/intellij.properties.resource.bundle.editor.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/python/intellij.pycharm.community.iml" filepath="$PROJECT_DIR$/python/intellij.pycharm.community.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/python/build/intellij.pycharm.community.build.iml" filepath="$PROJECT_DIR$/python/build/intellij.pycharm.community.build.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/python/build/build-debug-binaries/intellij.pycharm.community.build.debugBinaries.iml" filepath="$PROJECT_DIR$/python/build/build-debug-binaries/intellij.pycharm.community.build.debugBinaries.iml" />
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
<orderEntry type="module" module-name="intellij.relaxng" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.java" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.remoteServers.impl" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.properties.resource.bundle.editor" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.xml.dom.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.colorSchemes" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.javaFX.community" scope="RUNTIME" />
|
||||
|
||||
+1
@@ -100,6 +100,7 @@ class CommunityRepositoryModules {
|
||||
plugin("intellij.properties") {
|
||||
withModule("intellij.properties.psi", "properties.jar")
|
||||
withModule("intellij.properties.psi.impl", "properties.jar")
|
||||
withModule("intellij.properties.resource.bundle.editor", "properties.jar")
|
||||
},
|
||||
plugin("intellij.vcs.git") {
|
||||
withModule("intellij.vcs.git.rt", "git4idea-rt.jar", null)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<orderEntry type="module" module-name="intellij.xml.impl" />
|
||||
<orderEntry type="module" module-name="intellij.properties.psi" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.properties.psi.impl" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.properties.resource.bundle.editor" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.java.testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.boot" scope="TEST" />
|
||||
|
||||
+10
-25
@@ -1,18 +1,14 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.util.gotoByName.GotoFileCellRenderer;
|
||||
import com.intellij.lang.properties.ResourceBundle;
|
||||
import com.intellij.lang.properties.*;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -96,9 +92,9 @@ public class PropertiesCopyHandler extends CopyHandlerDelegateBase {
|
||||
public void doClone(PsiElement element) {
|
||||
}
|
||||
|
||||
private static void copyPropertyToAnotherBundle(@NotNull Collection<? extends IProperty> properties,
|
||||
@NotNull final String newName,
|
||||
@NotNull ResourceBundle targetResourceBundle) {
|
||||
private void copyPropertyToAnotherBundle(@NotNull Collection<? extends IProperty> properties,
|
||||
@NotNull final String newName,
|
||||
@NotNull ResourceBundle targetResourceBundle) {
|
||||
final Map<IProperty, PropertiesFile> propertiesFileMapping = new HashMap<>();
|
||||
for (IProperty property : properties) {
|
||||
final PropertiesFile containingFile = property.getPropertiesFile();
|
||||
@@ -130,26 +126,15 @@ public class PropertiesCopyHandler extends CopyHandlerDelegateBase {
|
||||
final IProperty representativeFromSourceBundle = ContainerUtil.getFirstItem(properties);
|
||||
LOG.assertTrue(representativeFromSourceBundle != null);
|
||||
final ResourceBundle sourceResourceBundle = representativeFromSourceBundle.getPropertiesFile().getResourceBundle();
|
||||
if (sourceResourceBundle.equals(targetResourceBundle)) {
|
||||
DataManager.getInstance()
|
||||
.getDataContextFromFocusAsync()
|
||||
.onSuccess(context -> {
|
||||
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
|
||||
if (fileEditor instanceof ResourceBundleEditor) {
|
||||
final ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)fileEditor;
|
||||
resourceBundleEditor.updateTreeRoot();
|
||||
resourceBundleEditor.selectProperty(newName);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (FileEditor editor : FileEditorManager.getInstance(project).openFile(new ResourceBundleAsVirtualFile(targetResourceBundle), true)) {
|
||||
((ResourceBundleEditor) editor).updateTreeRoot();
|
||||
((ResourceBundleEditor) editor).selectProperty(newName);
|
||||
}
|
||||
}
|
||||
updateBundleEditors(newName, targetResourceBundle, sourceResourceBundle, project);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateBundleEditors(@NotNull String newName,
|
||||
@NotNull ResourceBundle targetResourceBundle,
|
||||
@NotNull ResourceBundle sourceResourceBundle,
|
||||
@NotNull Project project) { }
|
||||
|
||||
@Nullable
|
||||
private static PropertiesFile findWithMatchedSuffix(@NotNull PropertiesFile searchFile, @NotNull ResourceBundle resourceBundle) {
|
||||
final String targetSuffix = getPropertiesFileSuffix(searchFile, searchFile.getResourceBundle().getBaseName());
|
||||
+5
-3
@@ -1,11 +1,13 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.structureView.newStructureView.StructureViewComponent;
|
||||
import com.intellij.lang.properties.PropertiesBundle;
|
||||
import com.intellij.lang.properties.structureView.GroupByWordPrefixes;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
+13
-1
@@ -26,7 +26,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class PropertyStructureViewElement implements StructureViewTreeElement {
|
||||
public class PropertyStructureViewElement implements StructureViewTreeElement, ResourceBundleEditorViewElement {
|
||||
private static final TextAttributesKey GROUP_KEY;
|
||||
|
||||
public static final String PROPERTY_GROUP_KEY_TEXT = "<property>";
|
||||
@@ -60,6 +60,18 @@ public class PropertyStructureViewElement implements StructureViewTreeElement {
|
||||
return element.isValid() ? element : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IProperty[] getProperties() {
|
||||
return new IProperty[] {myProperty};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiFile[] getFiles() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPresentableName(final String presentableName) {
|
||||
myPresentableName = presentableName;
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="intellij.properties.psi.impl" />
|
||||
<orderEntry type="module" module-name="intellij.xml.psi" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.PropertiesBundle;
|
||||
@@ -22,11 +21,9 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.properties.ResourceBundle;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PropertiesCopyHandlerEx extends PropertiesCopyHandler {
|
||||
@Override
|
||||
protected void updateBundleEditors(@NotNull String newName,
|
||||
@NotNull ResourceBundle targetResourceBundle,
|
||||
@NotNull ResourceBundle sourceResourceBundle,
|
||||
@NotNull Project project) {
|
||||
if (sourceResourceBundle.equals(targetResourceBundle)) {
|
||||
DataManager.getInstance()
|
||||
.getDataContextFromFocusAsync()
|
||||
.onSuccess(context -> {
|
||||
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
|
||||
if (fileEditor instanceof ResourceBundleEditor) {
|
||||
final ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)fileEditor;
|
||||
resourceBundleEditor.updateTreeRoot();
|
||||
resourceBundleEditor.selectProperty(newName);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (FileEditor editor : FileEditorManager.getInstance(project).openFile(new ResourceBundleAsVirtualFile(targetResourceBundle), true)) {
|
||||
((ResourceBundleEditor) editor).updateTreeRoot();
|
||||
((ResourceBundleEditor) editor).selectProperty(newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-2
@@ -10,8 +10,6 @@ import com.intellij.openapi.fileEditor.FileEditorPolicy;
|
||||
import com.intellij.openapi.fileEditor.FileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.FileEditorState;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeConsumer;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
+16
-1
@@ -20,7 +20,7 @@ import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class ResourceBundleFileStructureViewElement implements StructureViewTreeElement {
|
||||
public class ResourceBundleFileStructureViewElement implements StructureViewTreeElement, ResourceBundleEditorViewElement {
|
||||
@NotNull
|
||||
private final ResourceBundle myResourceBundle;
|
||||
@NotNull
|
||||
@@ -129,6 +129,21 @@ public class ResourceBundleFileStructureViewElement implements StructureViewTree
|
||||
return propertyNames;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IProperty[] getProperties() {
|
||||
return IProperty.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiFile[] getFiles() {
|
||||
ResourceBundle rb = getValue();
|
||||
if (rb == null) return null;
|
||||
final List<PropertiesFile> files = rb.getPropertiesFiles();
|
||||
return ContainerUtil.map2Array(files, new PsiFile[files.size()], propertiesFile -> propertiesFile.getContainingFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ItemPresentation getPresentation() {
|
||||
+1
-1
@@ -21,8 +21,8 @@ import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.QuickFix;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileModifiableModelKt;
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool;
|
||||
import com.intellij.lang.properties.*;
|
||||
import com.intellij.lang.properties.ResourceBundle;
|
||||
import com.intellij.lang.properties.*;
|
||||
import com.intellij.lang.properties.editor.inspections.ResourceBundleEditorInspection;
|
||||
import com.intellij.lang.properties.editor.inspections.ResourceBundleEditorProblemDescriptor;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
@@ -116,7 +116,7 @@
|
||||
<langCodeStyleSettingsProvider implementation="com.intellij.lang.properties.psi.codeStyle.PropertiesLanguageCodeStyleSettingsProvider"/>
|
||||
|
||||
<internalFileTemplate name="XML Properties File.xml"/>
|
||||
<refactoring.copyHandler implementation="com.intellij.lang.properties.editor.PropertiesCopyHandler"/>
|
||||
<refactoring.copyHandler implementation="com.intellij.lang.properties.editor.PropertiesCopyHandlerEx"/>
|
||||
<lang.formatter language="Properties" implementationClass="com.intellij.lang.properties.formatting.PropertiesFormattingModelBuilder"/>
|
||||
|
||||
<definitionsScopedSearch implementation="com.intellij.lang.properties.editor.PropertiesInheritorsSearcher"/>
|
||||
|
||||
Reference in New Issue
Block a user