use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
Sheet sheet = (Sheet) getComponent();
Component content = sheet.getContent();
if (content != null) {
if (height != -1) {
height = Math.max(height - (padding.getHeight() + 2), 0);
}
preferredWidth = content.getPreferredWidth(height);
}
preferredWidth += (padding.getWidth() + 2);
return preferredWidth;
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class ExpensesWindow method deleteSelectedExpense.
private void deleteSelectedExpense() {
Object expense = expenseTableView.getSelectedRow();
final int id = JSON.getInt(expense, "id");
deleteConfirmationPrompt.open(this, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult() && ((Prompt) sheet).getSelectedOptionIndex() == 1) {
// DELETE expense from server and then remove from table
Expenses expensesApplicationLocal = getExpensesApplication();
DeleteQuery deleteExpenseQuery = new DeleteQuery(expensesApplicationLocal.getHostname(), expensesApplicationLocal.getPort(), "/pivot-tutorials/expenses/" + id, expensesApplicationLocal.isSecure());
activityIndicatorBoxPane.setVisible(true);
activityIndicator.setActive(true);
deleteExpenseQuery.execute(new TaskAdapter<>(new TaskListener<Void>() {
@Override
public void taskExecuted(Task<Void> task) {
activityIndicatorBoxPane.setVisible(false);
activityIndicator.setActive(false);
// Find matching row and remove
@SuppressWarnings("unchecked") List<Object> expenses = (List<Object>) expenseTableView.getTableData();
for (int i = 0, n = expenses.getLength(); i < n; i++) {
if (JSON.get(expenses.get(i), "id").equals(id)) {
expenses.remove(i, 1);
break;
}
}
}
@Override
public void executeFailed(Task<Void> task) {
activityIndicatorBoxPane.setVisible(false);
activityIndicator.setActive(false);
Prompt.prompt(MessageType.ERROR, task.getFault().getMessage(), ExpensesWindow.this);
}
}));
}
}
});
}
Aggregations