use of org.apache.pivot.beans.BXMLSerializer 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.beans.BXMLSerializer in project pivot by apache.
the class TerraAlertSkin method install.
@Override
public void install(Component component) {
super.install(component);
Alert alert = (Alert) component;
alert.setPreferredWidth(320);
alert.setMinimumWidth(160);
alert.getAlertListeners().add(this);
// Load the alert content
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Component content;
try {
content = (Component) bxmlSerializer.readObject(TerraAlertSkin.class, "terra_alert_skin.bxml");
} catch (Exception exception) {
throw new RuntimeException(exception);
}
alert.setContent(content);
typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
messageBorder = (Border) bxmlSerializer.getNamespace().get("messageBorder");
messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
// Explicitly set the message border color and background color, this can't be done properly in the constructor
// as messageBorder is null at that point.
setBorderBackgroundColor(borderBackgroundColor);
setBorderColor(borderColor);
for (Object option : alert.getOptions()) {
PushButton optionButton = new PushButton(option);
optionButton.setStyleName(BUTTON_STYLE_NAME);
optionButton.getButtonPressListeners().add(optionButtonPressListener);
optionButtonBoxPane.add(optionButton);
}
messageTypeChanged(alert, null);
messageChanged(alert, null);
bodyChanged(alert, null);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class Expenses method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
// Get startup properties
URL origin = ApplicationContext.getOrigin();
if (origin == null) {
System.out.println("Warning: Origin null, so for this application to run you have to set the following properties: \n" + SECURE_KEY + ", " + HOSTNAME_KEY + ", " + PORT_KEY + "\n");
System.exit(1);
// make Eclipse's null checker happy
return;
}
if (properties.containsKey(SECURE_KEY)) {
secure = Boolean.parseBoolean(properties.get(SECURE_KEY));
} else {
secure = origin.getProtocol().equals("HTTPS");
}
if (properties.containsKey(HOSTNAME_KEY)) {
hostname = properties.get(HOSTNAME_KEY);
} else {
hostname = origin.getHost();
}
if (properties.containsKey(PORT_KEY)) {
port = Integer.parseInt(properties.get(PORT_KEY));
} else {
port = origin.getPort();
}
BXMLSerializer bxmlSerializer = new BXMLSerializer();
expensesWindow = (ExpensesWindow) bxmlSerializer.readObject(ExpensesWindow.class, "expenses_window.bxml", true);
expensesWindow.setExpensesApplication(this);
expensesWindow.open(display);
}
use of org.apache.pivot.beans.BXMLSerializer 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.beans.BXMLSerializer in project pivot by apache.
the class WebQueries method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(WebQueries.class, "web_queries.bxml");
listView = (ListView) bxmlSerializer.getNamespace().get("listView");
loadingLabel = (Label) bxmlSerializer.getNamespace().get("loadingLabel");
// Execute the query:
// http://pipes.yahoo.com/pipes/pipe.run?_id=43115761f2da5af5341ae2e56a93d646&_render=json
GetQuery getQuery = new GetQuery("pipes.yahoo.com", "/pipes/pipe.run");
getQuery.getParameters().put("_id", "43115761f2da5af5341ae2e56a93d646");
getQuery.getParameters().put("_render", "json");
getQuery.execute(new TaskAdapter<>(new TaskListener<Object>() {
@Override
public void taskExecuted(Task<Object> task) {
List<?> items = (List<?>) JSON.get(task.getResult(), "value.items");
if (items.getLength() > 0) {
listView.setListData(items);
loadingLabel.setVisible(false);
} else {
loadingLabel.setText("No results.");
}
}
@Override
public void executeFailed(Task<Object> task) {
loadingLabel.setText(task.getFault().getMessage());
}
}));
window.open(display);
}
Aggregations