if (TemplatePreferencePage.useCodeFormatter()) {
if (TemplatePreferencePage.useCodeFormatter() && fTemplate.getContext().equals("java")) {
	public void apply(IDocument document) {		int indentationLevel= guessIndentationLevel(document, fContext.getStart());		String pattern= fTemplate.getPattern();		// resolve variables automatically		pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator);				pattern= fInterpolator.interpolate(pattern, fContext);//		pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator);		fInterpolator.interpolate(pattern, fModelEvaluator);		TemplateModel model= fModelEvaluator.getModel();		if (model.getEditableCount() == 0) {					pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator);			// side effect: stores selection			int cursorStart= fCursorSelectionEvaluator.getStart();			if (cursorStart == -1) {				fSelectionStart= pattern.length();				fSelectionEnd= fSelectionStart;			} else {						fSelectionStart= cursorStart;				fSelectionEnd= fCursorSelectionEvaluator.getEnd();						}					} else {			// resolve variables manually			fContext.setDocument(document);			TemplateEditorPopup popup= new TemplateEditorPopup(fContext, model);	        			if (!popup.open()) {				// leave caret offset				fSelectionStart= fContext.getEnd() - fContext.getStart();				fSelectionEnd= fSelectionStart;				return;			}   			pattern= popup.getText();    						int[] selection= popup.getSelection();			if (selection[0] == -1) {				fSelectionStart= pattern.length();				fSelectionEnd= fSelectionStart;			} else {				fSelectionStart= selection[0];				fSelectionEnd= selection[1];			}		}		if (TemplatePreferencePage.useCodeFormatter()) {			CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions());			formatter.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd});			formatter.setInitialIndentationLevel(indentationLevel);			pattern= formatter.formatSourceString(pattern);						int[] positions= formatter.getMappedPositions();			fSelectionStart= positions[0];			fSelectionEnd= positions[1];		} else {			CodeIndentator indentator= new CodeIndentator();			indentator.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd});			indentator.setIndentationLevel(indentationLevel);						pattern= indentator.indentate(pattern);			int[] positions= indentator.getMappedPositions();			fSelectionStart= positions[0];			fSelectionEnd= positions[1];			}		// strip indentation on first line		String finalString= trimBegin(pattern);		int charactersRemoved= pattern.length() - finalString.length();		fSelectionStart -= charactersRemoved;		fSelectionEnd -= charactersRemoved;		int start= fContext.getStart();		int length= fContext.getEnd() - start;		try {			document.replace(start, length, finalString);		} catch (BadLocationException x) {} // ignore			}