GT-3459 - Updated parentless dialogs to use a visible hidden parent

This commit is contained in:
dragonmacher 2020-01-17 18:51:32 -05:00
parent 6ae0c1ce23
commit e25c7d881a
9 changed files with 69 additions and 32 deletions

View file

@ -18,13 +18,16 @@ package docking;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import org.apache.commons.collections4.map.LazyMap;
import docking.framework.ApplicationInformationDisplayFactory;
import docking.help.HelpDescriptor;
import generic.util.WindowUtilities;
import ghidra.framework.Application;
import ghidra.util.bean.GGlassPane;
// NOTE: this class has a static focus component variable that is set whenever the dialog gets
@ -51,18 +54,39 @@ public class DockingDialog extends JDialog implements HelpDescriptor {
private WindowAdapter modalFixWindowAdapter;
/**
* Creates a default parent frame that will appear in the OS's task bar. Having this frame
* gives the user something to click when their dialog is lost. We attempt to hide this
* frame offscreen.
*
* Note: we expect to only get here when there is no parent window found. This usually
* only happens during tests and one-off main methods that are not part of a
* running tool.
*
* @param componentProvider the dialog content for this dialog
* @return the hidden frame
*/
private static JFrame createHiddenParentFrame(DialogComponentProvider componentProvider) {
HiddenDockingFrame frame = new HiddenDockingFrame(componentProvider.getTitle());
frame.setBounds(-500, -500, 10, 10);
// we currently don't support icons from DialogComponentProvider
// frame.setIconImage( ... )
//
// Note: we expect to only get here when there is no parent window found. This usually
// only happens during tests and one-off main methods that are not part of a
// running tool
//
HiddenDockingFrame hiddenFrame = new HiddenDockingFrame(Application.getName());
hiddenFrame.setShowingAllowed(true);
List<Image> list = ApplicationInformationDisplayFactory.getWindowIcons();
hiddenFrame.setIconImages(list);
hiddenFrame.setUndecorated(true);
hiddenFrame.setBounds(-500, -500, 10, 10);
// This prevents a window from showing in the taskbar; it is assumed that we the
// window to appear in the taskbar. If clients need this in the future, then we would
// have to make it a value on the DialogComponentProvider
// frame.setHidden( true ); // make invisible
return frame;
hiddenFrame.setVisible(true);
return hiddenFrame;
}
public static DockingDialog createDialog(Window parent, DialogComponentProvider comp,
@ -94,7 +118,7 @@ public class DockingDialog extends JDialog implements HelpDescriptor {
initializeLocationAndSize(centeredOnComponent);
}
public DockingDialog(DialogComponentProvider comp, Component centeredOnComponent) {
private DockingDialog(DialogComponentProvider comp, Component centeredOnComponent) {
super(createHiddenParentFrame(comp), comp.getTitle(), comp.isModal());
init(comp);
initializeLocationAndSize(centeredOnComponent);

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,13 +23,23 @@ package docking;
*/
public class HiddenDockingFrame extends DockingFrame {
private boolean showingAllowed;
public HiddenDockingFrame(String name) {
super(name);
}
@Override
void setShowingAllowed(boolean showingAllowed) {
this.showingAllowed = showingAllowed;
}
@SuppressWarnings("deprecation")
@Override
public void show() {
// overridden to make sure nobody ever sees this frame when it's hidden
// overridden to make sure only some clients can show this frame
if (showingAllowed) {
super.show();
}
}
}

View file

@ -16,7 +16,6 @@
package docking.framework;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
@ -33,14 +32,16 @@ import utility.module.ModuleUtilities;
*/
public class DockingApplicationLayout extends ApplicationLayout {
private static final String NO_RELEASE_NAME = "NO_RELEASE";
/**
* Constructs a new docking application layout object with the given name.
*
* @param name The name of the application.
* @throws FileNotFoundException if there was a problem getting a user directory.
*/
public DockingApplicationLayout(String name) throws FileNotFoundException, IOException {
this(name, null);
public DockingApplicationLayout(String name) throws FileNotFoundException {
this(name, "0.1");
}
/**
@ -51,7 +52,7 @@ public class DockingApplicationLayout extends ApplicationLayout {
* @throws FileNotFoundException if there was a problem getting a user directory.
*/
public DockingApplicationLayout(String name, String version) throws FileNotFoundException {
this(new ApplicationProperties(name, version));
this(new ApplicationProperties(name, version, NO_RELEASE_NAME));
}
/**

View file

@ -344,8 +344,9 @@ public class SplashScreen extends JWindow {
}
public static void main(String[] args) throws Exception {
ApplicationLayout layout = new DockingApplicationLayout("SplashScreen");
ApplicationLayout layout = new DockingApplicationLayout("Splash Screen Main", "1.0");
DockingApplicationConfiguration config = new DockingApplicationConfiguration();
config.setShowSplashScreen(false);
Application.initializeApplication(layout, config);
showSplashScreen();