use of org.apache.pivot.wtk.ListView in project pivot by apache.
the class Pivot718 method controlList.
private void controlList(BXMLSerializer bxmlSerializer) {
listDelButton = (PushButton) bxmlSerializer.getNamespace().get("listDelButton");
list = (ListView) bxmlSerializer.getNamespace().get("list");
list.getListViewSelectionListeners().add(new ListViewSelectionListener() {
@Override
public void selectedRangeAdded(ListView listView, int rangeStart, int rangeEnd) {
System.out.println("selectedRangeAdded");
}
@Override
public void selectedRangeRemoved(ListView listView, int rangeStart, int rangeEnd) {
System.out.println("selectedRangeRemoved");
}
@Override
public void selectedRangesChanged(ListView listView, Sequence<Span> previousSelectedRanges) {
System.out.println("selectedRangesChanged");
}
@Override
public void selectedItemChanged(ListView listView, Object previousSelectedItem) {
System.out.println("selectedItemChanged :::" + listView.getSelectedItem());
}
});
listDelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = list.getSelectedItem();
System.out.println("delete :: " + x);
// List data = list.getListData();
@SuppressWarnings("unchecked") List<Object> data = (List<Object>) list.getListData();
data.remove(x);
}
});
}
use of org.apache.pivot.wtk.ListView in project pivot by apache.
the class ListViewTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) {
ListView listView = new ListView();
List<String> listData = new ArrayList<>();
listData.add("0");
listData.add("1");
listData.add("2");
listData.add("3");
listData.add("4");
listData.add("5");
listData.add("6");
listData.add("7");
listData.add("8");
listData.add("9");
listData.add("A");
listData.add("B");
listData.add("C");
listData.add("D");
listData.add("E");
listData.add("F");
listView.setListData(listData);
listView.setDisabledItemFilter(new Filter<String>() {
@Override
public boolean include(String item) {
return !Character.isDigit(item.charAt(0));
}
});
listView.setCheckmarksEnabled(true);
listView.setItemChecked(4, true);
listView.setItemChecked(6, true);
window = new Window(listView);
window.open(display);
listData.insert("-1", 0);
listData.insert("-2", 0);
listData.remove(0, 3);
}
use of org.apache.pivot.wtk.ListView in project pivot by apache.
the class ListViewSelectionTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) {
ArrayList<Span> selectedRanges = new ArrayList<>();
selectedRanges.add(new Span(0, 0));
listView.setSelectedRanges(selectedRanges);
dumpSelection();
listView.addSelectedRange(new Span(4, 4));
dumpSelection();
listView.addSelectedRange(new Span(2, 2));
dumpSelection();
listView.addSelectedRange(new Span(0, 4));
dumpSelection();
selectedRanges.clear();
selectedRanges.add(new Span(1, 1));
selectedRanges.add(new Span(3, 3));
listView.setSelectedRanges(selectedRanges);
dumpSelection();
listView.addSelectedRange(new Span(0, 4));
dumpSelection();
listView.removeSelectedRange(new Span(2, 2));
dumpSelection();
listView.removeSelectedRange(new Span(4, 4));
dumpSelection();
listView.removeSelectedRange(new Span(0, 0));
dumpSelection();
listView.removeSelectedRange(new Span(1, 3));
dumpSelection();
selectedRanges.clear();
selectedRanges.add(new Span(4, 6));
listView.setSelectedRanges(selectedRanges);
dumpSelection();
listView.addSelectedRange(new Span(2, 5));
dumpSelection();
listView.addSelectedRange(new Span(4, 8));
dumpSelection();
verifySelection(0);
verifySelection(4);
verifySelection(6);
verifySelection(8);
listView.removeSelectedRange(new Span(8, 12));
dumpSelection();
verifySelection(8);
listView.removeSelectedRange(new Span(0, 4));
dumpSelection();
verifySelection(4);
listView.getListViewSelectionListeners().add(new ListViewSelectionListener() {
@Override
public void selectedRangesChanged(ListView listViewArgument, Sequence<Span> previousSelectedRanges) {
System.out.println("Selection changed");
}
});
listView.setSelectedIndex(2);
listView.getListData().remove(2, 1);
}
use of org.apache.pivot.wtk.ListView in project pivot by apache.
the class FileBrowserWithCharsetTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
final Window window = Window.getActiveWindow();
final FileBrowserWithCharsetTest fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);
fileBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected (charset " + fileBrowserSheet.getCharsetName() + "):", listView, window);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", window);
}
}
});
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
use of org.apache.pivot.wtk.ListView in project pivot by apache.
the class VFSBrowserTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(final Button buttonArgument) {
try {
final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet(VFSBrowserSheet.Mode.OPEN);
vfsBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
vfsBrowserSheet.open(frame, new SheetCloseListener() {
@Override
public void sheetClosed(final Sheet sheet) {
if (sheet.getResult()) {
Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected:", listView, frame);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", frame);
}
}
});
} catch (FileSystemException fse) {
Alert.alert(MessageType.ERROR, String.format("File System Exception: %1$s", fse.getMessage()), frame);
}
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
Aggregations