use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class Pivot714 method getWindow.
public Window getWindow(final Window ownerArgument) {
this.owner = ownerArgument;
final BXMLSerializer bxmlSerializer = new BXMLSerializer();
try {
result = (Dialog) bxmlSerializer.readObject(Pivot714.class.getResource("pivot_714.bxml"));
} catch (IOException e) {
e.printStackTrace();
} catch (SerializationException e) {
e.printStackTrace();
}
final ListButton motif = (ListButton) bxmlSerializer.getNamespace().get("motif");
ArrayList<String> al = new ArrayList<>();
al.add("One");
al.add("Two");
motif.setListData(al);
CalendarButton cbDate = (CalendarButton) bxmlSerializer.getNamespace().get("date");
dcl = (new DialogCloseListener() {
@Override
public void dialogClosed(Dialog dialog, boolean modal) {
// empty block
}
});
cbDate.getCalendarButtonSelectionListeners().add(new CalendarButtonSelectionListener() {
@Override
public void selectedDateChanged(CalendarButton calendarButton, CalendarDate previousSelectedDate) {
// empty block
}
});
return result;
}
use of org.apache.pivot.collections.ArrayList 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.collections.ArrayList 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.collections.ArrayList in project pivot by apache.
the class ColorSchemeBuilderWindow method copyToClipboard.
private void copyToClipboard() {
int numberOfPaletteColors = getNumberOfPaletteColors();
ArrayList<String> colors = new ArrayList<>(numberOfPaletteColors);
for (int i = 0; i < numberOfPaletteColors; i++) {
ColorChooserButton colorChooserButton = colorChooserButtons.get(i);
Color color = colorChooserButton.getSelectedColor();
colors.add(ColorUtilities.toStringValue(color));
}
LocalManifest clipboardContent = new LocalManifest();
try {
clipboardContent.putText(JSONSerializer.toString(colors));
} catch (SerializationException exception) {
Prompt.prompt(exception.getMessage(), this);
}
Clipboard.setContent(clipboardContent);
}
use of org.apache.pivot.collections.ArrayList in project pivot by apache.
the class BindTest method testTypedList.
/**
* Tests returning a typed list using
* {@code org.apache.pivot.util.TypeLiteral}.
*
* @throws IOException
* @throws SerializationException
*/
@Test
public void testTypedList() throws IOException, SerializationException {
JSONSerializer listSerializer = new JSONSerializer();
@SuppressWarnings("unchecked") List<Object> list = (List<Object>) listSerializer.readObject(getClass().getResourceAsStream("list.json"));
JSONSerializer typedListSerializer = new JSONSerializer((new TypeLiteral<ArrayList<SampleBean2>>() {
}).getType());
@SuppressWarnings("unchecked") ArrayList<SampleBean2> typedList = (ArrayList<SampleBean2>) typedListSerializer.readObject(getClass().getResourceAsStream("list.json"));
Object item0 = typedList.get(0);
assertTrue(item0 instanceof SampleBean2);
assertEquals((Integer) typedList.get(0).getA(), (Integer) JSON.get(list, "[0].a"));
}
Aggregations