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 17 package com.android.ddmuilib; 18 19 import com.android.ddmlib.Client; 20 import com.android.ddmlib.IDevice; 21 22 /** 23 * A Panel that requires {@link Device}/{@link Client} selection notifications. 24 */ 25 public abstract class SelectionDependentPanel extends Panel { 26 private IDevice mCurrentDevice = null; 27 private Client mCurrentClient = null; 28 29 /** 30 * Returns the current {@link Device}. 31 * @return the current device or null if none are selected. 32 */ 33 protected final IDevice getCurrentDevice() { 34 return mCurrentDevice; 35 } 36 37 /** 38 * Returns the current {@link Client}. 39 * @return the current client or null if none are selected. 40 */ 41 protected final Client getCurrentClient() { 42 return mCurrentClient; 43 } 44 45 /** 46 * Sent when a new device is selected. 47 * @param selectedDevice the selected device. 48 */ 49 public final void deviceSelected(IDevice selectedDevice) { 50 if (selectedDevice != mCurrentDevice) { 51 mCurrentDevice = selectedDevice; 52 deviceSelected(); 53 } 54 } 55 56 /** 57 * Sent when a new client is selected. 58 * @param selectedClient the selected client. 59 */ 60 public final void clientSelected(Client selectedClient) { 61 if (selectedClient != mCurrentClient) { 62 mCurrentClient = selectedClient; 63 clientSelected(); 64 } 65 } 66 67 /** 68 * Sent when a new device is selected. The new device can be accessed 69 * with {@link #getCurrentDevice()}. 70 */ 71 public abstract void deviceSelected(); 72 73 /** 74 * Sent when a new client is selected. The new client can be accessed 75 * with {@link #getCurrentClient()}. 76 */ 77 public abstract void clientSelected(); 78 } 79