Search in sources :

Example 21 with ArrayList

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;
}
Also used : SerializationException(org.apache.pivot.serialization.SerializationException) ArrayList(org.apache.pivot.collections.ArrayList) CalendarButtonSelectionListener(org.apache.pivot.wtk.CalendarButtonSelectionListener) IOException(java.io.IOException) ListButton(org.apache.pivot.wtk.ListButton) CalendarDate(org.apache.pivot.util.CalendarDate) CalendarButton(org.apache.pivot.wtk.CalendarButton) Dialog(org.apache.pivot.wtk.Dialog) DialogCloseListener(org.apache.pivot.wtk.DialogCloseListener) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 22 with ArrayList

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);
}
Also used : Window(org.apache.pivot.wtk.Window) ListView(org.apache.pivot.wtk.ListView) ArrayList(org.apache.pivot.collections.ArrayList)

Example 23 with ArrayList

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);
}
Also used : ListView(org.apache.pivot.wtk.ListView) ArrayList(org.apache.pivot.collections.ArrayList) ListViewSelectionListener(org.apache.pivot.wtk.ListViewSelectionListener) Span(org.apache.pivot.wtk.Span)

Example 24 with ArrayList

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);
}
Also used : SerializationException(org.apache.pivot.serialization.SerializationException) ColorChooserButton(org.apache.pivot.wtk.ColorChooserButton) Color(java.awt.Color) ArrayList(org.apache.pivot.collections.ArrayList) LocalManifest(org.apache.pivot.wtk.LocalManifest)

Example 25 with ArrayList

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"));
}
Also used : ArrayList(org.apache.pivot.collections.ArrayList) ArrayList(org.apache.pivot.collections.ArrayList) List(org.apache.pivot.collections.List) JSONSerializer(org.apache.pivot.json.JSONSerializer) Test(org.junit.Test)

Aggregations

ArrayList (org.apache.pivot.collections.ArrayList)41 List (org.apache.pivot.collections.List)9 Span (org.apache.pivot.wtk.Span)8 Test (org.junit.Test)6 IOException (java.io.IOException)5 ListView (org.apache.pivot.wtk.ListView)5 Point (org.apache.pivot.wtk.Point)5 TableView (org.apache.pivot.wtk.TableView)5 StringWriter (java.io.StringWriter)4 HashMap (org.apache.pivot.collections.HashMap)4 CSVSerializer (org.apache.pivot.serialization.CSVSerializer)4 SerializationException (org.apache.pivot.serialization.SerializationException)4 Vote (org.apache.pivot.util.Vote)4 Component (org.apache.pivot.wtk.Component)4 Form (org.apache.pivot.wtk.Form)4 File (java.io.File)3 FileObject (org.apache.commons.vfs2.FileObject)3 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3 Bounds (org.apache.pivot.wtk.Bounds)3 ListButton (org.apache.pivot.wtk.ListButton)3