use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class Pivot859 method startup.
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
System.out.println("startup(...)");
initializeProperties(properties);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(Pivot859.class, "pivot_859.bxml");
initializeFields(bxmlSerializer);
window.open(display);
}
use of org.apache.pivot.beans.BXMLSerializer 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);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class Pivot835 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Window window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_835.bxml"));
window.open(display);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class Pivot862 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_862.bxml"));
bxmlSerializer.bind(this, Pivot862.class);
selectFolderButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
// to
fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_TO);
// be
// able
// to
// select
// a
// folder
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
File loadedFile = fileBrowserSheet.getSelectedFile();
try {
selectedFolder = loadedFile.getCanonicalPath();
System.out.println("Selected folder '" + selectedFolder + "'");
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
openFileButton.setEnabled(true);
} catch (IOException e) {
e.printStackTrace();
openFileButton.setEnabled(false);
}
window.setTitle("Selected folder: " + selectedFolder);
}
}
});
}
});
openFileButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
System.out.println("Now opening a BrowserSheet starting from the previous selected folder: \"" + selectedFolder + "\"");
FileBrowserSheet fileBrowserSheet = // selectedFolder); // use this as a workaround ...
new FileBrowserSheet(// test to see
FileBrowserSheet.Mode.OPEN);
// the wrong
// behavior
// new FileBrowserSheet(); // test to see the wrong behavior
// ok, but
fileBrowserSheet.setRootFolder(selectedFolder);
// doesn't solve
// this issue
// ...
System.out.println("\nNote: the behavior here is right only when using the constructor with two parameters ..." + " but in this source it's used one of other constructors.\n");
try {
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
} catch (IOException e) {
e.printStackTrace();
}
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
// empty block
}
});
}
});
window.open(display);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class Pivot837 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Window window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_837.bxml"));
window.open(display);
}
Aggregations