/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.messaging.MessageHandler;
public class GoToPageDialog extends JDialog {
+ private Translator res;
+
JPanel panel1 = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JLabel pgNbLabel = new JLabel();
int pageNumber = -1;
- public GoToPageDialog(Frame frame, String title, boolean modal) {
+ public GoToPageDialog(Frame frame, String title, boolean modal, Translator resource) {
super(frame, title, modal);
try {
+ res = resource;
jbInit();
pack();
} catch (Exception ex) {
}
public GoToPageDialog() {
- this(null, "", false);
+ this(null, "", false, null);
}
void jbInit() throws Exception {
panel1.setLayout(gridBagLayout1);
- pgNbLabel.setText("Page number");
- okButton.setText("Ok");
+ pgNbLabel.setText(res.getString("Page number"));
+ okButton.setText(res.getString("Ok"));
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
- cancelButton.setText("Cancel");
+ cancelButton.setText(res.getString("Cancel"));
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
* Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
* Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
- * Doro Wiarda (wiarda@dwiarda.com:
- * added MessageListener support and made
- * the showing of the progress and error
- * messages Swing thread safe.
- * This is needed as xml parse errors do not
- * necessarily occur in the
- * EventDispatchThread.
+ * Doro Wiarda (wiarda@dwiarda.com):
+ * added MessageListener support and made the showing of the progress and error
+ * messages Swing thread safe. This is needed as xml parse errors do not
+ * necessarily occur in the EventDispatchThread.
*/
import java.awt.*;
protected JLabel zoomLabel =
new JLabel(); // {public float getAlignmentY() { return 0.0f; }};
+
protected JComboBox scale = new JComboBox() {
public float getAlignmentY() {
return 0.5f;
}
-
};
protected JScrollPane previewArea = new JScrollPane();
public void doit() {
print();
}
-
};
+
firstPageAction = new Command(res.getString("First page"),
"firstpg") {
public void doit() {
}
};
+
previousPageAction = new Command(res.getString("Previous page"),
"prevpg") {
public void doit() {
goToPreviousPage(null);
}
-
};
+
nextPageAction = new Command(res.getString("Next page"), "nextpg") {
public void doit() {
goToNextPage(null);
}
-
};
+
lastPageAction = new Command(res.getString("Last page"), "lastpg") {
public void doit() {
goToLastPage(null);
}
-
};
+
reloadAction = new Command(res.getString("Reload"), "reload") {
public void doit() {
reload(null);
}
-
};
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
public void actionPerformed(ActionEvent e) {
scale_actionPerformed(e);
}
-
});
scale.setSelectedItem("100");
public void doit() {
print();
}
-
});
menu.add(new Command(res.getString("Reload")) {
public void doit() {
reload(null);
}
-
});
menu.addSeparator();
menu.add(new Command(res.getString("Exit")) {
public void doit() {
dispose();
}
-
});
menuBar.add(menu);
menu = new JMenu(res.getString("View"));
public void doit() {
goToFirstPage(null);
}
-
});
menu.add(new Command(res.getString("Previous page")) {
public void doit() {
goToPreviousPage(null);
}
-
});
menu.add(new Command(res.getString("Next page")) {
public void doit() {
goToNextPage(null);
}
-
});
menu.add(new Command(res.getString("Last page")) {
public void doit() {
goToLastPage(null);
}
-
});
menu.add(new Command(res.getString("Go to Page") + " ...") {
public void doit() {
goToPage(null);
}
-
});
menu.addSeparator();
subMenu = new JMenu(res.getString("Zoom"));
public void doit() {
setScale(25.0);
}
-
});
subMenu.add(new Command("50%") {
public void doit() {
setScale(50.0);
}
-
});
subMenu.add(new Command("75%") {
public void doit() {
setScale(75.0);
}
-
});
subMenu.add(new Command("100%") {
public void doit() {
setScale(100.0);
}
-
});
subMenu.add(new Command("150%") {
public void doit() {
setScale(150.0);
}
-
});
subMenu.add(new Command("200%") {
public void doit() {
setScale(200.0);
}
-
});
menu.add(subMenu);
menu.addSeparator();
public void doit() {
setScale(100.0);
}
-
});
menuBar.add(menu);
menu = new JMenu(res.getString("Help"));
public void doit() {
startHelpAbout(null);
}
-
});
menuBar.add(menu);
return menuBar;
}
- // Aktion Hilfe | Info durchgeführt
-
/**
* Show the About box
*
goToPage(currentPage);
}
-
/**
* Shows the next page.
*/
* Shows the last page.
*/
private void goToLastPage(ActionEvent e) {
-
if (currentPage == pageCount - 1)
return;
currentPage = pageCount - 1;
-
goToPage(currentPage);
}
* Shows a page by number.
*/
private void goToPage(ActionEvent e) {
-
GoToPageDialog d = new GoToPageDialog(this,
res.getString("Go to Page"),
- true);
+ true,
+ res);
d.setLocation((int)getLocation().getX() + 50,
(int)getLocation().getY() + 50);
d.show();
private void print() {
PrinterJob pj = PrinterJob.getPrinterJob();
- // Nicht nötig, Pageable get a Printable.
+ // Not necessary, Pageable gets a Printable.
// pj.setPrintable(renderer);
pj.setPageable(renderer);
}
public void setScale(double scaleFactor) {
-
if (scaleFactor == 25.0)
scale.setSelectedIndex(0);
else if (scaleFactor == 50.0)
progress(new String(message + " " + percentage + "%"));
}
-
/**
* Setting the text of a JLabel is not thread save, it
* needs to be done in the EventThread. Here we make sure
SwingUtilities.invokeLater(new showProgress(message, false));
}
-
/**
* This class is used to show status and error messages in
* a thread safe way.
*/
class showProgress implements Runnable {
-
/**
* The message to display
*/
} else
processStatus.setText(message.toString());
}
-
}
public void showPage() {
SwingUtilities.invokeLater(viewer);
}
-
/**
* This class is used to update the page image
* in a thread safe way.
/**
* The run method that does the actuall updating
*/
+
public void run() {
BufferedImage pageImage = null;
Graphics graphics = null;
+ (currentPage + 1) + " "
+ res.getString("of") + " " + pageCount);
}
-
}
-
/**
* Called by MessageHandler if an error message or a
* log message is received.
String msg = res.getString("An exception has occured");
progress(msg);
JOptionPane.showMessageDialog(
- getContentPane(),
+ getContentPane(),
"<html><b>" + msg + ":</b><br>"
- + e.getClass().getName() + "<br>" + e.getMessage() + "</html>", res.getString("Fatal error"),
+ + e.getClass().getName() + "<br>" + e.getMessage() + "</html>", res.getString("Fatal error"),
JOptionPane.ERROR_MESSAGE
- );
+ );
}
} // class PreviewDialog
-
-
-
-