1 30 31 package com.genimen.djeneric.tools.menu; 32 33 import java.awt.AWTEvent ; 34 import java.awt.BorderLayout ; 35 import java.awt.Dimension ; 36 import java.awt.Image ; 37 import java.awt.Toolkit ; 38 import java.awt.event.WindowEvent ; 39 import java.net.URL ; 40 41 import javax.swing.JPanel ; 42 43 import com.genimen.djeneric.language.Messages; 44 import com.genimen.djeneric.tools.common.DjenericTool; 45 import com.genimen.djeneric.util.DjEnvironment; 46 import com.genimen.djeneric.util.DjLogger; 47 import com.genimen.djeneric.util.DjVersion; 48 49 52 public class Menu extends DjenericTool 53 { 54 private static final long serialVersionUID = 1L; 55 private final String PROPERTIES_FILE_NAME = DjEnvironment.getAbsoluteFileName("menu.properties"); 56 57 final static String TOOL_VM_OPTIONS = "tool.vmoptions"; 58 final static String TOOL_LANGUAGE = "tool.language"; 59 final static String TOOL_PROTOTYPING = "tool.prototyping"; 60 final static String TOOL_STRIPSPACES = "tool.stripspaces"; 61 final static String MENU_RECENTDBS = "menu.recentdbs"; 62 63 String _repositoriesFile; 64 65 public Menu(String repositoriesFile) 66 { 67 enableEvents(AWTEvent.WINDOW_EVENT_MASK); 68 loadProps(PROPERTIES_FILE_NAME); 69 70 String language = getProperty(Menu.TOOL_LANGUAGE, ""); 71 if (language.trim().length() > 0) System.setProperty(Messages.DJENERIC_LANGUAGE, language); 72 Messages.reloadResources(); 73 74 setIconImage(getImage("djenericsmall.gif")); 75 76 JPanel contentPane = (JPanel ) this.getContentPane(); 77 contentPane.setLayout(new BorderLayout ()); 78 this.setSize(new Dimension (380, 173)); 79 MenuPanel menuPanel = new MenuPanel(); 80 menuPanel.setRepositoriesFile(repositoriesFile); 81 contentPane.add(menuPanel, BorderLayout.CENTER); 82 83 _repositoriesFile = repositoriesFile; 84 85 String title = Messages.getString("global.Version", "Djeneric", DjVersion.getVersion()); 86 87 setTitle(title); 88 89 menuPanel.setProps(getProperties()); 90 } 91 92 protected void processWindowEvent(WindowEvent e) 93 { 94 if (e.getID() == WindowEvent.WINDOW_CLOSING) 95 { 96 saveProps(); 97 98 System.exit(0); 99 } 100 else 101 { 102 super.processWindowEvent(e); 103 } 104 } 105 106 protected void updateProperties() 107 { 108 } 109 110 public static Image getImage(String fileName) 111 { 112 URL url = Menu.class.getResource("images/" + fileName); 113 if (url != null) 114 { 115 return Toolkit.getDefaultToolkit().getImage(url); 116 } 117 else 118 { 119 return Toolkit.getDefaultToolkit().getImage(""); 120 } 121 } 122 123 public static void main(String args[]) 124 { 125 try 126 { 127 DjenericTool.setLookAndFeel(); 128 129 if (args.length < 1) 130 { 131 System.out.println(Messages.getString("global.Usage", Menu.class.getName())); 132 return; 133 } 134 135 new Menu(args[0]).startApp(); 136 137 } 138 catch (Exception e) 139 { 140 DjLogger.log(e); 141 } 142 } 143 144 } | Popular Tags |