Home | History | Annotate | Download | only in configuration
      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 
     17 package com.android.ide.eclipse.adt.internal.editors.layout.configuration;
     18 
     19 import static com.android.SdkConstants.ANDROID_STYLE_RESOURCE_PREFIX;
     20 import static com.android.SdkConstants.STYLE_RESOURCE_PREFIX;
     21 
     22 import org.eclipse.jface.action.Action;
     23 import org.eclipse.jface.action.IAction;
     24 
     25 /**
     26  * Action which brings up the "Create new XML File" wizard, pre-selected with the
     27  * animation category
     28  */
     29 class SelectThemeAction extends Action {
     30     private final ConfigurationChooser mConfiguration;
     31     private final String mTheme;
     32 
     33     public SelectThemeAction(ConfigurationChooser configuration, String title, String theme,
     34             boolean selected) {
     35         super(title, IAction.AS_RADIO_BUTTON);
     36         assert theme.startsWith(STYLE_RESOURCE_PREFIX)
     37             || theme.startsWith(ANDROID_STYLE_RESOURCE_PREFIX) : theme;
     38         mConfiguration = configuration;
     39         mTheme = theme;
     40         if (selected) {
     41             setChecked(selected);
     42         }
     43     }
     44 
     45     @Override
     46     public void run() {
     47         mConfiguration.selectTheme(mTheme);
     48         mConfiguration.onThemeChange();
     49     }
     50 }
     51