KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > environment > gui > behaviour > CommandPrintView


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.environment.gui.behaviour.CommandPrintView
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * it is not released as a seperate version.
10  * For AMODA, see http://amoda.berlios.de/.
11  *
12  * This is licensed under the GNU Lesser General Public License (LGPL)
13  * and comes with NO WARRANTY.
14  *
15  * Author: Jens Gulden
16  * Email: amoda@jensgulden.de
17  */

18
19 package de.gulden.framework.amoda.environment.gui.behaviour;
20
21 import de.gulden.framework.amoda.generic.behaviour.GenericCommand;
22 import java.util.*;
23
24 /**
25  * Class CommandPrintView.
26  *
27  * @author Jens Gulden
28  * @version snapshot-beautyj-1.1
29  */

30 public class CommandPrintView extends GenericCommand {
31
32     // ------------------------------------------------------------------------
33
// --- method ---
34
// ------------------------------------------------------------------------
35

36     public void perform() {
37         de.gulden.framework.amoda.model.document.DocumentView view=getApplication().getWorkspace().getActiveView();
38         if (view!=null) {
39             javax.swing.JComponent JavaDoc editorComponent=((de.gulden.framework.amoda.environment.gui.GUIWorkspace)getApplication().getWorkspace()).getGUIEditor(view);
40             java.awt.Component JavaDoc component=view.getGUIPrintView(editorComponent);
41             javax.swing.JFrame JavaDoc frame=((de.gulden.framework.amoda.environment.gui.GUIApplicationEnvironment)getApplication().getEnvironment()).getFrame();
42             java.awt.PrintJob JavaDoc pj=frame.getToolkit().getPrintJob(frame,view.getDocument().getTitle(),new java.util.Properties JavaDoc());
43             if (pj!=null) {
44                 java.awt.Graphics JavaDoc g=pj.getGraphics();
45                 component.print(g);
46                 g.dispose();
47                 pj.end();
48             }
49         } else {
50             getApplication().message("Please select a view to print.");
51         }
52     }
53
54 } // end CommandPrintView
55
Popular Tags