View | Details | Raw Unified | Return to bug 144313
Collapse All | Expand All

(-)src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java (-3 / +36 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2001, 2006 IBM Corporation and others.
2
 * Copyright (c) 2001, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-27 Link Here
22
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.texteditor.ITextEditor;
23
import org.eclipse.ui.texteditor.ITextEditor;
24
import org.eclipse.ui.texteditor.ITextEditorExtension3;
24
import org.eclipse.ui.texteditor.ITextEditorExtension3;
25
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
26
import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
25
import org.eclipse.wst.sse.core.StructuredModelManager;
27
import org.eclipse.wst.sse.core.StructuredModelManager;
26
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
28
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
27
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
29
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
Lines 51-56 Link Here
51
				if (command.text != null) {
53
				if (command.text != null) {
52
					smartInsertForComment(command, document, model);
54
					smartInsertForComment(command, document, model);
53
					smartInsertForEndTag(command, document, model);
55
					smartInsertForEndTag(command, document, model);
56
					smartRemoveEndTag(command, document, model);
54
				}
57
				}
55
			}
58
			}
56
		}
59
		}
Lines 60-65 Link Here
60
		}
63
		}
61
	}
64
	}
62
65
66
	private boolean isPreferenceEnabled(String key) {
67
		return (key != null && HTMLUIPlugin.getDefault().getPreferenceStore().getBoolean(key));
68
	}
69
	
63
	private boolean isCommentNode(IDOMNode node) {
70
	private boolean isCommentNode(IDOMNode node) {
64
		return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
71
		return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
65
	}
72
	}
Lines 67-76 Link Here
67
	private boolean isDocumentNode(IDOMNode node) {
74
	private boolean isDocumentNode(IDOMNode node) {
68
		return (node != null && node.getNodeType() == Node.DOCUMENT_NODE);
75
		return (node != null && node.getNodeType() == Node.DOCUMENT_NODE);
69
	}
76
	}
77
	
78
	/**
79
	 * Attempts to clean up an end-tag if a start-tag is converted into an empty-element
80
	 * tag (e.g., <node />) and the original element was empty.
81
	 * 
82
	 * @param command the document command describing the change
83
	 * @param document the document that will be changed
84
	 * @param model the model based on the document
85
	 */
86
	private void smartRemoveEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
87
		try {
88
			// An opening tag is now a self-terminated end-tag
89
			if ("/".equals(command.text) && ">".equals(document.get(command.offset, 1)) && isPreferenceEnabled(HTMLUIPreferenceNames.TYPING_REMOVE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
90
				IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
91
				if (node != null && !node.hasChildNodes()) {
92
					IStructuredDocumentRegion region = node.getEndStructuredDocumentRegion();
93
94
					if (region != null && region.isEnded())
95
						document.replace(region.getStartOffset(), region.getLength(), ""); //$NON-NLS-1$
96
				}
97
			}
98
		}
99
		catch (BadLocationException e) {
100
			Logger.logException(e);
101
		}
102
	}
70
103
71
	private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
104
	private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
72
		try {
105
		try {
73
			if (command.text.equals("-") && document.getLength() >= 3 && document.get(command.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$
106
			if (command.text.equals("-") && document.getLength() >= 3 && document.get(command.offset - 3, 3).equals("<!-") && isPreferenceEnabled(HTMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS)) { //$NON-NLS-1$ //$NON-NLS-2$
74
				command.text += "  -->"; //$NON-NLS-1$
107
				command.text += "  -->"; //$NON-NLS-1$
75
				command.shiftsCaret = false;
108
				command.shiftsCaret = false;
76
				command.caretOffset = command.offset + 2;
109
				command.caretOffset = command.offset + 2;
Lines 85-91 Link Here
85
118
86
	private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
119
	private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
87
		try {
120
		try {
88
			if (command.text.equals("/") && document.getLength() >= 1 && document.get(command.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$
121
			if (command.text.equals("/") && document.getLength() >= 1 && document.get(command.offset - 1, 1).equals("<") && isPreferenceEnabled(HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
89
				IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
122
				IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
90
				if (isCommentNode(parentNode)) {
123
				if (isCommentNode(parentNode)) {
91
					// loop and find non comment node parent
124
					// loop and find non comment node parent
(-)src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceNames.java (-1 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 62-65 Link Here
62
	 * </p>
62
	 * </p>
63
	 */
63
	 */
64
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
64
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
65
	
66
	/**
67
	 * The key to store the option for auto-completing comments while
68
	 * typing.
69
	 * <p>
70
	 * Value is of type <code>boolean</code>.
71
	 * </p>
72
	 */
73
	public static final String TYPING_COMPLETE_COMMENTS = "completeComments"; //$NON-NLS-1$
74
	
75
	/**
76
	 * The key to store the option for auto-completing end-tags after entering
77
	 * <code>&lt;/</code>
78
	 * <p>
79
	 * Value is of type <code>boolean</code>.
80
	 * </p>
81
	 */
82
	public static final String TYPING_COMPLETE_END_TAGS = "completeEndTags"; //$NON-NLS-1$
83
	
84
	/**
85
	 * The key to store the option for removing an end-tag if the start tag is
86
	 * converted to an empty-tag.
87
	 * <p>
88
	 * Value is of type <code>boolean</code>.
89
	 * </p>
90
	 */
91
	public static final String TYPING_REMOVE_END_TAGS = "removeEndTags"; //$NON-NLS-1$
65
}
92
}
(-)src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceInitializer.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 102-107 Link Here
102
		if (template != null)
102
		if (template != null)
103
			templateName = template.getName();
103
			templateName = template.getName();
104
		store.setDefault(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
104
		store.setDefault(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
105
		
106
		// Defaults for the Typing preference page
107
		store.setDefault(HTMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, true);
108
		store.setDefault(HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, true);
109
		store.setDefault(HTMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, true);
105
	}
110
	}
106
111
107
}
112
}
(-)plugin.properties (+1 lines)
Lines 17-22 Link Here
17
HTML_Templates.name=Templates
17
HTML_Templates.name=Templates
18
HTML_Styles.name=Styles
18
HTML_Styles.name=Styles
19
HTML_Syntax_Coloring=Syntax Coloring
19
HTML_Syntax_Coloring=Syntax Coloring
20
HTML_Typing=Typing
20
WebContentSettings.name=Web Content Settings
21
WebContentSettings.name=Web Content Settings
21
Device_Profile_Entry_Provider_Extension.name=Device Profile Entry Provider Extension
22
Device_Profile_Entry_Provider_Extension.name=Device Profile Entry Provider Extension
22
All_HTML_context_type_Extension_Element.name=All HTML
23
All_HTML_context_type_Extension_Element.name=All HTML
(-)plugin.xml (+6 lines)
Lines 107-112 Link Here
107
			id="org.eclipse.wst.html.ui.preferences.styles">
107
			id="org.eclipse.wst.html.ui.preferences.styles">
108
			<keywordReference id="org.eclipse.wst.html.ui.styles"/>
108
			<keywordReference id="org.eclipse.wst.html.ui.styles"/>
109
		</page>
109
		</page>
110
		<page
111
			name="%HTML_Typing"
112
			category="org.eclipse.wst.html.ui.preferences.source"
113
			class="org.eclipse.wst.html.ui.internal.preferences.ui.HTMLTypingPreferencePage"
114
			id="org.eclipse.wst.html.ui.preferences.typing">
115
		</page>
110
	</extension>
116
	</extension>
111
	<!-- Web content settings -->
117
	<!-- Web content settings -->
112
	<extension point="org.eclipse.ui.propertyPages">
118
	<extension point="org.eclipse.ui.propertyPages">
(-)src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties (-1 / +8 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2004, 2007 IBM Corporation and others.
2
# Copyright (c) 2004, 2008 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 107-109 Link Here
107
EmptyFilePreferencePage_0=Expand the tree to edit preferences for a specific feature.
107
EmptyFilePreferencePage_0=Expand the tree to edit preferences for a specific feature.
108
_UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK=HTML editing preferences.  Note that some preferences may be set on the <a>{0}</a> preference page.
108
_UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK=HTML editing preferences.  Note that some preferences may be set on the <a>{0}</a> preference page.
109
# above are possibly unused strings that may be deleted
109
# above are possibly unused strings that may be deleted
110
111
# HTML Typing Preference Page
112
HTMLTyping_Auto_Complete=Automatically close
113
HTMLTyping_Auto_Remove=Automatically remove
114
HTMLTyping_Complete_Comments=&Comments
115
HTMLTyping_Complete_End_Tags=&End-tags
116
HTMLTyping_Remove_End_Tags=E&nd-tags when creating an empty-element tag
(-)src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others. All rights reserved.   This
2
 * Copyright (c) 2005, 2008 IBM Corporation and others. All rights reserved.   This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 133-136 Link Here
133
	// above are possibly unused strings that may be deleted
133
	// above are possibly unused strings that may be deleted
134
	public static String EmptyFilePreferencePage_0;
134
	public static String EmptyFilePreferencePage_0;
135
	public static String _UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK;
135
	public static String _UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK;
136
	
137
	// HTML Typing Preferences
138
	public static String HTMLTyping_Auto_Complete;
139
	public static String HTMLTyping_Auto_Remove;
140
	public static String HTMLTyping_Complete_Comments;
141
	public static String HTMLTyping_Complete_End_Tags;
142
	public static String HTMLTyping_Remove_End_Tags;
136
}
143
}
(-)src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLTypingPreferencePage.java (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
package org.eclipse.wst.html.ui.internal.preferences.ui;
13
14
import org.eclipse.jface.preference.IPreferenceStore;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Group;
20
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
21
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
22
import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
23
import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
24
25
public class HTMLTypingPreferencePage extends AbstractPreferencePage {
26
27
	private Button fCloseComment;
28
	private Button fCloseEndTag;
29
	private Button fRemoveEndTag;
30
	
31
	protected Control createContents(Composite parent) {
32
		Composite composite = super.createComposite(parent, 1);
33
		
34
		createAutoComplete(composite);
35
		createAutoRemove(composite);
36
		
37
		setSize(composite);
38
		loadPreferences();
39
		
40
		return composite;
41
	}
42
	
43
	private void createAutoComplete(Composite parent) {
44
		Group group = createGroup(parent, 2);
45
		
46
		group.setText(HTMLUIMessages.HTMLTyping_Auto_Complete);
47
		
48
		fCloseComment = createCheckBox(group, HTMLUIMessages.HTMLTyping_Complete_Comments);
49
		((GridData) fCloseComment.getLayoutData()).horizontalSpan = 2;
50
		
51
		fCloseEndTag = createCheckBox(group, HTMLUIMessages.HTMLTyping_Complete_End_Tags);
52
		((GridData) fCloseEndTag.getLayoutData()).horizontalSpan = 2;
53
		
54
	}
55
	
56
	private void createAutoRemove(Composite parent) {
57
		Group group = createGroup(parent, 2);
58
		
59
		group.setText(HTMLUIMessages.HTMLTyping_Auto_Remove);
60
		
61
		fRemoveEndTag = createCheckBox(group, HTMLUIMessages.HTMLTyping_Remove_End_Tags);
62
		((GridData) fRemoveEndTag.getLayoutData()).horizontalSpan = 2;
63
	}
64
	
65
	public boolean performOk() {
66
		boolean result = super.performOk();
67
		
68
		HTMLUIPlugin.getDefault().savePluginPreferences();
69
		
70
		return result;
71
	}
72
	
73
	protected void initializeValues() {
74
		initCheckbox(fCloseComment, HTMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
75
		initCheckbox(fCloseEndTag, HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
76
		initCheckbox(fRemoveEndTag, HTMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
77
	}
78
	
79
	protected void performDefaults() {
80
		defaultCheckbox(fCloseComment, HTMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
81
		defaultCheckbox(fCloseEndTag, HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
82
		defaultCheckbox(fRemoveEndTag, HTMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
83
	}
84
	
85
	private void initCheckbox(Button box, String key) {
86
		if(box != null && key != null)
87
			box.setSelection(getPreferenceStore().getBoolean(key));
88
	}
89
	
90
	private void defaultCheckbox(Button box, String key) {
91
		if(box != null && key != null)
92
			box.setSelection(getPreferenceStore().getDefaultBoolean(key));
93
	}
94
	
95
	protected void storeValues() {
96
		getPreferenceStore().setValue(HTMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, (fCloseComment != null) ? fCloseComment.getSelection() : false);
97
		getPreferenceStore().setValue(HTMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, (fCloseEndTag != null) ? fCloseEndTag.getSelection() : false);
98
		getPreferenceStore().setValue(HTMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, (fRemoveEndTag != null) ? fRemoveEndTag.getSelection() : false);
99
	}
100
	
101
	protected IPreferenceStore doGetPreferenceStore() {
102
		return HTMLUIPlugin.getDefault().getPreferenceStore();
103
	}
104
105
}
(-)src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceNames.java (-1 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 62-65 Link Here
62
	 * </p>
62
	 * </p>
63
	 */
63
	 */
64
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
64
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
65
	
66
	/**
67
	 * The key to store the option for auto-completing EL braces after entering
68
	 * <code>${</code>
69
	 * <p>
70
	 * Value is of type <code>boolean</code>.
71
	 * </p>
72
	 */
73
	public static final String TYPING_COMPLETE_EL_BRACES = "typingCompleteElBraces"; //$NON-NLS-1$
74
	
75
	/**
76
	 * The key to store the option for auto-completing scriptlets after entering
77
	 * <code>&lt;%</code>
78
	 * <p>
79
	 * Value is of type <code>boolean</code>.
80
	 * </p>
81
	 */
82
	public static final String TYPING_COMPLETE_SCRIPTLETS = "typingCompleteScriptlets"; //$NON-NLS-1$
65
}
83
}
(-)src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceInitializer.java (+3 lines)
Lines 66-71 Link Here
66
		if (template != null)
66
		if (template != null)
67
			templateName = template.getName();
67
			templateName = template.getName();
68
		store.setDefault(JSPUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
68
		store.setDefault(JSPUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
69
		
70
		store.setDefault(JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES, true);
71
		store.setDefault(JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS, true);
69
	}
72
	}
70
73
71
}
74
}
(-)src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties (-1 / +6 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2004, 2007 IBM Corporation and others.
2
# Copyright (c) 2004, 2008 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 94-96 Link Here
94
SyntaxColoringPage_5=&Strikethrough
94
SyntaxColoringPage_5=&Strikethrough
95
SyntaxColoringPage_6=&Underline
95
SyntaxColoringPage_6=&Underline
96
_UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK=JSP editing preferences.  Note that some preferences may be set on the <a>{0}</a> preference page.
96
_UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK=JSP editing preferences.  Note that some preferences may be set on the <a>{0}</a> preference page.
97
98
# HTML Typing Preference Page
99
JSPTyping_Auto_Complete=Automatically close
100
JSPTyping_Complete_Scriptlets=&Scriptlet regions
101
JSPTyping_Complete_Braces=&Braces in EL expressions
(-)src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java (+4 lines)
Lines 113-116 Link Here
113
	public static String SyntaxColoringPage_5;
113
	public static String SyntaxColoringPage_5;
114
	public static String SyntaxColoringPage_6;
114
	public static String SyntaxColoringPage_6;
115
	public static String _UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK;
115
	public static String _UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK;
116
	
117
	public static String JSPTyping_Auto_Complete;
118
	public static String JSPTyping_Complete_Scriptlets;
119
	public static String JSPTyping_Complete_Braces;
116
}
120
}
(-)src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java (-3 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-20 Link Here
14
import org.eclipse.jface.text.DocumentCommand;
14
import org.eclipse.jface.text.DocumentCommand;
15
import org.eclipse.jface.text.IAutoEditStrategy;
15
import org.eclipse.jface.text.IAutoEditStrategy;
16
import org.eclipse.jface.text.IDocument;
16
import org.eclipse.jface.text.IDocument;
17
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
17
import org.eclipse.jst.jsp.ui.internal.Logger;
18
import org.eclipse.jst.jsp.ui.internal.Logger;
19
import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
18
import org.eclipse.ui.IEditorPart;
20
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.IWorkbenchWindow;
22
import org.eclipse.ui.IWorkbenchWindow;
Lines 37-43 Link Here
37
39
38
			if (model != null) {
40
			if (model != null) {
39
				if (command.text != null) {
41
				if (command.text != null) {
40
					if (command.text.equals("%")) { //$NON-NLS-1$
42
					if (command.text.equals("%") && isPreferenceEnabled(JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS)) { //$NON-NLS-1$
41
						// scriptlet - add end %>
43
						// scriptlet - add end %>
42
						IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
44
						IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
43
						if (prefixedWith(document, command.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
45
						if (prefixedWith(document, command.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
Lines 47-53 Link Here
47
							command.doit = false;
49
							command.doit = false;
48
						}
50
						}
49
					}
51
					}
50
					if (command.text.equals("{")) { //$NON-NLS-1$
52
					if (command.text.equals("{") && isPreferenceEnabled(JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES)) { //$NON-NLS-1$
51
						IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
53
						IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
52
						if ((prefixedWith(document, command.offset, "$") || prefixedWith(document, command.offset, "#")) && //$NON-NLS-1$ //$NON-NLS-2$
54
						if ((prefixedWith(document, command.offset, "$") || prefixedWith(document, command.offset, "#")) && //$NON-NLS-1$ //$NON-NLS-2$
53
									!node.getSource().endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$
55
									!node.getSource().endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$
Lines 65-70 Link Here
65
				model.releaseFromRead();
67
				model.releaseFromRead();
66
		}
68
		}
67
	}
69
	}
70
	
71
	private boolean isPreferenceEnabled(String key) {
72
		return (key != null && JSPUIPlugin.getDefault().getPreferenceStore().getBoolean(key));
73
	}
68
74
69
	/**
75
	/**
70
	 * Return the active text editor if possible, otherwise the active editor
76
	 * Return the active text editor if possible, otherwise the active editor
(-)plugin.properties (+1 lines)
Lines 19-24 Link Here
19
JSP_Styles.name=Styles
19
JSP_Styles.name=Styles
20
JSP_Syntax_Coloring=Syntax Coloring
20
JSP_Syntax_Coloring=Syntax Coloring
21
JSP_Source_target_name=JSP Source
21
JSP_Source_target_name=JSP Source
22
JSP_Typing=Typing
22
23
23
# Snippets contributions for helping with JSP syntax
24
# Snippets contributions for helping with JSP syntax
24
jsp_scriptlet=<%..%> scriptlet
25
jsp_scriptlet=<%..%> scriptlet
(-)plugin.xml (+6 lines)
Lines 224-229 Link Here
224
			id="org.eclipse.wst.sse.ui.preferences.jsp.styles">
224
			id="org.eclipse.wst.sse.ui.preferences.jsp.styles">
225
			<keywordReference id="org.eclipse.wst.jsp.ui.styles"/>
225
			<keywordReference id="org.eclipse.wst.jsp.ui.styles"/>
226
		</page>
226
		</page>
227
		<page
228
			name="%JSP_Typing"
229
			category="org.eclipse.wst.sse.ui.preferences.jsp.source"
230
			class="org.eclipse.jst.jsp.ui.internal.preferences.ui.JSPTypingPreferencePage"
231
			id="org.eclipse.jst.jsp.ui.preferences.typing">
232
		</page>
227
	</extension>
233
	</extension>
228
	
234
	
229
	<!-- Keywords for preference and properties pages -->
235
	<!-- Keywords for preference and properties pages -->
(-)src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPTypingPreferencePage.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
package org.eclipse.jst.jsp.ui.internal.preferences.ui;
13
14
import org.eclipse.jface.preference.IPreferenceStore;
15
import org.eclipse.jst.jsp.ui.internal.JSPUIMessages;
16
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
17
import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.Group;
23
import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
24
25
public class JSPTypingPreferencePage extends AbstractPreferencePage {
26
27
	private Button fCloseBraces;
28
	private Button fCloseScriptlets;
29
	
30
	protected Control createContents(Composite parent) {
31
		Composite composite = super.createComposite(parent, 1);
32
		
33
		createAutoComplete(composite);
34
		
35
		setSize(composite);
36
		loadPreferences();
37
		
38
		return composite;
39
	}
40
	
41
	private void createAutoComplete(Composite parent) {
42
		Group group = createGroup(parent, 2);
43
		
44
		group.setText(JSPUIMessages.JSPTyping_Auto_Complete);
45
		
46
		fCloseBraces = createCheckBox(group, JSPUIMessages.JSPTyping_Complete_Braces);
47
		((GridData) fCloseBraces.getLayoutData()).horizontalSpan = 2;
48
		
49
		fCloseScriptlets = createCheckBox(group, JSPUIMessages.JSPTyping_Complete_Scriptlets);
50
		((GridData) fCloseScriptlets.getLayoutData()).horizontalSpan = 2;
51
		
52
	}
53
	
54
	public boolean performOk() {
55
		boolean result = super.performOk();
56
		
57
		JSPUIPlugin.getDefault().savePluginPreferences();
58
		
59
		return result;
60
	}
61
	
62
	protected void initializeValues() {
63
		initCheckbox(fCloseBraces, JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES);
64
		initCheckbox(fCloseScriptlets, JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS);
65
	}
66
	
67
	protected void performDefaults() {
68
		defaultCheckbox(fCloseBraces, JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES);
69
		defaultCheckbox(fCloseScriptlets, JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS);
70
	}
71
	
72
	private void initCheckbox(Button box, String key) {
73
		if(box != null && key != null)
74
			box.setSelection(getPreferenceStore().getBoolean(key));
75
	}
76
	
77
	private void defaultCheckbox(Button box, String key) {
78
		if(box != null && key != null)
79
			box.setSelection(getPreferenceStore().getDefaultBoolean(key));
80
	}
81
	
82
	protected void storeValues() {
83
		getPreferenceStore().setValue(JSPUIPreferenceNames.TYPING_COMPLETE_EL_BRACES, (fCloseBraces != null) ? fCloseBraces.getSelection() : false);
84
		getPreferenceStore().setValue(JSPUIPreferenceNames.TYPING_COMPLETE_SCRIPTLETS, (fCloseScriptlets != null) ? fCloseScriptlets.getSelection() : false);
85
	}
86
	
87
	protected IPreferenceStore doGetPreferenceStore() {
88
		return JSPUIPlugin.getDefault().getPreferenceStore();
89
	}
90
91
}
(-)plugin.properties (+1 lines)
Lines 20-25 Link Here
20
XML_Templates.name=Templates
20
XML_Templates.name=Templates
21
XML_Styles.name=Styles
21
XML_Styles.name=Styles
22
XML_Syntax_Coloring=Syntax Coloring
22
XML_Syntax_Coloring=Syntax Coloring
23
XML_Typing=Typing
23
XML_Editor.name=XML Editor
24
XML_Editor.name=XML Editor
24
###############################################################################
25
###############################################################################
25
_UI_WIZARD_NEW_XML=XML
26
_UI_WIZARD_NEW_XML=XML
(-)plugin.xml (+6 lines)
Lines 136-141 Link Here
136
			id="org.eclipse.wst.xml.core.ui.XMLCatalogPreferencePage">
136
			id="org.eclipse.wst.xml.core.ui.XMLCatalogPreferencePage">
137
         	<keywordReference id="org.eclipse.wst.xml.ui.xmlcatalog"/>
137
         	<keywordReference id="org.eclipse.wst.xml.ui.xmlcatalog"/>
138
		</page>
138
		</page>
139
		<page
140
			name="%XML_Typing"
141
			category="org.eclipse.wst.sse.ui.preferences.xml.source"
142
			class="org.eclipse.wst.xml.ui.internal.preferences.XMLTypingPreferencePage"
143
			id="org.eclipse.wst.sse.ui.preferences.xml.typing">
144
		</page>
139
	</extension>
145
	</extension>
140
	
146
	
141
	<!-- Keywords for preference and properties pages -->
147
	<!-- Keywords for preference and properties pages -->
(-)src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java (-1 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 92-95 Link Here
92
	 * </p>
92
	 * </p>
93
	 */
93
	 */
94
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
94
	public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
95
	
96
	/**
97
	 * The key to store the option for auto-completing comments while
98
	 * typing.
99
	 * <p>
100
	 * Value is of type <code>boolean</code>.
101
	 * </p>
102
	 */
103
	public static final String TYPING_COMPLETE_COMMENTS = "completeComments"; //$NON-NLS-1$
104
	
105
	/**
106
	 * The key to store the option for auto-completing end-tags after entering
107
	 * <code>&lt;/</code>
108
	 * <p>
109
	 * Value is of type <code>boolean</code>.
110
	 * </p>
111
	 */
112
	public static final String TYPING_COMPLETE_END_TAGS = "completeEndTags"; //$NON-NLS-1$
113
	
114
	/**
115
	 * The key to store the option for removing an end-tag if the start tag is
116
	 * converted to an empty-tag.
117
	 * <p>
118
	 * Value is of type <code>boolean</code>.
119
	 * </p>
120
	 */
121
	public static final String TYPING_REMOVE_END_TAGS = "removeEndTags"; //$NON-NLS-1$
95
}
122
}
(-)src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 122-127 Link Here
122
		if (template != null)
122
		if (template != null)
123
			templateName = template.getName();
123
			templateName = template.getName();
124
		store.setDefault(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
124
		store.setDefault(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
125
		
126
		// Defaults for the Typing preference page
127
		store.setDefault(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, true);
128
		store.setDefault(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, true);
129
		store.setDefault(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, true);
125
	}
130
	}
126
131
127
}
132
}
(-)src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java (-3 / +9 lines)
Lines 28-33 Link Here
28
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
28
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
29
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
29
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
30
import org.eclipse.wst.xml.ui.internal.Logger;
30
import org.eclipse.wst.xml.ui.internal.Logger;
31
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
32
import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
31
import org.w3c.dom.Node;
33
import org.w3c.dom.Node;
32
34
33
/**
35
/**
Lines 62-67 Link Here
62
			}
64
			}
63
		}
65
		}
64
	}
66
	}
67
	
68
	private boolean isPreferenceEnabled(String key) {
69
		return (key != null && XMLUIPlugin.getDefault().getPreferenceStore().getBoolean(key));
70
	}
65
71
66
	private boolean isCommentNode(IDOMNode node) {
72
	private boolean isCommentNode(IDOMNode node) {
67
		return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag());
73
		return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag());
Lines 82-88 Link Here
82
	private void smartRemoveEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
88
	private void smartRemoveEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
83
		try {
89
		try {
84
			// An opening tag is now a self-terminated end-tag
90
			// An opening tag is now a self-terminated end-tag
85
			if ("/".equals(command.text) && ">".equals(document.get(command.offset, 1))) { //$NON-NLS-1$ //$NON-NLS-2$
91
			if ("/".equals(command.text) && ">".equals(document.get(command.offset, 1)) && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
86
				IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
92
				IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
87
				if (node != null && !node.hasChildNodes()) {
93
				if (node != null && !node.hasChildNodes()) {
88
					IStructuredDocumentRegion region = node.getEndStructuredDocumentRegion();
94
					IStructuredDocumentRegion region = node.getEndStructuredDocumentRegion();
Lines 99-105 Link Here
99
105
100
	private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
106
	private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
101
		try {
107
		try {
102
			if (command.text.equals("-") && (document.getLength() >= 3) && document.get(command.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$
108
			if (command.text.equals("-") && (document.getLength() >= 3) && document.get(command.offset - 3, 3).equals("<!-") && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS)) { //$NON-NLS-1$ //$NON-NLS-2$
103
				command.text += "  -->"; //$NON-NLS-1$
109
				command.text += "  -->"; //$NON-NLS-1$
104
				command.shiftsCaret = false;
110
				command.shiftsCaret = false;
105
				command.caretOffset = command.offset + 2;
111
				command.caretOffset = command.offset + 2;
Lines 114-120 Link Here
114
120
115
	private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
121
	private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
116
		try {
122
		try {
117
			if (command.text.equals("/") && (document.getLength() >= 1) && document.get(command.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$
123
			if (command.text.equals("/") && (document.getLength() >= 1) && document.get(command.offset - 1, 1).equals("<") && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
118
				IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
124
				IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
119
				if (isCommentNode(parentNode)) {
125
				if (isCommentNode(parentNode)) {
120
					// loop and find non comment node parent
126
					// loop and find non comment node parent
(-)src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java (+5 lines)
Lines 266-271 Link Here
266
	public static String OpenFileFromSource_tooltip; // Resource bundle
266
	public static String OpenFileFromSource_tooltip; // Resource bundle
267
	public static String OpenFileFromSource_description; // Resource bundle
267
	public static String OpenFileFromSource_description; // Resource bundle
268
	public static String XMLContentOutlineConfiguration_0;
268
	public static String XMLContentOutlineConfiguration_0;
269
	public static String XMLTyping_Auto_Complete;
270
	public static String XMLTyping_Auto_Remove;
271
	public static String XMLTyping_Complete_Comments;
272
	public static String XMLTyping_Complete_End_Tags;
273
	public static String XMLTyping_Remove_End_Tags;
269
	public static String StructureSelectEnclosing_label;
274
	public static String StructureSelectEnclosing_label;
270
	public static String StructureSelectEnclosing_tooltip;
275
	public static String StructureSelectEnclosing_tooltip;
271
	public static String StructureSelectEnclosing_description;
276
	public static String StructureSelectEnclosing_description;
(-)src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties (+5 lines)
Lines 297-302 Link Here
297
OpenFileFromSource_tooltip=Open an editor on the selected link
297
OpenFileFromSource_tooltip=Open an editor on the selected link
298
OpenFileFromSource_description=Open an editor on the selected link
298
OpenFileFromSource_description=Open an editor on the selected link
299
XMLContentOutlineConfiguration_0=Show Attributes
299
XMLContentOutlineConfiguration_0=Show Attributes
300
XMLTyping_Auto_Complete=Automatically close
301
XMLTyping_Auto_Remove=Automatically remove
302
XMLTyping_Complete_Comments=&Comments
303
XMLTyping_Complete_End_Tags=&End-tags
304
XMLTyping_Remove_End_Tags=E&nd-tags when creating an empty-element tag
300
StructureSelectEnclosing_label=Enclosing Element
305
StructureSelectEnclosing_label=Enclosing Element
301
StructureSelectEnclosing_tooltip=Expand selection to include enclosing element
306
StructureSelectEnclosing_tooltip=Expand selection to include enclosing element
302
StructureSelectEnclosing_description=Expand selection to include enclosing element
307
StructureSelectEnclosing_description=Expand selection to include enclosing element
(-)src/org/eclipse/wst/xml/ui/internal/preferences/XMLTypingPreferencePage.java (+106 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
package org.eclipse.wst.xml.ui.internal.preferences;
13
14
import org.eclipse.jface.preference.IPreferenceStore;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Group;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
22
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
23
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
24
import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
25
 
26
public class XMLTypingPreferencePage extends AbstractPreferencePage {
27
28
	private Button fCloseComment;
29
	private Button fCloseEndTag;
30
	private Button fRemoveEndTag;
31
	
32
	protected Control createContents(Composite parent) {
33
		Composite composite = super.createComposite(parent, 1);
34
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID);
35
		
36
		createAutoComplete(composite);
37
		createAutoRemove(composite);
38
		
39
		setSize(composite);
40
		loadPreferences();
41
		
42
		return composite;
43
	}
44
	
45
	private void createAutoComplete(Composite parent) {
46
		Group group = createGroup(parent, 2);
47
		
48
		group.setText(XMLUIMessages.XMLTyping_Auto_Complete);
49
		
50
		fCloseComment = createCheckBox(group, XMLUIMessages.XMLTyping_Complete_Comments);
51
		((GridData) fCloseComment.getLayoutData()).horizontalSpan = 2;
52
		
53
		fCloseEndTag = createCheckBox(group, XMLUIMessages.XMLTyping_Complete_End_Tags);
54
		((GridData) fCloseEndTag.getLayoutData()).horizontalSpan = 2;
55
		
56
	}
57
	
58
	private void createAutoRemove(Composite parent) {
59
		Group group = createGroup(parent, 2);
60
		
61
		group.setText(XMLUIMessages.XMLTyping_Auto_Remove);
62
		
63
		fRemoveEndTag = createCheckBox(group, XMLUIMessages.XMLTyping_Remove_End_Tags);
64
		((GridData) fRemoveEndTag.getLayoutData()).horizontalSpan = 2;
65
	}
66
	
67
	public boolean performOk() {
68
		boolean result = super.performOk();
69
		
70
		XMLUIPlugin.getDefault().savePluginPreferences();
71
		
72
		return result;
73
	}
74
	
75
	protected void initializeValues() {
76
		initCheckbox(fCloseComment, XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
77
		initCheckbox(fCloseEndTag, XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
78
		initCheckbox(fRemoveEndTag, XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
79
	}
80
	
81
	protected void performDefaults() {
82
		defaultCheckbox(fCloseComment, XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
83
		defaultCheckbox(fCloseEndTag, XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
84
		defaultCheckbox(fRemoveEndTag, XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
85
	}
86
	
87
	private void initCheckbox(Button box, String key) {
88
		if(box != null && key != null)
89
			box.setSelection(getPreferenceStore().getBoolean(key));
90
	}
91
	
92
	private void defaultCheckbox(Button box, String key) {
93
		if(box != null && key != null)
94
			box.setSelection(getPreferenceStore().getDefaultBoolean(key));
95
	}
96
	
97
	protected void storeValues() {
98
		getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, (fCloseComment != null) ? fCloseComment.getSelection() : false);
99
		getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, (fCloseEndTag != null) ? fCloseEndTag.getSelection() : false);
100
		getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, (fRemoveEndTag != null) ? fRemoveEndTag.getSelection() : false);
101
	}
102
	
103
	protected IPreferenceStore doGetPreferenceStore() {
104
		return XMLUIPlugin.getDefault().getPreferenceStore();
105
	}
106
}

Return to bug 144313