SubServers Release v2.11.2f

This commit is contained in:
ME1312 2017-01-12 15:58:31 -05:00
parent 085e2d0518
commit 86647430de
7 changed files with 299 additions and 247 deletions

Binary file not shown.

Binary file not shown.

View File

@ -2,4 +2,4 @@ Manifest-Version: 1.0
Class-Path: BungeeCord.jar
Main-Class: net.ME1312.SubServers.Bungee.Launch
Implementation-Version: 2.11.2f
Specification-Version: 3
Specification-Version: 0

View File

@ -80,12 +80,12 @@ public class InternalSubLogger extends SubLogger {
// REGEX Formatting
String type = "";
Matcher matcher = Pattern.compile("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]?:?\\s*)").matcher(msg);
Matcher matcher = Pattern.compile("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARNING|WARN|ERROR|ERR|SEVERE)\\]?:?\\s*)").matcher(msg);
while (matcher.find()) {
type = matcher.group(3).toUpperCase();
}
msg = msg.replaceAll("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]?:?\\s*)", "");
msg = msg.replaceAll("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARNING|WARN|ERROR|ERR|SEVERE)\\]?:?\\s*)", "");
// Determine LOG LEVEL
switch (type) {

View File

@ -3,7 +3,6 @@ package net.ME1312.SubServers.Bungee;
import net.ME1312.SubServers.Bungee.Library.Container;
import net.ME1312.SubServers.Bungee.Library.Util;
import javax.swing.*;
import java.security.Security;
import java.text.SimpleDateFormat;
import java.util.Calendar;

View File

@ -31,7 +31,6 @@
<foreground color="-1"/>
<horizontalAlignment value="10"/>
<text value="&gt;"/>
<toolTipText value="Write a command here..."/>
</properties>
<clientProperties>
<html.disable class="java.lang.Boolean" value="true"/>
@ -80,7 +79,7 @@
</properties>
</component>
<grid id="35647" binding="find" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="6" left="6" bottom="0" right="6"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
@ -103,8 +102,9 @@
<properties>
<background color="-14144467"/>
<caretColor color="-2302756"/>
<font name="Courier" size="14"/>
<font size="14"/>
<foreground color="-1"/>
<text value=""/>
<toolTipText value="Search"/>
</properties>
<clientProperties>
@ -117,7 +117,11 @@
</constraints>
<properties>
<background color="-12236470"/>
<text value="Next"/>
<contentAreaFilled value="false"/>
<focusPainted value="false"/>
<foreground color="-1"/>
<opaque value="true"/>
<text value=" Next "/>
</properties>
</component>
<component id="b4434" class="javax.swing.JButton" binding="findP">
@ -126,7 +130,11 @@
</constraints>
<properties>
<background color="-12236470"/>
<text value="Previous"/>
<contentAreaFilled value="false"/>
<focusPainted value="false"/>
<foreground color="-1"/>
<opaque value="true"/>
<text value=" Previous "/>
</properties>
</component>
<component id="e6826" class="javax.swing.JButton" binding="findD">
@ -135,7 +143,10 @@
</constraints>
<properties>
<background color="-12236470"/>
<text value="Done"/>
<contentAreaFilled value="false"/>
<focusPainted value="false"/>
<foreground color="-1"/>
<text value=" Done "/>
</properties>
</component>
</children>

View File

@ -5,10 +5,10 @@ import net.ME1312.SubServers.Bungee.Host.SubLogger;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
@ -32,13 +32,11 @@ public class ConsoleWindow implements SubLogFilter {
private JButton findD;
private int findO = 0;
private int findI = 0;
private List<Runnable> events;
private boolean running = false;
private boolean open = false;
private SubLogger logger;
private KeyEventDispatcher keys = event -> {
if (window.isVisible() && window.isFocused()) {
if (event.getID() == KeyEvent.KEY_RELEASED) switch (event.getKeyCode()) {
if (event.getID() == KeyEvent.KEY_PRESSED) switch (event.getKeyCode()) {
case KeyEvent.VK_UP:
if (ifocus)
popup.prev(input);
@ -67,212 +65,248 @@ public class ConsoleWindow implements SubLogFilter {
public ConsoleWindow(ConsolePlugin plugin, SubLogger logger) {
this.plugin = plugin;
this.logger = logger;
this.events = new LinkedList<Runnable>();
events.add(() -> {
window = new JFrame();
window = new JFrame();
JMenuBar jMenu = new JMenuBar();
JMenu menu = new JMenu("View");
JMenuItem item = new JMenuItem("Scroll to Top");
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> vScroll.getVerticalScrollBar().setValue(0));
menu.add(item);
item = new JMenuItem("Scroll to Bottom");
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> vScroll.getVerticalScrollBar().setValue(vScroll.getVerticalScrollBar().getMaximum() - vScroll.getVerticalScrollBar().getVisibleAmount()));
menu.add(item);
item = new JMenuItem("Find");
item.setAccelerator(KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
if (find.isVisible()) {
find.setVisible(false);
findI = 0;
findO = 0;
} else {
find.setVisible(true);
findT.selectAll();
findT.requestFocusInWindow();
}
});
menu.add(item);
menu.addSeparator();
item = new JMenuItem("Reset Text Size");
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), 12));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
item = new JMenuItem("Bigger Text");
item.setAccelerator(KeyStroke.getKeyStroke('=', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), log.getFont().getSize() + 2));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
item = new JMenuItem("Smaller Text");
item.setAccelerator(KeyStroke.getKeyStroke('-', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), log.getFont().getSize() - 2));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
menu.addSeparator();
item = new JMenuItem("Clear Screen");
item.setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> clear());
menu.add(item);
item = new JMenuItem("Reload Log");
item.setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setText("\n");
for (SubLogger.LogMessage message : logger.getMessages()) log(message.getDate(), message.getLevel(), message.getMessage());
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
jMenu.add(menu);
window.setJMenuBar(jMenu);
window.setContentPane(panel);
window.pack();
window.setTitle(logger.getName() + " \u2014 SubServers 2");
window.setSize(1024, 576);
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
window.setLocation(x, y);
window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
close();
}
});
window.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
SwingUtilities.invokeLater(ConsoleWindow.this::hScroll);
}
});
vScroll.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45)));
new SmartScroller(vScroll, SmartScroller.VERTICAL, SmartScroller.END);
log.setText("\n");
log.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45)));
new TextFieldPopup(log, false);
((AbstractDocument) log.getDocument()).setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
super.insertString(fb, offset, string, attr);
hScroll();
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
super.replace(fb, offset, length, text, attrs);
hScroll();
}
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
super.remove(fb, offset, length);
hScroll();
}
});
popup = new TextFieldPopup(input, true);
input.setBorder(BorderFactory.createLineBorder(new Color(69, 73, 74)));
input.addActionListener((ActionEvent event) -> {
if (logger.getHandler() instanceof SubServer && input.getText().length() > 0 && !input.getText().equals(">")) {
if (((SubServer) logger.getHandler()).command((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText())) {
popup.commands.add((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText());
popup.current = 0;
popup.last = true;
input.setText("");
}
}
});
((AbstractDocument) input.getDocument()).setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
if (offset < 1) {
return;
}
super.insertString(fb, offset, string, attr);
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
if (offset < 1) {
length = Math.max(0, length - 1);
offset = 1;
}
super.replace(fb, offset, length, text, attrs);
}
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
if (offset < 1) {
length = Math.max(0, length + offset - 1);
offset = 1;
}
if (length > 0) {
super.remove(fb, offset, length);
}
}
});
input.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ifocus = true;
}
@Override
public void focusLost(FocusEvent e) {
ifocus = false;
}
});
vScroll.getHorizontalScrollBar().addAdjustmentListener(event -> {
if (!eScroll.contains(event.getValue())) {
eScroll.add(event.getValue());
hScroll.setValue(event.getValue());
} else {
eScroll.remove((Object) event.getValue());
}
});
hScroll.addAdjustmentListener(event -> {
if (!eScroll.contains(event.getValue())) {
eScroll.add(event.getValue());
vScroll.getHorizontalScrollBar().setValue(event.getValue());
} else {
eScroll.remove((Object) event.getValue());
}
});
new TextFieldPopup(findT, false);
findT.setBorder(BorderFactory.createLineBorder(new Color(69, 73, 74)));
findP.addActionListener(event -> find(false));
findN.addActionListener(event -> find(true));
findD.addActionListener(event -> {
JMenuBar jMenu = new JMenuBar();
JMenu menu = new JMenu("View");
JMenuItem item = new JMenuItem("Scroll to Top");
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> vScroll.getVerticalScrollBar().setValue(0));
menu.add(item);
item = new JMenuItem("Scroll to Bottom");
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> vScroll.getVerticalScrollBar().setValue(vScroll.getVerticalScrollBar().getMaximum() - vScroll.getVerticalScrollBar().getVisibleAmount()));
menu.add(item);
item = new JMenuItem("Find");
item.setAccelerator(KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
if (find.isVisible()) {
find.setVisible(false);
findI = 0;
findO = 0;
});
if (!(logger.getHandler() instanceof SubServer)) {
input.setVisible(false);
hScroll.setVisible(false);
vScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
} else {
find.setVisible(true);
findT.selectAll();
findT.requestFocusInWindow();
}
});
menu.add(item);
menu.addSeparator();
item = new JMenuItem("Reset Text Size");
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), 12));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
item = new JMenuItem("Bigger Text");
item.setAccelerator(KeyStroke.getKeyStroke('=', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), log.getFont().getSize() + 2));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
item = new JMenuItem("Smaller Text");
item.setAccelerator(KeyStroke.getKeyStroke('-', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setFont(new Font(log.getFont().getName(), log.getFont().getStyle(), log.getFont().getSize() - 2));
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
menu.addSeparator();
item = new JMenuItem("Clear Screen");
item.setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> clear());
menu.add(item);
item = new JMenuItem("Reload Log");
item.setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), true));
item.addActionListener(event -> {
log.setText("\n");
for (SubLogger.LogMessage message : logger.getMessages())
log(message.getDate(), message.getLevel(), message.getMessage());
SwingUtilities.invokeLater(this::hScroll);
});
menu.add(item);
jMenu.add(menu);
window.setJMenuBar(jMenu);
window.setContentPane(panel);
window.pack();
window.setTitle(logger.getName() + " \u2014 SubServers 2");
window.setSize(1024, 576);
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
window.setLocation(x, y);
window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
close();
}
});
window.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
SwingUtilities.invokeLater(ConsoleWindow.this::hScroll);
}
});
vScroll.setBorder(BorderFactory.createEmptyBorder());
new SmartScroller(vScroll, SmartScroller.VERTICAL, SmartScroller.END);
log.setText("\n");
log.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45)));
new TextFieldPopup(log, false);
((AbstractDocument) log.getDocument()).setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
super.insertString(fb, offset, string, attr);
hScroll();
}
logger.registerFilter(this);
for (SubLogger.LogMessage message : logger.getMessages()) log(message.getDate(), message.getLevel(), message.getMessage());
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keys);
events.add(() -> {
if (logger.isLogging() && !open) open();
});
hScroll();
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
super.replace(fb, offset, length, text, attrs);
hScroll();
}
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
super.remove(fb, offset, length);
hScroll();
}
});
runEvents();
popup = new TextFieldPopup(input, true);
input.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), 4));
input.addActionListener((ActionEvent event) -> {
if (logger.getHandler() instanceof SubServer && input.getText().length() > 0 && !input.getText().equals(">")) {
if (((SubServer) logger.getHandler()).command((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText())) {
popup.commands.add((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText());
popup.current = 0;
popup.last = true;
input.setText("");
}
}
});
((AbstractDocument) input.getDocument()).setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
if (offset < 1) {
return;
}
super.insertString(fb, offset, string, attr);
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
if (offset < 1) {
length = Math.max(0, length - 1);
offset = 1;
}
super.replace(fb, offset, length, text, attrs);
}
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
if (offset < 1) {
length = Math.max(0, length + offset - 1);
offset = 1;
}
if (length > 0) {
super.remove(fb, offset, length);
}
}
});
input.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ifocus = true;
}
@Override
public void focusLost(FocusEvent e) {
ifocus = false;
}
});
vScroll.getVerticalScrollBar().setBackground(new Color(69, 73, 74));
vScroll.getHorizontalScrollBar().setBackground(new Color(69, 73, 74));
vScroll.getHorizontalScrollBar().addAdjustmentListener(event -> {
if (!eScroll.contains(event.getValue())) {
eScroll.add(event.getValue());
hScroll.setValue(event.getValue());
} else {
eScroll.remove((Object) event.getValue());
}
});
hScroll.setBackground(new Color(69, 73, 74));
hScroll.addAdjustmentListener(event -> {
if (!eScroll.contains(event.getValue())) {
eScroll.add(event.getValue());
vScroll.getHorizontalScrollBar().setValue(event.getValue());
} else {
eScroll.remove((Object) event.getValue());
}
});
new TextFieldPopup(findT, false);
findT.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), 4));
((AbstractDocument) findT.getDocument()).setDocumentFilter(new DocumentFilter() {
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
super.insertString(fb, offset, string, attr);
findI = 0;
findO = 0;
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
super.replace(fb, offset, length, text, attrs);
findI = 0;
findO = 0;
}
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
super.remove(fb, offset, length);
findI = 0;
findO = 0;
}
});
findP.addChangeListener(e -> {
if (findP.getModel().isPressed()) findP.setBackground(new Color(40, 44, 45));
else findP.setBackground(new Color(69, 73, 74));
});
findP.setBorder(new ButtonBorder(40, 44, 45, 4));
findP.addActionListener(event -> find(false));
findN.addChangeListener(e -> {
if (findN.getModel().isPressed()) findN.setBackground(new Color(40, 44, 45));
else findN.setBackground(new Color(69, 73, 74));
});
findN.setBorder(new ButtonBorder(40, 44, 45, 4));
findN.addActionListener(event -> find(true));
findD.addChangeListener(e -> {
if (findD.getModel().isPressed()) findD.setBackground(new Color(40, 44, 45));
else findD.setBackground(new Color(69, 73, 74));
});
findD.setBorder(new ButtonBorder(40, 44, 45, 4));
findD.addActionListener(event -> {
find.setVisible(false);
findI = 0;
findO = 0;
});
if (!(logger.getHandler() instanceof SubServer)) {
input.setVisible(false);
hScroll.setVisible(false);
vScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
}
logger.registerFilter(this);
for (SubLogger.LogMessage message : logger.getMessages()) log(message.getDate(), message.getLevel(), message.getMessage());
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keys);
if (logger.isLogging() && !open) open();
SwingUtilities.invokeLater(this::hScroll);
}
private void hScroll() {
hScroll.setMaximum(vScroll.getHorizontalScrollBar().getMaximum());
@ -304,49 +338,18 @@ public class ConsoleWindow implements SubLogFilter {
SwingUtilities.invokeLater(this::hScroll);
}
public boolean runEvents() {
return runEvents(false);
}
private boolean runEvents(boolean force) {
if (events.size() > 0 && (force || !running)) {
try {
running = true;
final Runnable event = events.get(0);
if (event != null) {
SwingUtilities.invokeLater(() -> {
try {
event.run();
} catch (Throwable e) {
new InvocationTargetException(e, "Exception while running SubServers Console Window Event").printStackTrace();
}
events.remove(0);
if (!runEvents(true)) running = false;
});
} else {
events.remove(0);
if (!runEvents(true)) running = false;
}
return true;
} catch (NullPointerException e) {
return false;
}
} else return false;
}
@Override
public void start() {
open();
}
public void open() {
events.add(() -> {
SwingUtilities.invokeLater(() -> {
if (!open) {
window.setVisible(true);
this.open = true;
}
window.toFront();
});
runEvents();
}
public boolean isOpen() {
@ -358,7 +361,7 @@ public class ConsoleWindow implements SubLogFilter {
close();
}
public void close() {
events.add(() -> {
SwingUtilities.invokeLater(() -> {
if (open) {
this.open = false;
if (find.isVisible()) {
@ -370,7 +373,6 @@ public class ConsoleWindow implements SubLogFilter {
plugin.onClose(this);
}
});
runEvents();
}
public void destroy() {
@ -416,7 +418,7 @@ public class ConsoleWindow implements SubLogFilter {
} catch (BadLocationException e) {
findI = log.getText().length() - 1;
JOptionPane.showMessageDialog(window,
"There are no more results\nSearch again to start from the " + ((direction)?"top":"bottom"),
((findO > 0)?"There are no more results\nSearch again to start from the " + ((direction)?"top":"bottom"):"Couldn't find \"" + findT.getText() + "\""),
"Find",
JOptionPane.WARNING_MESSAGE);
}
@ -467,6 +469,21 @@ public class ConsoleWindow implements SubLogFilter {
menu.add(paste);
}
Action find = new TextAction("Find Selection") {
public void actionPerformed(ActionEvent e) {
JTextComponent field = getFocusedComponent();
if (field.getSelectedText() != null && field.getSelectedText().length() > 0) {
findT.setText(field.getSelectedText());
findI = 0;
findO = 0;
ConsoleWindow.this.find.setVisible(true);
find(true);
}
}
};
find.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + KeyEvent.SHIFT_MASK, true));
menu.add(find);
Action selectAll = new TextAction("Select All") {
public void actionPerformed(ActionEvent e) {
JTextComponent field = getFocusedComponent();
@ -628,4 +645,29 @@ public class ConsoleWindow implements SubLogFilter {
previousMaximum = maximum;
}
}
private class ButtonBorder implements Border {
private int radius;
private Color color;
public ButtonBorder(int red, int green, int blue, int radius) {
this.color = new Color(red, green, blue);
this.radius = radius;
}
public Insets getBorderInsets(Component c) {
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
}
public boolean isBorderOpaque() {
return true;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(color);
g.drawRoundRect(x, y, width-1, height-1, radius, radius);
}
}
}