comparison dwtx/jface/text/formatter/ContextBasedFormattingStrategy.d @ 129:eb30df5ca28b

Added JFace Text sources
author Frank Benoit <benoit@tionex.de>
date Sat, 23 Aug 2008 19:10:48 +0200
parents
children c4fb132a086c
comparison
equal deleted inserted replaced
128:8df1d4193877 129:eb30df5ca28b
1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13
14 module dwtx.jface.text.formatter.ContextBasedFormattingStrategy;
15
16 import dwt.dwthelper.utils;
17
18 import java.util.LinkedList;
19 import java.util.Map;
20
21 /**
22 * Formatting strategy for context based content formatting. Retrieves the preferences
23 * set on the formatting context's {@link FormattingContextProperties#CONTEXT_PREFERENCES}
24 * property and makes them available to subclasses.
25 * <p>
26 *
27 * @since 3.0
28 */
29 public abstract class ContextBasedFormattingStrategy : IFormattingStrategy, IFormattingStrategyExtension {
30
31 /** The current preferences for formatting */
32 private Map fCurrentPreferences= null;
33
34 /** The list of preferences for initiated the formatting steps */
35 private final LinkedList fPreferences= new LinkedList();
36
37 /*
38 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#format()
39 */
40 public void format() {
41 fCurrentPreferences= (Map)fPreferences.removeFirst();
42 }
43
44 /*
45 * @see dwtx.jface.text.formatter.IFormattingStrategy#format(java.lang.String, bool, java.lang.String, int[])
46 */
47 public String format(String content, bool start, String indentation, int[] positions) {
48 return null;
49 }
50
51 /*
52 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#formatterStarts(dwtx.jface.text.formatter.IFormattingContext)
53 */
54 public void formatterStarts(final IFormattingContext context) {
55 fPreferences.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES));
56 }
57
58 /*
59 * @see IFormattingStrategy#formatterStarts(String)
60 */
61 public void formatterStarts(final String indentation) {
62 // Do nothing
63 }
64
65 /*
66 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#formatterStops()
67 */
68 public void formatterStops() {
69 fPreferences.clear();
70
71 fCurrentPreferences= null;
72 }
73
74 /**
75 * Returns the preferences used for the current formatting step.
76 *
77 * @return The preferences for the current formatting step
78 */
79 public final Map getPreferences() {
80 return fCurrentPreferences;
81 }
82 }