Home | History | Annotate | Download | only in gle2
      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      */
     40     public DelegatingAction(@NonNull IAction action) {
     41         mAction = action;
     42     }
     43 
     44     @Override
     45     public void addPropertyChangeListener(IPropertyChangeListener listener) {
     46         mAction.addPropertyChangeListener(listener);
     47     }
     48 
     49     @Override
     50     public int getAccelerator() {
     51         return mAction.getAccelerator();
     52     }
     53 
     54     @Override
     55     public String getActionDefinitionId() {
     56         return mAction.getActionDefinitionId();
     57     }
     58 
     59     @Override
     60     public String getDescription() {
     61         return mAction.getDescription();
     62     }
     63 
     64     @Override
     65     public ImageDescriptor getDisabledImageDescriptor() {
     66         return mAction.getDisabledImageDescriptor();
     67     }
     68 
     69     @Override
     70     public HelpListener getHelpListener() {
     71         return mAction.getHelpListener();
     72     }
     73 
     74     @Override
     75     public ImageDescriptor getHoverImageDescriptor() {
     76         return mAction.getHoverImageDescriptor();
     77     }
     78 
     79     @Override
     80     public String getId() {
     81         return mAction.getId();
     82     }
     83 
     84     @Override
     85     public ImageDescriptor getImageDescriptor() {
     86         return mAction.getImageDescriptor();
     87     }
     88 
     89     @Override
     90     public IMenuCreator getMenuCreator() {
     91         return mAction.getMenuCreator();
     92     }
     93 
     94     @Override
     95     public int getStyle() {
     96         return mAction.getStyle();
     97     }
     98 
     99     @Override
    100     public String getText() {
    101         return mAction.getText();
    102     }
    103 
    104     @Override
    105     public String getToolTipText() {
    106         return mAction.getToolTipText();
    107     }
    108 
    109     @Override
    110     public boolean isChecked() {
    111         return mAction.isChecked();
    112     }
    113 
    114     @Override
    115     public boolean isEnabled() {
    116         return mAction.isEnabled();
    117     }
    118 
    119     @Override
    120     public boolean isHandled() {
    121         return mAction.isHandled();
    122     }
    123 
    124     @Override
    125     public void removePropertyChangeListener(IPropertyChangeListener listener) {
    126         mAction.removePropertyChangeListener(listener);
    127     }
    128 
    129     @Override
    130     public void run() {
    131         mAction.run();
    132     }
    133 
    134     @Override
    135     public void runWithEvent(Event event) {
    136         mAction.runWithEvent(event);
    137     }
    138 
    139     @Override
    140     public void setActionDefinitionId(String id) {
    141         mAction.setActionDefinitionId(id);
    142     }
    143 
    144     @Override
    145     public void setChecked(boolean checked) {
    146         mAction.setChecked(checked);
    147     }
    148 
    149     @Override
    150     public void setDescription(String text) {
    151         mAction.setDescription(text);
    152     }
    153 
    154     @Override
    155     public void setDisabledImageDescriptor(ImageDescriptor newImage) {
    156         mAction.setDisabledImageDescriptor(newImage);
    157     }
    158 
    159     @Override
    160     public void setEnabled(boolean enabled) {
    161         mAction.setEnabled(enabled);
    162     }
    163 
    164     @Override
    165     public void setHelpListener(HelpListener listener) {
    166         mAction.setHelpListener(listener);
    167     }
    168 
    169     @Override
    170     public void setHoverImageDescriptor(ImageDescriptor newImage) {
    171         mAction.setHoverImageDescriptor(newImage);
    172     }
    173 
    174     @Override
    175     public void setId(String id) {
    176         mAction.setId(id);
    177     }
    178 
    179     @Override
    180     public void setImageDescriptor(ImageDescriptor newImage) {
    181         mAction.setImageDescriptor(newImage);
    182     }
    183 
    184     @Override
    185     public void setMenuCreator(IMenuCreator creator) {
    186         mAction.setMenuCreator(creator);
    187     }
    188 
    189     @Override
    190     public void setText(String text) {
    191         mAction.setText(text);
    192     }
    193 
    194     @Override
    195     public void setToolTipText(String text) {
    196         mAction.setToolTipText(text);
    197     }
    198 
    199     @Override
    200     public void setAccelerator(int keycode) {
    201         mAction.setAccelerator(keycode);
    202     }
    203 }
    204