use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class ExpenseSheet method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resource) {
this.resources = resource;
dateSpinner = (Spinner) namespace.get("dateSpinner");
typeListButton = (ListButton) namespace.get("typeListButton");
amountTextInput = (TextInput) namespace.get("amountTextInput");
cancelButton = (PushButton) namespace.get("cancelButton");
okButton = (PushButton) namespace.get("okButton");
cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
close(false);
}
});
okButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
close(true);
}
});
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class StockTrackerWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
// Add stocks table view event handlers
stocksTableView.getTableViewRowListeners().add(new TableViewRowListener() {
@Override
public void rowsSorted(TableView tableView) {
List<?> tableData = stocksTableView.getTableData();
if (tableData.getLength() > 0) {
stocksTableView.setSelectedIndex(0);
}
}
});
stocksTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener() {
@Override
public void selectedRangesChanged(TableView tableView, Sequence<Span> previousSelectedRanges) {
int firstSelectedIndex = stocksTableView.getFirstSelectedIndex();
removeSymbolsAction.setEnabled(firstSelectedIndex != -1);
refreshDetail();
}
});
stocksTableView.getTableViewSortListeners().add(new TableViewSortListener() {
@Override
public void sortChanged(TableView tableView) {
@SuppressWarnings("unchecked") List<Object> tableData = (List<Object>) tableView.getTableData();
tableData.setComparator(new TableViewRowComparator(tableView));
}
});
stocksTableView.getComponentKeyListeners().add(new ComponentKeyListener() {
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
if (keyCode == Keyboard.KeyCode.DELETE || keyCode == Keyboard.KeyCode.BACKSPACE) {
removeSymbolsAction.perform(component);
} else if (keyCode == Keyboard.KeyCode.A && Keyboard.isPressed(Platform.getCommandModifier())) {
stocksTableView.selectAll();
}
return false;
}
});
// Add symbol text input event handlers
symbolTextInput.getTextInputContentListeners().add(new TextInputContentListener() {
@Override
public void textChanged(TextInput textInput) {
addSymbolAction.setEnabled(textInput.getCharacterCount() > 0);
}
});
symbolTextInput.getComponentKeyListeners().add(new ComponentKeyListener() {
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
if (keyCode == Keyboard.KeyCode.ENTER) {
if (addSymbolAction.isEnabled()) {
addSymbolAction.perform(component);
}
}
return false;
}
});
// Assign actions to add and remove symbol buttons
addSymbolButton.setAction(addSymbolAction);
removeSymbolsButton.setAction(removeSymbolsAction);
// Add a button press listener to open the Yahoo! Finance web page when
// the link is clicked
yahooFinanceButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URL(YAHOO_FINANCE_HOME).toURI());
} catch (MalformedURLException exception) {
throw new RuntimeException(exception);
} catch (URISyntaxException exception) {
throw new RuntimeException(exception);
} catch (IOException exception) {
System.out.println("Unable to open " + YAHOO_FINANCE_HOME + " in default browser.");
}
}
});
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class CardPanes method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
cardPane = (CardPane) namespace.get("cardPane");
previousButton = (LinkButton) namespace.get("previousButton");
nextButton = (LinkButton) namespace.get("nextButton");
sizeToSelectionCheckbox = (Checkbox) namespace.get("sizeToSelectionCheckbox");
crossfadeRadioButton = (RadioButton) namespace.get("crossfadeRadioButton");
horizontalSlideRadioButton = (RadioButton) namespace.get("horizontalSlideRadioButton");
verticalSlideRadioButton = (RadioButton) namespace.get("verticalSlideRadioButton");
horizontalFlipRadioButton = (RadioButton) namespace.get("horizontalFlipRadioButton");
verticalFlipRadioButton = (RadioButton) namespace.get("verticalFlipRadioButton");
zoomRadioButton = (RadioButton) namespace.get("zoomRadioButton");
noneRadioButton = (RadioButton) namespace.get("noneRadioButton");
cardPane.getCardPaneListeners().add(new CardPaneListener() {
@Override
public void selectedIndexChanged(CardPane cardPaneArgument, int previousSelectedIndex) {
updateLinkButtonState();
}
});
previousButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
cardPane.setSelectedIndex(cardPane.getSelectedIndex() - 1);
}
});
nextButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
cardPane.setSelectedIndex(cardPane.getSelectedIndex() + 1);
}
});
ButtonStateListener checkboxStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
updateCardPane();
}
};
sizeToSelectionCheckbox.getButtonStateListeners().add(checkboxStateListener);
ButtonStateListener radioButtonStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
if (button.isSelected()) {
updateCardPane();
}
}
};
crossfadeRadioButton.getButtonStateListeners().add(radioButtonStateListener);
horizontalSlideRadioButton.getButtonStateListeners().add(radioButtonStateListener);
verticalSlideRadioButton.getButtonStateListeners().add(radioButtonStateListener);
horizontalFlipRadioButton.getButtonStateListeners().add(radioButtonStateListener);
verticalFlipRadioButton.getButtonStateListeners().add(radioButtonStateListener);
zoomRadioButton.getButtonStateListeners().add(radioButtonStateListener);
noneRadioButton.getButtonStateListeners().add(radioButtonStateListener);
updateCardPane();
updateLinkButtonState();
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class Meters method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
meter = (Meter) namespace.get("meter");
progressButton = (PushButton) namespace.get("progressButton");
progressButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
if (sampleTask == null) {
// Create and start the simulated task; wrap it in a
// task adapter so the result handlers are called on the
// UI thread
sampleTask = new SampleTask();
sampleTask.execute(new TaskAdapter<>(new TaskListener<Void>() {
@Override
public void taskExecuted(Task<Void> task) {
reset();
}
@Override
public void executeFailed(Task<Void> task) {
reset();
}
private void reset() {
// Reset the meter and button
sampleTask = null;
meter.setPercentage(0);
updateProgressButton();
}
}));
} else {
// Cancel the task
sampleTask.abort();
}
updateProgressButton();
}
});
updateProgressButton();
}
Aggregations