/*
WorkspaceController workspaceController = context.getWorkspaceController();
JComponent workspaceComponent = workspaceController.getWorkspacePanel();
*/
final Workspace workspace = context.getWorkspace();
// WTF I can't add worksapcelistener by workspace contrller
workspace.addWorkspaceListener(new ArdublockWorkspaceListener(this));
JPanel buttons = new JPanel();
buttons.setLayout(new FlowLayout());
JButton newButton = new JButton(uiMessageBundle.getString("ardublock.ui.new"));
newButton.addActionListener(new NewButtonListener(this));
JButton saveButton = new JButton(uiMessageBundle.getString("ardublock.ui.save"));
saveButton.addActionListener(new SaveButtonListener(this));
JButton saveAsButton = new JButton(uiMessageBundle.getString("ardublock.ui.saveAs"));
saveAsButton.addActionListener(new SaveAsButtonListener(this));
JButton openButton = new JButton(uiMessageBundle.getString("ardublock.ui.load"));
openButton.addActionListener(new OpenButtonListener(this));
JButton generateButton = new JButton(uiMessageBundle.getString("ardublock.ui.upload"));
generateButton.addActionListener(new GenerateCodeButtonListener(this, context));
JButton serialMonitorButton = new JButton(uiMessageBundle.getString("ardublock.ui.serialMonitor"));
serialMonitorButton.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e) {
context.getEditor().handleSerial();
}
});
JButton saveImageButton = new JButton(uiMessageBundle.getString("ardublock.ui.saveImage"));
saveImageButton.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e) {
Dimension size = workspace.getCanvasSize();
System.out.println("size: " + size);
BufferedImage bi = new BufferedImage(2560, 2560, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D)bi.createGraphics();
double theScaleFactor = (300d/72d);
g.scale(theScaleFactor,theScaleFactor);
workspace.getBlockCanvas().getPageAt(0).getJComponent().paint(g);
try{
final JFileChooser fc = new JFileChooser();
fc.setSelectedFile(new File("ardublock.png"));
int returnVal = fc.showSaveDialog(workspace.getBlockCanvas().getJComponent());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
ImageIO.write(bi,"png",file);
}
} catch (Exception e1) {