View Javadoc

1   package com.explosion.expf.supportmodules;
2   
3   /* =============================================================================
4    *       
5    *     Copyright 2004 Stephen Cowx
6    *
7    *     Licensed under the Apache License, Version 2.0 (the "License");
8    *     you may not use this file except in compliance with the License.
9    *     You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *     Unless required by applicable law or agreed to in writing, software
14   *     distributed under the License is distributed on an "AS IS" BASIS,
15   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *     See the License for the specific language governing permissions and
17   *     limitations under the License.
18   * 
19   * =============================================================================
20   */
21  
22  import java.awt.event.KeyEvent;
23  import java.util.Hashtable;
24  import java.util.Properties;
25  import java.util.Vector;
26  
27  import javax.swing.JButton;
28  import javax.swing.JPanel;
29  import javax.swing.KeyStroke;
30  
31  import com.explosion.expf.Application;
32  import com.explosion.expf.ExpActionListener;
33  import com.explosion.expf.ExpConstants;
34  import com.explosion.expf.ExpFrame;
35  import com.explosion.expf.ExpModuleManager;
36  import com.explosion.expf.menusandtools.menu.ExpMenu;
37  import com.explosion.expf.menusandtools.menu.ExpMenuBar;
38  import com.explosion.expf.menusandtools.menu.MenuHelper;
39  import com.explosion.expf.menusandtools.menu.segmented.ExpMenuSegment;
40  import com.explosion.expf.menusandtools.tool.ExpToolBar;
41  import com.explosion.expf.menusandtools.tool.ExpToolBarSegment;
42  import com.explosion.utilities.preferences.Preference;
43  
44  /***
45   * @author Stephen Cowx
46   * Date created:@08-Feb-2003
47   */
48  public class PrintSupportModule implements ExpModuleManager
49  {
50    private Vector preferences;
51    private Hashtable preferenceHash;
52    private PrintSupportModule instance;
53    
54    public PrintSupportModule()
55    {
56    	instance = this;
57    }
58    
59    public void initialiseGui() throws Exception
60    {
61      ExpMenuBar menuBar = ((ExpFrame) Application.getApplicationFrame()).getExpMenuBar();
62      MenuHelper helper = menuBar.getMenuHelper();
63      ExpMenu menuFile = (ExpMenu) helper.getMenu(ExpConstants.MENU_FILE);
64      
65      /* File menu */
66      ExpMenuSegment printSegment = menuFile.createNewSegment(ExpMenuSegment.ANY_POSITION);
67      printSegment.addElement(helper.createMenuItem("Print",'p',ExpConstants.MENU_PRINT,KeyStroke.getKeyStroke(KeyEvent.VK_P,KeyEvent.CTRL_MASK),1));
68      //printSegment.addElement(menuBar.createMenuItem("Page setup",'u',ExpConstants.MENU_PRINTSETUP,null,1));
69          
70      /* Toolbar buttons */
71      ExpToolBar toolbar = ((ExpFrame) Application.getApplicationFrame()).getExpToolBar();
72      ExpToolBarSegment printsegment = toolbar.createNewSegment(ExpToolBarSegment.ANY_POSITION);
73  
74      JButton printButton   = toolbar.createExpToolBarItem(ExpConstants.DEFAULT_PRINT_ICON   ,"Print",ExpConstants.MENU_PRINT,1);
75      
76      printsegment.addElement(printButton);
77      
78    }
79  
80    public String getVersion()
81    {
82      return "1.0";
83    }
84  
85    public String getName()
86    {
87      return "Print Support";
88    }
89  
90    public String getDescription()
91    {
92      return "Menu and toolbar support for printing.";
93    }
94   
95    public void initialiseCore(Properties properties)
96    {
97    }
98  
99    public Vector getPreferences()
100   {
101     return preferences;
102   }
103   
104   public Preference getPreference(String preferenceName)
105   {
106   	return (Preference) preferenceHash.get(preferenceName);
107   }
108 
109   public JPanel getPreferencesEditor()
110   {
111     return null;
112   }
113   
114   public ExpActionListener getGlobalListener()
115   {
116   	return null;
117   }
118     
119 }