11package csep .ui .autoedit ;
22
3+ import org .eclipse .core .runtime .Platform ;
34import org .eclipse .jface .text .BadLocationException ;
45import org .eclipse .jface .text .DefaultIndentLineAutoEditStrategy ;
56import org .eclipse .jface .text .DocumentCommand ;
1213public class IndentLineAutoEditStrategy extends
1314 DefaultIndentLineAutoEditStrategy {
1415
16+ private static final String EDITORS_QUALIFIER = "org.eclipse.ui.editors" ;
17+
1518 /**
1619 * Start an indented block after certain lines
1720 */
@@ -31,9 +34,20 @@ protected void indentBlock(IDocument d, DocumentCommand c) {
3134 int p = (c .offset == d .getLength () ? c .offset - 1 : c .offset );
3235 IRegion info = d .getLineInformationOfOffset (p );
3336 String line = d .get (info .getOffset (), info .getLength ());
34- if (Helper .isBlockContainer (line ))
35- // TODO: get actual indentation string
36- c .text += "\t " ;
37+ if (Helper .isBlockContainer (line )) {
38+ if (Helper .isBlockContainer (line )) {
39+ boolean spacesForTabs = Platform .getPreferencesService ().getBoolean (EDITORS_QUALIFIER ,
40+ "spacesForTabs" , false , null );
41+ if (spacesForTabs ) {
42+ int tabWidth = Platform .getPreferencesService ().getInt (EDITORS_QUALIFIER , "tabWidth" , 4 , null );
43+ for (int i = 0 ; i < tabWidth ; i ++) {
44+ c .text += " " ;
45+ }
46+ } else {
47+ c .text += "\t " ;
48+ }
49+ }
50+ }
3751 }
3852 catch (BadLocationException e ) {
3953 // do nothing
0 commit comments