// Path: src/com/android/ddmuilib/ITableFocusListener.java
// public interface IFocusedTableActivator {
//     public void copy(Clipboard clipboard);
// 
//     public void selectAll();
// }


import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import java.util.Arrays;
/*
 * 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 com.android.ddmuilib;




/**
 * Base class for panel containing Table that need to support copy-paste-selectAll
 */
public abstract class TablePanel extends ClientDisplayPanel {
    private ITableFocusListener mGlobalListener;

    /**
     * Sets a TableFocusListener which will be notified when one of the tables
     * gets or loses focus.
     *
     * @param listener
     */
    public void setTableFocusListener(ITableFocusListener listener) {
        // record the global listener, to make sure table created after
        // this call will still be setup.
        mGlobalListener = listener;

        setTableFocusListener();
    }

    /**
     * Sets up the Table of object of the panel to work with the global listener.<br>
     * Default implementation does nothing.
     */
    protected void setTableFocusListener() {

    }

    /**
     * Sets up a Table object to notify the global Table Focus listener when it
     * gets or loses the focus.
     *
     * @param table the Table object.
     * @param colStart
     * @param colEnd
     */
    protected final void addTableToFocusListener(final Table table,
            final int colStart, final int colEnd) {
        // create the activator for this table
// Path: src/com/android/ddmuilib/ITableFocusListener.java
// public interface IFocusedTableActivator {
//     public void copy(Clipboard clipboard);
// 
//     public void selectAll();
// }


// Path: src/com/android/ddmuilib/TablePanel.java
import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import java.util.Arrays;

/*
 * 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 com.android.ddmuilib;




/**
 * Base class for panel containing Table that need to support copy-paste-selectAll
 */
public abstract class TablePanel extends ClientDisplayPanel {
    private ITableFocusListener mGlobalListener;

    /**
     * Sets a TableFocusListener which will be notified when one of the tables
     * gets or loses focus.
     *
     * @param listener
     */
    public void setTableFocusListener(ITableFocusListener listener) {
        // record the global listener, to make sure table created after
        // this call will still be setup.
        mGlobalListener = listener;

        setTableFocusListener();
    }

    /**
     * Sets up the Table of object of the panel to work with the global listener.<br>
     * Default implementation does nothing.
     */
    protected void setTableFocusListener() {

    }

    /**
     * Sets up a Table object to notify the global Table Focus listener when it
     * gets or loses the focus.
     *
     * @param table the Table object.
     * @param colStart
     * @param colEnd
     */
    protected final void addTableToFocusListener(final Table table,
            final int colStart, final int colEnd) {
        // create the activator for this table
        final IFocusedTableActivator activator = new IFocusedTableActivator() {