~smaioli/azureus/ubuntu-experimental

« back to all changes in this revision

Viewing changes to com/aelitis/azureus/ui/swt/columns/subscriptions/ColumnSubscriptionName.java

MergedĀ VuzeĀ 4.2.0.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import org.eclipse.swt.graphics.GC;
22
22
import org.eclipse.swt.graphics.Image;
23
23
import org.eclipse.swt.graphics.Rectangle;
24
 
import org.gudy.azureus2.plugins.ui.tables.TableCell;
25
 
import org.gudy.azureus2.plugins.ui.tables.TableCellMouseEvent;
26
 
import org.gudy.azureus2.plugins.ui.tables.TableCellMouseListener;
27
 
import org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener;
28
 
import org.gudy.azureus2.ui.swt.ImageRepository;
 
24
 
29
25
import org.gudy.azureus2.ui.swt.shells.GCStringPrinter;
30
26
import org.gudy.azureus2.ui.swt.views.table.TableCellSWT;
31
27
import org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener;
32
28
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
33
29
 
34
30
import com.aelitis.azureus.core.subs.Subscription;
 
31
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
35
32
import com.aelitis.azureus.ui.swt.subscriptions.SubscriptionManagerUI;
36
33
import com.aelitis.azureus.ui.swt.subscriptions.SubscriptionManagerUI.sideBarItem;
 
34
import com.aelitis.azureus.ui.swt.views.skin.sidebar.SideBar;
 
35
import com.aelitis.azureus.ui.swt.views.skin.sidebar.SideBarEntrySWT;
 
36
 
 
37
import org.gudy.azureus2.core3.util.ByteFormatter;
 
38
import org.gudy.azureus2.plugins.ui.tables.*;
37
39
 
38
40
/**
39
41
 * @author Olivier Chalouhi
46
48
{
47
49
        public static String COLUMN_ID = "name";
48
50
        
49
 
        static {
50
 
                ImageRepository.addPath("com/aelitis/azureus/ui/images/ic_view.png", "ic_view");
51
 
        }
52
 
        
53
 
        
54
 
        Image viewImage;
 
51
        
55
52
        int imageWidth = -1;
56
53
        int imageHeight = -1;
57
54
 
59
56
        public ColumnSubscriptionName(String sTableID) {
60
57
                super(COLUMN_ID, POSITION_LAST, 350, sTableID);
61
58
                setMinWidth(300);
62
 
                
63
 
                viewImage = ImageRepository.getImage("ic_view");
64
59
        }
65
60
 
66
61
        public void refresh(TableCell cell) {
87
82
        
88
83
        public void cellPaint(GC gc, TableCellSWT cell) {
89
84
                Rectangle bounds = cell.getBounds();
 
85
                
 
86
                ImageLoader imageLoader = ImageLoader.getInstance();
 
87
                Image viewImage = imageLoader.getImage("ic_view");
90
88
                if(imageWidth == -1 || imageHeight == -1) {
91
89
                        imageWidth = viewImage.getBounds().width;
92
90
                        imageHeight = viewImage.getBounds().height;
96
94
                
97
95
                GCStringPrinter.printString(gc, cell.getText(), bounds,true,false,SWT.LEFT);
98
96
                gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
 
97
 
 
98
                imageLoader.releaseImage("ic_view");
99
99
                
100
100
                //gc.drawText(cell.getText(), bounds.x,bounds.y);
101
101
        }
109
109
                        if(event.x > cellWidth - imageWidth - 5 && event.x < cellWidth - 5) {
110
110
                                Subscription sub = (Subscription) cell.getDataSource();
111
111
                                if(sub != null) {
112
 
                                        sideBarItem item = (sideBarItem) sub.getUserData(SubscriptionManagerUI.SUB_IVIEW_KEY);
113
 
                                        item.activate();
 
112
                                        String key = "Subscription_" + ByteFormatter.encodeString(sub.getPublicKey());
 
113
                                        SideBarEntrySWT entry = SideBar.getEntry(key);
 
114
                                        if (entry.isInTree()) {
 
115
                                                entry.getSidebar().showEntryByID(key);
 
116
                                        }
114
117
                                }
115
118
                        }
116
119
                }