use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class TerraVFSBrowserSkin method rootDirectoryChanged.
@Override
public void rootDirectoryChanged(VFSBrowser fileBrowser, FileObject previousRootDirectory) {
ArrayList<FileObject> path = new ArrayList<>();
// 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
// There is an open question on the Dev list about adding
// "getFileRoots()" to the VFS API.
/*
* try { FileObject[] roots = new FileObject[1]; roots[0] =
* manager.resolveFile
* (manager.getBaseFile().getName().getRoot().getURI()); drives =
* new ArrayList<>(); 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.equals(homeDirectory));
fileScrollPane.setScrollTop(0);
fileScrollPane.setScrollLeft(0);
searchTextInput.setText("");
fileTableView.requestFocus();
}
use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class TerraVFSBrowserSkin method updateSelectedFiles.
private void updateSelectedFiles(VFSBrowser fileBrowser) {
if (!updatingSelection) {
Sequence<FileObject> selectedFiles = fileBrowser.getSelectedFiles();
ArrayList<Span> selectedRanges = new ArrayList<>();
for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
FileObject selectedFile = selectedFiles.get(i);
@SuppressWarnings("unchecked") 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;
}
}
use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class TerraFileBrowserSkin method updateSelectedFiles.
private void updateSelectedFiles(FileBrowser fileBrowser) {
if (!updatingSelection) {
Sequence<File> selectedFiles = fileBrowser.getSelectedFiles();
ArrayList<Span> selectedRanges = new ArrayList<>();
for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
File selectedFile = selectedFiles.get(i);
@SuppressWarnings("unchecked") List<File> files = (List<File>) fileTableView.getTableData();
int index = files.indexOf(selectedFile);
if (index != -1) {
selectedRanges.add(new Span(index, index));
}
}
updatingSelection = true;
fileTableView.setSelectedRanges(selectedRanges);
updatingSelection = false;
}
}
use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class ExpensesWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
expenseTableView = (TableView) namespace.get("expenseTableView");
activityIndicator = (ActivityIndicator) namespace.get("activityIndicator");
activityIndicatorBoxPane = (BoxPane) namespace.get("activityIndicatorBoxPane");
// Load the add/edit sheet
try {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
expenseSheet = (ExpenseSheet) bxmlSerializer.readObject(ExpenseSheet.class, "expense_sheet.bxml", true);
} catch (IOException exception) {
throw new RuntimeException(exception);
} catch (SerializationException exception) {
throw new RuntimeException(exception);
}
// Create the delete confirmation prompt
ArrayList<String> options = new ArrayList<>((String) resources.get("ok"), (String) resources.get("cancel"));
deleteConfirmationPrompt = new Prompt(MessageType.QUESTION, (String) resources.get("confirmDelete"), options);
// Attach event listeners
expenseTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener() {
@Override
public void selectedRowChanged(TableView tableView, Object previousSelectedRow) {
int selectedIndex = expenseTableView.getSelectedIndex();
editSelectedExpenseAction.setEnabled(selectedIndex != -1);
deleteSelectedExpenseAction.setEnabled(selectedIndex != -1);
}
});
}
use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class SuggestionPopups method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
stateTextInput = (TextInput) namespace.get("stateTextInput");
stateTextInput.getTextInputContentListeners().add(new TextInputContentListener() {
@Override
public void textInserted(TextInput textInput, int index, int count) {
String text = textInput.getText();
ArrayList<String> suggestions = new ArrayList<>();
for (String state : states) {
if (state.toUpperCase().startsWith(text.toUpperCase())) {
suggestions.add(state);
}
}
if (suggestions.getLength() > 0) {
suggestionPopup.setSuggestionData(suggestions);
suggestionPopup.open(textInput);
}
}
@Override
public void textRemoved(TextInput textInput, int index, int count) {
suggestionPopup.close();
}
});
suggestionPopup.setListSize(4);
}
Aggregations