selected
flag.
- *
- * @param row
- * @param selected
- */
- void styleRow(final int row, final boolean selected) {
- if (row != -1 && row >= 0)
- if (selected)
- table.getRowFormatter().addStyleName(row + 1, "gss-SelectedRow");
- else
- table.getRowFormatter().removeStyleName(row + 1, "gss-SelectedRow");
- }
-
- /**
- * Update the display of the file list.
- */
- void update() {
- int count = folderFileCount;
- int max = startIndex + GSS.VISIBLE_FILE_COUNT;
- if (max > count)
- max = count;
- folderTotalSize = 0;
-
- // Show the selected files.
- int i = 1;
- for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
- // Don't read past the end.
- // if (i > folderFileCount)
- // break;
- if (startIndex + i > folderFileCount)
- break;
- // Add a new row to the table, then set each of its columns to the
- // proper values.
- FileResource file = files.get(startIndex + i - 1);
- table.setWidget(i, 0, getFileIcon(file).createImage());
- table.getRowFormatter().addStyleName(i, "gss-fileRow");
-
- table.setHTML(i, 1, file.getName());
- table.setText(i, 2, file.getOwner());
- table.setText(i, 3, file.getPath());
- table.setText(i, 4, String.valueOf(file.getVersion()));
- table.setText(i, 5, String.valueOf(file.getFileSizeAsString()));
- final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
- table.setText(i, 6, formatter.format(file.getCreationDate()));
- folderTotalSize += file.getContentLength();
- }
-
- // Clear any remaining slots.
- for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
- table.setHTML(i, 0, " ");
- table.setHTML(i, 1, " ");
- table.setHTML(i, 2, " ");
- table.setHTML(i, 3, " ");
- table.setHTML(i, 4, " ");
- table.setHTML(i, 5, " ");
- table.setHTML(i, 6, " ");
- table.setHTML(i, 7, " ");
- }
-
- if (folderFileCount == 0) {
- showingStats = "no files";
- prevButton.setVisible(false);
- nextButton.setVisible(false);
- } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
- if (folderFileCount == 1)
- showingStats = "1 file";
- else
- showingStats = folderFileCount + " files";
- showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
- prevButton.setVisible(false);
- nextButton.setVisible(false);
- } else {
- showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
- prevButton.setVisible(startIndex != 0);
- nextButton.setVisible(startIndex + GSS.VISIBLE_FILE_COUNT < count);
- }
- updateCurrentlyShowingStats();
-
- }
-
- /**
- * Return the proper icon based on the MIME type of the file.
- *
- * @param file
- * @return the icon
- */
- private AbstractImagePrototype getFileIcon(FileResource file) {
- String mimetype = file.getContentType();
- boolean shared = file.isShared();
- if (mimetype == null)
- return shared ? images.documentShared() : images.document();
- mimetype = mimetype.toLowerCase();
- if (mimetype.startsWith("application/pdf"))
- return shared ? images.pdfShared() : images.pdf();
- else if (mimetype.startsWith("application/vnd.ms-excel"))
- return shared ? images.spreadsheetShared() : images.spreadsheet();
- else if (mimetype.startsWith("application/msword"))
- return shared ? images.wordprocessorShared() : images.wordprocessor();
- else if (mimetype.startsWith("application/vnd.ms-powerpoint"))
- return shared ? images.presentationShared() : images.presentation();
- else if (mimetype.startsWith("application/zip") ||
- mimetype.startsWith("application/gzip") ||
- mimetype.startsWith("application/x-gzip") ||
- mimetype.startsWith("application/x-tar") ||
- mimetype.startsWith("application/x-gtar"))
- return shared ? images.zipShared() : images.zip();
- else if (mimetype.startsWith("text/html"))
- return shared ? images.htmlShared() : images.html();
- else if (mimetype.startsWith("text/plain"))
- return shared ? images.txtShared() : images.txt();
- else if (mimetype.startsWith("image/"))
- return shared ? images.imageShared() : images.image();
- else if (mimetype.startsWith("video/"))
- return shared ? images.videoShared() : images.video();
- else if (mimetype.startsWith("audio/"))
- return shared ? images.audioShared() : images.audio();
- return shared ? images.documentShared() : images.document();
- }
-
- /**
- * Update status panel with currently showing file stats.
- */
- public void updateCurrentlyShowingStats() {
- GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
- }
-
- /**
- * Adjust the height of the table by adding and removing rows as necessary.
- *
- * @param newHeight the new height to reach
- */
- void resizeTableHeight(final int newHeight) {
- GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null);
- // Fill the rest with empty slots.
- if (newHeight > table.getOffsetHeight())
- while (newHeight > table.getOffsetHeight()) {
- table.resizeRows(table.getRowCount() + 1);
- GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
- }
- else
- while (newHeight < table.getOffsetHeight()) {
- table.resizeRows(table.getRowCount() - 1);
- GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
- }
- }
-
- public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection) {
- if (!updateSelectedFolder && !GSS.get().getFolders().getTrashItem().equals(GSS.get().getFolders().getCurrent()))
- updateFileCache(clearSelection);
- else if (GSS.get().getFolders().getCurrent() != null) {
- final DnDTreeItem folderItem = (DnDTreeItem) GSS.get().getFolders().getCurrent();
- if (folderItem.getFolderResource() != null) {
- update();
- GetCommand"); + sb.appendHtmlConstant(imageHtml); + sb.appendHtmlConstant(" | "); + + // Add the name and address. + sb.appendHtmlConstant(""); + sb.appendEscaped(value.getName()); + sb.appendHtmlConstant(" |
"); + sb.appendEscaped(value.getFileSizeAsString()); + sb.appendHtmlConstant(" |
selected
flag.
+ *
+ * @param row
+ * @param selected
+ */
+ void styleRow(final int row, final boolean selected) {
+
+ }
+
+ /**
+ * Update the display of the file list.
+ */
+ void update(boolean sort) {
+ int count = folderFileCount;
+ int max = startIndex + GSS.VISIBLE_FILE_COUNT;
+ if (max > count)
+ max = count;
+ folderTotalSize = 0;
+
+ copyListAndContinue(files);
+
+ if (folderFileCount == 0) {
+ showingStats = "no files";
+ } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
+ if (folderFileCount == 1)
+ showingStats = "1 file";
+ else
+ showingStats = folderFileCount + " files";
+ showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
+ } else {
+ showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
+ }
+ updateCurrentlyShowingStats();
+
+ }
+
+ /**
+ * Return the proper icon based on the MIME type of the file.
+ *
+ * @param file
+ * @return the icon
+ */
+ private ImageResource getFileIcon(FileResource file) {
+ String mimetype = file.getContentType();
+ boolean shared = false;
+ /*Folders folders = GSS.get().getFolders();
+ if(folders.getCurrent() != null && folders.isOthersSharedItem(folders.getCurrent())){
+ DnDTreeItem otherUser = (DnDTreeItem) folders.getUserOfSharedItem(folders.getCurrent());
+ if(otherUser==null)
+ shared = false;
+ else{
+ String uname = otherUser.getOtherUserResource().getUsername();
+ if(uname==null)
+ uname = ((DnDTreeItem)folders.getSharesItem()).getOthersResource().getUsernameOfUri(otherUser.getOtherUserResource().getUri());
+ if(uname != null)
+ shared = file.isShared();
+ }
+ }
+ else*/
+ shared = file.isShared();
+ if (mimetype == null)
+ return shared ? images.documentShared() : images.document();
+ mimetype = mimetype.toLowerCase();
+ if (mimetype.startsWith("application/pdf"))
+ return shared ? images.pdfShared() : images.pdf();
+ else if (mimetype.endsWith("excel"))
+ return shared ? images.spreadsheetShared() : images.spreadsheet();
+ else if (mimetype.endsWith("msword"))
+ return shared ? images.wordprocessorShared() : images.wordprocessor();
+ else if (mimetype.endsWith("powerpoint"))
+ return shared ? images.presentationShared() : images.presentation();
+ else if (mimetype.startsWith("application/zip") ||
+ mimetype.startsWith("application/gzip") ||
+ mimetype.startsWith("application/x-gzip") ||
+ mimetype.startsWith("application/x-tar") ||
+ mimetype.startsWith("application/x-gtar"))
+ return shared ? images.zipShared() : images.zip();
+ else if (mimetype.startsWith("text/html"))
+ return shared ? images.htmlShared() : images.html();
+ else if (mimetype.startsWith("text/plain"))
+ return shared ? images.txtShared() : images.txt();
+ else if (mimetype.startsWith("image/"))
+ return shared ? images.imageShared() : images.image();
+ else if (mimetype.startsWith("video/"))
+ return shared ? images.videoShared() : images.video();
+ else if (mimetype.startsWith("audio/"))
+ return shared ? images.audioShared() : images.audio();
+ return shared ? images.documentShared() : images.document();
+ }
+
+ /**
+ * Update status panel with currently showing file stats.
+ */
+ public void updateCurrentlyShowingStats() {
+ GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
+ }
+
+ /**
+ * Adjust the height of the table by adding and removing rows as necessary.
+ *
+ * @param newHeight the new height to reach
+ */
+ //void resizeTableHeight(final int newHeight) {
+ /*GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null);
+ // Fill the rest with empty slots.
+ if (newHeight > table.getOffsetHeight())
+ while (newHeight > table.getOffsetHeight()) {
+ table.resizeRows(table.getRowCount() + 1);
+ GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
+ }
+ else
+ while (newHeight < table.getOffsetHeight()) {
+ table.resizeRows(table.getRowCount() - 1);
+ GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
+ }*/
+ //}
+
+ public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection) {
+ updateFileCache(updateSelectedFolder, clearSelection, null);
+ }
+
+ public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection, final String newFilename) {
+ if (!updateSelectedFolder && !GSS.get().getTreeView().getSelection().equals(GSS.get().getTreeView().getTrash()))
+ updateFileCache(clearSelection);
+ else if (GSS.get().getTreeView().getSelection() != null) {
+ final RestResource selectedResource = GSS.get().getTreeView().getSelection();
+ if (selectedResource instanceof FolderResource) {
+
+ update(true);
+ }
+ }
+ updateFileCache(clearSelection);
+ }
+
+
+ private void updateFileCache(boolean clearSelection) {
+ updateFileCache(clearSelection, null);
+ }
+
+ /**
+ * Update the file cache with data from the server.
+ *
+ * @param newFilename the new name of the previously selected file,
+ * if a rename operation has taken place
+ */
+ private void updateFileCache(boolean clearSelection, String newFilename) {
+ if (clearSelection)
+ clearSelectedRows();
+ startIndex = 0;
+ final RestResource folderItem = GSS.get().getTreeView().getSelection();
+ // Validation.
+ if (folderItem == null || folderItem.equals(GSS.get().getTreeView().getOthers())) {
+ setFiles(new ArrayList