Revision 9514a39b
b/src/gr/ebs/gss/client/FileList.java | ||
---|---|---|
49 | 49 |
import com.google.gwt.cell.client.AbstractCell; |
50 | 50 |
import com.google.gwt.cell.client.ImageResourceCell; |
51 | 51 |
import com.google.gwt.cell.client.SafeHtmlCell; |
52 |
import com.google.gwt.cell.client.TextCell; |
|
53 | 52 |
import com.google.gwt.cell.client.ValueUpdater; |
54 | 53 |
import com.google.gwt.core.client.GWT; |
55 | 54 |
import com.google.gwt.core.client.Scheduler; |
... | ... | |
62 | 61 |
import com.google.gwt.safehtml.client.SafeHtmlTemplates; |
63 | 62 |
import com.google.gwt.safehtml.shared.SafeHtml; |
64 | 63 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
65 |
import com.google.gwt.safehtml.shared.SafeHtmlUtils; |
|
66 | 64 |
import com.google.gwt.user.cellview.client.CellTable; |
67 | 65 |
import com.google.gwt.user.cellview.client.Column; |
66 |
import com.google.gwt.user.cellview.client.SimplePager; |
|
68 | 67 |
import com.google.gwt.user.cellview.client.TextColumn; |
69 | 68 |
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; |
70 | 69 |
import com.google.gwt.user.client.DOM; |
... | ... | |
77 | 76 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
78 | 77 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
79 | 78 |
import com.google.gwt.user.client.ui.VerticalPanel; |
79 |
import com.google.gwt.view.client.ListDataProvider; |
|
80 | 80 |
import com.google.gwt.view.client.MultiSelectionModel; |
81 | 81 |
import com.google.gwt.view.client.ProvidesKey; |
82 | 82 |
import com.google.gwt.view.client.SelectionChangeEvent; |
... | ... | |
86 | 86 |
* A composite that displays the list of files in a particular folder. |
87 | 87 |
*/ |
88 | 88 |
public class FileList extends Composite { |
89 |
|
|
89 |
ListDataProvider<FileResource> provider = new ListDataProvider<FileResource>(); |
|
90 | 90 |
interface TableResources extends DragAndDropCellTable.Resources { |
91 | 91 |
@Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"}) |
92 | 92 |
TableStyle cellTableStyle(); |
... | ... | |
257 | 257 |
public DragAndDropCellTable<FileResource> getCelltable() { |
258 | 258 |
return celltable; |
259 | 259 |
} |
260 |
/** |
|
261 |
* A label with the number of files in this folder. |
|
262 |
*/ |
|
263 |
private HTML countLabel = new HTML(); |
|
264 |
|
|
265 |
/** |
|
266 |
* The table widget with the file list. |
|
267 |
*/ |
|
268 |
//private FileTable table = new FileTable(GSS.VISIBLE_FILE_COUNT + 1, 8); |
|
269 |
|
|
270 |
/** |
|
271 |
* The navigation bar for paginating the results. |
|
272 |
*/ |
|
273 |
private HorizontalPanel navBar = new HorizontalPanel(); |
|
260 |
|
|
274 | 261 |
|
262 |
|
|
275 | 263 |
/** |
276 | 264 |
* The number of files in this folder. |
277 | 265 |
*/ |
... | ... | |
291 | 279 |
* The widget's image bundle. |
292 | 280 |
*/ |
293 | 281 |
private final Images images; |
294 |
VerticalPanel panel; |
|
295 | 282 |
|
296 | 283 |
private FileContextMenu menuShowing; |
297 | 284 |
private DragAndDropCellTable<FileResource> celltable; |
298 | 285 |
private final MultiSelectionModel<FileResource> selectionModel; |
299 | 286 |
private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>(); |
300 | 287 |
SortableHeader nameHeader; |
288 |
SimplePager pager; |
|
301 | 289 |
/** |
302 | 290 |
* Construct the file list widget. This entails setting up the widget |
303 | 291 |
* layout, fetching the number of files in the current folder from the |
... | ... | |
309 | 297 |
public FileList(Images _images) { |
310 | 298 |
images = _images; |
311 | 299 |
DragAndDropCellTable.Resources resources = GWT.create(TableResources.class); |
312 |
|
|
313 |
|
|
314 |
// Create the 'navigation' bar at the upper-right. |
|
315 |
HorizontalPanel innerNavBar = new HorizontalPanel(); |
|
316 |
innerNavBar.setStyleName("gss-ListNavBar"); |
|
317 |
innerNavBar.setSpacing(8); |
|
318 |
innerNavBar.add(countLabel); |
|
319 |
navBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); |
|
320 |
navBar.add(innerNavBar); |
|
321 |
navBar.setWidth("100%"); |
|
322 | 300 |
ProvidesKey<FileResource> keyProvider = new ProvidesKey<FileResource>(){ |
323 | 301 |
|
324 | 302 |
@Override |
... | ... | |
357 | 335 |
|
358 | 336 |
}; |
359 | 337 |
initDragOperation(nameColumn); |
360 |
celltable = new DragAndDropCellTable<FileResource>(100,resources,keyProvider){
|
|
338 |
celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT,resources,keyProvider){
|
|
361 | 339 |
@Override |
362 | 340 |
protected void onBrowserEvent2(Event event) { |
363 | 341 |
/*if (DOM.eventGetType((Event) event) == Event.ONMOUSEDOWN && DOM.eventGetButton((Event) event) == NativeEvent.BUTTON_RIGHT){ |
... | ... | |
366 | 344 |
super.onBrowserEvent2(event); |
367 | 345 |
} |
368 | 346 |
}; |
369 |
|
|
347 |
provider.addDataDisplay(celltable); |
|
370 | 348 |
celltable.addDragStopHandler(dragStop); |
371 | 349 |
celltable.addDragStartHandler(new DragStartEventHandler() { |
372 | 350 |
|
... | ... | |
441 | 419 |
},aheader = new SortableHeader("Last Modified")); |
442 | 420 |
allHeaders.add(aheader); |
443 | 421 |
aheader.setUpdater(new FileValueUpdater(aheader, "date")); |
422 |
VerticalPanel vp = new VerticalPanel(); |
|
423 |
vp.setWidth("100%"); |
|
424 |
celltable.setWidth("100%"); |
|
425 |
vp.add(celltable); |
|
426 |
pager = new SimplePager(SimplePager.TextLocation.CENTER); |
|
427 |
pager.setDisplay(celltable); |
|
428 |
//celltable.setPageSize(2); |
|
429 |
|
|
430 |
vp.add(pager); |
|
431 |
vp.setCellWidth(celltable, "100%"); |
|
444 | 432 |
|
445 |
initWidget(celltable); |
|
446 |
setStyleName("gss-List"); |
|
433 |
initWidget(vp); |
|
434 |
|
|
435 |
//initWidget(celltable); |
|
436 |
celltable.setStyleName("gss-List"); |
|
447 | 437 |
selectionModel = new MultiSelectionModel<FileResource>(); |
448 | 438 |
|
449 | 439 |
|
... | ... | |
947 | 937 |
*/ |
948 | 938 |
|
949 | 939 |
private void showCellTable(){ |
950 |
celltable.setRowCount(files.size()); |
|
951 |
celltable.setRowData(0,files); |
|
940 |
|
|
941 |
//celltable.setRowCount(files.size()); |
|
942 |
//celltable.setRowData(0,files); |
|
943 |
if(files.size()>=GSS.VISIBLE_FILE_COUNT){ |
|
944 |
pager.setVisible(true); |
|
945 |
} |
|
946 |
else{ |
|
947 |
pager.setVisible(false); |
|
948 |
} |
|
949 |
provider.setList(files); |
|
950 |
provider.refresh(); |
|
951 |
//celltable.redraw(); |
|
952 | 952 |
celltable.redrawHeaders(); |
953 | 953 |
} |
954 | 954 |
|
Also available in: Unified diff