• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.common.api;
18 
19 import com.android.annotations.NonNull;
20 import com.android.annotations.Nullable;
21 import com.google.common.annotations.Beta;
22 
23 import java.util.List;
24 
25 /**
26  * Callback interface for a {@link RuleAction}. The callback performs the actual
27  * work of the action, and this level of indirection allows multiple actions (which
28  * typically do not have their own class, only their own instances) to share a single
29  * implementation callback class.
30  * <p>
31  * <b>NOTE: This is not a public or final API; if you rely on this be prepared
32  * to adjust your code for the next tools release.</b>
33  * </p>
34  */
35 @Beta
36 public interface IMenuCallback {
37     /**
38      * Performs the actual work promised by the {@link RuleAction}.
39      * @param action The action being applied.
40      * @param selectedNodes The nodes to apply the action to
41      * @param valueId For a Choices action, the string id of the selected choice
42      * @param newValue For a toggle or for a flag, true if the item is being
43      *            checked, false if being unchecked. For enums this is not
44      *            useful; however for flags it allows one to add or remove items
45      *            to the flag's choices.
46      */
action( @onNull RuleAction action, @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable Boolean newValue)47     void action(
48             @NonNull RuleAction action,
49             @NonNull List<? extends INode> selectedNodes,
50             @Nullable String valueId,
51             @Nullable Boolean newValue);
52 
53     /** Callback which does nothing */
54     @NonNull
55     public static final IMenuCallback NONE = new IMenuCallback() {
56         @Override
57         public void action(
58                 @NonNull RuleAction action,
59                 @NonNull
60                 List<? extends INode> selectedNodes,
61                 @Nullable String valueId,
62                 @Nullable Boolean newValue) {
63         }
64     };
65 }
66