📄 jawe.java
字号:
package org.enhydra.jawe;import java.awt.Color;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.io.FileInputStream;import java.util.Properties;import javax.swing.Box;import javax.swing.BoxLayout;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.WindowConstants;/** * The main editor class. * * @author Sasa Bojanic */public class JaWE { static int timeLeft = 10; // in seconds public static void main(String[] args) throws Throwable { System.out.println("Starting JAWE ...."); System.out.println("JaWE -> JaWE is being initialized ..."); File cfgf = null; System.out.println("JaWE_CONF_HOME=" + JaWEConstants.JAWE_CONF_HOME); if (JaWEConstants.JAWE_CONF_HOME != null) { File mainConfig = new File(JaWEConstants.JAWE_CONF_HOME + "/" + "defaultconfig"); Properties props = new Properties(); if (mainConfig.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(mainConfig); props.load(fis); fis.close(); } catch (Exception ex) { System.err.println("Something went wrong while reading configuration from the file " + mainConfig.getAbsolutePath()); } } String conf_home = JaWEConstants.JAWE_CONF_HOME + "/" + props.getProperty(JaWEConstants.JAWE_CURRENT_CONFIG_HOME); File cfh = new File(conf_home); if (cfh.exists()) { System.setProperty(JaWEConstants.JAWE_CURRENT_CONFIG_HOME, conf_home); if (Utils.checkFileExistence(JaWEManager.TOGWE_BASIC_PROPERTYFILE_NAME) || Utils.checkResourceExistence(JaWEManager.TOGWE_BASIC_PROPERTYFILE_PATH, JaWEManager.TOGWE_BASIC_PROPERTYFILE_NAME)) { cfgf = new File(conf_home + "/" + JaWEManager.TOGWE_BASIC_PROPERTYFILE_NAME); } else { cfgf = new File(conf_home + "/" + JaWEConstants.JAWE_BASIC_PROPERTYFILE_NAME); } } } if (cfgf != null && cfgf.exists()) { JaWEManager.configure(cfgf); } else { JaWEManager.configure(); } // Starting file name String fn = null; // check if there is a file that should be open at the startup if (args != null && args.length > 0) { fn = args[0]; } JaWEManager.getInstance().start(fn); if (JaWE.getJaWEVersion()==JaWE.DEMO_VERSION || (JaWE.getJaWEVersion()==JaWE.COMMUNITY_VERSION && !addOnsAvailable())) { JaWEAboutDialog d = new JaWEAboutDialog(JaWEManager.getInstance() .getJaWEController() .getJaWEFrame()); d.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension winsize = d.getSize(); d.setLocation(screenSize.width / 2 - (winsize.width / 2), screenSize.height / 2 - (winsize.height / 2)); d.setLocationRelativeTo(JaWEManager.getInstance() .getJaWEController() .getJaWEFrame()); d.setTitle(JaWEManager.getInstance() .getJaWEController() .getSettings() .getLanguageDependentString("AboutFrameTitle")); d.setVisible(true); if (JaWE.getJaWEVersion() == JaWE.DEMO_VERSION) { timeLeft = 0; } while (timeLeft != 0) { Thread.sleep(1000); timeLeft--; d.setTime(timeLeft); } d.setTime(0); d = null; } } private static class JaWEAboutDialog extends JDialog { JButton okButton; public JaWEAboutDialog(JFrame frame) { super(frame); JPanel main = new JPanel(); main.setBackground(Color.WHITE); main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); okButton = new JButton(" OK (" + timeLeft + ")"); okButton.setAlignmentX(CENTER_ALIGNMENT); okButton.addActionListener(new ActionHandler()); okButton.setEnabled(false); main.add(JaWESplash.getSplashPanel()); main.add(Box.createVerticalStrut(15)); main.add(okButton); getContentPane().add(main); this.getParent().setEnabled(false); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); } public void setTime(int timeLeft) { if (timeLeft != 0) okButton.setText(" OK (" + timeLeft + ")"); else { okButton.setText(" OK "); okButton.setEnabled(true); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getParent().setEnabled(true); } } private class ActionHandler implements ActionListener { public void actionPerformed(ActionEvent e) { dispose(); } } } public static final int COMMUNITY_VERSION = 0; public static final int DEMO_VERSION = 1; public static final int PROFESSIONAL_VERSION = 2; protected static int VERSION = -1; public static int getJaWEVersion() { if (VERSION == -1) { try { Class.forName("org.enhydra.jawe.base.controller.TogWEDemoController"); VERSION = DEMO_VERSION; } catch (Exception ex) { try { Class.forName("org.enhydra.jawe.ProfInfo"); VERSION = PROFESSIONAL_VERSION; } catch (Exception ex2) { VERSION = COMMUNITY_VERSION; } } } return VERSION; } protected static boolean addOnsAvailable=false; public static boolean addOnsAvailable () { try { Class.forName("org.enhydra.jawe.AddOnInfo"); addOnsAvailable=true; } catch (Exception ex) { } return addOnsAvailable; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -