001: package net.refractions.udig.project.ui.internal.tool.display;
002:
003: import org.eclipse.jface.action.IContributionItem;
004: import org.eclipse.jface.action.IContributionManager;
005: import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
006: import org.eclipse.swt.widgets.Composite;
007: import org.eclipse.swt.widgets.CoolBar;
008: import org.eclipse.swt.widgets.Menu;
009: import org.eclipse.swt.widgets.ToolBar;
010:
011: public class PlaceholderToolbarContributionItem implements
012: IContributionItem {
013:
014: /**
015: * The identifier for the replaced contribution item.
016: */
017: private final String id;
018:
019: /**
020: * The height of the SWT widget corresponding to the replaced contribution
021: * item.
022: */
023: private final int storedHeight;
024:
025: /**
026: * The minimum number of items to display on the replaced contribution
027: * item.
028: */
029: private final int storedMinimumItems;
030:
031: /**
032: * Whether the replaced contribution item would display chevrons.
033: */
034: private final boolean storedUseChevron;
035:
036: /**
037: * The width of the SWT widget corresponding to the replaced contribution
038: * item.
039: */
040: private final int storedWidth;
041:
042: /**
043: * Constructs a new instance of <code>PlaceholderContributionItem</code>
044: * from the item it is intended to replace.
045: *
046: * @param item
047: * The item to be replaced; must not be <code>null</code>.
048: */
049: public PlaceholderToolbarContributionItem(String id) {
050: this .id = id;
051: storedHeight = -1;
052: storedWidth = -1;
053: storedMinimumItems = 0;
054: storedUseChevron = false;
055: }
056:
057: /*
058: * (non-Javadoc)
059: *
060: * @see org.eclipse.jface.action.IContributionItem#dispose()
061: */
062: public void dispose() {
063: // Do nothing
064: }
065:
066: /*
067: * (non-Javadoc)
068: *
069: * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Composite)
070: */
071: public void fill(Composite parent) {
072: throw new UnsupportedOperationException();
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.CoolBar,
079: * int)
080: */
081: public void fill(CoolBar parent, int index) {
082: throw new UnsupportedOperationException();
083:
084: }
085:
086: /*
087: * (non-Javadoc)
088: *
089: * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Menu,
090: * int)
091: */
092: public void fill(Menu parent, int index) {
093: throw new UnsupportedOperationException();
094:
095: }
096:
097: /*
098: * (non-Javadoc)
099: *
100: * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.ToolBar,
101: * int)
102: */
103: public void fill(ToolBar parent, int index) {
104: throw new UnsupportedOperationException();
105:
106: }
107:
108: /**
109: * The height of the replaced contribution item.
110: *
111: * @return The height.
112: */
113: int getHeight() {
114: return storedHeight;
115: }
116:
117: /*
118: * (non-Javadoc)
119: *
120: * @see org.eclipse.jface.action.IContributionItem#getId()
121: */
122: public String getId() {
123: return id;
124: }
125:
126: /**
127: * The width of the replaced contribution item.
128: *
129: * @return The width.
130: */
131: int getWidth() {
132: return storedWidth;
133: }
134:
135: /**
136: * Returns the minimum number of tool items to show in the cool item.
137: *
138: * @return the minimum number of tool items to show, or <code>SHOW_ALL_ITEMS</code>
139: * if a value was not set
140: * @see #setMinimumItemsToShow(int)
141: * @since 3.2
142: */
143: int getMinimumItemsToShow() {
144: return storedMinimumItems;
145: }
146:
147: /**
148: * Returns whether chevron support is enabled.
149: *
150: * @return <code>true</code> if chevron support is enabled, <code>false</code>
151: * otherwise
152: * @since 3.2
153: */
154: boolean getUseChevron() {
155: return storedUseChevron;
156: }
157:
158: /*
159: * (non-Javadoc)
160: *
161: * @see org.eclipse.jface.action.IContributionItem#isDirty()
162: */
163: public boolean isDirty() {
164: return false;
165: }
166:
167: /*
168: * (non-Javadoc)
169: *
170: * @see org.eclipse.jface.action.IContributionItem#isDynamic()
171: */
172: public boolean isDynamic() {
173: return false;
174: }
175:
176: /*
177: * (non-Javadoc)
178: *
179: * @see org.eclipse.jface.action.IContributionItem#isEnabled()
180: */
181: public boolean isEnabled() {
182: // XXX Auto-generated method stub
183: return false;
184: }
185:
186: /*
187: * (non-Javadoc)
188: *
189: * @see org.eclipse.jface.action.IContributionItem#isGroupMarker()
190: */
191: public boolean isGroupMarker() {
192: return false;
193: }
194:
195: /*
196: * (non-Javadoc)
197: *
198: * @see org.eclipse.jface.action.IContributionItem#isSeparator()
199: */
200: public boolean isSeparator() {
201: return false;
202: }
203:
204: /*
205: * (non-Javadoc)
206: *
207: * @see org.eclipse.jface.action.IContributionItem#isVisible()
208: */
209: public boolean isVisible() {
210: return false;
211: }
212:
213: /*
214: * (non-Javadoc)
215: *
216: * @see org.eclipse.jface.action.IContributionItem#saveWidgetState()
217: */
218: public void saveWidgetState() {
219: // Do nothing.
220:
221: }
222:
223: /*
224: * (non-Javadoc)
225: *
226: * @see org.eclipse.jface.action.IContributionItem#setParent(org.eclipse.jface.action.IContributionManager)
227: */
228: public void setParent(IContributionManager parent) {
229: // Do nothing
230:
231: }
232:
233: /*
234: * (non-Javadoc)
235: *
236: * @see org.eclipse.jface.action.IContributionItem#setVisible(boolean)
237: */
238: public void setVisible(boolean visible) {
239: // Do nothing.
240: }
241:
242: /**
243: * Displays a string representation of this contribution item, which is
244: * really just a function of its identifier.
245: */
246: public String toString() {
247: return "PlaceholderContributionItem(" + id + ")"; //$NON-NLS-1$//$NON-NLS-2$
248: }
249:
250: /*
251: * (non-Javadoc)
252: *
253: * @see org.eclipse.jface.action.IContributionItem#update()
254: */
255: public void update() {
256: update(null);
257:
258: }
259:
260: /*
261: * (non-Javadoc)
262: *
263: * @see org.eclipse.jface.action.IContributionItem#update(java.lang.String)
264: */
265: public void update(String identifier) {
266: // Do nothing
267: }
268: }
|