Skip to main content
summaryrefslogtreecommitdiffstats
blob: b2dda7a859fb5f575c46a17cbd84a0f3d01db848 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*******************************************************************************
 * Copyright (c) 2009 Oracle Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/ 
package org.eclipse.jst.pagedesigner.ui.preferences;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.pagedesigner.PDPlugin;
import org.eclipse.jst.pagedesigner.editors.HTMLEditor;

/**
 * Utility class for handling preferences related to the Web Page Editor plug-in.
 * <br>
 * <p><b>Provisional API - subject to change</b></p>
 */
public class PDPreferences extends AbstractPreferenceInitializer {

    /**
     * Preference used to set modes for the page designer when displayed in a
     * sash editor.
     */
    public static final String SASH_EDITOR_MODE_PREF = PDPreferences.class
            .getName()
            + ".sash_editor_mode"; //$NON-NLS-1$
    /**
     * The number of pixels of artificial cell padding to use Default = 0
     */
    public final static String CSS_USE_ARTIFICAL_CELL_PADDING = PDPreferences.class
            .getName()
            + ".CSSArtificalCellPadding"; //$NON-NLS-1$
    /**
     * Whether or not to enable absolute positioning Default = false
     */
    public final static String CSS_ENABLE_ABSOLUTE_POSITIONING = PDPreferences.class
            .getName()
            + ".CSSEnableAbsolutePositioning"; //$NON-NLS-1$
    /**
     * The default value for absolute positioning enablement
     */
    public static final boolean DEFAULT_CSS_ENABLE_ABSOLUTE_POSITIONING = false;
    /**
     * The default value for artificial cell padding.
     */
    public static final int DEFAULT_CSS_USE_ARTIFICIAL_CELL_PADDING = 4;

    private static IPreferenceStore getPreferenceStore()
    {
        return PDPlugin.getDefault().getPreferenceStore();
    }

    /**
     * @return the css absolute positioning enablement flag.
     */
    public boolean isCssAbsolutePositioningEnabled()
    {
        final IPreferenceStore store = getPreferenceStore();
        return store.getBoolean(CSS_ENABLE_ABSOLUTE_POSITIONING);
    }

    /**
     * @return the css artificial cell padding preference
     */
    public int getCssArtificialCellPadding()
    {
        final IPreferenceStore store = getPreferenceStore();
        return store.getInt(CSS_USE_ARTIFICAL_CELL_PADDING);
    }

    @Override
    public void initializeDefaultPreferences()
    {
        // Set default HTML editor split vertical (i.e. with top and bottom
        // pane)
        IPreferenceStore store = getPreferenceStore();
        store.setDefault(SASH_EDITOR_MODE_PREF, HTMLEditor.MODE_SASH_VERTICAL);
        store.setDefault(CSS_USE_ARTIFICAL_CELL_PADDING,
                DEFAULT_CSS_USE_ARTIFICIAL_CELL_PADDING);
        store.setDefault(CSS_ENABLE_ABSOLUTE_POSITIONING,
                DEFAULT_CSS_ENABLE_ABSOLUTE_POSITIONING);
    }
}

Back to the top