SelectionDependentViewPart.java :  » Plugin » microlog4eclipse » pl » polidea » lab » microlog4e » views » Android Open Source

Android Open Source » Plugin » microlog4eclipse 
microlog4eclipse » pl » polidea » lab » microlog4e » views » SelectionDependentViewPart.java
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package pl.polidea.lab.microlog4e.views;



import org.eclipse.swt.graphics.Device;
import org.eclipse.ui.part.ViewPart;

import pl.polidea.lab.microlog4e.J2meDevice;
import pl.polidea.lab.microlog4e.MicrologPlugin;
import pl.polidea.lab.microlog4e.MicrologPlugin.ISelectionListener;
import pl.polidea.lab.microlog4e.ddmlib.Client;
import pl.polidea.lab.microlog4e.ddmuilib.SelectionDependentPanel;

/**
 * A Workbench {@link ViewPart} that requires {@link Device}/{@link Client} selection notifications
 * from {@link MicrologPlugin} through the {@link ISelectionListener} interface.
 */
public abstract class SelectionDependentViewPart extends ViewPart implements ISelectionListener {

    private SelectionDependentPanel mPanel;

    protected final void setSelectionDependentPanel(SelectionDependentPanel panel) {
        // remember the panel
        mPanel = panel;

        // and add ourself as listener of selection events.
        MicrologPlugin.getDefault().addSelectionListener(this);
    }

    @Override
    public void dispose() {
        MicrologPlugin.getDefault().removeSelectionListener(this);
        super.dispose();
    }



    /**
     * Sent when a new {@link Device} is selected.
     * @param selectedDevice the selected device.
     *
     * @see ISelectionListener
     */
    public final void selectionChanged(J2meDevice selectedDevice) {
        mPanel.deviceSelected(selectedDevice);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.