() {
160 | @Override
161 | public Point compute() {
162 | JRootPane rootPane = SwingUtilities.getRootPane(getWindow().getParent());
163 | if (rootPane == null) {
164 | rootPane = SwingUtilities.getRootPane(getWindow().getOwner());
165 | }
166 |
167 | Point p = rootPane.getLocationOnScreen();
168 | p.x += (rootPane.getWidth() - getWindow().getWidth()) / 2;
169 | return p;
170 | }
171 | });
172 | animate();
173 | if (SystemInfo.isJavaVersionAtLeast("1.7")) {
174 | try {
175 | Method method = Class.forName("java.awt.Window").getDeclaredMethod("setOpacity", float.class);
176 | if (method != null) method.invoke(getPeer().getWindow(), .8f);
177 | } catch (Exception exception) {
178 | }
179 | }
180 | setAutoAdjustable(false);
181 | setSize(getPreferredSize().width, 0);//initial state before animation, zero height
182 | }
183 | super.show();
184 | }
185 |
186 | private void animate() {
187 | final int height = getPreferredSize().height;
188 | final int frameCount = 10;
189 | final boolean toClose = isShowing();
190 |
191 |
192 | final AtomicInteger i = new AtomicInteger(-1);
193 | final Alarm animator = new Alarm(myDisposable);
194 | final Runnable runnable = new Runnable() {
195 | @Override
196 | public void run() {
197 | int state = i.addAndGet(1);
198 |
199 | double linearProgress = (double) state / frameCount;
200 | if (toClose) {
201 | linearProgress = 1 - linearProgress;
202 | }
203 | myLayout.myPhase = (1 - Math.cos(Math.PI * linearProgress)) / 2;
204 | Window window = getPeer().getWindow();
205 | Rectangle bounds = window.getBounds();
206 | bounds.height = (int) (height * myLayout.myPhase);
207 |
208 | window.setBounds(bounds);
209 |
210 | if (state == 0 && !toClose && window.getOwner() instanceof IdeFrame) {
211 | WindowManager.getInstance().requestUserAttention((IdeFrame) window.getOwner(), true);
212 | }
213 |
214 | if (state < frameCount) {
215 | animator.addRequest(this, 10);
216 | } else if (toClose) {
217 | MultiSelectDialog.super.dispose();
218 | }
219 | }
220 | };
221 | animator.addRequest(runnable, 10, ModalityState.stateForComponent(getRootPane()));
222 | }
223 |
224 | protected JComponent doCreateCenterPanel() {
225 | final JPanel panel = new JPanel(new BorderLayout(15, 0));
226 |
227 | /*if (myMessage != null) {
228 | final JTextPane messageComponent = createMessageComponent(myMessage);
229 |
230 | final Dimension screenSize = messageComponent.getToolkit().getScreenSize();
231 | final Dimension textSize = messageComponent.getPreferredSize();
232 | if (myMessage.length() > 100) {
233 | final JScrollPane pane = ScrollPaneFactory.createScrollPane(messageComponent);
234 | pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
235 | pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
236 | pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
237 | final int scrollSize = (int) new JScrollBar(Adjustable.VERTICAL).getPreferredSize().getWidth() + 12;
238 | final Dimension preferredSize =
239 | new Dimension(Math.min(textSize.width, (int) (screenSize.width * REVERSE_GOLDEN_RATIO)) + scrollSize,
240 | Math.min(textSize.height, screenSize.height / 3) + scrollSize);
241 | pane.setPreferredSize(preferredSize);
242 | panel.add(pane, BorderLayout.NORTH);
243 | } else {
244 | panel.add(messageComponent, BorderLayout.NORTH);
245 | }
246 | }*/
247 |
248 | if (!data.isEmpty()) {
249 | final Container container = new Container();
250 |
251 | final JCheckBox checkbox_selectAll = new JCheckBox("Select All");
252 | checkbox_selectAll.setMargin(new Insets(22, 300, 0, 0));
253 | panel.add(checkbox_selectAll, BorderLayout.NORTH);
254 |
255 | checkbox_selectAll.addItemListener(new ItemListener() {
256 | @Override
257 | public void itemStateChanged(ItemEvent e) {
258 | if (e.getStateChange() == ItemEvent.SELECTED) {
259 | selectedLanguages.addAll(data);
260 | checkbox_selectAll.setSelected(true);
261 |
262 | for(Component component:container.getComponents()){
263 | JCheckBox checkBox = (JCheckBox) component;
264 | checkBox.setSelected(true);
265 | }
266 |
267 | } else if (e.getStateChange() == ItemEvent.DESELECTED) {
268 | checkbox_selectAll.setSelected(false);
269 | selectedLanguages.removeAll(data);
270 |
271 | for(Component component:container.getComponents()){
272 | JCheckBox checkBox = (JCheckBox) component;
273 | checkBox.setSelected(false);
274 | }
275 | }
276 | }
277 | });
278 |
279 |
280 | int gridCol = 3;
281 | int gridRow = (data.size() % gridCol == 0) ? data.size() / gridCol : data.size() / gridCol + 1;
282 | container.setLayout(new GridLayout(gridRow, gridCol));
283 | boolean showEnglish= PropertiesComponent.getInstance().getValue(StorageDataKey.SettingLanguageShowWhenChoose,"English").equals("English");
284 | for (final SupportedLanguages language : data) {
285 | String display;
286 | if(showEnglish)
287 | display=language.getLanguageEnglishDisplayName();
288 | else display=language.getLanguageChineseDisplayName();
289 | JCheckBox checkbox = new JCheckBox(display
290 | + " (" + language.getLanguageDisplayName() + ") ");
291 | checkbox.addItemListener(new ItemListener() {
292 | @Override
293 | public void itemStateChanged(ItemEvent e) {
294 | if (e.getStateChange() == ItemEvent.SELECTED) {
295 | if (!selectedLanguages.contains(language)) {
296 | selectedLanguages.add(language);
297 | }
298 | } else if (e.getStateChange() == ItemEvent.DESELECTED) {
299 | if (selectedLanguages.contains(language)) {
300 | selectedLanguages.remove(language);
301 | }
302 | }
303 | }
304 | });
305 | checkbox.setSelected(
306 | propertiesComponent.getBoolean(StorageDataKey.SupportedLanguageCheckStatusPrefix + language.getLanguageCode(), false));
307 | container.add(checkbox);
308 | }
309 |
310 | panel.add(container, BorderLayout.CENTER);
311 | }
312 |
313 | if (myCheckboxText != null) {
314 |
315 | myCheckBox = new JCheckBox(myCheckboxText);
316 | myCheckBox.setSelected(myChecked);
317 | myCheckBox.setMargin(new Insets(2, -4, 0, 0));
318 |
319 | panel.add(myCheckBox, BorderLayout.SOUTH);
320 | }
321 |
322 | return panel;
323 | }
324 |
325 | protected static JTextPane createMessageComponent(final String message) {
326 | final JTextPane messageComponent = new JTextPane();
327 | return configureMessagePaneUi(messageComponent, message);
328 | }
329 |
330 | @Override
331 | protected void doHelpAction() {
332 | // do nothing
333 | }
334 |
335 | @NotNull
336 | public static JTextPane configureMessagePaneUi(JTextPane messageComponent, String message) {
337 | return configureMessagePaneUi(messageComponent, message, true);
338 | }
339 |
340 | @NotNull
341 | public static JTextPane configureMessagePaneUi(JTextPane messageComponent,
342 | String message,
343 | final boolean addBrowserHyperlinkListener) {
344 | messageComponent.setFont(UIUtil.getLabelFont());
345 | if (BasicHTML.isHTMLString(message)) {
346 | final HTMLEditorKit editorKit = new HTMLEditorKit();
347 | editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(UIUtil.getLabelFont(), UIUtil.getLabelForeground()));
348 | messageComponent.setEditorKit(editorKit);
349 | messageComponent.setContentType(UIUtil.HTML_MIME);
350 | if (addBrowserHyperlinkListener) {
351 | messageComponent.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
352 | }
353 | }
354 | messageComponent.setText(message);
355 | messageComponent.setEditable(false);
356 | if (messageComponent.getCaret() != null) {
357 | messageComponent.setCaretPosition(0);
358 | }
359 |
360 | if (UIUtil.isUnderNimbusLookAndFeel()) {
361 | messageComponent.setOpaque(false);
362 | messageComponent.setBackground(UIUtil.TRANSPARENT_COLOR);
363 | } else {
364 | messageComponent.setBackground(UIUtil.getOptionPaneBackground());
365 | }
366 |
367 | messageComponent.setForeground(UIUtil.getLabelForeground());
368 | return messageComponent;
369 | }
370 |
371 | private static class MyBorderLayout extends BorderLayout {
372 | private double myPhase = 0;//it varies from 0 (hidden state) to 1 (fully visible)
373 |
374 | private MyBorderLayout() {
375 | }
376 |
377 | @Override
378 | public void layoutContainer(Container target) {
379 | final Dimension realSize = target.getSize();
380 | target.setSize(target.getPreferredSize());
381 |
382 | super.layoutContainer(target);
383 |
384 | target.setSize(realSize);
385 |
386 | synchronized (target.getTreeLock()) {
387 | int yShift = (int) ((1 - myPhase) * target.getPreferredSize().height);
388 | Component[] components = target.getComponents();
389 | for (Component component : components) {
390 | Point point = component.getLocation();
391 | point.y -= yShift;
392 | component.setLocation(point);
393 | }
394 | }
395 | }
396 | }
397 | }
398 |
--------------------------------------------------------------------------------
/src/util/Logger.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 |
4 | import com.intellij.notification.*;
5 |
6 | /**
7 | * create on 17/12/16
8 | * @author wujs
9 | */
10 | public class Logger {
11 | private static String NAME;
12 | private static int LEVEL = 0;
13 |
14 | public static final int DEBUG = 3;
15 | public static final int INFO = 2;
16 | public static final int WARN = 1;
17 | public static final int ERROR = 0;
18 |
19 | public static void init(String name,int level) {
20 | NAME = name;
21 | LEVEL = level;
22 | NotificationsConfiguration.getNotificationsConfiguration().register(NAME, NotificationDisplayType.NONE);
23 | }
24 |
25 | public static void debug(String text) {
26 | if (LEVEL >= DEBUG) {
27 | Notifications.Bus.notify(
28 | new Notification(NAME, NAME + " [DEBUG]", text, NotificationType.INFORMATION));
29 | }
30 | }
31 |
32 | public static void info(String text) {
33 | if (LEVEL > INFO) {
34 | Notifications.Bus.notify(
35 | new Notification(NAME, NAME + " [INFO]", text, NotificationType.INFORMATION));
36 | }
37 | }
38 |
39 | public static void warn(String text) {
40 | if (LEVEL > WARN) {
41 | Notifications.Bus.notify(
42 | new Notification(NAME, NAME + " [WARN]", text, NotificationType.WARNING));
43 | }
44 | }
45 |
46 | public static void error(String text) {
47 | if (LEVEL > ERROR) {
48 | Notifications.Bus.notify(
49 | new Notification(NAME, NAME + " [ERROR]", text, NotificationType.ERROR));
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/util/MyURLEncoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | *
24 | */
25 |
26 | package util;
27 |
28 | import sun.security.action.GetPropertyAction;
29 |
30 | import java.io.CharArrayWriter;
31 | import java.io.UnsupportedEncodingException;
32 | import java.net.URLDecoder;
33 | import java.nio.charset.Charset;
34 | import java.nio.charset.IllegalCharsetNameException;
35 | import java.nio.charset.UnsupportedCharsetException;
36 | import java.security.AccessController;
37 | import java.util.BitSet;
38 |
39 | /**
40 | * Utility class for HTML form encoding. This class contains static methods
41 | * for converting a String to the application/x-www-form-urlencoded
MIME
42 | * format. For more information about HTML form encoding, consult the HTML
43 | * specification.
44 | *
45 | *
46 | * When encoding a String, the following rules apply:
47 | *
48 | *
49 | * - The alphanumeric characters "{@code a}" through
50 | * "{@code z}", "{@code A}" through
51 | * "{@code Z}" and "{@code 0}"
52 | * through "{@code 9}" remain the same.
53 | *
- The special characters "{@code .}",
54 | * "{@code -}", "{@code *}", and
55 | * "{@code _}" remain the same.
56 | *
- The space character " " is
57 | * converted into a plus sign "{@code +}".
58 | *
- All other characters are unsafe and are first converted into
59 | * one or more bytes using some encoding scheme. Then each byte is
60 | * represented by the 3-character string
61 | * "{@code %xy}", where xy is the
62 | * two-digit hexadecimal representation of the byte.
63 | * The recommended encoding scheme to use is UTF-8. However,
64 | * for compatibility reasons, if an encoding is not specified,
65 | * then the default encoding of the platform is used.
66 | *
67 | *
68 | *
69 | * For example using UTF-8 as the encoding scheme the string "The
70 | * string ü@foo-bar" would get converted to
71 | * "The+string+%C3%BC%40foo-bar" because in UTF-8 the character
72 | * ü is encoded as two bytes C3 (hex) and BC (hex), and the
73 | * character @ is encoded as one byte 40 (hex).
74 | *
75 | * @author Herb Jellinek
76 | * @since JDK1.0
77 | */
78 | public class MyURLEncoder {
79 | static BitSet dontNeedEncoding;
80 | static final int caseDiff = ('a' - 'A');
81 | static String dfltEncName = null;
82 |
83 | static {
84 |
85 | /* The list of characters that are not encoded has been
86 | * determined as follows:
87 | *
88 | * RFC 2396 states:
89 | * -----
90 | * Data characters that are allowed in a URI but do not have a
91 | * reserved purpose are called unreserved. These include upper
92 | * and lower case letters, decimal digits, and a limited set of
93 | * punctuation marks and symbols.
94 | *
95 | * unreserved = alphanum | mark
96 | *
97 | * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
98 | *
99 | * Unreserved characters can be escaped without changing the
100 | * semantics of the URI, but this should not be done unless the
101 | * URI is being used in a context that does not allow the
102 | * unescaped character to appear.
103 | * -----
104 | *
105 | * It appears that both Netscape and Internet Explorer escape
106 | * all special characters from this list with the exception
107 | * of "-", "_", ".", "*". While it is not clear why they are
108 | * escaping the other characters, perhaps it is safest to
109 | * assume that there might be contexts in which the others
110 | * are unsafe if not escaped. Therefore, we will use the same
111 | * list. It is also noteworthy that this is consistent with
112 | * O'Reilly's "HTML: The Definitive Guide" (page 164).
113 | *
114 | * As a last note, Intenet Explorer does not encode the "@"
115 | * character which is clearly not unreserved according to the
116 | * RFC. We are being consistent with the RFC in this matter,
117 | * as is Netscape.
118 | *
119 | */
120 |
121 | dontNeedEncoding = new BitSet(256);
122 | int i;
123 | for (i = 'a'; i <= 'z'; i++) {
124 | dontNeedEncoding.set(i);
125 | }
126 | for (i = 'A'; i <= 'Z'; i++) {
127 | dontNeedEncoding.set(i);
128 | }
129 | for (i = '0'; i <= '9'; i++) {
130 | dontNeedEncoding.set(i);
131 | }
132 | dontNeedEncoding.set(' '); /* encoding a space to a + is done
133 | * in the encode() method */
134 | dontNeedEncoding.set('-');
135 | dontNeedEncoding.set('_');
136 | dontNeedEncoding.set('.');
137 | dontNeedEncoding.set('*');
138 |
139 | dfltEncName = AccessController.doPrivileged(
140 | new GetPropertyAction("file.encoding")
141 | );
142 | }
143 |
144 | /**
145 | * You can't call the constructor.
146 | */
147 | private MyURLEncoder() { }
148 |
149 | /**
150 | * Translates a string into {@code x-www-form-urlencoded}
151 | * format. This method uses the platform's default encoding
152 | * as the encoding scheme to obtain the bytes for unsafe characters.
153 | *
154 | * @param s {@code String} to be translated.
155 | * @deprecated The resulting string may vary depending on the platform's
156 | * default encoding. Instead, use the encode(String,String)
157 | * method to specify the encoding.
158 | * @return the translated {@code String}.
159 | */
160 | @Deprecated
161 | public static String encode(String s) {
162 |
163 | String str = null;
164 |
165 | try {
166 | str = encode(s, dfltEncName);
167 | } catch (UnsupportedEncodingException e) {
168 | // The system should always have the platform default
169 | }
170 |
171 | return str;
172 | }
173 |
174 | /**
175 | * Translates a string into {@code application/x-www-form-urlencoded}
176 | * format using a specific encoding scheme. This method uses the
177 | * supplied encoding scheme to obtain the bytes for unsafe
178 | * characters.
179 | *
180 | * Note: The
182 | * World Wide Web Consortium Recommendation states that
183 | * UTF-8 should be used. Not doing so may introduce
184 | * incompatibilities.
185 | *
186 | * @param s {@code String} to be translated.
187 | * @param enc The name of a supported
188 | * character
189 | * encoding.
190 | * @return the translated {@code String}.
191 | * @exception UnsupportedEncodingException
192 | * If the named encoding is not supported
193 | * @see URLDecoder#decode(String, String)
194 | * @since 1.4
195 | */
196 | public static String encode(String s, String enc)
197 | throws UnsupportedEncodingException {
198 |
199 | boolean needToChange = false;
200 | StringBuffer out = new StringBuffer(s.length());
201 | Charset charset;
202 | CharArrayWriter charArrayWriter = new CharArrayWriter();
203 |
204 | if (enc == null)
205 | throw new NullPointerException("charsetName");
206 |
207 | try {
208 | charset = Charset.forName(enc);
209 | } catch (IllegalCharsetNameException e) {
210 | throw new UnsupportedEncodingException(enc);
211 | } catch (UnsupportedCharsetException e) {
212 | throw new UnsupportedEncodingException(enc);
213 | }
214 |
215 | for (int i = 0; i < s.length();) {
216 | int c = (int) s.charAt(i);
217 | //System.out.println("Examining character: " + c);
218 | if (dontNeedEncoding.get(c)) {
219 | if (c == ' ') {
220 | c = '+';
221 | needToChange = true;
222 | }
223 | //System.out.println("Storing: " + c);
224 | out.append((char)c);
225 | i++;
226 | } else {
227 | // convert to external encoding before hex conversion
228 | do {
229 | charArrayWriter.write(c);
230 | /*
231 | * If this character represents the start of a Unicode
232 | * surrogate pair, then pass in two characters. It's not
233 | * clear what should be done if a bytes reserved in the
234 | * surrogate pairs range occurs outside of a legal
235 | * surrogate pair. For now, just treat it as if it were
236 | * any other character.
237 | */
238 | if (c >= 0xD800 && c <= 0xDBFF) {
239 | /*
240 | System.out.println(Integer.toHexString(c)
241 | + " is high surrogate");
242 | */
243 | if ( (i+1) < s.length()) {
244 | int d = (int) s.charAt(i+1);
245 | /*
246 | System.out.println("\tExamining "
247 | + Integer.toHexString(d));
248 | */
249 | if (d >= 0xDC00 && d <= 0xDFFF) {
250 | /*
251 | System.out.println("\t"
252 | + Integer.toHexString(d)
253 | + " is low surrogate");
254 | */
255 | charArrayWriter.write(d);
256 | i++;
257 | }
258 | }
259 | }
260 | i++;
261 | } while (i < s.length() && !dontNeedEncoding.get((c = (int) s.charAt(i))));
262 |
263 | charArrayWriter.flush();
264 | String str = new String(charArrayWriter.toCharArray());
265 | byte[] ba = str.getBytes(charset);
266 | for (int j = 0; j < ba.length; j++) {
267 | out.append('%');
268 | char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16);
269 | // converting to use uppercase letter as part of
270 | // the hex value if ch is a letter.
271 | if (Character.isLetter(ch)) {
272 | ch -= caseDiff;
273 | }
274 | out.append(ch);
275 | ch = Character.forDigit(ba[j] & 0xF, 16);
276 | if (Character.isLetter(ch)) {
277 | ch -= caseDiff;
278 | }
279 | out.append(ch);
280 | }
281 | charArrayWriter.reset();
282 | needToChange = true;
283 | }
284 | }
285 |
286 | return (needToChange? out.toString() : s);
287 | }
288 | }
289 |
--------------------------------------------------------------------------------
/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Browse
5 | One
6 | M
7 | ...
8 | ''
9 | honor watch S1-c86
10 | Set goals
11 |
12 | - @string/plan_step_1
13 | - 我的运动计划
14 |
15 | MAF \ nhealth run
16 |
17 | - Simplified Chinese
18 | - English
19 |
20 | Hi, you can now wake me up by saying \% 1 $s \ "or \% 2 $s \"
21 | This operation will lock the device. You need to enter the < font color = "ා" > Settings - > device information < / font > page "< font color =" ා "> scan code to activate < / font >", then the treadmill can be used normally.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 浏 览
6 |
7 | 1
8 |
9 | m
10 |
11 | …
12 |
13 | \'
14 |
15 | honor watch S1-c86
16 |
17 | 设定目标
18 |
19 |
20 |
21 | - @string/plan_step_1
22 | - 我的运动计划
23 |
24 |
25 |
26 |
27 |
28 |
29 | MAF\n健康跑
30 |
31 |
32 |
33 |
34 | - 中文简体
35 | - English
36 |
37 |
38 |
39 |
40 | Hi,你现在可以说 \"%1$s\" 或 \"%2$s\" 来唤醒我
41 |
42 |
43 |
44 | 设置->设备信息页面“扫码激活”后,跑步机才能正常使用。
46 | ]]>
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------