-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathNewToolAction.java
More file actions
76 lines (61 loc) · 1.79 KB
/
Copy pathNewToolAction.java
File metadata and controls
76 lines (61 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* 11/3/2009
*
* NewToolAction.java - Action that creates a new user tool
* Copyright (C) 2009 Robert Futrell
* https://bobbylight.github.io/RText/
* Licensed under a modified BSD license.
* See the included license file for details.
*/
package org.fife.rtext.plugins.tools;
import java.awt.event.ActionEvent;
import java.util.ResourceBundle;
import javax.swing.*;
import org.fife.rtext.RText;
import org.fife.ui.app.AppAction;
import org.fife.ui.app.themes.FlatLightTheme;
import org.fife.ui.app.themes.NativeTheme;
import org.fife.util.MacOSUtil;
/**
* Action that creates a new user tool.
*
* @author Robert Futrell
* @version 1.0
*/
class NewToolAction extends AppAction<RText> {
/**
* Constructor.
*
* @param owner The parent RText instance.
* @param msg The resource bundle to use for localization.
* @param icon The icon associated with the action.
*/
NewToolAction(RText owner, ResourceBundle msg, Icon icon) {
super(owner, msg, "NewToolAction");
setIcon(icon);
}
@Override
public void actionPerformed(ActionEvent e) {
RText owner = getApplication();
NewToolDialog ntd = new NewToolDialog(owner);
ntd.setVisible(true);
Tool tool = ntd.getTool();
if (tool!=null) {
ToolManager.get().addTool(tool);
}
}
void restoreDefaultIcon(ToolPlugin plugin) {
String themeId = getApplication().getTheme().getId();
if (MacOSUtil.isMacOs()) {
String menuItemThemeId = NativeTheme.ID.equals(themeId) ?
themeId : FlatLightTheme.ID;
setIcon(plugin.getIcon(menuItemThemeId));
setRolloverIcon((Icon)null);
return;
}
setIcon(plugin.getIcon(themeId));
Icon rolloverIcon = FlatLightTheme.ID.equals(themeId) ?
plugin.getIcon("white") : null;
setRolloverIcon(rolloverIcon);
}
}