mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Merge remote-tracking branch 'cmaglie/new-extension' into new-extension
This commit is contained in:
commit
53ab9306e2
10
.classpath
10
.classpath
@ -2,9 +2,11 @@
|
||||
<classpath>
|
||||
<classpathentry excluding="processing/app/tools/format/|processing/app/tools/format/src/|processing/app/Trace.java|processing/app/RunnerClassLoader.java" kind="src" path="app/src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
|
||||
<classpathentry kind="lib" path="build/shared/lib/antlr.jar"/>
|
||||
<classpathentry kind="lib" path="build/shared/lib/registry.jar"/>
|
||||
<classpathentry kind="lib" path="build/shared/lib/apple.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
|
||||
<classpathentry kind="lib" path="app/lib/antlr.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/apple.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/ecj.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/jna.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/RXTXcomm.jar"/>
|
||||
<classpathentry kind="output" path="app/bin"/>
|
||||
</classpath>
|
||||
|
@ -1,10 +1,15 @@
|
||||
#Thu Jan 10 10:50:38 PST 2008
|
||||
#Tue Aug 16 19:08:40 CEST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
|
||||
org.eclipse.jdt.core.compiler.compliance=1.4
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.3
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
|
@ -436,6 +436,17 @@ public class Base {
|
||||
// .................................................................
|
||||
|
||||
|
||||
/** Command on Mac OS X, Ctrl on Windows and Linux */
|
||||
static final int SHORTCUT_KEY_MASK =
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
|
||||
static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
|
||||
KeyStroke.getKeyStroke('W', SHORTCUT_KEY_MASK);
|
||||
/** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */
|
||||
static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK |
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
|
||||
|
||||
// Because of variations in native windowing systems, no guarantees about
|
||||
// changes to the focused and active Windows can be made. Developers must
|
||||
// never assume that this Window is the focused or active Window until this
|
||||
|
@ -99,6 +99,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
static SerialMenuListener serialMenuListener;
|
||||
static SerialMonitor serialMonitor;
|
||||
|
||||
Schematics schematics;
|
||||
|
||||
EditorHeader header;
|
||||
EditorStatus status;
|
||||
EditorConsole console;
|
||||
@ -625,6 +627,16 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// }
|
||||
// });
|
||||
// sketchMenu.add(item);
|
||||
|
||||
sketchMenu.addSeparator();
|
||||
|
||||
item = new JMenuItem("Show schematics");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSchematics();
|
||||
}
|
||||
});
|
||||
sketchMenu.add(item);
|
||||
|
||||
sketchMenu.addSeparator();
|
||||
|
||||
@ -1841,9 +1853,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
String appletClassName = sketch.build(false);
|
||||
statusNotice("Done compiling.");
|
||||
} catch (Exception e) {
|
||||
status.unprogress();
|
||||
statusError(e);
|
||||
}
|
||||
|
||||
status.unprogress();
|
||||
toolbar.deactivate(EditorToolbar.RUN);
|
||||
}
|
||||
}
|
||||
@ -1856,9 +1870,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
String appletClassName = sketch.build(true);
|
||||
statusNotice("Done compiling.");
|
||||
} catch (Exception e) {
|
||||
status.unprogress();
|
||||
statusError(e);
|
||||
}
|
||||
|
||||
status.unprogress();
|
||||
toolbar.deactivate(EditorToolbar.RUN);
|
||||
}
|
||||
}
|
||||
@ -1890,7 +1906,6 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
return sketchWindowLocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements Sketch → Stop, or pressing Stop on the toolbar.
|
||||
*/
|
||||
@ -1907,6 +1922,19 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
|
||||
|
||||
public void handleSchematics() { // called by menu or buttons
|
||||
//String s = sketch.getFolder().getAbsolutePath() + File.separator + sketch.getName() + ".png";
|
||||
File file = new File(sketch.getFolder(), sketch.getName() + ".png");
|
||||
if (file.exists()) {
|
||||
if (schematics == null)
|
||||
schematics = new Schematics(file);
|
||||
schematics.showFrame(this);
|
||||
} else {
|
||||
statusNotice("This sketch doesn't include schematics");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivate the Run button. This is called by Runner to notify that the
|
||||
* sketch has stopped running, usually in response to an error (or maybe
|
||||
@ -2334,7 +2362,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
//if (!handleExportCheckModified()) return;
|
||||
toolbar.activate(EditorToolbar.EXPORT);
|
||||
console.clear();
|
||||
statusNotice("Uploading to I/O Board...");
|
||||
status.progress("Uploading to I/O Board...");
|
||||
|
||||
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
|
||||
}
|
||||
@ -2363,10 +2391,12 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} catch (RunnerException e) {
|
||||
//statusError("Error during upload.");
|
||||
//e.printStackTrace();
|
||||
status.unprogress();
|
||||
statusError(e);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
status.unprogress();
|
||||
uploading = false;
|
||||
//toolbar.clear();
|
||||
toolbar.deactivate(EditorToolbar.EXPORT);
|
||||
@ -2397,10 +2427,12 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} catch (RunnerException e) {
|
||||
//statusError("Error during upload.");
|
||||
//e.printStackTrace();
|
||||
status.unprogress();
|
||||
statusError(e);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
status.unprogress();
|
||||
uploading = false;
|
||||
//toolbar.clear();
|
||||
toolbar.deactivate(EditorToolbar.EXPORT);
|
||||
|
@ -40,6 +40,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
//static final int PROMPT = 2;
|
||||
//static final int EDIT = 3;
|
||||
static final int EDIT = 2;
|
||||
static final int PROGRESS = 5;
|
||||
|
||||
static final int YES = 1;
|
||||
static final int NO = 2;
|
||||
@ -66,6 +67,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
JButton cancelButton;
|
||||
JButton okButton;
|
||||
JTextField editField;
|
||||
JProgressBar progressBar;
|
||||
|
||||
//Thread promptThread;
|
||||
int response;
|
||||
@ -76,16 +78,22 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
empty();
|
||||
|
||||
if (bgcolor == null) {
|
||||
bgcolor = new Color[3]; //4];
|
||||
bgcolor = new Color[6];
|
||||
bgcolor[0] = Theme.getColor("status.notice.bgcolor");
|
||||
bgcolor[1] = Theme.getColor("status.error.bgcolor");
|
||||
bgcolor[2] = Theme.getColor("status.edit.bgcolor");
|
||||
bgcolor[3] = null;
|
||||
bgcolor[4] = null;
|
||||
bgcolor[5] = Theme.getColor("status.notice.bgcolor");
|
||||
|
||||
fgcolor = new Color[3]; //4];
|
||||
fgcolor = new Color[6];
|
||||
fgcolor[0] = Theme.getColor("status.notice.fgcolor");
|
||||
fgcolor[1] = Theme.getColor("status.error.fgcolor");
|
||||
fgcolor[2] = Theme.getColor("status.edit.fgcolor");
|
||||
}
|
||||
fgcolor[3] = null;
|
||||
fgcolor[4] = null;
|
||||
fgcolor[5] = Theme.getColor("status.notice.fgcolor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -163,6 +171,54 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
empty();
|
||||
}
|
||||
|
||||
public void progress(String message)
|
||||
{
|
||||
mode = PROGRESS;
|
||||
this.message = message;
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setVisible(true);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void progressIndeterminate(String message)
|
||||
{
|
||||
mode = PROGRESS;
|
||||
this.message = message;
|
||||
progressBar.setIndeterminate(true);
|
||||
progressBar.setValue(50);
|
||||
progressBar.setVisible(true);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void progressNotice(String message) {
|
||||
//mode = NOTICE;
|
||||
this.message = message;
|
||||
//update();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void unprogress()
|
||||
{
|
||||
if (Preferences.getBoolean("editor.beep.compile")) {
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
progressBar.setVisible(false);
|
||||
progressBar.setValue(0);
|
||||
setCursor(null);
|
||||
//empty();
|
||||
}
|
||||
|
||||
|
||||
public void progressUpdate(int value)
|
||||
{
|
||||
progressBar.setValue(value);
|
||||
repaint();
|
||||
}
|
||||
|
||||
/*
|
||||
public void update() {
|
||||
@ -369,6 +425,19 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
});
|
||||
add(editField);
|
||||
editField.setVisible(false);
|
||||
|
||||
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
||||
progressBar.setIndeterminate(false);
|
||||
if (Base.isMacOS()) {
|
||||
//progressBar.setBackground(bgcolor[PROGRESS]);
|
||||
//progressBar.putClientProperty("JProgressBar.style", "circular");
|
||||
}
|
||||
progressBar.setValue(0);
|
||||
progressBar.setBorderPainted(true);
|
||||
//progressBar.setStringPainted(true);
|
||||
add(progressBar);
|
||||
progressBar.setVisible(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,11 +454,13 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
//noButton.setLocation(noLeft, top);
|
||||
cancelButton.setLocation(cancelLeft, top);
|
||||
okButton.setLocation(noLeft, top);
|
||||
progressBar.setLocation(noLeft, top);
|
||||
|
||||
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
progressBar.setSize(2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
|
||||
// edit field height is awkward, and very different between mac and pc,
|
||||
// so use at least the preferred height for now.
|
||||
@ -398,6 +469,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
|
||||
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
|
||||
editWidth, editHeight);
|
||||
progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
|
||||
/** Rollover titles for each button. */
|
||||
static final String title[] = {
|
||||
"Verify", "Upload", "New", "Open", "Save", "Serial Monitor"
|
||||
"Verify", "Upload", "New", "Open", "Save", "Show Schematics", "Serial Monitor"
|
||||
};
|
||||
|
||||
/** Titles for each button when the shift key is pressed. */
|
||||
@ -56,18 +56,20 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
static final int BUTTON_IMAGE_SIZE = 33;
|
||||
|
||||
|
||||
static final int RUN = 0;
|
||||
static final int EXPORT = 1;
|
||||
static final int RUN = 0;
|
||||
static final int EXPORT = 1;
|
||||
|
||||
static final int NEW = 2;
|
||||
static final int OPEN = 3;
|
||||
static final int SAVE = 4;
|
||||
static final int NEW = 2;
|
||||
static final int OPEN = 3;
|
||||
static final int SAVE = 4;
|
||||
static final int SCHEMATICS = 5;
|
||||
|
||||
static final int SERIAL = 5;
|
||||
static final int SERIAL = 6;
|
||||
|
||||
static final int INACTIVE = 0;
|
||||
static final int ROLLOVER = 1;
|
||||
static final int ACTIVE = 2;
|
||||
static final int DISABLED = 3;
|
||||
|
||||
Editor editor;
|
||||
|
||||
@ -108,6 +110,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
which[buttonCount++] = NEW;
|
||||
which[buttonCount++] = OPEN;
|
||||
which[buttonCount++] = SAVE;
|
||||
which[buttonCount++] = SCHEMATICS;
|
||||
which[buttonCount++] = SERIAL;
|
||||
|
||||
currentRollover = -1;
|
||||
@ -258,8 +261,9 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
if ((y > y1) && (x > x1[i]) &&
|
||||
(y < y2) && (x < x2[i])) {
|
||||
//System.out.println("sel is " + i);
|
||||
return i;
|
||||
if (state[i] != DISABLED) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -267,10 +271,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
|
||||
|
||||
private void setState(int slot, int newState, boolean updateAfter) {
|
||||
state[slot] = newState;
|
||||
stateImage[slot] = buttonImages[which[slot]][newState];
|
||||
if (updateAfter) {
|
||||
repaint();
|
||||
if (state[slot]!=DISABLED) {
|
||||
state[slot] = newState;
|
||||
stateImage[slot] = buttonImages[which[slot]][newState];
|
||||
if (updateAfter) {
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,6 +344,10 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
editor.handleExport(e.isShiftDown());
|
||||
break;
|
||||
|
||||
case SCHEMATICS:
|
||||
editor.handleSchematics();
|
||||
break;
|
||||
|
||||
case SERIAL:
|
||||
editor.handleSerial();
|
||||
break;
|
||||
@ -371,6 +381,15 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
}
|
||||
|
||||
|
||||
public void disable(int what) {
|
||||
if (buttonImages != null && which!=null && state!=null && stateImage!=null) {
|
||||
state[what] = DISABLED;
|
||||
stateImage[what] = buttonImages[which[what]][INACTIVE];
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
273
app/src/processing/app/Schematics.java
Normal file
273
app/src/processing/app/Schematics.java
Normal file
@ -0,0 +1,273 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Wiring project - http://wiring.org.co
|
||||
|
||||
Copyright (c) 2009-11 Hernando Barragan
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class Schematics extends JFrame {
|
||||
private static final long serialVersionUID = 3254345343658939796L;
|
||||
|
||||
// prompt text stuff
|
||||
Image image;
|
||||
|
||||
int diagramX = 0, diagramY = 0;
|
||||
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
static final String PROMPT_CLOSE = "Close";
|
||||
|
||||
static final String PROMPT_RESETVIEW = "Reset";
|
||||
|
||||
/**
|
||||
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
|
||||
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
|
||||
*/
|
||||
static public int BUTTON_WIDTH = 80;
|
||||
|
||||
/**
|
||||
* Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, presumably
|
||||
* because it now includes the blue border, where it didn't in Java 1.3.
|
||||
* Windows XP only wants 23 (not sure what default Linux would be). Because of
|
||||
* the disparity, on Mac OS X, it will be set inside a static block.
|
||||
*/
|
||||
static public int BUTTON_HEIGHT = 24;
|
||||
|
||||
// indents and spacing standards. these probably need to be modified
|
||||
// per platform as well, since macosx is so huge, windows is smaller,
|
||||
// and linux is all over the map
|
||||
|
||||
static final int GUI_BIG = 13;
|
||||
|
||||
static final int GUI_BETWEEN = 10;
|
||||
|
||||
static final int GUI_SMALL = 6;
|
||||
|
||||
// gui elements
|
||||
|
||||
int wide, high;
|
||||
|
||||
JLabel label;
|
||||
|
||||
JLabel labelBack;
|
||||
|
||||
JButton resetButton;
|
||||
|
||||
JButton closeButton;
|
||||
|
||||
// the calling editor, so updates can be applied
|
||||
|
||||
Editor editor;
|
||||
|
||||
public Schematics(File path) {
|
||||
super("Schematics");
|
||||
|
||||
image = Toolkit.getDefaultToolkit().createImage(path.getAbsolutePath());
|
||||
|
||||
// dialog = new JFrame("Schematics");
|
||||
setResizable(true);
|
||||
// setBackground(Color.white);
|
||||
// dialog.setContentPane(new JLabel(new ImageIcon(image)));
|
||||
|
||||
Container pain = getContentPane();
|
||||
|
||||
pain.setBackground(Color.white);
|
||||
pain.setLayout(null);
|
||||
|
||||
int top = GUI_BIG;
|
||||
int left = GUI_BIG;
|
||||
int right = 0;
|
||||
|
||||
// to override bug on OSX setting the JFrame background color
|
||||
labelBack = new JLabel();
|
||||
|
||||
label = new JLabel(new ImageIcon(image));
|
||||
// System.out.println(label.getPreferredSize());
|
||||
Dimension d = label.getPreferredSize();
|
||||
label.addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
// Base.openFolder(Base.getSettingsFolder());
|
||||
x2 = e.getX();
|
||||
y2 = e.getY();
|
||||
diagramX += x2 - x1;
|
||||
diagramY += y2 - y1;
|
||||
Dimension d = label.getPreferredSize();
|
||||
Dimension d1 = getSize();
|
||||
diagramX = Math.max(d1.width - (d.width + GUI_BIG), diagramX);
|
||||
diagramX = Math.min(GUI_BIG, diagramX);
|
||||
diagramY = Math
|
||||
.max(
|
||||
d1.height
|
||||
- (d.height + GUI_BIG + GUI_BETWEEN + BUTTON_HEIGHT
|
||||
+ GUI_BIG + GUI_BIG), diagramY);
|
||||
diagramY = Math.min(GUI_BIG, diagramY);
|
||||
label.setBounds(diagramX, diagramY, d.width, d.height);
|
||||
// System.out.println("dragging");
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
x1 = e.getX();
|
||||
y1 = e.getY();
|
||||
// System.out.println("pressed at "+x1+" "+y1);
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
pain.add(label);
|
||||
label.setBounds(left, top, d.width, d.height);
|
||||
|
||||
right = Math.max(right, left + d.width);
|
||||
top += d.height; // + GUI_SMALL;
|
||||
|
||||
resetButton = new JButton(PROMPT_RESETVIEW);
|
||||
resetButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
diagramX = GUI_BIG;
|
||||
diagramY = GUI_BIG;
|
||||
Dimension d = label.getPreferredSize();
|
||||
label.setBounds(diagramX, diagramY, d.width, d.height);
|
||||
}
|
||||
});
|
||||
|
||||
pain.add(resetButton);
|
||||
BUTTON_HEIGHT = resetButton.getPreferredSize().height;
|
||||
|
||||
int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
|
||||
resetButton.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
h += BUTTON_WIDTH + GUI_SMALL;
|
||||
|
||||
// h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
|
||||
// h += BUTTON_WIDTH + GUI_SMALL;
|
||||
|
||||
closeButton = new JButton(PROMPT_CLOSE);
|
||||
closeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeFrame();
|
||||
}
|
||||
});
|
||||
pain.add(closeButton);
|
||||
closeButton.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
|
||||
top += BUTTON_HEIGHT + GUI_BETWEEN;
|
||||
|
||||
// finish up
|
||||
|
||||
wide = right + GUI_BIG;
|
||||
high = top + GUI_SMALL;
|
||||
|
||||
// closing the window is same as hitting close button
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
disposeFrame();
|
||||
}
|
||||
});
|
||||
|
||||
ActionListener disposer = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
disposeFrame();
|
||||
}
|
||||
};
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), disposer);
|
||||
if (!Base.isMacOS())
|
||||
Base.setIcon(this);
|
||||
|
||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation((screen.width - wide) / 2, (screen.height - high) / 2);
|
||||
|
||||
pack(); // get insets
|
||||
Insets insets = getInsets();
|
||||
setSize(Math.min(screen.width, wide + insets.left + insets.right), Math
|
||||
.min(screen.height, high + insets.top + insets.bottom));
|
||||
|
||||
labelBack.setOpaque(true);
|
||||
labelBack.setBackground(Color.white);
|
||||
labelBack.setBounds(0, 0, screen.width, screen.height);
|
||||
pain.add(labelBack);
|
||||
|
||||
getContentPane().setBackground(Color.white);
|
||||
// handle window closing commands for ctrl/cmd-W or hitting ESC.
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
public void componentResized(ComponentEvent e) {
|
||||
Dimension d = getSize();
|
||||
int top = d.height - (BUTTON_HEIGHT + GUI_BETWEEN + GUI_BIG + GUI_BIG);
|
||||
int left = GUI_BIG;
|
||||
int right = Math.max(0, d.width - (left + GUI_BIG));
|
||||
int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
|
||||
resetButton.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
h += BUTTON_WIDTH + GUI_SMALL;
|
||||
closeButton.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
}
|
||||
});
|
||||
|
||||
pain.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
// System.out.println(e);
|
||||
KeyStroke wc = Base.WINDOW_CLOSE_KEYSTROKE;
|
||||
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE)
|
||||
|| (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
|
||||
disposeFrame();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(wide, high);
|
||||
}
|
||||
|
||||
// .................................................................
|
||||
|
||||
/**
|
||||
* Close the window after an OK or Cancel.
|
||||
*/
|
||||
protected void disposeFrame() {
|
||||
editor.toolbar.deactivate(EditorToolbar.SCHEMATICS);
|
||||
dispose();
|
||||
}
|
||||
|
||||
protected void applyFrame() {
|
||||
|
||||
}
|
||||
|
||||
protected void showFrame(Editor editor) {
|
||||
this.editor = editor;
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
}
|
@ -1507,6 +1507,7 @@ public class Sketch {
|
||||
throws RunnerException {
|
||||
|
||||
// run the preprocessor
|
||||
editor.status.progressUpdate(20);
|
||||
String primaryClassName = preprocess(buildPath);
|
||||
|
||||
// compile the program. errors will happen as a RunnerException
|
||||
@ -1552,6 +1553,7 @@ public class Sketch {
|
||||
appletFolder.mkdirs();
|
||||
|
||||
// build the sketch
|
||||
editor.status.progressNotice("Compiling sketch...");
|
||||
String foundName = build(appletFolder.getPath(), false);
|
||||
// (already reported) error during export, exit this function
|
||||
if (foundName == null) return false;
|
||||
@ -1565,12 +1567,18 @@ public class Sketch {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
editor.status.progressNotice("Uploading...");
|
||||
upload(appletFolder.getPath(), foundName, usingProgrammer);
|
||||
|
||||
editor.status.progressUpdate(100);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void setCompilingProgress(int percent) {
|
||||
editor.status.progressUpdate(percent);
|
||||
}
|
||||
|
||||
|
||||
protected void size(String buildPath, String suggestedClassName)
|
||||
throws RunnerException {
|
||||
long size = 0;
|
||||
|
@ -111,6 +111,7 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
// 0. include paths for core + all libraries
|
||||
|
||||
sketch.setCompilingProgress(20);
|
||||
List includePaths = new ArrayList();
|
||||
includePaths.add(corePath);
|
||||
if (pinsPath != null) includePaths.add(pinsPath);
|
||||
@ -120,6 +121,7 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
// 1. compile the sketch (already in the buildPath)
|
||||
|
||||
sketch.setCompilingProgress(30);
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(buildPath, "S", false),
|
||||
@ -129,6 +131,7 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||
|
||||
sketch.setCompilingProgress(40);
|
||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||
File utilityFolder = new File(libraryFolder, "utility");
|
||||
@ -156,6 +159,7 @@ public class Compiler implements MessageConsumer {
|
||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||
// collecting them into the core.a library file.
|
||||
|
||||
sketch.setCompilingProgress(50);
|
||||
includePaths.clear();
|
||||
includePaths.add(corePath); // include path for core only
|
||||
if (pinsPath != null) includePaths.add(pinsPath);
|
||||
@ -180,6 +184,7 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
// 4. link it all together into the .elf file
|
||||
|
||||
sketch.setCompilingProgress(60);
|
||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||
avrBasePath + "avr-gcc",
|
||||
"-Os",
|
||||
@ -208,6 +213,7 @@ public class Compiler implements MessageConsumer {
|
||||
List commandObjcopy;
|
||||
|
||||
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
||||
sketch.setCompilingProgress(70);
|
||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||
commandObjcopy.add(2, "ihex");
|
||||
commandObjcopy.set(3, "-j");
|
||||
@ -221,6 +227,7 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(commandObjcopy);
|
||||
|
||||
// 6. build the .hex file
|
||||
sketch.setCompilingProgress(80);
|
||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||
commandObjcopy.add(2, "ihex");
|
||||
commandObjcopy.add(".eeprom"); // remove eeprom data
|
||||
@ -228,6 +235,8 @@ public class Compiler implements MessageConsumer {
|
||||
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex");
|
||||
execAsynchronously(commandObjcopy);
|
||||
|
||||
sketch.setCompilingProgress(90);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
Loading…
x
Reference in New Issue
Block a user