View Javadoc

1   package com.explosion.expfmodules.fileutils;
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.util.Hashtable;
23  import java.util.Properties;
24  import java.util.Vector;
25  
26  import javax.swing.JPanel;
27  
28  import com.explosion.expf.Application;
29  import com.explosion.expf.ExpActionListener;
30  import com.explosion.expf.ExpConstants;
31  import com.explosion.expf.ExpFrame;
32  import com.explosion.expf.ExpModuleManager;
33  import com.explosion.expf.menusandtools.menu.ExpMenu;
34  import com.explosion.expf.menusandtools.menu.ExpMenuBar;
35  import com.explosion.expf.menusandtools.menu.MenuHelper;
36  import com.explosion.expf.menusandtools.menu.segmented.ExpMenuSegment;
37  import com.explosion.expf.preferences.SystemPreferences;
38  import com.explosion.utilities.preferences.Preference;
39  
40  /***
41   * Author: Stephen Cowx
42   * Date: Dec 9, 2002
43   * Time: 11:48:47 PM
44   */
45  
46  public class FileUtilsModuleManager implements ExpModuleManager
47  {
48    private Vector preferences = new Vector();
49    private Hashtable preferenceHash = new Hashtable();
50    private static FileUtilsModuleManager instance = null;
51    private ExpActionListener globalActionListener = null;
52    
53    /* Open connections menusegment */
54    ExpMenu menuSplitFiles = null; 
55    ExpMenuBar menuBar = null; 
56    ExpMenu menuUtils = null;
57    
58    public FileUtilsModuleManager()
59    {
60    	instance = this;
61    }
62    
63    public void initialiseGui() throws Exception
64    {
65    	menuBar = ((ExpFrame) Application.getApplicationFrame()).getExpMenuBar();
66      menuUtils 			= menuBar.createExpMenu("Utils", 'u', FileUtilsConstants.MENU_FILE_UTILS, 1, true);
67      
68      MenuHelper helper = menuBar.getMenuHelper();
69  
70      /* Connections menu */
71      ExpMenuSegment connectionsSegment = menuUtils.createNewSegment(ExpMenuSegment.ANY_POSITION);
72      connectionsSegment.addElement(helper.createMenuItem("Split Files", 's', FileUtilsConstants.MENU_FILE_SPLIT, null,1));
73      connectionsSegment.addElement(helper.createMenuItem("Unsplit Files", 'u', FileUtilsConstants.MENU_FILE_UNSPLIT, null,1));
74      
75      
76    	/* Add a cookie to the File >> New menu*/
77      Application.addToGlobalCookie(FileUtilsConstants.MENU_FILE_SPLIT,1);
78      Application.addToGlobalCookie(FileUtilsConstants.MENU_FILE_UNSPLIT,1);
79      Application.addToGlobalCookie(FileUtilsConstants.MENU_FILE_UTILS,1);
80      globalActionListener = new FileUtilsListener();
81    }
82  
83    public String getVersion()
84    {
85      return "1.0";
86    }
87  
88    public String getName()
89    {
90      return "File Utilities";
91    }
92  
93    public String getDescription()
94    {
95      return "A set of utilities for operations on files.";
96    }
97  
98    public void initialiseCore(Properties properties)
99    {
100     try
101     {
102       //Preferences prefs = Preferences.userRoot().node(getPreferenceRoot());
103       
104       
105     }
106     catch (Exception e)
107     {
108       com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, "Exception caught while initialising the Text Editor module.");
109     }
110   }
111 
112   public Vector getPreferences()
113   {
114     return preferences;
115   }
116   
117   public ExpActionListener getGlobalListener()
118   {
119   	return globalActionListener;
120   }
121 
122 
123   public Preference getPreference(String preferenceName)
124   {
125   	return (Preference) preferenceHash.get(preferenceName);
126   }
127   
128   public JPanel getPreferencesEditor()
129   {
130     return null;
131   }
132   
133   public static FileUtilsModuleManager instance()
134   {
135     return instance;
136   }
137   
138   public String getPreferenceRoot()
139   {
140     return (String) SystemPreferences.getPreference(ExpConstants.EXPF_APP_PREFIX).getValue()+"/fileutils";
141   }
142 
143 }