• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.common.api;
17 
18 import com.android.annotations.Nullable;
19 import com.google.common.annotations.Beta;
20 
21 import java.util.List;
22 
23 /**
24  * Default implementation of an {@link IViewRule}. This is a convenience
25  * implementation which makes it easier to supply designtime behavior for a
26  * custom view and just override the methods you are interested in.
27  * <p>
28  * <b>NOTE: This is not a public or final API; if you rely on this be prepared
29  * to adjust your code for the next tools release.</b>
30  */
31 @Beta
32 public class AbstractViewRule implements IViewRule {
33     @Override
onInitialize(String fqcn, IClientRulesEngine engine)34     public boolean onInitialize(String fqcn, IClientRulesEngine engine) {
35         return true;
36     }
37 
38     @Override
onDispose()39     public void onDispose() {
40     }
41 
42     @Override
43     @Nullable
getDisplayName()44     public String getDisplayName() {
45         // Default is to not override the selection display name.
46         return null;
47     }
48 
49     // ==== Selection ====
50 
51     @Override
52     @Nullable
getSelectionHint(INode parentNode, INode childNode)53     public List<String> getSelectionHint(INode parentNode, INode childNode) {
54         return null;
55     }
56 
57     @Override
addLayoutActions(List<RuleAction> actions, INode parentNode, List<? extends INode> children)58     public void addLayoutActions(List<RuleAction> actions, INode parentNode,
59             List<? extends INode> children) {
60     }
61 
62     @Override
addContextMenuActions(List<RuleAction> actions, INode node)63     public void addContextMenuActions(List<RuleAction> actions, INode node) {
64     }
65 
66     @Override
paintSelectionFeedback(IGraphics graphics, INode parentNode, List<? extends INode> childNodes, Object view)67     public void paintSelectionFeedback(IGraphics graphics, INode parentNode,
68             List<? extends INode> childNodes, Object view) {
69     }
70 
71     // ==== Drag & drop support ====
72 
73     // By default Views do not accept drag'n'drop.
74     @Override
75     @Nullable
onDropEnter(INode targetNode, Object targetView, IDragElement[] elements)76     public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) {
77         return null;
78     }
79 
80     @Override
81     @Nullable
onDropMove(INode targetNode, IDragElement[] elements, DropFeedback feedback, Point p)82     public DropFeedback onDropMove(INode targetNode, IDragElement[] elements,
83             DropFeedback feedback, Point p) {
84         return null;
85     }
86 
87     @Override
onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback)88     public void onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback) {
89         // ignore
90     }
91 
92     @Override
onDropped( INode targetNode, IDragElement[] elements, DropFeedback feedback, Point p)93     public void onDropped(
94             INode targetNode,
95             IDragElement[] elements,
96             DropFeedback feedback,
97             Point p) {
98         // ignore
99     }
100 
101 
102     @Override
onPaste(INode targetNode, Object targetView, IDragElement[] pastedElements)103     public void onPaste(INode targetNode, Object targetView, IDragElement[] pastedElements) {
104     }
105 
106     // ==== Create/Remove hooks ====
107 
108     @Override
onCreate(INode node, INode parent, InsertType insertType)109     public void onCreate(INode node, INode parent, InsertType insertType) {
110     }
111 
112     @Override
onChildInserted(INode child, INode parent, InsertType insertType)113     public void onChildInserted(INode child, INode parent, InsertType insertType) {
114     }
115 
116     @Override
onRemovingChildren(List<INode> deleted, INode parent)117     public void onRemovingChildren(List<INode> deleted, INode parent) {
118     }
119 
120     // ==== Resizing ====
121 
122     @Override
123     @Nullable
onResizeBegin(INode child, INode parent, SegmentType horizontalEdge, SegmentType verticalEdge, Object childView, Object parentView)124     public DropFeedback onResizeBegin(INode child, INode parent, SegmentType horizontalEdge,
125             SegmentType verticalEdge, Object childView, Object parentView) {
126         return null;
127     }
128 
129     @Override
onResizeUpdate(DropFeedback feedback, INode child, INode parent, Rect newBounds, int modifierMask)130     public void onResizeUpdate(DropFeedback feedback, INode child, INode parent, Rect newBounds,
131             int modifierMask) {
132     }
133 
134     @Override
onResizeEnd(DropFeedback feedback, INode child, final INode parent, final Rect newBounds)135     public void onResizeEnd(DropFeedback feedback, INode child, final INode parent,
136             final Rect newBounds) {
137     }
138 }
139