1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
17 
18 import com.android.annotations.NonNull;
19 
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.action.IMenuCreator;
22 import org.eclipse.jface.resource.ImageDescriptor;
23 import org.eclipse.jface.util.IPropertyChangeListener;
24 import org.eclipse.swt.events.HelpListener;
25 import org.eclipse.swt.widgets.Event;
26 
27 /**
28  * Implementation of {@link IAction} which delegates to a different
29  * {@link IAction} which allows a subclass to wrap and customize some of the
30  * behavior of a different action
31  */
32 public class DelegatingAction implements IAction {
33     private final IAction mAction;
34 
35     /**
36      * Construct a new delegate of the given action
37      *
38      * @param action the action to be delegated
39      */
DelegatingAction(@onNull IAction action)40     public DelegatingAction(@NonNull IAction action) {
41         mAction = action;
42     }
43 
44     @Override
addPropertyChangeListener(IPropertyChangeListener listener)45     public void addPropertyChangeListener(IPropertyChangeListener listener) {
46         mAction.addPropertyChangeListener(listener);
47     }
48 
49     @Override
getAccelerator()50     public int getAccelerator() {
51         return mAction.getAccelerator();
52     }
53 
54     @Override
getActionDefinitionId()55     public String getActionDefinitionId() {
56         return mAction.getActionDefinitionId();
57     }
58 
59     @Override
getDescription()60     public String getDescription() {
61         return mAction.getDescription();
62     }
63 
64     @Override
getDisabledImageDescriptor()65     public ImageDescriptor getDisabledImageDescriptor() {
66         return mAction.getDisabledImageDescriptor();
67     }
68 
69     @Override
getHelpListener()70     public HelpListener getHelpListener() {
71         return mAction.getHelpListener();
72     }
73 
74     @Override
getHoverImageDescriptor()75     public ImageDescriptor getHoverImageDescriptor() {
76         return mAction.getHoverImageDescriptor();
77     }
78 
79     @Override
getId()80     public String getId() {
81         return mAction.getId();
82     }
83 
84     @Override
getImageDescriptor()85     public ImageDescriptor getImageDescriptor() {
86         return mAction.getImageDescriptor();
87     }
88 
89     @Override
getMenuCreator()90     public IMenuCreator getMenuCreator() {
91         return mAction.getMenuCreator();
92     }
93 
94     @Override
getStyle()95     public int getStyle() {
96         return mAction.getStyle();
97     }
98 
99     @Override
getText()100     public String getText() {
101         return mAction.getText();
102     }
103 
104     @Override
getToolTipText()105     public String getToolTipText() {
106         return mAction.getToolTipText();
107     }
108 
109     @Override
isChecked()110     public boolean isChecked() {
111         return mAction.isChecked();
112     }
113 
114     @Override
isEnabled()115     public boolean isEnabled() {
116         return mAction.isEnabled();
117     }
118 
119     @Override
isHandled()120     public boolean isHandled() {
121         return mAction.isHandled();
122     }
123 
124     @Override
removePropertyChangeListener(IPropertyChangeListener listener)125     public void removePropertyChangeListener(IPropertyChangeListener listener) {
126         mAction.removePropertyChangeListener(listener);
127     }
128 
129     @Override
run()130     public void run() {
131         mAction.run();
132     }
133 
134     @Override
runWithEvent(Event event)135     public void runWithEvent(Event event) {
136         mAction.runWithEvent(event);
137     }
138 
139     @Override
setActionDefinitionId(String id)140     public void setActionDefinitionId(String id) {
141         mAction.setActionDefinitionId(id);
142     }
143 
144     @Override
setChecked(boolean checked)145     public void setChecked(boolean checked) {
146         mAction.setChecked(checked);
147     }
148 
149     @Override
setDescription(String text)150     public void setDescription(String text) {
151         mAction.setDescription(text);
152     }
153 
154     @Override
setDisabledImageDescriptor(ImageDescriptor newImage)155     public void setDisabledImageDescriptor(ImageDescriptor newImage) {
156         mAction.setDisabledImageDescriptor(newImage);
157     }
158 
159     @Override
setEnabled(boolean enabled)160     public void setEnabled(boolean enabled) {
161         mAction.setEnabled(enabled);
162     }
163 
164     @Override
setHelpListener(HelpListener listener)165     public void setHelpListener(HelpListener listener) {
166         mAction.setHelpListener(listener);
167     }
168 
169     @Override
setHoverImageDescriptor(ImageDescriptor newImage)170     public void setHoverImageDescriptor(ImageDescriptor newImage) {
171         mAction.setHoverImageDescriptor(newImage);
172     }
173 
174     @Override
setId(String id)175     public void setId(String id) {
176         mAction.setId(id);
177     }
178 
179     @Override
setImageDescriptor(ImageDescriptor newImage)180     public void setImageDescriptor(ImageDescriptor newImage) {
181         mAction.setImageDescriptor(newImage);
182     }
183 
184     @Override
setMenuCreator(IMenuCreator creator)185     public void setMenuCreator(IMenuCreator creator) {
186         mAction.setMenuCreator(creator);
187     }
188 
189     @Override
setText(String text)190     public void setText(String text) {
191         mAction.setText(text);
192     }
193 
194     @Override
setToolTipText(String text)195     public void setToolTipText(String text) {
196         mAction.setToolTipText(text);
197     }
198 
199     @Override
setAccelerator(int keycode)200     public void setAccelerator(int keycode) {
201         mAction.setAccelerator(keycode);
202     }
203 }
204