forked from taweili/ardublock
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from stfc/release-2.2.0
Release 2.2.0 to master
- Loading branch information
Showing
6 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/com/ardublock/ui/listener/EraseButtonListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.ardublock.ui.listener; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.util.ResourceBundle; | ||
|
||
import javax.swing.JFrame; | ||
|
||
import com.ardublock.core.Context; | ||
import com.ardublock.translator.AutoFormat; | ||
|
||
import edu.mit.blocks.workspace.Workspace; | ||
|
||
public class EraseButtonListener implements ActionListener | ||
{ | ||
private JFrame parentFrame; | ||
private Context context; | ||
private Workspace workspace; | ||
private ResourceBundle uiMessageBundle; | ||
|
||
public EraseButtonListener(JFrame frame, Context context) | ||
{ | ||
this.parentFrame = frame; | ||
this.context = context; | ||
workspace = context.getWorkspaceController().getWorkspace(); | ||
uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock"); | ||
} | ||
|
||
public void actionPerformed(ActionEvent e) | ||
{ | ||
AutoFormat formatter = new AutoFormat(); | ||
String codeOut = "void setup() {\n" | ||
+ "// put your setup code here, to run once:\n\n" | ||
+ "}\n\n" | ||
+ "void loop() {\n" | ||
+ "// put your main code here, to run repeatedly:\n\n" | ||
+ "}"; | ||
|
||
if (context.isNeedAutoFormat) | ||
{ | ||
codeOut = formatter.format(codeOut); | ||
} | ||
|
||
if (!context.isInArduino()) | ||
{ | ||
System.out.println(codeOut); | ||
} | ||
context.didGenerate(codeOut); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters