Home | History | Annotate | Download | only in ddms
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
      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.ddms;
     17 
     18 import com.android.ddmuilib.actions.ICommonAction;
     19 
     20 import org.eclipse.jface.action.Action;
     21 import org.eclipse.jface.resource.ImageDescriptor;
     22 
     23 /**
     24  * Basic action extending the jFace Action class in order to implement
     25  * ICommonAction.
     26  */
     27 public class CommonAction extends Action implements ICommonAction {
     28 
     29     private Runnable mRunnable;
     30 
     31     public CommonAction() {
     32         super();
     33     }
     34 
     35     public CommonAction(String text) {
     36         super(text);
     37     }
     38 
     39     /**
     40      * @param text
     41      * @param image
     42      */
     43     public CommonAction(String text, ImageDescriptor image) {
     44         super(text, image);
     45     }
     46 
     47     /**
     48      * @param text
     49      * @param style
     50      */
     51     public CommonAction(String text, int style) {
     52         super(text, style);
     53     }
     54 
     55     @Override
     56     public void run() {
     57         if (mRunnable != null) {
     58             mRunnable.run();
     59         }
     60     }
     61 
     62     /**
     63      * Sets the {@link Runnable}.
     64      * @see ICommonAction#setRunnable(Runnable)
     65      */
     66     public void setRunnable(Runnable runnable) {
     67         mRunnable = runnable;
     68     }
     69 }
     70