aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-07-10 20:15:17 +0000
committerJeremias Maerki <jeremias@apache.org>2006-07-10 20:15:17 +0000
commita383b3f433d5e577cb6fb2d851da0f28fc4a9eb3 (patch)
treecfb0c99df44c7e9604463d5563aa6fa255632e20
parentdd300009bbdb72312530097d424fd9836466b6ef (diff)
downloadxmlgraphics-fop-a383b3f433d5e577cb6fb2d851da0f28fc4a9eb3.tar.gz
xmlgraphics-fop-a383b3f433d5e577cb6fb2d851da0f28fc4a9eb3.zip
Bugzilla #39983:
Moved the setting of the system look&feel to CommandLineOptions. Shouldn't really be in PreviewDialog.java. Added a parameter to createPreviewDialog() so embedders don't get a System.exit() when the user closes the preview dialog. System.exit() may only be called if the preview dialog is the main window. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@420626 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/cli/CommandLineOptions.java12
-rw-r--r--src/java/org/apache/fop/render/awt/AWTRenderer.java17
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java22
3 files changed, 35 insertions, 16 deletions
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java
index fb93a060e..9fc2d5c52 100644
--- a/src/java/org/apache/fop/cli/CommandLineOptions.java
+++ b/src/java/org/apache/fop/cli/CommandLineOptions.java
@@ -25,6 +25,8 @@ import java.io.IOException;
import java.util.Locale;
import java.util.Vector;
+import javax.swing.UIManager;
+
import org.apache.fop.Version;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
@@ -153,7 +155,15 @@ public class CommandLineOptions {
inputHandler = createInputHandler();
if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) {
- AWTRenderer renderer = new AWTRenderer();
+ //set the system look&feel for the preview dialog
+ try {
+ if (false) UIManager.setLookAndFeel(
+ UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+ System.err.println("Couldn't set system look & feel!");
+ }
+
+ AWTRenderer renderer = new AWTRenderer(true);
renderer.setRenderable(inputHandler); //set before user agent!
renderer.setUserAgent(foUserAgent);
foUserAgent.setRendererOverride(renderer);
diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java
index a52e75470..6766d4809 100644
--- a/src/java/org/apache/fop/render/awt/AWTRenderer.java
+++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java
@@ -61,6 +61,9 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
/** If true, preview dialog is shown. */
public boolean dialogDisplay = true;
+ /** true if the preview dialog should be the main window of the application */
+ private boolean previewAsMainWindow;
+
/**
* Renderable instance that can be used to reload and re-render a document after
* modifications.
@@ -71,18 +74,30 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
* Will be notified when rendering progresses
*/
protected StatusListener statusListener = null;
+
/**
* Creates a new AWTRenderer instance.
*/
public AWTRenderer() {
+ this(false);
+ }
+
+ /**
+ * Creates a new AWTRenderer instance.
+ * @param previewAsMainWindow true if the preview dialog created by the renderer should be
+ * the main window of the application.
+ */
+ public AWTRenderer(boolean previewAsMainWindow) {
+ this.previewAsMainWindow = previewAsMainWindow;
}
/** @see org.apache.fop.render.Renderer#setUserAgent(org.apache.fop.apps.FOUserAgent) */
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);
if (dialogDisplay) {
- setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable));
+ setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable,
+ this.previewAsMainWindow));
}
}
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
index 31221664f..4851cd8c5 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
@@ -149,14 +149,6 @@ public class PreviewDialog extends JFrame implements StatusListener {
}
};
- //set the system look&feel
- try {
- UIManager.setLookAndFeel(
- UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- System.err.println("Couldn't set system look & feel!");
- }
-
setTitle("FOP: AWT-" + translator.getString("Title.Preview"));
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@@ -248,14 +240,16 @@ public class PreviewDialog extends JFrame implements StatusListener {
* @return the newly initialized preview dialog
*/
public static PreviewDialog createPreviewDialog(FOUserAgent foUserAgent,
- Renderable renderable) {
+ Renderable renderable, boolean asMainWindow) {
PreviewDialog frame = new PreviewDialog(foUserAgent, renderable);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosed(WindowEvent we) {
- System.exit(0);
- }
- });
+ if (asMainWindow) {
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent we) {
+ System.exit(0);
+ }
+ });
+ }
// Centers the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();