2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.ide.eclipse.ddms.views;
19 import com.android.ddmlib.Client;
20 import com.android.ddmlib.IDevice;
21 import com.android.ddmuilib.SelectionDependentPanel;
22 import com.android.ide.eclipse.ddms.DdmsPlugin;
23 import com.android.ide.eclipse.ddms.DdmsPlugin.ISelectionListener;
25 import org.eclipse.swt.graphics.Device;
26 import org.eclipse.ui.part.ViewPart;
29 * A Workbench {@link ViewPart} that requires {@link Device}/{@link Client} selection notifications
30 * from {@link DdmsPlugin} through the {@link ISelectionListener} interface.
32 public abstract class SelectionDependentViewPart extends ViewPart implements ISelectionListener {
34 private SelectionDependentPanel mPanel;
36 protected final void setSelectionDependentPanel(SelectionDependentPanel panel) {
40 // and add ourself as listener of selection events.
41 DdmsPlugin.getDefault().addSelectionListener(this);
45 public void dispose() {
46 DdmsPlugin.getDefault().removeSelectionListener(this);
51 * Sent when a new {@link Client} is selected.
52 * @param selectedClient The selected client.
54 * @see ISelectionListener
56 public final void selectionChanged(Client selectedClient) {
57 mPanel.clientSelected(selectedClient);
61 * Sent when a new {@link Device} is selected.
62 * @param selectedDevice the selected device.
64 * @see ISelectionListener
66 public final void selectionChanged(IDevice selectedDevice) {
67 mPanel.deviceSelected(selectedDevice);