diff --git a/app/src/processing/app/ui/EditorFooter.java b/app/src/processing/app/ui/EditorFooter.java index cf2ea561f..f81e41465 100644 --- a/app/src/processing/app/ui/EditorFooter.java +++ b/app/src/processing/app/ui/EditorFooter.java @@ -41,6 +41,7 @@ import javax.swing.*; import processing.app.Mode; import processing.app.Sketch; +import processing.app.contrib.ContributionManager; /** @@ -70,7 +71,9 @@ public class EditorFooter extends Box { Color[] textColor = new Color[2]; Color[] tabColor = new Color[2]; + Color updateColor; + int updateLeft, updateRight; Editor editor; @@ -188,6 +191,9 @@ public class EditorFooter extends Box { repaint(); } } + if (x > updateLeft) { + ContributionManager.openUpdates(); + } } }); } @@ -297,7 +303,8 @@ public class EditorFooter extends Box { g2.drawString(updatesStr, (int) (ex + (diameter - countWidth)/2), baseline); double updatesWidth = font.getStringBounds(updateLabel, frc).getWidth(); g2.setColor(textColor[UNSELECTED]); - g2.drawString(updateLabel, (int) (ex - updatesWidth - GAP), baseline); + updateLeft = (int) (ex - updatesWidth - GAP); + g2.drawString(updateLabel, updateLeft, baseline); } } diff --git a/app/src/processing/app/ui/Toolkit.java b/app/src/processing/app/ui/Toolkit.java index 2d6458070..e1389d191 100644 --- a/app/src/processing/app/ui/Toolkit.java +++ b/app/src/processing/app/ui/Toolkit.java @@ -489,12 +489,8 @@ public class Toolkit { } - /** - * Get an image icon with hi-dpi support. Pulls 1x or 2x versions of the - * file depending on the display type, but sizes them based on 1x. - */ - static public ImageIcon getLibIconX(String base) { - return getLibIconX(base, 0); + static public ImageIcon getIconX(File dir, String base) { + return getIconX(dir, base, 0); } @@ -502,12 +498,13 @@ public class Toolkit { * Get an icon of the format base-NN.png where NN is the size, but if it's * a hidpi display, get the NN*2 version automatically, sized at NN */ - static public ImageIcon getLibIconX(String base, int size) { + static public ImageIcon getIconX(File dir, String base, int size) { final int scale = Toolkit.highResDisplay() ? 2 : 1; String filename = (size == 0) ? (base + "-" + scale + "x.png") : (base + "-" + (size*scale) + ".png"); - File file = Platform.getContentFile("lib/" + filename); +// File file = Platform.getContentFile("lib/" + filename); + File file = new File(dir, filename); if (!file.exists()) { // System.err.println("does not exist: " + file); return null; @@ -536,6 +533,20 @@ public class Toolkit { } + /** + * Get an image icon with hi-dpi support. Pulls 1x or 2x versions of the + * file depending on the display type, but sizes them based on 1x. + */ + static public ImageIcon getLibIconX(String base) { + return getLibIconX(base, 0); + } + + + static public ImageIcon getLibIconX(String base, int size) { + return getIconX(Platform.getContentFile("lib"), base, size); + } + + static List iconImages; diff --git a/java/src/processing/mode/java/pdex/CompletionPanel.java b/java/src/processing/mode/java/pdex/CompletionPanel.java index 49f58b845..47b2ddf18 100644 --- a/java/src/processing/mode/java/pdex/CompletionPanel.java +++ b/java/src/processing/mode/java/pdex/CompletionPanel.java @@ -21,37 +21,27 @@ along with this program; if not, write to the Free Software Foundation, Inc. package processing.mode.java.pdex; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.Point; -import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; -import javax.swing.Painter; -import javax.swing.UIDefaults; -import javax.swing.UIManager; -import javax.swing.plaf.InsetsUIResource; -import javax.swing.plaf.basic.BasicScrollBarUI; import javax.swing.text.BadLocationException; import processing.app.Base; import processing.app.Messages; import processing.app.Mode; import processing.app.syntax.JEditTextArea; +import processing.app.ui.Toolkit; import processing.mode.java.JavaEditor; @@ -117,15 +107,43 @@ public class CompletionPanel { this.subWord = subWord; } - loadIcons(); + if (classIcon == null) { + File dir = new File(editor.getMode().getFolder(), "theme/completion"); + classIcon = Toolkit.getIconX(dir, "class_obj"); + methodIcon = Toolkit.getIconX(dir, "methpub_obj"); + fieldIcon = Toolkit.getIconX(dir, "field_protected_obj"); + localVarIcon = Toolkit.getIconX(dir, "field_default_obj"); + } + popupMenu = new JPopupMenu(); popupMenu.removeAll(); popupMenu.setOpaque(false); popupMenu.setBorder(null); scrollPane = new JScrollPane(); - styleScrollPane(); - scrollPane.setViewportView(completionList = createSuggestionList(position, items)); +// styleScrollPane(); + //scrollPane.setViewportView(completionList = createSuggestionList(position, items)); + completionList = new JList(items) { + { + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + setSelectedIndex(0); + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + insertSelection(MOUSE_COMPLETION); + setInvisible(); + } + } + }); + setCellRenderer(new CustomListRenderer()); + setFocusable(false); + } + }; + scrollPane.setViewportView(completionList); + // remove an ugly multi-line border around it + scrollPane.setBorder(null); + popupMenu.add(scrollPane, BorderLayout.CENTER); popupMenu.setPopupSize(calcWidth(), calcHeight(items.getSize())); //TODO: Eradicate this evil popupMenu.setFocusable(false); @@ -138,17 +156,7 @@ public class CompletionPanel { } - private void loadIcons() { - if (classIcon == null) { - Mode mode = editor.getMode(); - classIcon = mode.loadIcon("theme/completion/class_obj.png"); - methodIcon = mode.loadIcon("theme/completion/methpub_obj.png"); - fieldIcon = mode.loadIcon("theme/completion/field_protected_obj.png"); - localVarIcon = mode.loadIcon("theme/completion/field_default_obj.png"); - } - } - - + /* private void styleScrollPane() { String laf = UIManager.getLookAndFeel().getID(); if (!laf.equals("Nimbus") && !laf.equals("Windows")) return; @@ -205,6 +213,7 @@ public class CompletionPanel { return jbutton; } } + */ public boolean isVisible() { @@ -270,7 +279,6 @@ public class CompletionPanel { * @param position * @param items * @return - */ private JList createSuggestionList(final int position, final DefaultListModel items) { @@ -291,6 +299,7 @@ public class CompletionPanel { list.setFocusable(false); return list; } + */ /* @@ -333,8 +342,8 @@ public class CompletionPanel { try { // If user types 'abc.', subword becomes '.' and null is returned String currentSubword = fetchCurrentSubword(); - int currentSubwordLen = currentSubword == null ? 0 : currentSubword - .length(); + int currentSubwordLen = + (currentSubword == null) ? 0 : currentSubword.length(); //logE(currentSubword + " <= subword,len => " + currentSubword.length()); String selectedSuggestion = completionList.getSelectedValue().getCompletionString(); @@ -346,13 +355,12 @@ public class CompletionPanel { } String completionString = - completionList.getSelectedValue().getCompletionString(); + completionList.getSelectedValue().getCompletionString(); if (selectedSuggestion.endsWith(" )")) { // the case of single param methods // selectedSuggestion = ")"; if (completionString.endsWith(" )")) { - completionString = completionString.substring(0, completionString - .length() - 2) - + ")"; + completionString = + completionString.substring(0, completionString.length() - 2) + ")"; } } @@ -365,20 +373,19 @@ public class CompletionPanel { } } - Messages.loge(subWord + " <= subword, Inserting suggestion=> " - + selectedSuggestion + " Current sub: " + currentSubword); + Messages.loge(subWord + " <= subword, Inserting suggestion=> " + + selectedSuggestion + " Current sub: " + currentSubword); if (currentSubword.length() > 0) { textarea.getDocument().remove(insertionPosition - currentSubwordLen, currentSubwordLen); } - textarea.getDocument() - .insertString(insertionPosition - currentSubwordLen, - completionString, null); + textarea.getDocument().insertString(insertionPosition - currentSubwordLen, + completionString, null); if (selectedSuggestion.endsWith(")") && !selectedSuggestion.endsWith("()")) { // place the caret between '( and first ',' int x = selectedSuggestion.indexOf(','); - if(x == -1) { + if (x == -1) { // the case of single param methods, containing no ',' textarea.setCaretPosition(textarea.getCaretPosition() - 1); // just before ')' } else { @@ -395,12 +402,12 @@ public class CompletionPanel { setInvisible(); } - if(mouseClickOnOverloadedMethods) { + if (mouseClickOnOverloadedMethods) { // See #2755 ((JavaTextArea) editor.getTextArea()).fetchPhrase(); } - return true; + } catch (BadLocationException e1) { e1.printStackTrace(); } catch (Exception e) { diff --git a/todo.txt b/todo.txt index 9b2aceea2..a7133ffa6 100644 --- a/todo.txt +++ b/todo.txt @@ -21,6 +21,9 @@ X https://github.com/processing/processing/issues/3518 X https://github.com/processing/processing/pull/3896 X https://github.com/processing/processing/pull/3901 o total number of updates available is not correct? (may be fixed) +o ArrayIndexOutOfBoundsException freak out when clicking the header line +o think this was on name, with libraries, but not sure +X should be fixed with the updates from Jakub gui X distinguish errors and warnings @@ -57,6 +60,11 @@ X implement custom tooltip for error/warning hover X applies to both MarkerColumn and JavaTextAreaPainter X make gutter of console match error list X https://github.com/processing/processing/issues/3904 +o bring back the # of updates on the update tab +o use this instead of the 'icon' stuff? +o or in addition, since only the 'updates' tab has it +X https://github.com/processing/processing/issues/3855 +X for updates available, have it be clickable to open the manager earlier/cleaning X list with contrib types separated is really wonky @@ -82,10 +90,11 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice 3.0 final _ https://github.com/processing/processing/milestones/3.0%20final _ fix the design of the completions window -_ remove extra border around the outside +X remove extra border around the outside _ change font _ change selection highlight color _ put some margin around it +X add 2x version of the icons _ https://github.com/processing/processing/issues/3906 _ import suggestions box needs design review _ https://github.com/processing/processing/issues/3407 @@ -94,11 +103,6 @@ _ easy to do inside JavaTextAreaPainter.paintSquiggle() manager / 3.0 final -_ bring back the # of updates on the update tab -_ use this instead of the 'icon' stuff? -_ or in addition, since only the 'updates' tab has it -_ https://github.com/processing/processing/issues/3855 -_ for updates available, have it be clickable to open the manager _ ugly white gap at the top of scroll bar _ the table header doesn't extend far enough _ scrolling "past" top/bottom causes the screen to jiggle (OS X and Trackpad) @@ -126,8 +130,6 @@ _ https://github.com/processing/processing/issues/136 manager / post 3.0 _ Examples window closes and re-opens during library install/remove _ https://github.com/processing/processing/issues/3304 -_ ArrayIndexOutOfBoundsException freak out when clicking the header line -_ think this was on name, with libraries, but not sure _ CM - Icon instead of an "X" for the "could not connect" message _ https://github.com/processing/processing/issues/3706