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();
}
}
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);
}
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);
}
});
}
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);
}
Aggregations