PageRenderTime 83ms CodeModel.GetById 30ms app.highlight 17ms RepoModel.GetById 33ms app.codeStats 0ms

/bundles/plugins-trunk/XML/xml/options/GeneralOptionPane.java

#
Java | 200 lines | 140 code | 36 blank | 24 comment | 3 complexity | 3c151279decf16cd406161b151eda46a MD5 | raw file
  1/*
  2 * GeneralOptionPane.java - XML general options panel
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 2001, 2003 Slava Pestov
  7 *
  8 * The XML plugin is licensed under the GNU General Public License, with
  9 * the following exception:
 10 *
 11 * "Permission is granted to link this code with software released under
 12 * the Apache license version 1.1, for example used by the Xerces XML
 13 * parser package."
 14 */
 15
 16package xml.options;
 17
 18//{{{ Imports
 19import java.util.Arrays;
 20
 21import java.awt.event.ActionListener;
 22import java.awt.event.ActionEvent;
 23
 24import javax.swing.JCheckBox;
 25import javax.swing.JComboBox;
 26import javax.swing.JTextPane;
 27
 28import org.gjt.sp.jedit.AbstractOptionPane;
 29import org.gjt.sp.jedit.jEdit;
 30
 31import xml.Resolver;
 32//}}}
 33
 34public class GeneralOptionPane extends AbstractOptionPane
 35{
 36	//{{{ Private members
 37
 38	private JComboBox network;
 39
 40	private JCheckBox cache;
 41	
 42	private JCheckBox popupEditorComplete;
 43	private JCheckBox validate;
 44	private JCheckBox enableSchemaMapping;
 45	private JComboBox showAttributes;
 46	private JCheckBox closeCompleteOpen;
 47	private JCheckBox closeComplete;
 48	private JCheckBox standaloneExtraSpace;
 49	
 50	private JCheckBox xinclude;
 51	private JCheckBox xincludeBaseURI;
 52	
 53	static String[] comboLabels;
 54	
 55	//}}}	
 56	
 57	//{{{ GeneralOptionPane constructor
 58	public GeneralOptionPane()
 59	{
 60		super("xml.general");
 61	} //}}}
 62
 63	//{{{ _init() method
 64	protected void _init()
 65	{
 66		
 67		JTextPane info = new JTextPane();
 68		info.setEditorKit(info.createEditorKitForContentType("text/html"));	
 69		info.setOpaque(false);
 70		String text = jEdit.getProperty("options.sidekick.general.info");
 71		info.setText(text);
 72		info.setEditable(false);
 73		addComponent(jEdit.getProperty("options.note", "NOTE: "), info);
 74		
 75		addSeparator("options.xml.general.validate-separator");
 76		addComponent(validate = new JCheckBox(jEdit.getProperty(
 77			"options.xml.general.validate")));
 78		validate.setSelected(jEdit.getBooleanProperty("buffer.xml.validate"));
 79		validate.setName("validate");
 80		
 81		String prefix = "options." + Resolver.NETWORK_PROPS + ".";
 82		String[] comboLabels = new String[Resolver.MODES.length];
 83		for (int i=0; i<comboLabels.length; ++i) {
 84			comboLabels[i] = jEdit.getProperty(prefix + Resolver.MODES[i]);
 85		}
 86		
 87		network = new JComboBox(comboLabels);
 88		network.setSelectedIndex(Arrays.asList(Resolver.MODES).indexOf(Resolver.getNetworkMode()));
 89		network.setName("network");
 90		
 91		addComponent(jEdit.getProperty("options.xml.general.network-mode"), network);
 92		
 93		cache = new JCheckBox (jEdit.getProperty("options." + Resolver.CACHE));
 94		cache.setSelected(Resolver.isUsingCache());
 95		cache.setName("cache");
 96		addComponent(cache);
 97		
 98		addComponent(enableSchemaMapping = new JCheckBox(jEdit.getProperty(
 99			"options.xml.general.enable-schema-mapping")));
100		enableSchemaMapping.setSelected(jEdit.getBooleanProperty(xml.SchemaMappingManager.ENABLE_SCHEMA_MAPPING_PROP));
101		enableSchemaMapping.setName("enable-schema-mapping");
102		enableSchemaMapping.setToolTipText(jEdit.getProperty(
103				"options.xml.general.enable-schema-mapping.tooltip" ));
104		
105		String[] showAttributeValues = {
106			jEdit.getProperty("options.xml.general.show-attributes.none"),
107			jEdit.getProperty("options.xml.general.show-attributes.id-only"),
108			jEdit.getProperty("options.xml.general.show-attributes.all")
109		};
110
111		addSeparator("options.xml.general.tree-separator");
112
113		addComponent(jEdit.getProperty("options.xml.general.show-attributes"),
114			showAttributes = new JComboBox(showAttributeValues));
115		showAttributes.setSelectedIndex(jEdit.getIntegerProperty(
116			"xml.show-attributes",0));
117		showAttributes.setName("showAttributes");
118
119		addSeparator("options.xml.general.tags-separator");
120
121		closeComplete = new JCheckBox(jEdit.getProperty(
122			"options.xml.general.close-complete"));
123		closeComplete.setSelected(jEdit.getBooleanProperty(
124			"xml.close-complete"));
125		closeComplete.setToolTipText(jEdit.getProperty(
126				"options.xml.general.close-complete.tooltip" ));
127		closeComplete.setName("closeComplete");
128		addComponent(closeComplete);
129
130		closeCompleteOpen = new JCheckBox(jEdit.getProperty(
131			"options.xml.general.close-complete-open"));
132		closeCompleteOpen.setSelected(jEdit.getBooleanProperty(
133			"xml.close-complete-open"));
134		closeCompleteOpen.setName("closeCompleteOpen");
135		addComponent(closeCompleteOpen);
136		
137		addComponent(standaloneExtraSpace = new JCheckBox(jEdit.getProperty(
138			"options.xml.general.standalone-extra-space")));
139		standaloneExtraSpace.setSelected(jEdit.getBooleanProperty(
140			"xml.standalone-extra-space"));
141		standaloneExtraSpace.setName("standaloneExtraSpace");
142
143		addComponent(popupEditorComplete = new JCheckBox(jEdit.getProperty(
144			"options.xml.general.tageditor.popupOnCompletion")));
145		popupEditorComplete.setSelected(jEdit.getBooleanProperty("xml.tageditor.popupOnComplete", true));
146		popupEditorComplete.setName("popupEditorComplete");
147		
148		addSeparator("options.xml.general.xinclude-separator");
149		
150		addComponent(xinclude = new JCheckBox(jEdit.getProperty(
151			"options.xml.general.xinclude")));
152		xinclude.setSelected(jEdit.getBooleanProperty(
153			"buffer.xml.xinclude"));
154		xinclude.setName("xinclude");
155		//force sensible default
156		xinclude.addActionListener(new ActionListener()
157		{
158			public void actionPerformed(ActionEvent ae)
159			{
160				if(xinclude.isSelected())xincludeBaseURI.setSelected(true);
161			}
162		});
163		addComponent(xincludeBaseURI = new JCheckBox(jEdit.getProperty(
164			"options.xml.general.xinclude-xmlbase")));
165		xincludeBaseURI.setSelected(jEdit.getBooleanProperty(
166			"buffer.xml.xinclude.fixup-base-uris"));
167		xincludeBaseURI.setToolTipText(jEdit.getProperty(
168			"options.xml.general.xinclude-xmlbase.tooltip"));
169		xincludeBaseURI.setName("xincludeBaseURI");
170	} //}}}
171
172	//{{{ _save() method
173	protected void _save()
174	{
175		jEdit.setBooleanProperty("xml.tageditor.popupOnComplete", popupEditorComplete.isSelected());
176		
177		jEdit.setBooleanProperty("buffer.xml.validate",validate.isSelected());
178		Resolver.setNetworkMode(Resolver.MODES[network.getSelectedIndex()]);
179		Resolver.setUsingCache(cache.isSelected());
180		jEdit.setBooleanProperty(xml.SchemaMappingManager.ENABLE_SCHEMA_MAPPING_PROP,
181			enableSchemaMapping.isSelected());
182		jEdit.setIntegerProperty("xml.show-attributes",
183			showAttributes.getSelectedIndex());
184		jEdit.setBooleanProperty("xml.close-complete",
185			closeComplete.isSelected());
186		jEdit.setBooleanProperty("xml.close-complete-open",
187			closeCompleteOpen.isSelected());
188		/* If we want XML close completion, we need to also enable the
189		   SideKick option to close immediately when possible.  */
190		if (closeComplete.isSelected()) {
191			jEdit.setBooleanProperty("sidekick.complete-instant.toggle", true);
192		}
193		jEdit.setBooleanProperty("xml.standalone-extra-space",
194			standaloneExtraSpace.isSelected());
195		jEdit.setBooleanProperty("buffer.xml.xinclude",xinclude.isSelected());
196		jEdit.setBooleanProperty("buffer.xml.xinclude.fixup-base-uris",xincludeBaseURI.isSelected());
197	} //}}}
198
199
200}