1 42 43 44 45 package org.gjt.sp.jedit.gui; 46 47 48 49 51 import javax.swing.border.EmptyBorder ; 52 import javax.swing.*; 53 import java.awt.*; 54 import java.awt.event.*; 55 56 import java.util.Arrays ; 57 58 import org.gjt.sp.jedit.buffer.FoldHandler; 59 import org.gjt.sp.jedit.buffer.JEditBuffer; 60 import org.gjt.sp.jedit.options.BufferOptionPane; 61 62 import org.gjt.sp.jedit.*; 63 64 66 73 74 public class BufferOptions extends EnhancedDialog 75 { 76 78 public BufferOptions(View view, Buffer buffer) 79 { 80 super(view,jEdit.getProperty("buffer-options.title"),true); 81 this.view = view; 82 this.buffer = buffer; 83 84 JPanel content = new JPanel(new BorderLayout()); 85 content.setBorder(new EmptyBorder (12,12,12,12)); 86 setContentPane(content); 87 88 ActionHandler actionListener = new ActionHandler(); 89 panel = new BufferOptionPane(); 90 91 content.add(BorderLayout.NORTH,panel); 92 93 95 JPanel buttons = new JPanel(); 96 buttons.setLayout(new BoxLayout(buttons,BoxLayout.X_AXIS)); 97 buttons.setBorder(new EmptyBorder (12,0,0,0)); 98 buttons.add(Box.createGlue()); 99 100 ok = new JButton(jEdit.getProperty("common.ok")); 101 ok.addActionListener(actionListener); 102 getRootPane().setDefaultButton(ok); 103 buttons.add(ok); 104 105 buttons.add(Box.createHorizontalStrut(6)); 106 107 cancel = new JButton(jEdit.getProperty("common.cancel")); 108 cancel.addActionListener(actionListener); 109 buttons.add(cancel); 110 111 buttons.add(Box.createGlue()); 112 content.add(BorderLayout.SOUTH,buttons); 113 114 116 pack(); 117 setLocationRelativeTo(view); 118 setVisible(true); 119 } 121 122 123 125 public void ok() 126 { 127 panel.save(); 128 dispose(); 129 } 131 133 public void cancel() 134 { 135 dispose(); 136 } 138 140 private View view; 141 private Buffer buffer; 142 private BufferOptionPane panel; 143 private JButton ok; 144 private JButton cancel; 145 146 148 class ActionHandler implements ActionListener 149 { 150 public void actionPerformed(ActionEvent evt) 152 { 153 Object source = evt.getSource(); 154 if(source == ok) 155 ok(); 156 else if(source == cancel) 157 cancel(); 158 } 160 } 162 } 163 164 | Popular Tags |