}
private void showConfigDialog() {
final Stage stage = Stage.createStage();
stage.setTitle("Share with Twitter");
GridBox grid = new GridBox()
.createColumn(30, GridBox.Align.Left)
.createColumn(300, GridBox.Align.Left)
;
stage.setWidth(400);
stage.setHeight(280);
final Radiobutton selected = new Radiobutton("Just selected shapes");
final Radiobutton contents = new Radiobutton("Page contents (just big enough for the content)");
final Radiobutton page = new Radiobutton("Entire page (clipped at page edges)");
final Checkbox includeStamp = new Checkbox("include 'handcrafted with LeonardoSketch.org' in lower left");
includeStamp.setSelected(true);
final ToggleGroup tg = new ToggleGroup();
tg.add(selected)
.add(contents)
.add(page);
tg.setSelectedButton(page);
grid.addControl(new Label("Share:"));
grid.addControl(selected);
grid.nextRow();
grid.addControl(new Spacer());
grid.addControl(contents);
grid.nextRow();
grid.addControl(new Spacer());
grid.addControl(page);
grid.nextRow();
grid.nextRow();
grid.addControl(includeStamp);
grid.nextRow();
Button cancelButton = new Button("cancel");
cancelButton.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
stage.hide();
}
});
grid.addControl(cancelButton);
Button continueButton = new Button("continue");
continueButton.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
stage.hide();
final File file = File.createTempFile("foo", ".png");
file.deleteOnExit();
CanvasDocument doc = context.getDocument();
if(doc instanceof SketchDocument) {
SketchDocument sdoc = (SketchDocument) doc;
SavePNGAction save = new SavePNGAction(null);
VectorDocContext vdc = (VectorDocContext) context;
save.includeBackground = true;
if(includeStamp.isSelected()) {
save.includeStamp = true;
}
if(tg.getSelectedButton() == page) {
save.includeDocumentBounds = true;
}
if(tg.getSelectedButton() == selected) {
SavePNGAction.exportFragment(file, (Iterable<SNode>) vdc.getSelection().items());
} else {
save.export(file, sdoc);
}
}
if(doc instanceof PixelDocument) {
SavePNGAction save = new SavePNGAction(null);
save.exportStatic(file, (PixelDocument) doc);
}
requestMessage(file);
}
});
grid.addControl(continueButton);
stage.setContent(grid);
}