1 22 23 package org.gjt.sp.jedit.options; 24 25 import javax.swing.*; 27 import java.awt.event.*; 28 import java.io.*; 29 import org.gjt.sp.jedit.gui.FontSelector; 30 import org.gjt.sp.jedit.*; 31 import org.gjt.sp.util.Log; 32 import org.gjt.sp.util.IOUtilities; 33 35 public class AppearanceOptionPane extends AbstractOptionPane 36 { 37 public AppearanceOptionPane() 39 { 40 super("appearance"); 41 } 43 protected void _init() 45 { 46 47 addComponent(new JLabel(jEdit.getProperty("options.appearance.lf.note"))); 48 49 lfs = UIManager.getInstalledLookAndFeels(); 50 String [] names = new String [lfs.length]; 51 String lf = UIManager.getLookAndFeel().getClass().getName(); 52 int index = 0; 53 for(int i = 0; i < names.length; i++) 54 { 55 names[i] = lfs[i].getName(); 56 if(lf.equals(lfs[i].getClassName())) 57 index = i; 58 } 59 60 lookAndFeel = new JComboBox(names); 61 lookAndFeel.setSelectedIndex(index); 62 lookAndFeel.addActionListener(new ActionListener() 63 { 64 public void actionPerformed(ActionEvent evt) 65 { 66 updateEnabled(); 67 } 68 }); 69 70 addComponent(jEdit.getProperty("options.appearance.lf"), 71 lookAndFeel); 72 73 74 primaryFont = new FontSelector(jEdit.getFontProperty( 75 "metal.primary.font")); 76 addComponent(jEdit.getProperty("options.appearance.primaryFont"), 77 primaryFont); 78 79 80 secondaryFont = new FontSelector(jEdit.getFontProperty( 81 "metal.secondary.font")); 82 addComponent(jEdit.getProperty("options.appearance.secondaryFont"), 83 secondaryFont); 84 85 91 updateEnabled(); 92 93 94 history = new JTextField(jEdit.getProperty("history")); 95 addComponent(jEdit.getProperty("options.appearance.history"),history); 96 97 98 menuSpillover = new JTextField(jEdit.getProperty("menu.spillover")); 99 addComponent(jEdit.getProperty("options.appearance.menuSpillover"),menuSpillover); 100 101 continuousLayout = new JCheckBox(jEdit.getProperty( 102 "options.appearance.continuousLayout.label")); 103 continuousLayout.setSelected(jEdit.getBooleanProperty("appearance.continuousLayout")); 104 addComponent(continuousLayout); 105 106 addSeparator("options.appearance.startup.label"); 107 108 109 showSplash = new JCheckBox(jEdit.getProperty( 110 "options.appearance.showSplash")); 111 String settingsDirectory = jEdit.getSettingsDirectory(); 112 if(settingsDirectory == null) 113 showSplash.setSelected(true); 114 else 115 showSplash.setSelected(!new File(settingsDirectory,"nosplash").exists()); 116 addComponent(showSplash); 117 118 119 showTips = new JCheckBox(jEdit.getProperty( 120 "options.appearance.showTips")); 121 showTips.setSelected(jEdit.getBooleanProperty("tip.show")); 122 addComponent(showTips); 123 124 addSeparator("options.appearance.experimental.label"); 125 addComponent(GUIUtilities.createMultilineLabel( 126 jEdit.getProperty("options.appearance.experimental.caption"))); 127 128 129 textColors = new JCheckBox(jEdit.getProperty( 130 "options.appearance.textColors")); 131 textColors.setSelected(jEdit.getBooleanProperty("textColors")); 132 addComponent(textColors); 133 134 135 decorateFrames = new JCheckBox(jEdit.getProperty( 136 "options.appearance.decorateFrames")); 137 decorateFrames.setSelected(jEdit.getBooleanProperty("decorate.frames")); 138 addComponent(decorateFrames); 139 140 141 decorateDialogs = new JCheckBox(jEdit.getProperty( 142 "options.appearance.decorateDialogs")); 143 decorateDialogs.setSelected(jEdit.getBooleanProperty("decorate.dialogs")); 144 addComponent(decorateDialogs); 145 } 147 protected void _save() 149 { 150 String lf = lfs[lookAndFeel.getSelectedIndex()].getClassName(); 151 jEdit.setProperty("lookAndFeel",lf); 152 jEdit.setFontProperty("metal.primary.font",primaryFont.getFont()); 153 jEdit.setFontProperty("metal.secondary.font",secondaryFont.getFont()); 154 jEdit.setProperty("history",history.getText()); 155 jEdit.setProperty("menu.spillover",menuSpillover.getText()); 156 jEdit.setBooleanProperty("tip.show",showTips.isSelected()); 157 jEdit.setBooleanProperty("appearance.continuousLayout",continuousLayout.isSelected()); 158 159 166 167 String settingsDirectory = jEdit.getSettingsDirectory(); 171 if(settingsDirectory != null) 172 { 173 File file = new File(settingsDirectory,"nosplash"); 174 if(showSplash.isSelected()) 175 file.delete(); 176 else 177 { 178 FileOutputStream out = null; 179 try 180 { 181 out = new FileOutputStream(file); 182 out.write('\n'); 183 out.close(); 184 } 185 catch(IOException io) 186 { 187 Log.log(Log.ERROR,this,io); 188 } 189 finally 190 { 191 IOUtilities.closeQuietly(out); 192 } 193 } 194 } 195 jEdit.setBooleanProperty("textColors",textColors.isSelected()); 196 jEdit.setBooleanProperty("decorate.frames",decorateFrames.isSelected()); 197 jEdit.setBooleanProperty("decorate.dialogs",decorateDialogs.isSelected()); 198 } 200 202 private UIManager.LookAndFeelInfo[] lfs; 204 private JComboBox lookAndFeel; 205 private FontSelector primaryFont; 206 private FontSelector secondaryFont; 207 private JTextField history; 208 private JTextField menuSpillover; 209 private JCheckBox showTips; 210 private JCheckBox continuousLayout; 211 private JCheckBox showSplash; 212 private JCheckBox textColors; 213 private JCheckBox decorateFrames; 214 private JCheckBox decorateDialogs; 215 private JComboBox antiAliasExtras; 216 218 private void updateEnabled() 220 { 221 String className = lfs[lookAndFeel.getSelectedIndex()] 222 .getClassName(); 223 224 if(className.equals("javax.swing.plaf.metal.MetalLookAndFeel") 225 || className.equals("com.incors.plaf.kunststoff.KunststoffLookAndFeel")) 226 { 227 primaryFont.setEnabled(true); 228 secondaryFont.setEnabled(true); 229 } 230 else 231 { 232 primaryFont.setEnabled(false); 233 secondaryFont.setEnabled(false); 234 } 235 } 237 } 239 | Popular Tags |