1 /**
2  * Created on Jan 3, 2009
3  *
4  * Copyright (C) Azureus Software, Inc, All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
19  */
20 
21 package org.gudy.azureus2.ui.swt.views.columnsetup;
22 
23 import org.gudy.azureus2.core3.internat.MessageText;
24 import org.gudy.azureus2.plugins.ui.tables.TableCell;
25 import org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener;
26 import org.gudy.azureus2.ui.swt.views.table.CoreTableColumnSWT;
27 
28 import com.aelitis.azureus.ui.common.table.TableColumnCore;
29 
30 /**
31  * @author TuxPaper
32  * @created Jan 3, 2009
33  *
34  */
35 public class ColumnTC_ChosenColumn
36 	extends CoreTableColumnSWT
37 	implements TableCellRefreshListener
38 {
39 	public static final String COLUMN_ID = "TableColumnChosenColumn";
40 
41 	/**
42 	 * @param name
43 	 * @param tableID
44 	 */
ColumnTC_ChosenColumn(String tableID)45 	public ColumnTC_ChosenColumn(String tableID) {
46 		super(COLUMN_ID, tableID);
47 		initialize(ALIGN_LEAD | ALIGN_TOP, POSITION_INVISIBLE, 175, INTERVAL_INVALID_ONLY);
48 	}
49 
50 	// @see org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell)
refresh(TableCell cell)51 	public void refresh(TableCell cell) {
52 		TableColumnCore column = (TableColumnCore) cell.getDataSource();
53 		int colPos = column.getPosition();
54 		// colPos can have gaps in numbers
55 		if (!cell.setSortValue(colPos) && cell.isValid()) {
56 			return;
57 		}
58 		String key = column.getTitleLanguageKey();
59 		String s = MessageText.getString(key, column.getName());
60 		//s = column.getPosition() + "] " + s;
61 		cell.setText(s);
62 		String info = MessageText.getString(key + ".info", "");
63 		cell.setToolTip(info);
64 	}
65 }
66