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