mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 06:27:59 -05:00
Merge remote-tracking branch 'origin/GP-6044-dragonmacher-log-viewer-to-frame'
This commit is contained in:
@@ -1186,6 +1186,12 @@
|
||||
|
||||
<P>The field next to the icon in the Ghidra Project Window shows the last message sent to the
|
||||
console (error messages are in red). </P>
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<P><IMG src="help/shared/tip.png" border="0">You can copy log messages from the log viewer
|
||||
window by using <CODE>Ctrl-C</CODE>.
|
||||
</P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
</BLOCKQUOTE>
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||
private DefaultLaunchMode defaultLaunchMode = DefaultLaunchMode.DEFAULT;
|
||||
|
||||
private ComponentProvider compProvider;
|
||||
private LogComponentProvider logProvider;
|
||||
private LogWindow logWindow;
|
||||
|
||||
private WindowListener windowListener;
|
||||
private DockingAction configureToolAction;
|
||||
@@ -169,8 +169,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
if (logProvider != null) {
|
||||
logProvider.dispose();
|
||||
if (logWindow != null) {
|
||||
logWindow.dispose();
|
||||
}
|
||||
shutdown();
|
||||
}
|
||||
@@ -844,7 +844,9 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||
|
||||
@Override
|
||||
public boolean canCloseDomainFile(DomainFile df) {
|
||||
PluginTool[] tools = getProject().getToolManager().getRunningTools();
|
||||
Project project = getProject();
|
||||
ToolManager toolManager = project.getToolManager();
|
||||
PluginTool[] tools = toolManager.getRunningTools();
|
||||
for (PluginTool tool : tools) {
|
||||
DomainFile[] files = tool.getDomainFiles();
|
||||
for (DomainFile domainFile : files) {
|
||||
@@ -862,59 +864,62 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||
return;// something odd is going on; can't find log file
|
||||
}
|
||||
|
||||
if (logProvider == null) {
|
||||
logProvider = new LogComponentProvider(this, logFile);
|
||||
showDialog(logProvider);
|
||||
if (logWindow == null) {
|
||||
logWindow = new LogWindow(logFile);
|
||||
JFrame toolFrame = getToolFrame();
|
||||
Point center = WindowUtilities.centerOnComponent(toolFrame, logWindow);
|
||||
logWindow.setLocation(center);
|
||||
logWindow.setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (logProvider.isShowing()) {
|
||||
logProvider.toFront();
|
||||
}
|
||||
else {
|
||||
showDialog(logProvider, getToolFrame());
|
||||
}
|
||||
logWindow.setVisible(true);
|
||||
logWindow.toFront();
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Inner Classes
|
||||
//==================================================================================================
|
||||
|
||||
private static class LogComponentProvider extends ReusableDialogComponentProvider {
|
||||
private class LogWindow extends JFrame {
|
||||
|
||||
private static final Dimension DEFAULT_SIZE = new Dimension(600, 400);
|
||||
|
||||
private final File logFile;
|
||||
private Dimension defaultSize = new Dimension(600, 400);
|
||||
|
||||
private FileWatcher watcher;
|
||||
|
||||
LogComponentProvider(PluginTool tool, File logFile) {
|
||||
super("Ghidra User Log", false, false, false, false);
|
||||
LogWindow(File logFile) {
|
||||
setTitle("Ghidra User Log");
|
||||
|
||||
JFrame toolFrame = getToolFrame();
|
||||
setIconImage(toolFrame.getIconImage());
|
||||
|
||||
this.logFile = logFile;
|
||||
|
||||
addWorkPanel(buildWorkPanel());
|
||||
}
|
||||
JPanel panel = buildWorkPanel();
|
||||
getContentPane().add(panel);
|
||||
|
||||
/**
|
||||
* Need to override this method so we can stop the file watcher when the
|
||||
* dialog is closed.
|
||||
*/
|
||||
@Override
|
||||
protected void dialogClosed() {
|
||||
if (watcher != null) {
|
||||
watcher.stop();
|
||||
}
|
||||
}
|
||||
HelpService help = Help.getHelpService();
|
||||
help.registerHelp(panel, new HelpLocation("FrontEndPlugin", "StatusWindow"));
|
||||
|
||||
/**
|
||||
* Need to override this method so we can stop the file watcher when the
|
||||
* dialog is closed.
|
||||
*/
|
||||
@Override
|
||||
protected void dialogShown() {
|
||||
if (watcher != null) {
|
||||
watcher.start();
|
||||
}
|
||||
addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
if (watcher != null) {
|
||||
watcher.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
if (watcher != null) {
|
||||
watcher.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
private JPanel buildWorkPanel() {
|
||||
@@ -922,7 +927,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||
JPanel panel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return defaultSize;
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -55,7 +55,16 @@ public class LogPanel extends JPanel implements LogListener {
|
||||
super(new BorderLayout());
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(8, 4, 4, 2));
|
||||
|
||||
button = new EmptyBorderButton(new GIcon("icon.console"));
|
||||
button.setPreferredSize(new Dimension(24, 24));
|
||||
button.setFocusable(false);
|
||||
button.setToolTipText("Show Console (Refresh Open Console)");
|
||||
button.addActionListener(e -> {
|
||||
FrontEndTool tool = (FrontEndTool) plugin.getTool();
|
||||
tool.showGhidraUserLogFile();
|
||||
});
|
||||
|
||||
label = new GDLabel();
|
||||
label.setName("Details");
|
||||
panel.add(label, BorderLayout.CENTER);
|
||||
@@ -69,14 +78,6 @@ public class LogPanel extends JPanel implements LogListener {
|
||||
BorderFactory.createLoweredBevelBorder());
|
||||
label.setBorder(b);
|
||||
|
||||
button.setPreferredSize(new Dimension(24, 24));
|
||||
button.setFocusable(false);
|
||||
button.setToolTipText("Show Console (Refresh Open Console)");
|
||||
button.addActionListener(e -> {
|
||||
FrontEndTool tool = (FrontEndTool) plugin.getTool();
|
||||
tool.showGhidraUserLogFile();
|
||||
});
|
||||
|
||||
addLogAppender();
|
||||
add(panel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user