KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > renderings > AsyncCopyTableRenderingAction


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.memory.renderings;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.jface.viewers.StructuredViewer;
16 import org.eclipse.swt.widgets.Table;
17 import org.eclipse.swt.widgets.TableItem;
18
19 /**
20  * Copy action for <code>AbstractAsyncTableRendering</code>. Only copy what is visible in the view.
21  *
22  */

23 public class AsyncCopyTableRenderingAction extends
24         CopyTableRenderingToClipboardAction {
25
26     public AsyncCopyTableRenderingAction(AbstractBaseTableRendering rendering, StructuredViewer viewer) {
27         super(rendering, viewer);
28     }
29
30     protected String JavaDoc concatenateTableAsString(TableItem[] itemList) {
31         
32         Table table = null;
33         if (itemList.length > 0)
34             table = itemList[0].getParent();
35         
36         int topIndex = table.getTopIndex();
37         int itemCount = table.getItemCount();
38         int numVisibleLines = Math.min((table.getBounds().height / table.getItemHeight()) + 2, itemCount - topIndex);
39         
40         ArrayList JavaDoc items = new ArrayList JavaDoc();
41         
42         // start at top index until there is no more data in the table
43
for (int i=topIndex; i< topIndex + numVisibleLines; i++)
44         {
45             if (itemList[i].getData() != null)
46             {
47                 items.add(itemList[i]);
48             }
49             else
50                 break;
51         }
52         
53         return super.concatenateTableAsString((TableItem[]) items.toArray(new TableItem[items.size()]));
54     }
55 }
56
Popular Tags