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 | |
package org.omegat.util.gui; |
30 | |
|
31 | |
import java.awt.Dimension; |
32 | |
import java.awt.Point; |
33 | |
import java.awt.Window; |
34 | |
|
35 | |
import javax.swing.ImageIcon; |
36 | |
import javax.swing.JLabel; |
37 | |
import javax.swing.JPopupMenu; |
38 | |
import javax.swing.JSeparator; |
39 | |
import javax.swing.UIManager; |
40 | |
|
41 | |
import org.omegat.core.Core; |
42 | |
import org.omegat.util.OStrings; |
43 | |
|
44 | |
import com.vlsolutions.swing.docking.ui.DockingUISettings; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | 0 | public class DockingUI { |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public static void initialize() { |
55 | 3605 | DockingUISettings.getInstance().installUI(); |
56 | 3605 | UIManager.put("DockViewTitleBar.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); |
57 | 3605 | UIManager.put("DockViewTitleBar.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); |
58 | 3605 | UIManager.put("DockViewTitleBar.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); |
59 | 3605 | UIManager.put("DockViewTitleBar.attachButtonText", OStrings.getString("DOCKING_HINT_DOCK")); |
60 | 3605 | UIManager.put("DockViewTitleBar.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); |
61 | 3605 | UIManager.put("DockViewTitleBar.closeButtonText", new String()); |
62 | 3605 | UIManager.put("DockTabbedPane.minimizeButtonText", OStrings.getString("DOCKING_HINT_MINIMIZE")); |
63 | 3605 | UIManager.put("DockTabbedPane.maximizeButtonText", OStrings.getString("DOCKING_HINT_MAXIMIZE")); |
64 | 3605 | UIManager.put("DockTabbedPane.restoreButtonText", OStrings.getString("DOCKING_HINT_RESTORE")); |
65 | 3605 | UIManager.put("DockTabbedPane.floatButtonText", OStrings.getString("DOCKING_HINT_UNDOCK")); |
66 | 3605 | UIManager.put("DockTabbedPane.closeButtonText", new String()); |
67 | |
|
68 | 3605 | UIManager.put("DockViewTitleBar.titleFont", new JLabel().getFont()); |
69 | |
|
70 | 3605 | UIManager.put("DockViewTitleBar.isCloseButtonDisplayed", Boolean.FALSE); |
71 | |
|
72 | 3605 | UIManager.put("DockViewTitleBar.hide", getIcon("minimize.gif")); |
73 | 3605 | UIManager.put("DockViewTitleBar.hide.rollover", getIcon("minimize.rollover.gif")); |
74 | 3605 | UIManager.put("DockViewTitleBar.hide.pressed", getIcon("minimize.pressed.gif")); |
75 | 3605 | UIManager.put("DockViewTitleBar.maximize", getIcon("maximize.gif")); |
76 | 3605 | UIManager.put("DockViewTitleBar.maximize.rollover", getIcon("maximize.rollover.gif")); |
77 | 3605 | UIManager.put("DockViewTitleBar.maximize.pressed", getIcon("maximize.pressed.gif")); |
78 | 3605 | UIManager.put("DockViewTitleBar.restore", getIcon("restore.gif")); |
79 | 3605 | UIManager.put("DockViewTitleBar.restore.rollover", getIcon("restore.rollover.gif")); |
80 | 3605 | UIManager.put("DockViewTitleBar.restore.pressed", getIcon("restore.pressed.gif")); |
81 | 3605 | UIManager.put("DockViewTitleBar.dock", getIcon("restore.gif")); |
82 | 3605 | UIManager.put("DockViewTitleBar.dock.rollover", getIcon("restore.rollover.gif")); |
83 | 3605 | UIManager.put("DockViewTitleBar.dock.pressed", getIcon("restore.pressed.gif")); |
84 | 3605 | UIManager.put("DockViewTitleBar.float", getIcon("undock.gif")); |
85 | 3605 | UIManager.put("DockViewTitleBar.float.rollover", getIcon("undock.rollover.gif")); |
86 | 3605 | UIManager.put("DockViewTitleBar.float.pressed", getIcon("undock.pressed.gif")); |
87 | 3605 | UIManager.put("DockViewTitleBar.attach", getIcon("dock.gif")); |
88 | 3605 | UIManager.put("DockViewTitleBar.attach.rollover", getIcon("dock.rollover.gif")); |
89 | 3605 | UIManager.put("DockViewTitleBar.attach.pressed", getIcon("dock.pressed.gif")); |
90 | |
|
91 | 3605 | UIManager.put("DockViewTitleBar.menu.hide", getIcon("minimize.gif")); |
92 | 3605 | UIManager.put("DockViewTitleBar.menu.maximize", getIcon("maximize.gif")); |
93 | 3605 | UIManager.put("DockViewTitleBar.menu.restore", getIcon("restore.gif")); |
94 | 3605 | UIManager.put("DockViewTitleBar.menu.dock", getIcon("restore.gif")); |
95 | 3605 | UIManager.put("DockViewTitleBar.menu.float", getIcon("undock.gif")); |
96 | 3605 | UIManager.put("DockViewTitleBar.menu.attach", getIcon("dock.gif")); |
97 | |
|
98 | 3605 | UIManager.put("DockViewTitleBar.menu.close", getIcon("empty.gif")); |
99 | 3605 | UIManager.put("DockTabbedPane.close", getIcon("empty.gif")); |
100 | 3605 | UIManager.put("DockTabbedPane.close.rollover", getIcon("empty.gif")); |
101 | 3605 | UIManager.put("DockTabbedPane.close.pressed", getIcon("empty.gif")); |
102 | 3605 | UIManager.put("DockTabbedPane.menu.close", getIcon("empty.gif")); |
103 | 3605 | UIManager.put("DockTabbedPane.menu.hide", getIcon("empty.gif")); |
104 | 3605 | UIManager.put("DockTabbedPane.menu.maximize", getIcon("empty.gif")); |
105 | 3605 | UIManager.put("DockTabbedPane.menu.float", getIcon("empty.gif")); |
106 | 3605 | UIManager.put("DockTabbedPane.menu.closeAll", getIcon("empty.gif")); |
107 | 3605 | UIManager.put("DockTabbedPane.menu.closeAllOther", getIcon("empty.gif")); |
108 | |
|
109 | 3605 | UIManager.put("DockingDesktop.closeActionAccelerator", null); |
110 | 3605 | UIManager.put("DockingDesktop.maximizeActionAccelerator", null); |
111 | 3605 | UIManager.put("DockingDesktop.dockActionAccelerator", null); |
112 | 3605 | UIManager.put("DockingDesktop.floatActionAccelerator", null); |
113 | |
|
114 | 3605 | UIManager.put("DragControler.detachCursor", getIcon("undock.gif").getImage()); |
115 | 3605 | } |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
private static ImageIcon getIcon(final String iconName) { |
125 | 126175 | return ResourcesUtil.getIcon("/org/omegat/gui/resources/" + iconName); |
126 | |
} |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public static void displayCentered(final Window window) { |
135 | 6 | Point mLocation = Core.getMainWindow().getApplicationFrame().getLocation(); |
136 | 6 | Dimension mSize = Core.getMainWindow().getApplicationFrame().getSize(); |
137 | |
|
138 | 6 | Point mCenter = new Point(); |
139 | 6 | mCenter.x = mLocation.x + mSize.width / 2; |
140 | 6 | mCenter.y = mLocation.y + mSize.height / 2; |
141 | |
|
142 | 6 | Dimension dSize = window.getSize(); |
143 | 6 | Point dLocation = new Point(); |
144 | 6 | dLocation.x = mCenter.x - dSize.width / 2; |
145 | 6 | dLocation.y = mCenter.y - dSize.height / 2; |
146 | 6 | window.setLocation(dLocation); |
147 | 6 | } |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public static void removeUnusedMenuSeparators(final JPopupMenu menu) { |
153 | 3605 | if (menu.getComponentCount() > 0 && menu.getComponent(0) instanceof JSeparator) { |
154 | |
|
155 | 0 | menu.remove(0); |
156 | |
} |
157 | 3605 | if (menu.getComponentCount() > 0 |
158 | |
&& menu.getComponent(menu.getComponentCount() - 1) instanceof JSeparator) { |
159 | |
|
160 | 3605 | menu.remove(menu.getComponentCount() - 1); |
161 | |
} |
162 | 57680 | for (int i = 0; i < menu.getComponentCount() - 1; i++) { |
163 | 54075 | if (menu.getComponent(i) instanceof JSeparator && menu.getComponent(i + 1) instanceof JSeparator) { |
164 | |
|
165 | 0 | menu.remove(i); |
166 | |
} |
167 | |
} |
168 | 3605 | } |
169 | |
} |