Skip to content

Commit 8e8c72d

Browse files
committed
finish merge of DebugEditor, move vars around, clean up accessors and menus
1 parent d5d7c14 commit 8e8c72d

File tree

9 files changed

+300
-340
lines changed

9 files changed

+300
-340
lines changed

app/src/processing/app/Mode.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,15 +1176,25 @@ public void run() {
11761176
});
11771177
}
11781178

1179-
/**
1180-
* Get an image object from the theme folder.
1179+
1180+
/**
1181+
* Get an ImageIcon object from the mode folder.
1182+
* @since 3.0a6
11811183
*/
1182-
public Image loadImage(String filename) {
1184+
public ImageIcon loadIcon(String filename) {
11831185
File file = new File(folder, filename);
11841186
if (!file.exists()) {
11851187
return null;
11861188
}
1187-
return new ImageIcon(file.getAbsolutePath()).getImage();
1189+
return new ImageIcon(file.getAbsolutePath());
1190+
}
1191+
1192+
1193+
/**
1194+
* Get an image object from the mode folder.
1195+
*/
1196+
public Image loadImage(String filename) {
1197+
return loadIcon(filename).getImage();
11881198
}
11891199

11901200

java/src/processing/mode/java/JavaEditor.java

Lines changed: 247 additions & 311 deletions
Large diffs are not rendered by default.

java/src/processing/mode/java/JavaMode.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import java.util.logging.Level;
3030
import java.util.logging.Logger;
3131

32-
import javax.swing.ImageIcon;
33-
3432
import processing.app.*;
3533
import processing.mode.java.runner.Runner;
3634
import processing.mode.java.tweak.SketchParser;
@@ -48,7 +46,6 @@ public JavaMode(Base base, File folder) {
4846

4947
initLogger();
5048
loadPreferences();
51-
loadIcons();
5249
}
5350

5451

@@ -277,19 +274,15 @@ void initLogger() {
277274
}
278275

279276

280-
public ImageIcon classIcon, fieldIcon, methodIcon, localVarIcon;
281-
282-
protected void loadIcons(){
283-
String iconPath = getContentFile("data").getAbsolutePath() + File.separator + "icons";
284-
classIcon = new ImageIcon(iconPath + File.separator + "class_obj.png");
285-
methodIcon = new ImageIcon(iconPath + File.separator
286-
+ "methpub_obj.png");
287-
fieldIcon = new ImageIcon(iconPath + File.separator
288-
+ "field_protected_obj.png");
289-
localVarIcon = new ImageIcon(iconPath + File.separator
290-
+ "field_default_obj.png");
291-
// log("Icons loaded");
292-
}
277+
//ImageIcon classIcon, fieldIcon, methodIcon, localVarIcon;
278+
279+
// protected void loadIcons() {
280+
// String iconPath = getContentFile("data").getAbsolutePath() + File.separator + "icons";
281+
// classIcon = new ImageIcon(iconPath + File.separator + "class_obj.png");
282+
// methodIcon = new ImageIcon(iconPath + File.separator + "methpub_obj.png");
283+
// fieldIcon = new ImageIcon(iconPath + File.separator + "field_protected_obj.png");
284+
// localVarIcon = new ImageIcon(iconPath + File.separator + "field_default_obj.png");
285+
// }
293286

294287

295288
static public volatile boolean errorCheckEnabled = true;

java/src/processing/mode/java/pdex/CompletionPanel.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.awt.event.MouseEvent;
3434

3535
import javax.swing.DefaultListModel;
36+
import javax.swing.ImageIcon;
3637
import javax.swing.JButton;
3738
import javax.swing.JComponent;
3839
import javax.swing.JLabel;
@@ -50,6 +51,7 @@
5051
import javax.swing.text.BadLocationException;
5152

5253
import processing.app.Base;
54+
import processing.app.Mode;
5355
import processing.app.syntax.JEditTextArea;
5456
import processing.mode.java.JavaEditor;
5557

@@ -91,6 +93,9 @@ public class CompletionPanel {
9193

9294
public static final int MOUSE_COMPLETION = 10, KEYBOARD_COMPLETION = 20;
9395

96+
ImageIcon classIcon, fieldIcon, methodIcon, localVarIcon;
97+
98+
9499
/**
95100
* Triggers the completion popup
96101
* @param textarea
@@ -123,6 +128,12 @@ public CompletionPanel(final JEditTextArea textarea, int position, String subWor
123128
popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0)
124129
+ location.y);
125130
//log("Suggestion shown: " + System.currentTimeMillis());
131+
132+
Mode mode = editor.getMode();
133+
classIcon = mode.loadIcon("theme/icon_class_obj.png");
134+
methodIcon = mode.loadIcon("theme/icon_methpub_obj.png");
135+
fieldIcon = mode.loadIcon("theme/icon_field_protected_obj.png");
136+
localVarIcon = mode.loadIcon("theme/icon_field_default_obj.png");
126137
}
127138

128139
private void styleScrollPane() {
@@ -199,7 +210,7 @@ private int calcHeight(int itemCount) {
199210
int maxHeight = 250;
200211
FontMetrics fm = textarea.getGraphics().getFontMetrics();
201212
float itemHeight = Math.max((fm.getHeight() + (fm.getDescent()) * 0.5f),
202-
editor.dmode.classIcon.getIconHeight() * 1.2f);
213+
classIcon.getIconHeight() * 1.2f);
203214

204215
if (horizontalScrollBarVisible)
205216
itemCount++;
@@ -233,7 +244,7 @@ private int calcWidth() {
233244
int w = Math.min((int) min, maxWidth);
234245
if(w == maxWidth)
235246
horizontalScrollBarVisible = true;
236-
w += editor.dmode.classIcon.getIconWidth(); // add icon width too!
247+
w += classIcon.getIconWidth(); // add icon width too!
237248
w += fm.stringWidth(" "); // a bit of offset
238249
//log("popup width " + w);
239250
return w; // popup menu width
@@ -545,19 +556,19 @@ public Component getListCellRendererComponent(JList<?> list, Object value,
545556
CompletionCandidate cc = (CompletionCandidate) value;
546557
switch (cc.getType()) {
547558
case CompletionCandidate.LOCAL_VAR:
548-
label.setIcon(editor.dmode.localVarIcon);
559+
label.setIcon(localVarIcon);
549560
break;
550561
case CompletionCandidate.LOCAL_FIELD:
551562
case CompletionCandidate.PREDEF_FIELD:
552-
label.setIcon(editor.dmode.fieldIcon);
563+
label.setIcon(fieldIcon);
553564
break;
554565
case CompletionCandidate.LOCAL_METHOD:
555566
case CompletionCandidate.PREDEF_METHOD:
556-
label.setIcon(editor.dmode.methodIcon);
567+
label.setIcon(methodIcon);
557568
break;
558569
case CompletionCandidate.LOCAL_CLASS:
559570
case CompletionCandidate.PREDEF_CLASS:
560-
label.setIcon(editor.dmode.classIcon);
571+
label.setIcon(classIcon);
561572
break;
562573

563574
default:

java/src/processing/mode/java/pdex/SketchOutline.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import javax.swing.BoxLayout;
3535
import javax.swing.Icon;
36+
import javax.swing.ImageIcon;
3637
import javax.swing.JFrame;
3738
import javax.swing.JPanel;
3839
import javax.swing.JScrollPane;
@@ -55,6 +56,7 @@
5556
import org.eclipse.jdt.core.dom.TypeDeclaration;
5657
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
5758

59+
import processing.app.Mode;
5860
import processing.mode.java.JavaEditor;
5961

6062

@@ -68,6 +70,8 @@ public class SketchOutline {
6870
protected JavaEditor editor;
6971
protected boolean internalSelection = false;
7072

73+
ImageIcon classIcon, fieldIcon, methodIcon;
74+
7175

7276
public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) {
7377
errorCheckerService = ecs;
@@ -77,6 +81,12 @@ public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) {
7781
soNode = (DefaultMutableTreeNode) soNode.getChildAt(0);
7882
tempNode = soNode;
7983
soTree = new JTree(soNode);
84+
85+
Mode mode = editor.getMode();
86+
classIcon = mode.loadIcon("theme/icon_class_obj.png");
87+
methodIcon = mode.loadIcon("theme/icon_methpub_obj.png");
88+
fieldIcon = mode.loadIcon("theme/icon_field_protected_obj.png");
89+
8090
createGUI();
8191
}
8292

@@ -386,11 +396,11 @@ public Icon getTreeIcon(Object o) {
386396

387397
int type = awrap.getNode().getParent().getNodeType();
388398
if (type == ASTNode.METHOD_DECLARATION) {
389-
return editor.dmode.methodIcon;
399+
return methodIcon;
390400
} else if (type == ASTNode.TYPE_DECLARATION) {
391-
return editor.dmode.classIcon;
401+
return classIcon;
392402
} else if (type == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
393-
return editor.dmode.fieldIcon;
403+
return fieldIcon;
394404
}
395405
}
396406
return null;

0 commit comments

Comments
 (0)