PageRenderTime 100ms CodeModel.GetById 87ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/bundles/plugins-trunk/XML/sidekick/html/HtmlOptionPane.java

#
Java | 122 lines | 70 code | 22 blank | 30 comment | 0 complexity | 61726d50b6a0fb75921acb629a0c0eae MD5 | raw file
  1/*
  2Copyright (c) 2006, Dale Anson
  3All rights reserved.
  4
  5Redistribution and use in source and binary forms, with or without modification, 
  6are permitted provided that the following conditions are met:
  7
  8* Redistributions of source code must retain the above copyright notice, 
  9this list of conditions and the following disclaimer.
 10* Redistributions in binary form must reproduce the above copyright notice, 
 11this list of conditions and the following disclaimer in the documentation 
 12and/or other materials provided with the distribution.
 13* Neither the name of the <ORGANIZATION> nor the names of its contributors 
 14may be used to endorse or promote products derived from this software without 
 15specific prior written permission.
 16
 17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
 21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
 24ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27*/
 28
 29package sidekick.html;
 30
 31import java.awt.*;
 32import java.awt.event.*;
 33import javax.swing.*;
 34import javax.swing.border.*;
 35import org.gjt.sp.jedit.*;
 36
 37public class HtmlOptionPane extends AbstractOptionPane  /*implements ActionListener*/ {
 38    
 39    JCheckBox showTagAttributes;
 40    JCheckBox showCoreAttributes;
 41    JCheckBox showLangAttributes;
 42    JCheckBox showScriptAttributes;
 43    JCheckBox showBrackets;
 44    JRadioButton showAllElements;
 45    JRadioButton showBlockElements;
 46    JCheckBox showJspElements;
 47    
 48    public HtmlOptionPane() {
 49        super("sidekick.html");   
 50    }
 51
 52    public void _init() {
 53    	    
 54	JTextPane info = new JTextPane();
 55	info.setEditorKit(info.createEditorKitForContentType("text/html"));	
 56	info.setOpaque(false);
 57	String text = jEdit.getProperty("options.sidekick.general.info");
 58	info.setText(text);
 59	info.setEditable(false);
 60	addComponent(jEdit.getProperty("options.note", "NOTE: "), info);
 61    	    
 62    	    
 63        setBorder(new TitledBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(6, 6, 6, 6)), jEdit.getProperty("options.sidekick.html.panel_label")));
 64        
 65        // attribute display
 66        JLabel attributes_label = new JLabel(jEdit.getProperty("options.sidekick.html.showAttributes.label"));
 67        addComponent(attributes_label);
 68        
 69        showTagAttributes = new JCheckBox(jEdit.getProperty("options.sidekick.html.showTagAttributes.label"));
 70        showTagAttributes.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showTagAttributes", true));
 71        addComponent(showTagAttributes);
 72        
 73        showCoreAttributes = new JCheckBox(jEdit.getProperty("options.sidekick.html.showCoreAttributes.label"));
 74        showCoreAttributes.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showCoreAttributes", true));
 75        addComponent(showCoreAttributes);
 76        
 77        showLangAttributes = new JCheckBox(jEdit.getProperty("options.sidekick.html.showLangAttributes.label"));
 78        showLangAttributes.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showLangAttributes", true));
 79        addComponent(showLangAttributes);
 80
 81        showScriptAttributes = new JCheckBox(jEdit.getProperty("options.sidekick.html.showScriptAttributes.label"));
 82        showScriptAttributes.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showScriptAttributes", true));
 83        addComponent(showScriptAttributes);
 84        
 85        addSeparator();
 86        
 87        // bracket display
 88        showBrackets = new JCheckBox(jEdit.getProperty("options.sidekick.html.showBrackets.label"));
 89        showBrackets.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showBrackets", true));
 90        addComponent(showBrackets);
 91
 92        addSeparator();
 93        
 94        // element display
 95        showAllElements = new JRadioButton(jEdit.getProperty("options.sidekick.html.showAllElements.label"));
 96        showAllElements.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showAllElements", true));
 97        addComponent(showAllElements);
 98
 99        showBlockElements = new JRadioButton(jEdit.getProperty("options.sidekick.html.showBlockElements.label"));
100        showBlockElements.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showBlockElements", false));
101        addComponent(showBlockElements);
102        
103        ButtonGroup bg = new ButtonGroup();
104        bg.add(showAllElements);
105        bg.add(showBlockElements);
106
107        showJspElements = new JCheckBox(jEdit.getProperty("options.sidekick.html.showJspElements.label"));
108        showJspElements.setSelected(jEdit.getBooleanProperty("options.sidekick.html.showJspElements", true));
109        addComponent(showJspElements);
110    }
111
112    public void _save() {
113        jEdit.setBooleanProperty("options.sidekick.html.showTagAttributes", showTagAttributes.isSelected());
114        jEdit.setBooleanProperty("options.sidekick.html.showCoreAttributes", showCoreAttributes.isSelected());
115        jEdit.setBooleanProperty("options.sidekick.html.showLangAttributes", showLangAttributes.isSelected());
116        jEdit.setBooleanProperty("options.sidekick.html.showScriptAttributes", showScriptAttributes.isSelected());
117        jEdit.setBooleanProperty("options.sidekick.html.showBrackets", showBrackets.isSelected());
118        jEdit.setBooleanProperty("options.sidekick.html.showAllElements", showAllElements.isSelected());
119        jEdit.setBooleanProperty("options.sidekick.html.showBlockElements", showBlockElements.isSelected());
120        jEdit.setBooleanProperty("options.sidekick.html.showJspElements", showJspElements.isSelected());
121    }
122}