Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
9eef326c
Commit
9eef326c
authored
6 years ago
by
Sergey Simonchik
1
Browse files
Options
Download
Email Patches
Plain Diff
terminal: show default path for empty fields (shell path and starting directory)
parent
897d12e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.kt
+1
-1
...org/jetbrains/plugins/terminal/TerminalOptionsProvider.kt
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalProjectOptionsProvider.kt
+0
-21
...brains/plugins/terminal/TerminalProjectOptionsProvider.kt
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalSettingsPanel.java
+40
-37
...org/jetbrains/plugins/terminal/TerminalSettingsPanel.java
with
41 additions
and
59 deletions
+41
-59
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.kt
+
1
-
1
View file @
9eef326c
...
...
@@ -126,7 +126,7 @@ class TerminalOptionsProvider : PersistentStateComponent<TerminalOptionsProvider
myState
.
envDataOptions
.
set
(
envData
)
}
private
fun
defaultShellPath
():
String
{
fun
defaultShellPath
():
String
{
val
shell
=
System
.
getenv
(
"SHELL"
)
if
(
shell
!=
null
&&
File
(
shell
).
canExecute
())
{
return
shell
...
...
This diff is collapsed.
Click to expand it.
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalProjectOptionsProvider.kt
+
0
-
21
View file @
9eef326c
...
...
@@ -60,27 +60,6 @@ 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
)
...
...
This diff is collapsed.
Click to expand it.
plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalSettingsPanel.java
+
40
-
37
View file @
9eef326c
...
...
@@ -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.FileChooserDescriptor
;
import
com.intellij.openapi.fileChooser.FileChooserDescriptor
Factory
;
import
com.intellij.openapi.options.ConfigurationException
;
import
com.intellij.openapi.options.UnnamedConfigurable
;
import
com.intellij.openapi.ui.TextComponentAccessor
;
...
...
@@ -13,6 +13,7 @@ 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
;
...
...
@@ -23,6 +24,7 @@ import javax.swing.event.DocumentEvent;
import
java.awt.*
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.function.Supplier
;
/**
* @author traff
...
...
@@ -59,42 +61,8 @@ public class TerminalSettingsPanel {
myProjectSettingsPanel
.
setBorder
(
IdeBorderFactory
.
createTitledBorder
(
"Project settings"
));
myGlobalSettingsPanel
.
setBorder
(
IdeBorderFactory
.
createTitledBorder
(
"Application settings"
));
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
());
}
});
configureShellPathField
();
configureStartDirectoryField
();
List
<
Component
>
customComponents
=
ContainerUtil
.
newArrayList
();
for
(
LocalTerminalCustomizer
c
:
LocalTerminalCustomizer
.
EP_NAME
.
getExtensions
())
{
...
...
@@ -124,6 +92,41 @@ 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
()))
...
...
This diff is collapsed.
Click to expand it.
小 白蛋
@baidan
mentioned in commit
9f562a56
·
2 years ago
mentioned in commit
9f562a56
mentioned in commit 9f562a561b97ebf070981cc803044f21ccea1da1
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help