Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1391503 13f7…

…9535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 86f6e438db1248ef4c5ae2d4cf9eb840128e38ec 1 parent a30b3d4
Roger Lee Whitcomb authored
Showing with 3 additions and 3,649 deletions.
  1. +1 −1  build.properties
  2. +0 −1  build.xml
  3. +0 −83 core/src/org/apache/pivot/io/FileObjectList.java
  4. +1 −1  tests/src/org/apache/pivot/tests/issues/Pivot721.java
  5. +0 −4 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
  6. +0 −517 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
  7. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.json
  8. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_cs.json
  9. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_de.json
  10. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_es.json
  11. +0 −20 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_fr.json
  12. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_it.json
  13. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_pl.json
  14. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_ru.json
  15. +0 −21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_zh.json
  16. +0 −1,326 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java
  17. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.json
  18. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_cs.json
  19. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_de.json
  20. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_es.json
  21. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_fr.json
  22. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_it.json
  23. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_pl.json
  24. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_ru.json
  25. +0 −27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_zh.json
  26. +0 −55 wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_vfs_browser_sheet_skin.bxml
  27. +0 −115 wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_vfs_browser_skin.bxml
  28. +0 −442 wtk/src/org/apache/pivot/wtk/VFSBrowser.java
  29. +0 −127 wtk/src/org/apache/pivot/wtk/VFSBrowserListener.java
  30. +0 −398 wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java
  31. +0 −106 wtk/src/org/apache/pivot/wtk/VFSBrowserSheetListener.java
  32. +1 −6 wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
  33. +0 −36 wtk/src/org/apache/pivot/wtk/skin/VFSBrowserSkin.java
View
2  build.properties
@@ -27,7 +27,7 @@ compiler.source=1.6
compiler.target=1.6
compiler.encoding=UTF-8
compiler.indexJars=true
-compiler.arg=-Xlint -bootclasspath c:/jdk1.6.0_16/jre/lib/rt.jar
+compiler.arg=-Xlint
# Test properties
test.verbose=false
View
1  build.xml
@@ -166,7 +166,6 @@ limitations under the License.
<path refid="classpath.general"/>
<dirset dir="${basedir}" includes="**/${folder.bin}"/>
<fileset dir="@{project}" includes="lib/**/*.jar"/>
- <fileset dir="${basedir}" includes="wtk/lib/*.jar"/>
<project-lib/>
</classpath>
</javac>
View
83 core/src/org/apache/pivot/io/FileObjectList.java
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.io;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-import org.apache.commons.vfs2.FileObject;
-import org.apache.pivot.collections.adapter.ListAdapter;
-
-
-/**
- * Collection representing a list of files. Each entry in the list is unique;
- * i.e. a single file can't be added to the list more than once.
- * TODO: compute new serailVersionUIDs
- */
-public class FileObjectList extends ListAdapter<FileObject> {
- private static final long serialVersionUID = -6741822480264805279L;
-
- private static class FilePathComparator implements Comparator<FileObject>, Serializable {
- private static final long serialVersionUID = 6341769187574031281L;
-
- @Override
- public int compare(FileObject file1, FileObject file2) {
- String path1 = file1.getName().getPath();
- String path2 = file2.getName().getPath();
-
- return path1.compareTo(path2);
- }
- }
-
- private static final FilePathComparator filePathComparator = new FilePathComparator();
-
- public FileObjectList() {
- this(new java.util.ArrayList<FileObject>());
- }
-
- public FileObjectList(java.util.List<FileObject> files) {
- super(files);
-
- super.setComparator(filePathComparator);
- }
-
- @Override
- public int add(FileObject file) {
- int index = indexOf(file);
-
- if (index == -1) {
- index = super.add(file);
- }
-
- return index;
- }
-
- @Override
- public void insert(FileObject file, int index) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public FileObject update(int index, FileObject file) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setComparator(Comparator<FileObject> comparator) {
- throw new UnsupportedOperationException();
- }
-}
View
2  tests/src/org/apache/pivot/tests/issues/Pivot721.java
@@ -32,7 +32,7 @@
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
- window = (Window) bxmlSerializer.readObject(Pivot721.class, "pivot_721.bxml");
+ window = (Window) bxmlSerializer.readObject(Pivot734.class, "pivot_721.bxml");
// force fill into button renderer, but only in some buttons ...
ButtonDataRenderer filledButtonDataRenderer = new ButtonDataRenderer();
View
4 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
@@ -83,8 +83,6 @@
import org.apache.pivot.wtk.Theme;
import org.apache.pivot.wtk.Tooltip;
import org.apache.pivot.wtk.TreeView;
-import org.apache.pivot.wtk.VFSBrowser;
-import org.apache.pivot.wtk.VFSBrowserSheet;
import org.apache.pivot.wtk.media.Image;
/**
@@ -157,8 +155,6 @@ public TerraTheme() {
componentSkinMap.put(TextInput.class, TerraTextInputSkin.class);
componentSkinMap.put(Tooltip.class, TerraTooltipSkin.class);
componentSkinMap.put(TreeView.class, TerraTreeViewSkin.class);
- componentSkinMap.put(VFSBrowser.class, TerraVFSBrowserSkin.class);
- componentSkinMap.put(VFSBrowserSheet.class, TerraVFSBrowserSheetSkin.class);
componentSkinMap.put(TerraCalendarSkin.DateButton.class, TerraCalendarSkin.DateButtonSkin.class);
componentSkinMap.put(TerraExpanderSkin.ShadeButton.class, TerraExpanderSkin.ShadeButtonSkin.class);
View
517 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
@@ -1,517 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.wtk.skin.terra;
-
-import java.io.IOException;
-
-import org.apache.commons.vfs2.FileName;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.FileType;
-import org.apache.pivot.beans.BXML;
-import org.apache.pivot.beans.BXMLSerializer;
-import org.apache.pivot.collections.ArrayList;
-import org.apache.pivot.collections.Sequence;
-import org.apache.pivot.serialization.SerializationException;
-import org.apache.pivot.util.Filter;
-import org.apache.pivot.util.Vote;
-import org.apache.pivot.wtk.BoxPane;
-import org.apache.pivot.wtk.Button;
-import org.apache.pivot.wtk.ButtonPressListener;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.ComponentMouseButtonListener;
-import org.apache.pivot.wtk.Container;
-import org.apache.pivot.wtk.VFSBrowser;
-import org.apache.pivot.wtk.VFSBrowserListener;
-import org.apache.pivot.wtk.VFSBrowserSheet;
-import org.apache.pivot.wtk.VFSBrowserSheetListener;
-import org.apache.pivot.wtk.Form;
-import org.apache.pivot.wtk.Mouse;
-import org.apache.pivot.wtk.PushButton;
-import org.apache.pivot.wtk.Sheet;
-import org.apache.pivot.wtk.TablePane;
-import org.apache.pivot.wtk.TextInput;
-import org.apache.pivot.wtk.TextInputContentListener;
-import org.apache.pivot.wtk.Window;
-
-/**
- * Terra VFS browser sheet skin.
- */
-public class TerraVFSBrowserSheetSkin extends TerraSheetSkin implements VFSBrowserSheetListener {
-
- private static class SaveToFileFilter implements Filter<FileObject> {
- public final Filter<FileObject> sourceFilter;
-
- public SaveToFileFilter(Filter<FileObject> sourceFilter) {
- this.sourceFilter = sourceFilter;
- }
-
- @Override
- public boolean include(FileObject file) {
- return (file.getName().getType() != FileType.FOLDER
- || (sourceFilter != null
- && sourceFilter.include(file)));
- }
- }
-
- @BXML private TablePane tablePane = null;
- @BXML private BoxPane saveAsBoxPane = null;
- @BXML private TextInput saveAsTextInput = null;
- @BXML private VFSBrowser fileBrowser = null;
- @BXML private PushButton okButton = null;
- @BXML private PushButton cancelButton = null;
-
- private boolean updatingSelection = false;
- private int selectedDirectoryCount = 0;
-
- public TerraVFSBrowserSheetSkin() {
- setResizable(true);
- }
-
- @Override
- public void install(Component component) {
- super.install(component);
-
- final VFSBrowserSheet fileBrowserSheet = (VFSBrowserSheet)component;
- fileBrowserSheet.setMinimumWidth(360);
- fileBrowserSheet.setMinimumHeight(180);
-
- // Load the sheet content
- BXMLSerializer bxmlSerializer = new BXMLSerializer();
-
- Component content;
- try {
- content = (Component)bxmlSerializer.readObject(TerraVFSBrowserSheetSkin.class,
- "terra_vfs_browser_sheet_skin.bxml", true);
- } catch (IOException exception) {
- throw new RuntimeException(exception);
- } catch (SerializationException exception) {
- throw new RuntimeException(exception);
- }
-
- fileBrowserSheet.setContent(content);
-
- bxmlSerializer.bind(this, TerraVFSBrowserSheetSkin.class);
-
- // set the same rootDirectory to fileBrowser
- try {
- fileBrowser.setRootDirectory(fileBrowserSheet.getRootDirectory());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- saveAsTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
- @Override
- public void textChanged(TextInput textInput) {
- Form.clearFlag(saveAsBoxPane);
- updateOKButtonState();
- }
- });
-
- fileBrowser.getFileBrowserListeners().add(new VFSBrowserListener.Adapter() {
- @Override
- public void rootDirectoryChanged(VFSBrowser fileBrowserArgument,
- FileObject previousRootDirectory) {
- updatingSelection = true;
-
- try {
- fileBrowserSheet.setRootDirectory(fileBrowserArgument.getRootDirectory());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- updatingSelection = false;
-
- selectedDirectoryCount = 0;
- updateOKButtonState();
- }
-
- @Override
- public void selectedFileAdded(VFSBrowser fileBrowserArgument, FileObject file) {
- if (file.getName().getType() == FileType.FOLDER) {
- selectedDirectoryCount++;
- }
-
- updateOKButtonState();
- }
-
- @Override
- public void selectedFileRemoved(VFSBrowser fileBrowserArgument, FileObject file) {
- if (file.getName().getType() == FileType.FOLDER) {
- selectedDirectoryCount--;
- }
-
- updateOKButtonState();
- }
-
- @Override
- public void selectedFilesChanged(VFSBrowser fileBrowserArgument,
- Sequence<FileObject> previousSelectedFiles) {
- selectedDirectoryCount = 0;
-
- Sequence<FileObject> selectedFiles = fileBrowserArgument.getSelectedFiles();
- for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
- FileObject selectedFile = selectedFiles.get(i);
-
- if (selectedFile.getName().getType() == FileType.FOLDER) {
- selectedDirectoryCount++;
- }
- }
-
- if (!fileBrowserArgument.isMultiSelect()) {
- FileObject selectedFile = fileBrowserArgument.getSelectedFile();
-
- if (selectedFile != null
- && selectedFile.getName().getType() != FileType.FOLDER) {
- saveAsTextInput.setText(selectedFile.getName().getPath());
- }
- }
-
- updateOKButtonState();
- }
- });
-
- fileBrowser.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
- private FileObject file = null;
-
- @Override
- public boolean mouseClick(Component componentArgument, Mouse.Button button, int x, int y, int count) {
- boolean consumed = super.mouseClick(componentArgument, button, x, y, count);
-
- VFSBrowserSheet.Mode mode = fileBrowserSheet.getMode();
-
- if (count == 1) {
- file = fileBrowser.getFileAt(x, y);
- } else if (count == 2) {
- FileObject fileLocal = fileBrowser.getFileAt(x, y);
-
- if (fileLocal != null
- && this.file != null
- && fileLocal.equals(this.file)
- && fileBrowser.isFileSelected(fileLocal)) {
- if (mode == VFSBrowserSheet.Mode.OPEN
- || mode == VFSBrowserSheet.Mode.OPEN_MULTIPLE) {
- if (fileLocal.getName().getType() != FileType.FOLDER) {
- fileBrowserSheet.close(true);
- consumed = true;
- }
- }
- }
- }
-
- return consumed;
- }
- });
-
- okButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- fileBrowserSheet.close(true);
- }
- });
-
- cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- fileBrowserSheet.close(false);
- }
- });
-
- // Add this as a file browser sheet listener
- fileBrowserSheet.getFileBrowserSheetListeners().add(this);
-
- modeChanged(fileBrowserSheet, null);
- rootDirectoryChanged(fileBrowserSheet, null);
- selectedFilesChanged(fileBrowserSheet, null);
- }
-
- public boolean isHideDisabledFiles() {
- return (Boolean)fileBrowser.getStyles().get("hideDisabledFiles");
- }
-
- public void setHideDisabledFiles(boolean hideDisabledFiles) {
- fileBrowser.getStyles().put("hideDisabledFiles", hideDisabledFiles);
- }
-
- public boolean getShowOKButtonFirst() {
- Container parent = okButton.getParent();
- return parent.indexOf(okButton) < parent.indexOf(cancelButton);
- }
-
- public void setShowOKButtonFirst(boolean showOKButtonFirst) {
- if (showOKButtonFirst != getShowOKButtonFirst()) {
- Container parent = okButton.getParent();
- parent.remove(okButton);
- parent.remove(cancelButton);
-
- if (showOKButtonFirst) {
- parent.add(okButton);
- parent.add(cancelButton);
- } else {
- parent.add(cancelButton);
- parent.add(okButton);
- }
- }
- }
-
- @Override
- public void windowOpened(Window window) {
- super.windowOpened(window);
- window.requestFocus();
- }
-
- @Override
- public Vote previewSheetClose(final Sheet sheet, final boolean result) {
- Vote vote = null;
-
- if (result
- && !okButton.isEnabled()) {
- vote = Vote.DENY;
- } else {
- if (result) {
- updatingSelection = true;
-
- VFSBrowserSheet fileBrowserSheet = (VFSBrowserSheet)sheet;
- VFSBrowserSheet.Mode mode = fileBrowserSheet.getMode();
- FileSystemManager manager = fileBrowserSheet.getManager();
- FileName baseFileName = fileBrowserSheet.getBaseFileName();
-
- switch (mode) {
- case OPEN:
- case OPEN_MULTIPLE:
- case SAVE_TO: {
- try {
- fileBrowserSheet.setSelectedFiles(fileBrowser.getSelectedFiles());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- break;
- }
-
- case SAVE_AS: {
- String fileName = saveAsTextInput.getText();
- // Contents of the entry field could be:
- // 1. Just a new file name in the current root directory
- // 2. A relative or absolute path that is an existing directory
- // to navigate to
- // 3. A relative or absolute path including the new file name
- // in an existing directory
- // So, first make it an absolute path
- // TODO: all this logic needs changing (not sure how) with VFS
- // because you could type in a whole new URI and have to change
- // managers
- try {
- FileObject selectedFile = manager.resolveFile(fileName);
- //if (!selectedFile.isAbsolute() && !fileName.startsWith(File.separator)) {
- if (!baseFileName.isDescendent(selectedFile.getName())) {
- selectedFile = manager.resolveFile(fileBrowser.getRootDirectory(), fileName);
- } else {
- // TODO: is there really anything to do here?
- //selectedFile = selectedFile.getAbsoluteFile();
- }
- if (selectedFile.exists() && selectedFile.getType() == FileType.FOLDER) {
- try {
- // TODO: what to do about canonical file representations?
- FileObject root = /* selectedFile.getCanonicalFile(); */selectedFile;
- fileBrowserSheet.setRootDirectory(root);
- fileBrowser.setRootDirectory(root);
- saveAsTextInput.setText("");
- } catch (IOException ioe) {
- Form.setFlag(saveAsBoxPane, new Form.Flag());
- }
- selectedFile = null;
- vote = Vote.DENY;
- } else {
- FileObject root = selectedFile.getParent();
- if (root != null && root.exists() && root.getType() == FileType.FOLDER) {
- try {
- // TODO: canonical file again
- //fileBrowserSheet.setRootDirectory(root.getCanonicalFile());
- fileBrowserSheet.setRootDirectory(root);
- selectedFile = manager.resolveFile(selectedFile.getName().getPath());
- }
- catch (IOException ioe) {
- Form.setFlag(saveAsBoxPane, new Form.Flag());
- selectedFile = null;
- vote = Vote.DENY;
- }
- } else {
- // Could be an error message here ("Directory does not exist")
- Form.setFlag(saveAsBoxPane, new Form.Flag());
- selectedFile = null;
- vote = Vote.DENY;
- }
- }
- if (selectedFile != null) {
- fileBrowserSheet.setSelectedFiles(new ArrayList<FileObject>(selectedFile));
- }
- } catch (FileSystemException fse) {
- Form.setFlag(saveAsBoxPane, new Form.Flag());
- vote = Vote.DENY;
- }
- break;
- }
- }
-
- updatingSelection = false;
- }
- if (vote == null) {
- vote = super.previewSheetClose(sheet, result);
- }
- }
-
- return vote;
- }
-
- @Override
- public void managerChanged(VFSBrowserSheet fileBrowserSheet,
- FileSystemManager previousManager) {
- // TODO: what to do here?
- }
-
- @Override
- public void modeChanged(VFSBrowserSheet fileBrowserSheet,
- VFSBrowserSheet.Mode previousMode) {
- VFSBrowserSheet.Mode mode = fileBrowserSheet.getMode();
-
- fileBrowser.getStyles().put("keyboardFolderTraversalEnabled",
- (mode != VFSBrowserSheet.Mode.SAVE_TO));
-
- switch (mode) {
- case OPEN: {
- saveAsBoxPane.setVisible(false);
- fileBrowser.setMultiSelect(false);
- break;
- }
-
- case OPEN_MULTIPLE: {
- saveAsBoxPane.setVisible(false);
- fileBrowser.setMultiSelect(true);
- break;
- }
-
- case SAVE_AS: {
- saveAsBoxPane.setVisible(true);
- fileBrowser.setMultiSelect(false);
- break;
- }
-
- case SAVE_TO: {
- saveAsBoxPane.setVisible(false);
- fileBrowser.setMultiSelect(false);
- break;
- }
- }
-
- updateDisabledFileFilter();
- updateOKButtonState();
- }
-
- @Override
- public void rootDirectoryChanged(VFSBrowserSheet fileBrowserSheet,
- FileObject previousRootDirectory) {
- if (!updatingSelection) {
- try {
- fileBrowser.setRootDirectory(fileBrowserSheet.getRootDirectory());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- @Override
- public void selectedFilesChanged(VFSBrowserSheet fileBrowserSheet,
- Sequence<FileObject> previousSelectedFiles) {
- if (!updatingSelection) {
- Sequence<FileObject> selectedFiles = fileBrowserSheet.getSelectedFiles();
- try {
- fileBrowser.setSelectedFiles(selectedFiles);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- if (fileBrowser.getSelectedFiles().getLength() == 0
- && selectedFiles.getLength() == 1) {
- // The file does not currently exist; set the file name in the
- // text input if the parent directory is the same as the root
- // directory
- FileObject selectedFile = selectedFiles.get(0);
-
- try {
- FileObject rootDirectory = fileBrowser.getRootDirectory();
- if (rootDirectory.equals(selectedFile.getParent())) {
- saveAsTextInput.setText(selectedFile.getName().getPath());
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
- }
-
- @Override
- public void disabledFileFilterChanged(VFSBrowserSheet fileBrowserSheet,
- Filter<FileObject> previousDisabledFileFilter) {
- updateDisabledFileFilter();
- }
-
- private void updateDisabledFileFilter() {
- VFSBrowserSheet fileBrowserSheet = (VFSBrowserSheet)getComponent();
- Filter<FileObject> disabledFileFilter = fileBrowserSheet.getDisabledFileFilter();
-
- VFSBrowserSheet.Mode mode = fileBrowserSheet.getMode();
- if (mode == VFSBrowserSheet.Mode.SAVE_TO) {
- disabledFileFilter = new SaveToFileFilter(disabledFileFilter);
- }
-
- fileBrowser.setDisabledFileFilter(disabledFileFilter);
- }
-
- private void updateOKButtonState() {
- VFSBrowserSheet fileBrowserSheet = (VFSBrowserSheet)getComponent();
-
- VFSBrowserSheet.Mode mode = fileBrowserSheet.getMode();
- Sequence<FileObject> selectedFiles = fileBrowser.getSelectedFiles();
-
- switch (mode) {
- case OPEN:
- case OPEN_MULTIPLE: {
- okButton.setEnabled(selectedFiles.getLength() > 0
- && selectedDirectoryCount == 0);
- break;
- }
-
- case SAVE_AS: {
- okButton.setEnabled(saveAsTextInput.getCharacterCount() > 0);
- break;
- }
-
- case SAVE_TO: {
- okButton.setEnabled(selectedDirectoryCount > 0);
- break;
- }
- }
- }
-
- public void addComponent(Component component) {
- TablePane.Row row = new TablePane.Row(-1);
- row.add(component);
- Sequence<TablePane.Row> rows = tablePane.getRows();
- rows.insert(row, rows.getLength() - 1);
- }
-}
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Save as:",
- ok: "OK",
- cancel: "Cancel"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_cs.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Uložit jako:",
- ok: "OK",
- cancel: "Zrušit"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_de.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Speichern als:",
- ok: "OK",
- cancel: "Abbruch"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_es.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Guardar como:",
- ok: "Aceptar",
- cancel: "Cancelar"
-}
-
View
20 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_fr.json
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Sauvegarder sous:",
- ok: "OK",
- cancel: "Annuler"
-}
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_it.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Salva come:",
- ok: "OK",
- cancel: "Annulla"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_pl.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Zapisz jako:",
- ok: "OK",
- cancel: "Anuluj"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_ru.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "Сохранить как:",
- ok: "OK",
- cancel: "Отмена"
-}
-
View
21 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin_zh.json
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ saveAs: "保存为:",
- ok: "确定",
- cancel: "取消"
-}
-
View
1,326 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java
@@ -1,1326 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.wtk.skin.terra;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.io.IOException;
-import java.io.Serializable;
-import java.text.DateFormat;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-
-import org.apache.commons.vfs2.FileFilter;
-import org.apache.commons.vfs2.FileName;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSelectInfo;
-import org.apache.commons.vfs2.FileSelector;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.FileType;
-import org.apache.pivot.beans.BXML;
-import org.apache.pivot.beans.BXMLSerializer;
-import org.apache.pivot.collections.ArrayList;
-import org.apache.pivot.collections.Dictionary;
-import org.apache.pivot.collections.List;
-import org.apache.pivot.collections.Sequence;
-import org.apache.pivot.serialization.SerializationException;
-import org.apache.pivot.text.FileSizeFormat;
-import org.apache.pivot.util.Filter;
-import org.apache.pivot.util.concurrent.AbortException;
-import org.apache.pivot.util.concurrent.Task;
-import org.apache.pivot.util.concurrent.TaskExecutionException;
-import org.apache.pivot.util.concurrent.TaskListener;
-import org.apache.pivot.wtk.ActivityIndicator;
-import org.apache.pivot.wtk.BoxPane;
-import org.apache.pivot.wtk.Button;
-import org.apache.pivot.wtk.ButtonPressListener;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.ComponentKeyListener;
-import org.apache.pivot.wtk.ComponentMouseButtonListener;
-import org.apache.pivot.wtk.Container;
-import org.apache.pivot.wtk.Dimensions;
-import org.apache.pivot.wtk.VFSBrowser;
-import org.apache.pivot.wtk.FocusTraversalDirection;
-import org.apache.pivot.wtk.GridPane;
-import org.apache.pivot.wtk.HorizontalAlignment;
-import org.apache.pivot.wtk.ImageView;
-import org.apache.pivot.wtk.Insets;
-import org.apache.pivot.wtk.Keyboard;
-import org.apache.pivot.wtk.Keyboard.KeyCode;
-import org.apache.pivot.wtk.Label;
-import org.apache.pivot.wtk.ListButton;
-import org.apache.pivot.wtk.ListButtonSelectionListener;
-import org.apache.pivot.wtk.ListView;
-import org.apache.pivot.wtk.Mouse;
-import org.apache.pivot.wtk.Platform;
-import org.apache.pivot.wtk.Point;
-import org.apache.pivot.wtk.PushButton;
-import org.apache.pivot.wtk.ScrollPane;
-import org.apache.pivot.wtk.SortDirection;
-import org.apache.pivot.wtk.Span;
-import org.apache.pivot.wtk.StackPane;
-import org.apache.pivot.wtk.TableView;
-import org.apache.pivot.wtk.TableViewSelectionListener;
-import org.apache.pivot.wtk.TableViewSortListener;
-import org.apache.pivot.wtk.TaskAdapter;
-import org.apache.pivot.wtk.TextInput;
-import org.apache.pivot.wtk.TextInputContentListener;
-import org.apache.pivot.wtk.VerticalAlignment;
-import org.apache.pivot.wtk.media.Image;
-import org.apache.pivot.wtk.skin.VFSBrowserSkin;
-
-/**
- * Terra file browser skin.
- */
-public class TerraVFSBrowserSkin extends VFSBrowserSkin {
-
- public static final String HOME_DIRECTORY = System.getProperty("user.home");
-
- /**
- * Abstract renderer for displaying file system contents.
- */
- public static abstract class FileRenderer extends BoxPane {
- protected ImageView imageView = new ImageView();
- protected Label label = new Label();
-
- public static final int ICON_WIDTH = 16;
- public static final int ICON_HEIGHT = 16;
-
- public static final Image FOLDER_IMAGE;
- public static final Image HOME_FOLDER_IMAGE;
- public static final Image FILE_IMAGE;
-
- static {
- try {
- FOLDER_IMAGE = Image.load(FileRenderer.class.getResource("folder.png"));
- HOME_FOLDER_IMAGE = Image.load(FileRenderer.class.getResource("folder_home.png"));
- FILE_IMAGE = Image.load(FileRenderer.class.getResource("page_white.png"));
- } catch (TaskExecutionException exception) {
- throw new RuntimeException(exception);
- }
- }
-
- public FileRenderer() {
- getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
-
- add(imageView);
- add(label);
-
- imageView.setPreferredSize(ICON_WIDTH, ICON_HEIGHT);
- imageView.getStyles().put("backgroundColor", null);
- }
-
- @Override
- public void setSize(int width, int height) {
- super.setSize(width, height);
-
- // Since this component doesn't have a parent, it won't be validated
- // via layout; ensure that it is valid here
- validate();
- }
-
- /**
- * Obtains the icon to display for a given file.
- *
- * @param file
- */
- public static Image getIcon(FileObject file) {
- Image icon;
- if (file.getName().getType() == FileType.FOLDER) {
- icon = file.getName().getPath().equals(HOME_DIRECTORY) ? HOME_FOLDER_IMAGE : FOLDER_IMAGE;
- } else {
- icon = FILE_IMAGE;
- }
-
- return icon;
- }
- }
-
- /**
- * List button file renderer.
- */
- public static class ListButtonFileRenderer extends FileRenderer implements Button.DataRenderer {
- public ListButtonFileRenderer() {
- getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
- }
-
- @Override
- public void render(Object data, Button button, boolean highlight) {
- if (data != null) {
- FileObject file = (FileObject)data;
-
- // Update the image view
- imageView.setImage(getIcon(file));
- imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
-
- // Update the label
- String text = file.getName().getBaseName();
- if (text.length() == 0) {
- text = System.getProperty("file.separator");
- }
-
- label.setText(text);
- }
- }
-
- @Override
- public String toString(Object item) {
- FileObject file = (FileObject)item;
- String text = file.getName().getBaseName();
- if (text.length() == 0) {
- text = System.getProperty("file.separator");
- }
-
- return text;
- }
- }
-
- /**
- * List view file renderer.
- */
- public static class ListViewFileRenderer extends FileRenderer implements ListView.ItemRenderer {
- public ListViewFileRenderer() {
- getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
- getStyles().put("padding", new Insets(2, 3, 2, 3));
- }
-
- @Override
- public void render(Object item, int index, ListView listView, boolean selected,
- boolean checked, boolean highlighted, boolean disabled) {
- label.getStyles().put("font", listView.getStyles().get("font"));
-
- Object color = null;
- if (listView.isEnabled() && !disabled) {
- if (selected) {
- if (listView.isFocused()) {
- color = listView.getStyles().get("selectionColor");
- } else {
- color = listView.getStyles().get("inactiveSelectionColor");
- }
- } else {
- color = listView.getStyles().get("color");
- }
- } else {
- color = listView.getStyles().get("disabledColor");
- }
-
- label.getStyles().put("color", color);
-
- if (item != null) {
- FileObject file = (FileObject)item;
-
- // Update the image view
- imageView.setImage(getIcon(file));
- imageView.getStyles().put("opacity",
- (listView.isEnabled() && !disabled) ? 1.0f : 0.5f);
-
- // Update the label
- String text = file.getName().getPath();
- if (text.length() == 0) {
- text = FileName.ROOT_PATH;
- }
-
- label.setText(text);
- }
- }
-
- @Override
- public String toString(Object item) {
- FileObject file = (FileObject)item;
- String text = file.getName().getPath();
- if (text.length() == 0) {
- text = FileName.ROOT_PATH;
- }
-
- return text;
- }
- }
-
- /**
- * Table view file renderer.
- */
- public static class TableViewFileRenderer extends FileRenderer
- implements TableView.CellRenderer {
- public static final String NAME_KEY = "name";
- public static final String SIZE_KEY = "size";
- public static final String LAST_MODIFIED_KEY = "lastModified";
-
- public TableViewFileRenderer() {
- getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
- getStyles().put("padding", new Insets(2));
- }
-
- @Override
- public void render(Object row, int rowIndex, int columnIndex,
- TableView tableView, String columnName,
- boolean selected, boolean highlighted, boolean disabled) {
- if (row != null) {
- FileObject file = (FileObject)row;
-
- String text = null;
- Image icon = null;
-
- try {
- if (columnName.equals(NAME_KEY)) {
- text = file.getName().getPath();
- icon = getIcon(file);
- getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
- } else if (columnName.equals(SIZE_KEY)) {
- long length = file.getContent().getSize();
- text = FileSizeFormat.getInstance().format(length);
- getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
- } else if (columnName.equals(LAST_MODIFIED_KEY)) {
- long lastModified = file.getContent().getLastModifiedTime();
- Date lastModifiedDate = new Date(lastModified);
- text = DATE_FORMAT.format(lastModifiedDate);
- getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
- } else {
- System.err.println("Unexpected column name in " + getClass().getName()
- + ": " + columnName);
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- label.setText(text);
- imageView.setImage(icon);
- }
-
- Font font = (Font)tableView.getStyles().get("font");
- label.getStyles().put("font", font);
-
- Color color;
- if (tableView.isEnabled() && !disabled) {
- if (selected) {
- if (tableView.isFocused()) {
- color = (Color)tableView.getStyles().get("selectionColor");
- } else {
- color = (Color)tableView.getStyles().get("inactiveSelectionColor");
- }
- } else {
- color = (Color)tableView.getStyles().get("color");
- }
- } else {
- color = (Color)tableView.getStyles().get("disabledColor");
- }
-
- label.getStyles().put("color", color);
- }
-
- @Override
- public String toString(Object row, String columnName) {
- String string;
-
- FileObject file = (FileObject)row;
- try {
- if (columnName.equals(NAME_KEY)) {
- string = file.getName().getPath();
- } else if (columnName.equals(SIZE_KEY)) {
- long length = file.getContent().getSize();
- string = FileSizeFormat.getInstance().format(length);
- } else if (columnName.equals(LAST_MODIFIED_KEY)) {
- long lastModified = file.getContent().getLastModifiedTime();
- Date lastModifiedDate = new Date(lastModified);
- string = DATE_FORMAT.format(lastModifiedDate);
- } else {
- System.err.println("Unexpected column name in " + getClass().getName()
- + ": " + columnName);
- string = null;
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- return string;
- }
- }
-
- /**
- * Abstract base class for drive renderers.
- */
- public static abstract class DriveRenderer extends BoxPane {
- protected ImageView imageView = new ImageView();
- protected Label label = new Label();
-
- public static final int ICON_WIDTH = 16;
- public static final int ICON_HEIGHT = 16;
-
- public static final Image DRIVE_IMAGE;
-
- static {
- try {
- DRIVE_IMAGE = Image.load(FileRenderer.class.getResource("drive.png"));
- } catch (TaskExecutionException exception) {
- throw new RuntimeException(exception);
- }
- }
-
- public DriveRenderer() {
- getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
-
- add(imageView);
- add(label);
-
- imageView.setPreferredSize(ICON_WIDTH, ICON_HEIGHT);
- imageView.getStyles().put("backgroundColor", null);
- }
-
- @Override
- public void setSize(int width, int height) {
- super.setSize(width, height);
-
- // Since this component doesn't have a parent, it won't be validated
- // via layout; ensure that it is valid here
- validate();
- }
- }
-
- /**
- * List button drive renderer.
- */
- public static class ListButtonDriveRenderer extends DriveRenderer
- implements Button.DataRenderer {
- public ListButtonDriveRenderer() {
- getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
- }
-
- @Override
- public void render(Object data, Button button, boolean highlight) {
- if (data != null) {
- FileObject file = (FileObject)data;
-
- // Update the image view
- imageView.setImage(DRIVE_IMAGE);
- imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
-
- // Update the label
- label.setText(file.toString());
- }
- }
-
- @Override
- public String toString(Object data) {
- return null;
- }
- }
-
- /**
- * List view drive renderer.
- */
- public static class ListViewDriveRenderer extends DriveRenderer
- implements ListView.ItemRenderer {
- public ListViewDriveRenderer() {
- getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
- getStyles().put("padding", new Insets(2, 3, 2, 3));
- }
-
- @Override
- public void render(Object item, int index, ListView listView, boolean selected,
- boolean checked, boolean highlighted, boolean disabled) {
- label.getStyles().put("font", listView.getStyles().get("font"));
-
- Object color = null;
- if (listView.isEnabled() && !disabled) {
- if (selected) {
- if (listView.isFocused()) {
- color = listView.getStyles().get("selectionColor");
- } else {
- color = listView.getStyles().get("inactiveSelectionColor");
- }
- } else {
- color = listView.getStyles().get("color");
- }
- } else {
- color = listView.getStyles().get("disabledColor");
- }
-
- label.getStyles().put("color", color);
-
- if (item != null) {
- FileObject file = (FileObject)item;
-
- // Update the image view
- imageView.setImage(DRIVE_IMAGE);
- imageView.getStyles().put("opacity",
- (listView.isEnabled() && !disabled) ? 1.0f : 0.5f);
-
- // Update the label
- label.setText(file.toString());
- }
- }
-
- @Override
- public String toString(Object item) {
- return null;
- }
- }
-
- public static abstract class FileComparator implements Comparator<FileObject>, Serializable {
- private static final long serialVersionUID = 1L;
-
- @Override
- public abstract int compare(FileObject f1, FileObject f2);
- }
-
- public static class FileNameAscendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- boolean file1IsDirectory = f1.getName().getType() == FileType.FOLDER;
- boolean file2IsDirectory = f2.getName().getType() == FileType.FOLDER;
-
- int result;
- if (file1IsDirectory && !file2IsDirectory) {
- result = -1;
- } else if (!file1IsDirectory && file2IsDirectory) {
- result = 1;
- } else {
- // Do the compare according to the rules of the file system
- result = f1.compareTo(f2);
- }
- return result;
- }
- }
-
- public static class FileNameDescendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- boolean file1IsDirectory = f1.getName().getType() == FileType.FOLDER;
- boolean file2IsDirectory = f2.getName().getType() == FileType.FOLDER;
-
- int result;
- if (file1IsDirectory && !file2IsDirectory) {
- result = -1;
- } else if (!file1IsDirectory && file2IsDirectory) {
- result = 1;
- } else {
- // Do the compare according to the rules of the file system
- result = f2.compareTo(f1);
- }
- return result;
- }
- }
-
- public static class FileSizeAscendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- try {
- return Long.signum(f1.getContent().getSize() - f2.getContent().getSize());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- public static class FileSizeDescendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- try {
- return Long.signum(f2.getContent().getSize() - f1.getContent().getSize());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- public static class FileDateAscendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- try {
- return Long.signum(f1.getContent().getLastModifiedTime() - f2.getContent().getLastModifiedTime());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- public static class FileDateDescendingComparator extends FileComparator {
- private static final long serialVersionUID = 1L;
- @Override
- public int compare(FileObject f1, FileObject f2) {
- try {
- return Long.signum(f2.getContent().getLastModifiedTime() - f1.getContent().getLastModifiedTime());
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- /**
- * FileObject comparator.
- */
- public static FileComparator getFileComparator(String columnName, SortDirection sortDirection) {
- if (columnName.equals("name")) {
- return sortDirection == SortDirection.ASCENDING ?
- new FileNameAscendingComparator() :
- new FileNameDescendingComparator();
- }
- else if (columnName.equals("size")) {
- return sortDirection == SortDirection.ASCENDING ?
- new FileSizeAscendingComparator() :
- new FileSizeDescendingComparator();
- }
- else if (columnName.equals("lastModified")) {
- return sortDirection == SortDirection.ASCENDING ?
- new FileDateAscendingComparator() :
- new FileDateDescendingComparator();
- }
- else {
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Include file filter.
- */
- public static class IncludeFileFilter implements Filter<FileObject> {
- private String match;
-
- public IncludeFileFilter() {
- this(null);
- }
-
- public IncludeFileFilter(String match) {
- this.match = (match == null ? null : match.toLowerCase());
- }
-
- @Override
- public boolean include(FileObject file) {
- boolean include = true;
-
- if (match != null) {
- String name = file.getName().getPath();
- name = name.toLowerCase();
-
- if (match.startsWith("*")) {
- if (match.length() == 1) {
- include = true;
- } else {
- include = name.contains(match.substring(1));
- }
- } else {
- include = name.startsWith(match);
- }
- }
-
- return include;
- }
- }
-
- public static class FullFileSelector implements FileSelector {
- private Filter<FileObject> includeFileFilter;
- private Filter<FileObject> excludeFileFilter;
-
- public FullFileSelector(Filter<FileObject> includeFileFilter, Filter<FileObject> excludeFileFilter) {
- this.includeFileFilter = includeFileFilter;
- this.excludeFileFilter = excludeFileFilter;
- }
-
- @Override
- public boolean includeFile(FileSelectInfo fileInfo) {
- boolean include = HIDDEN_FILE_FILTER.accept(fileInfo);
- if (include
- && includeFileFilter != null) {
- include = includeFileFilter.include(fileInfo.getFile());
- }
- if (include
- && excludeFileFilter != null) {
- include = !excludeFileFilter.include(fileInfo.getFile());
- }
- return include;
- }
-
- @Override
- public boolean traverseDescendents(FileSelectInfo fileInfo) {
- return false;
- }
- }
-
- private class RefreshFileListTask extends Task<ArrayList<FileObject>> {
- private Filter<FileObject> includeFileFilter;
- private Filter<FileObject> excludeFileFilter;
- private FileComparator fileComparator;
-
- public RefreshFileListTask(Filter<FileObject> includeFileFilter,
- Filter<FileObject> excludeFileFilter,
- FileComparator fileComparator) {
- this.includeFileFilter = includeFileFilter;
- this.excludeFileFilter = excludeFileFilter;
- this.fileComparator = fileComparator;
- }
-
- @Override
- public ArrayList<FileObject> execute() {
- VFSBrowser fileBrowser = (VFSBrowser)getComponent();
-
- FileObject rootDirectory = fileBrowser.getRootDirectory();
- if (abort) {
- throw new AbortException();
- }
-
- try {
- FileObject[] files = rootDirectory.findFiles(new FullFileSelector(includeFileFilter, excludeFileFilter));
- if (abort) {
- throw new AbortException();
- }
-
- Arrays.sort(files, fileComparator);
-
- return new ArrayList<FileObject>(files, 0, files.length);
-
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- private Component content = null;
-
- @BXML private ListButton driveListButton = null;
- @BXML private ListButton pathListButton = null;
- @BXML private PushButton goUpButton = null;
- @BXML private PushButton newFolderButton = null;
- @BXML private PushButton goHomeButton = null;
- @BXML private TextInput searchTextInput = null;
-
- @BXML private StackPane fileStackPane = null;
- @BXML private ScrollPane fileScrollPane = null;
- @BXML private TableView fileTableView = null;
-
- private ActivityIndicator indicator = null;
- private GridPane activityGrid = null;
-
- private boolean keyboardFolderTraversalEnabled = true;
- private boolean hideDisabledFiles = false;
-
- private boolean updatingSelection = false;
- private boolean refreshRoots = true;
-
- private RefreshFileListTask refreshFileListTask = null;
-
- private static final FileFilter HIDDEN_FILE_FILTER = new FileFilter() {
- @Override
- public boolean accept(FileSelectInfo fileInfo) {
- try {
- return !fileInfo.getFile().isHidden();
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- };
-
- private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(
- DateFormat.SHORT, DateFormat.SHORT);
-
-
- @Override
- public void install(Component component) {
- super.install(component);
-System.out.format("TerraVFSBrowserSkin.install%n");
- final VFSBrowser fileBrowser = (VFSBrowser)component;
-System.out.format("reading 'terra_vfs_browser_skin.bxml'%n");
- BXMLSerializer bxmlSerializer = new BXMLSerializer();
- try {
- content = (Component)bxmlSerializer.readObject(TerraVFSBrowserSkin.class,
- "terra_vfs_browser_skin.bxml", true);
- } catch (IOException exception) {
- throw new RuntimeException(exception);
- } catch (SerializationException exception) {
- throw new RuntimeException(exception);
- }
-System.out.format("adding content %1$s to fileBrowser %2$s%n", content, fileBrowser);
- fileBrowser.add(content);
-
- bxmlSerializer.bind(this, TerraVFSBrowserSkin.class);
-
- driveListButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener.Adapter() {
- @Override
- public void selectedItemChanged(ListButton listButton, Object previousSelectedItem) {
- if (previousSelectedItem != null) {
- FileObject drive = (FileObject)listButton.getSelectedItem();
- try {
- if(drive.isReadable()) {
- fileBrowser.setRootDirectory(drive);
- } else {
- refreshRoots = true;
- listButton.setSelectedItem(previousSelectedItem);
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
- });
-
- pathListButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener.Adapter() {
- @Override
- public void selectedItemChanged(ListButton listButton, Object previousSelectedItem) {
- FileObject ancestorDirectory = (FileObject)listButton.getSelectedItem();
-
- if (ancestorDirectory != null) {
- try {
- fileBrowser.setRootDirectory(ancestorDirectory);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
- });
-
- goUpButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- try {
- FileObject rootDirectory = fileBrowser.getRootDirectory();
- FileObject parentDirectory = rootDirectory.getParent();
- fileBrowser.setRootDirectory(parentDirectory);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- });
-
- newFolderButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- // TODO
- }
- });
-
- goHomeButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- try {
- fileBrowser.setRootDirectory(HOME_DIRECTORY);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- });
-
- /**
- * {@link KeyCode#DOWN DOWN} Transfer focus to the file list and select
- * the first item.<br>
- * {@link KeyCode#ESCAPE ESCAPE} Clear the search field.
- */
- searchTextInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() {
- @Override
- public boolean keyPressed(Component componentArgument, int keyCode, Keyboard.KeyLocation keyLocation) {
- boolean consumed = super.keyPressed(componentArgument, keyCode, keyLocation);
-
- if (keyCode == Keyboard.KeyCode.ESCAPE) {
- searchTextInput.setText("");
- consumed = true;
- } else if (keyCode == Keyboard.KeyCode.DOWN) {
- if (fileTableView.getTableData().getLength() > 0) {
- fileTableView.setSelectedIndex(0);
- fileTableView.requestFocus();
- }
- }
-
- return consumed;
- }
- });
-
- searchTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
- @Override
- public void textChanged(TextInput textInput) {
- refreshFileList();
- }
- });
-
- fileTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener() {
- @Override
- @SuppressWarnings("unchecked")
- public void selectedRangeAdded(TableView tableView, int rangeStart, int rangeEnd) {
- if (!updatingSelection) {
- updatingSelection = true;
-
- try {
- for (int i = rangeStart; i <= rangeEnd; i++) {
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- FileObject file = files.get(i);
- fileBrowser.addSelectedFile(file);
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- updatingSelection = false;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void selectedRangeRemoved(TableView tableView, int rangeStart, int rangeEnd) {
- if (!updatingSelection) {
- updatingSelection = true;
-
- for (int i = rangeStart; i <= rangeEnd; i++) {
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- FileObject file = files.get(i);
- fileBrowser.removeSelectedFile(file);
- }
-
- updatingSelection = false;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void selectedRangesChanged(TableView tableView, Sequence<Span> previousSelectedRanges) {
- if (!updatingSelection && previousSelectedRanges != null) {
- updatingSelection = true;
-
- Sequence<FileObject> files = (Sequence<FileObject>)tableView.getSelectedRows();
- for (int i = 0, n = files.getLength(); i < n; i++) {
- FileObject file = files.get(i);
- files.update(i, file);
- }
-
- try {
- fileBrowser.setSelectedFiles(files);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- updatingSelection = false;
- }
- }
-
- @Override
- public void selectedRowChanged(TableView tableView, Object previousSelectedRow) {
- // No-op
- }
- });
-
- fileTableView.getTableViewSortListeners().add(new TableViewSortListener.Adapter() {
- @Override
- @SuppressWarnings("unchecked")
- public void sortChanged(TableView tableView) {
- TableView.SortDictionary sort = fileTableView.getSort();
-
- if (!sort.isEmpty()) {
- Dictionary.Pair<String, SortDirection> pair = fileTableView.getSort().get(0);
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- files.setComparator(getFileComparator(pair.key, pair.value));
- }
- }
- });
-
- fileTableView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
- private int index = -1;
-
- @Override
- public boolean mouseClick(Component componentArgument, Mouse.Button button, int x, int y, int count) {
- boolean consumed = super.mouseClick(componentArgument, button, x, y, count);
-
- if (count == 1) {
- index = fileTableView.getRowAt(y);
- } else if (count == 2) {
- int indexLocal = fileTableView.getRowAt(y);
- if (indexLocal != -1
- && indexLocal == this.index
- && fileTableView.isRowSelected(indexLocal)) {
- FileObject file = (FileObject)fileTableView.getTableData().get(indexLocal);
-
- try {
- if (file.getName().getType() == FileType.FOLDER) {
- fileBrowser.setRootDirectory(file);
- consumed = true;
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- }
-
- return consumed;
- }
- });
-
- fileBrowser.setFocusTraversalPolicy(new IndexFocusTraversalPolicy() {
- @Override
- public Component getNextComponent(Container container, Component componentArgument,
- FocusTraversalDirection direction) {
- Component nextComponent;
- if (componentArgument == null) {
- nextComponent = fileTableView;
- } else {
- nextComponent = super.getNextComponent(container, componentArgument, direction);
- }
-
- return nextComponent;
- }
- });
-
- fileTableView.setSort(TableViewFileRenderer.NAME_KEY, SortDirection.ASCENDING);
-System.out.format("rootDirectoryChanged to null%n");
- rootDirectoryChanged(fileBrowser, null);
-System.out.format("selectedFilesChanged to null%n");
- selectedFilesChanged(fileBrowser, null);
-System.out.format("Done with TerraVFSBrowserSkin.install%n");
- }
-
- @Override
- public int getPreferredWidth(int height) {
- return content.getPreferredWidth(height);
- }
-
- @Override
- public int getPreferredHeight(int width) {
- return content.getPreferredHeight(width);
- }
-
- @Override
- public Dimensions getPreferredSize() {
- return content.getPreferredSize();
- }
-
- @Override
- public void layout() {
- int width = getWidth();
- int height = getHeight();
-
- content.setLocation(0, 0);
- content.setSize(width, height);
- }
-
- @Override
- public FileObject getFileAt(int x, int y) {
- FileObject file = null;
-
- VFSBrowser fileBrowser = (VFSBrowser)getComponent();
- Component component = fileBrowser.getDescendantAt(x, y);
- if (component == fileTableView) {
- Point location = fileTableView.mapPointFromAncestor(fileBrowser, x, y);
-
- int index = fileTableView.getRowAt(location.y);
- if (index != -1) {
- file = (FileObject)fileTableView.getTableData().get(index);
- }
- }
-
- return file;
- }
-
- public boolean isKeyboardFolderTraversalEnabled() {
- return keyboardFolderTraversalEnabled;
- }
-
- public void setKeyboardFolderTraversalEnabled(boolean keyboardFolderTraversalEnabled) {
- this.keyboardFolderTraversalEnabled = keyboardFolderTraversalEnabled;
- }
-
- public boolean isHideDisabledFiles() {
- return hideDisabledFiles;
- }
-
- public void setHideDisabledFiles(boolean hideDisabledFiles) {
- this.hideDisabledFiles = hideDisabledFiles;
- refreshFileList();
- }
-
- /**
- * {@link KeyCode#ENTER ENTER} Change into the selected directory if
- * {@link #keyboardFolderTraversalEnabled} is true.<br>
- * {@link KeyCode#DELETE DELETE} or {@link KeyCode#BACKSPACE BACKSPACE}
- * Change into the parent of the current directory.<br>
- * {@link KeyCode#F5 F5} Refresh the file list.
- */
- @Override
- public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
- boolean consumed = super.keyPressed(component, keyCode, keyLocation);
-
- VFSBrowser fileBrowser = (VFSBrowser)getComponent();
-
- if (keyCode == Keyboard.KeyCode.ENTER
- && keyboardFolderTraversalEnabled) {
- Sequence<FileObject> selectedFiles = fileBrowser.getSelectedFiles();
-
- if (selectedFiles.getLength() == 1) {
- FileObject selectedFile = selectedFiles.get(0);
- try {
- if (selectedFile.getName().getType() == FileType.FOLDER) {
- fileBrowser.setRootDirectory(selectedFile);
- consumed = true;
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- }
- } else if (keyCode == Keyboard.KeyCode.DELETE
- || keyCode == Keyboard.KeyCode.BACKSPACE) {
- FileObject rootDirectory = fileBrowser.getRootDirectory();
- try {
- FileObject parentDirectory = rootDirectory.getParent();
- if (parentDirectory != null) {
- fileBrowser.setRootDirectory(parentDirectory);
- consumed = true;
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- } else if (keyCode == Keyboard.KeyCode.F5) {
- refreshFileList();
- consumed = true;
- }
-
- return consumed;
- }
-
- /**
- * CommandModifier + {@link KeyCode#F F} Transfers focus to the search
- * TextInput.
- *
- * @see Platform#getCommandModifier()
- */
- @Override
- public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
- boolean consumed = super.keyReleased(component, keyCode, keyLocation);
-
- Keyboard.Modifier commandModifier = Platform.getCommandModifier();
- if (keyCode == Keyboard.KeyCode.F
- && Keyboard.isPressed(commandModifier)) {
- searchTextInput.requestFocus();
- consumed = true;
- }
-
- return consumed;
- }
-
- @Override
- public void managerChanged(VFSBrowser fileBrowser, FileSystemManager previousManager) {
- // TODO: Is there anything to do here? Surely, but what?
- }
-
- @Override
- public void rootDirectoryChanged(VFSBrowser fileBrowser, FileObject previousRootDirectory) {
- ArrayList<FileObject> path = new ArrayList<FileObject>();
-
- FileSystemManager manager = fileBrowser.getManager();
- FileObject rootDirectory = fileBrowser.getRootDirectory();
-
- try {
- FileObject ancestorDirectory = rootDirectory.getParent();
- while (ancestorDirectory != null) {
- path.add(ancestorDirectory);
- ancestorDirectory = ancestorDirectory.getParent();
- }
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
-
- @SuppressWarnings("unchecked")
- ArrayList<FileObject> drives = (ArrayList<FileObject>) driveListButton.getListData();
- if(refreshRoots) {
- // TODO: this is ugly -- need to do much better at managing drive list with VFS
- try {
- FileObject[] roots = new FileObject[1];
- roots[0] = manager.resolveFile(manager.getBaseFile().getName().getRoot().getPath());
- drives = new ArrayList<FileObject>();
- for (int i = 0; i < roots.length; i++) {
- FileObject root = roots[i];
- if (root.exists()) {
- drives.add(root);
- }
- }
- driveListButton.setListData(drives);
- } catch (FileSystemException fse) {
- throw new RuntimeException(fse);
- }
- refreshRoots = false;
- }
-
- driveListButton.setVisible(drives.getLength() > 1);
-
- FileObject drive;
- if (path.getLength() == 0) {
- drive = rootDirectory;
- } else {
- drive = path.get(path.getLength() - 1);
- }
-
- driveListButton.setSelectedItem(drive);
-
- pathListButton.setListData(path);
- pathListButton.setButtonData(rootDirectory);
- pathListButton.setEnabled(rootDirectory.getName().getDepth() > 0);
-
- goUpButton.setEnabled(pathListButton.isEnabled());
-
- goHomeButton.setEnabled(!rootDirectory.getName().getPath().equals(HOME_DIRECTORY));
-
- fileScrollPane.setScrollTop(0);
- fileScrollPane.setScrollLeft(0);
-
- searchTextInput.setText("");
-
- fileTableView.requestFocus();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void selectedFileAdded(VFSBrowser fileBrowser, FileObject file) {
- if (!updatingSelection) {
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- int index = files.indexOf(file);
- if (index != -1) {
- updatingSelection = true;
- fileTableView.addSelectedIndex(index);
- updatingSelection = false;
- }
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void selectedFileRemoved(VFSBrowser fileBrowser, FileObject file) {
- if (!updatingSelection) {
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- int index = files.indexOf(file);
- if (index != -1) {
- updatingSelection = true;
- fileTableView.removeSelectedIndex(index);
- updatingSelection = false;
- }
- }
- }
-
- @Override
- public void selectedFilesChanged(VFSBrowser fileBrowser, Sequence<FileObject> previousSelectedFiles) {
- updateSelectedFiles(fileBrowser);
- }
-
- @SuppressWarnings("unchecked")
- private void updateSelectedFiles(VFSBrowser fileBrowser) {
- if (!updatingSelection) {
- Sequence<FileObject> selectedFiles = fileBrowser.getSelectedFiles();
-
- ArrayList<Span> selectedRanges = new ArrayList<Span>();
- for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
- FileObject selectedFile = selectedFiles.get(i);
-
- List<FileObject> files = (List<FileObject>)fileTableView.getTableData();
- int index = files.indexOf(selectedFile);
- if (index != -1) {
- selectedRanges.add(new Span(index, index));
- }
- }
-
- updatingSelection = true;
- fileTableView.setSelectedRanges(selectedRanges);
- updatingSelection = false;
- }
- }
-
- @Override
- public void multiSelectChanged(VFSBrowser fileBrowser) {
- fileTableView.setSelectMode(fileBrowser.isMultiSelect() ? TableView.SelectMode.MULTI :
- TableView.SelectMode.SINGLE);
- }
-
- @Override
- public void disabledFileFilterChanged(VFSBrowser fileBrowser, Filter<FileObject> previousDisabledFileFilter) {
- fileTableView.setDisabledRowFilter(fileBrowser.getDisabledFileFilter());
- refreshFileList();
- }
-
- private void refreshFileList() {
- // Cancel any outstanding task
- if (refreshFileListTask != null) {
- refreshFileListTask.abort();
-
- if (indicator != null) {
- indicator.setActive(false);
- fileStackPane.remove(fileStackPane.getLength() - 1, 1);
- }
- }
-
- if (indicator == null) {
- indicator = new ActivityIndicator();
- activityGrid = new GridPane(5);
- GridPane.Row row1 = new GridPane.Row();
- GridPane.Row row2 = new GridPane.Row();
- GridPane.Row row3 = new GridPane.Row();
- for (int i = 0; i < 5; i++) {
- row1.add(new GridPane.Filler());
- if (i == 2)
- row2.add(indicator);
- else
- row2.add(new GridPane.Filler());
- row3.add(new GridPane.Filler());
- }
- activityGrid.getRows().add(row1);
- activityGrid.getRows().add(row2);
- activityGrid.getRows().add(row3);
- }
- fileStackPane.add(activityGrid);
- indicator.setActive(true);
-
- fileTableView.setTableData(new ArrayList<FileObject>());
-
- String text = searchTextInput.getText().trim();
- Filter<FileObject> disabledFileFilter = hideDisabledFiles ? ((VFSBrowser) getComponent()).getDisabledFileFilter() : null;
- Filter<FileObject> includeFileFilter = text.length() != 0 ? new IncludeFileFilter(text) : null;
-
- TableView.SortDictionary sort = fileTableView.getSort();
-
- final FileComparator fileComparator;
- if (sort.isEmpty()) {
- fileComparator = null;
- } else {
- Dictionary.Pair<String, SortDirection> pair = fileTableView.getSort().get(0);
- fileComparator = getFileComparator(pair.key, pair.value);
- }
-
- refreshFileListTask = new RefreshFileListTask(includeFileFilter, disabledFileFilter, fileComparator);
- refreshFileListTask.execute(new TaskAdapter<ArrayList<FileObject>>(new TaskListener<ArrayList<FileObject>>() {
- @SuppressWarnings("unchecked")
- @Override
- public void taskExecuted(Task<ArrayList<FileObject>> task) {
- if (task == refreshFileListTask) {
- indicator.setActive(false);
- fileStackPane.remove(fileStackPane.getLength() - 1, 1);
-
- ArrayList<FileObject> fileList = task.getResult();
- fileTableView.setTableData(fileList);
-
- updateSelectedFiles((VFSBrowser) getComponent());
-
- refreshFileListTask = null;
- }
- }
-
- @Override
- public void executeFailed(Task<ArrayList<FileObject>> task) {
- if (task == refreshFileListTask) {
- indicator.setActive(false);
- fileStackPane.remove(fileStackPane.getLength() - 1, 1);
-
- refreshFileListTask = null;
- }
- }
- }));
- }
-}
View
27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.json
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ selectDrive: "Select drive",
- goTo: "Go to a folder",
- goUp: "Go up a folder",
- newFolder: "Create new folder",
- goHome: "Go to home folder",
- search: "search",
- searchFor: "Search for files",
- fileName: "File",
- size: "Size",
- lastModified: "Modified"
-}
View
27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_cs.json
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ selectDrive: "Vybrat jednotku",
- goTo: "Přejít do složky",
- goUp: "O úroveň výš",
- newFolder: "Vytvořit novou složku",
- goHome: "Domovská složka",
- search: "hledat",
- searchFor: "Hledat soubor",
- fileName: "Soubor",
- size: "Velikost",
- lastModified: "Změněno"
-}
View
27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_de.json
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ selectDrive: "Laufwerk auswählen",
- goTo: "Ordner auswählen",
- goUp: "Eine Ebene nach oben",
- newFolder: "Neuen Ordner erstellen",
- goHome: "Eigene Dateien anzeigen",
- search: "suchen",
- searchFor: "Suche nach Dateien",
- fileName: "Datei",
- size: "Größe",
- lastModified: "Geändert am"
-}
View
27 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin_es.json
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-{ selectDrive: "Selecionar unidad",