Search in sources :

Example 11 with Window

use of org.apache.pivot.wtk.Window in project pivot by apache.

the class ColorPaletteTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    Theme theme = Theme.getTheme();
    TablePane tablePane = new TablePane();
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    int numberOfPaletteColors = theme.getNumberOfPaletteColors();
    // ArrayList<String> colors = new ArrayList<>(numberOfPaletteColors);
    for (int i = 0; i < numberOfPaletteColors; i++) {
        TablePane.Row row = new TablePane.Row(tablePane, 1, true);
        row.add(createCell(i * 3));
        row.add(createCell(i * 3 + 1));
        row.add(createCell(i * 3 + 2));
    }
    tablePane.getStyles().put(Style.horizontalSpacing, 4);
    tablePane.getStyles().put(Style.verticalSpacing, 4);
    Border border = new Border(tablePane);
    border.getStyles().put(Style.padding, 6);
    this.window = new Window(border);
    this.window.setTitle("Color Palette");
    this.window.setMaximized(true);
    this.window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Theme(org.apache.pivot.wtk.Theme) Border(org.apache.pivot.wtk.Border) TablePane(org.apache.pivot.wtk.TablePane)

Example 12 with Window

use of org.apache.pivot.wtk.Window in project pivot by apache.

the class SheetSlideDirectionWindow method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    // Populate the ListButton with values from the enum
    listButton.setListData(new ArrayList<>(SheetPlacement.values()));
    listButton = null;
    // Populate the form with data from the Sheet's styles
    form.load(sheet.getStyles());
    // Common ButtonPressListener to be applied to all four of
    // the PushButtons representing a slide direction
    ButtonPressListener openSheetButtonPressListener = new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            StyleDictionary sheetStyles = sheet.getStyles();
            form.store(sheetStyles);
            button.store(sheetStyles);
            form.load(sheetStyles);
            sheet.load(sheetStyles);
            sheet.open(button.getWindow());
        }
    };
    // Apply the common ButtonPressListener to the PushButtons
    for (Iterator<Component> it = tablePane.iterator(); it.hasNext(); ) {
        Component component = it.next();
        if (component instanceof PushButton) {
            PushButton button = (PushButton) component;
            button.getButtonPressListeners().add(openSheetButtonPressListener);
            button.setTooltipText("Press me!");
        }
    }
    tablePane = null;
    // Mouse handler to enable users to quickly close the sheet
    final ContainerMouseListener displayMouseHandler = new ContainerMouseListener() {

        @Override
        public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
            Display display = (Display) container;
            Component component = display.getComponentAt(x, y);
            // Close the sheet by clicking away from it.
            // This allows resizing etc to work without requiring
            // a close button or similar on the sheet.
            boolean consumed = (component != sheet);
            if (consumed) {
                sheet.close();
            }
            return consumed;
        }
    };
    // Add/remove the mouse handler based on the Sheet's state
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            window.getDisplay().getContainerMouseListeners().add(displayMouseHandler);
        }

        @Override
        public void windowClosed(Window window, Display display, Window owner) {
            display.getContainerMouseListeners().remove(displayMouseHandler);
        }
    });
}
Also used : Window(org.apache.pivot.wtk.Window) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Container(org.apache.pivot.wtk.Container) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) ContainerMouseListener(org.apache.pivot.wtk.ContainerMouseListener) Component(org.apache.pivot.wtk.Component) PushButton(org.apache.pivot.wtk.PushButton) Display(org.apache.pivot.wtk.Display)

Example 13 with Window

use of org.apache.pivot.wtk.Window in project pivot by apache.

the class BaselineTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = new Window((Component) bxmlSerializer.readObject(getClass().getResource("baseline_test.bxml")));
    window.setTitle("Baseline Test");
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 14 with Window

use of org.apache.pivot.wtk.Window in project pivot by apache.

the class PushButtonTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    window = new Window();
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    PushButton uploadButton = new PushButton("Upload");
    uploadButton.getStyles().put(Style.minimumAspectRatio, 3.0f);
    boxPane.add(uploadButton);
    window.setContent(boxPane);
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton)

Example 15 with Window

use of org.apache.pivot.wtk.Window in project pivot by apache.

the class JavascriptConsoleTest method loadWindow.

/**
 * Load (and returns) a Window, given its file name and serializer to use
 *
 * @param fileName the file name for the bxml file to load
 * @param bxmlSerializer the serializer to use, or if null a new one will be
 * created
 * @return the Window instance
 * @throws SerializationException in case of error
 * @throws IOException in case of error
 */
private Window loadWindow(String fileName, final BXMLSerializer bxmlSerializer) throws SerializationException, IOException {
    logObject("loadWindow from \"" + fileName + "\", with the serializer " + bxmlSerializer);
    BXMLSerializer serializer = bxmlSerializer;
    if (serializer == null) {
        serializer = new BXMLSerializer();
    }
    // setLocation or setResources in the serializer) ...
    return (Window) serializer.readObject(JavascriptConsoleTest.class, fileName, true);
}
Also used : Window(org.apache.pivot.wtk.Window) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Aggregations

Window (org.apache.pivot.wtk.Window)45 Component (org.apache.pivot.wtk.Component)14 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)13 PushButton (org.apache.pivot.wtk.PushButton)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Button (org.apache.pivot.wtk.Button)7 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)6 Display (org.apache.pivot.wtk.Display)5 Border (org.apache.pivot.wtk.Border)4 Label (org.apache.pivot.wtk.Label)4 Sheet (org.apache.pivot.wtk.Sheet)4 TablePane (org.apache.pivot.wtk.TablePane)4 File (java.io.File)3 Bounds (org.apache.pivot.wtk.Bounds)3 Point (org.apache.pivot.wtk.Point)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 SerializationException (org.apache.pivot.serialization.SerializationException)2 Vote (org.apache.pivot.util.Vote)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2