1 /*
2 * This file is a part of CAST project.
3 * (c) Copyright 2007, AGH University of Science & Technology
4 * https://caribou.iisg.agh.edu.pl/trac/cast
5 *
6 * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.eclipse.org/legal/epl-v10.html
10 */
11 /*
12 * File: DefaultActionBarContributor.java
13 * Created: 2007-02-05
14 * Author: cast
15 * $Id: DefaultFlayoutPreferences.java 2774 2009-04-22 13:56:23Z tmilos $
16 */
17
18 package pl.edu.agh.cast.editor;
19
20 import org.eclipse.draw2d.PositionConstants;
21 import org.eclipse.gef.ui.palette.FlyoutPaletteComposite;
22 import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences;
23
24 /**
25 * Default {@link FlyoutPreferences}.
26 *
27 * @author AGH CAST Team
28 */
29 public class DefaultFlayoutPreferences implements FlyoutPreferences {
30
31 /**
32 * Dock location. See {@link PositionConstants}.
33 */
34 private int dockLocation = PositionConstants.EAST;
35
36 /**
37 * Palette state. See {@link FlyoutPaletteComposite}.
38 */
39 private int paletteState = FlyoutPaletteComposite.STATE_PINNED_OPEN;
40
41 /**
42 * Palette width.
43 */
44 private int paletteWidth = 150;
45
46 /**
47 * {@inheritDoc}
48 *
49 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#getDockLocation()
50 */
51 public int getDockLocation() {
52 return dockLocation;
53 }
54
55 /**
56 * {@inheritDoc}
57 *
58 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#getPaletteState()
59 */
60 public int getPaletteState() {
61 return paletteState;
62 }
63
64 /**
65 * {@inheritDoc}
66 *
67 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#getPaletteWidth()
68 */
69 public int getPaletteWidth() {
70 return paletteWidth;
71 }
72
73 /**
74 * {@inheritDoc}
75 *
76 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#setDockLocation(int)
77 */
78 public void setDockLocation(int location) {
79 if (location != PositionConstants.EAST && location != PositionConstants.WEST){
80 throw new IllegalArgumentException("The dock location might be only EAST or WEST."); //$NON-NLS-1$
81 }
82 this.dockLocation = location;
83 }
84
85 /**
86 * {@inheritDoc}
87 *
88 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#setPaletteState(int)
89 */
90 public void setPaletteState(int state) {
91 if (state != FlyoutPaletteComposite.STATE_PINNED_OPEN && state != FlyoutPaletteComposite.STATE_COLLAPSED){
92 throw new IllegalArgumentException(
93 "The palette state might be only PINNED_OPEN or COLLAPSED."); //$NON-NLS-1$
94 }
95 this.paletteState = state;
96 }
97
98 /**
99 * {@inheritDoc}
100 *
101 * @see org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences#setPaletteWidth(int)
102 */
103 public void setPaletteWidth(int width) {
104 if(width < 0){
105 throw new IllegalArgumentException("The width must be at least 0."); //$NON-NLS-1$
106 }
107 this.paletteWidth = width;
108 }
109
110 }