use of org.apache.pivot.wtk.PushButton 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");
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class Pivot718 method controlList.
private void controlList(BXMLSerializer bxmlSerializer) {
listDelButton = (PushButton) bxmlSerializer.getNamespace().get("listDelButton");
list = (ListView) bxmlSerializer.getNamespace().get("list");
list.getListViewSelectionListeners().add(new ListViewSelectionListener() {
@Override
public void selectedRangeAdded(ListView listView, int rangeStart, int rangeEnd) {
System.out.println("selectedRangeAdded");
}
@Override
public void selectedRangeRemoved(ListView listView, int rangeStart, int rangeEnd) {
System.out.println("selectedRangeRemoved");
}
@Override
public void selectedRangesChanged(ListView listView, Sequence<Span> previousSelectedRanges) {
System.out.println("selectedRangesChanged");
}
@Override
public void selectedItemChanged(ListView listView, Object previousSelectedItem) {
System.out.println("selectedItemChanged :::" + listView.getSelectedItem());
}
});
listDelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = list.getSelectedItem();
System.out.println("delete :: " + x);
// List data = list.getListData();
@SuppressWarnings("unchecked") List<Object> data = (List<Object>) list.getListData();
data.remove(x);
}
});
}
use of org.apache.pivot.wtk.PushButton 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);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class PromptTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.BOTTOM);
helloButton = new PushButton("Say Hello");
boxPane.add(helloButton);
helloButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
String text = button.getButtonData().toString();
if (window.isBlocked()) {
System.out.println("I'm already saying \"" + text + "\" !");
} else {
Prompt.prompt(text, window);
}
}
});
Border border = new Border(boxPane);
border.getStyles().put(Style.color, 7);
border.getStyles().put(Style.padding, 5);
window = new Window(border);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class Pivot894 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
System.out.println("public startup(...)");
System.out.println("\n" + "Attention: now the application will go in an infinite loop, to be able to see the memory leak.\n" + "Note that probably you'll have to kill the application from outside (kill the Java process).\n" + "\n");
// add some sleep to let users see the warning messages in console ...
Thread.sleep(2000);
final CardPane cardPane = new CardPane();
cardPane.getStyles().put(Style.selectionChangeEffect, CardPaneSkin.SelectionChangeEffect.HORIZONTAL_SLIDE);
final Window window = new Window(cardPane);
window.open(display);
ApplicationContext.scheduleRecurringCallback(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("switcher-thread");
// temp
System.out.println("Run num " + num++);
//
try {
// Before the fixes for PIVOT-861 (part two) it was causing
// out of memory ...
//
// Note that this has been moved to another issue, but the
// problem is due to the usage
// of dataRenderer tags (and then instancing
// ButtonDataRenderer) in the loaded bxml,
// so probably even this test will be updated ...
//
final GridPane grid = (GridPane) new BXMLSerializer().readObject(Pivot894.class, "btn_grid.bxml");
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Iterator<Component> iterator = cardPane.iterator();
List<Component> componentList = new ArrayList<>();
while (iterator.hasNext()) {
Component card = iterator.next();
if (!card.isShowing()) {
componentList.add(card);
}
}
for (Component card : componentList) {
cardPane.remove(card);
}
cardPane.setSelectedIndex(cardPane.add(grid));
System.out.println(cardPane.getSelectedIndex());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unused")
private Row createGridRow() {
Row row = new Row();
try {
// note that this method doesn't use ApplicationContext
// cache for images ...
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (TaskExecutionException e) {
e.printStackTrace();
}
return row;
}
}, 100);
}
Aggregations