Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
keyescgm
jadx
提交
ac3f3e83
J
jadx
项目概览
keyescgm
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac3f3e83
编写于
5月 31, 2015
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gui: add common popup actions for text fields.
上级
bc8ad4df
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
165 addition
and
0 deletion
+165
-0
jadx-gui/src/main/java/jadx/gui/ui/SearchBar.java
jadx-gui/src/main/java/jadx/gui/ui/SearchBar.java
+2
-0
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
+1
-0
jadx-gui/src/main/java/jadx/gui/utils/TextStandardActions.java
...gui/src/main/java/jadx/gui/utils/TextStandardActions.java
+154
-0
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
+8
-0
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/SearchBar.java
浏览文件 @
ac3f3e83
package
jadx.gui.ui
;
import
jadx.gui.utils.TextStandardActions
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.Utils
;
...
...
@@ -73,6 +74,7 @@ class SearchBar extends JToolBar {
search
(
1
);
}
});
new
TextStandardActions
(
searchField
);
add
(
searchField
);
JButton
prevButton
=
new
JButton
(
NLS
.
str
(
"search.previous"
));
...
...
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
浏览文件 @
ac3f3e83
...
...
@@ -236,6 +236,7 @@ public class SearchDialog extends JDialog {
searchField
=
new
JTextField
();
searchField
.
setAlignmentX
(
LEFT_ALIGNMENT
);
searchField
.
getDocument
().
addDocumentListener
(
new
SearchFieldListener
());
new
TextStandardActions
(
searchField
);
JCheckBox
clsChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.class"
),
SearchOptions
.
CLASS
);
JCheckBox
mthChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.method"
),
SearchOptions
.
METHOD
);
...
...
jadx-gui/src/main/java/jadx/gui/utils/TextStandardActions.java
0 → 100644
浏览文件 @
ac3f3e83
package
jadx.gui.utils
;
import
javax.swing.AbstractAction
;
import
javax.swing.Action
;
import
javax.swing.JPopupMenu
;
import
javax.swing.KeyStroke
;
import
javax.swing.event.UndoableEditEvent
;
import
javax.swing.event.UndoableEditListener
;
import
javax.swing.text.JTextComponent
;
import
javax.swing.undo.UndoManager
;
import
java.awt.Toolkit
;
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
@SuppressWarnings
(
"serial"
)
public
class
TextStandardActions
{
private
final
JTextComponent
textComponent
;
private
final
JPopupMenu
popup
=
new
JPopupMenu
();
private
final
UndoManager
undoManager
;
private
Action
undoAction
;
private
Action
redoAction
;
private
Action
cutAction
;
private
Action
copyAction
;
private
Action
pasteAction
;
private
Action
deleteAction
;
private
Action
selectAllAction
;
public
TextStandardActions
(
JTextComponent
textComponent
)
{
this
.
textComponent
=
textComponent
;
this
.
undoManager
=
new
UndoManager
();
initActions
();
addPopupItems
();
addKeyActions
();
registerListeners
();
}
private
void
initActions
()
{
undoAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.undo"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
if
(
undoManager
.
canUndo
())
{
undoManager
.
undo
();
}
}
};
redoAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.redo"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
if
(
undoManager
.
canRedo
())
{
undoManager
.
redo
();
}
}
};
cutAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.cut"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
textComponent
.
cut
();
}
};
copyAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.copy"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
textComponent
.
copy
();
}
};
pasteAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.paste"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
textComponent
.
paste
();
}
};
deleteAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.delete"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
textComponent
.
replaceSelection
(
""
);
}
};
selectAllAction
=
new
AbstractAction
(
NLS
.
str
(
"popup.select_all"
))
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
textComponent
.
selectAll
();
}
};
}
void
addPopupItems
()
{
popup
.
add
(
undoAction
);
popup
.
add
(
redoAction
);
popup
.
addSeparator
();
popup
.
add
(
cutAction
);
popup
.
add
(
copyAction
);
popup
.
add
(
pasteAction
);
popup
.
add
(
deleteAction
);
popup
.
addSeparator
();
popup
.
add
(
selectAllAction
);
}
private
void
addKeyActions
()
{
KeyStroke
undoKey
=
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_Z
,
InputEvent
.
CTRL_MASK
);
textComponent
.
getInputMap
().
put
(
undoKey
,
undoAction
);
KeyStroke
redoKey
=
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_R
,
InputEvent
.
CTRL_MASK
);
textComponent
.
getInputMap
().
put
(
redoKey
,
redoAction
);
}
private
void
registerListeners
()
{
textComponent
.
addMouseListener
(
new
MouseAdapter
()
{
public
void
mouseReleased
(
MouseEvent
e
)
{
if
(
e
.
getModifiers
()
==
InputEvent
.
BUTTON3_MASK
&&
e
.
getSource
()
==
textComponent
)
{
process
(
e
);
}
}
});
textComponent
.
getDocument
().
addUndoableEditListener
(
new
UndoableEditListener
()
{
public
void
undoableEditHappened
(
UndoableEditEvent
event
)
{
undoManager
.
addEdit
(
event
.
getEdit
());
}
});
}
private
void
process
(
MouseEvent
e
)
{
textComponent
.
requestFocus
();
boolean
enabled
=
textComponent
.
isEnabled
();
boolean
editable
=
textComponent
.
isEditable
();
boolean
nonempty
=
!(
textComponent
.
getText
()
==
null
||
textComponent
.
getText
().
equals
(
""
));
boolean
marked
=
textComponent
.
getSelectedText
()
!=
null
;
boolean
pasteAvailable
=
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
()
.
getContents
(
null
).
isDataFlavorSupported
(
DataFlavor
.
stringFlavor
);
undoAction
.
setEnabled
(
enabled
&&
editable
&&
undoManager
.
canUndo
());
redoAction
.
setEnabled
(
enabled
&&
editable
&&
undoManager
.
canRedo
());
cutAction
.
setEnabled
(
enabled
&&
editable
&&
marked
);
copyAction
.
setEnabled
(
enabled
&&
marked
);
pasteAction
.
setEnabled
(
enabled
&&
editable
&&
pasteAvailable
);
deleteAction
.
setEnabled
(
enabled
&&
editable
&&
marked
);
selectAllAction
.
setEnabled
(
enabled
&&
nonempty
);
int
nx
=
e
.
getX
();
if
(
nx
>
500
)
{
nx
=
nx
-
popup
.
getSize
().
width
;
}
popup
.
show
(
e
.
getComponent
(),
nx
,
e
.
getY
()
-
popup
.
getSize
().
height
);
}
}
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
浏览文件 @
ac3f3e83
...
...
@@ -68,3 +68,11 @@ preferences.cancel=Cancel
msg.open_file
=
Please open file
msg.saving_sources
=
Saving sources
popup.undo
=
Undo
popup.redo
=
Redo
popup.cut
=
Cut
popup.copy
=
Copy
popup.paste
=
Paste
popup.delete
=
Delete
popup.select_all
=
Select All
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录