mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert "terminal: show default path for empty fields (shell path and starting directory)"
This reverts commit 9eef326c
Reason: https://buildserver.labs.intellij.net/viewLog.html?buildId=40998261&buildTypeId=ijplatform_master_Idea_Installers&tab=buildLog&branch_ijplatform_master_Idea=%3Cdefault%3E&state=&expand=all&_focus=918#_state=
This commit is contained in:
@@ -126,7 +126,7 @@ class TerminalOptionsProvider : PersistentStateComponent<TerminalOptionsProvider
|
||||
myState.envDataOptions.set(envData)
|
||||
}
|
||||
|
||||
fun defaultShellPath(): String {
|
||||
private fun defaultShellPath(): String {
|
||||
val shell = System.getenv("SHELL")
|
||||
if (shell != null && File(shell).canExecute()) {
|
||||
return shell
|
||||
|
||||
@@ -60,6 +60,27 @@ class TerminalProjectOptionsProvider(val project: Project) : PersistentStateComp
|
||||
return dir?.canonicalPath
|
||||
}
|
||||
|
||||
val defaultShellPath: String
|
||||
get() {
|
||||
val shell = System.getenv("SHELL")
|
||||
|
||||
if (shell != null && File(shell).canExecute()) {
|
||||
return shell
|
||||
}
|
||||
|
||||
if (SystemInfo.isUnix) {
|
||||
if (File("/bin/bash").exists()) {
|
||||
return "/bin/bash"
|
||||
}
|
||||
else {
|
||||
return "/bin/sh"
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "cmd.exe"
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(TerminalProjectOptionsProvider::class.java)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.jetbrains.plugins.terminal;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
@@ -13,7 +13,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -24,7 +23,6 @@ import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
@@ -61,8 +59,42 @@ public class TerminalSettingsPanel {
|
||||
myProjectSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Project settings"));
|
||||
myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Application settings"));
|
||||
|
||||
configureShellPathField();
|
||||
configureStartDirectoryField();
|
||||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
|
||||
|
||||
myShellPathField.addBrowseFolderListener(
|
||||
"",
|
||||
"Shell executable path",
|
||||
null,
|
||||
fileChooserDescriptor,
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
|
||||
|
||||
fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
|
||||
|
||||
myStartDirectoryField.addBrowseFolderListener(
|
||||
"",
|
||||
"Starting directory",
|
||||
null,
|
||||
fileChooserDescriptor,
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
|
||||
|
||||
myShellPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
myShellPathField
|
||||
.getTextField().setForeground(StringUtil.equals(myShellPathField.getText(), myProjectOptionsProvider.getDefaultShellPath()) ?
|
||||
getDefaultValueColor() : getChangedValueColor());
|
||||
}
|
||||
});
|
||||
|
||||
myStartDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
myStartDirectoryField
|
||||
.getTextField()
|
||||
.setForeground(StringUtil.equals(myStartDirectoryField.getText(), myProjectOptionsProvider.getDefaultStartingDirectory()) ?
|
||||
getDefaultValueColor() : getChangedValueColor());
|
||||
}
|
||||
});
|
||||
|
||||
List<Component> customComponents = ContainerUtil.newArrayList();
|
||||
for (LocalTerminalCustomizer c : LocalTerminalCustomizer.EP_NAME.getExtensions()) {
|
||||
@@ -92,41 +124,6 @@ public class TerminalSettingsPanel {
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
private void configureStartDirectoryField() {
|
||||
myStartDirectoryField.addBrowseFolderListener(
|
||||
"",
|
||||
"Starting directory",
|
||||
null,
|
||||
FileChooserDescriptorFactory.createSingleFolderDescriptor(),
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT
|
||||
);
|
||||
setupTextFieldDefaultValue(myStartDirectoryField.getTextField(), () -> myProjectOptionsProvider.getDefaultStartingDirectory());
|
||||
}
|
||||
|
||||
private void configureShellPathField() {
|
||||
myShellPathField.addBrowseFolderListener(
|
||||
"",
|
||||
"Shell executable path",
|
||||
null,
|
||||
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT
|
||||
);
|
||||
setupTextFieldDefaultValue(myShellPathField.getTextField(), () -> myOptionsProvider.defaultShellPath());
|
||||
}
|
||||
|
||||
private void setupTextFieldDefaultValue(@NotNull JTextField textField, @NotNull Supplier<String> defaultValueSupplier) {
|
||||
textField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
String defaultShellPath = defaultValueSupplier.get();
|
||||
textField.setForeground(defaultShellPath.equals(textField.getText()) ? getDefaultValueColor() : getChangedValueColor());
|
||||
}
|
||||
});
|
||||
if (textField instanceof JBTextField) {
|
||||
((JBTextField)textField).getEmptyText().setText(defaultValueSupplier.get());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return !Comparing.equal(myShellPathField.getText(), myOptionsProvider.getShellPath())
|
||||
|| !Comparing.equal(myStartDirectoryField.getText(), StringUtil.notNullize(myProjectOptionsProvider.getStartingDirectory()))
|
||||
|
||||
Reference in New Issue
Block a user