1 22 23 package org.gjt.sp.jedit.options; 24 25 import javax.swing.border.*; 26 import javax.swing.*; 27 import java.awt.event.*; 28 import java.awt.*; 29 import java.io.*; 30 import org.gjt.sp.jedit.*; 31 import org.gjt.sp.util.Log; 32 33 public class ViewOptionPane extends AbstractOptionPane 34 { 35 public ViewOptionPane() 37 { 38 super("view"); 39 } 41 protected void _init() 43 { 44 45 layoutIcon1 = GUIUtilities.loadIcon("dock_layout1.png"); 46 layoutIcon2 = GUIUtilities.loadIcon("dock_layout2.png"); 47 layoutIcon3 = GUIUtilities.loadIcon("dock_layout3.png"); 48 layoutIcon4 = GUIUtilities.loadIcon("dock_layout4.png"); 49 50 JPanel layoutPanel = new JPanel(new BorderLayout(12,12)); 51 52 if(jEdit.getBooleanProperty("view.docking.alternateLayout")) 53 { 54 layout = new JLabel(jEdit.getBooleanProperty( 55 "view.toolbar.alternateLayout") 56 ? layoutIcon4 : layoutIcon2); 57 } 58 else 59 { 60 layout = new JLabel(jEdit.getBooleanProperty( 61 "view.toolbar.alternateLayout") 62 ? layoutIcon3 : layoutIcon1); 63 } 64 65 layout.setBorder(new EmptyBorder(12,12,12,12)); 66 layoutPanel.add(BorderLayout.CENTER,layout); 67 68 JPanel buttons = new JPanel(new GridLayout(2,1,12,12)); 69 buttons.setBorder(new EmptyBorder(0,12,12,12)); 70 buttons.add(alternateDockingLayout = new JButton(jEdit.getProperty( 71 "options.view.alternateDockingLayout"))); 72 alternateDockingLayout.addActionListener(new ActionHandler()); 73 buttons.add(alternateToolBarLayout = new JButton(jEdit.getProperty( 74 "options.view.alternateToolBarLayout"))); 75 alternateToolBarLayout.addActionListener(new ActionHandler()); 76 layoutPanel.add(BorderLayout.SOUTH,buttons); 77 78 TitledBorder border = new TitledBorder(jEdit.getProperty( 79 "options.view.viewLayout")); 80 border.setTitleJustification(TitledBorder.CENTER); 81 layoutPanel.setBorder(border); 82 83 addComponent(layoutPanel); 84 85 86 showFullPath = new JCheckBox(jEdit.getProperty( 87 "options.view.showFullPath")); 88 showFullPath.setSelected(jEdit.getBooleanProperty( 89 "view.showFullPath")); 90 addComponent(showFullPath); 91 92 93 showSearchbar = new JCheckBox(jEdit.getProperty( 94 "options.view.showSearchbar")); 95 showSearchbar.setSelected(jEdit.getBooleanProperty( 96 "view.showSearchbar")); 97 addComponent(showSearchbar); 98 99 100 beepOnSearchAutoWrap = new JCheckBox(jEdit.getProperty( 101 "options.view.beepOnSearchAutoWrap")); 102 beepOnSearchAutoWrap.setSelected(jEdit.getBooleanProperty( 103 "search.beepOnSearchAutoWrap")); 104 addComponent(beepOnSearchAutoWrap); 105 106 107 showBufferSwitcher = new JCheckBox(jEdit.getProperty( 108 "options.view.showBufferSwitcher")); 109 showBufferSwitcher.setSelected(jEdit.getBooleanProperty( 110 "view.showBufferSwitcher")); 111 addComponent(showBufferSwitcher); 112 } 114 protected void _save() 116 { 117 jEdit.setBooleanProperty("view.docking.alternateLayout", 118 layout.getIcon() == layoutIcon2 119 || layout.getIcon() == layoutIcon4); 120 jEdit.setBooleanProperty("view.toolbar.alternateLayout", 121 layout.getIcon() == layoutIcon3 122 || layout.getIcon() == layoutIcon4); 123 jEdit.setBooleanProperty("view.showFullPath",showFullPath 124 .isSelected()); 125 jEdit.setBooleanProperty("view.showSearchbar",showSearchbar 126 .isSelected()); 127 jEdit.setBooleanProperty("search.beepOnSearchAutoWrap",beepOnSearchAutoWrap 128 .isSelected()); 129 jEdit.setBooleanProperty("view.showBufferSwitcher", 130 showBufferSwitcher.isSelected()); 131 } 133 private JLabel layout; 135 private Icon layoutIcon1, layoutIcon2, layoutIcon3, layoutIcon4; 136 private JButton alternateDockingLayout, alternateToolBarLayout; 137 private JCheckBox showFullPath; 138 private JCheckBox showSearchbar; 139 private JCheckBox beepOnSearchAutoWrap; 140 private JCheckBox showBufferSwitcher; 141 143 class ActionHandler implements ActionListener 145 { 146 public void actionPerformed(ActionEvent evt) 147 { 148 if(evt.getSource() == alternateDockingLayout) 149 { 150 if(layout.getIcon() == layoutIcon1) 151 layout.setIcon(layoutIcon2); 152 else if(layout.getIcon() == layoutIcon2) 153 layout.setIcon(layoutIcon1); 154 else if(layout.getIcon() == layoutIcon3) 155 layout.setIcon(layoutIcon4); 156 else if(layout.getIcon() == layoutIcon4) 157 layout.setIcon(layoutIcon3); 158 } 159 else if(evt.getSource() == alternateToolBarLayout) 160 { 161 if(layout.getIcon() == layoutIcon1) 162 layout.setIcon(layoutIcon3); 163 else if(layout.getIcon() == layoutIcon3) 164 layout.setIcon(layoutIcon1); 165 else if(layout.getIcon() == layoutIcon2) 166 layout.setIcon(layoutIcon4); 167 else if(layout.getIcon() == layoutIcon4) 168 layout.setIcon(layoutIcon2); 169 } 170 } 171 } } 173 | Popular Tags |