Search in sources :

Example 1 with Prompt

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

the class TerraPromptSkin method windowOpened.

@Override
public void windowOpened(Window window) {
    super.windowOpened(window);
    Prompt prompt = (Prompt) window;
    int index = prompt.getSelectedOptionIndex();
    if (index >= 0) {
        optionButtonBoxPane.get(index).requestFocus();
    } else {
        window.requestFocus();
    }
}
Also used : Prompt(org.apache.pivot.wtk.Prompt)

Example 2 with Prompt

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

the class TerraPromptSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Prompt prompt = (Prompt) component;
    prompt.setPreferredWidth(320);
    prompt.setMinimumWidth(160);
    prompt.getPromptListeners().add(this);
    // Load the prompt content
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    Component content;
    try {
        content = (Component) bxmlSerializer.readObject(TerraPromptSkin.class, "terra_prompt_skin.bxml");
    } catch (Exception exception) {
        throw new RuntimeException(exception);
    }
    prompt.setContent(content);
    typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
    messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
    messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
    optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
    for (Object option : prompt.getOptions()) {
        PushButton optionButton = new PushButton(option);
        optionButton.setStyleName(BUTTON_STYLE_NAME);
        optionButton.getButtonPressListeners().add(optionButtonPressListener);
        optionButtonBoxPane.add(optionButton);
    }
    messageTypeChanged(prompt, null);
    messageChanged(prompt, null);
    bodyChanged(prompt, null);
}
Also used : Prompt(org.apache.pivot.wtk.Prompt) Component(org.apache.pivot.wtk.Component) PushButton(org.apache.pivot.wtk.PushButton) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 3 with Prompt

use of org.apache.pivot.wtk.Prompt 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);
        }
    });
}
Also used : SerializationException(org.apache.pivot.serialization.SerializationException) ArrayList(org.apache.pivot.collections.ArrayList) Prompt(org.apache.pivot.wtk.Prompt) IOException(java.io.IOException) TableViewSelectionListener(org.apache.pivot.wtk.TableViewSelectionListener) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) TableView(org.apache.pivot.wtk.TableView)

Example 4 with Prompt

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

the class SheetTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
    picture.resample(120);
    BoxPane windowContent = new BoxPane();
    PushButton button = new PushButton(picture);
    button.getStyles().put(Style.toolbar, true);
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setPreferredSize(480, 360);
    frame.getStyles().put(Style.padding, 0);
    frame.open(display);
    final TablePane tablePane = new TablePane();
    tablePane.setPreferredSize(320, 240);
    new TablePane.Column(tablePane, 1, true);
    TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
    TablePane.Row row1 = new TablePane.Row(tablePane, -1);
    final Label sheetContent = new Label("Sheet Content");
    sheetContent.getStyles().put(Style.wrapText, true);
    sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    row0.add(sheetContent);
    Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    promptBody.getStyles().put(Style.wrapText, true);
    final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
    prompt.setTitle("Prompt");
    prompt.getStyles().put(Style.resizable, true);
    prompt.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public void mouseOver(Component component) {
            System.out.println("Mouse Over");
        }

        @Override
        public void mouseOut(Component component) {
            System.out.println("Mouse out");
        }
    });
    Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    alertBody.getStyles().put(Style.wrapText, true);
    final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
    alert.setTitle("Alert");
    BoxPane boxPane = new BoxPane();
    row1.add(boxPane);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    final PushButton closeButton = new PushButton("Close");
    closeButton.getStyles().put(Style.minimumAspectRatio, 3);
    boxPane.add(closeButton);
    sheet = new Sheet(tablePane);
    closeButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            buttonArgument.getWindow().close();
        }
    });
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            prompt.open(frame);
            Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
            Window window = new Window();
            window.setTitle("New Secondary Window");
            window.setMaximized(true);
            window.setContent(new Label("I am a secondary window!"));
            window.open(displayLocal);
        }
    });
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            closeButton.requestFocus();
        }
    });
    DesktopApplicationContext.sizeHostToFit(frame);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) Label(org.apache.pivot.wtk.Label) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Picture(org.apache.pivot.wtk.media.Picture) Prompt(org.apache.pivot.wtk.Prompt) Alert(org.apache.pivot.wtk.Alert) PushButton(org.apache.pivot.wtk.PushButton) Component(org.apache.pivot.wtk.Component) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) Sheet(org.apache.pivot.wtk.Sheet) TablePane(org.apache.pivot.wtk.TablePane) Display(org.apache.pivot.wtk.Display)

Aggregations

Prompt (org.apache.pivot.wtk.Prompt)4 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)2 Component (org.apache.pivot.wtk.Component)2 PushButton (org.apache.pivot.wtk.PushButton)2 IOException (java.io.IOException)1 ArrayList (org.apache.pivot.collections.ArrayList)1 SerializationException (org.apache.pivot.serialization.SerializationException)1 Alert (org.apache.pivot.wtk.Alert)1 BoxPane (org.apache.pivot.wtk.BoxPane)1 Button (org.apache.pivot.wtk.Button)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 ComponentMouseListener (org.apache.pivot.wtk.ComponentMouseListener)1 Display (org.apache.pivot.wtk.Display)1 Frame (org.apache.pivot.wtk.Frame)1 Label (org.apache.pivot.wtk.Label)1 Sheet (org.apache.pivot.wtk.Sheet)1 TablePane (org.apache.pivot.wtk.TablePane)1 TableView (org.apache.pivot.wtk.TableView)1 TableViewSelectionListener (org.apache.pivot.wtk.TableViewSelectionListener)1 Window (org.apache.pivot.wtk.Window)1