" + message, title, option);
85 | } catch (Exception e) {
86 | nogui = true;
87 | alert(Level.WARNING, context, noguiMessage);
88 | alert(level, context, message);
89 | }
90 | }
91 | }
92 |
93 | public String prompt(String content) {
94 | if (noprompt)
95 | return null;
96 | if (nogui) {
97 | if (scanner == null)
98 | scanner = new Scanner(System.in);
99 | try {
100 | System.out.println(content);
101 | if (scanner.hasNextLine())
102 | return scanner.nextLine();
103 | return null;
104 | } catch (Exception e) {
105 | alert(Level.ERROR, title, "コマンドラインから入力を読み込めません。");
106 | e.printStackTrace();
107 | return null;
108 | }
109 | } else {
110 | try {
111 | return JOptionPane.showInputDialog(null, content, title, JOptionPane.QUESTION_MESSAGE);
112 | } catch (Exception e) {
113 | nogui = true;
114 | alert(Level.WARNING, title, noguiMessage);
115 | return prompt(content);
116 | }
117 | }
118 | }
119 |
120 | public enum Level {
121 | INFO, WARNING, ERROR
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/com/jagrosh/jmusicbot/gui/ConsolePanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2020 Cosgy Dev
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.jagrosh.jmusicbot.gui;
17 |
18 | import javax.swing.*;
19 | import java.awt.*;
20 | import java.io.PrintStream;
21 |
22 | /**
23 | * @author John Grosh queue = new FairQueue<>();
31 | int size = 100;
32 | for (int i = 0; i < size; i++)
33 | queue.add(new Q(i));
34 | assertEquals(queue.size(), size);
35 | }
36 |
37 | @Test
38 | public void sameIdentifierSize() {
39 | FairQueue
queue = new FairQueue<>();
40 | int size = 100;
41 | for (int i = 0; i < size; i++)
42 | queue.add(new Q(0));
43 | assertEquals(queue.size(), size);
44 | }
45 |
46 | private class Q implements Queueable {
47 | private final long identifier;
48 |
49 | private Q(long identifier) {
50 | this.identifier = identifier;
51 | }
52 |
53 | @Override
54 | public long getIdentifier() {
55 | return identifier;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------