use of org.apache.pivot.wtk.Window in project pivot by apache.
the class ColorPaletteTest method startup.
@SuppressWarnings("unused")
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
Theme theme = Theme.getTheme();
TablePane tablePane = new TablePane();
new TablePane.Column(tablePane, 1, true);
new TablePane.Column(tablePane, 1, true);
new TablePane.Column(tablePane, 1, true);
int numberOfPaletteColors = theme.getNumberOfPaletteColors();
// ArrayList<String> colors = new ArrayList<>(numberOfPaletteColors);
for (int i = 0; i < numberOfPaletteColors; i++) {
TablePane.Row row = new TablePane.Row(tablePane, 1, true);
row.add(createCell(i * 3));
row.add(createCell(i * 3 + 1));
row.add(createCell(i * 3 + 2));
}
tablePane.getStyles().put(Style.horizontalSpacing, 4);
tablePane.getStyles().put(Style.verticalSpacing, 4);
Border border = new Border(tablePane);
border.getStyles().put(Style.padding, 6);
this.window = new Window(border);
this.window.setTitle("Color Palette");
this.window.setMaximized(true);
this.window.open(display);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class SheetSlideDirectionWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
// Populate the ListButton with values from the enum
listButton.setListData(new ArrayList<>(SheetPlacement.values()));
listButton = null;
// Populate the form with data from the Sheet's styles
form.load(sheet.getStyles());
// Common ButtonPressListener to be applied to all four of
// the PushButtons representing a slide direction
ButtonPressListener openSheetButtonPressListener = new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
StyleDictionary sheetStyles = sheet.getStyles();
form.store(sheetStyles);
button.store(sheetStyles);
form.load(sheetStyles);
sheet.load(sheetStyles);
sheet.open(button.getWindow());
}
};
// Apply the common ButtonPressListener to the PushButtons
for (Iterator<Component> it = tablePane.iterator(); it.hasNext(); ) {
Component component = it.next();
if (component instanceof PushButton) {
PushButton button = (PushButton) component;
button.getButtonPressListeners().add(openSheetButtonPressListener);
button.setTooltipText("Press me!");
}
}
tablePane = null;
// Mouse handler to enable users to quickly close the sheet
final ContainerMouseListener displayMouseHandler = new ContainerMouseListener() {
@Override
public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
Display display = (Display) container;
Component component = display.getComponentAt(x, y);
// Close the sheet by clicking away from it.
// This allows resizing etc to work without requiring
// a close button or similar on the sheet.
boolean consumed = (component != sheet);
if (consumed) {
sheet.close();
}
return consumed;
}
};
// Add/remove the mouse handler based on the Sheet's state
sheet.getWindowStateListeners().add(new WindowStateListener() {
@Override
public void windowOpened(Window window) {
window.getDisplay().getContainerMouseListeners().add(displayMouseHandler);
}
@Override
public void windowClosed(Window window, Display display, Window owner) {
display.getContainerMouseListeners().remove(displayMouseHandler);
}
});
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class BaselineTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = new Window((Component) bxmlSerializer.readObject(getClass().getResource("baseline_test.bxml")));
window.setTitle("Baseline Test");
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class PushButtonTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
window = new Window();
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
PushButton uploadButton = new PushButton("Upload");
uploadButton.getStyles().put(Style.minimumAspectRatio, 3.0f);
boxPane.add(uploadButton);
window.setContent(boxPane);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class JavascriptConsoleTest method loadWindow.
/**
* Load (and returns) a Window, given its file name and serializer to use
*
* @param fileName the file name for the bxml file to load
* @param bxmlSerializer the serializer to use, or if null a new one will be
* created
* @return the Window instance
* @throws SerializationException in case of error
* @throws IOException in case of error
*/
private Window loadWindow(String fileName, final BXMLSerializer bxmlSerializer) throws SerializationException, IOException {
logObject("loadWindow from \"" + fileName + "\", with the serializer " + bxmlSerializer);
BXMLSerializer serializer = bxmlSerializer;
if (serializer == null) {
serializer = new BXMLSerializer();
}
// setLocation or setResources in the serializer) ...
return (Window) serializer.readObject(JavascriptConsoleTest.class, fileName, true);
}
Aggregations