Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
db2dd159
Commit
db2dd159
authored
6 years ago
by
Konstantin Bulenkov
Browse files
Options
Download
Email Patches
Plain Diff
add PMM Utils to internal actions (ability to set custom size to any window)
parent
af941306
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
platform/platform-impl/src/com/intellij/internal/inspector/ApplyWindowSizeAction.java
+35
-0
...om/intellij/internal/inspector/ApplyWindowSizeAction.java
platform/platform-impl/src/com/intellij/internal/inspector/ConfigureCustomSizeAction.kt
+66
-0
.../intellij/internal/inspector/ConfigureCustomSizeAction.kt
platform/platform-resources/src/idea/PlatformActions.xml
+5
-0
platform/platform-resources/src/idea/PlatformActions.xml
with
106 additions
and
0 deletions
+106
-0
platform/platform-impl/src/com/intellij/internal/inspector/ApplyWindowSizeAction.java
0 → 100644
+
35
-
0
View file @
db2dd159
// 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.
package
com.intellij.internal.inspector
;
import
com.intellij.ide.util.PropertiesComponent
;
import
com.intellij.openapi.actionSystem.AnActionEvent
;
import
com.intellij.openapi.project.DumbAwareAction
;
import
com.intellij.openapi.wm.IdeFocusManager
;
import
com.intellij.util.ui.UIUtil
;
import
org.jetbrains.annotations.NotNull
;
import
java.awt.*
;
/**
* @author Konstantin Bulenkov
*/
public
class
ApplyWindowSizeAction
extends
DumbAwareAction
{
public
ApplyWindowSizeAction
()
{
setEnabledInModalContext
(
true
);
}
@Override
public
void
actionPerformed
(
@NotNull
AnActionEvent
e
)
{
Component
owner
=
IdeFocusManager
.
findInstance
().
getFocusOwner
();
if
(
owner
!=
null
)
{
Window
window
=
UIUtil
.
getParentOfType
(
Window
.
class
,
owner
);
if
(
window
!=
null
)
{
PropertiesComponent
props
=
PropertiesComponent
.
getInstance
();
int
w
=
props
.
getInt
(
ConfigureCustomSizeAction
.
widthId
(),
640
);
int
h
=
props
.
getInt
(
ConfigureCustomSizeAction
.
heightId
(),
300
);
window
.
setMinimumSize
(
new
Dimension
(
w
,
h
));
window
.
setSize
(
w
,
h
);
}
}
}
}
This diff is collapsed.
Click to expand it.
platform/platform-impl/src/com/intellij/internal/inspector/ConfigureCustomSizeAction.kt
0 → 100644
+
66
-
0
View file @
db2dd159
// 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.
package
com.intellij.internal.inspector
import
com.intellij.ide.util.PropertiesComponent
import
com.intellij.openapi.actionSystem.AnActionEvent
import
com.intellij.openapi.project.DumbAwareAction
import
com.intellij.openapi.project.Project
import
com.intellij.openapi.ui.DialogWrapper
import
com.intellij.openapi.ui.ValidationInfo
import
com.intellij.ui.layout.*
import
javax.swing.JComponent
import
javax.swing.JTextField
/**
* @author Konstantin Bulenkov
*/
class
ConfigureCustomSizeAction
:
DumbAwareAction
()
{
override
fun
actionPerformed
(
e
:
AnActionEvent
)
{
ConfigureCustomSizeDialog
(
e
.
project
).
show
()
}
companion
object
{
private
fun
id
()
=
ConfigureCustomSizeAction
::
class
.
java
@JvmStatic
fun
widthId
()
=
"${id()}.width"
@JvmStatic
fun
heightId
()
=
"${id()}.height"
}
class
ConfigureCustomSizeDialog
(
project
:
Project
?):
DialogWrapper
(
project
)
{
val
width
:
JTextField
val
height
:
JTextField
init
{
title
=
"Default Size"
width
=
JTextField
(
loadWidth
(),
20
)
height
=
JTextField
(
loadHeight
(),
20
)
init
()
}
private
fun
loadWidth
()
=
PropertiesComponent
.
getInstance
().
getValue
(
widthId
(),
"640"
)
private
fun
loadHeight
()
=
PropertiesComponent
.
getInstance
().
getValue
(
heightId
(),
"300"
)
override
fun
createCenterPanel
():
JComponent
?
{
return
panel
{
row
(
"Width:"
)
{
width
()}
row
(
"Height:"
)
{
height
()}
}
}
override
fun
doOKAction
()
{
PropertiesComponent
.
getInstance
().
setValue
(
widthId
(),
width
.
text
)
PropertiesComponent
.
getInstance
().
setValue
(
heightId
(),
height
.
text
)
super
.
doOKAction
()
}
override
fun
doValidate
():
ValidationInfo
?
{
val
errorMessage
=
"Should be integer in range 1..1000"
val
w
=
width
.
text
.
toIntOrNull
()
val
h
=
height
.
text
.
toIntOrNull
()
if
(
w
==
null
||
w
<
1
||
w
>
1000
)
return
ValidationInfo
(
errorMessage
,
width
)
if
(
h
==
null
||
h
<
1
||
h
>
1000
)
return
ValidationInfo
(
errorMessage
,
height
)
return
null
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
platform/platform-resources/src/idea/PlatformActions.xml
+
5
-
0
View file @
db2dd159
...
...
@@ -855,6 +855,11 @@
<action
internal=
"true"
id=
"RecordStateCollectors"
class=
"com.intellij.internal.statistic.actions.RecordStateStatisticsEventLogAction"
text=
"Record State Collectors to Event Log"
/>
</group>
<group
id=
"Internal.PMM"
popup=
"true"
text=
"PMM Utils"
>
<action
id=
"ApplyFixedWindowSize"
internal=
"true"
class=
"com.intellij.internal.inspector.ApplyWindowSizeAction"
text=
"Apply Specific Size"
/>
<action
id=
"ConfigureDefaultSize"
internal=
"true"
class=
"com.intellij.internal.inspector.ConfigureCustomSizeAction"
text=
"Configure Default Size..."
/>
</group>
<action
internal=
"true"
id=
"ShowEditorHighlighterTokens"
class=
"com.intellij.openapi.editor.actions.ShowEditorHighlighterTokensAction"
text=
"Show Editor Highlighter Tokens"
/>
<add-to-group
group-id=
"ToolsMenu"
anchor=
"last"
/>
...
...
This diff is collapsed.
Click to expand it.
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