Merge pull request #2415 from Owain94/alwaysontop

alwaysontop: Always set a parent component to prevent components from rendering behind the main panel
This commit is contained in:
Owain van Brakel
2020-03-08 01:09:34 +01:00
committed by GitHub
5 changed files with 64 additions and 61 deletions

View File

@@ -8,11 +8,41 @@ import com.google.inject.CreationException;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import static net.runelite.client.RuneLite.EXTERNALPLUGIN_DIR;
import static net.runelite.client.RuneLite.SYSTEM_VERSION;
import net.runelite.client.RuneLiteProperties; import net.runelite.client.RuneLiteProperties;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
@@ -20,6 +50,7 @@ import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.ExternalPluginChanged; import net.runelite.client.events.ExternalPluginChanged;
import net.runelite.client.events.ExternalRepositoryChanged; import net.runelite.client.events.ExternalRepositoryChanged;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.RuneLiteSplashScreen; import net.runelite.client.ui.RuneLiteSplashScreen;
import net.runelite.client.util.MiscUtils; import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.SwingUtil;
@@ -41,36 +72,6 @@ import org.pf4j.update.PluginInfo;
import org.pf4j.update.UpdateManager; import org.pf4j.update.UpdateManager;
import org.pf4j.update.UpdateRepository; import org.pf4j.update.UpdateRepository;
import org.pf4j.update.VerifyException; import org.pf4j.update.VerifyException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static net.runelite.client.RuneLite.EXTERNALPLUGIN_DIR;
import static net.runelite.client.RuneLite.SYSTEM_VERSION;
@Slf4j @Slf4j
@Singleton @Singleton
@@ -474,7 +475,7 @@ class ExternalPluginManager
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Plugin instantiate(List<Plugin> scannedPlugins, Class<Plugin> clazz, boolean init, boolean initConfig) private Plugin instantiate(List<Plugin> scannedPlugins, Class<Plugin> clazz, boolean init, boolean initConfig)
throws PluginInstantiationException throws PluginInstantiationException
{ {
net.runelite.client.plugins.PluginDependency[] pluginDependencies = net.runelite.client.plugins.PluginDependency[] pluginDependencies =
clazz.getAnnotationsByType(net.runelite.client.plugins.PluginDependency.class); clazz.getAnnotationsByType(net.runelite.client.plugins.PluginDependency.class);
@@ -752,7 +753,7 @@ class ExternalPluginManager
try try
{ {
SwingUtil.syncExec(() -> SwingUtil.syncExec(() ->
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(ClientUI.getFrame(),
pluginId + " is outdated and cannot be installed", pluginId + " is outdated and cannot be installed",
"Installation error", "Installation error",
JOptionPane.ERROR_MESSAGE)); JOptionPane.ERROR_MESSAGE));

View File

@@ -1,19 +1,5 @@
package net.runelite.client.plugins.openosrs.externals; package net.runelite.client.plugins.openosrs.externals;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.ExternalPluginManager;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.ImageUtil;
import javax.inject.Inject;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@@ -23,6 +9,21 @@ import java.awt.image.BufferedImage;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.ExternalPluginManager;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.ImageUtil;
public class ExternalPluginManagerPanel extends PluginPanel public class ExternalPluginManagerPanel extends PluginPanel
{ {
@@ -102,7 +103,7 @@ public class ExternalPluginManagerPanel extends PluginPanel
}; };
int option = int option =
JOptionPane.showConfirmDialog(null, message, "Add repository", JOptionPane.OK_CANCEL_OPTION); JOptionPane.showConfirmDialog(ClientUI.getFrame(), message, "Add repository", JOptionPane.OK_CANCEL_OPTION);
if (option != JOptionPane.OK_OPTION || owner.getText().equals("") || name.getText().equals("")) if (option != JOptionPane.OK_OPTION || owner.getText().equals("") || name.getText().equals(""))
{ {
return; return;
@@ -110,14 +111,14 @@ public class ExternalPluginManagerPanel extends PluginPanel
if (externalPluginManager.doesGhRepoExist(owner.getText(), name.getText())) if (externalPluginManager.doesGhRepoExist(owner.getText(), name.getText()))
{ {
JOptionPane.showMessageDialog(null, "This repository already exists.", "Error!", JOptionPane.showMessageDialog(ClientUI.getFrame(), "This repository already exists.", "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
} }
if (ExternalPluginManager.testGHRepository(owner.getText(), name.getText())) if (ExternalPluginManager.testGHRepository(owner.getText(), name.getText()))
{ {
JOptionPane.showMessageDialog(null, "This doesn't appear to be a valid repository.", "Error!", JOptionPane.showMessageDialog(ClientUI.getFrame(), "This doesn't appear to be a valid repository.", "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
} }
@@ -153,7 +154,7 @@ public class ExternalPluginManagerPanel extends PluginPanel
}; };
int option = int option =
JOptionPane.showConfirmDialog(null, message, "Add repository", JOptionPane.OK_CANCEL_OPTION); JOptionPane.showConfirmDialog(ClientUI.getFrame(), message, "Add repository", JOptionPane.OK_CANCEL_OPTION);
if (option != JOptionPane.OK_OPTION || id.getText().equals("") || url.getText().equals("")) if (option != JOptionPane.OK_OPTION || id.getText().equals("") || url.getText().equals(""))
{ {
return; return;
@@ -161,7 +162,7 @@ public class ExternalPluginManagerPanel extends PluginPanel
if (id.getText().startsWith("gh:") || id.getText().contains("|")) if (id.getText().startsWith("gh:") || id.getText().contains("|"))
{ {
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(ClientUI.getFrame(),
"Repository id cannot begin with \"gh:\"\nor contain the pipe character '|'.", "Error!", "Repository id cannot begin with \"gh:\"\nor contain the pipe character '|'.", "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
@@ -169,7 +170,7 @@ public class ExternalPluginManagerPanel extends PluginPanel
if (externalPluginManager.doesRepoExist(id.getText())) if (externalPluginManager.doesRepoExist(id.getText()))
{ {
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(ClientUI.getFrame(),
String.format("The repository with id %s already exists.", id.getText()), "Error!", String.format("The repository with id %s already exists.", id.getText()), "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
@@ -182,14 +183,14 @@ public class ExternalPluginManagerPanel extends PluginPanel
} }
catch (MalformedURLException e) catch (MalformedURLException e)
{ {
JOptionPane.showMessageDialog(null, "This doesn't appear to be a valid repository.", "Error!", JOptionPane.showMessageDialog(ClientUI.getFrame(), "This doesn't appear to be a valid repository.", "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
} }
if (ExternalPluginManager.testRepository(urlActual)) if (ExternalPluginManager.testRepository(urlActual))
{ {
JOptionPane.showMessageDialog(null, "This doesn't appear to be a valid repository.", "Error!", JOptionPane.showMessageDialog(ClientUI.getFrame(), "This doesn't appear to be a valid repository.", "Error!",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
} }

View File

@@ -36,6 +36,7 @@ import net.runelite.client.events.ExternalPluginChanged;
import net.runelite.client.events.ExternalRepositoryChanged; import net.runelite.client.events.ExternalRepositoryChanged;
import net.runelite.client.plugins.ExternalPluginManager; import net.runelite.client.plugins.ExternalPluginManager;
import static net.runelite.client.plugins.openosrs.externals.ExternalPluginManagerPanel.wrapContainer; import static net.runelite.client.plugins.openosrs.externals.ExternalPluginManagerPanel.wrapContainer;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
@@ -256,7 +257,7 @@ public class PluginsPanel extends JPanel
if (availablePlugins == null || plugins == null) if (availablePlugins == null || plugins == null)
{ {
JOptionPane.showMessageDialog(null, "The external plugin list could not be loaded.", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(ClientUI.getFrame(), "The external plugin list could not be loaded.", "Error", JOptionPane.ERROR_MESSAGE);
return; return;
} }
@@ -464,7 +465,7 @@ public class PluginsPanel extends JPanel
{ {
if (hideAction) if (hideAction)
{ {
JOptionPane.showMessageDialog(null, "This plugin can't be uninstalled because one or more other plugins have a dependency on it.", "Error!", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(ClientUI.getFrame(), "This plugin can't be uninstalled because one or more other plugins have a dependency on it.", "Error!", JOptionPane.ERROR_MESSAGE);
} }
else else
{ {
@@ -572,7 +573,7 @@ public class PluginsPanel extends JPanel
try try
{ {
SwingUtil.syncExec(() -> SwingUtil.syncExec(() ->
JOptionPane.showMessageDialog(null, pluginInfo.name + " could not be installed, the hash could not be verified.", "Error!", JOptionPane.ERROR_MESSAGE)); JOptionPane.showMessageDialog(ClientUI.getFrame(), pluginInfo.name + " could not be installed, the hash could not be verified.", "Error!", JOptionPane.ERROR_MESSAGE));
} }
catch (InvocationTargetException | InterruptedException ignored) catch (InvocationTargetException | InterruptedException ignored)
{ {

View File

@@ -29,7 +29,6 @@ import java.applet.Applet;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -65,13 +64,13 @@ final class ClientPanel extends JPanel
{ {
String message = "Detected a bad codebase. Resetting...\n" String message = "Detected a bad codebase. Resetting...\n"
+ "Please restart client.\n"; + "Please restart client.\n";
JOptionPane.showMessageDialog(new JFrame(), message, "Bad Codebase", JOptionPane.showMessageDialog(ClientUI.getFrame(), message, "Bad Codebase",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
StringFileUtils.writeStringToFile(RuneLite.RUNELITE_DIR + "/codebase", "http://127.0.0.1/"); StringFileUtils.writeStringToFile(RuneLite.RUNELITE_DIR + "/codebase", "http://127.0.0.1/");
} }
else else
{ {
JOptionPane.showMessageDialog(new JFrame(), "Error loading Oldschool RuneScape!", "Error", JOptionPane.showMessageDialog(ClientUI.getFrame(), "Error loading Oldschool RuneScape!", "Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
Sentry.capture(e); Sentry.capture(e);
} }

View File

@@ -36,6 +36,7 @@ import javax.inject.Singleton;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.ui.ClientUI;
/** /**
* Utility class used for web and file browser navigation * Utility class used for web and file browser navigation
@@ -249,7 +250,7 @@ public class LinkBrowser
{ {
SwingUtilities.invokeLater(() -> SwingUtilities.invokeLater(() ->
{ {
final int result = JOptionPane.showConfirmDialog(null, message, "Message", final int result = JOptionPane.showConfirmDialog(ClientUI.getFrame(), message, "Message",
JOptionPane.OK_CANCEL_OPTION); JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION) if (result == JOptionPane.OK_OPTION)