use of org.apache.pivot.wtk.Button in project pivot by apache.
the class TerraListViewSkin method mouseClick.
@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
boolean consumed = super.mouseClick(component, button, x, y, count);
ListView listView = (ListView) getComponent();
int itemIndex = getItemAt(y);
if (itemIndex != -1 && !listView.isItemDisabled(itemIndex)) {
if (listView.getCheckmarksEnabled() && !listView.isCheckmarkDisabled(itemIndex) && getCheckboxBounds(itemIndex).contains(x, y)) {
if (listView.getAllowTriStateCheckmarks()) {
Button.State currentState = listView.getItemCheckmarkState(itemIndex);
Button.State nextState = currentState;
switch(currentState) {
case UNSELECTED:
if (listView.getCheckmarksMixedAsChecked()) {
nextState = Button.State.SELECTED;
} else {
nextState = Button.State.MIXED;
}
break;
case MIXED:
nextState = Button.State.SELECTED;
break;
case SELECTED:
nextState = Button.State.UNSELECTED;
break;
}
listView.setItemCheckmarkState(itemIndex, nextState);
} else {
listView.setItemChecked(itemIndex, !listView.isItemChecked(itemIndex));
}
} else {
if (selectIndex != -1 && count == 1 && button == Mouse.Button.LEFT) {
ListView.ItemEditor itemEditor = listView.getItemEditor();
if (itemEditor != null) {
if (itemEditor.isEditing()) {
itemEditor.endEdit(true);
}
itemEditor.beginEdit(listView, selectIndex);
}
}
}
}
selectIndex = -1;
return consumed;
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class TerraAccordionSkin method selectedIndexChanged.
@Override
public void selectedIndexChanged(Accordion accordion, int previousSelectedIndex) {
int selectedIndex = accordion.getSelectedIndex();
if (selectedIndex != previousSelectedIndex) {
// This was not an indirect selection change
if (selectedIndex == -1) {
Button button = panelHeaderGroup.getSelection();
if (button != null) {
button.setSelected(false);
}
} else {
Button button = panelHeaders.get(selectedIndex);
button.setSelected(true);
Component selectedPanel = accordion.getPanels().get(selectedIndex);
selectedPanel.requestFocus();
}
invalidateComponent();
}
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class TabPanes method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
confirmCloseTabPrompt = (Prompt) namespace.get("confirmCloseTabPrompt");
tabPane = (TabPane) namespace.get("tabPane");
closeableCheckbox = (Checkbox) namespace.get("closeableCheckbox");
collapsibleCheckbox = (Checkbox) namespace.get("collapsibleCheckbox");
horizontalRadioButton = (RadioButton) namespace.get("horizontalRadioButton");
verticalRadioButton = (RadioButton) namespace.get("verticalRadioButton");
cornerBoxPane = (BoxPane) namespace.get("cornerBoxPane");
tabPane.getTabPaneListeners().add(new TabPaneListener() {
@Override
public Vote previewRemoveTabs(final TabPane tabPaneArgument, final int index, final int count) {
Vote vote;
if (confirmCloseTab) {
confirmCloseTabPrompt.open(TabPanes.this, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (confirmCloseTabPrompt.getResult() && confirmCloseTabPrompt.getSelectedOptionIndex() == 1) {
confirmCloseTab = false;
int n = tabPaneArgument.getTabs().getLength();
if (index < n - 1) {
tabPaneArgument.setSelectedIndex(index + 1);
} else {
tabPaneArgument.setSelectedIndex(index - 1);
}
tabPaneArgument.getTabs().remove(index, count);
confirmCloseTab = true;
}
}
});
vote = Vote.DENY;
} else {
vote = Vote.APPROVE;
}
return vote;
}
});
ButtonStateListener checkboxStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
updateTabPane();
}
};
closeableCheckbox.getButtonStateListeners().add(checkboxStateListener);
collapsibleCheckbox.getButtonStateListeners().add(checkboxStateListener);
ButtonStateListener radioButtonStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
if (button.isSelected()) {
updateTabPane();
}
}
};
horizontalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
verticalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
updateTabPane();
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class ActivityIndicators method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
activityIndicator1 = (ActivityIndicator) namespace.get("activityIndicator1");
activityIndicator2 = (ActivityIndicator) namespace.get("activityIndicator2");
activityIndicator3 = (ActivityIndicator) namespace.get("activityIndicator3");
activityButton = (PushButton) namespace.get("activityButton");
activityButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator1.setActive(!activityIndicator1.isActive());
activityIndicator2.setActive(!activityIndicator2.isActive());
activityIndicator3.setActive(!activityIndicator3.isActive());
updateButtonData();
}
});
updateButtonData();
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot694 method initializeFields.
private void initializeFields(BXMLSerializer serializer) {
System.out.println("initializeFields: start");
// TODO: for release 2.1 ... maybe generalizing some test here
// pushButtons =
// (ButtonGroup)serializer.getNamespace().get("pushButtons");
// toggleButtons =
// (ButtonGroup)serializer.getNamespace().get("toggleButtons");
// radioButtons =
// (ButtonGroup)serializer.getNamespace().get("radioButtons");
// checkButtons =
// (ButtonGroup)serializer.getNamespace().get("checkButtons");
// checkTriButtons =
// (ButtonGroup)serializer.getNamespace().get("checkTriButtons");
calendarButton1 = (CalendarButton) serializer.getNamespace().get("calendarButton1");
calendarButton2 = (CalendarButton) serializer.getNamespace().get("calendarButton2");
spinner1 = (Spinner) serializer.getNamespace().get("spinner1");
spinner2 = (Spinner) serializer.getNamespace().get("spinner2");
listView1 = (ListView) serializer.getNamespace().get("listView1");
listView2 = (ListView) serializer.getNamespace().get("listView2");
tableView1 = (TableView) serializer.getNamespace().get("tableView1");
tableView2 = (TableView) serializer.getNamespace().get("tableView2");
treeView1 = (TreeView) serializer.getNamespace().get("treeView1");
treeView2 = (TreeView) serializer.getNamespace().get("treeView2");
listButton1 = (ListButton) serializer.getNamespace().get("listButton1");
listButton2 = (ListButton) serializer.getNamespace().get("listButton2");
clearSelectionButton = (PushButton) serializer.getNamespace().get("clearSelectionButton");
clearSelectionButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
System.out.println("Clearing selection from " + button.getName() + " at " + new Date());
// TODO: for release 2.1 ... maybe generalizing some test here
// pushButtons.clearSelection();
// toggleButtons.clearSelection();
// radioButtons.clearSelection();
// checkButtons.clearSelection();
// checkTriButtons.clearSelection();
calendarButton1.clearSelection();
calendarButton2.clearSelection();
spinner1.clearSelection();
spinner2.clearSelection();
listButton1.clearSelection();
listButton2.clearSelection();
listView1.clearSelection();
listView2.clearSelection();
tableView1.clearSelection();
tableView2.clearSelection();
treeView1.clearSelection();
treeView2.clearSelection();
}
});
clearButton = (PushButton) serializer.getNamespace().get("clearButton");
clearButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
System.out.println("Clearing data from " + button.getName() + " at " + new Date());
// TODO: verify for release 2.1 if implement a method to empty
// components inside ...
// pushButtons.remove(button);
// toggleButtons.remove(button);
// radioButtons.remove(button);
// checkButtons.remove(button);
// checkTriButtons.remove(button);
// force clear of elements data ...
clearComponent(calendarButton1);
clearComponent(calendarButton2);
clearComponent(spinner1);
clearComponent(spinner2);
clearComponent(listButton1);
clearComponent(listButton2);
clearComponent(listView1);
clearComponent(listView2);
clearComponent(tableView1);
clearComponent(tableView2);
clearComponent(treeView1);
clearComponent(treeView2);
// TODO: put (in bxml) the two tableView in a SplitPane, and see
// some strange moving mouse over ...
// TODO: add clear/clearSelection methods even to some type of
// buttons (all types in the first row displayed) ...
}
});
System.out.println("initializeFields: end");
}
Aggregations