mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
@@ -49,14 +49,7 @@ public class JavaEditor extends Editor {
|
||||
|
||||
// Need to sort through the rest of these additions [fry]
|
||||
|
||||
// TODO these are all null, need to remove color support
|
||||
protected Color breakpointColor;
|
||||
protected Color currentLineColor;
|
||||
protected Color breakpointMarkerColor;
|
||||
protected Color currentLineMarkerColor;
|
||||
|
||||
protected List<LineHighlight> breakpointedLines =
|
||||
new ArrayList<LineHighlight>();
|
||||
protected final List<LineHighlight> breakpointedLines = new ArrayList<>();
|
||||
protected LineHighlight currentLine; // where the debugger is suspended
|
||||
protected final String breakpointMarkerComment = " //<>//";
|
||||
|
||||
@@ -983,7 +976,7 @@ public class JavaEditor extends Editor {
|
||||
Object value = optionPane.getValue();
|
||||
if (value.equals(exportButton)) {
|
||||
return jmode.handleExportApplication(sketch);
|
||||
} else if (value.equals(cancelButton) || value.equals(Integer.valueOf(-1))) {
|
||||
} else if (value.equals(cancelButton) || value.equals(-1)) {
|
||||
// closed window by hitting Cancel or ESC
|
||||
statusNotice(Language.text("export.notice.exporting.cancel"));
|
||||
}
|
||||
@@ -1619,7 +1612,7 @@ public class JavaEditor extends Editor {
|
||||
item = Toolkit.newJMenuItem(Language.text("menu.debug.show_sketch_outline"), KeyEvent.VK_L);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.log("Show Sketch Outline:");
|
||||
Messages.log("Show Sketch Outline:");
|
||||
errorCheckerService.getASTGenerator().showSketchOutline();
|
||||
}
|
||||
});
|
||||
@@ -1628,7 +1621,7 @@ public class JavaEditor extends Editor {
|
||||
item = Toolkit.newJMenuItem(Language.text("menu.debug.show_tabs_list"), KeyEvent.VK_Y);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.log("Show Tab Outline:");
|
||||
Messages.log("Show Tab Outline:");
|
||||
errorCheckerService.getASTGenerator().showTabOutline();
|
||||
}
|
||||
});
|
||||
@@ -1681,7 +1674,7 @@ public class JavaEditor extends Editor {
|
||||
* removed from.
|
||||
*/
|
||||
protected List<LineID> stripBreakpointComments() {
|
||||
List<LineID> bps = new ArrayList<LineID>();
|
||||
List<LineID> bps = new ArrayList<>();
|
||||
// iterate over all tabs
|
||||
Sketch sketch = getSketch();
|
||||
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
||||
@@ -1757,7 +1750,7 @@ public class JavaEditor extends Editor {
|
||||
@Override
|
||||
public boolean handleSave(boolean immediately) {
|
||||
// note modified tabs
|
||||
final List<String> modified = new ArrayList<String>();
|
||||
final List<String> modified = new ArrayList<>();
|
||||
for (int i = 0; i < getSketch().getCodeCount(); i++) {
|
||||
SketchCode tab = getSketch().getCode(i);
|
||||
if (tab.isModified()) {
|
||||
@@ -1915,7 +1908,7 @@ public class JavaEditor extends Editor {
|
||||
PApplet.matchAll(tabCode, ErrorCheckerService.IMPORT_REGEX);
|
||||
|
||||
if (pieces != null) {
|
||||
ArrayList<String> importHeaders = new ArrayList<String>();
|
||||
ArrayList<String> importHeaders = new ArrayList<>();
|
||||
for (String[] importStatement : pieces) {
|
||||
importHeaders.add(importStatement[2]);
|
||||
}
|
||||
@@ -1924,7 +1917,7 @@ public class JavaEditor extends Editor {
|
||||
if (!installLibsHeaders.isEmpty()) {
|
||||
StringBuilder libList = new StringBuilder("Would you like to install them now?");
|
||||
for (AvailableContribution ac : installLibsHeaders) {
|
||||
libList.append("\n • " + ac.getName());
|
||||
libList.append("\n • ").append(ac.getName());
|
||||
}
|
||||
int option = Messages.showYesNoQuestion(this,
|
||||
Language.text("contrib.import.dialog.title"),
|
||||
@@ -1950,7 +1943,7 @@ public class JavaEditor extends Editor {
|
||||
private List<AvailableContribution> getNotInstalledAvailableLibs(ArrayList<String> importHeadersList) {
|
||||
Map<String, Contribution> importMap =
|
||||
ContributionListing.getInstance().getLibrariesByImportHeader();
|
||||
List<AvailableContribution> libList = new ArrayList<AvailableContribution>();
|
||||
List<AvailableContribution> libList = new ArrayList<>();
|
||||
for (String importHeaders : importHeadersList) {
|
||||
int dot = importHeaders.lastIndexOf('.');
|
||||
String entry = (dot == -1) ? importHeaders : importHeaders.substring(0,
|
||||
@@ -2148,7 +2141,7 @@ public class JavaEditor extends Editor {
|
||||
|
||||
for (Component item : debugMenu.getMenuComponents()) {
|
||||
if (item instanceof JMenuItem && item != debugItem) {
|
||||
((JMenuItem) item).setEnabled(debugEnabled);
|
||||
item.setEnabled(debugEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2213,8 +2206,8 @@ public class JavaEditor extends Editor {
|
||||
// scroll to line, by setting the cursor
|
||||
cursorToLineStart(line.lineIdx());
|
||||
// highlight line
|
||||
currentLine = new LineHighlight(line.lineIdx(), currentLineColor, this);
|
||||
currentLine.setMarker(JavaTextArea.STEP_MARKER, currentLineMarkerColor);
|
||||
currentLine = new LineHighlight(line.lineIdx(), this);
|
||||
currentLine.setMarker(JavaTextArea.STEP_MARKER);
|
||||
currentLine.setPriority(10); // fixes current line being hidden by the breakpoint when moved down
|
||||
}
|
||||
|
||||
@@ -2242,8 +2235,8 @@ public class JavaEditor extends Editor {
|
||||
* @param lineID the line id to highlight as breakpointed
|
||||
*/
|
||||
public void addBreakpointedLine(LineID lineID) {
|
||||
LineHighlight hl = new LineHighlight(lineID, breakpointColor, this);
|
||||
hl.setMarker(JavaTextArea.BREAK_MARKER, breakpointMarkerColor);
|
||||
LineHighlight hl = new LineHighlight(lineID, this);
|
||||
hl.setMarker(JavaTextArea.BREAK_MARKER);
|
||||
breakpointedLines.add(hl);
|
||||
// repaint current line if it's on this line
|
||||
if (currentLine != null && currentLine.getLineID().equals(lineID)) {
|
||||
@@ -2252,17 +2245,6 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add highlight for a breakpointed line on the current tab.
|
||||
* @param lineIdx the line index on the current tab to highlight as
|
||||
* breakpointed
|
||||
*/
|
||||
//TODO: remove and replace by {@link #addBreakpointedLine(LineID lineID)}
|
||||
public void addBreakpointedLine(int lineIdx) {
|
||||
addBreakpointedLine(getLineIDInCurrentTab(lineIdx));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a highlight for a breakpointed line. Needs to be on the current tab.
|
||||
* @param lineIdx the line index on the current tab to remove a breakpoint
|
||||
@@ -2299,7 +2281,6 @@ public class JavaEditor extends Editor {
|
||||
breakpointedLines.clear(); // remove all breakpoints
|
||||
// fix highlights not being removed when tab names have
|
||||
// changed due to opening a new sketch in same editor
|
||||
getJavaTextArea().clearLineBgColors(); // force clear all highlights
|
||||
getJavaTextArea().clearGutterText();
|
||||
|
||||
// repaint current line
|
||||
@@ -2364,11 +2345,8 @@ public class JavaEditor extends Editor {
|
||||
final JavaTextArea ta = getJavaTextArea();
|
||||
// can be null when setCode is called the first time (in constructor)
|
||||
if (ta != null) {
|
||||
// clear all line backgrounds
|
||||
ta.clearLineBgColors();
|
||||
// clear all gutter text
|
||||
ta.clearGutterText();
|
||||
// load appropriate line backgrounds for tab
|
||||
// first paint breakpoints
|
||||
if (breakpointedLines != null) {
|
||||
for (LineHighlight hl : breakpointedLines) {
|
||||
@@ -2618,7 +2596,7 @@ public class JavaEditor extends Editor {
|
||||
// frmImportSuggest = null;
|
||||
return;
|
||||
}
|
||||
final JList<String> classList = new JList<String>(list);
|
||||
final JList<String> classList = new JList<>(list);
|
||||
classList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
frmImportSuggest = new JFrame();
|
||||
|
||||
@@ -2876,7 +2854,7 @@ public class JavaEditor extends Editor {
|
||||
|
||||
baseCode = new String[code.length];
|
||||
for (int i = 0; i < code.length; i++) {
|
||||
baseCode[i] = new String(code[i].getSavedProgram());
|
||||
baseCode[i] = code[i].getSavedProgram();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@@ -20,7 +20,6 @@ along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
|
||||
package processing.mode.java.debug;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,25 +34,21 @@ import processing.mode.java.JavaEditor;
|
||||
*/
|
||||
public class LineHighlight {
|
||||
|
||||
protected JavaEditor editor; // the view, used for highlighting lines by setting a background color
|
||||
protected Color bgColor; // the background color for highlighting lines
|
||||
protected LineID lineID; // the id of the line
|
||||
protected final JavaEditor editor; // the view, used for highlighting lines by setting a background color
|
||||
protected final LineID lineID; // the id of the line
|
||||
protected String marker; //
|
||||
protected Color markerColor;
|
||||
protected int priority = 0;
|
||||
protected static Set<LineHighlight> allHighlights = new HashSet<LineHighlight>();
|
||||
protected static final Set<LineHighlight> allHighlights = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@link LineHighlight}.
|
||||
*
|
||||
* @param lineID the line id to highlight
|
||||
* @param bgColor the background color used for highlighting
|
||||
* @param editor the {@link JavaEditor}
|
||||
*/
|
||||
public LineHighlight(LineID lineID, Color bgColor, JavaEditor editor) {
|
||||
public LineHighlight(LineID lineID, JavaEditor editor) {
|
||||
this.lineID = lineID;
|
||||
this.bgColor = bgColor;
|
||||
this.editor = editor;
|
||||
lineID.addListener(this);
|
||||
lineID.startTracking(editor.getTab(lineID.fileName()).getDocument()); // TODO: overwrite a previous doc?
|
||||
@@ -87,12 +82,11 @@ public class LineHighlight {
|
||||
* Create a {@link LineHighlight} on the current tab.
|
||||
*
|
||||
* @param lineIdx the line index on the current tab to highlight
|
||||
* @param bgColor the background color used for highlighting
|
||||
* @param editor the {@link JavaEditor}
|
||||
*/
|
||||
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, Color bgColor, JavaEditor editor)}
|
||||
public LineHighlight(int lineIdx, Color bgColor, JavaEditor editor) {
|
||||
this(editor.getLineIDInCurrentTab(lineIdx), bgColor, editor);
|
||||
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, JavaEditor editor)}
|
||||
public LineHighlight(int lineIdx, JavaEditor editor) {
|
||||
this(editor.getLineIDInCurrentTab(lineIdx), editor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,18 +100,6 @@ public class LineHighlight {
|
||||
paint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a text based marker displayed in the left hand gutter area of this
|
||||
* highlighted line. Also use a custom text color.
|
||||
*
|
||||
* @param marker the marker text
|
||||
* @param markerColor the text color
|
||||
*/
|
||||
public void setMarker(String marker, Color markerColor) {
|
||||
this.markerColor = markerColor;
|
||||
setMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the line id of this {@link LineHighlight}.
|
||||
*
|
||||
@@ -127,15 +109,6 @@ public class LineHighlight {
|
||||
return lineID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the color for highlighting this line.
|
||||
*
|
||||
* @return the highlight color.
|
||||
*/
|
||||
public Color getColor() {
|
||||
return bgColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this highlight is on a certain line.
|
||||
*
|
||||
@@ -157,7 +130,6 @@ public class LineHighlight {
|
||||
public void lineChanged(LineID line, int oldLineIdx, int newLineIdx) {
|
||||
// clear old line
|
||||
if (editor.isInCurrentTab(new LineID(line.fileName(), oldLineIdx))) {
|
||||
editor.getJavaTextArea().clearLineBgColor(oldLineIdx);
|
||||
editor.getJavaTextArea().clearGutterText(oldLineIdx);
|
||||
}
|
||||
|
||||
@@ -184,13 +156,8 @@ public class LineHighlight {
|
||||
*/
|
||||
public void paint() {
|
||||
if (editor.isInCurrentTab(lineID)) {
|
||||
editor.getJavaTextArea().setLineBgColor(lineID.lineIdx(), bgColor);
|
||||
if (marker != null) {
|
||||
if (markerColor != null) {
|
||||
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker, markerColor);
|
||||
} else {
|
||||
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker);
|
||||
}
|
||||
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +167,6 @@ public class LineHighlight {
|
||||
*/
|
||||
public void clear() {
|
||||
if (editor.isInCurrentTab(lineID)) {
|
||||
editor.getJavaTextArea().clearLineBgColor(lineID.lineIdx());
|
||||
editor.getJavaTextArea().clearGutterText(lineID.lineIdx());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
@@ -119,7 +118,7 @@ import com.google.classpath.RegExpResourceFilter;
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public class ASTGenerator {
|
||||
protected final ErrorCheckerService errorCheckerService;
|
||||
protected JavaEditor editor;
|
||||
protected final JavaEditor editor;
|
||||
public DefaultMutableTreeNode codeTree = new DefaultMutableTreeNode();
|
||||
|
||||
protected JFrame frmASTView;
|
||||
@@ -139,9 +138,9 @@ public class ASTGenerator {
|
||||
protected JLabel lblRefactorOldName;
|
||||
|
||||
|
||||
public ASTGenerator(ErrorCheckerService ecs) {
|
||||
public ASTGenerator(JavaEditor editor, ErrorCheckerService ecs) {
|
||||
this.editor = editor;
|
||||
this.errorCheckerService = ecs;
|
||||
this.editor = ecs.getEditor();
|
||||
setupGUI();
|
||||
//addCompletionPopupListner();
|
||||
addListeners();
|
||||
@@ -233,19 +232,12 @@ public class ASTGenerator {
|
||||
Messages.loge("No CU found!");
|
||||
}
|
||||
visitRecur((ASTNode) compilationUnit.types().get(0), codeTree);
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (codeTree != null) {
|
||||
if(SHOW_AST){
|
||||
if (jtree.hasFocus() || frmASTView.hasFocus())
|
||||
return;
|
||||
if (SHOW_AST) {
|
||||
if (jtree.hasFocus() || frmASTView.hasFocus())
|
||||
return;
|
||||
jtree.setModel(new DefaultTreeModel(codeTree));
|
||||
((DefaultTreeModel) jtree.getModel()).reload();
|
||||
jtree.validate();
|
||||
@@ -271,8 +263,7 @@ public class ASTGenerator {
|
||||
// }
|
||||
}
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
});
|
||||
// Base.loge("++>" + System.getProperty("java.class.path"));
|
||||
// log(System.getProperty("java.class.path"));
|
||||
// log("-------------------------------");
|
||||
@@ -809,7 +800,6 @@ public class ASTGenerator {
|
||||
*/
|
||||
public List<CompletionCandidate> preparePredictions(final String pdePhrase,
|
||||
final int line) {
|
||||
ErrorCheckerService errorCheckerService = editor.getErrorChecker();
|
||||
ASTNode astRootNode = (ASTNode) errorCheckerService.getLatestCU().types().get(0);
|
||||
|
||||
// If the parsed code contains pde enhancements, take 'em out.
|
||||
@@ -1650,7 +1640,6 @@ public class ASTGenerator {
|
||||
int pdeLineNumber = lineNumber + errorCheckerService.mainClassOffset;
|
||||
// log("----getASTNodeAt---- CU State: "
|
||||
// + errorCheckerService.compilationUnitState);
|
||||
editor = errorCheckerService.getEditor();
|
||||
int codeIndex = editor.getSketch().getCodeIndex(editor.getCurrentTab());
|
||||
if (codeIndex > 0) {
|
||||
for (int i = 0; i < codeIndex; i++) {
|
||||
@@ -1871,79 +1860,55 @@ public class ASTGenerator {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
Messages.log(e.toString());
|
||||
|
||||
// TODO: this should already run on EDT so why the SwingWorker?
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
if(jtree.getLastSelectedPathComponent() == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode =
|
||||
(DefaultMutableTreeNode) jtree.getLastSelectedPathComponent();
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
awrap.highlightNode(editor);
|
||||
// errorCheckerService.highlightNode(awrap);
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
if(jtree
|
||||
.getLastSelectedPathComponent() == null){
|
||||
//--
|
||||
try {
|
||||
int javaLineNumber = getLineNumber(awrap.getNode());
|
||||
int pdeOffs[] = errorCheckerService
|
||||
.calculateTabIndexAndLineNumber(javaLineNumber);
|
||||
PlainDocument javaSource = new PlainDocument();
|
||||
javaSource.insertString(0, errorCheckerService.lastCodeCheckResult.sourceCode, null);
|
||||
Element lineElement = javaSource.getDefaultRootElement()
|
||||
.getElement(javaLineNumber-1);
|
||||
if(lineElement == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) jtree
|
||||
.getLastSelectedPathComponent();
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
awrap.highlightNode(editor);
|
||||
// errorCheckerService.highlightNode(awrap);
|
||||
|
||||
//--
|
||||
try {
|
||||
int javaLineNumber = getLineNumber(awrap.getNode());
|
||||
int pdeOffs[] = errorCheckerService
|
||||
.calculateTabIndexAndLineNumber(javaLineNumber);
|
||||
PlainDocument javaSource = new PlainDocument();
|
||||
javaSource.insertString(0, errorCheckerService.lastCodeCheckResult.sourceCode, null);
|
||||
Element lineElement = javaSource.getDefaultRootElement()
|
||||
.getElement(javaLineNumber-1);
|
||||
if(lineElement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String javaLine = javaSource.getText(lineElement.getStartOffset(),
|
||||
lineElement.getEndOffset()
|
||||
- lineElement.getStartOffset());
|
||||
editor.getSketch().setCurrentCode(pdeOffs[0]);
|
||||
String pdeLine = editor.getLineText(pdeOffs[1]);
|
||||
//String lookingFor = nodeName.toString();
|
||||
//log(lookingFor + ", " + nodeName.getStartPosition());
|
||||
log("JL " + javaLine + " LSO " + lineElement.getStartOffset() + ","
|
||||
+ lineElement.getEndOffset());
|
||||
log("PL " + pdeLine);
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String javaLine = javaSource.getText(lineElement.getStartOffset(),
|
||||
lineElement.getEndOffset()
|
||||
- lineElement.getStartOffset());
|
||||
editor.getSketch().setCurrentCode(pdeOffs[0]);
|
||||
String pdeLine = editor.getLineText(pdeOffs[1]);
|
||||
//String lookingFor = nodeName.toString();
|
||||
//log(lookingFor + ", " + nodeName.getStartPosition());
|
||||
log("JL " + javaLine + " LSO " + lineElement.getStartOffset() + ","
|
||||
+ lineElement.getEndOffset());
|
||||
log("PL " + pdeLine);
|
||||
} catch (BadLocationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
btnRename.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(txtRenameField.getText().length() == 0)
|
||||
if(txtRenameField.getText().length() == 0) {
|
||||
return;
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
refactorIt();
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
}
|
||||
refactorIt();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1951,19 +1916,7 @@ public class ASTGenerator {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
handleShowUsage();
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
handleShowUsage();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1972,30 +1925,18 @@ public class ASTGenerator {
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
log(e);
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
if(refactorTree
|
||||
.getLastSelectedPathComponent() == null){
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) refactorTree
|
||||
.getLastSelectedPathComponent();
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
if(refactorTree
|
||||
.getLastSelectedPathComponent() == null){
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) refactorTree
|
||||
.getLastSelectedPathComponent();
|
||||
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
//errorCheckerService.highlightNode(awrap);
|
||||
awrap.highlightNode(editor);
|
||||
}
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
//errorCheckerService.highlightNode(awrap);
|
||||
awrap.highlightNode(editor);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2349,15 +2290,15 @@ public class ASTGenerator {
|
||||
public void showSketchOutline() {
|
||||
if (editor.hasJavaTabs()) return;
|
||||
|
||||
sketchOutline = new SketchOutline(codeTree, errorCheckerService);
|
||||
sketchOutline = new SketchOutline(editor, codeTree);
|
||||
sketchOutline.show();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void showTabOutline() {
|
||||
new TabOutline(errorCheckerService).show();
|
||||
new TabOutline(editor).show();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public int javaCodeOffsetToLineStartOffset(int line, int jOffset){
|
||||
|
||||
@@ -159,10 +159,7 @@ public class CompletionPanel {
|
||||
popupMenu.add(scrollPane, BorderLayout.CENTER);
|
||||
popupMenu.setPopupSize(calcWidth(), calcHeight(items.getSize())); //TODO: Eradicate this evil
|
||||
popupMenu.setFocusable(false);
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
// TODO: Update JavaDoc to completionList.getSelectedValue()
|
||||
popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y);
|
||||
//log("Suggestion shown: " + System.currentTimeMillis());
|
||||
}
|
||||
@@ -517,10 +514,7 @@ public class CompletionPanel {
|
||||
.getVerticalScrollBar()
|
||||
.getValue()
|
||||
- step);
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
// TODO: update JavaDoc to completionList.getSelectedValue()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,10 +531,7 @@ public class CompletionPanel {
|
||||
int index = Math.min(completionList.getSelectedIndex() + 1,
|
||||
completionList.getModel().getSize() - 1);
|
||||
selectIndex(index);
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
// TODO: update JavaDoc to completionList.getSelectedValue()
|
||||
int step = scrollPane.getVerticalScrollBar().getMaximum() / completionList.getModel().getSize();
|
||||
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue() + step);
|
||||
}
|
||||
|
||||
@@ -176,10 +176,11 @@ public class ErrorCheckerService {
|
||||
public static final String IMPORT_REGEX =
|
||||
"(?:^|;)\\s*(import\\s+)((?:static\\s+)?\\S+)(\\s*;)";
|
||||
|
||||
public ErrorCheckerService(JavaEditor debugEditor) {
|
||||
this.editor = debugEditor;
|
||||
xqpreproc = new XQPreprocessor(this);
|
||||
astGenerator = new ASTGenerator(this);
|
||||
|
||||
public ErrorCheckerService(JavaEditor editor) {
|
||||
this.editor = editor;
|
||||
xqpreproc = new XQPreprocessor(editor);
|
||||
astGenerator = new ASTGenerator(editor, this);
|
||||
loadCompClass = true;
|
||||
}
|
||||
|
||||
@@ -318,7 +319,7 @@ public class ErrorCheckerService {
|
||||
|
||||
|
||||
public void addListener(Document doc) {
|
||||
doc.addDocumentListener(sketchChangedListener);
|
||||
if (doc != null) doc.addDocumentListener(sketchChangedListener);
|
||||
}
|
||||
|
||||
|
||||
@@ -1516,10 +1517,6 @@ public class ErrorCheckerService {
|
||||
}
|
||||
|
||||
|
||||
public JavaEditor getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
public ArrayList<ImportStatement> getProgramImports() {
|
||||
return programImports;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import processing.app.Messages;
|
||||
import processing.app.Mode;
|
||||
import processing.app.Platform;
|
||||
import processing.app.syntax.JEditTextArea;
|
||||
import processing.app.syntax.PdeTextAreaDefaults;
|
||||
import processing.app.syntax.TextAreaDefaults;
|
||||
import processing.app.ui.Editor;
|
||||
|
||||
@@ -57,20 +56,9 @@ import processing.app.ui.Editor;
|
||||
// changes into JEditTextArea (or a subclass in processing.app)
|
||||
|
||||
public class JavaTextArea extends JEditTextArea {
|
||||
protected PdeTextAreaDefaults defaults;
|
||||
protected JavaEditor editor;
|
||||
protected final JavaEditor editor;
|
||||
|
||||
// cached mouselisteners, these are wrapped by MouseHandler
|
||||
protected MouseListener[] mouseListeners;
|
||||
|
||||
// contains line background colors
|
||||
protected Map<Integer, Color> lineColors = new HashMap<Integer, Color>();
|
||||
|
||||
// [px] space added to the left and right of gutter chars
|
||||
protected int gutterPadding; // = 3;
|
||||
protected Image gutterGradient;
|
||||
// protected Color gutterBgColor; // = new Color(252, 252, 252); // gutter background color
|
||||
protected Color gutterLineColor; // = new Color(233, 233, 233); // color of vertical separation line
|
||||
|
||||
/// the text marker for highlighting breakpoints in the gutter
|
||||
static public final String BREAK_MARKER = "<>";
|
||||
@@ -78,12 +66,8 @@ public class JavaTextArea extends JEditTextArea {
|
||||
static public final String STEP_MARKER = "->";
|
||||
|
||||
/// maps line index to gutter text
|
||||
protected Map<Integer, String> gutterText = new HashMap<Integer, String>();
|
||||
protected final Map<Integer, String> gutterText = new HashMap<>();
|
||||
|
||||
/// maps line index to gutter text color
|
||||
protected Map<Integer, Color> gutterTextColors = new HashMap<Integer, Color>();
|
||||
|
||||
// protected ErrorCheckerService errorCheckerService;
|
||||
private CompletionPanel suggestion;
|
||||
|
||||
|
||||
@@ -91,46 +75,18 @@ public class JavaTextArea extends JEditTextArea {
|
||||
super(defaults, new JavaInputHandler(editor));
|
||||
this.editor = editor;
|
||||
|
||||
// removed all this since we have the createPainter() method and we
|
||||
// won't have to remove/re-add the custom painter object [fry 150122]
|
||||
// although there's also something bad happening here, that we're
|
||||
// re-forwarding all those events to all the other listeners?
|
||||
// that's making a hacky mess, plus the tweak code is also doing
|
||||
// something similar? [fry 150512]
|
||||
// handle right click on a word
|
||||
painter.addMouseListener(rightClickMouseAdapter);
|
||||
|
||||
// // replace the painter:
|
||||
// // first save listeners, these are package-private in JEditTextArea, so not accessible
|
||||
// ComponentListener[] componentListeners = painter.getComponentListeners();
|
||||
mouseListeners = painter.getMouseListeners();
|
||||
// MouseMotionListener[] mouseMotionListeners = painter.getMouseMotionListeners();
|
||||
//
|
||||
// remove(painter);
|
||||
// // set new painter
|
||||
// customPainter = new TextAreaPainter(this, defaults);
|
||||
// painter = customPainter;
|
||||
//
|
||||
// // set listeners
|
||||
// for (ComponentListener cl : componentListeners) {
|
||||
// painter.addComponentListener(cl);
|
||||
// }
|
||||
//
|
||||
// for (MouseMotionListener mml : mouseMotionListeners) {
|
||||
// painter.addMouseMotionListener(mml);
|
||||
// }
|
||||
// change cursor to pointer in the gutter area
|
||||
painter.addMouseMotionListener(gutterCursorMouseAdapter);
|
||||
|
||||
// use a custom mouse handler instead of directly using mouseListeners
|
||||
MouseHandler mouseHandler = new MouseHandler();
|
||||
painter.addMouseListener(mouseHandler);
|
||||
painter.addMouseMotionListener(mouseHandler);
|
||||
//addCompletionPopupListner();
|
||||
add(CENTER, painter);
|
||||
|
||||
// load settings from theme.txt
|
||||
Mode mode = editor.getMode();
|
||||
gutterGradient = mode.makeGradient("editor", Editor.LEFT_GUTTER, 500);
|
||||
//gutterBgColor = mode.getColor("editor.gutter.bgcolor");
|
||||
gutterLineColor = mode.getColor("editor.gutter.linecolor");
|
||||
gutterPadding = mode.getInteger("editor.gutter.padding");
|
||||
|
||||
// TweakMode code
|
||||
prevCompListeners = painter.getComponentListeners();
|
||||
@@ -139,10 +95,10 @@ public class JavaTextArea extends JEditTextArea {
|
||||
prevKeyListeners = editor.getKeyListeners();
|
||||
|
||||
tweakMode = false;
|
||||
addPrevListeners();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected JavaTextAreaPainter createPainter(final TextAreaDefaults defaults) {
|
||||
return new JavaTextAreaPainter(this, defaults);
|
||||
}
|
||||
@@ -161,6 +117,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
/**
|
||||
* Handles KeyEvents for TextArea (code completion begins from here).
|
||||
*/
|
||||
@Override
|
||||
public void processKeyEvent(KeyEvent evt) {
|
||||
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
if (suggestion != null){
|
||||
@@ -373,9 +330,6 @@ public class JavaTextArea extends JEditTextArea {
|
||||
|
||||
SwingWorker<Void, Void> suggestionWorker = null;
|
||||
|
||||
int lastCaretPosition = 0;
|
||||
String lastPhrase = "";
|
||||
|
||||
volatile boolean suggestionRunning = false;
|
||||
volatile boolean suggestionRequested = false;
|
||||
|
||||
@@ -446,7 +400,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
Messages.log("phrase: " + phrase);
|
||||
if (phrase == null) return null;
|
||||
|
||||
List<CompletionCandidate> candidates = null;
|
||||
List<CompletionCandidate> candidates;
|
||||
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
@@ -687,22 +641,6 @@ public class JavaTextArea extends JEditTextArea {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the gutter text and color of a specific line.
|
||||
*
|
||||
* @param lineIdx
|
||||
* the line index (0-based)
|
||||
* @param text
|
||||
* the text
|
||||
* @param textColor
|
||||
* the text color
|
||||
*/
|
||||
public void setGutterText(int lineIdx, String text, Color textColor) {
|
||||
gutterTextColors.put(lineIdx, textColor);
|
||||
setGutterText(lineIdx, text);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the gutter text of a specific line.
|
||||
*
|
||||
@@ -738,67 +676,6 @@ public class JavaTextArea extends JEditTextArea {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the gutter text color for a specific line.
|
||||
*
|
||||
* @param lineIdx
|
||||
* the line index
|
||||
* @return the gutter text color
|
||||
*/
|
||||
public Color getGutterTextColor(int lineIdx) {
|
||||
return gutterTextColors.get(lineIdx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the background color of a line.
|
||||
*
|
||||
* @param lineIdx
|
||||
* 0-based line number
|
||||
* @param col
|
||||
* the background color to set
|
||||
*/
|
||||
public void setLineBgColor(int lineIdx, Color col) {
|
||||
lineColors.put(lineIdx, col);
|
||||
painter.invalidateLine(lineIdx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the background color of a line.
|
||||
*
|
||||
* @param lineIdx
|
||||
* 0-based line number
|
||||
*/
|
||||
public void clearLineBgColor(int lineIdx) {
|
||||
lineColors.remove(lineIdx);
|
||||
painter.invalidateLine(lineIdx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all line background colors.
|
||||
*/
|
||||
public void clearLineBgColors() {
|
||||
for (int lineIdx : lineColors.keySet()) {
|
||||
painter.invalidateLine(lineIdx);
|
||||
}
|
||||
lineColors.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a lines background color.
|
||||
*
|
||||
* @param lineIdx
|
||||
* 0-based line number
|
||||
* @return the color or null if no color was set for the specified line
|
||||
*/
|
||||
public Color getLineBgColor(int lineIdx) {
|
||||
return lineColors.get(lineIdx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a character offset to a horizontal pixel position inside the text
|
||||
* area. Overridden to take gutter width into account.
|
||||
@@ -832,90 +709,27 @@ public class JavaTextArea extends JEditTextArea {
|
||||
|
||||
|
||||
/**
|
||||
* Custom mouse handler. Implements double clicking in the gutter area to
|
||||
* toggle breakpoints, sets default cursor (instead of text cursor) in the
|
||||
* gutter area.
|
||||
* Fetches word under the cursor on right click
|
||||
*/
|
||||
protected class MouseHandler implements MouseListener, MouseMotionListener {
|
||||
protected int lastX; // previous horizontal positon of the mouse cursor
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent me) {
|
||||
// forward to standard listeners
|
||||
for (MouseListener ml : mouseListeners) {
|
||||
ml.mouseClicked(me);
|
||||
}
|
||||
}
|
||||
|
||||
protected final MouseAdapter rightClickMouseAdapter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent me) {
|
||||
// // check if this happened in the gutter area
|
||||
// if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
// if (me.getButton() == MouseEvent.BUTTON1) { // && me.getClickCount() == 2) {
|
||||
// //int line = me.getY() / painter.getFontMetrics().getHeight() + firstLine;
|
||||
// int offset = xyToOffset(me.getX(), me.getY());
|
||||
// if (offset >= 0) {
|
||||
// int lineIndex = getLineOfOffset(offset);
|
||||
// editor.toggleBreakpoint(lineIndex);
|
||||
// }
|
||||
//// if (line >= 0 && line < getLineCount()) {
|
||||
//// //editor.gutterDblClicked(line);
|
||||
//// editor.toggleBreakpoint(line);
|
||||
//// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (me.getButton() == MouseEvent.BUTTON3) {
|
||||
if (!editor.hasJavaTabs()) { // tooltips, etc disabled for java tabs
|
||||
fetchPhrase(me);
|
||||
}
|
||||
}
|
||||
|
||||
// forward to standard listeners
|
||||
for (MouseListener ml : mouseListeners) {
|
||||
ml.mousePressed(me);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
// forward to standard listeners
|
||||
for (MouseListener ml : mouseListeners) {
|
||||
ml.mouseReleased(me);
|
||||
if (me.getButton() == MouseEvent.BUTTON3 &&
|
||||
!editor.hasJavaTabs()) { // tooltips, etc disabled for java tabs
|
||||
fetchPhrase(me);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
// forward to standard listeners
|
||||
for (MouseListener ml : mouseListeners) {
|
||||
// investigating an NPE that keeps showing up here [fry]
|
||||
// if (ml == null || me == null) {
|
||||
// System.out.println(ml + " " + me);
|
||||
// }
|
||||
ml.mouseEntered(me);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent me) {
|
||||
// forward to standard listeners
|
||||
for (MouseListener ml : mouseListeners) {
|
||||
ml.mouseExited(me);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent me) {
|
||||
// No need to forward since the standard MouseMotionListeners are called anyway
|
||||
// nop
|
||||
}
|
||||
/**
|
||||
* Sets default cursor (instead of text cursor) in the gutter area.
|
||||
*/
|
||||
protected final MouseMotionAdapter gutterCursorMouseAdapter = new MouseMotionAdapter() {
|
||||
private int lastX; // previous horizontal positon of the mouse cursor
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent me) {
|
||||
// No need to forward since the standard MouseMotionListeners are called anyway
|
||||
if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
if (lastX >= Editor.LEFT_GUTTER) {
|
||||
painter.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
@@ -927,7 +741,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
}
|
||||
lastX = me.getX();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// appears unused, removed when looking to change completion trigger [fry 140801]
|
||||
@@ -994,11 +808,11 @@ public class JavaTextArea extends JEditTextArea {
|
||||
|
||||
|
||||
// save input listeners to stop/start text edit
|
||||
ComponentListener[] prevCompListeners;
|
||||
MouseListener[] prevMouseListeners;
|
||||
MouseMotionListener[] prevMMotionListeners;
|
||||
KeyListener[] prevKeyListeners;
|
||||
boolean tweakMode;
|
||||
protected final ComponentListener[] prevCompListeners;
|
||||
protected final MouseListener[] prevMouseListeners;
|
||||
protected final MouseMotionListener[] prevMMotionListeners;
|
||||
protected final KeyListener[] prevKeyListeners;
|
||||
protected boolean tweakMode;
|
||||
|
||||
|
||||
/* remove all standard interaction listeners */
|
||||
@@ -1050,11 +864,6 @@ public class JavaTextArea extends JEditTextArea {
|
||||
}
|
||||
|
||||
|
||||
public int getHorizontalScroll() {
|
||||
return horizontal.getValue();
|
||||
}
|
||||
|
||||
|
||||
private void addPrevListeners() {
|
||||
// add the original text-edit listeners
|
||||
for (ComponentListener cl : prevCompListeners) {
|
||||
|
||||
@@ -61,21 +61,20 @@ import processing.mode.java.JavaEditor;
|
||||
|
||||
|
||||
public class SketchOutline {
|
||||
protected final JavaEditor editor;
|
||||
|
||||
protected JFrame frmOutlineView;
|
||||
protected ErrorCheckerService errorCheckerService;
|
||||
protected JScrollPane jsp;
|
||||
protected DefaultMutableTreeNode soNode, tempNode;
|
||||
protected final JTree soTree;
|
||||
protected JTextField searchField;
|
||||
protected JavaEditor editor;
|
||||
protected boolean internalSelection = false;
|
||||
|
||||
ImageIcon classIcon, fieldIcon, methodIcon;
|
||||
|
||||
|
||||
public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) {
|
||||
errorCheckerService = ecs;
|
||||
editor = ecs.getEditor();
|
||||
public SketchOutline(JavaEditor editor, DefaultMutableTreeNode codeTree) {
|
||||
this.editor = editor;
|
||||
soNode = new DefaultMutableTreeNode();
|
||||
generateSketchOutlineTree(soNode, codeTree);
|
||||
soNode = (DefaultMutableTreeNode) soNode.getChildAt(0);
|
||||
@@ -95,7 +94,7 @@ public class SketchOutline {
|
||||
frmOutlineView = new JFrame();
|
||||
frmOutlineView.setAlwaysOnTop(true);
|
||||
frmOutlineView.setUndecorated(true);
|
||||
Point tp = errorCheckerService.getEditor().getTextArea().getLocationOnScreen();
|
||||
Point tp = editor.getTextArea().getLocationOnScreen();
|
||||
|
||||
int minWidth = (int) (editor.getMinimumSize().width * 0.7f);
|
||||
int maxWidth = (int) (editor.getMinimumSize().width * 0.9f);
|
||||
@@ -130,10 +129,10 @@ public class SketchOutline {
|
||||
frmOutlineView.add(panelBottom);
|
||||
frmOutlineView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frmOutlineView.pack();
|
||||
frmOutlineView.setBounds(tp.x + errorCheckerService.getEditor().getTextArea().getWidth() - minWidth, tp.y, minWidth,
|
||||
frmOutlineView.setBounds(tp.x + editor.getTextArea().getWidth() - minWidth, tp.y, minWidth,
|
||||
Math.min(editor.getTextArea().getHeight(), frmOutlineView.getHeight()));
|
||||
frmOutlineView.setMinimumSize(new Dimension(minWidth, Math.min(errorCheckerService.getEditor().getTextArea().getHeight(), frmOutlineView.getHeight())));
|
||||
frmOutlineView.setLocation(tp.x + errorCheckerService.getEditor().getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2,
|
||||
frmOutlineView.setMinimumSize(new Dimension(minWidth, Math.min(editor.getTextArea().getHeight(), frmOutlineView.getHeight())));
|
||||
frmOutlineView.setLocation(tp.x + editor.getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2,
|
||||
frmOutlineView.getY() + (editor.getTextArea().getHeight() - frmOutlineView.getHeight()) / 2);
|
||||
addListeners();
|
||||
}
|
||||
@@ -221,7 +220,7 @@ public class SketchOutline {
|
||||
protected Object doInBackground() throws Exception {
|
||||
String text = searchField.getText().toLowerCase();
|
||||
tempNode = new DefaultMutableTreeNode();
|
||||
filterTree(text, tempNode, soNode);
|
||||
filterTree(text, tempNode, soNode); // TODO: is using soNode thread-safe? [jv]
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -270,28 +269,19 @@ public class SketchOutline {
|
||||
|
||||
|
||||
private void scrollToNode() {
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
if (soTree.getLastSelectedPathComponent() == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) soTree
|
||||
.getLastSelectedPathComponent();
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
awrap.highlightNode(editor);
|
||||
// log(awrap);
|
||||
//errorCheckerService.highlightNode(awrap);
|
||||
close();
|
||||
}
|
||||
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
if (soTree.getLastSelectedPathComponent() == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) soTree
|
||||
.getLastSelectedPathComponent();
|
||||
if (tnode.getUserObject() instanceof ASTNodeWrapper) {
|
||||
ASTNodeWrapper awrap = (ASTNodeWrapper) tnode.getUserObject();
|
||||
awrap.highlightNode(editor);
|
||||
// log(awrap);
|
||||
//errorCheckerService.highlightNode(awrap);
|
||||
close();
|
||||
}
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,13 +63,11 @@ public class TabOutline {
|
||||
protected JTextField searchField;
|
||||
protected JLabel lblCaption;
|
||||
protected JavaEditor editor;
|
||||
protected ErrorCheckerService errorCheckerService;
|
||||
protected boolean internalSelection = false;
|
||||
|
||||
|
||||
public TabOutline(ErrorCheckerService ecs) {
|
||||
errorCheckerService = ecs;
|
||||
editor = ecs.getEditor();
|
||||
public TabOutline(JavaEditor editor) {
|
||||
this.editor = editor;
|
||||
createGUI();
|
||||
}
|
||||
|
||||
@@ -78,7 +76,7 @@ public class TabOutline {
|
||||
frmOutlineView = new JFrame();
|
||||
frmOutlineView.setAlwaysOnTop(true);
|
||||
frmOutlineView.setUndecorated(true);
|
||||
Point tp = errorCheckerService.getEditor().getTextArea().getLocationOnScreen();
|
||||
Point tp = editor.getTextArea().getLocationOnScreen();
|
||||
lblCaption = new JLabel("Tabs List (type to filter)");
|
||||
int minWidth = estimateFrameWidth();
|
||||
int maxWidth = (int) (editor.getMinimumSize().width * 0.9f);
|
||||
@@ -108,14 +106,14 @@ public class TabOutline {
|
||||
frmOutlineView.add(panelBottom);
|
||||
frmOutlineView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frmOutlineView.pack();
|
||||
frmOutlineView.setBounds(tp.x + errorCheckerService.getEditor().getTextArea().getWidth() - minWidth,
|
||||
frmOutlineView.setBounds(tp.x + editor.getTextArea().getWidth() - minWidth,
|
||||
tp.y,
|
||||
minWidth,
|
||||
estimateFrameHeight());
|
||||
frmOutlineView.setMinimumSize(new Dimension(minWidth, Math
|
||||
.min(errorCheckerService.getEditor().getTextArea().getHeight(),
|
||||
.min(editor.getTextArea().getHeight(),
|
||||
frmOutlineView.getHeight())));
|
||||
frmOutlineView.setLocation(tp.x + errorCheckerService.getEditor().getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2,
|
||||
frmOutlineView.setLocation(tp.x + editor.getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2,
|
||||
frmOutlineView.getY() + (editor.getTextArea().getHeight() - frmOutlineView.getHeight()) / 2);
|
||||
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tabTree.getCellRenderer();
|
||||
renderer.setLeafIcon(null);
|
||||
@@ -202,7 +200,7 @@ public class TabOutline {
|
||||
protected Object doInBackground() throws Exception {
|
||||
String text = searchField.getText().toLowerCase();
|
||||
tempNode = new DefaultMutableTreeNode();
|
||||
filterTree(text, tempNode, tabNode);
|
||||
filterTree(text, tempNode, tabNode); // TODO: is using tabNode thread-safe? [jv]
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -223,31 +221,21 @@ public class TabOutline {
|
||||
tabTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
|
||||
if (internalSelection) {
|
||||
//log("Internal selection");
|
||||
internalSelection = (false);
|
||||
return;
|
||||
}
|
||||
// log(e);
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
if (tabTree.getLastSelectedPathComponent() == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) tabTree
|
||||
.getLastSelectedPathComponent();
|
||||
//log("Clicked " + tnode);
|
||||
switchToTab(tnode.toString());
|
||||
close();
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
if (tabTree.getLastSelectedPathComponent() == null) {
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) tabTree
|
||||
.getLastSelectedPathComponent();
|
||||
//log("Clicked " + tnode);
|
||||
switchToTab(tnode.toString());
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.eclipse.text.edits.TextEdit;
|
||||
|
||||
import processing.app.Util;
|
||||
import processing.data.StringList;
|
||||
import processing.mode.java.JavaEditor;
|
||||
import processing.mode.java.preproc.PdePreprocessor;
|
||||
|
||||
|
||||
@@ -47,17 +48,17 @@ import processing.mode.java.preproc.PdePreprocessor;
|
||||
public class XQPreprocessor {
|
||||
private ASTRewrite rewrite = null;
|
||||
private List<ImportStatement> extraImports;
|
||||
private ErrorCheckerService ecs;
|
||||
private final JavaEditor editor;
|
||||
private String[] coreImports;
|
||||
private String[] defaultImports;
|
||||
|
||||
|
||||
public XQPreprocessor(ErrorCheckerService ecs) {
|
||||
this.ecs = ecs;
|
||||
public XQPreprocessor(JavaEditor editor) {
|
||||
this.editor = editor;
|
||||
|
||||
// get parameters from the main preproc
|
||||
// PdePreprocessor p = new PdePreprocessor(null);
|
||||
PdePreprocessor p = ecs.editor.createPreprocessor(null);
|
||||
PdePreprocessor p = editor.createPreprocessor(null);
|
||||
defaultImports = p.getDefaultImports();
|
||||
coreImports = p.getCoreImports();
|
||||
}
|
||||
@@ -105,16 +106,16 @@ public class XQPreprocessor {
|
||||
for (String imp : defaultImports) {
|
||||
imports.append("import " + imp + ";");
|
||||
}
|
||||
if (ecs.getEditor().getSketch().getCodeFolder().exists()) {
|
||||
if (editor.getSketch().getCodeFolder().exists()) {
|
||||
StringList codeFolderPackages = null;
|
||||
String codeFolderClassPath = Util.contentsToClassPath(ecs.getEditor().getSketch().getCodeFolder());
|
||||
String codeFolderClassPath = Util.contentsToClassPath(editor.getSketch().getCodeFolder());
|
||||
codeFolderPackages = Util.packageListFromClassPath(codeFolderClassPath);
|
||||
if (codeFolderPackages != null) {
|
||||
ecs.codeFolderImports.clear();
|
||||
editor.getErrorChecker().codeFolderImports.clear();
|
||||
for (String item : codeFolderPackages) {
|
||||
// Messages.log("CF import " + item);
|
||||
imports.append("import " + item + ".*;");
|
||||
ecs.codeFolderImports.add(new ImportStatement("import " + item + ".*;",0,0));
|
||||
editor.getErrorChecker().codeFolderImports.add(new ImportStatement("import " + item + ".*;",0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user