mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -29,6 +29,8 @@ public abstract class EditorColorsManager {
|
||||
|
||||
@NonNls public static final String DEFAULT_SCHEME_NAME = "Default";
|
||||
|
||||
@NonNls public static final String COLOR_SCHEME_FILE_EXTENSION = ".icls";
|
||||
|
||||
public static EditorColorsManager getInstance() {
|
||||
return ServiceManager.getService(EditorColorsManager.class);
|
||||
}
|
||||
|
||||
+4
@@ -903,6 +903,10 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
|
||||
return null;
|
||||
}
|
||||
|
||||
public EditorColorsScheme getParentScheme() {
|
||||
return myParentScheme;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Element writeScheme() {
|
||||
|
||||
-53
@@ -20,10 +20,6 @@ import com.intellij.application.options.schemes.AbstractSchemeActions;
|
||||
import com.intellij.application.options.schemes.AbstractSchemesPanel;
|
||||
import com.intellij.application.options.schemes.SchemeNameGenerator;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.fileChooser.FileSaverDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileSaverDialog;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
@@ -31,13 +27,10 @@ import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWrapper;
|
||||
import com.intellij.psi.codeStyle.CodeStyleScheme;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
abstract class CodeStyleSchemesActions extends AbstractSchemeActions<CodeStyleScheme> {
|
||||
|
||||
private final static String SHARED_IMPORT_SOURCE = ApplicationBundle.message("import.scheme.shared");
|
||||
@@ -181,52 +174,6 @@ abstract class CodeStyleSchemesActions extends AbstractSchemeActions<CodeStyleSc
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@Override
|
||||
protected void exportScheme(@NotNull CodeStyleScheme scheme, @NotNull String exporterName) {
|
||||
SchemeExporter<CodeStyleScheme> exporter = SchemeExporterEP.getExporter(exporterName, CodeStyleScheme.class);
|
||||
if (exporter != null) {
|
||||
String ext = exporter.getExtension();
|
||||
FileSaverDialog saver =
|
||||
FileChooserFactory.getInstance()
|
||||
.createSaveFileDialog(new FileSaverDescriptor(
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.title"),
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.message"),
|
||||
ext), getSchemesPanel());
|
||||
VirtualFileWrapper target = saver.save(null, scheme.getName() + "." + ext);
|
||||
if (target != null) {
|
||||
VirtualFile targetFile = target.getVirtualFile(true);
|
||||
String message;
|
||||
MessageType messageType;
|
||||
if (targetFile != null) {
|
||||
try {
|
||||
WriteAction.run(() -> {
|
||||
OutputStream outputStream = targetFile.getOutputStream(this);
|
||||
try {
|
||||
exporter.exportScheme(scheme, outputStream);
|
||||
}
|
||||
finally {
|
||||
outputStream.close();
|
||||
}
|
||||
});
|
||||
message = ApplicationBundle
|
||||
.message("scheme.exporter.ui.code.style.exported.message", scheme.getName(), targetFile.getPresentableUrl());
|
||||
messageType = MessageType.INFO;
|
||||
}
|
||||
catch (Exception e) {
|
||||
message = ApplicationBundle.message("scheme.exporter.ui.export.failed", e.getMessage());
|
||||
messageType = MessageType.ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
message = ApplicationBundle.message("scheme.exporter.ui.cannot.write.message");
|
||||
messageType = MessageType.ERROR;
|
||||
}
|
||||
getSchemesPanel().showStatus(message, messageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CodeStyleSchemesModel getModel() {
|
||||
|
||||
+4
-9
@@ -227,7 +227,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
public boolean saveSchemeAs(@NotNull EditorColorsScheme editorScheme, @NotNull String name) {
|
||||
if (editorScheme instanceof MyColorScheme) {
|
||||
MyColorScheme scheme = (MyColorScheme)editorScheme;
|
||||
EditorColorsScheme clone = (EditorColorsScheme)scheme.getOriginalScheme().clone();
|
||||
EditorColorsScheme clone = (EditorColorsScheme)scheme.getParentScheme().clone();
|
||||
scheme.apply(clone);
|
||||
if (clone instanceof AbstractColorsScheme) {
|
||||
((AbstractColorsScheme)clone).setSaveNeeded(true);
|
||||
@@ -304,13 +304,13 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
List<EditorColorsScheme> result = new ArrayList<>(mySchemes.values().size());
|
||||
boolean activeSchemeModified = false;
|
||||
EditorColorsScheme activeOriginalScheme = mySelectedScheme.getOriginalScheme();
|
||||
EditorColorsScheme activeOriginalScheme = mySelectedScheme.getParentScheme();
|
||||
for (MyColorScheme scheme : mySchemes.values()) {
|
||||
boolean isModified = scheme.apply();
|
||||
if (isModified && !activeSchemeModified && activeOriginalScheme == scheme.getOriginalScheme()) {
|
||||
if (isModified && !activeSchemeModified && activeOriginalScheme == scheme.getParentScheme()) {
|
||||
activeSchemeModified = true;
|
||||
}
|
||||
result.add(scheme.getOriginalScheme());
|
||||
result.add(scheme.getParentScheme());
|
||||
}
|
||||
|
||||
// refresh only if scheme is not switched
|
||||
@@ -1194,11 +1194,6 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EditorColorsScheme getOriginalScheme() {
|
||||
return myParentScheme;
|
||||
}
|
||||
|
||||
public void setIsNew() {
|
||||
myIsNew = true;
|
||||
}
|
||||
|
||||
+14
-5
@@ -21,13 +21,11 @@ import com.intellij.application.options.schemes.SchemeNameGenerator;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
|
||||
import com.intellij.openapi.editor.colors.impl.EmptyColorScheme;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.options.SchemeImportException;
|
||||
import com.intellij.openapi.options.SchemeImportUtil;
|
||||
import com.intellij.openapi.options.SchemeImporter;
|
||||
import com.intellij.openapi.options.SchemeImporterEP;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.DefaultProjectFactory;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -115,7 +113,18 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions<EditorCol
|
||||
|
||||
@Override
|
||||
protected void exportScheme(@NotNull EditorColorsScheme scheme, @NotNull String exporterName) {
|
||||
// Unsupported for now.
|
||||
EditorColorsScheme schemeToExport = scheme;
|
||||
if (scheme instanceof AbstractColorsScheme) {
|
||||
EditorColorsScheme parent = ((AbstractColorsScheme)scheme).getParentScheme();
|
||||
if (!(parent instanceof DefaultColorsScheme)) {
|
||||
schemeToExport = parent;
|
||||
}
|
||||
}
|
||||
if (schemeToExport.getName().startsWith(SchemeManager.EDITABLE_COPY_PREFIX)) {
|
||||
schemeToExport = (EditorColorsScheme)schemeToExport.clone();
|
||||
schemeToExport.setName(SchemeManager.getDisplayName(schemeToExport));
|
||||
}
|
||||
super.exportScheme(schemeToExport, exporterName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.colors;
|
||||
|
||||
import com.intellij.application.options.schemes.SerializableSchemeExporter;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
|
||||
/**
|
||||
* Exports a scheme as .icls file.
|
||||
*/
|
||||
public class ColorSchemeExporter extends SerializableSchemeExporter {
|
||||
|
||||
@Override
|
||||
public String getExtension() {
|
||||
return EditorColorsManager.COLOR_SCHEME_FILE_EXTENSION.substring(1);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.colors;
|
||||
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.options.SchemeFactory;
|
||||
import com.intellij.openapi.options.SchemeImportException;
|
||||
import com.intellij.openapi.options.SchemeImportUtil;
|
||||
import com.intellij.openapi.options.SchemeImporter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Imports Intellij IDEA color scheme (.icls) to application configuration
|
||||
*/
|
||||
public class ColorSchemeImporter implements SchemeImporter<EditorColorsScheme> {
|
||||
|
||||
private final static String[] FILE_EXTENSIONS =
|
||||
new String[] {EditorColorsManager.COLOR_SCHEME_FILE_EXTENSION.substring(1)};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getSourceExtensions() {
|
||||
return FILE_EXTENSIONS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public EditorColorsScheme importScheme(@NotNull Project project,
|
||||
@NotNull VirtualFile selectedFile,
|
||||
@NotNull EditorColorsScheme currentScheme,
|
||||
@NotNull SchemeFactory<EditorColorsScheme> schemeFactory) throws SchemeImportException {
|
||||
Element root = SchemeImportUtil.loadSchemeDom(selectedFile);
|
||||
String name = getSchemeName(root);
|
||||
EditorColorsScheme scheme = schemeFactory.createNewScheme(name);
|
||||
String preferredName = scheme.getName();
|
||||
scheme.readExternal(root);
|
||||
scheme.setName(preferredName);
|
||||
return scheme;
|
||||
}
|
||||
|
||||
private static String getSchemeName(@NotNull Element root) throws SchemeImportException {
|
||||
String name = root.getAttributeValue("name");
|
||||
if (name == null) throw new SchemeImportException("Scheme 'name' attribute is missing.");
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getAdditionalImportInfo(@NotNull EditorColorsScheme scheme) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+54
-1
@@ -17,13 +17,21 @@ package com.intellij.application.options.schemes;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.fileChooser.FileSaverDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileSaverDialog;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWrapper;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -369,7 +377,52 @@ public abstract class AbstractSchemeActions<T extends Scheme> {
|
||||
* @see SchemeExporter
|
||||
* @see SchemeExporterEP
|
||||
*/
|
||||
protected abstract void exportScheme(@NotNull T scheme, @NotNull String exporterName);
|
||||
protected void exportScheme(@NotNull T scheme, @NotNull String exporterName) {
|
||||
SchemeExporter<T> exporter = SchemeExporterEP.getExporter(exporterName, getSchemeType());
|
||||
if (exporter != null) {
|
||||
String ext = exporter.getExtension();
|
||||
FileSaverDialog saver =
|
||||
FileChooserFactory.getInstance()
|
||||
.createSaveFileDialog(new FileSaverDescriptor(
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.title"),
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.message"),
|
||||
ext), getSchemesPanel());
|
||||
VirtualFileWrapper target = saver.save(null, SchemeManager.getDisplayName(scheme) + "." + ext);
|
||||
if (target != null) {
|
||||
VirtualFile targetFile = target.getVirtualFile(true);
|
||||
String message;
|
||||
MessageType messageType;
|
||||
if (targetFile != null) {
|
||||
try {
|
||||
WriteAction.run(() -> {
|
||||
OutputStream outputStream = targetFile.getOutputStream(this);
|
||||
try {
|
||||
exporter.exportScheme(scheme, outputStream);
|
||||
}
|
||||
finally {
|
||||
outputStream.close();
|
||||
}
|
||||
});
|
||||
message = ApplicationBundle
|
||||
.message("scheme.exporter.ui.scheme.exported.message",
|
||||
scheme.getName(),
|
||||
getSchemesPanel().getSchemeTypeName(),
|
||||
targetFile.getPresentableUrl());
|
||||
messageType = MessageType.INFO;
|
||||
}
|
||||
catch (Exception e) {
|
||||
message = ApplicationBundle.message("scheme.exporter.ui.export.failed", e.getMessage());
|
||||
messageType = MessageType.ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
message = ApplicationBundle.message("scheme.exporter.ui.cannot.write.message");
|
||||
messageType = MessageType.ERROR;
|
||||
}
|
||||
getSchemesPanel().showStatus(message, messageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make necessary configurable updates when another scheme has been selected.
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.options.SchemeFactory;
|
||||
import com.intellij.openapi.options.SchemeImportException;
|
||||
import com.intellij.openapi.options.SchemeImportUtil;
|
||||
import com.intellij.openapi.options.SchemeImporter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -49,7 +50,7 @@ public class CodeStyleSchemeXmlImporter extends CodeStyleSettingsLoader implemen
|
||||
@NotNull VirtualFile selectedFile,
|
||||
@NotNull CodeStyleScheme currentScheme,
|
||||
@NotNull SchemeFactory<CodeStyleScheme> schemeFactory) throws SchemeImportException {
|
||||
Element rootElement = loadSchemeDom(selectedFile);
|
||||
Element rootElement = SchemeImportUtil.loadSchemeDom(selectedFile);
|
||||
Element schemeRoot = getSchemeRoot(rootElement);
|
||||
final Pair<String, CodeStyleScheme> importPair =
|
||||
!ApplicationManager.getApplication().isUnitTestMode() ?
|
||||
|
||||
+2
-36
@@ -17,56 +17,22 @@ package com.intellij.psi.impl.source.codeStyle;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.options.SchemeImportException;
|
||||
import com.intellij.openapi.options.SchemeImportUtil;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class CodeStyleSettingsLoader {
|
||||
|
||||
public CodeStyleSettings loadSettings(@NotNull VirtualFile file) throws SchemeImportException {
|
||||
Element rootElement = loadSchemeDom(file);
|
||||
Element rootElement = SchemeImportUtil.loadSchemeDom(file);
|
||||
CodeStyleSettings settings = new CodeStyleSettings();
|
||||
loadSettings(rootElement, settings);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Element loadSchemeDom(@NotNull VirtualFile file) throws SchemeImportException {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
final Document document = JDOMUtil.loadDocument(inputStream);
|
||||
final Element root = document.getRootElement();
|
||||
inputStream.close();
|
||||
return root;
|
||||
}
|
||||
catch (IOException | JDOMException e) {
|
||||
throw new SchemeImportException(getErrorMessage(e, file));
|
||||
}
|
||||
finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getErrorMessage(@NotNull Exception e, @NotNull VirtualFile file) {
|
||||
return "Can't read from" + file.getName() + ", " + e.getMessage();
|
||||
}
|
||||
|
||||
protected void loadSettings(@NotNull Element rootElement, @NotNull CodeStyleSettings settings) throws SchemeImportException {
|
||||
try {
|
||||
settings.readExternal(rootElement);
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers
|
||||
@NonNls
|
||||
@Override
|
||||
public String getSchemeExtension() {
|
||||
return ".icls";
|
||||
return COLOR_SCHEME_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,11 +19,17 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDialog;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.fileChooser.FileElement;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -67,5 +73,30 @@ public class SchemeImportUtil {
|
||||
virtualFiles[0].refresh(false, false);
|
||||
return virtualFiles[0];
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static Element loadSchemeDom(@NotNull VirtualFile file) throws SchemeImportException {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
final Document document = JDOMUtil.loadDocument(inputStream);
|
||||
final Element root = document.getRootElement();
|
||||
inputStream.close();
|
||||
return root;
|
||||
}
|
||||
catch (IOException | JDOMException e) {
|
||||
throw new SchemeImportException("Can't read from" + file.getName() + ", " + e.getMessage());
|
||||
}
|
||||
finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ message.code.style.scheme.import.failure={0} import failed with error message: {
|
||||
scheme.exporter.ui.export.as.title=Export As
|
||||
scheme.exporter.ui.file.chooser.title=Target File
|
||||
scheme.exporter.ui.file.chooser.message=Export to
|
||||
scheme.exporter.ui.code.style.exported.message={0} code style scheme was exported to {1}
|
||||
scheme.exporter.ui.scheme.exported.message={0} {1} was exported to {2}
|
||||
scheme.exporter.ui.cannot.write.message=Cannot write to selected file/location.
|
||||
scheme.exporter.ui.export.failed=Export failed: {0}
|
||||
|
||||
|
||||
@@ -984,10 +984,18 @@
|
||||
name="Intellij IDEA code style XML"
|
||||
schemeClass="com.intellij.psi.codeStyle.CodeStyleScheme"
|
||||
implementationClass="com.intellij.application.options.schemes.SerializableSchemeExporter"/>
|
||||
<schemeExporter
|
||||
name="Intellij IDEA color scheme (.icls)"
|
||||
schemeClass="com.intellij.openapi.editor.colors.EditorColorsScheme"
|
||||
implementationClass="com.intellij.application.options.colors.ColorSchemeExporter"/>
|
||||
<schemeImporter
|
||||
name="Intellij IDEA code style XML"
|
||||
schemeClass="com.intellij.psi.codeStyle.CodeStyleScheme"
|
||||
implementationClass="com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeXmlImporter"/>
|
||||
<schemeImporter
|
||||
name="Intellij IDEA color scheme (.icls)"
|
||||
schemeClass="com.intellij.openapi.editor.colors.EditorColorsScheme"
|
||||
implementationClass="com.intellij.application.options.colors.ColorSchemeImporter"/>
|
||||
|
||||
<schemeExporter
|
||||
name="Intellij IDEA inspection profile XML"
|
||||
|
||||
+7
-4
@@ -41,7 +41,8 @@ import static java.awt.GridBagConstraints.NONE;
|
||||
import static java.awt.GridBagConstraints.NORTHWEST;
|
||||
|
||||
public class ShelfProjectConfigurationPanel extends JPanel {
|
||||
@NotNull private static final String CURRENT_LOCATION_HINT = "Current location: ";
|
||||
@NotNull private static final String CURRENT_LOCATION_HINT = "Current location is ";
|
||||
@NotNull private static final String DEFAULT_LOCATION_HINT = "Default location is ";
|
||||
@NotNull private final VcsConfiguration myVcsConfiguration;
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final JBCheckBox myBaseRevisionTexts;
|
||||
@@ -73,6 +74,7 @@ public class ShelfProjectConfigurationPanel extends JPanel {
|
||||
|
||||
JPanel shelfConfigurablePanel = new JPanel(new BorderLayout(DEFAULT_HGAP, DEFAULT_VGAP));
|
||||
JButton shelfConfigurableButton = new JButton("Change Shelves Location");
|
||||
shelfConfigurableButton.setEnabled(!myProject.isDefault());
|
||||
shelfConfigurableButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -89,10 +91,11 @@ public class ShelfProjectConfigurationPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void updateLabelInfo() {
|
||||
myInfoLabel.setText(CURRENT_LOCATION_HINT + (myVcsConfiguration.USE_CUSTOM_SHELF_PATH ? toSystemDependentName(
|
||||
assertNotNull(myVcsConfiguration.CUSTOM_SHELF_PATH)) : getDefaultShelfPresentationPath(myProject)));
|
||||
myInfoLabel.setText((myProject.isDefault() ? DEFAULT_LOCATION_HINT : CURRENT_LOCATION_HINT) +
|
||||
(myVcsConfiguration.USE_CUSTOM_SHELF_PATH ? toSystemDependentName(
|
||||
assertNotNull(myVcsConfiguration.CUSTOM_SHELF_PATH)) : getDefaultShelfPresentationPath(myProject)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* System dependent path to default shelf dir
|
||||
*/
|
||||
|
||||
+13
-15
@@ -69,6 +69,9 @@ public class ShelfStorageConfigurationDialog extends DialogWrapper {
|
||||
myMoveShelvesCheckBox = new JBCheckBox(VcsBundle.message("vcs.shelf.move.text"));
|
||||
setOKButtonText("_Change Location");
|
||||
initComponents();
|
||||
updateOkAction();
|
||||
getOKAction().putValue(DEFAULT_ACTION, null);
|
||||
getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE);
|
||||
init();
|
||||
initValidation();
|
||||
}
|
||||
@@ -87,7 +90,8 @@ public class ShelfStorageConfigurationDialog extends DialogWrapper {
|
||||
myUseCustomShelfDirectory.setSelected(myVcsConfiguration.USE_CUSTOM_SHELF_PATH);
|
||||
myMoveShelvesCheckBox.setSelected(myVcsConfiguration.MOVE_SHELVES);
|
||||
myShelfDirectoryPath
|
||||
.setText(FileUtil.toSystemDependentName(chooseNotNull(myVcsConfiguration.CUSTOM_SHELF_PATH, getDefaultShelfPresentationPath(myProject))));
|
||||
.setText(
|
||||
FileUtil.toSystemDependentName(chooseNotNull(myVcsConfiguration.CUSTOM_SHELF_PATH, getDefaultShelfPresentationPath(myProject))));
|
||||
setEnabledCustomShelfDirectoryComponents(myUseCustomShelfDirectory.isSelected());
|
||||
myUseCustomShelfDirectory.addChangeListener(e -> setEnabledCustomShelfDirectoryComponents(myUseCustomShelfDirectory.isSelected()));
|
||||
}
|
||||
@@ -95,9 +99,6 @@ public class ShelfStorageConfigurationDialog extends DialogWrapper {
|
||||
private void setEnabledCustomShelfDirectoryComponents(boolean enabled) {
|
||||
myShelfDirectoryPath.setEnabled(enabled);
|
||||
myShelfDirectoryPath.setEditable(enabled);
|
||||
if (enabled && myProject.isDefault() && myVcsConfiguration.CUSTOM_SHELF_PATH == null) {
|
||||
myShelfDirectoryPath.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -162,17 +163,15 @@ public class ShelfStorageConfigurationDialog extends DialogWrapper {
|
||||
myVcsConfiguration.USE_CUSTOM_SHELF_PATH = nowCustom;
|
||||
myVcsConfiguration.CUSTOM_SHELF_PATH = customPath;
|
||||
myVcsConfiguration.MOVE_SHELVES = myMoveShelvesCheckBox.isSelected();
|
||||
if (!myProject.isDefault()) {
|
||||
File fromFile = new File(wasCustom ? prevPath : getDefaultShelfPath(myProject));
|
||||
File toFile = new File(nowCustom ? customPath : getDefaultShelfPath(myProject));
|
||||
|
||||
if (!FileUtil.filesEqual(fromFile, toFile)) {
|
||||
myProject.save();
|
||||
if (wasCustom) {
|
||||
ApplicationManager.getApplication().saveSettings();
|
||||
}
|
||||
ShelveChangesManager.getInstance(myProject).checkAndMigrateUnderProgress(fromFile, toFile, wasCustom);
|
||||
File fromFile = new File(wasCustom ? prevPath : getDefaultShelfPath(myProject));
|
||||
File toFile = new File(nowCustom ? customPath : getDefaultShelfPath(myProject));
|
||||
|
||||
if (!FileUtil.filesEqual(fromFile, toFile)) {
|
||||
myProject.save();
|
||||
if (wasCustom) {
|
||||
ApplicationManager.getApplication().saveSettings();
|
||||
}
|
||||
ShelveChangesManager.getInstance(myProject).checkAndMigrateUnderProgress(fromFile, toFile, wasCustom);
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
@@ -214,7 +213,6 @@ public class ShelfStorageConfigurationDialog extends DialogWrapper {
|
||||
|
||||
private boolean isModified() {
|
||||
if (myVcsConfiguration.USE_CUSTOM_SHELF_PATH != myUseCustomShelfDirectory.isSelected()) return true;
|
||||
if (myVcsConfiguration.MOVE_SHELVES != myMoveShelvesCheckBox.isSelected()) return true;
|
||||
return myUseCustomShelfDirectory.isSelected() &&
|
||||
!StringUtil.equals(myVcsConfiguration.CUSTOM_SHELF_PATH, myShelfDirectoryPath.getText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user