summaryrefslogtreecommitdiff
path: root/propertysheet/src/org/eclipse/wb/core/controls/flyout/PluginFlyoutPreferences.java
blob: 270dba0096a16cc61c306d6ec5f3647c525ebe90 (plain)
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
/*******************************************************************************
 * Copyright (c) 2011 Google, Inc.
 * 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
 *
 * Contributors:
 *    Google, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.wb.core.controls.flyout;

import org.eclipse.jface.preference.IPreferenceStore;

/**
 * Implementation of {@link IFlyoutPreferences} for {@link IPreferenceStore}.
 * 
 * @author scheglov_ke
 * @coverage core.control
 */
public final class PluginFlyoutPreferences implements IFlyoutPreferences {
  private final IPreferenceStore m_store;
  private final String m_dockLocationKey;
  private final String m_stateKey;
  private final String m_widthKey;

  ////////////////////////////////////////////////////////////////////////////
  //
  // Constructor
  //
  ////////////////////////////////////////////////////////////////////////////
  public PluginFlyoutPreferences(IPreferenceStore store, String prefix) {
    m_store = store;
    m_dockLocationKey = prefix + ".flyout.dockLocation";
    m_stateKey = prefix + ".flyout.state";
    m_widthKey = prefix + ".flyout.width";
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Access
  //
  ////////////////////////////////////////////////////////////////////////////
  /**
   * Initializes defaults using given values.
   */
  public void initializeDefaults(int location, int state, int width) {
    m_store.setDefault(m_dockLocationKey, location);
    m_store.setDefault(m_stateKey, state);
    m_store.setDefault(m_widthKey, width);
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // IFlyoutPreferences
  //
  ////////////////////////////////////////////////////////////////////////////
  public int getDockLocation() {
    return m_store.getInt(m_dockLocationKey);
  }

  public int getState() {
    return m_store.getInt(m_stateKey);
  }

  public int getWidth() {
    return m_store.getInt(m_widthKey);
  }

  public void setDockLocation(int location) {
    m_store.setValue(m_dockLocationKey, location);
  }

  public void setState(int state) {
    m_store.setValue(m_stateKey, state);
  }

  public void setWidth(int width) {
    m_store.setValue(m_widthKey, width);
  }
}