| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1176,15 +1176,25 @@ public void run() { | |||
| 1176 | 1176 | }); | |
| 1177 | 1177 | } | |
| 1178 | 1178 | ||
| 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 | ||
| 1181 | 1183 | */ | |
| 1182 | - public Image loadImage(String filename) { | ||
| 1184 | + public ImageIcon loadIcon(String filename) { | ||
| 1183 | 1185 | File file = new File(folder, filename); | |
| 1184 | 1186 | if (!file.exists()) { | |
| 1185 | 1187 | return null; | |
| 1186 | 1188 | } | |
| 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(); | ||
| 1188 | 1198 | } | |
| 1189 | 1199 | ||
| 1190 | 1200 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,8 +29,6 @@ | |||
| 29 | 29 | import java.util.logging.Level; | |
| 30 | 30 | import java.util.logging.Logger; | |
| 31 | 31 | ||
| 32 | - import javax.swing.ImageIcon; | ||
| 33 | - | ||
| 34 | 32 | import processing.app.*; | |
| 35 | 33 | import processing.mode.java.runner.Runner; | |
| 36 | 34 | import processing.mode.java.tweak.SketchParser; | |
@@ -48,7 +46,6 @@ public JavaMode(Base base, File folder) { | |||
| 48 | 46 | ||
| 49 | 47 | initLogger(); | |
| 50 | 48 | loadPreferences(); | |
| 51 | - loadIcons(); | ||
| 52 | 49 | } | |
| 53 | 50 | ||
| 54 | 51 | ||
@@ -277,19 +274,15 @@ void initLogger() { | |||
| 277 | 274 | } | |
| 278 | 275 | ||
| 279 | 276 | ||
| 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 | + // } | ||
| 293 | 286 | ||
| 294 | 287 | ||
| 295 | 288 | static public volatile boolean errorCheckEnabled = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ | |||
| 33 | 33 | import java.awt.event.MouseEvent; | |
| 34 | 34 | ||
| 35 | 35 | import javax.swing.DefaultListModel; | |
| 36 | + import javax.swing.ImageIcon; | ||
| 36 | 37 | import javax.swing.JButton; | |
| 37 | 38 | import javax.swing.JComponent; | |
| 38 | 39 | import javax.swing.JLabel; | |
@@ -50,6 +51,7 @@ | |||
| 50 | 51 | import javax.swing.text.BadLocationException; | |
| 51 | 52 | ||
| 52 | 53 | import processing.app.Base; | |
| 54 | + import processing.app.Mode; | ||
| 53 | 55 | import processing.app.syntax.JEditTextArea; | |
| 54 | 56 | import processing.mode.java.JavaEditor; | |
| 55 | 57 | ||
@@ -91,6 +93,9 @@ public class CompletionPanel { | |||
| 91 | 93 | ||
| 92 | 94 | public static final int MOUSE_COMPLETION = 10, KEYBOARD_COMPLETION = 20; | |
| 93 | 95 | ||
| 96 | + ImageIcon classIcon, fieldIcon, methodIcon, localVarIcon; | ||
| 97 | + | ||
| 98 | + | ||
| 94 | 99 | /** | |
| 95 | 100 | * Triggers the completion popup | |
| 96 | 101 | * @param textarea | |
@@ -123,6 +128,12 @@ public CompletionPanel(final JEditTextArea textarea, int position, String subWor | |||
| 123 | 128 | popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) | |
| 124 | 129 | + location.y); | |
| 125 | 130 | //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"); | ||
| 126 | 137 | } | |
| 127 | 138 | ||
| 128 | 139 | private void styleScrollPane() { | |
@@ -199,7 +210,7 @@ private int calcHeight(int itemCount) { | |||
| 199 | 210 | int maxHeight = 250; | |
| 200 | 211 | FontMetrics fm = textarea.getGraphics().getFontMetrics(); | |
| 201 | 212 | float itemHeight = Math.max((fm.getHeight() + (fm.getDescent()) * 0.5f), | |
| 202 | - editor.dmode.classIcon.getIconHeight() * 1.2f); | ||
| 213 | + classIcon.getIconHeight() * 1.2f); | ||
| 203 | 214 | ||
| 204 | 215 | if (horizontalScrollBarVisible) | |
| 205 | 216 | itemCount++; | |
@@ -233,7 +244,7 @@ private int calcWidth() { | |||
| 233 | 244 | int w = Math.min((int) min, maxWidth); | |
| 234 | 245 | if(w == maxWidth) | |
| 235 | 246 | horizontalScrollBarVisible = true; | |
| 236 | - w += editor.dmode.classIcon.getIconWidth(); // add icon width too! | ||
| 247 | + w += classIcon.getIconWidth(); // add icon width too! | ||
| 237 | 248 | w += fm.stringWidth(" "); // a bit of offset | |
| 238 | 249 | //log("popup width " + w); | |
| 239 | 250 | return w; // popup menu width | |
@@ -545,19 +556,19 @@ public Component getListCellRendererComponent(JList<?> list, Object value, | |||
| 545 | 556 | CompletionCandidate cc = (CompletionCandidate) value; | |
| 546 | 557 | switch (cc.getType()) { | |
| 547 | 558 | case CompletionCandidate.LOCAL_VAR: | |
| 548 | - label.setIcon(editor.dmode.localVarIcon); | ||
| 559 | + label.setIcon(localVarIcon); | ||
| 549 | 560 | break; | |
| 550 | 561 | case CompletionCandidate.LOCAL_FIELD: | |
| 551 | 562 | case CompletionCandidate.PREDEF_FIELD: | |
| 552 | - label.setIcon(editor.dmode.fieldIcon); | ||
| 563 | + label.setIcon(fieldIcon); | ||
| 553 | 564 | break; | |
| 554 | 565 | case CompletionCandidate.LOCAL_METHOD: | |
| 555 | 566 | case CompletionCandidate.PREDEF_METHOD: | |
| 556 | - label.setIcon(editor.dmode.methodIcon); | ||
| 567 | + label.setIcon(methodIcon); | ||
| 557 | 568 | break; | |
| 558 | 569 | case CompletionCandidate.LOCAL_CLASS: | |
| 559 | 570 | case CompletionCandidate.PREDEF_CLASS: | |
| 560 | - label.setIcon(editor.dmode.classIcon); | ||
| 571 | + label.setIcon(classIcon); | ||
| 561 | 572 | break; | |
| 562 | 573 | ||
| 563 | 574 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | 34 | import javax.swing.BoxLayout; | |
| 35 | 35 | import javax.swing.Icon; | |
| 36 | + import javax.swing.ImageIcon; | ||
| 36 | 37 | import javax.swing.JFrame; | |
| 37 | 38 | import javax.swing.JPanel; | |
| 38 | 39 | import javax.swing.JScrollPane; | |
@@ -55,6 +56,7 @@ | |||
| 55 | 56 | import org.eclipse.jdt.core.dom.TypeDeclaration; | |
| 56 | 57 | import org.eclipse.jdt.core.dom.VariableDeclarationFragment; | |
| 57 | 58 | ||
| 59 | + import processing.app.Mode; | ||
| 58 | 60 | import processing.mode.java.JavaEditor; | |
| 59 | 61 | ||
| 60 | 62 | ||
@@ -68,6 +70,8 @@ public class SketchOutline { | |||
| 68 | 70 | protected JavaEditor editor; | |
| 69 | 71 | protected boolean internalSelection = false; | |
| 70 | 72 | ||
| 73 | + ImageIcon classIcon, fieldIcon, methodIcon; | ||
| 74 | + | ||
| 71 | 75 | ||
| 72 | 76 | public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) { | |
| 73 | 77 | errorCheckerService = ecs; | |
@@ -77,6 +81,12 @@ public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) { | |||
| 77 | 81 | soNode = (DefaultMutableTreeNode) soNode.getChildAt(0); | |
| 78 | 82 | tempNode = soNode; | |
| 79 | 83 | 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 | + | ||
| 80 | 90 | createGUI(); | |
| 81 | 91 | } | |
| 82 | 92 | ||
@@ -386,11 +396,11 @@ public Icon getTreeIcon(Object o) { | |||
| 386 | 396 | ||
| 387 | 397 | int type = awrap.getNode().getParent().getNodeType(); | |
| 388 | 398 | if (type == ASTNode.METHOD_DECLARATION) { | |
| 389 | - return editor.dmode.methodIcon; | ||
| 399 | + return methodIcon; | ||
| 390 | 400 | } else if (type == ASTNode.TYPE_DECLARATION) { | |
| 391 | - return editor.dmode.classIcon; | ||
| 401 | + return classIcon; | ||
| 392 | 402 | } else if (type == ASTNode.VARIABLE_DECLARATION_FRAGMENT) { | |
| 393 | - return editor.dmode.fieldIcon; | ||
| 403 | + return fieldIcon; | ||
| 394 | 404 | } | |
| 395 | 405 | } | |
| 396 | 406 | return null; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments