1 12 package org.eclipse.team.internal.ccvs.ui; 13 14 import org.eclipse.jface.viewers.*; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.swt.layout.GridData; 18 import org.eclipse.swt.widgets.*; 19 import org.eclipse.team.internal.ccvs.core.EditorsInfo; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.part.ViewPart; 22 23 30 public class EditorsView extends ViewPart { 31 public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.EditorsView"; 33 private Table table; 34 private TableViewer tableViewer; 35 36 class EditorsContentProvider implements IStructuredContentProvider { 37 38 41 public Object [] getElements(Object inputElement) { 42 return (EditorsInfo[]) inputElement; 43 } 44 45 48 public void dispose() { 49 } 50 51 54 public void inputChanged( 55 Viewer viewer, 56 Object oldInput, 57 Object newInput) { 58 } 59 60 } 61 62 class EditorsLabelProvider implements ITableLabelProvider { 63 66 public Image getColumnImage(Object element, int columnIndex) { 67 return null; 68 } 69 70 73 public String getColumnText(Object element, int columnIndex) { 74 if (element == null) 75 return ""; EditorsInfo info = (EditorsInfo) element; 77 78 String result = null; 79 switch (columnIndex) { 80 case 0 : 81 result = info.getFileName(); 82 break; 83 case 1 : 84 result = info.getUserName(); 85 break; 86 case 2 : 87 result = info.getDateString(); 88 break; 89 case 3 : 90 result = info.getComputerName(); 91 break; 92 } 93 if (result == null) result = ""; return result; 96 97 } 98 99 102 public void addListener(ILabelProviderListener listener) { 103 } 104 105 108 public void dispose() { 109 } 110 111 114 public boolean isLabelProperty(Object element, String property) { 115 return false; 116 } 117 118 121 public void removeListener(ILabelProviderListener listener) { 122 } 123 124 } 125 126 129 public void createPartControl(Composite parent) { 130 table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); 131 table.setHeaderVisible(true); 132 table.setLinesVisible(true); 133 134 GridData gridData = new GridData(GridData.FILL_BOTH); 135 gridData.widthHint=500; 136 gridData.heightHint=100; 137 table.setLayoutData(gridData); 138 139 TableLayout layout = new TableLayout(); 140 table.setLayout(layout); 141 142 tableViewer = new TableViewer(table); 143 createColumns(table, layout); 144 145 tableViewer.setContentProvider(new EditorsContentProvider()); 146 tableViewer.setLabelProvider(new EditorsLabelProvider()); 147 PlatformUI.getWorkbench().getHelpSystem().setHelp(tableViewer.getControl(), IHelpContextIds.CVS_EDITORS_VIEW); 149 } 150 public void setInput(EditorsInfo[] infos) { 151 tableViewer.setInput(infos); 152 } 153 159 private void createColumns(Table table, TableLayout layout) { 160 161 TableColumn col; 162 col = new TableColumn(table, SWT.NONE); 164 col.setResizable(true); 165 col.setText(CVSUIMessages.EditorsView_file); 166 layout.addColumnData(new ColumnWeightData(30, true)); 167 168 col = new TableColumn(table, SWT.NONE); 170 col.setResizable(true); 171 col.setText(CVSUIMessages.EditorsView_user); 172 layout.addColumnData(new ColumnWeightData(20, true)); 173 174 col = new TableColumn(table, SWT.NONE); 176 col.setResizable(true); 177 col.setText(CVSUIMessages.EditorsView_date); 178 layout.addColumnData(new ColumnWeightData(30, true)); 179 180 col = new TableColumn(table, SWT.NONE); 182 col.setResizable(true); 183 col.setText(CVSUIMessages.EditorsView_computer); 184 layout.addColumnData(new ColumnWeightData(20, true)); 185 186 } 187 188 191 public void setFocus() { 192 if (table != null) 193 table.setFocus(); 194 } 195 196 199 public Table getTable() { 200 return table; 201 } 202 203 } 204 | Popular Tags |